-
Notifications
You must be signed in to change notification settings - Fork 20
Paths And Grids
As of v0.8, both Paths and Grids are supported in Tetra3D if the GLTF file is exported through the Tetra3D add-on.
To actually use a Path, you would need a Path and a PathStepper. A PathStepper is a struct that allows an object to move along a given path, going from the start to the finish progressively. You can advance this object along the path in steps, or by converting a percentage to the accurate position in the path. Once the PathStepper is finished moving along the Path, you can have it stop, restart on the Path, or ping-pong (reverse) by changing PathFollower's FinishMode property.
To make a Path closed, you can toggle it either in code in the Path's Closed property, or in Blender (specify "Cyclic" in the Active Spline section of the Object Data properties panel, or if it isn't there, press Alt+C / toggle the cyclic property on the active spline in edit mode). Paths are most easily created in Blender by creating a Path like you normally would (i.e. F3 > search for "Add Path", or go to Add > Curve > Path in the 3D view header), though you can create them programmatically as well.

A mesh in Blender that becomes a Grid in Tetra3D
Grids are something like Paths, but they don't have a beginning or end - instead, they are made from a mesh and represent a network. For a Grid, the vertices of the mesh become GridPoints (nodes representing positions in space), and the edges between these vertices become connections between these points. Just like a normal mesh, each GridPoint (or vertex) can connect to one or more other GridPoints. This being the case, Grids can be used to easily perform some basic pathfinding around a static scene.
Connections to GridPoints are comprised of one-way pairs, with each connection having a cost and a passability. This is done so that pathfinding could be one-way, or that one connection to a node be higher cost than another connection (i.e. if a path to a node passes over a wall).
Similarly to Paths, to navigate an object on a Grid, you can simply use a PathStepper and give it a GridPath to follow. You generate GridPaths by using GridPoint.PathTo(other *GridPoint) - to get the nearest grid point to a position in world, you can use Grid.NearestGridPoint().
To turn a mesh into a Grid, simply select it and press the "Grid" button under the Object Type: section of the Tetra3D Object Properties panel. Only mesh objects have the option to turn into a Grid - note that Grids are not visible in Tetra3D, as well.

Internally, a Grid is essentially just a Node with some additional helper functions to easily handle selection of GridPoints (by position or randomly, for example). The Grid's points (vertices in Blender) become GridPoint objects in Tetra3D, which are children of the parent Grid.