vtlib library
Classes | Typedefs | Functions
Scene graph

Classes

class  vtGeomFactory
 
class  vtDimension
 
class  vtDynBoundBox
 
class  vtLodGrid
 
class  vtSimpleLodGrid
 
class  vtMaterial
 
class  vtMaterialArray
 
class  vtMesh
 
class  vtTextMesh
 
struct  NodeExtension
 
struct  TransformExtension
 
class  vtGroup
 
class  vtTransform
 
class  vtFog
 
class  vtShadow
 
class  vtLightSource
 
class  vtGeode
 
class  vtMovGeode
 
class  vtLOD
 
class  vtCamera
 
class  vtHUD
 
class  vtDynGeom
 
struct  vtHit
 
struct  vtPrimInfo
 
class  vtWindow
 
class  vtScene
 

Typedefs

typedef osg::ref_ptr< osgText::Font > vtFontPtr
 

Functions

vtGeodeCreate3DCursor (float fSize, float fSmall, float fAlpha=0.5f)
 
vtGeodeCreateBoundSphereGeode (const FSphere &sphere, int res=24)
 
vtMeshCreateSphereMesh (const FSphere &sphere, int res=24)
 
vtGeodeCreateBlockGeom (const vtMaterialArray *pMats, int iMatIdx, const FPoint3 &size)
 
vtGeodeCreateSphereGeom (const vtMaterialArray *pMats, int iMatIdx, int iVertType, float fRadius, int res)
 
vtGeodeCreateCylinderGeom (const vtMaterialArray *pMats, int iMatIdx, int iVertType, float hHeight, float fRadius, int res, bool bTop=true, bool bBottom=true, bool bCentered=true, int direction=1)
 
vtGeodeCreateLineGridGeom (const vtMaterialArray *pMats, int iMatIdx, const FPoint3 &min1, const FPoint3 &max1, int steps)
 
bool WriteGeodeToOBJ (vtGeode *geode, const char *filename)
 
osg::Image * LoadOsgImage (const char *fname)
 Convenience method. More...
 
bool FindAncestor (osg::Node *node, osg::Node *parent)
 
osg::Node * FindDescendent (osg::Group *node, const char *pName)
 
void InsertNodeAbove (osg::Node *node, osg::Group *newnode)
 
void InsertNodeBelow (osg::Group *group, osg::Group *newnode)
 
void LocalToWorld (osg::Node *node, FPoint3 &point)
 
void GetBoundSphere (osg::Node *node, FSphere &sphere, bool bGlobal=false)
 
void ApplyVertexRotation (osg::Node *node, const FPoint3 &axis, float angle)
 
void ApplyVertexTransform (osg::Node *node, const FMatrix4 &mat)
 
void vtLogGraph (osg::Node *node, bool bExtents=false, bool bRefCounts=false, int indent=0)
 
void WriteDotFile (osg::Group *node, const char *filename)
 
osg::Node * vtLoadModel (const char *filename, bool bAllowCache=true, bool bDisableMipmaps=false)
 Load a 3D model file. More...
 
int vtIntersect (osg::Node *pTop, const FPoint3 &start, const FPoint3 &end, vtHitList &hitlist, bool bLocalCoords=false, bool bNativeNodes=true)
 
void GetNodeBoundBox (osg::Node *node, FBox3 &box)
 
void GetNodePrimCounts (osg::Node *node, vtPrimInfo &info)
 

Detailed Description

These classes define the node of a scene graph and the Scene class which contains them.

Typedef Documentation

typedef osg::ref_ptr<osgText::Font> vtFontPtr

A Font for use with vtTextMesh.

Function Documentation

void ApplyVertexRotation ( osg::Node *  node,
const FPoint3 axis,
float  angle 
)

Given a node with geometry under it, rotate the vertices of that geometry by a given axis/angle.

void ApplyVertexTransform ( osg::Node *  node,
const FMatrix4 mat 
)

Given any node with geometry under it, transform the vertices of that geometry.

vtGeode* Create3DCursor ( float  fSize,
float  fSmall,
float  fAlpha 
)

Create a "3d Cursor" geometry, which consists of 3 blocks (red, green, blue) along the XYZ axes.

Parameters
fSizeThe overall width, height, and depth of the geometry
fSmallThe width of the blocks (generally much smaller than fSize)
fAlphaThe alpha value to use, from 0 (transparent) to 1 (opaque)
vtGeode* CreateBlockGeom ( const vtMaterialArray pMats,
int  iMatIdx,
const FPoint3 size 
)

Create a block geometry with the indicated material and size. See vtMesh::CreateBlock for how the block is constructed.

Parameters
pMatsThe array of materials to use.
iMatIdxThe index of the material to use.
sizeThe dimensions of the block in x, y, z.
vtGeode* CreateBoundSphereGeode ( const FSphere sphere,
int  res 
)

Create a wireframe sphere which is very useful for visually representing the bounding sphere of an object in the scene.

vtGeode* CreateCylinderGeom ( const vtMaterialArray pMats,
int  iMatIdx,
int  iVertType,
float  fHeight,
float  fRadius,
int  res,
bool  bTop,
bool  bBottom,
bool  bCentered,
int  direction 
)

Create a cylinder geometry with the indicated attributes.

Parameters
pMatsThe array of materials to use.
iMatIdxThe index of the material to use.
iVertTypeFlags which indicate what type of information is stored with each vertex. This can be any combination of the following bit flags:
  • VT_Normals - a normal per vertex.
  • VT_Colors - a color per vertex.
  • VT_TexCoords - a texture coordinate (UV) per vertex.
fHeightThe height of the cylinder.
fRadiusThe radius of the cylinder.
resThe resolution (number of sides) of the cylinder.
bTopTrue to create the top of the cylinder.
bBottomTrue to create the bottom of the cylinder. You could set this to false, for example, if the cylinder is going to sit on a flat surface where you will never see its bottom.
bCenteredTrue to create a cylinder centered around its origin, false for a cylinder with its base at the origin that extends outward.
directionAn orientation, 0-2 corresponds to X, Y, Z. Default is 1 (Y).
vtGeode* CreateLineGridGeom ( const vtMaterialArray pMats,
int  iMatIdx,
const FPoint3 min1,
const FPoint3 max1,
int  steps 
)

Create a grid of lines in the XZ plane. This can be useful as a reference object, like a sheet of graph paper.

vtGeode* CreateSphereGeom ( const vtMaterialArray pMats,
int  iMatIdx,
int  iVertType,
float  fRadius,
int  res 
)

Create a sphere geometry with the indicated material, radius and resolution.

Parameters
pMatsThe array of materials to use.
iMatIdxThe index of the material to use.
iVertTypeFlags which indicate what type of information is stored with each vertex. This can be any combination of the following bit flags:
  • VT_Normals - a normal per vertex.
  • VT_Colors - a color per vertex.
  • VT_TexCoords - a texture coordinate (UV) per vertex.
fRadiusThe radius of the sphere.
resThe resolution (tesselation) of the sphere. The number of vertices in the result will be res*res*2.
vtMesh* CreateSphereMesh ( const FSphere sphere,
int  res 
)

Create a wireframe sphere which is very useful for visually representing the bounding sphere of an object in the scene.

bool FindAncestor ( osg::Node *  node,
osg::Node *  parent 
)

Recursively travel up the scene graph, looking for a specific parent node. Return true if it is found.

osg::Node* FindDescendent ( osg::Group *  group,
const char *  pName 
)

Recursively travel down the scene graph, looking for a specific child node by name. Return it if it is found.

void GetBoundSphere ( osg::Node *  node,
FSphere sphere,
bool  bGlobal 
)

Get the Bounding Sphere of the node

void GetNodeBoundBox ( osg::Node *  node,
FBox3 box 
)

Calculates the bounding box of the geometry contained in and under this node in the scene graph. Note that unlike the bounding sphere which is cached, this value is calculated each time this method is called.

Parameters
nodeThe node to visit.
boxWill receive the bounding box.
void GetNodePrimCounts ( osg::Node *  node,
vtPrimInfo info 
)

This method walks through a node (and all its children), collecting information about all the geometric primitives. The result is placed in an object of type vtPrimInfo. This includes information such as number of vertices, number of triangles, and so forth. Note that this can be a time-consuming operation if your geometry is large or complex. The results are not cached, so this method should be called only when needed.

Parameters
nodeThe node to investigate.
infoA vtPrimInfo object which will receive all the information about this node and its children.
void InsertNodeAbove ( osg::Node *  node,
osg::Group *  newnode 
)

Insert a node into a scene graph. For example, if the graph is A-B-C, where B is the child of A and C is the child of B, then inserting a node D above C results in A-B-D-C.

Parameters
nodeThe node to insert above.
newnodeThe node to insert.
void InsertNodeBelow ( osg::Group *  group,
osg::Group *  newnode 
)

Insert a node into a scene graph. For example, if the graph is A-B-C, where B is the child of A and C is the child of B, then inserting a node D below A results in A-D-B-C.

Parameters
groupThe node to insert below.
newnodeThe node to insert.
osg::Image* LoadOsgImage ( const char *  fname)

Load an image.

void LocalToWorld ( osg::Node *  node,
FPoint3 point 
)

Transform a 3D point from a node's local frame of reference to world coordinates. This is done by walking the scene graph upwards, applying all transforms that are encountered.

Parameters
nodeThe node to consider.
pointA reference to the input point is modified in-place with world coordinate result.
int vtIntersect ( osg::Node *  pTop,
const FPoint3 start,
const FPoint3 end,
vtHitList &  hitlist,
bool  bLocalCoords,
bool  bNativeNodes 
)

Check for surface intersections along a line segment in space.

Parameters
pTopThe top of the scene graph that you want to search for intersections. This can be the root node if you want to seach your entire scene, or any other node to search a subgraph.
startThe start point (world coordinates) of the line segment.
endThe end point (world coordinates) of the line segment.
hitlistThe results. If there are intersections (hits), they are placed in this list, which is simply a std::vector of vtHit objects. Each vtHit object gives information about the hit point.
bLocalCoordsPass true to get your results in local coordinates (in the frame of the object which was hit). Otherwise, result points are in world coordinates.
bNativeNodesPass true to return the internal (native) scene graph node that was hit, when there is no corresponding vtNode. Pass false to always return a vtNode, by looking up the scene graph as needed.
Returns
The number of intersection hits (size of the hitlist array).
osg::Node* vtLoadModel ( const char *  filename,
bool  bAllowCache,
bool  bDisableMipmaps 
)

Load a 3D model from a file.

The underlying scenegraph (i.e. OSG) is used to load the model, which is returned as an osg::Node. You can then use this node normally, for example add it to your scenegraph with addChild(), or to your terrain's subgraph with vtTerrain::AddNode().

Parameters
filenameThe filename to load from.
bAllowCacheDefault is true, to allow OSG to cache models. This means that if you load from the same filename more than once, you will get the same model again instantly. If you don't want this, for example if the model has changed on disk and you want to force loading, pass false.
bDisableMipmapsPass true to turn off mipmapping in the texture maps in the loaded model. Default is false (enable mipmapping).
Returns
A node pointer if successful, or NULL if the load failed.
void vtLogGraph ( osg::Node *  node,
bool  bExtents,
bool  bRefCounts,
int  indent 
)

Diagnostic function to help debugging: Log the scene graph from a given node downwards.

void WriteDotFile ( osg::Group *  node,
const char *  filename 
)

Write the scene graph to a file for use with the 'dot' graphing application which is part of GraphViz (http://www.graphviz.org/).

For example, to write the whole scenegraph to a file:

1 WriteDotFile(vtGetScene()->GetRoot(), "scene.dot");

Then to use dot to produce a visual graph, from a command line:

1 > dot -Tpng scene.dot -oscene.png
bool WriteGeodeToOBJ ( vtGeode geode,
const char *  filename 
)

Write a geometry node to a old-fashioned Wavefront OBJ file.