Class l2df.class.component.physix.grid
Grid helper.
Info:
- Copyright: 2014 Enrique García Cota, 2020 Atom-TM
- Author: Abelidze, oniietzschan, Enrique García Cota
Functions
Grid:toWorld(cellsize, cx, cy, cz) | Get left-top corner cell coordinates. |
Grid:toCell(cellsize, x, y, z) | Convert left-top corner cell coordinates to cell indexes. |
Grid:toCellCube(cellsize, x, y, z, w, h, d) | Convert cube from world to cell coordinates. |
Grid:traverse(cellsize, x1, y1, z1, x2, y2, z2, f) | Function is based on "A Fast Voxel Traversal Algorithm for Ray Tracing", by John Amanides and Andrew Woo - http://www.cse.yorku.ca/~amana/research/grid.pdf It has been modified to include both cells when the ray "touches a grid corner", and with a different exit condition. |
Functions
Methods- Grid:toWorld(cellsize, cx, cy, cz)
-
Get left-top corner cell coordinates.
Parameters:
- cellsize number Size of the cell in pixels.
- cx number Cell X index.
- cy number Cell Y index.
- cz number Cell Z index.
Returns:
- number X coordinate.
- number Y coordinate.
- number Z coordinate.
- Grid:toCell(cellsize, x, y, z)
-
Convert left-top corner cell coordinates to cell indexes.
Parameters:
- cellsize number Size of the cell in pixels.
- x number X coordinate.
- y number Y coordinate.
- z number Z coordinate.
Returns:
- number Cell X index.
- number Cell Y index.
- number Cell Z index.
- Grid:toCellCube(cellsize, x, y, z, w, h, d)
-
Convert cube from world to cell coordinates.
Parameters:
- cellsize number Size of the cell in pixels.
- x number Cube X coordinate.
- y number Cube Y coordinate.
- z number Cube Z coordinate.
- w number Cube width.
- h number Cube height.
- d number Cube depth.
Returns:
- number Cell X index.
- number Cell Y index.
- number Cell Z index.
- number Cell width.
- number Cell height.
- number Cell depth.
- Grid:traverse(cellsize, x1, y1, z1, x2, y2, z2, f)
-
Function is based on "A Fast Voxel Traversal Algorithm for Ray Tracing",
by John Amanides and Andrew Woo - http://www.cse.yorku.ca/~amana/research/grid.pdf
It has been modified to include both cells when the ray "touches a grid corner",
and with a different exit condition.
Parameters:
- cellsize number Size of the cell in pixels.
- x1 number Start X coordinate.
- y1 number Start Y coordinate.
- z1 number Start Z coordinate.
- x2 number End X coordinate.
- y2 number End Y coordinate.
- z2 number End Z coordinate.
- f function Traverse function called for each cell in path.