vrecko
virtual reality framework
|
#include <Scene.h>
Classes | |
class | EOIteratorHelper |
Class for iterating through all environment objects in non-main threads. More... | |
struct | OBJ_INT_PRIO |
struct | SC_INT_PRIO |
Public Types | |
typedef Sgi::hash_map < unsigned long, EnvironmentObject * > | EOMap |
Public Types inherited from vrecko::BaseClass | |
enum | NotificationTypes { NOTIFICATION_DELETE_CLASS = 1, NOTIFICATION_EO_REGISTERING = 2, NOTIFICATION_EO_UNREGISTERING = 4, NOTIFICATION_PROGRAM_TERMINATION = 8, NOTIFICATION_ALL = 0xFFFFFFFF } |
Public Member Functions | |
Scene () | |
~Scene () | |
void | prepareForTermination () |
void | setDescription (const std::string &desc) |
Set scene description. More... | |
const std::string & | getDescription (void) |
Return scene description. More... | |
void | update (void) |
This method is called periodically in case this instance is registered in Scheduler. More... | |
osg::MatrixTransform * | getRoot () |
Return pointer to the root. More... | |
osg::MatrixTransform * | getEORoot () |
Return pointer to the node where the EOs are added. More... | |
unsigned long | getFreeID (unsigned long req_id) |
Returns free ID for EnvironmentObject. More... | |
int | addEnvironmentObject (EnvironmentObject *environment_object, osg::Group *parentNode) |
Add EnvironmentObject to the scene to the scene under the parent node. More... | |
int | addEnvironmentObject (EnvironmentObject *environment_object) |
Add EnvironmentObject to the scene. More... | |
bool | removeEnvironmentObject (unsigned long id) |
Remove EnvironmentObject from the scene (unregister id + remove object from ALL of its parents) More... | |
EnvironmentObject * | getEnvironmentObject (unsigned long id, bool bReportErrorIfNotFound=true) |
Return pointer to the EnvironmentObject with given ID. More... | |
bool | registerEnvironmentObject (EnvironmentObject *environment_object) |
bool | unregisterEnvironmentObject (EnvironmentObject *environment_object) |
bool | unregisterEnvironmentObject (unsigned long id) |
EOMap & | getEOMap (void) |
Return reference to the map with EnvironmentObjects. More... | |
void | lockEOMapForRead (void) |
Usage is not required in the main thread. More... | |
void | unlockEOMapForRead (void) |
Usage is not required in the main thread. More... | |
void | lockEOMapForWrite (void) |
Usage is not required in the main thread. More... | |
void | unlockEOMapForWrite (void) |
Usage is not required in the main thread. More... | |
bool | isLoaded (void) |
Has the Scene class finished loading its data from the XML files? More... | |
void | setIsLoaded (bool bNewValue) |
EnvironmentObject * | getCollisionObject (EnvironmentObject *eobject) |
EnvironmentObject ** | getCollisionObjects (EnvironmentObject *eobject, int &size) |
EnvironmentObject ** | getCollisionObjects (esg::OSGAdapter *pOSGAdapter, const osg::Matrix &transf, int &size) |
EnvironmentObject * | getRayIntersection (const osg::Vec3 &origin, const osg::Vec3 &dir) |
EnvironmentObject * | getRayIntersection (const osg::Vec3 &origin, const osg::Vec3 &dir, osg::Vec3 &intersection_point) |
bool | getRayIntersection (EnvironmentObject *eobject, const osg::Vec3 &origin, const osg::Vec3 &dir, osg::Vec3 &intersection_point) |
void | getObjectExtent (EnvironmentObject *eobject, const osg::Vec3 &dir, float &min, float &max) |
bool | separation (esg::Matrix4 *trMat1, std::vector< esg::OSGAdapter * > object1, esg::Matrix4 *trMat2, std::vector< esg::OSGAdapter * > object2, unsigned d1=UINT_MAX, unsigned d2=UINT_MAX) |
bool | calcNodeBBox (osg::Node *node, osg::BoundingBox *outBox, osg::Matrix *outTransform, bool *bTransformUsed=NULL, unsigned long dwFlags=0, osg::Node *subTreeToIgnore=NULL) |
bool | getCollisions (CollisionParams *params, COLLISIONS_INFO_VECTOR **collisions, unsigned long limitToEO1=0, unsigned long limitToEO2=0) |
bool | addPartitioningSceneInterface (SP_SceneInterface *newInterface, int priority=0) |
void | removePartitioningSceneInterface (SP_SceneInterface *anInterface) |
SP_SceneInterface * | getPartitioningSceneInterface (int id=PARTITIONING_INTERFACE_DEFAULT) |
bool | addPartitioningObjectInterface (SP_ObjectInterface *newInterface, int priority=0) |
void | removePartitioningObjectInterface (SP_ObjectInterface *anInterface) |
SP_ObjectInterface * | getPartitioningObjectInterface (int id=PARTITIONING_INTERFACE_DEFAULT) |
void | logHierarchy (const osg::Node *topNode, const char *note=NULL) |
Output the (sub-)scene the hierarchy into the logger. More... | |
Public Member Functions inherited from vrecko::BaseClass | |
BaseClass (const char *startingSenderString) | |
The main constructor. More... | |
BaseClass (BaseClass &bc) | |
Copy constructor. Probably not really used. More... | |
virtual | ~BaseClass () |
Destructor. More... | |
virtual bool | initialize (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parameters=NULL) |
Core initialization. More... | |
virtual bool | initializeFromString (const char *xmlString) |
Helper method that allows to initialize ability from a XML-formatted string. More... | |
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * | saveXMLParameters (XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *) |
Save current setting into a XML node. More... | |
bool | inputPresent (const std::string &name) |
Returns true if input pin (not request inputpin ) with given name is present. More... | |
bool | outputPresent (const std::string &name) |
Returns true if output pin (not request output pin) with given name is present. More... | |
void | addInputPin (InputPinBase *pin) |
Adds an input pin. More... | |
void | removeInputPin (InputPinBase *pin) |
Removes an input pin. More... | |
void | addOutputPin (OutputPinBase *pin) |
Adds an output pin. More... | |
void | removeOutputPin (OutputPinBase *pin) |
Removes and output pin. More... | |
void | addRequestInputPin (RequestInputPinBase *pin) |
Adds a request input pin. More... | |
void | removeRequestInputPin (RequestInputPinBase *pin) |
Removes a request input pin. More... | |
void | addRequestOutputPin (RequestOutputPinBase *pin) |
Adds a request output pin. More... | |
void | removeRequestOutputPin (RequestOutputPinBase *pin) |
Removes a request output pin. More... | |
bool | addNotification (BaseClass *receiver, unsigned long notificationTypes) |
Registers an observer that will be notified if a specific change occurs. More... | |
bool | removeNotification (BaseClass *receiver, unsigned long notificationTypes=NOTIFICATION_ALL) |
Unregisters a previously registered observer. More... | |
virtual void | processEvent (const std::string &input_name, VreckoMessage *pMessage) |
Internal method for processing the events. More... | |
virtual VreckoMessage * | processRequest (const std::string &request_input_name, VreckoMessage *pMessage) |
Internal method for processing the requests. More... | |
virtual const std::string & | getSenderString (void) |
Returns the sender (or receiver) identification string. More... | |
void | reportError (const std::string &error) |
Print error message. More... | |
void | setPriority (long int pr) |
Sets the priority. (Possible problems - read the full description for more info) More... | |
long int | getPriority (void) const |
Returns current object priority. More... | |
void | setAttribute (const std::string &attr_name, int attr_value) |
Sets an attribute value. More... | |
int | getAttribute (const std::string &attr_name) |
Returns attribute value. More... | |
int | getAttribute (const char *attr_name) |
Returns attribute value. More... | |
void | deleteAttribute (const std::string &attr_name) |
Delete an attribute. More... | |
void | setSceneFile (const std::string &sceneFileName) |
Set the name of the file this component was in (and possibly will be saved to). More... | |
const std::string & | getSceneFile () const |
Get the name of the file this component was in. More... | |
virtual void | preInitialize (void) |
OBSOLETE METHOD, kept for backwards compatibility. More... | |
virtual void | postInitialize (void) |
OBSOLETE METHOD, kept for backwards compatibility. More... | |
virtual bool | loadXMLParameters (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *) |
OBSOLETE METHOD, kept for backwards compatibility. More... | |
virtual bool | loadXMLParameters (const char *xmlString) |
OBSOLETE METHOD, kept for backwards compatibility. More... | |
InputPinBase * | getInputPin (const char *strName) |
Returns pointer to an input pin with specified name. More... | |
OutputPinBase * | getOutputPin (const char *strName) |
Returns pointer to an output pin with specified name. More... | |
RequestInputPinBase * | getRequestInputPin (const char *strName) |
Returns pointer to an request input pin with specified name. More... | |
RequestOutputPinBase * | getRequestOutputPin (const char *strName) |
Returns pointer to an input pin with specified name. More... | |
Protected Member Functions | |
bool | calcNodeBBoxHelper (osg::Node *node, osg::BoundingBox *outBox, osg::Matrix *outTransform, bool *bTransformUsed, unsigned long dwFlags, osg::Node *nodeToStopTraversalAt, osg::Node *subTreeToIgnore) |
void | logHierarchyHelper (int level, const osg::Node *node) |
void | logHierarchyDrawableHelper (int level, const osg::Drawable *dw) |
Protected Member Functions inherited from vrecko::BaseClass | |
bool | sendNotifications (unsigned long notificationType, void *notificationData) |
virtual int | processNotification (BaseClass *sender, unsigned long notificationType, void *notificationData) |
Process an incoming notification. More... | |
IOPinBase * | findPinInList (const char *strName, PinList *pinList) |
Internal method to find a given pin in a given list. More... | |
Protected Attributes | |
std::string | description |
Scene description. More... | |
MTReadWriteLock | eoMapLock |
EOMap | environment_objects_map |
Map with EnvironmentObjects that have been added to the scene. More... | |
osg::MatrixTransform * | rootNode |
Root of the scenegraph - ... More... | |
osg::MatrixTransform * | eoRootNode |
Node where most EOs are added. More... | |
unsigned long | nextFreeID |
bool | _bIsLoaded |
Has the Scene class finished loading its data from the XML files? More... | |
DynamicArray< SC_INT_PRIO > | partitioningSceneInterfaces |
Partitioning interfaces for scene operations, sorted by priority. More... | |
DynamicArray< OBJ_INT_PRIO > | partitioningObjectInterfaces |
Partitioning interface for object operations, sorted by priority. More... | |
std::vector< ScenePSThreadInfo * > | partThreadsInfo |
int | lastUpdatePartThrIndex |
Which "partitioning" thread was last checked in the update. More... | |
Protected Attributes inherited from vrecko::BaseClass | |
AttributeMap | attribute |
MTReadWriteLock | attributeLock |
std::string | senderString |
MTLock | notificationsLock |
std::vector < NOTIFICATION_DESCRIPTION > | notifications |
long int | priority |
const std::string * | sceneFile |
PinList | inputPinsList |
PinList | outputPinsList |
PinList | requestInputPinsList |
PinList | requestOutputPinsList |
Friends | |
DWORD WINAPI | ScenePSThreadProc (ScenePSThreadInfo *lpParameter) |
Additional Inherited Members | |
Protected Types inherited from vrecko::BaseClass | |
typedef std::map< std::string, int > | AttributeMap |
Attributes. More... | |
typedef std::vector < osg::ref_ptr< IOPinBase > > | PinList |
typedef Sgi::hash_map<unsigned long, EnvironmentObject *> vrecko::Scene::EOMap |
vrecko::Scene::Scene | ( | ) |
vrecko::Scene::~Scene | ( | ) |
int vrecko::Scene::addEnvironmentObject | ( | EnvironmentObject * | environment_object, |
osg::Group * | parentNode | ||
) |
Add EnvironmentObject to the scene to the scene under the parent node.
|
inline |
Add EnvironmentObject to the scene.
bool vrecko::Scene::addPartitioningObjectInterface | ( | SP_ObjectInterface * | newInterface, |
int | priority = 0 |
||
) |
bool vrecko::Scene::addPartitioningSceneInterface | ( | SP_SceneInterface * | newInterface, |
int | priority = 0 |
||
) |
bool vrecko::Scene::calcNodeBBox | ( | osg::Node * | node, |
osg::BoundingBox * | outBox, | ||
osg::Matrix * | outTransform, | ||
bool * | bTransformUsed = NULL , |
||
unsigned long | dwFlags = 0 , |
||
osg::Node * | subTreeToIgnore = NULL |
||
) |
Calculates the bounding box of the scene node. Has various working modes - see the dwFlags parameter.
[bTransformUsed] returns whether the resulting transformation is identity (hence the AABox was created) or the transformation is not identity (so the oriented box was created). [subTreeToIgnore] is a child node (not necessarily a direct child) which will be ignored in the bounding box calculations. [dwFlags] is a combination of CNBB_F_*
|
protected |
EnvironmentObject * vrecko::Scene::getCollisionObject | ( | EnvironmentObject * | eobject | ) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return (the nearest - but not yet:( ) EnvironmentObject that collides with eobject
If any collision occurs (collision is detected) between an environment object and any env. object within the scene, it returns pointer to env. object which have collided with _eobject. Else it returns NULL. Collision detection is made using FDH14.
EnvironmentObject ** vrecko::Scene::getCollisionObjects | ( | EnvironmentObject * | eobject, |
int & | size | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return all EnvironmentObjects that collide with eobject.
If the collision occurs (collision is detected) between an environment object and any env. object within the scene, it returns pointer to env. objects which have collided with _eobject. Else it returs NULL. Collision detection is made with FDH14.
EnvironmentObject ** vrecko::Scene::getCollisionObjects | ( | esg::OSGAdapter * | pOSGAdapter, |
const osg::Matrix & | transf, | ||
int & | size | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return all EnvironmentObjects that collide with given OSGAdapter.
bool vrecko::Scene::getCollisions | ( | CollisionParams * | params, |
COLLISIONS_INFO_VECTOR ** | collisions, | ||
unsigned long | limitToEO1 = 0 , |
||
unsigned long | limitToEO2 = 0 |
||
) |
Get collision between object using currently registered collision detection structures.
Beware that by default there are NO STRUCTURES, so you would have to set them up to get proper collision detection.
This method will work only if scene and object partitioning interfaces have been added into the scene and objects have assigned the proper data abilities. Currently (4/2011) only useful for PHANToM precise multicontact collision detection using SNCH or Pointshell/Voxelgrid collision algorithms. For common projects you won't be able to run it - if you think you need collision detection, ask core developers about the current possibilities.
|
inline |
Return scene description.
EnvironmentObject * vrecko::Scene::getEnvironmentObject | ( | unsigned long | id, |
bool | bReportErrorIfNotFound = true |
||
) |
Return pointer to the EnvironmentObject with given ID.
|
inline |
Return reference to the map with EnvironmentObjects.
|
inline |
Return pointer to the node where the EOs are added.
unsigned long vrecko::Scene::getFreeID | ( | unsigned long | req_id | ) |
Returns free ID for EnvironmentObject.
void vrecko::Scene::getObjectExtent | ( | EnvironmentObject * | eobject, |
const osg::Vec3 & | dir, | ||
float & | min, | ||
float & | max | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return extent of the EnvironmentObject in given direction.
SP_ObjectInterface * vrecko::Scene::getPartitioningObjectInterface | ( | int | id = PARTITIONING_INTERFACE_DEFAULT | ) |
SP_SceneInterface * vrecko::Scene::getPartitioningSceneInterface | ( | int | id = PARTITIONING_INTERFACE_DEFAULT | ) |
EnvironmentObject * vrecko::Scene::getRayIntersection | ( | const osg::Vec3 & | origin, |
const osg::Vec3 & | dir | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return first EnvironmentObject that collides with given ray.
Better to use osgUtil::LineSegmentIntersector, see example here: http://decibel.fi.muni.cz/wiki/index.php/VRECKO_TestPruseciku
EnvironmentObject * vrecko::Scene::getRayIntersection | ( | const osg::Vec3 & | origin, |
const osg::Vec3 & | dir, | ||
osg::Vec3 & | intersection_point | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) Return first EnvironmentObject that collides with given ray and intersection point.
Better to use osgUtil::LineSegmentIntersector, see example here: http://decibel.fi.muni.cz/wiki/index.php/VRECKO_TestPruseciku
bool vrecko::Scene::getRayIntersection | ( | EnvironmentObject * | eobject, |
const osg::Vec3 & | origin, | ||
const osg::Vec3 & | dir, | ||
osg::Vec3 & | intersection_point | ||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) It tests if given EnvironmentObject is intersected by ray.
Better to use osgUtil::LineSegmentIntersector, see example here: http://decibel.fi.muni.cz/wiki/index.php/VRECKO_TestPruseciku
|
inline |
Return pointer to the root.
|
inline |
Has the Scene class finished loading its data from the XML files?
|
inline |
Usage is not required in the main thread.
|
inline |
Usage is not required in the main thread.
void vrecko::Scene::logHierarchy | ( | const osg::Node * | topNode, |
const char * | note = NULL |
||
) |
Output the (sub-)scene the hierarchy into the logger.
|
protected |
|
protected |
void vrecko::Scene::prepareForTermination | ( | ) |
Some preparation steps before the World is ending. This is called by the vreckoApp before the abilities are terminated.
bool vrecko::Scene::registerEnvironmentObject | ( | EnvironmentObject * | environment_object | ) |
This function only registers an object (anywhere in the scene) to the internal structures, so VRECKO knows about the object. You can insert it anywhere in the scene tree, even under a non-EO object.
bool vrecko::Scene::removeEnvironmentObject | ( | unsigned long | id | ) |
Remove EnvironmentObject from the scene (unregister id + remove object from ALL of its parents)
void vrecko::Scene::removePartitioningObjectInterface | ( | SP_ObjectInterface * | anInterface | ) |
void vrecko::Scene::removePartitioningSceneInterface | ( | SP_SceneInterface * | anInterface | ) |
bool vrecko::Scene::separation | ( | esg::Matrix4 * | trMat1, |
std::vector< esg::OSGAdapter * > | object1, | ||
esg::Matrix4 * | trMat2, | ||
std::vector< esg::OSGAdapter * > | object2, | ||
unsigned | d1 = UINT_MAX , |
||
unsigned | d2 = UINT_MAX |
||
) |
(OBSOLETE? - Uses FDH structure, but its calculation is now turned off when loading EO) It detects if the separation exists between two given object.
|
inline |
Set scene description.
|
inline |
|
inline |
Usage is not required in the main thread.
|
inline |
Usage is not required in the main thread.
bool vrecko::Scene::unregisterEnvironmentObject | ( | EnvironmentObject * | environment_object | ) |
Unregisters an EnvObj from the internal structures. Doesn't remove the object from the scene tree.
bool vrecko::Scene::unregisterEnvironmentObject | ( | unsigned long | id | ) |
Unregisters an EnvObj from the internal structures. Doesn't remove the object from the scene tree.
|
virtual |
This method is called periodically in case this instance is registered in Scheduler.
The method is called periodically at specified frequency or every frame. Use the Scheduler::addEntity() method to register your class and set the frequency.
Reimplemented from vrecko::BaseClass.
|
friend |
|
protected |
Has the Scene class finished loading its data from the XML files?
|
protected |
Scene description.
|
protected |
Map with EnvironmentObjects that have been added to the scene.
|
protected |
|
protected |
Node where most EOs are added.
|
protected |
Which "partitioning" thread was last checked in the update.
|
protected |
|
protected |
Partitioning interface for object operations, sorted by priority.
|
protected |
Partitioning interfaces for scene operations, sorted by priority.
|
protected |
Threads for calculating the partitioning queries in background. The ScebePSThreadInfo structures are accessible also from the thread, but this vector itself is modified only in the main thread. So we don't need any locking mechanism.
|
protected |
Root of the scenegraph - ...