This page has been translated automatically.
Программирование
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

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 in range from 0 to number of surfaces.

Return value

Bounding box.

BoundSphere getBoundSphere(int surface)

Returns the bounding sphere of a given surface.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Bounding sphere.

void setCastShadow(int enabled, int surface)

Sets a surface cast shadow flag, which indicates if a given object surface should cast shadows from non-world lights.

Arguments

  • int enabled - Surface cast shadow flag.
  • int surface - Surface number.

int getCastShadow(int surface)

Returns a surface cast shadow flag, which indicates if a given object surface should cast shadows from non-world lights.

Arguments

  • int surface - Surface number.

Return value

Surface cast shadow flag.

void setCastWorldShadow(int enabled, int surface)

Sets a cast world shadow flag for a given surface. This flag indicates if the surface should cast shadows from world lights.

Arguments

  • int enabled - Cast world shadow flag to set for the surface.
  • int surface - Surface number.

int getCastWorldShadow(int surface)

Returns a cast world shadow flag for a given surface. This flag indicates if the surface should cast shadows from world lights.

Arguments

  • int surface - Surface number.

Return value

Cast world shadow flag set for the surface.

void setCollision(int enabled, int surface)

Sets a surface collision flag. This flag indicates if collisions with a given surface are enabled.

Arguments

  • int enabled - Surface collision flag.
  • int surface - Surface number.

int getCollision(int surface)

Returns a surface collision flag. This flag indicates if collisions with a given surface are enabled.

Arguments

  • int surface - Surface number.

Return value

Surface collision flag.

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 a collision mask for a given surface. Two objects collide, if they both have matching masks.

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 the node.

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 the node and its parent nodes are enabled.

Arguments

  • int surface - ID number of the surface.

Return value

Returns 1 if the node and its parent nodes are enabled; otherwise, 0.

int isEnabled()

Returns a value indicating if the node and its parent nodes are enabled.

Return value

Returns 1 if the node and its parent nodes are enabled; otherwise, 0.

void setFolded(int folded, int surface)

Shows or minimizes surface children in the surface hierarchy.

Arguments

  • int folded - Positive number to minimize surface children, 0 to expand the hierarchy.
  • int surface - Surface number.

int isFolded(int surface)

Returns a value indicating if surface children are displayed of minimized in the surface hierarchy.

Arguments

  • int surface - Surface number.

Return value

Positive number if surface children are hidden in the surface hierarchy; otherwise, 0.

void setIntersection(int enabled, int surface)

Sets a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • int enabled - Surface intersection flag.
  • int surface - Surface number.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersectionTexCoord> & v, int surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • const Ptr<ObjectIntersectionTexCoord> & v - Variable used to control which type of intersection object will be returned:
  • int surface - Surface number.

Return value

Surface intersection flag.

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

Surface intersection flag.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersectionNormal> & v, int surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • const Ptr<ObjectIntersectionNormal> & v - Variable used to control which type of intersection object will be returned:
  • int surface - Surface number.

Return value

Surface intersection flag.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersection> & v, int * ret_surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • int mask - Variable used to control which type of intersection object will be returned:
  • const Ptr<ObjectIntersection> & v - Surface number.
  • int * ret_surface

Return value

Surface intersection flag.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, const Ptr<ObjectIntersection> & v, int surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • const Ptr<ObjectIntersection> & v - Variable used to control which type of intersection object will be returned:
  • int surface - Surface number.

Return value

Surface intersection flag.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersectionNormal> & v, int * ret_surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • int mask - Variable used to control which type of intersection object will be returned:
  • const Ptr<ObjectIntersectionNormal> & v - Surface number.
  • int * ret_surface

Return value

Surface intersection flag.

int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, int mask, const Ptr<ObjectIntersectionTexCoord> & v, int * ret_surface)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - ID number of the surface.
  • const Math::vec3 & p1 - End point coordinates.
  • int mask - Variable used to control which type of intersection object will be returned:
  • const Ptr<ObjectIntersectionTexCoord> & v - Surface number.
  • int * ret_surface

Return value

Surface intersection flag.

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)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - Coordinates of the line start point.
  • const Math::vec3 & p1 - Coordinates of the line end point.
  • int mask - Intersection mask.
  • Math::vec3 * ret_point - Intersection point of the line and object. You can pass NULL if the parameter is not required.
  • Math::vec3 * ret_normal - Normal vector to the intersection point. You can pass NULL if the parameter is not required.
  • Math::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). You can pass NULL if the parameter is not required.
  • int * ret_index - Intersected triangle number. You can pass NULL if the parameter is not required.
  • int * ret_surface - Intersected surface number. You can pass NULL if the parameter is not required.

Return value

Surface intersection flag.

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)

Returns a surface intersection flag. This flag indicates if intersections with a given surface are enabled.

Arguments

  • const Math::vec3 & p0 - Coordinates of the line start point.
  • const Math::vec3 & p1 - Coordinates of the line end point.
  • Math::vec3 * ret_point - Intersection point of the line and object. You can pass NULL if the parameter is not required.
  • Math::vec3 * ret_normal - Normal vector to the intersection point. You can pass NULL if the parameter is not required.
  • Math::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). You can pass NULL if the parameter is not required.
  • int * ret_index - Intersected triangle number. You can pass NULL if the parameter is not required.
  • int surface - The number of the surface, with which the intersection must be detected.

Return value

Surface intersection flag.

void setIntersectionMask(int mask, int surface)

Sets an intersection mask for a given surface.

Arguments

  • int mask - Surface intersection mask (integer, each bit of which is a mask).
  • int surface - Surface number.

int getIntersectionMask(int surface)

Return an intersection mask for a given surface.

Arguments

  • int surface - Surface number.

Return value

Surface intersection mask.

void setLightMask(int mask, int surface)

Sets a light mask for a given surface.

Arguments

  • int mask - Surface light mask (integer, each bit of which is a mask).
  • int surface - Surface number.

int getLightMask(int surface)

Returns a light mask for a given surface.

Arguments

  • int surface - Surface number.

Return value

Surface light mask (integer, each bit of which is a mask).

int setMaterial(const char * name, int surface)

Sets a material for a specified surface.

Arguments

  • const char * name - Name of the new material.
  • int surface - Surface number in range from 0 to number of surfaces.

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 - Name of the new material.
  • const char * pattern - Surface number in range from 0 to number of surfaces.

Return value

1 if the material is set successfully; otherwise, 0.

Ptr<Material> getMaterial(int surface)

Returns the material smart pointer.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Material smart pointer.

Ptr<Material> getMaterialInherit(int surface)

Inherits the surface material (i.e. creates a material instance). Modifications made in a new material instance will not affect the source material.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Inherited material smart pointer.

int isMaterialInherited(int surface)

Returns a 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 in range from 0 to number of surfaces.

Return value

Returns 1 if the object surface material is inherited.

const char * getMaterialName(int surface)

Returns the name of the material applied to a given surface.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Material name.

void setMaterialParameter(const char * name, const Math::vec4 & parameter, int surface)

Sets a value of a given parameter of the surface material.

Arguments

  • const char * name - Name of the parameter.
  • const Math::vec4 & parameter - Value of the parameter.
  • int surface - ID number of the surface.

Math::vec4 getMaterialParameter(const char * name, int surface)

Returns a value of a given parameter of the surface material.

Arguments

  • const char * name - Name of the parameter.
  • int surface - ID number of the surface.

Return value

Value of the parameter.

void setMaterialState(const char * name, int state, int surface)

Sets a state value for a given surface material.

Arguments

  • const char * name - Material state name.
  • int state - State value.
  • int surface - ID number of the surface.

int getMaterialState(const char * name, int surface)

Returns a state value of a given surface material.

Arguments

  • const char * name - Material state name.
  • int surface - ID number of the surface.

Return value

State value.

void setMaterialTexture(const char * name, const char * texture, int surface)

Sets a 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 - ID number of the surface.

const char * getMaterialTexture(const char * name, int surface)

Returns a path to a given texture of a given surface material.

Arguments

  • const char * name - Material texture name.
  • int surface - ID number of the surface.

Return value

Path to the texture file.

void setMaxFadeDistance(float distance, int surface)

Updates maximum fade-out distance of a given surface. Across 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 of the surface. The default is 0.
  • int surface - Surface number in range from 0 to number of surfaces.

float getMaxFadeDistance(int surface)

Returns maximum fade-out distance of a given surface. Across this distance the surface smoothly becomes invisible due to alpha fading. It is counted off starting from the maximum visibility distance.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Maximum fade-out distance of the surface.

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 in range from 0 to number of surfaces.

int getMaxParent(int surface)

Returns a surface maximum LOD parent surface number.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Surface maximum LOD parent surface number.

void setMaxVisibleDistance(float distance, int surface)

Updates maximum visibility distance of a given surface (the distance, from which the surface begins fading out until completely invisible).

Arguments

  • float distance - Maximum visibility distance. The default is inf.
  • int surface - Surface number in range from 0 to number of surfaces.

float getMaxVisibleDistance(int surface)

Returns maximum visibility distance of a given surface (the distance, from which the surface begins fading out until completely invisible).

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Maximum visibility distance of the surface.

void setMinFadeDistance(float distance, int surface)

Updates minimum fade-in distance of a given surface. Across this distance the surface smoothly becomes visible due to alpha fading. It is counted off starting from the minimum visibility distance.

Arguments

  • float distance - Minimum fade-in distance. The default is 0.
  • int surface - Surface number in range from 0 to number of surfaces.

float getMinFadeDistance(int surface)

Returns minimum fade-in distance of a given surface. Across this distance the surface smoothly becomes visible due to alpha fading. It is counted off starting from the minimum visibility distance. It is counted off starting from the minimum visibility distance.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Minimum fade-in distance.

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 in range from 0 to number of surfaces.

int getMinParent(int surface)

Return 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 minimum visibility distance of a given surface (the distance, starting from which the surface begins fading in and then is completely visible).

Arguments

  • float distance - Minimum visibility distance. The default is -inf.
  • int surface - Surface number in range from 0 to number of surfaces.

float getMinVisibleDistance(int surface)

Returns minimum visibility distance of a given surface (the distance, starting from which the surface begins fading in and then is completely visible).

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Minimum visibility distance.

int getNumSurfaces()

Returns the number of object surfaces.

Return value

Number of surfaces of the object.

int getNumTriangles(int surface)

Returns the number of triangles comprising a given surface.

Arguments

  • int surface - ID number of the surface.

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 number of a parent surface of a given surface.

Arguments

  • int parent - Parent surface number in range from -1 to the number of object surfaces; -1 is used to clear the parent surface.
  • int surface - Surface number in range from 0 to the number of object surfaces.

int getParent(int surface)

Returns the number of a parent surface of a given surface.

Arguments

  • int surface - Surface number in range from 0 to the number of object surfaces.

Return value

Parent surface number. If -1 is returned, the parent surface is not specified for the given surface.

int setProperty(const char * name, const char * pattern)

Sets a property for a given surface.

Arguments

  • const char * name - Name of the new property.
  • const char * pattern - ID number of the surface (int) or 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 property for a given surface.

Arguments

  • const char * name - Name of the new property.
  • int surface - Surface number in range from 0 to number of surfaces.

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 in range from 0 to number of surfaces.

Return value

Property smart pointer.

Ptr<Property> getPropertyInherit(int surface)

Inherits the property for the specific object. All transformations done to the inherited property will not affect the reference one.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

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 in range from 0 to number of surfaces.

Return value

Returns 1 if the surface property is inherited.

const char * getPropertyName(int surface)

Returns the name of a property applied to a given surface.

Arguments

  • int surface - Surface number in range from 0 to number of surfaces.

Return value

Name of the surface property.

void setPropertyState(const char * name, int state, int surface)

Sets a state value for a given surface property.

Arguments

  • const char * name - Property state name.
  • int state - State value.
  • int surface - ID number of the surface.

int getPropertyState(const char * name, int surface)

Returns a state value of a given surface property.

Arguments

  • const char * name - Material state name.
  • int surface - ID number of the surface.

Return value

State value.

const char * getSurfaceName(int surface)

Returns the name of a given object surface.

Arguments

  • int surface - number of the surface.

Return value

Surface name.

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 (integer, each bit of which is a 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 in range from 0 to number of surfaces.

Return value

World 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 in range from 0 to number of surfaces.

Return value

World bounding sphere (in world coordinates).

int findSurface(const char * name)

Searches for an object 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.

Notice
All camera parameters should be set manually.

Usage Example

Source code (C++)
texture_render->setColorTexture(0, texture);
texture_render->enable();
object->render(PASS_AMBIENT,0);
texture_render->disable();
texture_render->unbindColorTexture();

Arguments

Last update: 03.07.2017
Build: ()