AB3DMT-3DScanning

AB3DMT-3DScanning 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

Part of project 'Agent-based 3D Modeling'
Visible to everyone | Changeable by the author
Model was written in NetLogo 3D 6.2.1 • Viewed 271 times • Downloaded 12 times • Run 0 times
Download the 'AB3DMT-3DScanning' 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-3DScanning** model is created by [Donghua Chen](https://dhchenx.github.io).

This is a NetLogo 3D model to demonstrate the scanning use of 3D point clouds from existing 3D models. This model is a part of our agent-based 3D modeling toolkit ([AB3DMT](https://github.com/dhchenx/AB3DMT)) platform that facilitates the use of 3D modeling in NetLogo 3D simulation.

Author: Donghua Chen

Date of model: 2022-08-03

## HOW IT WORKS

After we import a 3D point cloud model into NetLogo 3D using our [AB3DMT-3DModel model](http://modelingcommons.org/browse/one_model/7047#model_tabs_browse_info), we can design three directional scanning agent-based methods, namely scan-x, scan-y and scan-z.

For example, the scan-x algoritm scans the 3D model from the lowest x value to largest x value along the axis. So are scan-y and scan-z algorithms.

There are three scanning settings:

- scan-thick: determine the length of scanning along the axis.

- render-part?: determine whether we should keep the scanned points with visited colors in a new scanning position.

- hide-cude?: determine whether the cube box should display during scanning.

## HOW TO USE IT

When you want to use this model, first, download all necessary file including:

- AB3DMT-3DScanning.nlogo3d

- AB3DMT-lib-3dmodel.nls

- sample 3D file: male.csv

Three above files are put in the same folder. Then you need to run the .nlogo3d file to start simulation.

Step 1: click SETUP button to initialize the model;

Step 2: clikc LOAD-MODEL button to load 3d points into NetLogo 3D. Then you should see a 3D model displaying in the NetLogo world;

Step 3: After the model is loaded, you can click the buttons like scan-x, scan-y or scan-z to examine the function of this toolkit.

## 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 by changing the default csv file in the NetLogo code.

## EXTENDING THE MODEL

We are working on the development of high-level agent-based modeling platform 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-3DScanning** model is created by [Donghua Chen](https://dhchenx.github.io).

; This is a NetLogo 3D model to demonstrate the scanning use of 3D point clouds from existing 3D models.
; This model is a part of our agent-based 3D modeling toolkit ([AB3DMT](https://github.com/dhchenx/AB3DMT)) platform
; that facilitates the use of 3D modeling in NetLogo 3D simulation.

; Author: Donghua Chen
; Date of model: 2022-08-03

extensions[
  csv
]

turtles-own[object-type]


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

]

__includes["AB3DMT-lib-3dmodel.nls"]

to setup
  ; clear world
  clear-all
  reset-ticks
  reset-timer
  set total-points 0
  set model-path "male.csv"
  set world-min-x -22
  set world-max-x 22
   set world-min-y -66
  set world-max-y 17
   set world-min-x -5
  set world-max-x 9
  set scale 10
  set point-size 1
  set world-scale 1.2
  set show-axis false
  set sample-rate 40
end 

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

to init-go
  reset-ticks
  clear-all-plots


  ask turtles with [object-type = "human"] [
    set color blue
  ]

  ask turtles with [object-type = "box"][die]

  clear-links

  clear-patches
end 

to scan-y

  reset-ticks

  init-go

   scan-from-y world-min-x world-max-x world-min-y world-max-y world-min-z world-max-z scan-thick render-part? hide-cube?
end 

to scan-x

  reset-ticks

  init-go

   scan-from-x world-min-x world-max-x world-min-y world-max-y world-min-z world-max-z scan-thick render-part? hide-cube?
end 

to scan-z

  reset-ticks

  init-go

   scan-from-z world-min-x world-max-x world-min-y world-max-y world-min-z world-max-z scan-thick render-part? hide-cube?
end 

to-report show-cube [x y z width height depth hide]

  ask turtles with [object-type =  "box"][
   die
  ]

  create-turtles 1 [
    setxyz x + width / 2 y  z
    facexyz x + width y  z
    set shape "line"
    set size width
    set color yellow
    set object-type "box"
    set hidden? hide
  ]

  create-turtles 1 [
    setxyz x y z

    set shape "dot"
    set size 2
    set color red
    set object-type "box"
    set hidden? hide
  ]

create-turtles 1 [
    setxyz x  y + height / 2 z
    facexyz x  y + height  z
    set shape "line"
    set size height
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

     create-turtles 1 [
    setxyz x + width  y + height / 2 z
    facexyz x + width  y + height  z
    set shape "line"
    set size height
    set color yellow
      set object-type "box"
    set hidden? hide
  ]


   create-turtles 1 [
    setxyz x + width / 2 y  z -  depth
    facexyz x + width y  z - depth
    set shape "line"
    set size width
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

    create-turtles 1 [
    setxyz x + width / 2 y + height  z -  depth
    facexyz x + width y + height  z - depth
    set shape "line"
    set size width
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

    create-turtles 1 [
    setxyz x  y + height / 2 z  -  depth
    facexyz x  y + height   z - depth
    set shape "line"
    set size height
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

    create-turtles 1 [
    setxyz x + width / 2 y + height  z
    facexyz x + width y + height z
    set shape "line"
    set size width
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

    create-turtles 1 [
    setxyz x + width   y + height / 2 z  -  depth
    facexyz x + width  y + height   z - depth
    set shape "line"
    set size height
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

        create-turtles 1 [
    setxyz x + width   y + height  z - depth / 2
    facexyz x + width  y + height   z - depth
    set shape "line"
    set size depth
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

   create-turtles 1 [
    setxyz x   y + height  z - depth / 2
    facexyz x  y + height   z - depth
    set shape "line"
    set size depth
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

       create-turtles 1 [
    setxyz x + width   y   z - depth / 2
    facexyz x + width  y   z - depth
    set shape "line"
    set size depth
    set color yellow
      set object-type "box"
    set hidden? hide
  ]

         create-turtles 1 [
    setxyz x   y   z - depth / 2
    facexyz x  y   z - depth
    set shape "line"
    set size depth
    set color yellow
      set object-type "box"
    set hidden? hide
  ]
  let result []
  set result (list (list x  (x + width))  (list y  (y + height)) (list (z - depth) z))

  report result
end 

to-report is-in-cube [point corrs]


  let x item 0 point
  let y item 1 point
  let z item 2 point

  let xx item 0 corrs
  let yy item 1 corrs
  let zz item 2 corrs

  let x1 item 0 xx
  let x2 item 1 xx

  ifelse x >= x1 and x <= x2 and y >= item 0 yy and y <= item 1 yy and z >= item 0 zz and z <= item 1 zz
  [
    report true
  ][

      report false
  ]
end 

to clear-all-cube
  ask turtles with [object-type = "box"][die]
end 

to scan-from-y [my-world-min-x my-world-max-x my-world-min-y my-world-max-y my-world-min-z my-world-max-z my-scan-thick only-render-cube my-hide-cube]

   let cur-y my-world-min-y
  while [cur-y < my-world-max-y] [

    let r show-cube my-world-min-x cur-y my-world-max-z (my-world-max-x - my-world-min-x) scan-thick (my-world-max-z - my-world-min-z) my-hide-cube

     ask turtles with [object-type = "human"][
       ifelse only-render-cube =  true [
            ifelse is-in-cube (list xcor ycor zcor) r [

        set color red

    ][
          set color blue
      ]
      ]
      [
    if is-in-cube (list xcor ycor zcor) r [

        set color red

    ]
      ]


  ]
     set cur-y cur-y + my-scan-thick
     tick
  ]

  clear-all-cube
end 

to scan-from-x [my-world-min-x my-world-max-x my-world-min-y my-world-max-y my-world-min-z my-world-max-z my-scan-thick only-render-cube my-hide-cube]

   let cur-x my-world-min-x
  while [cur-x < my-world-max-x] [

    let r show-cube cur-x my-world-min-y my-world-max-z  scan-thick (my-world-max-y - my-world-min-y) (my-world-max-z - my-world-min-z) my-hide-cube

     ask turtles with [object-type = "human"][
       ifelse only-render-cube =  true [
            ifelse is-in-cube (list xcor ycor zcor) r [

        set color red

    ][
          set color blue
      ]
      ]
      [
    if is-in-cube (list xcor ycor zcor) r [

        set color red

    ]
      ]


  ]
     set cur-x cur-x + my-scan-thick
    tick
  ]

  clear-all-cube
end 

to scan-from-z [my-world-min-x my-world-max-x my-world-min-y my-world-max-y my-world-min-z my-world-max-z my-scan-thick only-render-cube my-hide-cube]

   let cur-z my-world-min-z
  while [cur-z < my-world-max-z] [

    let r show-cube my-world-min-x my-world-min-y cur-z (my-world-max-x - my-world-min-x) (my-world-max-y - my-world-min-y)  scan-thick  my-hide-cube

     ask turtles with [object-type = "human"][
       ifelse only-render-cube =  true [
            ifelse is-in-cube (list xcor ycor zcor) r [

        set color red

    ][
          set color blue
      ]
      ]
      [
    if is-in-cube (list xcor ycor zcor) r [

        set color red

    ]
      ]


  ]
     set cur-z cur-z + my-scan-thick
      tick
  ]

  clear-all-cube
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-3DScanning.png preview Preview of AB3DMT-3DScanning v2 over 2 years ago, by Donghua Chen Download
AB3DMT-lib-3dmodel.nls extension external library files for AB3DMT-3DScanning over 2 years ago, by Donghua Chen Download
male.zip data csv formatted 3D model (you need to unzip before use) over 2 years ago, by Donghua Chen Download

This model does not have any ancestors.

This model does not have any descendants.