SPIN Framework
|
The main class that maintains the scene and handles OSC messages. More...
#include <SceneManager.h>
Public Member Functions | |
SceneManager (std::string id) | |
void | init () |
void | debugContext () |
void | debugNodes () |
void | debugStateSets () |
void | debugSceneGraph () |
void | debug () |
void | setGraphical (bool b) |
bool | isGraphical () |
void | setLog (spinLog &log) |
void | registerStateSet (ReferencedStateSet *s) |
void | unregisterStateSet (ReferencedStateSet *s) |
void | sendNodeTypes (lo_address txAddr=0) |
void | sendStateTypes (lo_address txAddr=0) |
void | sendNodeList (std::string type, lo_address txAddr=0) |
void | sendConnectionList (lo_address txAddr=0) |
std::vector< std::string > | getAllNodeTypes () |
ReferencedNode * | createNode (std::string id, std::string type) |
ReferencedNode * | createNode (const char *id, const char *type) |
ReferencedNode * | getNode (std::string id) |
ReferencedNode * | getNode (const char *id) |
ReferencedNode * | getNode (const char *id, const char *type) |
ReferencedNode * | getOrCreateNode (const char *id, const char *type) |
ReferencedStateSet * | getStateSet (const char *id) |
ReferencedStateSet * | createStateSet (const char *id, const char *type) |
ReferencedStateSet * | createStateSet (const char *fname) |
void | setWorldStateSet (const char *s) |
std::vector< ReferencedNode * > | findNodes (const char *pattern) |
std::vector< ReferencedStateSet * > | findStateSets (const char *pattern) |
std::vector< SoundConnection * > | getConnections () |
void | deleteNode (const char *id) |
void | deleteGraph (const char *id) |
void | doDelete (ReferencedNode *n) |
void | doDelete (ReferencedStateSet *n) |
void | clear () |
void | clearUsers () |
void | clearStates () |
void | update () |
osg::Matrix | getWorldCoords (t_symbol *id) |
void | exportScene (const char *nodeID, const char *filename) |
std::string | getStateAsXML (std::vector< lo_message > nodeState) |
std::string | getNodeAsXML (ReferencedNode *n, bool withUsers) |
std::string | getConnectionsAsXML () |
std::vector< t_symbol * > | getSavableStateSets (ReferencedNode *n, bool withUsers) |
bool | saveXML (const char *filename, bool withUsers=false) |
bool | saveUsers (const char *s) |
bool | createNodeFromXML (TiXmlElement *XMLnode, const char *parentNode) |
bool | createStateSetFromXML (TiXmlElement *XMLnode) |
bool | createConnectionsFromXML (TiXmlElement *XMLnode) |
bool | loadXML (const char *filename) |
void | refreshAll () |
void | refreshSubscribers (const std::map< std::string, lo_address > &clients) |
void | setGravity (float x, float y, float z) |
void | setUpdateRate (float seconds) |
void | detectCollision (bool &lastColState, btCollisionWorld *cw) |
Public Attributes | |
std::string | sceneID |
osg::ref_ptr< osg::ClearNode > | rootNode |
osg::ref_ptr< ReferencedNode > | worldNode |
osg::ref_ptr< osg::Geode > | gridGeode |
t_symbol * | worldStateSet_ |
bool | graphicalMode |
osg::ref_ptr< GroupNode > | globalObserver |
bool | activeLights [OSG_NUM_LIGHTS] |
std::string | resourcesPath |
bool | lastColState |
btDynamicsWorld * | dynamicsWorld_ |
The main class that maintains the scene and handles OSC messages.
The SceneManager class should only be instantiated once for each process or thread. However, this should rarely be done directly because the spinContext instance (listener or server) have a better interface for including SPIN in an application.
void spin::SceneManager::clear | ( | ) |
Clears scene elements that are not part of any user's subgraphs
void spin::SceneManager::clearStates | ( | ) |
Forces a removal of all states from the scene graph. This should only be used to clean up upon exit.
void spin::SceneManager::clearUsers | ( | ) |
Clears only the users from the scene (and any attached nodes in their subgraphs
void spin::SceneManager::deleteGraph | ( | const char * | id | ) |
deleteGraph() operates similarly to deleteNode(), except that all children are also deleted.
void spin::SceneManager::deleteNode | ( | const char * | id | ) |
This method removes a node from the scene, however the actual work is done by the doDelete() method.
NOTE: All children of the node will remain, but will be re-attached to the 'world' node instead. If you want to destroy all children as well, then use deleteGraph().
void spin::SceneManager::doDelete | ( | ReferencedStateSet * | n | ) |
The doDelete method performs all of the necessary steps to delete a stateset. It is similar to the doDelete method for a note: it calls the node's removeFromScene() method, releases resources (eg, videos), removes it from the stateMap list, etc.
void spin::SceneManager::doDelete | ( | ReferencedNode * | n | ) |
The doDelete method performs all of the necessary steps to remove a node from the scene: The node's detach() method is called, which will actually remove it from the scene graph, and eliminate the OSC callback. The callbackUpdate() function is unregistered. And finally, a message is broadcasted to all clients.
void spin::SceneManager::refreshAll | ( | ) |
The refreshAll method results in a broadcast of all nodelists so that clients can create any missing nodes. Then, the full node state is broadcasted, for ALL nodes.
void spin::SceneManager::refreshSubscribers | ( | const std::map< std::string, lo_address > & | clients | ) |
The refreshSubscribers method results in a publication of all nodelists to the given TCP subscribers. Then, the full node state is published to the subscribers, for ALL nodes.
void spin::SceneManager::setGravity | ( | float | x, |
float | y, | ||
float | z | ||
) |
Set the gravity vector for the physics engine (only used by some nodes).
void spin::SceneManager::setUpdateRate | ( | float | seconds | ) |
Sets the update delay for the physics engine (in seconds). The default is 0.02 seconds (ie, 50hz).
void spin::SceneManager::update | ( | ) |
The update method is where any thread-safe changes to the scene graph should go. The method is guaranteed to be called only when there are no traversals being performed.
The scene manager can operate in graphical mode or non-graphical. > For graphical mode, the full scene graph structure is instantiated, and can thus be renderered by an OSG rendering process. > Non-graphical mode only maintains the basic features in the scene graph that are needed for GUIs and information servers. Eg, lights are not created.