Ocean
|
This class implements the manager for all scene descriptions. More...
Public Types | |
typedef std::vector< std::string > | LibraryNames |
Definition of a vector holding library names. More... | |
Public Types inherited from Ocean::IO::FileManager | |
typedef std::map< std::string, std::string > | FileExtensions |
Definition of a map mapping supported file extensions to file type descriptions. More... | |
Public Member Functions | |
SceneRef | load (const std::string &filename, const Rendering::EngineRef &engine, const Timestamp ×tamp, const DescriptionType preferredDescriptionType=TYPE_PERMANENT, float *progress=nullptr, bool *cancel=nullptr) |
Loads a new scene and creates a scene description hierarchy. More... | |
bool | unload (const SceneId sceneId) |
Unloads a given permanent scene description objects. More... | |
void | unloadScenes () |
Unloads all permanent scene description objects. More... | |
LibraryNames | libraries () |
Returns a list of all registered libraries. More... | |
FileExtensions | supportedExtensions () |
Returns all currently supported file extensions. More... | |
bool | handlesMouseEvents () const |
Returns whether currently at least one scene description node handles mouse events. More... | |
void | mouseEvent (const ButtonType button, const ButtonEvent buttonEvent, const Vector2 &screenPosition, const Vector3 &objectPosition, const Rendering::ObjectId objectId, const Timestamp timestamp) |
Sends a mouse event to be handled by the scene description. More... | |
void | keyEvent (const int key, const ButtonEvent buttonEvent, const Rendering::ObjectId objectId, const Timestamp timestamp) |
Sends a key event to be handled by the scene description. More... | |
Timestamp | preUpdate (const Rendering::ViewRef &view, const Timestamp timestamp) |
Pre-updates all scene description objects needing regularly pre updates. More... | |
Timestamp | preUpdate (const std::string &library, const Rendering::ViewRef &view, const Timestamp timestamp) |
Pre-updates all scene description objects of a specified library only. More... | |
void | update (const Rendering::ViewRef &view, const Timestamp timestamp) |
Updates all scene description objects needing regularly updates. More... | |
void | update (const std::string &library, const Rendering::ViewRef &view, const Timestamp timestamp) |
Updates all scene description objects of a specified library only. More... | |
NodeRef | node (const std::string &name) const |
Returns the node reference of the first available scene description node with a specified name. More... | |
NodeRef | node (const std::string &library, const std::string &name) const |
Returns the node reference of the first available scene description node with a specified name defined inside a specific library. More... | |
NodeRefs | nodes (const std::string &name) const |
Returns all node references of all available scene description nodes with a specified name. More... | |
NodeRefs | nodes (const std::string &library, const std::string &name) const |
Returns all node references of all available scene description nodes with a specified name defined inside a specific library. More... | |
void | release () |
Releases all scene library. More... | |
template<typename T > | |
bool | registerLibrary (const std::string &name) |
Registers a new library. More... | |
bool | unregisterLibrary (const std::string &name) |
Unregisters a library. More... | |
Public Member Functions inherited from Ocean::IO::FileManager | |
virtual bool | isSupported (const std::string &extension) |
Returns whether a specified file extension is supported. More... | |
Protected Types | |
typedef std::pair< LibraryRef, unsigned int > | LibraryCounterPair |
Definition of a pair combining a library with a reference counter. More... | |
typedef std::vector< LibraryCounterPair > | Libraries |
Definition of a vector holding library pairs. More... | |
typedef std::unordered_set< std::string > | NameSet |
Definition of a set holding library names. More... | |
typedef std::unordered_map< NodeId, SDXEventNode * > | EventNodes |
Definition of a map mapping scene description node ids to event nodes. More... | |
typedef std::unordered_map< NodeId, SDXUpdateNode * > | UpdateNodes |
Definition of a map mapping scene description node ids to update nodes. More... | |
typedef std::map< SceneId, SDXSceneRef > | PermanentSceneMap |
Definition of a set holding permanent scene description objects. More... | |
Protected Member Functions | |
Manager () | |
Creates a new manager. More... | |
virtual | ~Manager () |
Destructs a manager. More... | |
void | registerEventNode (SDXEventNode &node) |
Registers a new event node. More... | |
void | unregisterEventNode (SDXEventNode &node) |
Unregisters an event node. More... | |
void | registerUpdateNode (SDXUpdateNode &node) |
Registers a new update node. More... | |
void | unregisterUpdateNode (SDXUpdateNode &node) |
Unregisters an update node. More... | |
Protected Member Functions inherited from Ocean::IO::FileManager | |
FileManager () | |
Creates a new file manager object. More... | |
virtual | ~FileManager () |
Destructs a file manager object. More... | |
Protected Member Functions inherited from Ocean::Singleton< Manager > | |
Singleton ()=default | |
Default constructor. More... | |
Protected Attributes | |
Libraries | libraries_ |
The vector holding all registered scene description libraries. More... | |
PermanentSceneMap | permanentSceneMap_ |
Map holding all permanent scene description objects. More... | |
EventNodes | eventNodes_ |
Map holding all event nodes. More... | |
UpdateNodes | updateNodes_ |
Map holding all update nodes. More... | |
Lock | managerLock_ |
Manager lock. More... | |
Lock | libraryLock_ |
Library lock. More... | |
Friends | |
class | Singleton< Manager > |
class | Library |
class | SDXEventNode |
class | SDXUpdateNode |
Additional Inherited Members | |
Static Public Member Functions inherited from Ocean::Singleton< Manager > | |
static Manager & | get () |
Returns a reference to the unique object. More... | |
This class implements the manager for all scene descriptions.
The manager encapsulates all registered scene description libraries.
Use the load() function to load a new scene description object.
Example demonstrating the manager usage:
|
protected |
Definition of a map mapping scene description node ids to event nodes.
|
protected |
Definition of a vector holding library pairs.
|
protected |
Definition of a pair combining a library with a reference counter.
typedef std::vector<std::string> Ocean::SceneDescription::Manager::LibraryNames |
Definition of a vector holding library names.
|
protected |
Definition of a set holding library names.
|
protected |
Definition of a set holding permanent scene description objects.
|
protected |
Definition of a map mapping scene description node ids to update nodes.
|
protected |
Creates a new manager.
|
protectedvirtual |
Destructs a manager.
|
inline |
Returns whether currently at least one scene description node handles mouse events.
The state change with every new frame.
Because mouse events can produce high computational overhead this test can safe computational time.
void Ocean::SceneDescription::Manager::keyEvent | ( | const int | key, |
const ButtonEvent | buttonEvent, | ||
const Rendering::ObjectId | objectId, | ||
const Timestamp | timestamp | ||
) |
Sends a key event to be handled by the scene description.
key | The key type |
buttonEvent | Type of the event |
objectId | Id of a rendering object associated with the event |
timestamp | Event timestamp |
LibraryNames Ocean::SceneDescription::Manager::libraries | ( | ) |
Returns a list of all registered libraries.
SceneRef Ocean::SceneDescription::Manager::load | ( | const std::string & | filename, |
const Rendering::EngineRef & | engine, | ||
const Timestamp & | timestamp, | ||
const DescriptionType | preferredDescriptionType = TYPE_PERMANENT , |
||
float * | progress = nullptr , |
||
bool * | cancel = nullptr |
||
) |
Loads a new scene and creates a scene description hierarchy.
Two different scene description types are available.
First: A transient scene description creates a scene and object hierarchy and must be applied to a rendering engine afterwards explicitly.
After that all scene description objects are not needed anymore and can be disposed.
Second: a permanent scene description creates a scene and object hierarchy and directly creates corresponding rendering engine objects.
Therefore, all rendering objects exist as long as the corresponding scene description object exist.
The scene description object allows for easy scene manipulation without knowledge of the underling rendering structure.
This manager will hold a copy of all permanent scene description objects as long as they are unloaded explicitly.
Beware: Check the type of returned scene description object.
Depending on the available scene description libraries the description type may vary.
To not hold a reference of the returned object longer than necessary!
filename | The filename of the scene to load |
engine | Rendering engine to be connected with the scene description, must be defined for permanent scene description objects only |
timestamp | The current timestamp, must be valid |
preferredDescriptionType | Preferred description type of the scene to load |
progress | The progress state receiving recurrently information about the load state with range [0, 1] |
cancel | The cancel state allows the cancellation of a load process while loading process hasn't finished, if the cancel state is used the load process stops if the value is set to True |
void Ocean::SceneDescription::Manager::mouseEvent | ( | const ButtonType | button, |
const ButtonEvent | buttonEvent, | ||
const Vector2 & | screenPosition, | ||
const Vector3 & | objectPosition, | ||
const Rendering::ObjectId | objectId, | ||
const Timestamp | timestamp | ||
) |
Sends a mouse event to be handled by the scene description.
button | The button type |
buttonEvent | Type of the event |
screenPosition | Screen device position |
objectPosition | Object position |
objectId | Id of a rendering object associated with the event |
timestamp | Event timestamp |
NodeRef Ocean::SceneDescription::Manager::node | ( | const std::string & | library, |
const std::string & | name | ||
) | const |
Returns the node reference of the first available scene description node with a specified name defined inside a specific library.
library | The library to be searched |
name | The name of the node to return |
NodeRef Ocean::SceneDescription::Manager::node | ( | const std::string & | name | ) | const |
Returns the node reference of the first available scene description node with a specified name.
This function searches in all libraries and all description types.
name | The name of the node to return |
NodeRefs Ocean::SceneDescription::Manager::nodes | ( | const std::string & | library, |
const std::string & | name | ||
) | const |
Returns all node references of all available scene description nodes with a specified name defined inside a specific library.
library | The library to be searched |
name | The name of the nodes to return |
NodeRefs Ocean::SceneDescription::Manager::nodes | ( | const std::string & | name | ) | const |
Returns all node references of all available scene description nodes with a specified name.
This function searches in all libraries and all description types.
name | The name of the nodes to return |
Timestamp Ocean::SceneDescription::Manager::preUpdate | ( | const Rendering::ViewRef & | view, |
const Timestamp | timestamp | ||
) |
Pre-updates all scene description objects needing regularly pre updates.
view | Rendering view to be used for rendering |
timestamp | Preferred update timestamp |
Timestamp Ocean::SceneDescription::Manager::preUpdate | ( | const std::string & | library, |
const Rendering::ViewRef & | view, | ||
const Timestamp | timestamp | ||
) |
Pre-updates all scene description objects of a specified library only.
library | Name of the library |
view | Rendering view to be used for rendering |
timestamp | Preferred Update timestamp |
|
protected |
Registers a new event node.
node | Event node to register |
bool Ocean::SceneDescription::Manager::registerLibrary | ( | const std::string & | name | ) |
Registers a new library.
With each register call, the reference counter for a specific library will be incremented. Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
name | The name of the library to register, must be valid |
T | The data type of the library to register |
|
protected |
Registers a new update node.
node | Update node to register |
void Ocean::SceneDescription::Manager::release | ( | ) |
Releases all scene library.
|
virtual |
Returns all currently supported file extensions.
Implements Ocean::IO::FileManager.
bool Ocean::SceneDescription::Manager::unload | ( | const SceneId | sceneId | ) |
Unloads a given permanent scene description objects.
Transient description objects must not be unloaded because the manager does not hold a copy of transient scene objects.
Beware: At the moment the scene is unloaded there should not be any other resource holding a reference to this object!
sceneId | Scene id of the permanent scene description object to be unloaded |
void Ocean::SceneDescription::Manager::unloadScenes | ( | ) |
Unloads all permanent scene description objects.
|
protected |
Unregisters an event node.
node | Event node to unregister |
bool Ocean::SceneDescription::Manager::unregisterLibrary | ( | const std::string & | name | ) |
Unregisters a library.
With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero. Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
name | The name of the library to unregister, must be valid |
|
protected |
Unregisters an update node.
node | Update node to unregister |
void Ocean::SceneDescription::Manager::update | ( | const Rendering::ViewRef & | view, |
const Timestamp | timestamp | ||
) |
Updates all scene description objects needing regularly updates.
view | Rendering view to be used for rendering |
timestamp | Update timestamp |
void Ocean::SceneDescription::Manager::update | ( | const std::string & | library, |
const Rendering::ViewRef & | view, | ||
const Timestamp | timestamp | ||
) |
Updates all scene description objects of a specified library only.
library | Name of the library |
view | Rendering view to be used for rendering |
timestamp | Update timestamp |
|
friend |
|
friend |
|
friend |
|
protected |
Map holding all event nodes.
|
protected |
The vector holding all registered scene description libraries.
|
protected |
Map holding all permanent scene description objects.
|
protected |
Map holding all update nodes.