Unigine::WorldSplineGraph Class
Header: | #include <UnigineWorlds.h> |
Inherits: | Node |
This class is used to generate specified nodes (called source nodes) along a spline graph.
A world spline graph consists of segments and has a list of source nodes (currently ObjectMeshStatic only) that can be stretched or tiled along the segments. Each WorldSplineGraph node can have a single or a set of source nodes. An arbitrary number of WorldSplineGraph nodes can be added to the scene.
WorldSplineGraph has the following features:
- Vertices and segments of the spline graph are managed via the SplineGraph class.
- 2 modes are supported:
- stretching: source nodes are stretched along the spline segment.
- tiling: source nodes are duplicated along the spline segment.
- Forward axis selection for stretching/tiling source nodes.
See Also
See the following C++ API samples to learn how to manage the WorldSplineGraph class:
<UnigineSDK>/data/samples/worlds/world_spline_graph_00 featuring:
- Creation of a WorldSplineGraph node from a SplineGraph file.
- Generation of geometry along the graph segments in stretching mode.
<UnigineSDK>/data/samples/worlds/world_spline_graph_01 featuring:
- Creation of a WorldSplineGraph node from a SplineGraph file.
- Generation of geometry along the graph segments in tiling mode.
WorldSplineGraph Class
Members
static WorldSplineGraphPtr create()
Default constructor. Creates an empty world spline graph.static WorldSplineGraphPtr create(const char * name)
Constructor. Creates an empty world spline graph with a given name.Arguments
- const char * name - World spline graph name.
static Ptr<WorldSplineGraph> cast(const Ptr<Node> & node)
Casts a WorldSplineGraph out of the Node instance.Arguments
- const Ptr<Node> & node - Pointer to Node.
Return value
Pointer to WorldSplineGraph.int getNumPoints()
Returns the total number of points in the world spline graph.Return value
Number of points.int getNumSourceNodes()
Returns the total number of source nodes in the list.Return value
Number of source nodes.int getNumSegmentNodes()
Returns the total number of nodes assigned to the segments of the world spline graph.Return value
Number of nodes assigned to the segments of the world spline graph.int getNumSegments()
Returns the total number of segments in the world spline graph.Return value
Number of segments.Math::vec3 calcSegmentPoint(int index, float t)
Returns the coordinates of the point on the given segment.Arguments
- int index - Segment index.
- float t - Position of the point on the segment, in increments of the segment's length normalized to 1.
Return value
Coordinates of the point on the given segment.Math::vec3 calcSegmentTangent(int index, float t)
Returns the tangent coordinates for the point on the given segment.Arguments
- int index - Segment index.
- float t - Position of the point on the segment, in increments of the segment's length normalized to 1.
Return value
Tangent coordinates for the point on the given segment.Math::vec3 calcSegmentUpVector(int index, float t)
Returns the "up" vector coordinates for the point on the given segment.Arguments
- int index - Segment index.
- float t - Position of the point on the segment, in increments of the segment's length normalized to 1.
Return value
"Up" vector coordinates for the point on the given segment.void setPoint(int index, const Math::vec3 & point)
Sets the coordinates of the point with a given index.Arguments
- int index - Point index.
- const Math::vec3 & point - Point coordinates.
Math::vec3 getPoint(int index)
Returns the coordinates of the point with a given index.Arguments
- int index - Point index.
Return value
Point coordinates.Math::vec3 getSegmentEndPoint(int index)
Returns the coordinates of the end point for the segment with a given index.Arguments
- int index - Segment index.
Return value
Segment end point coordinates.int getSegmentEndPointIndex(int index)
Returns the index of the end point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
Segment end point index.void setSegmentEndTangent(int index, const Math::vec3 & tangent)
Sets the tangent coordinates for the end point of the spline segment with a given index.Arguments
- int index - Segment index.
- const Math::vec3 & tangent - End point tangent coordinates.
Math::vec3 getSegmentEndTangent(int index)
Returns the tangent coordinates for the end point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
End point tangent coordinates.void setSegmentEndUpVector(int index, const Math::vec3 & up)
Sets the "up" vector coordinates for the end point of the spline segment with a given index.Arguments
- int index - Segment index.
- const Math::vec3 & up - End point "up" vector coordinates.
Math::vec3 getSegmentEndUpVector(int index)
Returns the "up" vector coordinates for the end point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
End point "up" vector coordinates.int getSegmentMode(int segment_index)
Returns the current mode for the secment with a given index.Arguments
- int segment_index - Segment index.
Return value
Mode. One of the SEGMENT_* variables.void getSegmentNodes(Vector< Ptr<Node> > & nodes, int segment_index = -1)
Retrieves the list of nodes assigned to the specified segment of the world spline graph and puts it to the buffer.Arguments
- Vector< Ptr<Node> > & nodes - Buffer to store the nodes assigned to the segments of the world spline graph.
- int segment_index - Segment index. If no segment index is specified, the method retrieves the list of source nodes assigned to all segments.
int getSegmentSourceIndex(int segment_index)
Returns the index of the source node currently assigned to the segment with a given index.Arguments
- int segment_index - Segment index.
Return value
Source node index or -1 if no source node is assigned to the segment with a given index.Math::vec3 getSegmentStartPoint(int index)
Returns the coordinates of the start point for the segment with a given index.Arguments
- int index - Segment index.
Return value
Segment start point coordinates.int getSegmentStartPointIndex(int index)
Returns the index of the start point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
Segment start point index.void setSegmentStartTangent(int index, const Math::vec3 & tangent)
Sets the tangent coordinates for the start point of the spline segment with a given index.Arguments
- int index - Segment index.
- const Math::vec3 & tangent - Start point tangent coordinates.
Math::vec3 getSegmentStartTangent(int index)
Returns the tangent coordinates for the start point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
Start point tangent coordinates.void setSegmentStartUpVector(int index, const Math::vec3 & up)
Sets the "up" vector coordinates for the start point of the segment with a given index.Arguments
- int index - Segment index.
- const Math::vec3 & up - Start point "up" vector coordinates.
Math::vec3 getSegmentStartUpVector(int index)
Returns the "up" vector coordinates for the start point of the spline segment with a given index.Arguments
- int index - Segment index.
Return value
Start point "up" vector coordinates.int assignSegmentSource(int segment_index, int source_num, int mode = 0)
Assigns the specified source node to the given segment of the spline graph.Arguments
- int segment_index - Segment index.
- int source_num - Source node index.
- int mode - Mode. One of the SEGMENT_* variables. The default mode is SEGMENT_STRETCH.
Return value
1 if the source node was successfully assigned to the segment; otherwise, 0.void clearSegmentSource(int segment_index = -1)
Removes the assigned source node from the segment with a given index.Arguments
- int segment_index - Segment index. If no segment index is specified, the method removes assigned source nodes from all segments.
int addSourceNode(const char * name, int forward_axis = 0)
Adds a source node with a given name to the list.Arguments
- const char * name - Source node name.
- int forward_axis - Forward axis. One of the FORWARD_* variables. The default value is FORWARD_X.
int addSourceNode(const Ptr<Node> & node, int forward_axis = 0)
Adds the given source node to the list.Arguments
- const Ptr<Node> & node - Source node smart pointer.
- int forward_axis - Forward axis. One of the FORWARD_* variables. The default value is FORWARD_X.
void removeSourceNode(int num)
Removes the source node with a given index from the list. This method also removes all nodes of all segments linked to this source node and performs correction of source node indices for all segments.Arguments
- int num - Source node index.
int setSourceForwardAxis(int num, int forward_axis)
Sets the forward axis for a given source node.Arguments
- int num - Source node index.
- int forward_axis - Forward axis. One of the FORWARD_* variables.
Return value
1 if the forward axis for the source node was set successfully; otherwise, 0.int getSourceForwardAxis(int num)
Returns the forward axis for a given source node.Arguments
- int num - Source node index.
Return value
Forward axis. One of the FORWARD_* variables.const char * getSourceNodeName(int num)
Returns the name of the source node with a given index.Arguments
- int num - Source node index.
Return value
Source node name.void setSplineGraph(const Ptr<SplineGraph> & splinegraph)
Sets the specified source spline graph as the current one.Arguments
- const Ptr<SplineGraph> & splinegraph - Source spline graph.
void getSplineGraph(const Ptr<SplineGraph> & splinegraph)
Copies current spline graph to the destination spline graph.Arguments
- const Ptr<SplineGraph> & splinegraph - Destination spline graph.
void setSplineGraphName(const char * name, int force_load = 0)
Sets the name of the world spline graph.Arguments
- const char * name - World spline graph name.
- int force_load - Force flag.
- If 1 is specified, the world spline graph will immediately loaded from a file.
- If 0 is specified, only the world spline graph name will be updated.
const char * getSplineGraphName()
Returns the name of the world spline graph.Return value
World spline graph name.void loadSegmentNodes(int segment_index = -1)
Loads source nodes assigned to the specified spline segment immediately.Arguments
- int segment_index - Segment index. If no segment index is specified, the method loads source nodes assigned to all segments.
void clear()
Clears the world spline graph.int isCurved()
Returns a value indicating if the world spline graph is curved.Return value
1 if the world spline graph is curved; otherwise, 0.void makeCurved()
Curves the world spline graph using its geodetic pivot. The spline file is saved upon completion of the curving operation.The world spline graph must be a child of a Geodetic Pivot node.
void makeFlat()
Flattens the world spline graph using its geodetic pivot. The spline file is saved upon completion of the flattening operation.The world spline graph must be a child of a Geodetic Pivot node.
int load(const char * name)
Loads a spline graph from the specified XML-file.Arguments
- const char * name - Name of the XML-file to load the spline graph from.
Return value
1 if the spline graph was successfully loaded; otherwise, 0.int save(const char * name)
Saves a spline graph to the specified XML-file.Arguments
- const char * name - Name of the XML-file to save the spline graph to.
Return value
1 if the spline graph was successfully saved; otherwise, 0.static int type()
Returns the type of the node.Return value
WorldSplineGraph type identifier.int FORWARD_X
Description
X is a forward axis for stretching.int FORWARD_Y
Description
Y is a forward axis for stretching.int FORWARD_Z
Description
Z is a forward axis for stretching.int SEGMENT_STRETCH
Description
The source node is stretched along the segment.int SEGMENT_TILING
Description
The source node is duplicated along the segment.Last update: 2017-12-21
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)