This page has been translated automatically.
Programming
Fundamentials
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
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

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.

PhysicalTrigger Class

Members


PhysicalTrigger (int type, const Math::vec3 & size)

Constructor. Creates a physical trigger of the specified shape and size.

Arguments

  • int type - Shape of the physical trigger:
    • 0 = Sphere
    • 1 = Capsule
    • 2 = Cylinder
    • 3 = Box
  • const Math::vec3 & size - Size of the physical trigger:
    • Radius, in case of a sphere
    • Radius and height, in case of a capsule or a cylinder
    • Dimensions, in case of the box

Math::Vec3 getContactPoint (int contact)

Returns world coordinates of the contact point.

Arguments

  • int contact - Contact number.

Return value

Contact point.

int getNumBodies ()

Returns the total number of bodies with which a physical trigger intersected.

Return value

The number of bodies.

float getContactDepth (int contact)

Returns penetration depth by the given contact.

Arguments

  • int contact - Contact number.

Return value

Penetration depth.

void setLeaveCallbackName (const char * name)

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.

void setCollisionMask (int mask)

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.

void setEnterCallbackName (const char * name)

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.

Ptr<Body> getBody (int num)

Returns the specified body with which a physical trigger intersects.

Arguments

  • int num - Body number.

Return value

Intersected body.

int getCollisionMask ()

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.

Math::vec3 getSize ()

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.

Ptr<Shape> getContactShape (int contact)

Returns a shape that collided with a physical trigger.

Arguments

  • int contact - Contact number.

Return value

Shape in contact.

int getContactSurface (int contact)

Returns the surface of the current object, which is in contact (used for intersecting with non-physical objects).

Arguments

  • int contact - Contact number.

Return value

Surface number.

Math::vec3 getContactNormal (int contact)

Returns a normal of the contact point, in world coordinates.

Arguments

  • int contact - Contact number.

Return value

Normal of the contact point.

void setShapeType (int type)

Sets a shape of the physical trigger.

Arguments

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

int getExclusionMask ()

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.

void setExclusionMask (int mask)

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.

void setSize (const Math::vec3 & size)

Sets a size of the physical trigger.

Arguments

  • const Math::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.

Ptr<Object> getContactObject (int contact)

Returns an object participating in the contact with a physical trigger (used for intersecting with physical objects).

Arguments

  • int contact - Contact number.

Return value

Object in contact.

int getShapeType ()

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.

void updateContacts ()

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.

int getNumContacts ()

Returns the total number of contacts with bodies, shapes and colliding surfaces in which a physical trigger participated.

Return value

The number of contacts.

const char * getEnterCallbackName ()

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.

const char * getLeaveCallbackName ()

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