Unigine::World Class
Unigine world. This interface provides access to Unigine world functions. See UnigineScript analog
To use this class, include the UnigineWorld.h file.
Unigine::World Class
Members
virtual ~World ()
Virtual destructor.static World * get ()
Returns a pointer to the world.Return value
Pointer to the world.virtual int isLoaded () const =0
Returns a value indicating if the current world is fully loaded.Return value
Returns 1 if the world is loaded; otherwise, 0.virtual void setName (const char * name) const =0
Sets a new name for the world.Arguments
- const char * name - Name of the world.
virtual const char * getName () const =0
Returns a name of the currently loaded world.Return value
Name of the world.virtual void setData (const char * data) const =0
Sets user data associated with the world. In the *.world file, the data is set in the data tag.Arguments
- const char * data - New user data.
virtual const char * getData () const =0
Returns user string data associated with the world. This string is written directly into the data tag of the *.world file.Return value
User string data.virtual void setBudget (float budget) const =0
Sets the world generation budget value for Grass and Clutter objects. New objects are not created when time is out of the budget.Arguments
- float budget - The budget value in seconds.
virtual float getBudget () const =0
Returns the value of the world generation budget for Grass and Clutter objects. New objects are not created when time is out of the budget.Return value
The budget value in seconds. The default value is 1/60.virtual int isNode (int id) const =0
Checks if a node with a given ID exists in the world.Arguments
- int id - Node ID.
Return value
Returns 1 if the node with the given ID exists; otherwise, 0.virtual NodePtr getNode (int id) const =0
Returns a node by its ID. This can be any node: either created dynamically in run-time or loaded from the *.world file.Arguments
- int id - Node ID.
Return value
Node smart pointer if the node with the specified ID exists; otherwise, NULL.virtual void getNodes (Vector< NodePtr > & nodes) const =0
Gets all of the nodes (either loaded from the *.world file or created dynamically in run-time).Arguments
- Vector< NodePtr > & nodes - Return array with node smart pointers.
virtual int getCollision (const UNIGINE_BOUND_BOX & bb, Vector< ObjectPtr > & objects) const =0
Searches for all collider objects within a given bounding box.Arguments
- const UNIGINE_BOUND_BOX & bb - Bounding box.
- Vector< ObjectPtr > & objects - Array with collider objects' smart pointers.
Return value
Returns 1 if the collider objects are found; otherwise, 0.virtual int getCollision (const UNIGINE_BOUND_SPHERE & bb, Vector< ObjectPtr > & objects) const =0
Searches for all collider objects within a given bounding sphere.Arguments
- const UNIGINE_BOUND_SPHERE & bb - Bounding sphere.
- Vector< ObjectPtr > & objects - Array with collider objects' smart pointers.
Return value
Returns 1 if the collider objects are found; otherwise, 0.virtual int getCollision (const UNIGINE_VEC3 & p0, const UNIGINE_VEC3 & p1, Vector< ObjectPtr > & objects) const =0
Performs tracing from the p0 point to the p1 point to find all collider objects.Arguments
- const UNIGINE_VEC3 & p0 - The start point coordinates.
- const UNIGINE_VEC3 & p1 - The end point coordinates.
- Vector< ObjectPtr > & objects - Array with collider objects' smart pointers.
Return value
Returns 1 if the collider objects are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_BOX & bb, Vector< NodePtr > & nodes) const =0
Searches for intersections with nodes that are found in a given bounding box.Arguments
- const UNIGINE_BOUND_BOX & bb - Bounding box.
- Vector< NodePtr > & nodes - Array with intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_BOX & bb, Vector< ObjectPtr > & objects) const =0
Searches for intersections with objects that are found in a given bounding box. Intersection is performed with object surfaces.Arguments
- const UNIGINE_BOUND_BOX & bb - Bounding box.
- Vector< ObjectPtr > & objects - Array of intersected objects' smart pointers.
Return value
Return 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_BOX & bb, int type, Vector< NodePtr > & nodes) const =0
Searches for intersections with nodes of a specified type that are found in a given bounding box. Intersection is performed with nodes surfaces.Arguments
- const UNIGINE_BOUND_BOX & bb - Bounding box.
- int type - Node type filter. Only the nodes of the specified type is checked.
- Vector< NodePtr > & nodes - Array of intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_SPHERE & bs, Vector< NodePtr > & nodes) const =0
Searches for intersections with nodes that are found in a given bounding sphere. Intersection is performed with nodes surfaces.Arguments
- const UNIGINE_BOUND_SPHERE & bs - Bounding sphere.
- Vector< NodePtr > & nodes - Array of intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_SPHERE & bs, Vector< ObjectPtr > & objects) const =0
Searches for intersections with objects that are found in a given bounding sphere. Intersection is performed with surfaces of objects.Arguments
- const UNIGINE_BOUND_SPHERE & bs - Bounding sphere.
- Vector< ObjectPtr > & objects - Array of intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_SPHERE & bs, int type, Vector< NodePtr > & nodes) const =0
Searches for intersections with nodes of a specified type that are found in a given bounding sphere. Intersection is performed with surfaces of nodes.Arguments
- const UNIGINE_BOUND_SPHERE & bs - Bounding sphere.
- int type - Node type filter. Only the nodes of the specified type is checked.
- Vector< NodePtr > & nodes - Array of intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_FRUSTUM & bf, Vector< ObjectPtr > & objects) const =0
Searches for intersections with objects that are found in a given bounding frustum. Intersection is performed with surfaces of objects.Arguments
- const UNIGINE_BOUND_FRUSTUM & bf - Bounding frustum.
- Vector< ObjectPtr > & objects - Array of intersected objects' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_BOUND_FRUSTUM & bf, int type, Vector< NodePtr > & nodes) const =0
Searches for intersections with nodes of a specified type that are found in a given bounding frustum. Intersection is performed with surfaces of nodes.Arguments
- const UNIGINE_BOUND_FRUSTUM & bf - Bounding frustum.
- int type - Node type filter. Only the nodes of the specified type is checked.
- Vector< NodePtr > & nodes - Array of intersected nodes' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual int getIntersection (const UNIGINE_VEC3 & p0, const UNIGINE_VEC3 & p1, Vector< ObjectPtr > & objects) const =0
Searches for all of the objects intersecting the line.Arguments
- const UNIGINE_VEC3 & p0 - Coordinates of the line start point.
- const UNIGINE_VEC3 & p1 - Coordinates of the line end point.
- Vector< ObjectPtr > & objects - Array of intersected objects' smart pointers.
Return value
Returns 1 if intersections are found; otherwise, 0.virtual ObjectPtr getIntersection (const UNIGINE_VEC3 & p0, const UNIGINE_VEC3 & p1, int mask, UNIGINE_VEC3 * ret_point, vec3 * ret_normal, vec4 * ret_texcoord, int * ret_index, int * ret_surface) const =0
Searches for all of the objects intersecting the line. An intersection is found only if an object is matching the intersection mask. An object, which is the most close to the start point of the line, is returned. An intersection with the surface can be found only if the following conditions are fulfilled:- A per-surface Intersection flag is enabled.
- An Intersection option of the property in the Properties window is enabled.
- A surface has an assigned material.
- A surface has an assigned property.
- A surface is enabled.
Arguments
- const UNIGINE_VEC3 & p0 - Coordinates of the line start point.
- const UNIGINE_VEC3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- UNIGINE_VEC3 * ret_point - Intersection point of the line and object.
- vec3 * ret_normal - Normal vector to the intersection point.
- vec4 * ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
- int * ret_index - Intersected triangle (polygon) number.
- int * ret_surface - Intersected surface number.
Return value
Returns the first intersected object smart pointer if found; otherwise, NULL pointer.virtual ObjectPtr getIntersection (const UNIGINE_VEC3 & p0, const UNIGINE_VEC3 & p1, int mask, const Vector< NodePtr > & exclude, UNIGINE_VEC3 * ret_point, vec3 * ret_normal, vec4 * ret_texcoord, int * ret_index, int * ret_surface) const =0
Searches for all of the objects intersecting the line. An intersection is found only if an object is matching the intersection mask. An object, which is the most close to the start point of the line, is returned. An intersection with the surface can be found only if the following conditions are fulfilled:- A per-surface Intersection flag is enabled.
- An Intersection option of the property in the Properties window is enabled.
- A surface has an assigned material.
- A surface has an assigned property.
- A surface is enabled.
Arguments
- const UNIGINE_VEC3 & p0 - Coordinates of the line start point.
- const UNIGINE_VEC3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Vector< NodePtr > & exclude - The list of objects to exclude.
- UNIGINE_VEC3 * ret_point - Intersection point of the line and object.
- vec3 * ret_normal - Normal vector to the intersection point.
- vec4 * ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
- int * ret_index - Intersected triangle (polygon) number.
- int * ret_surface - Intersected surface number.
Return value
Returns the first intersected object smart pointer if found; otherwise, NULL pointer.virtual int clearNode (const char * name) const =0
Clears a cache of a given node.Arguments
- const char * name - Path to the *.node file.
Return value
Returns 1 if the cache is cleared successfully; otherwise, 0.virtual NodePtr loadNode (const char * name, int cache) const =0
Loads a node from a file. If the node is loaded successfully, it does not belong to any node hierarchy or list, so be careful and make sure to handle it properly, when it is no longer needed.Arguments
- const char * name - Path to the *.node file.
- int cache - 1 to use the file cache, 0 not to use.
Return value
Loaded node or 0 if the node cannot be loaded.virtual int saveNode (const char * name, const NodePtr & node) const =0
Saves a given node into a file.Arguments
- const char * name - Path to the *.node file.
- const NodePtr & node - Pointer to the node to save.
Return value
Returns 1 if the node is saved successfully; otherwise, 0.virtual int loadNodes (const char * name, Vector< NodePtr > & nodes) const =0
Loads nodes from a file.Arguments
- const char * name - Path to the *.node file.
- Vector< NodePtr > & nodes - Array of nodes' smart pointers to which the loaded nodes are appended.
Return value
Returns 1 if the nodes are loaded successfully; otherwise, 0.virtual int saveNodes (const char * name, const Vector< NodePtr > & nodes) const =0
Saves nodes into a file.Arguments
- const char * name - Path to the *.node file.
- const Vector< NodePtr > & nodes - Array of nodes' smart pointers to be saved.
Return value
Returns 1 if the nodes are saved successfully; otherwise, 0.virtual int loadAsyncNode (const char * name, int group, float weight) const =0
Loads the node with the specified group and priority to the thread.Arguments
- const char * name - Node name.
- int group - Number of a node group.
- float weight - Node priority.
Return value
Returns the loading operation identifier.virtual int removeAsyncNode (int id) const =0
Removes node from the loading queue.Arguments
- int id - Loading operation identifier (see the loadAsyncNode() function).
Return value
Returns 1 if the node is removed successfully; otherwise, 0.virtual int forceAsyncNode (int id) const =0
Forces the node loading. The specified node gets the higher priority and will be loaded first.Arguments
- int id - Loading operation identifier.
Return value
Returns 1 if the node is loaded successfully; otherwise, 0.virtual int checkAsyncNode (int id) const =0
Returns a value indicating if the node is in the loading queue or already loaded.Arguments
- int id - Loading operation identifier.
Return value
Returns 1 if the node is in queue or already loaded; otherwise, 0.virtual NodePtr getAsyncNode (int id) const =0
Gets the loaded node. If the loaded node consists of multiple objects, a new dummy object is created to combine them and its smart pointer is returned.Arguments
- int id - Loading operation identifier.
Return value
Returns the loaded node smart pointer, if found; otherwise, 0.virtual int getAsyncNodes (int id, Vector< NodePtr > & nodes) const =0
Gets an array of the loaded nodes. If the loaded node consists of multiple objects, they are put into the array.Arguments
- int id - Loading operation identifier.
- Vector< NodePtr > & nodes - Array of loaded nodes' smart pointers.
Return value
Returns 1 if the operation is successful; otherwise, 0.Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter