Unigine::Object Class
Header: | #include <UnigineObjects.h> |
Inherits: | Node |
An object with a set of surfaces to represent geometry. Rendering materials are assigned per object surface. An object can be assigned a physical body.
Object Class
Members
Ptr<Object> cast(const Ptr<Node> & node)
Casts an Object out of the Node instance.Arguments
- const Ptr<Node> & node - Pointer to Node.
Return value
Pointer to Object.void setBody(const Ptr<Body> & body, int update = 1)
Assigns a physical body to the object.Arguments
- const Ptr<Body> & body - Physical body.
- int update
Ptr<Body> getBody()
Returns a physical body assigned to the object.Return value
Body assigned to the object or NULL (0), if no body is assigned.Ptr<BodyRigid> getBodyRigid()
Returns a rigid body assigned to the object.Return value
Rigid body assigned to the object or NULL (0), if no body is assigned or the body is not rigid.BoundBox getBoundBox(int surface)
Returns the bounding box of a given surface.Arguments
- int surface - Surface number.
Return value
Bounding box.BoundSphere getBoundSphere(int surface)
Returns the bounding sphere of a given surface.Arguments
- int surface - Surface number.
Return value
Bounding sphere.void setCastShadow(int enabled, int surface)
Enables or disables casting shadows from non-world lights for a given surface.Arguments
- int enabled - 1 if shadows are to be cast by a given surface; otherwise, 0.
- int surface - Surface number.
int getCastShadow(int surface)
Returns the surface cast shadow flag, which indicates if a given surface should cast shadows from non-world lights.Arguments
- int surface - Surface number.
Return value
Positive number if shadows are cast by a given surface; otherwise, 0.void setCastWorldShadow(int enabled, int surface)
Enables or disables casting shadows from world lights for a given surface.Arguments
- int enabled - 1 if world shadows are to be cast by a given surface; otherwise, 0.
- int surface - Surface number.
int getCastWorldShadow(int surface)
Returns the surface cast world shadow flag, which indicates if a given surface should cast shadows from world lights.Arguments
- int surface - Surface number.
Return value
Positive number if world shadows are cast by a given surface; otherwise, 0.void setCollision(int enabled, int surface)
Enables or disables collision detection for a given surface.Arguments
- int enabled - 1 if collision detection is enabled for a given surface; otherwise, 0.
- int surface - Surface number.
int getCollision(int surface)
Returns the surface collision flag, which indicates if collision detection for a given surface is enabled.Arguments
- int surface - Surface number.
Return value
Positive number if collision detection is enabled for a given surface; otherwise, 0.void setCollisionMask(int mask, int surface)
Sets a collision mask for a given surface. Two objects collide, if they both have matching masks.Arguments
- int mask - Surface collision mask.
- int surface - Surface number.
int getCollisionMask(int surface)
Returns the collision mask for a given surface.Arguments
- int surface - Surface number.
Return value
Surface collision mask.void setEnabled(int enabled)
Enables or disables the node.Arguments
- int enabled - 1 to enable the node, 0 to disable it.
void setEnabled(int enabled, int surface)
Enables or disables a given surface.Arguments
- int enabled - 1 to enable the surface, 0 to disable it.
- int surface - Surface number.
int isEnabled(int surface)
Returns a value indicating if a given surface is enabled.Arguments
- int surface - Surface number.
Return value
Positive number if the surface is enabled; otherwise, 0.int isEnabled()
Returns a value indicating if the node and its parent nodes are enabled.Return value
Positive number if the node and its parent nodes are enabled; otherwise, 0.void setFolded(int folded, int surface)
Shows or minimizes surface's children in the surface hierarchy.Arguments
- int folded - 1 to minimize surface children, 0 to expand the hierarchy.
- int surface - Surface number.
int isFolded(int surface)
Returns a value indicating if surface's children are displayed or minimized in the surface hierarchy.Arguments
- int surface - Surface number.
Return value
Positive number if surface's children are hidden in the surface hierarchy; otherwise, 0.void setIntersection(int enabled, int surface)
Enables or disables intersections with a given surface.Arguments
- int enabled - 1 to enable intersections with a given surface, 0 to disable them.
- int surface - Surface number.
int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersectionTexCoord> & v, int surface)
Checks if there is an intersection between a line and a given surface. If the function returns 1 the data about the texture coordinates of the intersection point will be put to ObjectIntersectionTexCoord object.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- const Ptr<ObjectIntersectionTexCoord> & v - ObjectIntersectionTexCoord class instance to store corresponding intersection data.
- int surface - Surface number.
Return value
1 if there is an intersection with a given surface; otherwise, 0.int getIntersection(int surface)
Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.Arguments
- int surface - Surface number.
Return value
1 if intersections with a given surface are enabled; otherwise, 0. Surface intersection flag.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersectionNormal> & v, int surface)
Checks if there is an intersection between a line and a given surface. If the function returns 1 the data about the normal at the intersection point will be put to ObjectIntersectionNormal object.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- const Ptr<ObjectIntersectionNormal> & v - ObjectIntersectionNormal class instance to store corresponding intersection data.
- int surface - Surface number.
Return value
1 if there is an intersection with a given surface; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersection> & v, int * ret_surface)
Checks if there is an intersection between a line and a surface with a given intersection mask. If the function returns 1 the data about the intersection point will be put to ObjectIntersection object and the number of the first intersected surface will be put to the return array.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask.
- const Ptr<ObjectIntersection> & v - ObjectIntersection class instance to store corresponding intersection data.
- int * ret_surface - Return array.
Return value
1 if there is an intersection; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersection> & v, int surface)
Checks if there is an intersection between a line and a given surface. If the function returns 1 the data about the intersection point will be put to ObjectIntersection object.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- const Ptr<ObjectIntersection> & v - ObjectIntersection class instance to store corresponding intersection data.
- int surface - Surface number.
Return value
1 if there is an intersection with a given surface; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersectionNormal> & v, int * ret_surface)
Checks if there is an intersection between a line and a surface with a given intersection mask. If the function returns 1 the data about the normal at the intersection point will be put to ObjectIntersectionNormal object and the number of the first intersected surface will be put to the return array.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask.
- const Ptr<ObjectIntersectionNormal> & v - ObjectIntersectionNormal class instance to store corresponding intersection data.
- int * ret_surface - Return array.
Return value
1 if there is an intersection; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersectionTexCoord> & v, int * ret_surface)
Checks if there is an intersection between a line and a surface with a given intersection mask. If the function returns 1 the data about the texture coordinates of the intersection point will be put to ObjectIntersectionNormal object and the number of the first intersected surface will be put to the return array.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask.
- const Ptr<ObjectIntersectionTexCoord> & v - ObjectIntersectionTexCoord class instance to store corresponding intersection data.
- int * ret_surface - Return array.
Return value
1 if there is an intersection; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, Math::vec3 * ret_point, Math::vec3 * ret_normal, Math::vec4 * ret_texcoord, int * ret_index, int * ret_surface)
Checks if there is an intersection between a line and a surface with a given intersection mask. If the function returns 1 the data about the intersection (point, normal and texture coordinates) and the number of the first intersected surface will be put to corresponding return arrays.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask.
- Math::vec3 * ret_point - Return array for the intersection point coordinates. Pass NULL if this parameter is not required.
- Math::vec3 * ret_normal - Return array for the coordinates of the normal vector to the intersection point. Pass NULL if this parameter is not required.
- Math::vec4 * ret_texcoord - Return array for the 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). Pass NULL if this parameter is not required.
- int * ret_index - Return array for the intersected triangle number. Pass NULL if this parameter is not required.
- int * ret_surface - Return array for the intersected surface number. Pass NULL if this parameter is not required.
Return value
1 if there is an intersection; otherwise, 0.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, Math::vec3 * ret_point, Math::vec3 * ret_normal, Math::vec4 * ret_texcoord, int * ret_index, int surface)
Checks if there is an intersection between a line and a given surface. If the function returns 1 the data about the intersection (point, normal and texture coordinates) will be put to corresponding return arrays.Arguments
- const Math::vec3 & p0 - Line start point coordinates.
- const Math::vec3 & p1 - Line end point coordinates.
- Math::vec3 * ret_point - Return array for the intersection point coordinates. Pass NULL if this parameter is not required.
- Math::vec3 * ret_normal - Return array for the coordinates of the normal vector to the intersection point. Pass NULL if this parameter is not required.
- Math::vec4 * ret_texcoord - Return array for the 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). Pass NULL if this parameter is not required.
- int * ret_index - Return array for the intersected triangle number. Pass NULL if this parameter is not required.
- int surface - Surface number.
Return value
1 if there is an intersection with a given surface; otherwise, 0.void setIntersectionMask(int mask, int surface)
Sets an intersection mask for a given surface.Arguments
- int mask - Surface intersection mask.
- int surface - Surface number.
int getIntersectionMask(int surface)
Returns the intersection mask for a given surface.Arguments
- int surface - Surface number.
Return value
Surface intersection mask.void setLightMask(int mask, int surface)
Sets a shadow mask for a given surface. A surface casts shadow if its shadow mask and its material shadow mask match the shadow mask of the light source.Arguments
- int mask - Surface shadow mask.
- int surface - Surface number.
int getLightMask(int surface)
Returns the shadow mask for a given surface.Arguments
- int surface - Surface number.
Return value
Surface shadow mask.int setMaterial(const char * name, int surface)
Sets a material for a specified surface.Arguments
- const char * name - Material name.
- int surface - Surface number.
Return value
1 if the material is set successfully; otherwise, 0.int setMaterial(const char * name, const char * pattern)
Sets a material for a specified surface.Arguments
- const char * name - Material name.
- const char * pattern - Pattern (string with a regular expression), against which surface names will be matched.
Return value
1 if the material is set successfully; otherwise, 0.Ptr<Material> getMaterial(int surface)
Returns a smart pointer to the material used for a given surface.Arguments
- int surface - Surface number.
Return value
Material smart pointer.Ptr<Material> getMaterialInherit(int surface)
Inherits the surface material (i.e. creates a material instance). Modifications made to a new material instance will not affect the source material.Arguments
- int surface - Surface number.
Return value
Inherited material smart pointer.int isMaterialInherited(int surface)
Returns the value indicating if a given surface material is inherited. Modifications made in a material instance do not affect the source material.Arguments
- int surface - Surface number.
Return value
Positive number if the material is inherited; otherwise, 0.const char * getMaterialName(int surface)
Returns the name of the material applied to a given surface.Arguments
- int surface - Surface number.
Return value
Material name.void setMaterialParameter(const char * name, const Math::vec4 & parameter, int surface)
Sets the value of a given parameter of the surface material.Arguments
- const char * name - Parameter name.
- const Math::vec4 & parameter - Parameter value.
- int surface - Surface number.
Math::vec4 getMaterialParameter(const char * name, int surface)
Returns the value of a given parameter of the surface material.Arguments
- const char * name - Parameter name.
- int surface - Surface number.
Return value
Parameter value.void setMaterialState(const char * name, int state, int surface)
Sets the state value for a given surface material.Arguments
- const char * name - Material state name.
- int state - State value.
- int surface - Surface number.
int getMaterialState(const char * name, int surface)
Returns the state value of a given surface material.Arguments
- const char * name - Material state name.
- int surface - Surface number.
Return value
State value.void setMaterialTexture(const char * name, const char * texture, int surface)
Sets the path to a given texture of a given surface material.Arguments
- const char * name - Material texture name.
- const char * texture - Path to the texture file.
- int surface - Surface number.
const char * getMaterialTexture(const char * name, int surface)
Returns the path to a given texture of a given surface material.Arguments
- const char * name - Material texture name.
- int surface - Surface number.
Return value
Path to the texture file.void setMaxFadeDistance(float distance, int surface)
Updates the maximum fade-out distance of a given surface. Over this distance the surface smoothly becomes invisible due to alpha fading. It is counted off starting from the maximum visibility distance.Arguments
- float distance - Maximum fade-out distance, in units. If a negative value is provided, 0 will be used instead. The default value is 0.
- int surface - Surface number.
float getMaxFadeDistance(int surface)
Returns the maximum fade-out distance. Over this distance the surface smoothly becomes invisible due to alpha fading. It is counted starting from the maximum visibility distance.Arguments
- int surface - Surface number.
Return value
Maximum fade-out distance, in units.void setMaxParent(int parent, int surface)
Sets a surface maximum LOD parent surface number.Arguments
- int parent - Surface maximum LOD parent surface number.
- int surface - Surface number.
int getMaxParent(int surface)
Returns the surface maximum LOD parent surface number.Arguments
- int surface - Surface number.
Return value
Surface maximum LOD parent surface number.void setMaxVisibleDistance(float distance, int surface)
Updates the maximum visibility distance of a given surface. It is the distance, starting from which the surface begins to fade out until it becomes completely invisible.Arguments
- float distance - Maximum visibility distance, in units. If a negative value is provided, 0 will be used instead. The default value is inf.
- int surface - Surface number.
float getMaxVisibleDistance(int surface)
Returns the maximum visibility distance of a given surface. It is the distance, starting from which the surface begins to fade out until it becomes completely invisible.Arguments
- int surface - Surface number.
Return value
Maximum visibility distance, in units.void setMinFadeDistance(float distance, int surface)
Updates the minimum fade-in distance of a given surface. Over this distance the surface smoothly becomes visible due to alpha fading. It is counted starting from the minimum visibility distance.Arguments
- float distance - Minimum fade-in distance, in units. If a negative value is provided, 0 will be used instead. The default value is 0.
- int surface - Surface number.
float getMinFadeDistance(int surface)
Returns the minimum fade-in distance of a given surface. Over this distance the surface smoothly becomes visible due to alpha fading. It is counted starting from the minimum visibility distance.Arguments
- int surface - Surface number.
Return value
Minimum fade-in distance, in units.void setMinParent(int parent, int surface)
Sets surface minimum LOD parent surface number.Arguments
- int parent - Surface minimum LOD parent surface number.
- int surface - Surface number.
int getMinParent(int surface)
Returns the surface minimum LOD parent surface number.Arguments
- int surface - Surface number.
Return value
Surface minimum LOD parent surface number.void setMinVisibleDistance(float distance, int surface)
Updates the minimum visibility distance of a given surface. It is the distance, starting from which the surface begins to fade in until it becomes completely visible.Arguments
- float distance - Minimum visibility distance, in units. If a negative value is provided, 0 will be used instead. The default value is -inf.
- int surface - Surface number.
float getMinVisibleDistance(int surface)
Returns minimum visibility distance of a given surface. It is the distance, starting from which the surface begins to fade in until it becomes completely visible.Arguments
- int surface - Surface number.
Return value
Minimum visibility distance, in units.int getNumSurfaces()
Returns the number of surfaces of the object.Return value
int getNumTriangles(int surface)
Returns the number of triangles comprising a given surface.Arguments
- int surface - Surface number.
Return value
Number of triangles.Ptr<Object> getObject()
Returns an object pointer.Return value
Object pointer.void setParent(int parent, int surface)
Sets or clears the parent surface for a given surface.Arguments
- int parent - Number of the parent surface or -1 to clear the parent.
- int surface - Surface number.
int getParent(int surface)
Returns the number of the parent surface for a given surface.Arguments
- int surface - Surface number.
Return value
Parent surface number. If -1 is returned, the parent surface is not specified for a given surface.int setProperty(const char * name, const char * pattern)
Sets a new property for a given surface.Arguments
- const char * name - Name of the new property.
- const char * pattern - Pattern (string with a regular expression), against which surface names will be matched.
Return value
1 if the property is set successfully; otherwise, 0.int setProperty(const char * name, int surface)
Sets a new property for a given surface.Arguments
- const char * name - Name of the new property.
- int surface - Surface number.
Return value
1 if the property is set successfully; otherwise, 0.Ptr<Property> getProperty(int surface)
Returns the property smart pointer.Arguments
- int surface - Surface number.
Return value
Property smart pointer.Ptr<Property> getPropertyInherit(int surface)
Inherits the property for the specific object. All changes of the inherited property will not affect the reference one.Arguments
- int surface - Surface number.
Return value
Inherited property smart pointer.int isPropertyInherited(int surface)
Returns a value indicating if a given property is inherited.Arguments
- int surface - Surface number.
Return value
Positive number if the surface property is inherited; otherwise, 0.const char * getPropertyName(int surface)
Returns the name of the property of a given surface.Arguments
- int surface - Surface number.
Return value
Property name.void setPropertyState(const char * name, int state, int surface)
Sets the state value for a given surface property.Arguments
- const char * name - Property state name.
- int state - State value.
- int surface - Surface number.
int getPropertyState(const char * name, int surface)
Returns the state value of a given surface property.Arguments
- const char * name - Material state name.
- int surface - Surface number.
Return value
State value.const char * getSurfaceName(int surface)
Returns the name of a given surface.Arguments
- int surface - Surface number.
Return value
Surface name.void getSurfacePrefabPropertyNames(Vector< String > & property_names)
Arguments
- Vector< String > & property_names
int isSurfacePrefabPropertyOverridden(const char * property_name, int surface)
Arguments
- const char * property_name
- int surface
void setViewportMask(int mask, int surface)
Sets a viewport mask for a given surface. The object surface is rendered, if its mask matches the player (camera), light source and material masks.Arguments
- int mask - Surface viewport mask.
- int surface - Surface number.
int getViewportMask(int surface)
Returns a viewport mask for a given surface. The object surface is rendered, if its mask matches the player (camera), light source and material masks.Arguments
- int surface - Surface number.
Return value
Surface viewport mask.UNIGINE_BOUND_BOX getWorldBoundBox(int surface)
Returns the world bounding box of a given surface.Arguments
- int surface - Surface number.
Return value
Bounding box (in world coordinates).UNIGINE_BOUND_SPHERE getWorldBoundSphere(int surface)
Returns the world bounding sphere of a given surface.Arguments
- int surface - Surface number.
Return value
Bounding sphere (in world coordinates).int findSurface(const char * name)
Searches for a surface with a given name.Arguments
- const char * name - Surface name.
Return value
Surface number if it exists; otherwise, -1.void flushBodyTransform()
Forces to set the transformations of the body for the node.void render(int pass, int surface)
Renders raw object's surface to texture in specified pass.
All camera parameters should be set manually.
Usage Example
texture_render->setColorTexture(0, texture);
texture_render->enable();
object->render(PASS_AMBIENT,0);
texture_render->disable();
texture_render->unbindColorTexture();
Arguments
- int pass - A rendering pass.
- int surface - Surface number.
int revertSurfacePrefabProperty(const char * property_name, int surface)
Arguments
- const char * property_name
- int surface
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)