H3D API
2.4.1
|
The Scene node is topmost node that takes care of the rendering of the scene graph both haptically and graphically. More...
#include <H3D/Scene.h>
Classes | |
class | EventSink |
The EventSink class makes all fields up-to-date what are routed to it, with the exception of PeriodicUpdateFields. More... | |
Public Types | |
enum | CallbackCode { CALLBACK_DONE , CALLBACK_CONTINUE } |
Return code for callback functions. More... | |
typedef CallbackCode(* | CallbackFunc) (void *data) |
Callback function type. | |
typedef void(* | ProgramSettingsCallbackFunc) (ProgramSettingsEvent event, const ProgramSetting &settings, void *data) |
Callback function type. | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
Public Member Functions | |
Scene (Inst< SFChildNode > _sceneRoot=0, Inst< MFWindow > _window=0, Inst< SFFloat > _frameRate=0, Inst< MFString > _profiledResult=0, Inst< SFFloat > _maxFrameRate=0, Inst< SFNvidiaGraphicsOptions > _nvidiaGraphicsOptions=0) | |
Constructor. | |
~Scene () | |
Destructor. | |
TraverseInfo * | getLastTraverseInfo () |
Returns the TraverseInfo from the previous sceneRoot traversal. | |
void | setActive (bool _active) |
Set whether this Scene instance should be active or not. More... | |
bool | isActive () |
Returns if the Scene instance is active or not. | |
virtual void | idle () |
This function will be called by the event loop when there are no other events to process and the Scene is active. More... | |
void | loadSceneRoot (const string &url) |
Load the scene graph that is to be the root of the Scene object. More... | |
void | setSceneRoot (SAI::SAIScene *scene_info) |
Set the scene to use based on a SAIScene object. | |
SAI::Browser * | getSAIBrowser () |
Returns the SAI::Browser object for this Scene. | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual void | render () |
the render() function is used for the depth-first rendering traversal of the scene-graph. More... | |
virtual void | traverseSG (TraverseInfo &ti) |
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More... | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the Node. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on Node to p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the Node. More... | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
Static Public Member Functions | |
static void | mainLoop () |
Static function that is called to start the main event loop. More... | |
static void | addCallback (CallbackFunc func, void *data) |
Add a callback function to be called after scene traversal and rendering. | |
static void | addProgramSetting (Field *field, const string &name="", const string §ion="Main settings") |
Add a program setting value. More... | |
static bool | removeProgramSetting (const string &name, const string §ion="Main settings") |
Remove a program setting value. More... | |
static bool | removeProgramSetting (Field *field) |
Remove all program settings referring to a field. More... | |
static Field * | getProgramSetting (const string &name, const string §ion="Main settings") |
Get a program setting value. More... | |
static SettingsIterator | programSettingsBegin () |
Get an iterator to the first element of the program settings. More... | |
static SettingsIterator | programSettingsEnd () |
Get an iterator to the end of the program settings. | |
static ProgramSettingsCallbackId | addProgramSettingsCallback (ProgramSettingsCallbackFunc func, void *data) |
Add a callback function to be called each time a new program settings value is added, removed or changed. | |
static bool | removeProgramSettingsCallback (ProgramSettingsCallbackId id) |
Remove a program settings callback function. | |
static void | clearProgramSettingsCallbacks () |
Remove all program setting callback functions. | |
static H3D::Node * | findChildNode (H3D::X3DGroupingNode *group, const std::string &nodeType, const std::string &nodeName="") |
Find a child node for a given group node with a certain nodeType and optional name. | |
static H3D::Node * | findNodeType (H3D::Node *node, const std::string &nodeType, const std::string &nodeName="") |
Top down search for a node with a certain nodeType and optional name starting from node passed as argument. | |
template<typename NodeType > | |
static void | findNodes (Node &_node, AutoRefVector< NodeType > &_result, const std::string &_nodeName="", NodeParentsMap *_parentMap=NULL, SearchFieldNameMap *_searchFieldNames=NULL, StringVec *_typeNames=NULL, bool _exactNodeName=true, bool _verbose=false, Node *_parent=NULL, StringVec *_ignoreTraverseNodeTypeNames=NULL) |
Finds all the nodes of a given type (and optional name) by searching downwards from _node through all SFNode and MFNode fields. More... | |
static void | removeCallback (void *data) |
Remove a callback function by finding a callback with the same data adress. | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
Public Attributes | |
H3DUniquePtr< SFChildNode > | sceneRoot |
The scene graph to render in this scene. More... | |
H3DUniquePtr< MFWindow > | window |
The windows to render into this scene. More... | |
H3DUniquePtr< SFFloat > | frameRate |
The instantaneous frame rate of the scene. More... | |
H3DUniquePtr< SFFloat > | maxFrameRate |
A desired maximum frame rate (Hz). More... | |
Static Public Attributes | |
static H3DUniquePtr< SFTime > | time |
Current time within the simulation, updated during each graphic loop. More... | |
static set< Scene * > | scenes |
All instances of Scene that has been created. | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
static H3DUniquePtr< EventSink > | eventSink |
Any field routed to this field will be updated once per frame. | |
Additional Inherited Members | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The Scene node is topmost node that takes care of the rendering of the scene graph both haptically and graphically.
Scene::mainLoop() can be called to start the main event loop when using GLUT, e.g. start the haptic and graphical rendering. Before this function is called at least one instance of Scene must have created and be active.
|
static |
Add a program setting value.
A program setting value is a global Field value assiciated with a name. These settings can be used in GUIs in e.g. H3DViewer to allow a user to change the values. Settings can be dynamically added and removed during the execution of a program.
field | The field to assiciate the name with. A field will be automatically removed from the settings if destructed somewhere else. |
name | The name of the parameter. If "" the name of the field will be used. |
section | The type if paramter it is, e.g. graphics. |
References H3D::Field::getName(), H3D::Field::markProgramSetting(), and H3DUtil::RefCountedClass::name.
|
inlinestatic |
Finds all the nodes of a given type (and optional name) by searching downwards from _node through all SFNode and MFNode fields.
[in] | _node | The node to start searching down from |
[out] | _result | The list of nodes found matching the search criteria. The type of this parameter is used to define the type of nodes to search for. Only nodes that can be dynamically cast to NodeType will be included in the results. |
[in] | _nodeName | The name of the node(s) to find. If not empty then only nodes matching this name are found. If empty, then nodes of any name are found. |
[out] | _parentMap | A map from a found node to a list of the node's parents. If NULL then no information about the found node's parents is collected. |
[in] | _searchFieldNames | A map from node type name, to a list of field names to search through for that node type. If NULL then all fields are searched. |
[in] | _typeNames | List of acceptable node type names that found nodes must match. |
[in] | _exactNodeName | If true, then _nodeName must exactly match the node's name, otherwise the node's name must just contain _nodeName. |
[in] | _verbose | If true, then output will be written to the Console to show the search path. |
[in] | _parent | The parent of this node. Used during recursion, should usually be left as NULL when called from user code. |
[in] | _ignoreTraverseNodeTypeNames | The nodes with type name in the _ignoreTraverseNodeTypeNames will neither be traversed nor added to the result. |
Examples:
|
static |
Get a program setting value.
name | The name of the parameter. |
section | The type if paramter it is, e.g. graphics. |
References H3DUtil::RefCountedClass::name.
Referenced by removeProgramSetting().
|
virtual |
This function will be called by the event loop when there are no other events to process and the Scene is active.
Performs the rendering.
References H3D::X3DViewpointNode::accForwardMatrix, H3D::GraphicsOptions::bindlessTexturesUnusedTime, CALLBACK_DONE, H3D::TraverseInfo::callPostTraverseCallbacks(), H3D::DefaultAppearance::defaultAppearance, H3D::DeviceInfo::device, H3D::X3DShapeNode::disable_lighting_if_no_app, eventSink, frameRate, H3D::DeviceInfo::getActive(), H3D::GlobalSettings::getActive(), H3D::NavigationInfo::getActive(), H3D::X3DViewpointNode::getActive(), H3DUtil::ThreadBase::getCurrentThreadId(), H3D::Node::getField(), H3D::H3DHapticsDevice::getHAPIDevice(), H3DUtil::ThreadBase::getMainThreadId(), H3D::TraverseInfo::getMultiPassTransparency(), H3D::GlobalSettings::getOptionNode(), H3D::H3DHapticsDevice::getThread(), H3DUtil::ThreadBase::getThreadId(), H3DUtil::ThreadBase::getThreadName(), H3D::NavigationInfo::headlight, H3D::NavigationInfo::headlightShadows, H3D::H3DHapticsDevice::initialized, H3DUtil::MutexLock::lock(), H3D::H3DSingleTextureNode::makeUnusedTexturesNonResident(), H3D::Appearance::material, maxFrameRate, H3DUtil::Exception::H3DException::message, H3D::RenderProperties::multiPassTransparency, H3D::TraverseInfo::nrLayers(), H3D::H3DHapticsDevice::postRender(), H3D::H3DHapticsDevice::preRender(), H3D::H3DDisplayListObject::DisplayList::rebuildAllDisplayLists(), H3D::H3DWindowNode::render(), H3D::H3DHapticsDevice::renderEffects(), H3D::Appearance::renderProperties, H3D::H3DHapticsDevice::renderShapes(), H3D::Anchor::replaceSceneRoot(), H3D::H3DMultiPassRenderObject::resetCounters(), Rotation(), sceneRoot, H3D::X3DAppearanceNode::setDefaultUsingMultiPassTransparency(), H3D::H3DWindowNode::setMultiPassTransparency(), H3D::H3DHapticsDevice::stylus, time, H3D::X3DViewpointNode::totalOrientation, H3D::H3DHapticsDevice::trackerOrientation, H3D::Node::traverseSG(), H3DUtil::MutexLock::unlock(), H3D::H3DHapticsDevice::updateDeviceValues(), H3D::X3DProgrammableShaderObject::use_bindless_textures, H3D::H3DHapticsDevice::weightedProxyPosition, and window.
void Scene::loadSceneRoot | ( | const string & | url | ) |
Load the scene graph that is to be the root of the Scene object.
This function should always be used instead of setting sceneRoot directly in order to keep SAI information up to data.
References H3D::X3D::createX3DFromURL().
|
static |
Static function that is called to start the main event loop.
Before this function is called at least one instance of Scene must have created and be active.
References H3D::GLUTWindow::initGLUT().
|
static |
Get an iterator to the first element of the program settings.
Adding or removing a new program setting will make this iterator invalid.
|
static |
Remove a program setting value.
name | The name of the parameter. If "" the name of the field will be used. |
section | The type if paramter it is, e.g. graphics. |
References getProgramSetting(), and H3DUtil::RefCountedClass::name.
Referenced by removeProgramSetting(), and H3D::Field::~Field().
|
static |
Remove all program settings referring to a field.
field | The field which settings to remove. |
References H3D::Field::markProgramSetting(), and removeProgramSetting().
|
inline |
H3DUniquePtr< SFFloat > H3D::Scene::frameRate |
H3DUniquePtr< SFFloat > H3D::Scene::maxFrameRate |
H3DUniquePtr< SFChildNode > H3D::Scene::sceneRoot |
The scene graph to render in this scene.
Access type: inputOutput
Referenced by idle(), and H3D::Anchor::replaceSceneRoot().
|
static |
Current time within the simulation, updated during each graphic loop.
Access type: outputOnly Default value: -1
Referenced by H3D::DirectShowDecoder::DirectShowDecoder(), H3D::H3DDisplayListObject::DisplayList::DisplayList(), H3D::H3DNavigation::doNavigation(), H3D::DynamicTransform::DynamicTransform(), idle(), H3D::H3DSingleTextureNode::inUse(), H3D::Collision::movingSphereIntersect(), H3D::OculusRiftSensor::OculusRiftSensor(), H3D::PlanarReflector::PlanarReflector(), Scene(), H3D::SimpleMovieTexture::SimpleMovieTexture(), H3D::SpaceWareSensor::SpaceWareSensor(), H3D::VirtualHandGloveSensor::VirtualHandGloveSensor(), and H3D::X3DTimeDependentNode::X3DTimeDependentNode().
H3DUniquePtr< MFWindow > H3D::Scene::window |
The windows to render into this scene.
Access type: inputOutput
Referenced by H3D::FrameBufferTextureGenerator::blitColorBuffer(), idle(), H3D::FrameBufferTextureGenerator::preProcessFBO(), and H3D::FrameBufferTextureGenerator::render().