WorldDatabase Class Reference
#include <WorldDatabase.h>

Classes | |
| class | AvatarConverterToV1_0a4 |
| class | EntityTypeConverterToV1_0a4 |
| class | EnvironmentConverterToV1_0a4 |
| class | EnvLayoutConverterToV1_0a4 |
| class | PrivateAccessor |
| class | TileConverterToV1_0a4 |
| class | WorldConverterToV1_0a4 |
Static Public Member Functions | |
| static void | init () |
| static void | cleanup () |
| static void | clearWorld () |
| static bool | loadEntityTypes (std::string entityCfg) |
| static bool | loadTiles (std::string tileCfg) |
| static bool | loadEnvironmentLayout (std::string envLayCfg) |
| static bool | loadWorldDatabase (std::string worldCfg) |
| static bool | reloadEnvironmentLayout () |
| static EntityType * | getEntityTypeWithId (unsigned short id) |
| static EntityType * | getEntityTypeWithName (std::string name) |
| static Entity * | getEntityWithEnvironmentId (unsigned environmentBasedId) |
| static Entity * | getEntityWithEnvironmentId (unsigned short environmentId, unsigned short entityId) |
| static Entity * | getEntityWithTypeInstanceId (unsigned typeInstanceId) |
| static Entity * | getEntityWithTypeInstanceId (unsigned short entityTypeId, unsigned short instanceId) |
| static Tile * | getTileWithId (int id) |
| static Environment * | getEnvironmentWithId (unsigned short environmentId) |
| static Environment * | getEnvironmentAtWorldPosition (float x, float z) |
| static unsigned | createEntity (unsigned short entityTypeId, unsigned short startEnvironmentId, TransformationData startTrans=identityTransformation(), AbstractEntityCreationCB *callback=NULL) |
| static unsigned | createEntity (EntityType *type, Environment *startEnv, TransformationData startTrans=identityTransformation(), AbstractEntityCreationCB *callback=NULL) |
| static bool | destroyEntity (Entity *entity, AbstractEntityDeletionCB *callback=NULL) |
| static bool | unregisterEntityCreationCallback (unsigned environmentBasedId) |
| static bool | unregisterEntityDeletionCallback (unsigned environmentBasedId) |
| static void | registerEntityTypeFactory (EntityTypeFactory *entityTypeFactory) |
| static void | registerAvatarFactory (AvatarFactory *avatarFactory) |
| static AvatarInterface * | loadAvatar (std::string configFile) |
| static void | removeAvatar (AvatarInterface *avatarInt) |
| static void | updateAvatars (float dt) |
| static int | getXSpacing () |
| static int | getZSpacing () |
| static const std::vector < EntityType * > & | getEntityTypeList () |
| static const std::vector< Tile * > & | getTileList () |
| static const std::vector < Environment * > & | getEnvironmentList () |
| static void | dumpEntityTypes () |
| static void | dumpTiles () |
| static void | dumpEnvironment () |
| static void | dump () |
| static const WorldDatabase::PrivateAccessor & | getPrivateAccessor () |
| static void | reloadEnvironments () |
Static Private Member Functions | |
| static bool | loadEnvironmentLayout (std::string config, bool reload) |
| static Environment * | loadEnvironment (std::string envCfg, int xSpacing, int ySpacing, int environmentId, bool reload=false) |
| static bool | addEntryPointToEnvironment (const XmlElement *entryPointElement, Environment *env) |
| static bool | createEntityInEnvironment (const XmlElement *entityElement, Environment *env, bool reload) |
| static bool | createTilesInEnvironment (const XmlElement *tileMapElement, Environment *env) |
| static EntityType * | getEntityType (std::string className, unsigned short id, EntityTypeFactory **factory) |
| static void | executeEnvironmentReload () |
| static void | addEntityType (EntityType *entityType) |
Static Private Attributes | |
| static std::string | worldConfigFile |
| Configuration file for world configuration. | |
| static std::string | envLayoutConfigFile |
| Configuration file for environment layout. | |
| static std::vector< Tile * > | tileList |
| List of all Tiles. | |
| static std::vector< EntityType * > | entityTypeList |
| List of all EntityTypes. | |
| static std::vector< Environment * > | environmentList |
| List of all Environments. | |
| static std::map< unsigned int, Tile * > | tileMap |
| Map from Tile ID to Tile. | |
| static std::map< unsigned short, EntityType * > | entityTypeIDMap |
| Map from EntityType ID to EntityType. | |
| static std::map< std::string, EntityType * > | entityTypeNameMap |
| Map from EntityType name to EntityType. | |
| static std::map< unsigned short, Environment * > | environmentMap |
| Map from Environment ID to Environment. | |
| static std::vector < EntityTypeFactory * > | entityTypeFactories |
| List of all EntityTypeFactories. | |
| static std::vector < AvatarFactory * > | avatarFactories |
| List of all AvatarFactories. | |
| static std::vector < AvatarInterface * > | avatarList |
| List of all registered Avatars. | |
| static int | xSpacing |
| horizontal and vertical spacing (units per tile) | |
| static int | zSpacing |
| static SceneGraphInterface * | sgIF |
| Pointer to the used SceneGraphInterface. | |
| static bool | initialized = false |
| Used to check if WDB is already initialized. | |
| static PrivateAccessor | privateAccessor |
| Used to access WDB-internal functions. | |
| static XmlConfigurationLoader | avatarXmlConfigLoader |
| static XmlConfigurationLoader | worldXmlConfigLoader |
| static XmlConfigurationLoader | entityTypeXmlConfigLoader |
| static XmlConfigurationLoader | tileXmlConfigLoader |
| static XmlConfigurationLoader | envLayoutXmlConfigLoader |
| static XmlConfigurationLoader | environmentXmlConfigLoader |
Friends | |
| class | WorldDatabaseReloadEnvironmentsEvent |
Member Function Documentation
| void WorldDatabase::addEntityType | ( | EntityType * | entityType | ) | [static, private] |
Adds the passed EntityType to the WDB
- Parameters:
-
entityType EntityType which should be added
| bool WorldDatabase::addEntryPointToEnvironment | ( | const XmlElement * | entryPointElement, | |
| Environment * | env | |||
| ) | [static, private] |
Parses an entry point from the XmlElement and adds it to the Environment
- Parameters:
-
entryPointElement env
- Returns:
- true if the entry-point could be parsed and added
| void WorldDatabase::cleanup | ( | ) | [static] |
Cleans up the WorldDatabase. The method deletes all Environments including all Entities and Tiles inside of the Environments. It also deletes all Tiles in the tile list and all EntityTypes. Furthermore it deletes all registered Avatars and Avatar factories and all EntityType factories.
- See also:
- SystemCore::cleanup(), UserDatabase::cleanup()
| void WorldDatabase::clearWorld | ( | ) | [static] |
Removes every Tile, Entity and Environment from the world. The method removes every Environment from the WorldDatabase. This includes every Tile and Entity. The Tile- and EntityType-vectors are not cleared.
| unsigned WorldDatabase::createEntity | ( | EntityType * | type, | |
| Environment * | startEnv, | |||
| TransformationData | startTrans = identityTransformation(), |
|||
| AbstractEntityCreationCB * | callback = NULL | |||
| ) | [static] |
Creates a new Entity of passed Type in the passed environment. The method tries to find the desired EntityType and the initial Environment of the Entity and forwards the call to the createEntity method of the Environment.
- Parameters:
-
entityType The desired EntityType startEnvironmentId The Environment the Entity should be built in startTrans initial Transformation of the Entity, default is IdentityTransformation
- Returns:
- environmentBasedId of new Entity
| unsigned WorldDatabase::createEntity | ( | unsigned short | entityTypeId, | |
| unsigned short | startEnvironmentId, | |||
| TransformationData | startTrans = identityTransformation(), |
|||
| AbstractEntityCreationCB * | callback = NULL | |||
| ) | [static] |
Creates a new Entity of passed Type in the passed environment. The method tries to find the desired EntityType and the initial Environment of the Entity and forwards the call to the createEntity method of the Environment.
- Parameters:
-
entityTypeId ID of the desired EntityType startEnvironmentId ID of the Environment the Entity should be built in startTrans initial Transformation of the Entity, default is IdentityTransformation
- Returns:
- environmentBasedId of new Entity
| bool WorldDatabase::createEntityInEnvironment | ( | const XmlElement * | entityElement, | |
| Environment * | env, | |||
| bool | reload | |||
| ) | [static, private] |
| bool WorldDatabase::createTilesInEnvironment | ( | const XmlElement * | tileMapElement, | |
| Environment * | env | |||
| ) | [static, private] |
Parses the tileMap element and adds all tiles to the passed environment
- Parameters:
-
tileMapElement env
- Returns:
- true if the tile map was loaded successfully
| bool WorldDatabase::destroyEntity | ( | Entity * | entity, | |
| AbstractEntityDeletionCB * | callback = NULL | |||
| ) | [static] |
Creates a new Environment The method tries to create a new environment with the passed ID and the passed size at the defined positions. The method will only be successful if following conditions are met: 1) The environment-ID has to be unique (no other environment has the passed ID already) 2) The xPosition and zPosition values of the environment must be multiples of the xSpacing and zSpacing values. This is essential in order to allow the dynamic movement of environment borders 3) The environment does not superpose other environments
NOTE: The xSize and zSize values define the size of the tile-grid and not the overall Environment size. The overall size is calculated by multiplying xSize and zSize with the xSpacing and zSpacing values.
- Parameters:
-
id id of the new environment xPosition horizontal position of the environment zPosition vertical position of the environment xSize horizontal size of the environment (= horizontal grid size) zSize vertical size of the environment (= vertical grid size) Destroys an existing Entity. The method creates a WorldDatabaseDestroyEntityEvent and sends it to all connected users including the local machine. entity Entity which should be destroyed
- Returns:
- true if the Event could be created and was sent, false if not
| void WorldDatabase::dump | ( | ) | [static] |
Dumps all EntityTypes, Tiles and Environments.
| void WorldDatabase::dumpEntityTypes | ( | ) | [static] |
Dumps all EntityTypes.
| void WorldDatabase::dumpEnvironment | ( | ) | [static] |
Dumps all Environments.
| void WorldDatabase::dumpTiles | ( | ) | [static] |
Dumps all Tiles.
| void WorldDatabase::executeEnvironmentReload | ( | ) | [static, private] |
- Todo:
- document
| EntityType * WorldDatabase::getEntityType | ( | std::string | className, | |
| unsigned short | id, | |||
| EntityTypeFactory ** | factory | |||
| ) | [static, private] |
Creates a new EntityType with the corresponding className. It iterates over all elements in the entityTypeFactoryList and tries to create a new EntityType with the passed className. If an EntityType was created then it sets the responsible factory to the passed pointer and returns the new EntityType.
- Parameters:
-
className name of the EntityType-class id id of the new EntityType factory optional parameter which can be used to return the factory which built the EntityType
- Returns:
- new EntityType, NULL if className was not found
| const std::vector< EntityType * > & WorldDatabase::getEntityTypeList | ( | ) | [static] |
Returns a pointer to the EntityType-list. WARNING: the method returns a pointer to the list so every change also changes data in the WDB!!!
- Returns:
- pointer to EntityType-list
| EntityType * WorldDatabase::getEntityTypeWithId | ( | unsigned short | id | ) | [static] |
Returns the EntityType with the passed ID.
- Parameters:
-
id ID of the EntityType
- Returns:
- EntityType with the corresponding ID, NULL if not existing
| EntityType * WorldDatabase::getEntityTypeWithName | ( | std::string | name | ) | [static] |
Returns the EntityType with the given name.
- Parameters:
-
name Name of the EntityType, as specified in the xml-configuration.
- Returns:
- EntityType with the corresponding name, NULL if not existing
| Entity * WorldDatabase::getEntityWithEnvironmentId | ( | unsigned short | environmentId, | |
| unsigned short | entityId | |||
| ) | [static] |
Returns The Entity from the Environment with the passed ID.
- Parameters:
-
environmentId ID of the Environment where the Entity was created entityId ID of the Entity inside the Environment
- Returns:
- Entity with the corresponding ID, NULL if not found
| Entity * WorldDatabase::getEntityWithEnvironmentId | ( | unsigned | environmentBasedId | ) | [static] |
| Entity * WorldDatabase::getEntityWithTypeInstanceId | ( | unsigned short | entityTypeId, | |
| unsigned short | instanceId | |||
| ) | [static] |
Returns the Entity with the passed ID. The passed ID is split up into the entityType-ID and the instance-ID of the Entity
- Parameters:
-
entityTypeId ID of the EntityType instanceId instance-ID of the Entity
- Returns:
- Entity with the corresponding ID, NULL if not existing
| Entity * WorldDatabase::getEntityWithTypeInstanceId | ( | unsigned | typeInstanceId | ) | [static] |
| Environment * WorldDatabase::getEnvironmentAtWorldPosition | ( | float | x, | |
| float | z | |||
| ) | [static] |
Returns the Environment at the passed position. The method iterates over each Environment and checks if the passed point is inside the Environment. If so it returns the Environment.
- Parameters:
-
x,z point in world coordinates
- Returns:
- Environment in which point lies, NULL if no Environment found
| const std::vector< Environment * > & WorldDatabase::getEnvironmentList | ( | ) | [static] |
Returns a pointer to the Environment-list. WARNING: the method returns a pointer to the list so every change also changes data in the WDB!!!
- Returns:
- pointer to Environment-list
| Environment * WorldDatabase::getEnvironmentWithId | ( | unsigned short | environmentId | ) | [static] |
Returns the Environment with the passed ID.
- Parameters:
-
environmentId ID of the desired Environment
- Returns:
- Environment with the passed ID, NULL if not existing
| const WorldDatabase::PrivateAccessor & WorldDatabase::getPrivateAccessor | ( | ) | [static] |
| const std::vector< Tile * > & WorldDatabase::getTileList | ( | ) | [static] |
Returns a pointer to the Tile-list. WARNING: the method returns a pointer to the list so every change also changes data in the WDB!!!
- Returns:
- pointer to Tile-list
| Tile * WorldDatabase::getTileWithId | ( | int | id | ) | [static] |
| int WorldDatabase::getXSpacing | ( | ) | [static] |
Returns the used horizontal spacing.
- Returns:
- horizontal spacing (number of units per tile)
| int WorldDatabase::getZSpacing | ( | ) | [static] |
Returns the used vertical spacing.
- Returns:
- vertical spacing (number of units per tile)
| void WorldDatabase::init | ( | ) | [static] |
Initializes the WorldDatabase. The method adds the default Avatar factory to the list of Avatar factories. It also adds the default EntityType factory to the list of EntityType factories. Furthermore it requests the SceneGraphInterface from the SystemCore.
| AvatarInterface * WorldDatabase::loadAvatar | ( | std::string | configFile | ) | [static] |
Loads an Avatar from a XML-config file. The method scans the config file for the type of the Avatar and then calls the create-method of the registered avatar- factories which should return an Avatar object. Afterwards the avatar is added to the SceneGraph.
- Parameters:
-
configFile URL of the avatar XML file
- Returns:
- new avatar object
| bool WorldDatabase::loadEntityTypes | ( | std::string | entityCfg | ) | [static] |
The method loads EntityTypes into the WorldDatabase. The EntityTypes are parsed from a XML file passed as an argument and then stored in the WorldDatabase.
- Parameters:
-
entityCfg the URL of the XML-EntityType definition file
| Environment * WorldDatabase::loadEnvironment | ( | std::string | envCfg, | |
| int | xSpacing, | |||
| int | ySpacing, | |||
| int | environmentId, | |||
| bool | reload = false | |||
| ) | [static, private] |
Loads an Environment from a config file. The Environment is parsed from a XML file passed as an argument. The provided arguments are passed to the Environment constructor. Finally the built Environment is returned.
- Parameters:
-
envCfg the URL of the XML-Environment definition file xSpacing the horizontal Tile-spacing ySpacing the vertical Tile-spacing environmentId the ID of the new Environment reload defines if an existing environment should be reloaded or a new one should be created
- Returns:
- the new built Environment
| bool WorldDatabase::loadEnvironmentLayout | ( | std::string | config, | |
| bool | reload | |||
| ) | [static, private] |
| bool WorldDatabase::loadEnvironmentLayout | ( | std::string | envLayCfg | ) | [static] |
Loads all Environments into the WorldDatabase. The method reads the layout of the environments from the passed XML-file, creates each environment by calling the loadEnvironment method and puts every environment in the environmentList.
- Parameters:
-
envLayCfg the URL of the XML-config file
| bool WorldDatabase::loadTiles | ( | std::string | tileCfg | ) | [static] |
Loads tiles into the WorldDatabase. The Tiles are parsed from a XML file passed as an argument and then stored in the WorldDatabase.
- Parameters:
-
tileCfg the URL of the XML-Tile definition file
| bool WorldDatabase::loadWorldDatabase | ( | std::string | worldCfg | ) | [static] |
Fills the WorldDatabase according to the passed config file. Entity-, Tile- and Environment- configuration files are parsed from the config-file and then loaded into the WorldDatabase by the according methods. After the method call the WorldDatabase is fully filled.
- Parameters:
-
worldCfg URL to XML-World definition
- Returns:
- true if the world was loaded successfully
| void WorldDatabase::registerAvatarFactory | ( | AvatarFactory * | avatarFactory | ) | [static] |
Registers an AvatarFactory in the WDB. All registered AvatarFactories will be delete'd automatically when cleanup() is invoked
- Parameters:
-
avatarFactory avatarFactory that should be added
| void WorldDatabase::registerEntityTypeFactory | ( | EntityTypeFactory * | entityTypeFactory | ) | [static] |
Registers an EntityTypeFactory in the WDB. All registered EntityTypeFactories will be delete'd automatically when cleanup() is invoked
- Parameters:
-
entityTypeFactory entityTypeFactory that should be added
| static bool WorldDatabase::reloadEnvironmentLayout | ( | ) | [static] |
TODO: document
| void WorldDatabase::reloadEnvironments | ( | ) | [static] |
| void WorldDatabase::removeAvatar | ( | AvatarInterface * | avatarInt | ) | [static] |
Removes an Avatar from the WorldDatabase. The method removes the Avatar-OpenSG-Node from the World and removes the Avatar-Object from the avatar list. The Avatar object itself is NOT deleted!
- Parameters:
-
avatarInt the Avatar object which should be removed
| bool WorldDatabase::unregisterEntityCreationCallback | ( | unsigned | environmentBasedId | ) | [static] |
- Todo:
- document
| bool WorldDatabase::unregisterEntityDeletionCallback | ( | unsigned | environmentBasedId | ) | [static] |
- Todo:
- document
| void WorldDatabase::updateAvatars | ( | float | dt | ) | [static] |
Updates all registered avatars. It iterates over all elements of the avatarList and calls their update-methods.
- Parameters:
-
dt elapsed time since last call
Friends And Related Function Documentation
friend class WorldDatabaseReloadEnvironmentsEvent [friend] |
Member Data Documentation
std::vector< AvatarFactory * > WorldDatabase::avatarFactories [static, private] |
List of all AvatarFactories.
std::vector< AvatarInterface * > WorldDatabase::avatarList [static, private] |
List of all registered Avatars.
XmlConfigurationLoader WorldDatabase::avatarXmlConfigLoader [static, private] |
std::vector< EntityTypeFactory * > WorldDatabase::entityTypeFactories [static, private] |
List of all EntityTypeFactories.
std::map< unsigned short, EntityType * > WorldDatabase::entityTypeIDMap [static, private] |
Map from EntityType ID to EntityType.
std::vector< EntityType * > WorldDatabase::entityTypeList [static, private] |
List of all EntityTypes.
std::map< std::string, EntityType * > WorldDatabase::entityTypeNameMap [static, private] |
Map from EntityType name to EntityType.
XmlConfigurationLoader WorldDatabase::entityTypeXmlConfigLoader [static, private] |
std::vector< Environment * > WorldDatabase::environmentList [static, private] |
List of all Environments.
std::map< unsigned short, Environment * > WorldDatabase::environmentMap [static, private] |
Map from Environment ID to Environment.
XmlConfigurationLoader WorldDatabase::environmentXmlConfigLoader [static, private] |
std::string WorldDatabase::envLayoutConfigFile [static, private] |
Configuration file for environment layout.
XmlConfigurationLoader WorldDatabase::envLayoutXmlConfigLoader [static, private] |
bool WorldDatabase::initialized = false [static, private] |
Used to check if WDB is already initialized.
WorldDatabase::PrivateAccessor WorldDatabase::privateAccessor [static, private] |
Used to access WDB-internal functions.
SceneGraphInterface * WorldDatabase::sgIF [static, private] |
Pointer to the used SceneGraphInterface.
std::vector< Tile * > WorldDatabase::tileList [static, private] |
List of all Tiles.
std::map< unsigned int, Tile * > WorldDatabase::tileMap [static, private] |
XmlConfigurationLoader WorldDatabase::tileXmlConfigLoader [static, private] |
std::string WorldDatabase::worldConfigFile [static, private] |
Configuration file for world configuration.
Adds a new Environment to the WorldDatabase This method is called from the WorldDatabaseCreateEnvironmentEvent when a new Environment is created.
- Parameters:
-
environment Created environment which should be added to the WDB
XmlConfigurationLoader WorldDatabase::worldXmlConfigLoader [static, private] |
int WorldDatabase::xSpacing [static, private] |
horizontal and vertical spacing (units per tile)
int WorldDatabase::zSpacing [static, private] |
The documentation for this class was generated from the following files:
- src/inVRs/SystemCore/WorldDatabase/WorldDatabase.h
- src/inVRs/SystemCore/WorldDatabase/WorldDatabase.cpp
Generated on Wed Oct 20 16:12:02 2010 for inVRs by
1.5.8