Documentation


X3DTK::MainScene Class Reference

#include <mainScene.h>

List of all members.


Detailed Description

This class manages with the data structures, i.e.

x3d scene graph and openGL scene graph, in order to load x3d files, to save the scene in x3d files, to animate and draw the scene

Examples:

qtapp.cpp.

Definition at line 58 of file mainScene.h.

Public Member Functions

 MainScene ()
 Constructor.

virtual ~MainScene ()
 Destructor.

virtual void load (const char *file, bool fileValidation=false)
 Load the scene from file. It erases the existed x3d scene.

void load (const char *file, X3D::X3DNode *node, bool fileValidation=false)
 Load the scene from the given file and insert the scene's children from the given node.

virtual void draw ()
 Draw the scene from the openGL graph glscene.

void save (const char *file)
 Save the x3d graphe in a file.x3d.

void reset ()
 Reset the scene for the animation.

virtual void move (double dt)
 Move the scene.

bool computeBbox ()
 Compute a bounding box from the x3d scene.

bool pastNode (X3DAbstractNode *node, X3DAbstractNode *parentNode)
 Past a node from a parent node.

void deleteNode (X3DAbstractNode *node, X3DAbstractNode *parentNode)
 Delete a node i.e break the link between the node and its current parent node and delete it.

bool cutNode (X3DAbstractNode *node, X3DAbstractNode *parentNode)
 Cut a node, i.e break the link between the node and its current parent node.

template<typename GroupingNode_t> void newX4DClass ()
 Define a new x3d grouping node.

void addEngine (animal::Engine *engine)
 Add an engine.

void removeEngine (animal::Engine *engine)
 Remove an engine.

void clearEngines ()
 Clear the engines list.

X3D::Scene * getX3DScene () const
 Get the x3d scene.

SFVec3f getBboxMin () const
 Get the Bounding Box minima.

SFVec3f getBboxMax () const
 Get the Bounding Box maxima.

MainControllergetMainController () const
 Get the main GUI.

void setMainController (MainController *MC)
void keyPressEvent (animal::KeyEvent *e)
 Deal with key press event. Return false if the event is not handled.

void mouseDoubleClickEvent (animal::MouseEvent *e)
 Deal with mouse double-click event. Return false if the event is not handled.

void mouseMoveEvent (animal::MouseEvent *e)
 Deal with mouse move event. Return false if the event is not handled.

void mousePressEvent (animal::MouseEvent *e)
 Deal with mouse press event. Return false if the event is not handled.

void mouseReleaseEvent (animal::MouseEvent *e)
 Deal with mouse release event. Return false if the event is not handled.

animal::ConstrainedItempickPoint (float origin[3], float direction[3], float threshold)
void setSelectedNode (X3D::X3DBoundedObject *)
 highlight a node

void updateGL ()
 Update all the gl nodes contained in the list glNodeToUpdate.


Public Attributes

X3DGLMap x3dGLMap
 The map which links X3DTK::X3D::X3DNode to their corresponding X3DTK::GL::X3DNode.


Protected Attributes

X3D::Scene * x3dscene
 The x3d scene graph.

GL::Scene * glscene
 The openGL scene graph.

SFVec3f min
 Minima for the bounding box.

SFVec3f max
 Maxima for the bounding box.

GLUpdates glUpdates
 gl updates to perform after an animation step


Private Member Functions

void buildGL ()
 Build the glscene from the x3dscene, update the list glNodeToUpdate and compute the bounding box of the scene.

void releaseNode (X3DAbstractNode *node)
 Release a node, i.e delete it if there is no more parent link.

bool isADescendant (X3DAbstractNode *node1, X3DAbstractNode *node2)
 Test if node1 is a descendant of node2.


Private Attributes

X3DTK::X3D::GroupingNodeCreator groupingNodeCreator
X3D::Loader * x3dloader
 The x3d scene graph loader from a file .x3d.

X3D::EngineLoaderengineLoader
 The visitor used for creating animal::engines associated with x3d nodes.

GL::MyRenderer renderer
 The openGL scene graph renderer.

AnimalEngines animalEngines
 The group of engines which do not belong to the scene graph (added directly using method addEngine).

X3D::EngineNodes allEngineNodes
 The group of engines which belong to the scene graph.

X3D::EngineNodes kinematicEngines
 engines which do not react to collisions (subset of allEngineNodes)

X3D::EngineNodes dynamicEngines
 engines which can react to collisions (subset of allEngineNodes)

X3D::EngineNodes collisionEngines
 collision detection engines (subset of allEngineNodes)

MainControllermainController
 The main GUI.

X3D::X3DBoundedObject * m_selectedNode
 A selected object which must be highlighted.

X3D::BBoxUpdater * bbupdater
 update the bounding box of the scene


Constructor & Destructor Documentation

X3DTK::MainScene::MainScene  ) 
 

Constructor.

Definition at line 35 of file mainScene.cpp.

References allEngineNodes, bbupdater, buildGL(), collisionEngines, dynamicEngines, engineLoader, kinematicEngines, and x3dscene.

X3DTK::MainScene::~MainScene  )  [virtual]
 

Destructor.

Definition at line 59 of file mainScene.cpp.

References glscene, releaseNode(), x3dloader, and x3dscene.


Member Function Documentation

void X3DTK::MainScene::addEngine animal::Engine engine  ) 
 

Add an engine.

Definition at line 464 of file mainScene.cpp.

References animalEngines, computeBbox(), and animal::Engine::init().

Referenced by MainController::addEngine().

void X3DTK::MainScene::buildGL  )  [private]
 

Build the glscene from the x3dscene, update the list glNodeToUpdate and compute the bounding box of the scene.

Definition at line 502 of file mainScene.cpp.

References X3DTK::GL::X3DGLMapBuilder::build(), X3DTK::X3D::EngineNode::declareOutputs(), glscene, glUpdates, releaseNode(), X3DTK::X3D::X3D_X3DNodeList, x3dGLMap, and x3dscene.

Referenced by cutNode(), load(), MainScene(), and pastNode().

void X3DTK::MainScene::clearEngines  ) 
 

Clear the engines list.

Definition at line 479 of file mainScene.cpp.

References animalEngines, and computeBbox().

bool X3DTK::MainScene::computeBbox  ) 
 

Compute a bounding box from the x3d scene.

Returns:
true if the x3d scene exists

Definition at line 386 of file mainScene.cpp.

References allEngineNodes, animalEngines, bbupdater, max, min, and x3dscene.

Referenced by addEngine(), clearEngines(), MainController::computeBbox(), removeEngine(), and updateGL().

bool X3DTK::MainScene::cutNode X3DAbstractNode *  node,
X3DAbstractNode *  parentNode
 

Cut a node, i.e break the link between the node and its current parent node.

parentNode can be NULL, for example when node == scene. In this case all the children of scene are cut.

Definition at line 209 of file mainScene.cpp.

References buildGL(), deleteNode(), engineLoader, X3DTK::X3D::EngineLoader::release(), and x3dscene.

Referenced by deleteNode().

void X3DTK::MainScene::deleteNode X3DAbstractNode *  node,
X3DAbstractNode *  parentNode
 

Delete a node i.e break the link between the node and its current parent node and delete it.

parentNode can be NULL, for example when node == scene. In this case all the children of scene are deleted.

Definition at line 260 of file mainScene.cpp.

References cutNode(), isADescendant(), mainController, releaseNode(), MainController::removeX3DQtMap(), and x3dscene.

Referenced by cutNode(), and releaseNode().

void X3DTK::MainScene::draw  )  [virtual]
 

Draw the scene from the openGL graph glscene.

Definition at line 305 of file mainScene.cpp.

References animalEngines, glscene, X3DTK::GL::MyRenderer::render(), and renderer.

SFVec3f X3DTK::MainScene::getBboxMax  )  const [inline]
 

Get the Bounding Box maxima.

Definition at line 145 of file mainScene.h.

References max.

SFVec3f X3DTK::MainScene::getBboxMin  )  const [inline]
 

Get the Bounding Box minima.

Definition at line 142 of file mainScene.h.

References min.

MainController* X3DTK::MainScene::getMainController  )  const [inline]
 

Get the main GUI.

Definition at line 148 of file mainScene.h.

References mainController.

X3D::Scene* X3DTK::MainScene::getX3DScene  )  const [inline]
 

Get the x3d scene.

Definition at line 139 of file mainScene.h.

References x3dscene.

Referenced by MainController::fileOpen(), and MainController::fileReload().

bool X3DTK::MainScene::isADescendant X3DAbstractNode *  node1,
X3DAbstractNode *  node2
[private]
 

Test if node1 is a descendant of node2.

Definition at line 581 of file mainScene.cpp.

Referenced by deleteNode(), and pastNode().

void X3DTK::MainScene::keyPressEvent animal::KeyEvent e  ) 
 

Deal with key press event. Return false if the event is not handled.

Definition at line 597 of file mainScene.cpp.

References animalEngines.

Referenced by MainController::keyPressEvent().

void X3DTK::MainScene::load const char *  file,
X3D::X3DNode *  node,
bool  fileValidation = false
 

Load the scene from the given file and insert the scene's children from the given node.

Definition at line 127 of file mainScene.cpp.

References engineLoader, X3DTK::X3D::EngineLoader::initialize(), pastNode(), and x3dloader.

void X3DTK::MainScene::load const char *  file,
bool  fileValidation = false
[virtual]
 

Load the scene from file. It erases the existed x3d scene.

Definition at line 106 of file mainScene.cpp.

References buildGL(), engineLoader, X3DTK::X3D::EngineLoader::initialize(), releaseNode(), x3dloader, and x3dscene.

Referenced by MainController::fileInsert(), MainController::fileOpen(), and MainController::fileReload().

void X3DTK::MainScene::mouseDoubleClickEvent animal::MouseEvent e  ) 
 

Deal with mouse double-click event. Return false if the event is not handled.

Definition at line 603 of file mainScene.cpp.

References animalEngines.

Referenced by MainController::mouseDoubleClickEvent().

void X3DTK::MainScene::mouseMoveEvent animal::MouseEvent e  ) 
 

Deal with mouse move event. Return false if the event is not handled.

Definition at line 609 of file mainScene.cpp.

References animalEngines.

Referenced by MainController::mouseMoveEvent().

void X3DTK::MainScene::mousePressEvent animal::MouseEvent e  ) 
 

Deal with mouse press event. Return false if the event is not handled.

Definition at line 615 of file mainScene.cpp.

References animalEngines.

Referenced by MainController::mousePressEvent().

void X3DTK::MainScene::mouseReleaseEvent animal::MouseEvent e  ) 
 

Deal with mouse release event. Return false if the event is not handled.

Definition at line 621 of file mainScene.cpp.

References animalEngines.

Referenced by MainController::mouseReleaseEvent().

void X3DTK::MainScene::move double  dt  )  [virtual]
 

Move the scene.

Definition at line 361 of file mainScene.cpp.

References allEngineNodes, animalEngines, and updateGL().

Referenced by MainController::doStep().

template<typename GroupingNode_t>
void X3DTK::MainScene::newX4DClass  )  [inline]
 

Define a new x3d grouping node.

Examples:
qtapp.cpp.

Definition at line 118 of file mainScene.h.

References groupingNodeCreator, X3DTK::X3D::GroupingNodeCreator::newX4DClass(), and x3dloader.

bool X3DTK::MainScene::pastNode X3DAbstractNode *  node,
X3DAbstractNode *  parentNode
 

Past a node from a parent node.

Definition at line 161 of file mainScene.cpp.

References buildGL(), engineLoader, X3DTK::X3D::EngineLoader::initialize(), and isADescendant().

Referenced by load().

animal::ConstrainedItem * X3DTK::MainScene::pickPoint float  origin[3],
float  direction[3],
float  threshold
 

Definition at line 629 of file mainScene.cpp.

References allEngineNodes, and animalEngines.

Referenced by MainController::pickPoint().

void X3DTK::MainScene::releaseNode X3DAbstractNode *  node  )  [private]
 

Release a node, i.e delete it if there is no more parent link.

if node == scene, all the children of scene are released.

Definition at line 284 of file mainScene.cpp.

References deleteNode(), glUpdates, and x3dscene.

Referenced by buildGL(), deleteNode(), load(), and ~MainScene().

void X3DTK::MainScene::removeEngine animal::Engine engine  ) 
 

Remove an engine.

Definition at line 472 of file mainScene.cpp.

References animalEngines, and computeBbox().

void X3DTK::MainScene::reset  ) 
 

Reset the scene for the animation.

Definition at line 343 of file mainScene.cpp.

References allEngineNodes, animalEngines, and updateGL().

Referenced by MainController::reset().

void X3DTK::MainScene::save const char *  file  ) 
 

Save the x3d graphe in a file.x3d.

Definition at line 329 of file mainScene.cpp.

References allEngineNodes, and x3dscene.

Referenced by MainController::fileSave().

void X3DTK::MainScene::setMainController MainController MC  )  [inline]
 

Definition at line 151 of file mainScene.h.

References mainController.

Referenced by MainController::MainController().

void X3DTK::MainScene::setSelectedNode X3D::X3DBoundedObject *   ) 
 

highlight a node

Definition at line 656 of file mainScene.cpp.

References m_selectedNode, renderer, and X3DTK::GL::MyRenderer::setBoundedObject().

void X3DTK::MainScene::updateGL  ) 
 

Update all the gl nodes contained in the list glNodeToUpdate.

Definition at line 486 of file mainScene.cpp.

References computeBbox(), and glUpdates.

Referenced by move(), and reset().


Member Data Documentation

X3D::EngineNodes X3DTK::MainScene::allEngineNodes [private]
 

The group of engines which belong to the scene graph.

Definition at line 228 of file mainScene.h.

Referenced by computeBbox(), MainScene(), move(), pickPoint(), reset(), and save().

AnimalEngines X3DTK::MainScene::animalEngines [private]
 

The group of engines which do not belong to the scene graph (added directly using method addEngine).

Definition at line 224 of file mainScene.h.

Referenced by addEngine(), clearEngines(), computeBbox(), draw(), keyPressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), move(), pickPoint(), removeEngine(), and reset().

X3D::BBoxUpdater* X3DTK::MainScene::bbupdater [private]
 

update the bounding box of the scene

Definition at line 240 of file mainScene.h.

Referenced by computeBbox(), and MainScene().

X3D::EngineNodes X3DTK::MainScene::collisionEngines [private]
 

collision detection engines (subset of allEngineNodes)

Definition at line 231 of file mainScene.h.

Referenced by MainScene().

X3D::EngineNodes X3DTK::MainScene::dynamicEngines [private]
 

engines which can react to collisions (subset of allEngineNodes)

Definition at line 230 of file mainScene.h.

Referenced by MainScene().

X3D::EngineLoader* X3DTK::MainScene::engineLoader [private]
 

The visitor used for creating animal::engines associated with x3d nodes.

Definition at line 213 of file mainScene.h.

Referenced by cutNode(), load(), MainScene(), and pastNode().

GL::Scene* X3DTK::MainScene::glscene [protected]
 

The openGL scene graph.

Definition at line 195 of file mainScene.h.

Referenced by buildGL(), draw(), and ~MainScene().

GLUpdates X3DTK::MainScene::glUpdates [protected]
 

gl updates to perform after an animation step

Definition at line 203 of file mainScene.h.

Referenced by buildGL(), releaseNode(), and updateGL().

X3DTK::X3D::GroupingNodeCreator X3DTK::MainScene::groupingNodeCreator [private]
 

Definition at line 207 of file mainScene.h.

Referenced by newX4DClass().

X3D::EngineNodes X3DTK::MainScene::kinematicEngines [private]
 

engines which do not react to collisions (subset of allEngineNodes)

Definition at line 229 of file mainScene.h.

Referenced by MainScene().

X3D::X3DBoundedObject* X3DTK::MainScene::m_selectedNode [private]
 

A selected object which must be highlighted.

Definition at line 237 of file mainScene.h.

Referenced by setSelectedNode().

MainController* X3DTK::MainScene::mainController [private]
 

The main GUI.

Definition at line 234 of file mainScene.h.

Referenced by deleteNode(), getMainController(), and setMainController().

SFVec3f X3DTK::MainScene::max [protected]
 

Maxima for the bounding box.

Definition at line 201 of file mainScene.h.

Referenced by computeBbox(), and getBboxMax().

SFVec3f X3DTK::MainScene::min [protected]
 

Minima for the bounding box.

Definition at line 198 of file mainScene.h.

Referenced by computeBbox(), and getBboxMin().

GL::MyRenderer X3DTK::MainScene::renderer [private]
 

The openGL scene graph renderer.

Definition at line 221 of file mainScene.h.

Referenced by draw(), and setSelectedNode().

X3DGLMap X3DTK::MainScene::x3dGLMap
 

The map which links X3DTK::X3D::X3DNode to their corresponding X3DTK::GL::X3DNode.

Definition at line 217 of file mainScene.h.

Referenced by buildGL().

X3D::Loader* X3DTK::MainScene::x3dloader [private]
 

The x3d scene graph loader from a file .x3d.

Definition at line 210 of file mainScene.h.

Referenced by load(), newX4DClass(), and ~MainScene().

X3D::Scene* X3DTK::MainScene::x3dscene [protected]
 

The x3d scene graph.

Definition at line 192 of file mainScene.h.

Referenced by buildGL(), computeBbox(), cutNode(), deleteNode(), getX3DScene(), load(), MainScene(), releaseNode(), save(), and ~MainScene().


The documentation for this class was generated from the following files:
Generated on Thu Dec 23 13:52:34 2004 by doxygen 1.3.6