UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1

Unigine::Object Class

Interface for object handling. See also the UnigineScript analog.

To use this class, include the UnigineObject.h file.

Unigine::Object Class

Members


static Ptr< Object > create (const NodePtr & node)

Object constructor.

Arguments

  • const NodePtr & node - Node smart pointer.

virtual Ptr< Object > getObject () const =0

Returns an object pointer.

Return value

Object pointer.

virtual void setEnabled (int enable) const =0

Enables or disables the node.

Arguments

  • int enable - 1 to enable the node, 0 to disable it.

virtual int isEnabled () const =0

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.

virtual int getNumSurfaces () const =0

Returns the number of object surfaces.

Return value

Number of surfaces of the object.

virtual const char * getSurfaceName (int surface) const =0

Returns the name of a given object surface.

Arguments

  • int surface - number of the surface.

Return value

Surface name.

virtual int findSurface (const char * name) const =0

Searches for an object surface with a given name.

Arguments

  • const char * name - Surface name.

Return value

Surface number if it exists; otherwise, -1.

virtual void setEnabled (int enable, int surface) const =0

Enables or disables a given object surface.

Arguments

  • int enable - 1 to enable the surface, 0 to disable it.
  • int surface - Surface number.

virtual int isEnabled () const =0

Returns a value indicating if a given object surface is enabled.

Return value

Returns 1 if the given surface is disabled; otherwise, 0.

virtual void setFolded (int folded, int surface) const =0

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.

virtual int isFolded (int surface) const =0

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.

virtual void setParent (int parent, int surface) const =0

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.

virtual int getParent (int surface) const =0

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.

virtual void setCastShadow (int enable, int surface) const =0

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

Arguments

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

virtual int getCastShadow (int surface) const =0

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.

virtual void setCastWorldShadow (int enable, int surface) const =0

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

Arguments

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

virtual int getCastWorldShadow (int surface) const =0

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.

virtual void setIntersection (int enable, int surface) const =0

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

Arguments

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

virtual int getIntersection (int surface) const =0

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.

virtual void setCollision (int enable, int surface) const =0

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

Arguments

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

virtual int getCollision (int surface) const =0

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.

virtual void setLightMask (int mask, int surface) const =0

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.

virtual int getLightMask (int surface) const =0

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).

virtual void setViewportMask (int mask, int surface) const =0

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.

virtual int getViewportMask (int surface) const =0

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.

virtual void setIntersectionMask (int mask, int surface) const =0

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.

virtual int getIntersectionMask (int surface) const =0

Return an intersection mask for a given surface.

Arguments

  • int surface - Surface number.

Return value

Surface intersection mask.

virtual void setCollisionMask (int mask, int surface) const =0

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.

virtual int getCollisionMask (int surface) const =0

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.

virtual void setMinParent (int parent, int surface) const =0

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.

virtual int getMinParent (int surface) const =0

Return the surface minimum LOD parent surface number.

Arguments

  • int surface - Surface number.

Return value

Surface minimum LOD parent surface number.

virtual void setMinVisibleDistance (float distance, int surface) const =0

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.

virtual float getMinVisibleDistance (int surface) const =0

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.

virtual void setMinFadeDistance (float distance, int surface) const =0

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.

virtual float getMinFadeDistance (int surface) const =0

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.

virtual void setMaxParent (int parent, int surface) const =0

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.

virtual int getMaxParent (int surface) const =0

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.

virtual void setMaxVisibleDistance (float distance, int surface) const =0

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.

virtual float getMaxVisibleDistance (int surface) const =0

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.

virtual void setMaxFadeDistance (float distance, int surface) const =0

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.

virtual float getMaxFadeDistance (int surface) const =0

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.

virtual int setMaterial (const char * name, int surface) const =0

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.

virtual int setMaterial (const char * name, const char * pattern) const =0

Sets a material for a specified surface.

Arguments

  • const char * name - Name of the new material.
  • const char * pattern - Surface name pattern, against which surface names will be matched. The pattern is a string with a regular expression.

Return value

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

virtual MaterialPtr getMaterial (int surface) const =0

Returns the material smart pointer.

Arguments

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

Return value

Material smart pointer.

virtual MaterialPtr getMaterialInherit (int surface) const =0

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.

virtual int isMaterialInherited (int surface) const =0

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.

virtual const char * getMaterialName (int surface) const =0

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.

virtual int setProperty (const char * name, int surface) const =0

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.

virtual int setProperty (const char * name, const char * pattern) const =0

Sets a property for a given surface.

Arguments

  • const char * name - Name of the new property.
  • const char * pattern - Surface name pattern, against which surface names will be matched. The pattern is a string with a regular expression.

Return value

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

virtual PropertyPtr getProperty (int surface) const =0

Returns the property smart pointer.

Arguments

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

Return value

Property smart pointer.

virtual PropertyPtr getPropertyInherit (int surface) const =0

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.

virtual int isPropertyInherited (int surface) const =0

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.

virtual const char * getPropertyName (int surface) const =0

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.

virtual int getIntersection (const vec3 & p0, const vec3 & p1, vec3 * ret_point, vec3 * ret_normal, vec4 * ret_texcoord, int * ret_index, int surface) const =0

Searches for an intersection of the object's surface with the given line. An intersection with the surface can be found only if the following conditions are fulfilled:
  1. A per-surface Intersection flag is enabled.
  2. An Intersection option of the property in the Properties window is enabled.
  3. A surface has an assigned material.
  4. A surface has an assigned property.
  5. A surface is enabled.

Arguments

  • const vec3 & p0 - Coordinates of the line start point.
  • const vec3 & p1 - Coordinates of the line end point.
  • vec3 * ret_point - Intersection point of the line and object. You can pass NULL if the parameter is not required.
  • vec3 * ret_normal - Normal vector to the intersection point. You can pass NULL if the parameter is not required.
  • 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

Returns the 1 if the intersection is found; otherwise, 0.

virtual int getIntersection (const vec3 & p0, const vec3 & p1, int mask, vec3 * ret_point, vec3 * ret_normal, vec4 * ret_texcoord, int * ret_index, int * ret_surface) const =0

Searches for an intersection of the object with the given line. An intersection is found only if an object is matching the intersection mask. An intersection with the surface can be found only if the following conditions are fulfilled:
  1. A per-surface Intersection flag is enabled.
  2. An Intersection option of the property in the Properties window is enabled.
  3. A surface has an assigned material.
  4. A surface has an assigned property.
  5. A surface is enabled.

Arguments

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

Returns 1 if the intersection is found; otherwise, 0.

virtual BoundBox getBoundBox (int surface) const =0

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.

virtual BoundSphere getBoundSphere (int surface) const =0

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.

virtual UNIGINE_BOUND_BOX getWorldBoundBox (int surface) const =0

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).

virtual UNIGINE_BOUND_SPHERE getWorldBoundSphere (int surface) const =0

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).
Last update: 2017-07-03