SceneGraph Class Reference

This class encapsulates all the OpenSG-stuff. More...

#include <SceneGraph.h>

List of all members.


Public Member Functions

 SceneGraph ()
virtual ~SceneGraph ()
void addNodePtr (SGPtr child)
SGPtr getNodePtr ()
void setPickingPointer (void *p)
void * getPickingPointer (Ray &ray)
void setScale (float x, float y, float z)
void setTranslate (float x, float y, float z)
void setRotate (float x, float y, float z, float angle)
void loadModel (const char *filename)
void mergeScene (SceneGraph *scene)
void setVisibility (bool vis)
void setTransparency (float alpha)

Private Member Functions

void multMatrix (OSG::Matrix &matrix)

Private Attributes

OSG::NodePtr root
OSG::NodePtr transformednode
OSG::TransformPtr transform
OSG::Pnt3f center

Detailed Description

This class encapsulates all the OpenSG-stuff.

This class handels all the scenegraph-depending stuff. Therefore no other class, used for the 3dMenu-core-package, needs to include any scenegraph-headers.

This class creates an OpenSG transform-node and attaches an OpenSG group-node. All nodes, which will be added with the methods mergeScene(SceneGraph *scene), loadModel(const char* filename) and addNodePtr(SGPtr child), will be added to this group node. The other methods manipulate the transform-node.

If an object of this class has been deleted, all OpenSG-nodes, which have been created by this object, will be removed from the scene by the destructor automatically.

This class provides also picking-functionality, which consists of two steps:

  • If someone wants to pick into the scene, the method getPickingPointer( Ray &ray ) must be called. This method tries to find a visible object und performs a lockup for finding the SceneGraph -object to which the visible object belongs. If a SceneGraph -object has been found, the method returns the registered pointer. If no visible object had been hit by the ray, NULL will be returned. In case that a SceneGraph -object has no pointer registered, the lockup-mechanism tries to find a parent- SceneGraph -object, which has a pointer registered.

Date:
23rd of March 2007
Author:
Thomas Weberndorfer

Constructor & Destructor Documentation

SceneGraph::SceneGraph (  ) 

The constructor creates a root-node containing a transform-core and attaches a transformed-node containing a group-core.

SceneGraph::~SceneGraph (  )  [virtual]

The destructor removes all OpenSG-nodes from the scenegraph to which the nodes have been added.


Member Function Documentation

void SceneGraph::addNodePtr ( SGPtr  child  ) 

This method adds a OpenSG-node to the internal group-node.

Parameters:
child This node will be added to the intern group-node.

NodePtr SceneGraph::getNodePtr (  ) 

This method returns the internal root-node.

Returns:
a reference to the internal root-node

void * SceneGraph::getPickingPointer ( Ray ray  ) 

This method is used for picking. If the ray hits a SceneGraph -object, it returns the previously assigned pointer.

Parameters:
ray This ray will be traced to find any hit SceneGraph -objects.
Returns:
It returns the assigned pointer of the first SceneGraph -object, which have been hit by the ray or NULL if nothing has been hit.

void SceneGraph::loadModel ( const char *  filename  ) 

This method loads a scene from a file and adds it to the internal group-node. All formats, which are accepted by OpenSG, can be used to store and load the scene.

Parameters:
filename This is the filename of the scene, which should be loaded.

void SceneGraph::mergeScene ( SceneGraph scene  ) 

This method adds a scene of another SceneGraph -object to this SceneGraph -object.

Parameters:
scene This has to be a reference to another SceneGraph -object.

void SceneGraph::multMatrix ( OSG::Matrix &  matrix  )  [private]

void SceneGraph::setPickingPointer ( void *  p  ) 

This method is used for picking. It assignes a pointer to the SceneGraph -object.

Parameters:
p The pointer, which should be assigned.

void SceneGraph::setRotate ( float  x,
float  y,
float  z,
float  angle 
)

This method rotates all objects, which have been added to the SceneGraph -object. The parameters x, y and z are building a vector, which is used as rotation-axis.

Parameters:
x This is the x value of the rotation-axis.
y This is the y value of the rotation-axis.
z This is the z value of the rotation-axis.
angle The added objects will be rotated by the value of angle. This value is given in degrees.

void SceneGraph::setScale ( float  x,
float  y,
float  z 
)

This method scales all objects, which have been added to the SceneGraph -object.

Parameters:
x scale in x-direction by factor x
y scale in y-direction by factor y
z scale in z-direction by factor z

void SceneGraph::setTranslate ( float  x,
float  y,
float  z 
)

This method translates all objects, which have been added to the SceneGraph -object.

Parameters:
x translate in x-direction by the value of x
y translate in y-direction by the value of y
z translate in z-direction by the value of z

void SceneGraph::setTransparency ( float  alpha  ) 

This method sets the transparency of the SceneGraph -object.

Parameters:
alpha This is the alpha value of the transparency. Valid values are [0 .. 1].

void SceneGraph::setVisibility ( bool  vis  ) 

This method sets the visibility of the SceneGraph -object.

Parameters:
vis Pass true to make the SceneGraph -object visible. Pass false to make the SceneGraph -object invisible.


Member Data Documentation

OSG::Pnt3f SceneGraph::center [private]

OSG::NodePtr SceneGraph::root [private]

OSG::TransformPtr SceneGraph::transform [private]

OSG::NodePtr SceneGraph::transformednode [private]


The documentation for this class was generated from the following files:

Generated on Wed Oct 20 16:12:00 2010 for inVRs by doxygen 1.5.8