This page has been translated automatically.
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::PhysicalTrigger Class

Interface for physical trigger handling. Physical triggers fire callbacks when physical or non-physical collider objects get inside or outside of them.

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

Unigine::PhysicalTrigger Class

Members


static int type ()

PhysicalTrigger type.

Return value

PhysicalTrigger type identifier.

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

PhysicalTrigger constructor.

Arguments

  • const NodePtr & node - Node smart pointer.

static Ptr< PhysicalTrigger > create (const PhysicalPtr & physical)

PhysicalTrigger constructor.

Arguments

  • const PhysicalPtr & physical - Physical smart pointer.

static Ptr< PhysicalTrigger > create (int type, const vec3 & size)

PhysicalTrigger constructor.

Arguments

  • int type - The shape of the physical trigger:
    • 0 - Sphere
    • 1 - Capsule
    • 2 - Cylinder
    • 3 - Box
  • const vec3 & size - The size of the physical trigger:
    • The radius, in case of a sphere (pass the radius in the first element of the vector).
    • The radius and the height, in case of a capsule or a cylinder (pass the radius as the first vector element and the height as the second element).
    • The dimensions along the X, Y and Z axes, in case of the box.

virtual void setShapeType (int type) const =0

Sets a shape of the physical trigger.

Arguments

  • int type - A shape of the physical trigger:
    • 0 - Sphere
    • 1 - Capsule
    • 2 - Cylinder
    • 3 - Box

virtual int getShapeType () const =0

Returns the shape of the physical trigger:
  • 0, in case of the sphere shape.
  • 1, in case of the capsule shape.
  • 2, in case of the cylinder shape.
  • 3, in case of the box shape.

Return value

The shape of the physical trigger.

virtual void setSize (const vec3 & size) const =0

Sets a size of the physical trigger.

Arguments

  • const vec3 & size - A new size of the physical trigger:
    • The radius, in case of a sphere (pass the radius in the first element of the vector).
    • The radius and the height, in case of a capsule or a cylinder (pass the radius as the first vector element and the height as the second element).
    • The dimensions along the X, Y and Z axes, in case of the box.

virtual vec3 getSize () const =0

Returns the current size of the physical trigger:
  • The radius, in case of a sphere (pass the radius in the first element of the vector).
  • The radius and the height, in case of a capsule or a cylinder (pass the radius as the first vector element and the height as the second element).
  • The dimensions along the X, Y and Z axes, in case of the box.

Return value

The size of the physical trigger.

virtual void setCollisionMask (int mask) const =0

Sets the collision bit mask for the trigger:
  • In case of physical objects, the trigger will be activated if the entered body will have a matching physical mask and at the same time its shape will have a matching collision mask.
  • In case of non-physical objects, the trigger will be activated if the surface has a matching collision mask. See also details on additional collision exclusion mask (setExclusionMask()).

Arguments

  • int mask - An integer value, each bit of which is used to set a mask.

virtual int getCollisionMask () const =0

Sets the collision bit mask for the trigger:
  • In case of physical objects, the trigger will be activated if the entered body will have a matching physical mask and at the same time its shape will have a matching collision mask.
  • In case of non-physical objects, the trigger will be activated if the surface has a matching collision mask. See also details on additional collision exclusion mask (setExclusionMask()).

Return value

The integer value, each bit of which is used to set a mask.

virtual void setExclusionMask (int mask) const =0

Sets an bit mask to prevent detecting collisions with shapes and bodies. This mask is independent of the collision mask. To avoid detecting collisions by a physical trigger for bodies and shapes with matching collision masks, at least one bit in exclusion masks should match. 0 is to collide with all bodies and shapes with a matching collision mask.

Arguments

  • int mask - An integer value, each bit of which is used to set a mask.

virtual int getExclusionMask () const =0

Returns the bit mask that prevent detecting collisions with shapes and bodies. This mask is independent of the collision mask. To avoid detecting collisions by a physical trigger for bodies and shapes with matching collision masks, at least one bit in exclusion masks should match.

Return value

The integer value, each bit of which is used to set a mask.

virtual void setEnterCallbackName (const char * name) const =0

Sets a UnigineScript callback function to be fired on entering the physical trigger.
  • Unlike setEnterCallback(), this callback function accepts a body that entered the physical trigger and the physical trigger itself as arguments.
  • If collision with non-physical collider surface happens, the returned body is NULL.

Arguments

  • const char * name - A name of the UnigineScript callback function.

virtual const char * getEnterCallbackName () const =0

Returns the UnigineScript callback function fired on the physical trigger entering. This callback function is set via setEnterCallbackName().

Return value

The name of the UnigineScript callback function.

virtual void setLeaveCallbackName (const char * name) const =0

Sets a UnigineScript callback function to be fired on leaving the physical trigger.
  • Unlike setLeaveCallback(), this callback function accepts a body that left the physical trigger and physical trigger itself as arguments.
  • If collision with non-physical collider surface happens, the returned body is NULL.

Arguments

  • const char * name - A name of the UnigineScript callback function.

virtual const char * getLeaveCallbackName () const =0

Returns the UnigineScript callback function name fired on leaving the physical trigger. This callback function is set via setLeaveCallbackName().

Return value

The name of the UnigineScript callback function.

virtual void setEnterCallback (CallbackBase * func) const =0

Sets a pointer to the UnigineScript callback function to be fired on entering the physical trigger.

Arguments

  • CallbackBase * func - A pointer to the UnigineScript callback function.

virtual void setLeaveCallback (CallbackBase * func) const =0

Sets a pointer to the UnigineScript callback function to be fired on leaving the physical trigger.

Arguments

  • CallbackBase * func - A pointer to the UnigineScript callback function.

virtual void updateContacts () const =0

Forces a physical trigger to be updated, i.e. to recalculate its intersections with physical objects and colliders. After that, you can access all updated data; however, callback functions themselves will be executed only when physics flush is over.

Unigine::PhysicalTrigger::anonymous_88 Enumeration

SHAPE_SPHERE = 0
SHAPE_CAPSULE
SHAPE_CYLINDER
SHAPE_BOX
Last update: 2017-07-03
Build: ()