This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine 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
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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.

Unigine::PhysicalTrigger Class

Header: #include <UniginePhysicals.h>
Inherits from: Physical
Read More

PhysicalTrigger Class

Members


static PhysicalTriggerPtr create ( Shape::TYPE type, const Math::vec3 & size ) #

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

Arguments

  • Shape::TYPE 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

Ptr<Body> getBody ( int num ) #

Returns the specified body that intersects the physical trigger.

Arguments

  • int num - Body number.

Return value

Intersected body.

void setCollisionMask ( int mask ) #

Sets the collision bit mask for the trigger:
  • 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.

Arguments

  • int mask - Integer, each bit of which is a mask.

int getCollisionMask ( ) #

Sets the collision bit mask for the trigger:
  • 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.

Return value

Integer, each bit of which is a mask.

float getContactDepth ( int contact ) #

Returns penetration depth by the given contact.

Arguments

  • int contact - Contact number.

Return value

Penetration depth.

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.

Ptr<Object> getContactObject ( int contact ) #

Returns an object participating in the contact with a physical trigger .

Arguments

  • int contact - Contact number.

Return value

Object in contact.

Math::Vec3 getContactPoint ( int contact ) #

Returns world coordinates of the contact point.

Arguments

  • int contact - Contact number.

Return value

Contact point.

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 .

Arguments

  • int contact - Contact number.

Return value

Surface number.

void * addEnterCallback ( Unigine::CallbackBase1< Ptr<Body> > * func ) #

Adds a callback function to be fired when a body enters the physical trigger. The callback function must receive a Body as its first argument. In addition, it can also take 2 arguments of any type.

Source code (C++)
// implement the enter callback
void AppWorldLogic::enter_callback(BodyPtr body){
	Log::message("\nA body named %s has entered the trigger\n", body->getName());
}

PhysicalTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a box-type physical trigger
	trigger = PhysicalTrigger::create(3, Math::vec3(3.0f));
	
	// add the enter callback to be fired when a body enters the physical trigger
	trigger->addEnterCallback(MakeCallback(this, &AppWorldLogic::enter_callback));
	
	return 1;
}

Arguments

Return value

ID of the last added enter callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeEnterCallback ( void * id ) #

Removes the specified callback from the list of enter callbacks.

Arguments

  • void * id - Enter callback ID obtained when adding it.

Return value

True if the enter callback with the given ID was removed successfully; otherwise false.

void clearEnterCallbacks ( ) #

Clears all added enter callbacks.

void setEnterCallbackName ( const char * name ) #

Sets a 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.

Arguments

  • const char * name - Name of the callback function.

const char * getEnterCallbackName ( ) #

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

Return value

Name of the callback function.

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 - Integer, each bit of which is a mask.

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

Integer, each bit of which is a mask.

void * addLeaveCallback ( Unigine::CallbackBase1< Ptr<Body> > * func ) #

Adds a callback function to be fired when a body leaves the physical trigger. The callback function must receive a Body as its first argument. In addition, it can also take 2 arguments of any type.

Source code (C++)
// implement the leave callback
void AppWorldLogic::leave_callback(BodyPtr body){
	Log::message("\nA body named %s has left the trigger\n", body->getName());
}

PhysicalTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a box-type physical trigger
	trigger = PhysicalTrigger::create(3, Math::vec3(3.0f));
	
	// add the leave callback to be fired when a body leaves the physical trigger
	trigger->addLeaveCallback(MakeCallback(this, &AppWorldLogic::leave_callback));
	
	return 1;
}

Arguments

Return value

ID of the last added leave callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeLeaveCallback ( void * id ) #

Removes the specified callback from the list of leave callbacks.

Arguments

  • void * id - Leave callback ID obtained when adding it.

Return value

True if the leave callback with the given ID was removed successfully; otherwise false.

void clearLeaveCallbacks ( ) #

Clears all added leave callbacks.

void setLeaveCallbackName ( const char * name ) #

Sets the name of a 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.

Arguments

  • const char * name - Name of the callback function.

const char * getLeaveCallbackName ( ) #

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

Return value

Name of the callback function.

int getNumBodies ( ) #

Returns the total number of bodies intersecting with the physical trigger.

Return value

Number of bodies.

int getNumContacts ( ) #

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

Return value

Number of contacts.

void setShapeType ( int type ) #

Sets the shape type of the physical trigger.

Arguments

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

int getShapeType ( ) #

Returns the shape type of the physical trigger.

Return value

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

void setSize ( const Math::vec3 & size ) #

Sets the size of the physical trigger.

Arguments

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

Math::vec3 getSize ( ) #

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

Return value

Size of the physical trigger.

static int type ( ) #

Returns the type of the node.

Return value

Physical trigger type identifier.

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.
Last update: 2022-04-20
Build: ()