UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

Object Class

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

This class inherits from Node

Members


int findSurface (string name)

Searches for a surface with a given name.

Arguments

  • string name - Name of the surface.

Return value

Surface ID number or -1, if nothing is found.

void flushBodyTransform ()

Forces to set the transformations of the body for the node.

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.

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.

vec3 getBoundCenter (int surface)

Returns the center of the bounding sphere of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Coordinates of the center of the bounding sphere.

vec3 getBoundMax (int surface)

Returns the point with the maximum coordinates of the axis-aligned bounding box of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Maximum coordinates of the bounding box.

vec3 getBoundMin (int surface)

Returns the point with the minimum coordinates of the axis-aligned bounding box of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Minimum coordinates of the bounding box.

float getBoundRadius (int surface)

Returns the radius of the bounding sphere of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Radius of the bounding sphere.

int getCastShadow (int surface)

Returns a value indicating if a given surface casts shadows from non-world lights.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if shadows are cast by the surface.

int getCastWorldShadow (int surface)

Returns a value indicating if a given surface casts shadows from world lights.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if world shadows are cast by the surface.

int getCollisionMask (int surface)

Returns a collision mask of a given surface. Two objects collide, if they both have matching masks. The default is ~0.

Arguments

  • int surface - ID number of the surface.

Return value

Integer, each bit of which is a mask.

int getCollision (int surface)

Returns a value indicating if collisions with a given surface are calculated.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if collisions with the surface are calculated; otherwise 0.

int getDecalMask (int surface)

Returns a decal mask of a given surface. A surface receives a decal, if they both have corresponding masks. The default is ~0.

Arguments

  • int surface - ID number of the surface.

Return value

Integer, each bit of which is a mask.

int getDecal (int surface)

Returns a value indicating if a given surface can have decals on itself.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if the surface can have decals on itself; otherwise 0.

int getIntersectionMask (int surface)

Returns an intersection mask of a given surface. The default is ~0.

Arguments

  • int surface - ID number of the surface.

Return value

Integer, each bit of which is a mask.

int getIntersection (int surface)

Returns a value indicating if a given surface can be intersected.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if the surface can be intersected; otherwise 0.

int getIntersection (vec3 p0, vec3 p1, int surface)

Performs tracing from one point to another to find, if the object is located on that line. Object local space coordinates are used for this function.

Arguments

  • vec3 p0 - Source point (in the local coordinates).
  • vec3 p1 - Destination point (in the local coordinates).
  • int surface - Surface to test.

Return value

Positive number if the specified object surface is intersected; otherwise, 0.

int getIntersection (vec3 p0, vec3 p1, int surface, int ret[])

Performs tracing from one point to another to find, if the object is located on that line. Object local space coordinates are used for this function.

Arguments

  • vec3 p0 - Source point (in the local coordinates).
  • vec3 p1 - Destination point (in the local coordinates).
  • int surface - Surface to test.
  • int ret[] - Return array, its components are:
    • ret[0]: intersection point (vec3), in the local coordinates.
    • ret[1]: normal of the intersection point (vec3).
    • ret[2]: texture coordinates of the intersection point (vec4; vec4.xy is for UV channel 0, vec4.zw is for UV channel 1).
    • ret[3]: intersected triangle number.

Return value

Positive number if the specified object surface is intersected; otherwise, 0.

int getLightMask (int surface)

Returns a light mask of a given surface. A surface is illuminated by a light source, if they both have corresponding masks. The default is ~0.

Arguments

  • int surface - ID number of the surface.

Return value

Integer, each bit of which is a mask.

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

Return value

The inherited material.

string getMaterialName (int surface)

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

Arguments

  • int surface - ID number of the surface.

Return value

Material name.

vec4 getMaterialParameter (string parameter, int surface)

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

Arguments

  • string parameter - Name of the parameter.
  • int surface - ID number of the surface.

Return value

Value of the parameter.

int getMaterialState (string state, int surface)

Returns a state value of a given surface material.

Arguments

  • string state - Material state name.
  • int surface - ID number of the surface.

Return value

State value.

string getMaterialTexture (string texture, int surface)

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

Arguments

  • string texture - Material texture name.
  • int surface - ID number of the surface.

Return value

Path to the texture file.

Material getMaterial (int surface)

Returns a material used for a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Material used for the surface.

float getMaxFadeDistance (int surface)

Returns a maximum fade-out distance, across which the surface smoothly becomes invisible due to the alpha fading. It is counted starting from the maximum visibility distance value.

Arguments

  • int surface - ID number of the surface.

Return value

Distance value, in units.

int getMaxParent (int surface)

Returns the number of hierarchy levels up to the reference object, which is used to measure the maximum visible distance:
  • 0 is the current surface
  • 1 is the object to which the surface belongs
  • higher values are to move higher up the hierarchy to node parents

Arguments

  • int surface - ID number of the surface.

Return value

Number of hierarchy levels.

int getMaxShadowSplit (int surface)

Returns the highest shadow split (for shadows from the LightWorld source) rendered for an object surface. It is used to skip rendering of high-detail shadows splits (which is useful for small objects like stones, debris, etc.). The default is 4 (no shadow optimization).

Arguments

  • int surface - ID number of the surface.

Return value

Maximum rendered shadow split.

float getMaxVisibleDistance (int surface)

Returns a maximum visibility distance, starting at which the surface begins to fade out until becomes completely invisible.

Arguments

  • int surface - ID number of the surface.

Return value

Distance value, in units.

float getMinFadeDistance (int surface)

Returns a minimum fade-in distance, across which the surface smoothly becomes visible due to the alpha fading. It is counted starting from the minimum visibility distance value.

Arguments

  • int surface - ID number of the surface.

Return value

Distance value, in units.

int getMinParent (int surface)

Returns the number of hierarchy levels up to the reference object, which is used to measure the minimum visible distance:
  • 0 is the current surface
  • 1 is the object to which the surface belongs
  • higher values are to move higher up the hierarchy to node parents
The default is 1.

Arguments

  • int surface - ID number of the surface.

Return value

Number of hierarchy levels.

float getMinVisibleDistance (int surface)

Returns a minimum visibility distance, starting at which the surface begins to fade in and then becomes completely visible.

Arguments

  • int surface - ID number of the surface.

Return value

Distance value, in units.

int getNumObjectDecals (int surface)

Returns the number of decals projected onto the given object surface.

Arguments

  • int surface - ID number of the surface.

Return value

The number of decals currently projected onto the surface.

int getNumSurfaces ()

Returns the number of surfaces of the object.

Return value

Number of surfaces.

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.

int getParent (int surface)

Returns the parent surface of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

ID number of the parent surface.

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

Return value

The inherited property.

string getPropertyName (int surface)

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

Arguments

  • int surface - ID number of the surface.

Return value

Property name.

variable getPropertyParameter (string parameter, int surface)

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

Arguments

  • string parameter - Name of the parameter.
  • int surface - ID number of the surface.

Return value

Value of the parameter. Either int, float or string.

int getPropertyState (string state, int surface)

Returns a state value of a given surface property.

Arguments

  • string state - Material state name.
  • int surface - ID number of the surface.

Return value

State value.

Property getProperty (int surface)

Returns a property defined for a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Property used for the surface.

int getReceiveShadow (int surface)

Returns a value indicating if a given surface receives shadows created with non-world lights.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if shadows are received by the surface.

int getReceiveWorldShadow (int surface)

Returns a value indicating if a given surface receives shadows created with world lights.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if world shadows are received by the surface.

string getSurfaceName (int surface)

Returns the name of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Name of the surface.

int getViewportMask (int surface)

Returns the current bit mask for rendering into the viewport. The object surface is rendered, if its mask matches the player's and light source's ones. The material mask should also match.

Arguments

  • int surface - ID number of the surface.

Return value

Integer, each bit of which is a mask.

vec3 getWorldBoundCenter (int surface)

Returns the center, in world coordinates, of the bounding sphere of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Coordinates of the center of the bounding sphere.

vec3 getWorldBoundMax (int surface)

Returns the point with the maximum world coordinates of the axis-aligned bounding box of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Maximum coordinates of the bounding box.

vec3 getWorldBoundMin (int surface)

Returns the point with the minimum world coordinates of the axis-aligned bounding box of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Minimum coordinates of the bounding box.

float getWorldBoundRadius (int surface)

Returns the radius of the bounding sphere, in world coordinates, of a given surface.

Arguments

  • int surface - ID number of the surface.

Return value

Radius of the bounding sphere.

int isEnabled (int surface)

Returns a value indicating if a given surface is enabled.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if the surface is enabled; otherwise, 0.

int isFolded (int surface)

Returns a value indicating if surface's children are displayed or minimized in the surface hierarchy.

Arguments

  • int surface - Surface ID to minimize its children.

Return value

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

int isMaterialInherited (int surface)

Returns a value indicating if a given surface material is inherited (instanced). Modifications made in a material instance do not affect the source material.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if the material is inherited; otherwise, 0.

int isPropertyInherited (int surface)

Returns a value indicating if a given property is inherited.

Arguments

  • int surface - ID number of the surface.

Return value

Positive number if the property is inherited; otherwise, 0.

void removeObjectDecals (int surface)

Clears the given object surface from all decals projected onto it.

Arguments

  • int surface - ID number of the surface.

void setBody (Body body)

Assigns a physical body to the object.

Arguments

  • Body body - Physical body.

void setCastShadow (int mode, int surface)

Sets a value indicating if a given surface should cast shadows from non-world lights.

Arguments

  • int mode - Positive number to let the surface cast shadows, 0 no to let.
  • int surface - ID number of the surface.

void setCastWorldShadow (int mode, int surface)

Sets a value indicating if a given surface should cast shadows from world lights.

Arguments

  • int mode - Positive number to let the surface cast world shadows, 0 no to let.
  • int surface - ID number of the surface.

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 - Integer, each bit of which is a mask.
  • int surface - ID number of the surface.

void setCollision (int mode, int surface)

Enables or disables collisions with a given surface.

Arguments

  • int mode - Positive number to enable collisions with the surface; otherwise 0.
  • int surface - ID number of the surface.

void setDecalMask (int mask, int surface)

Sets a decal mask for a given surface. A surface receives a decal, if they both have corresponding masks.

Arguments

  • int mask - Integer, each bit of which is a mask.
  • int surface - ID number of the surface.

void setDecal (int mode, int surface)

Allows or disallows a given surface accept decals.

Arguments

  • int mode - Positive number to allow the surface accept decals, 0 to disallow.
  • int surface - ID number of the surface.

void setEnabled (int mode, int surface)

Enables or disables a given surface.

Arguments

  • int mode - Positive number to enable the surface, 0 to disable it.
  • int surface - ID number of the surface.

void setFolded (int fold, int surface)

Shows or minimizes surface's children in the surface hierarchy.

Arguments

  • int fold - Positive number to minimize surface's children, 0 to expand the hierarchy.
  • int surface - Surface ID to minimize its children.

void setIntersectionMask (int mask, int surface)

Sets an intersection mask for a given surface.

Arguments

  • int mask - Integer, each bit of which is a mask.
  • int surface - ID number of the surface.

void setIntersection (int mode, int surface)

Enables or disables intersections with a given surface.

Arguments

  • int mode - Positive number to enable intersections with the surface; otherwise 0.
  • int surface - ID number of the surface.

void setLightMask (int mask, int surface)

Sets a light mask for a given surface. A surface is illuminated by a light source, if they both have corresponding masks.

Arguments

  • int mask - Integer, each bit of which is a mask.
  • int surface - ID number of the surface.

void setMaterialParameter (string parameter, vec4 value, int surface)

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

Arguments

  • string parameter - Name of the parameter.
  • vec4 value - Value of the parameter.
  • int surface - ID number of the surface.

void setMaterialState (string state, int value, int surface)

Sets a state value for a given surface material.

Arguments

  • string state - Material state name.
  • int value - State value.
  • int surface - ID number of the surface.

void setMaterialTexture (string texture, string path, int surface)

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

Arguments

  • string texture - Material texture name.
  • string path - Path to the texture file.
  • int surface - ID number of the surface.

void setMaterial (string material, variable surface)

Sets a material for specified surfaces.

Arguments

  • string material - Name of the new material.
  • variable surface - ID number of the surface (int) or pattern (string with a regular expression), against which surface names will be matched.

void setMaxFadeDistance (float distance, int surface)

Updates a maximum fade-out distance, across which the surface smoothly becomes invisible due to the alpha fading. It is counted starting from the maximum visibility distance value. The default is 0.

Arguments

  • float distance - A minimum fade-out distance, in units. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setMaxParent (int parent, int surface)

Updates the number of hierarchy levels up to the reference object, which is used to measure the maximum visible distance:
  • 0 is the current surface
  • 1 is the object to which the surface belongs
  • higher values are to move higher up the hierarchy to node parents
The default is 1.

Arguments

  • int parent - Number of hierarchy levels. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setMaxShadowSplit (int split, int surface)

Limits the highest shadow split (for shadows from the LightWorld source) rendered for an object surface. It is used to skip rendering of high-detail shadows splits (which is useful for small objects like stones, debris, etc.). The default is 4 (no shadow optimization).

Arguments

  • int split - Maximum rendered shadow split.
  • int surface - ID number of the surface.

void setMaxVisibleDistance (float distance, int surface)

Updates the maximum visibility distance, starting at which the surface begins to fade out until becomes completely invisible. The default is inf.

Arguments

  • float distance - A maximum visibility distance, in units. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setMinFadeDistance (float distance, int surface)

Updates a minimum fade-in distance, across which the surface smoothly becomes visible due to the alpha fading. It is counted starting from the minimum visibility distance value. The default value is 0.

Arguments

  • float distance - A minimum fade-in distance, in units. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setMinParent (int parent, int surface)

Updates the number of hierarchy levels up to the reference object, which is used to measure the minimum visible distance:
  • 0 is the current surface
  • 1 is the object to which the surface belongs
  • higher values are to move higher up the hierarchy to node parents

Arguments

  • int parent - Number of hierarchy levels. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setMinVisibleDistance (float distance, int surface)

Updates a minimum visibility distance, starting at which the surface begins to fade in and then becomes completely visible. The default is -inf.

Arguments

  • float distance - A minimum visibility distance, in units. If a negative value is provided, 0 will be used instead.
  • int surface - ID number of the surface.

void setParent (int parent, int surface)

Sets or clears the parent surface of a given surface.

Arguments

  • int parent - ID number of the parent surface or -1 to clear the parent.
  • int surface - ID number of the surface.

void setPropertyParameter (string parameter, variable value, int surface)

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

Arguments

  • string parameter - Name of the parameter.
  • variable value - Value of the parameter. Either int, float or string.
  • int surface - ID number of the surface.

void setPropertyState (string state, int value, int surface)

Sets a state value for a given surface property.

Arguments

  • string state - Property state name.
  • int value - State value.
  • int surface - ID number of the surface.

void setProperty (string property, variable surface)

Sets a property for specified surfaces.

Arguments

  • string property - Name of the new property.
  • variable surface - ID number of the surface (int) or pattern (string with a regular expression), against which surface names will be matched.

void setReceiveShadow (int mode, int surface)

Sets a value indicating if a given surface should receive shadows created with non-world lights.

Arguments

  • int mode - Positive number to let the surface receive shadows, 0 no to let.
  • int surface - ID number of the surface.

void setReceiveWorldShadow (int mode, int surface)

Sets a value indicating if a given surface should receive shadows created with world lights.

Arguments

  • int mode - Positive number to let the surface receive world shadows, 0 no to let.
  • int surface - ID number of the surface.

void setViewportMask (int mask, int surface)

Sets a bit mask for rendering into the viewport. The object surface is rendered, if its mask matches the player's and light source's ones. The material mask should also match.

Arguments

  • int mask - Integer, each bit of which is a mask.
  • int surface - ID number of the surface.
Last update: 2017-07-03