This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
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 Objects
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
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
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.Joint Class

This class is used to simulate various types of joints and define common parameters shared by all joints.

See Also#

  • A C++ API sample located in the <UnigineSDK>/source/samples/Api/Physics/JointCallbacks folder
  • A C# API sample located in the <UnigineSDK>/source/csharp/samples/Api/Physics/JointCallbacks folder
  • A UnigineScript API sample <UnigineSDK>/data/samples/physics/callbacks_03

Joint Class

Enums

TYPE#

Type of the joint defining its properties.
NameDescription
JOINT_FIXED = 0Fixed joint.
JOINT_BALL = 1Ball joint.
JOINT_HINGE = 2Hinge joint.
JOINT_PRISMATIC = 3Prismatic joint.
JOINT_CYLINDRICAL = 4Cylindrical joint.
JOINT_SUSPENSION = 5Suspension joint.
JOINT_WHEEL = 6Wheel joint.
JOINT_PARTICLES = 7Particles joint.
JOINT_PATH = 8Path joint.
NUM_JOINTS = 9

Properties

vec3 WorldAnchor#

The anchor point in the world coordinates.
set
Sets the anchor point in the world coordinates.
set value - Coordinates of the anchor point in the world space.

vec3 Anchor1#

The coordinates of the anchor point in a system of coordinates of the second connected body.
set
Sets coordinates of the anchor point in a system of coordinates of the second connected body.
set value - Coordinates of the anchor point in the body coordinate space.

vec3 Anchor0#

The coordinates of the anchor point in a system of coordinates of the first connected body.
set
Sets coordinates of the anchor point in a system of coordinates of the first connected body.
set value - Coordinates of the anchor point in the body coordinate space.

float AngularSoftness#

The current angular softness (elasticity) of the joint. when the joint is twisted, angular softness defines whether angular velocities of the bodies are averaged out. for example:
  • 0 means that the joint is rigid. Angular velocities of the first and the second body are independent.
  • 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.
set
Sets the angular softness (elasticity) of the joint. When the joint is twisted, angular softness defines whether angular velocities of the bodies are averaged out. For example:
  • 0 means that the joint is rigid. Angular velocities of the first and the second body are independent.
  • 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.
set value - Angular softness. The provided value will be clamped in the range [0;1].

float LinearSoftness#

The current linear softness (elasticity) of the joint. when the joint is stretched, linear softness defines whether linear velocities of the bodies are averaged out. for example:
  • 0 means that the joint is rigid. Velocities of the first and the second body are independent.
  • 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.
set
Sets the linear softness (elasticity) of the joint. When the joint is stretched, linear softness defines whether linear velocities of the bodies are averaged out. For example:
  • 0 means that the joint is rigid. Linear velocities of the first and the second body are independent.
  • 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.
set value - Linear softness. The provided value will be clamped in the range [0;1].

float AngularRestitution#

The current angular restitution (stiffness) of the joint. angular restitution defines how fast the joint compensates for change of the angle between two bodies. when bodies are turned relative each other, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. for example:
  • 1 means that the joint is to return bodies in place throughout 1 physics tick.
  • 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).
set
Sets the current angular restitution (stiffness) of the joint. Angular restitution defines how fast the joint compensates for change of the angle between two bodies. When bodies are turned relative each other, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
  • 1 means that the joint is to return bodies in place throughout 1 physics tick.
  • 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).
set value - Angular restitution. The provided value will be clamped in the range [0;1].

float LinearRestitution#

The current linear restitution (stiffness) of the joint. linear restitution defines how fast the joint compensates for linear coordinate change between two bodies. when bodies are dragged apart, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. for example:
  • 1 means that the joint is to return bodies in place throughout 1 physics tick.
  • 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).
set
Sets the linear restitution (stiffness) of the joint. Linear restitution defines how fast the joint compensates for linear coordinate change between two bodies. When bodies are dragged apart, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
  • 1 means that the joint is to return bodies in place throughout 1 physics tick.
  • 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).
set value - Linear restitution. The provided value will be clamped in the range [0;1].

float MaxTorque#

The maximum amount of torque that can be exerted on the joint. if this limit is exceeded, the joint breaks.
set
Sets the maximum amount of torque that can be exerted on the joint. If this limit is exceeded, the joint breaks.
set value - Maximum amount of torque.

float MaxForce#

The maximum amount of force that can be exerted on the joint. if this limit is exceeded, the joint breaks.
set
Sets the maximum amount of force that can be exerted on the joint. If this limit is exceeded, the joint breaks.
set value - Maximum amount of force.

int NumIterations#

The current number of iterations used to solve joints.
set
Sets the number of iterations used to solve joints. Note that if this value is too low, the precision of calculations will suffer.
set value - Number of iterations. If a non-positive value is provided, 1 will be used instead.

string Name#

The name of the joint.
set
Sets the name of the joint.
set value - Name of the joint.

bool Frozen#

A value indicating if the joint is frozen or not.
set
Freezes or unfreezes the joint.
set value - Positive number to freeze the joint, 0 to unfreeze it.

bool Broken#

A value indicating if the joint is broken or not.
set
Sets a value indicating if the joint is broken or not.
set value - Positive number to break the joint, 0 to make it intact.

int Collision#

A value indicating if collisions between the connected bodies are enabled.
set
Sets a value indicating if collisions between the connected bodies are enabled.
set value - Positive number to enable collisions between the bodies, 0 to disable them.

bool IsEnabledSelf#

A value indicating is the joint is enabled.

bool Enabled#

A value indicating if the joint calculations are enabled.
set
Enables or disables joint calculations.
set value - Positive number to enable the joint, 0 to disable it.

Body Body1#

The second body connected using the joint.
set
Sets the second body connected using the joint.
set value - The second body connected with the joint.

Body Body0#

The first body connected using the joint.
set
Sets the first body connected using the joint.
set value - The first body connected with the joint.

string TypeName#

The name of the joint type.

Joint.TYPE Type#

The type of the joint.

Node Node1#

Returns a node possessing the second body connected to the joint.
set
Sets the node possessing the second body to be connected to the joint.
set value - Node possessing the second body connected to the joint is assigned. The node must be an object and must have a body assigned.

Node Node0#

Returns a node possessing the first body connected to the joint.
set
Sets the node possessing the first body to be connected to the joint.
set value - Node possessing the first body connected to the joint is assigned. The node must be an object and must have a body assigned.

Members


Joint CreateJoint ( int type ) #

Creates a new joint of the specified type.

Arguments

  • int type - Joint type. One of the JOINT_* values.

Return value

New created joint instance.

Joint CreateJoint ( string type_name ) #

Creates a new joint of the specified type.

Arguments

  • string type_name - Joint type name.

Return value

New created joint instance.

void SetNode0 ( Node node0 ) #

Sets the node possessing the first body to be connected to the joint.

Arguments

  • Node node0 - Node possessing the first body connected to the joint is assigned. The node must be an object and must have a body assigned.

Node GetNode0 ( ) #

Returns a node possessing the first body connected to the joint.

Return value

Node possessing the first body connected to the joint is assigned (if it exists).

void SetNode1 ( Node node1 ) #

Sets the node possessing the second body to be connected to the joint.

Arguments

  • Node node1 - Node possessing the second body connected to the joint is assigned. The node must be an object and must have a body assigned.

Node GetNode1 ( ) #

Returns a node possessing the second body connected to the joint.

Return value

Node possessing the second body connected to the joint is assigned (if it exists).

BodyRigid GetBodyRigid0 ( ) #

Returns the first connected body as a rigid body.

Return value

The first rigid body connected using the joint or NULL (0), if the body is not rigid.

BodyRigid GetBodyRigid1 ( ) #

Returns the second connected body as a rigid body.

Return value

The second rigid body connected using the joint or NULL (0), if the body is not rigid.

IntPtr addBrokenCallback ( BrokenDelegate func ) #

Adds a callback function to be called when the joint breaks. The signature of the broken callback function must be as follows:
Source code (C#)
void broken_callback_function_name(Body body);

You can set a callback function as follows:

Source code (C#)
addBrokenCallback(broken_callback_function_name);

Example: Setting a joint broken callback function for a certain class:

Source code (C#)
class SomeClass
{
	// joint for which a broken callback function is to be set
	Unigine.Joint Joint;

	/*...*/

	// callback function
	private void on_broken(Joint joint)
	{
		// insert your code handling joint breaking here
	}

	private void registerCallback()
	{
		// setting the on_broken() function to handle breaking for the joint
		joint.addBrokenCallback(on_broken);
	}
	
	/*...*/
}

Arguments

  • BrokenDelegate func - Callback function with the following signature: void BrokenDelegate(Joint joint)

Return value

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

bool removeBrokenCallback ( IntPtr id ) #

Removes the specified callback from the list of broken callbacks.

Arguments

  • IntPtr id - Broken callback ID obtained when adding it.

Return value

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

void clearBrokenCallbacks ( ) #

Clears all added broken callbacks.

int SetID ( int id ) #

Sets the unique ID for the joint.

Arguments

  • int id - Unique ID.

Return value

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

int GetID ( ) #

Returns the unique ID of the joint.

Return value

Unique ID.

string GetTypeName ( int type ) #

Returns the name of a joint type with a given ID.

Arguments

  • int type - Joint type ID. One of the JOINT_* values.

Return value

Joint type name.

Joint Clone ( ) #

Clones the joint.

Return value

Copy of the joint.

void RenderVisualizer ( vec4 color ) #

Renders the joint.
Notice
You should enable the engine visualizer by the show_visualizer 1 console command.

Arguments

  • vec4 color - Color, in which the joint will be rendered.

bool SaveState ( Stream stream ) #

Saves the state of a given node into a binary stream.
  • If a node is a parent for other nodes, states of these child nodes need to be saved manually.
  • To save the state from a buffer, file or a message from a socket, make sure the stream is opened. For buffers and files, you also need to set the proper position for reading.

Example using saveState() and restoreState() methods:

Source code (C#)
// set the joint state
joint.AngularRestitution = 0.8f;

// save state
Blob blob_state = new Blob();
joint.SaveState(blob_state);

// change the state
joint.AngularRestitution = 0.4f;

// restore state
blob_state.SeekSet(0);        // returning the carriage to the start of the blob
joint.RestoreState(blob_state);

Arguments

  • Stream stream - Stream to save node state data.

Return value

true if the node state is saved successfully; otherwise, false.

bool RestoreState ( Stream stream ) #

Restores the state of a given node from a binary stream.
  • If a node is a parent for other nodes, states of these child nodes need to be restored manually.
  • To save the state into a buffer, file or a message from a socket, make sure the stream is opened. If necessary, you can set a position for writing for buffers and files.

Example using saveState() and restoreState() methods:

Source code (C#)
// set the joint state
joint.AngularRestitution = 0.8f;

// save state
Blob blob_state = new Blob();
joint.SaveState(blob_state);

// change the state
joint.AngularRestitution = 0.4f;

// restore state
blob_state.SeekSet(0);        // returning the carriage to the start of the blob
joint.RestoreState(blob_state);

Arguments

  • Stream stream - Stream with saved node state data.

Return value

true if the node state is restored successfully; otherwise, false.

void Swap ( Joint joint ) #

Swaps the joints saving the pointers.

Arguments

  • Joint joint - A joint to swap.
Last update: 2021-04-29
Build: ()