Momentum Scripting v1
Loading...
Searching...
No Matches
MOMENTUM_NAMESPACE::SceneGraph Class Reference

#include <SceneGraph.h>

Static Public Member Functions

static SceneNodePtr createAndAdd3DGrid (int resU, int resV, int resW, const Vec3 &origin, const Vec3 &endPointX, const Vec3 &endPointY, const Vec3 &endPointZ, const Vec4 &color, float width)
 
static SceneNodePtr createAndAddLine (const Vec3 &p1, const Vec3 &p2, const Vec4 &color, float width)
 
static SceneNodePtr createAndAddPolyline (std::vector< Vec3 > points, const Vec4 &color, float width)
 
static SceneNodePtr createAndAddText (const std::string &text, const Vec3 &relPosition, const Vec4 &color, float size)
 
static bool removeNode (SceneNodePtr node)
 

Detailed Description

The SceneGraph class provides an interface for managing and rendering graphical objects within a scene, such as lines, polylines, grids, and text objects.

Use this to draw graphical objects that doesn't interact with the physics.

The class offers static methods to create these graphical objects, which return pointers to the created SceneNode objects, allowing further manipulation or deletion as required. The created graphical objects doesn't interact with rigid bodies or other objects in the simulation.

Note that the graphical objects are only visible in the Journal Viewer or the External Simulation viewer. They are never displayed inside SpaceClaim, e.g. when running the simulation from inside SpaceClaim. This means that the visual objects may only be seen when running an external simulation or the Journal Viewer.

Member Function Documentation

◆ createAndAdd3DGrid()

static SceneNodePtr MOMENTUM_NAMESPACE::SceneGraph::createAndAdd3DGrid ( int  resU,
int  resV,
int  resW,
const Vec3 origin,
const Vec3 endPointX,
const Vec3 endPointY,
const Vec3 endPointZ,
const Vec4 color,
float  width 
)
static

Create a uniform grid and adds it to the scene graph.

Check return value to see if everything was successful.

Parameters
resUThe resolution of the grid (in number of lines) in x.
resVThe resolution of the grid (in number of lines) in y.
resWThe resolution of the grid (in number of lines) in z.
originThe origin of the grid in world coordinates
endPointXThe end point of the grid in x coordinates. The distance between this point and the origin gives the length of the grid in x.
endPointYThe end point of the grid in y coordinates. The distance between this point and the origin gives the length of the grid in y.
endPointZThe end point of the grid in z coordinates. The distance between this point and the origin gives the length of the grid in z.
color- An RGBt color array, where x is R, y is G, z is B and w is transparency. Values in the interval 0-1.
widthThe line width of the grid, this is in pixel size.
Returns
a pointer to a new SceneNode containing the grid. Note that null is returned if this call fails.

◆ createAndAddLine()

static SceneNodePtr MOMENTUM_NAMESPACE::SceneGraph::createAndAddLine ( const Vec3 p1,
const Vec3 p2,
const Vec4 color,
float  width 
)
static

Create and add a line to the scene graph.

Parameters
p1,p2- Start, end points in WORLD coordinate system
color- An RGBt color array, where x is R, y is G, z is B and w is transparency. Values in the interval 0-1.
width- This is the number defining the line width in pixels
Returns
a pointer to a new SceneNode containing the line. Note that null is returned if this call fails.

◆ createAndAddPolyline()

static SceneNodePtr MOMENTUM_NAMESPACE::SceneGraph::createAndAddPolyline ( std::vector< Vec3 points,
const Vec4 color,
float  width 
)
static

Create and return a new Polyine to render.

The polyline is added to the scene graph.

Parameters
points- A vector of points, in WORLD coordinate system, defining the polyline. Give at least two points
color- An RGBt color array, where x is R, y is G, z is B and w is transparency. Values in the interval 0-1.
width- This is the number defining the line width in pixels
Returns
a pointer to a new SceneNode contaning the polyline. Note that null is returned if this call fails.

◆ createAndAddText()

static SceneNodePtr MOMENTUM_NAMESPACE::SceneGraph::createAndAddText ( const std::string &  text,
const Vec3 relPosition,
const Vec4 color,
float  size 
)
static

Create a text object and adds it to the scene graph.

Parameters
text- the text to render
relPosition- relative position to the geometry
color- An RGBt color array, where x is R, y is G, z is B and w is transparency. Values in the interval 0-1.
size- size of the text
Returns
a pointer to a new SceneNode containing the text. Note that null is returned if this call fails.

◆ removeNode()

static bool MOMENTUM_NAMESPACE::SceneGraph::removeNode ( SceneNodePtr  node)
static

Remove the given scene node from the scene graph.

Returns
true if the node is succesfully removed, else false.