AB3DMT-3DModel

AB3DMT-3DModel preview image

1 collaborator

%e6%88%91 Donghua Chen (Author)

Tags

3d-environment 

Tagged by Donghua Chen over 2 years ago

3d-model 

Tagged by Donghua Chen over 2 years ago

ab3dmt 

Tagged by Donghua Chen over 2 years ago

point-cloud 

Tagged by Donghua Chen over 2 years ago

Part of project 'Agent-based 3D Modeling'
Visible to everyone | Changeable by the author
Model was written in NetLogo 3D 6.2.1 • Viewed 339 times • Downloaded 12 times • Run 0 times
Download the 'AB3DMT-3DModel' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


## WHAT IS IT?

The AB3DMT-3DModel model is created by [Donghua Chen](https://dhchenx.github.io).

This is a NetLogo 3D model to demonstrate the use of 3D point clouds from existing 3D models. This model is a part of our agent-based 3D modeling toolkit (AB3DMT) platform that facilitates the use of 3D modeling in NetLogo 3D simulation.

Date of model: 2022-08-03

## HOW IT WORKS

First, a csv file that contains 3D point information with the row format [id, x, y, z] is used. Please refer to our sample file "male.csv" for other 3D model transformation.

With the use of the csv file that contains point coordinates, we then develope a csv reader to tranform the point cloud into agent sets in NetLogo, thus you can see the 3D model in NetLogo 3D world.

Future 3D models should be firstly tranformed into a csv-formatted file as shown above and can be imported in NetLogo.

Due to a flexible world size needed to show the entire 3D model with different scales of coordinates respectively, we introduced a function to infer the world size needed to show the entire 3D model.

Finally, the 3D agent sets are created in the redefined NetLogo 3D world.

## HOW TO USE IT

When you download the NetLogo file and the "male.csv" sample file, you can follow the steps:

Step 1: Select model - please click the "select model" button and choose the "male.csv" file.

Step 2: Infer world size - after selecting the model, please click the button to infer world size according to the input file. This stage will not create agent sets. Or you can change values of sliders about world-size (x, y , z) and click the 'define-world-size' button to create your own world size.

Step 3: Load 3D model - after resizing the world size, we start to load the model and convert the points to agents in NetLogo 3D. Thus, a 3D-alike agent-based model is establshed.

Step 4: Press "go" button for a sample simuation that randomly visit neighbor agents on the agent-based 3D model.

## THINGS TO NOTICE

This model works in NetLogo 3D 6.2.1.

## THINGS TO TRY

With the established agent-based 3D model in NetLogo 3D, you can perform various agent-based methods to simulate cases in the 3D context with great complexity.

You may import other 3D models into NetLogo following the csv format.

## EXTENDING THE MODEL

We are working on the development of high-level agent-basel modeling in 3D environment, please refer to my GitHub project: https://github.com/dhchenx/AB3DMT.

Please let us know if there is any problem in: https://github.com/dhchenx/AB3DMT/issues

## HOW TO CITE

The model's project page: https://github.com/dhchenx/AB3DMT

Please cite our GitHub project if the model is used in your research.

Donghua Chen (2022). Agent-based 3D modeling toolkit (Version 0.0.7) [Source code]. https://github.com/dhchenx/AB3DMT. [2022-08-03].

## COPYRIGHT AND LICENSE

Copyright 2022 Donghua Chen

License: MIT

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

; The AB3DMT-3DModel model is created by [Donghua Chen](https://dhchenx.github.io).

; This is a NetLogo 3D model to demonstrate the use of 3D point clouds from existing 3D models.
; This model is a part of our agent-based 3D modeling toolkit (AB3DMT) platform that facilitates the use of 3D modeling in NetLogo 3D simulation.
; Date of model: 2022-08-03

; Please cite our GitHub project if the model is used in your research.
; Donghua Chen (2022). Agent-based 3D modeling toolkit (Version 0.0.7) [Source code]. https://github.com/dhchenx/AB3DMT. [2022-08-03].

; License: MIT

extensions[
  csv
]

turtles-own[object-type]


globals[
  current
  min_x max_x
  min_y max_y
  min_z max_z
  total-points

]

to setup
  ; clear world
   clear-all
   reset-ticks
   reset-timer
    set total-points 0
  set model-path ""
end 

to select-3d-model
  let selected-file user-file
  if selected-file != false [
    set model-path selected-file
  ]
end 

to load-3d-model
  open-3d-model model-path true
end 

to open-3d-model [current-model-file should-create]

  if current-model-file = "" [
   user-message "Please select a 3D model"
   stop
  ]

  ; clear world
   clear-all
   reset-ticks
   reset-timer
    set total-points 0

  ; create X, Y and Z axis
  if show-axis = true [
  create-turtles 1 [ set shape "line"
          set heading 90
          set color red
          set size world-width
          stamp
          die ]
  create-turtles 1 [ set shape "line"
          set color yellow
          set heading 0
          set size world-height
          stamp
          die ]
  create-turtles 1 [ set shape "line"
          set pitch 90
          set color blue
          set size world-depth
          stamp
          die ]

  ; Draw X, Y and Z axis line
  ask patch max-pxcor 0 0 [ set plabel "x-axis"  ]
  ask patch 0 max-pycor 0 [ set plabel "y-axis" ]
  ask patch 0 0 max-pzcor [ set plabel "z-axis" ]

  ]

  ; init temp variables
  set max_x -10000
  set min_x 10000
  set max_y -10000
  set min_y 10000
  set max_z -10000
  set min_z 10000
  set total-points 0
  let count1 0

  ; set current model-file variable to current-model-file
  set model-path current-model-file

  ; open the csv file
  file-open current-model-file
  let result csv:from-row file-read-line

  print (word "Starting importing..." current-model-file)
  while [ not file-at-end? ] [

    set count1 count1 + 1

    let row csv:from-row file-read-line
    ifelse count1 mod sample-rate != 0 [ ; use a point per sample-rate
      ; print("pass")
      ; pass
    ]
    [
    ; print(row)
    ; read points (x,y,z)
    let x item 1 row
    let y item 2 row
    let z item 3 row
    ; identify world size
    if x > max_x [ set max_x x]
    if x < min_x [ set min_x x]
    if y > max_y [ set max_y y]
    if y < min_y [ set min_y y]
    if z > max_z [ set max_z z]
    if z < min_z [ set min_z z]

    ; create an agent for each point
    if should-create = true [
    create-turtles 1 [
      set shape "dot"
      set xcor x * scale
      set ycor y * scale
      set zcor z * scale
      set size point-size
      set color blue
      set object-type "human"
    ]
      ]

      ; counter the total number of points
       set total-points total-points + 1
    ]


  ]
  file-close

  ; show world size [x, y, z]
  print (word "point counts: " total-points)
  print (word "x range: ["   min_x "," max_x "]")
  print (word "y range: ["   min_y "," max_y "]")
  print (word "z range: ["   min_z "," max_z "]")

  ; print (word total-points "\t" sample-rate "\t" timer "\t" scale  "\t["   precision min_x 2 "," precision max_x 2 "]" "\t["  precision min_y 2 "," precision max_y 2 "]" "\t["   precision min_z 2 "," precision max_z 2 "]")
  print (word total-points "\t" sample-rate "\t" timer "\t" scale  "\t"  precision (max_x - min_x) 2 "\t" precision (max_y - min_y) 2  "\t"  precision (max_z - min_z) 2 )
  ;
  print("Finished Importing!")

      set world-min-x int (min_x * scale * world-scale)
    set world-max-x int  (max_x * scale *  world-scale)
    set world-min-y int (min_y * scale * world-scale )
    set world-max-y int (max_y * scale * world-scale )
    set world-min-z int (min_z * scale * world-scale )
    set world-max-z int (max_z * scale * world-scale )

      ifelse world-max-x > 60 or world-max-y > 60 or world-max-z > 60 or world-min-x < -60 or world-min-y < -60 or world-min-z < -60  [
      user-message "world size may be too large? We have stopped resizing world size. you can manually set the world size later!"
    ][
       resize-world world-min-x world-max-x  world-min-y  world-max-y    world-min-z   world-max-z
    ]
end 

to infer-world-size
   open-3d-model model-path false
   resize-world world-min-x  world-max-x world-min-y  world-max-y  world-min-z  world-max-z
end 

to define-world-size
   resize-world world-min-x  world-max-x world-min-y  world-max-y  world-min-z  world-max-z
end 

to go

  if current = 0 [ set current one-of turtles with [object-type = "human"]]

    ask current[
    let all-near-turtles []
    ask neighbors6 [
      ask turtles-here with [object-type = "human"][
      set all-near-turtles lput self all-near-turtles
      set color pink

    ]
    ]

    ;ask patch-at dx dy dz[
    ;  ask turtles-here[
     ;   set color yellow
    ;  ]
    ;]

    ask turtles at-points [[0 0 0]][
     set color red - 1
    ]

    set current one-of all-near-turtles
    set color red
  ]
end 

There is only one version of this model, created over 2 years ago by Donghua Chen.

Attached files

File Type Description Last updated
AB3DMT-3DModel.png preview Preview for 'AB3DMT-3DModel' over 2 years ago, by Donghua Chen Download
male.csv data A sample 3D model file with point information over 2 years ago, by Donghua Chen Download

This model does not have any ancestors.

This model does not have any descendants.