All access to Nvidia PhysX is made through this abstraction layer.

The abstraction layer hides Nvidia PhysX references and most data types by using numeric identifiers for actors and joints and sticking to osg matrices and vectors.

All games inherit from PhysxScene through TeetairApplication, therefore they automatically have access to the following methods.


Scene and materials

createScene(const osg::Vec3& gravity)
Summary:
Creates the scene.
Params:
gravity: The gravity vector.
Returns:
true if the scene was created, false if the scene could not be created.
createMaterial(const string name, const PxReal staticFriction, const PxReal dynamicFriction, const PxReal restitution)
Summary:
Creates a material.
Params:
name: The name.
staticFriction: The static friction.
dynamicFriction: The dynamic friction.
restitution: The restitution.
Returns:
true if the material was created, false if the material could not be created or if the name was already taken.

Actors and shapes

ENUM ForceResponsiveness
Summary:
The behaviour of an actor concerning forces.
ALL
Summary:
All forces apply to the actor
NO_GRAVITY
Summary:
The actor won't notice gravity
KINEMATIC
Summary:
The actor is kinematic and does not respond to forces at all
createPlane(int id, const string materialName, const osg::Vec3 center, const osg::Vec3 normal, const PxU32 filterGroup = 0, const PxU32 filterMask = 0)
Summary:
Creates a plane.
Params:
id: The identifier.
materialName: Name of the material.
center: The center point.
normal: The normal vector.
filterGroup: The filter group.
filterMask: The filter mask.
Returns:
true if the plane was created, false if the actor could not be created or the id is already taken.
createBox(int id, const osg::Vec3& dim, double density, const string materialName, const ForceResponsiveness forceResponsiveness = ALL, const PxU32 filterGroup = 0, const PxU32 filterMask = 0)
Summary:
Creates a box.
Params:
id: The identifier.
dim: The dimension of the box (width, length, height).
density: The density.
materialName: Name of the material.
forceResponsiveness: The force responsiveness.
filterGroup: The filter group.
filterMask: The filter mask.
Returns:
true if the box was created, false if the actor could not be created or the id is already taken.
createSphere(int id, double radius, double density, const string materialName, const ForceResponsiveness forceResponsiveness = ALL, const PxU32 filterGroup = 0, const PxU32 filterMask = 0)
Summary:
Creates a sphere.
Params:
id: The identifier.
radius: The radius.
density: The density.
materialName: Name of the material.
forceResponsiveness: The force responsiveness.
filterGroup: The filter group.
filterMask: The filter mask.
Returns:
true if the sphere was created, false if the actor could not be created or the id is already taken.
createConvexBox(int id, const osg::Vec3Array& vertices, double density, const string materialName, const ForceResponsiveness forceResponsiveness, const PxU32 filterGroup = 0, const PxU32 filterMask = 0)
Summary:
Creates a convex box.
Params:
id: The identifier.
vertices: The vertices of the convex object.
density: The density.
materialName: Name of the material.
forceResponsiveness: The force responsiveness.
filterGroup: The filter group.
filterMask: The filter mask.
Returns:
true if the convex box was created, false if the actor could not be created or the id is already taken.
createCompound(int id, const ForceResponsiveness forceResponsiveness)
Summary:
Creates a compound actor, consisting of several shapes.
Params:
id: The identifier.
forceResponsiveness: The force responsiveness.
Returns:
true if the compound was created, false if the actor could not be created or the id is already taken.
addBoxToCompound(int id, const osg::Vec3& dim, const string materialName, const osg::Matrix& localPose, const PxU32 filterGroup = 0, const PxU32 filterMask = 0, const bool triggerShape = false)
Summary:
Adds a box to a previously created compound.
Params:
id: The identifier.
dim: The dim.
materialName: Name of the material.
localPose: The local pose.
filterGroup: The filter group.
filterMask: The filter mask.
triggerShape: if set to true, the shape will not play a role in the simulation, but only produce trigger events.
Returns:
true if the box was added to the compound, false if the compound does not exist or the box could not be added.
addConvexBoxToCompound(int id, const osg::Vec3Array& vertices, const string materialName, const PxU32 filterGroup = 0, const PxU32 filterMask = 0, const bool triggerShape = false)
Summary:
Adds a convex box to a previously created compound.
Params:
id: The identifier.
vertices: The vertices of the convex object.
materialName: Name of the material.
filterGroup: The filter group.
filterMask: The filter mask.
triggerShape: if set to true, the shape will not play a role in the simulation, but only produce trigger events.
Returns:
true if the box was added to the compound, false if the compound does not exist or the box could not be added.
finishCompound(int id, const double density = 1)
Summary:
Finishes the compound and adds the actor to the scene.
Params:
id: The identifier.
density: The density.
Returns:
true if the compound was finished, false if the compound does not exist or the actor could not be added to the scene

Joints

getNextJointId()
Summary:
Gets the next joint identifier.
Returns:
the identifier to use for the next joint creation.
createSphericalJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a spherical joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
setSphericalJointLimit(int id, PxReal yLimitAngle, PxReal zLimitAngle, PxReal limitContactDistance)
Summary:
Sets the spherical joint limit.
Params:
id: The identifier.
yLimitAngle: The y limit angle.
zLimitAngle: The z limit angle.
limitContactDistance: The limit contact distance.
Returns:
true if the limit was set, false if the joint does not exist or is not a spherical joint.
createDistanceJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a distance joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
setDistanceJointLimit(int id, PxReal minDistance, PxReal maxDistance, PxReal tolerance, PxReal stiffness)
Summary:
Sets the distance joint limits.
Params:
id: The identifier.
minDistance: The minimum distance.
maxDistance: The maximum distance.
tolerance: The tolerance of the joint.
stiffness: The stiffness of the joint.
Returns:
true if the limits were set, false if the joint does not exist or is not a distance joint.
createFixedJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a fixed joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
createRevoluteJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a revolute joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
setRevoluteJointLimit(int id, PxReal lowerAngle, PxReal upperAngle, PxReal contactDistance)
Summary:
Sets the revolute joint limits.
Params:
id: The identifier.
lowerAngle: The lower angle.
upperAngle: The upper angle.
contactDistance: The contact distance limit.
Returns:
true if the limits were set, false if the joint does not exist or is not a revolute joint.
createPrismaticJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a prismatic joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
setPrismaticJointLimit(int id, PxReal minDistance, PxReal maxDistance, PxReal contactDistance)
Summary:
Sets the prismatic joint limits.
Params:
id: The identifier.
lowerAngle: The lower angle.
upperAngle: The upper angle.
contactDistance: The contact distance limit.
Returns:
true if the limits were set, false if the joint does not exist or is not a revolute joint.
createD6Joint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
Summary:
Creates a D6 joint.
Params:
jointId: The joint identifier.
actorId0: The first actor's id or an invalid id to joint to the world.
localPose0: The local pose of the first actor.
actorId1: The second actor's id or an invalid id to joint to the world.
localPose1: The local pose of the second actor.
Returns:
true if the joint was created, false if the two actors are the same.
setD6Motion(int id, PxD6Axis::Enum axis, PxD6Motion::Enum type, PxReal extent = 0, PxReal contactDistance = 0)
Summary:
Sets a D6 joint axis motion.
Params:
id: The joint identifier.
axis: The axis.
type: The motion type (locked/free/limited).
extent: The extent value if motion is limited.
contactDistance: The contact distance limit is limited.
Returns:
true if the limits were set, false if the joint does not exist or is not a d6 joint.
setD6Drive(int id, PxD6Drive::Enum axis, PxReal driveSpring, PxReal driveDamping, PxReal forceLimit, bool isAcceleration = false)
Summary:
Sets the d6 drive for an axis.
Params:
id: The joint identifier.
axis: The axis.
driveSpring: The drive's spring.
driveDamping: The drive's damping.
forceLimit: The spring's force limit.
isAcceleration: if set to true the spring will apply to acceleration instead of force.
Returns:
true if the drive was set, false if the joint does not exist or is not a d6 joint.
d6Drive(int id, PxD6Drive::Enum axis, PxReal driveSpring, PxReal driveDamping, PxReal forceLimit, bool isAcceleration = false)
Summary:
Drive a D6 joint.
Params:
id: The joint identifier.
targetPose: The target pose.
linearVelocity: The linear velocity.
angularVelocity: The angular velocity.
Returns:
true if the parameters were set, false if the joint does not exist or is not a d6 joint.
releaseJoint(int id)
Summary:
Releases the joint.
Params:
id: The identifier.

Poses and forces

getMatrix(int id)
Summary:
Gets the matrix of the actor.
Params:
id: The actor's identifier.
Returns:
The current pose matrix of the actor or an empty matrix if the actor does not exist.
setMatrix(int id, const osg::Matrix& matrix)
Summary:
Sets the current pose of the actor to the matrix.
Params:
id: The actor's identifier.
matrix: The pose matrix.
addForce(int id, const osg::Vec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true)
Summary:
Adds the force to the actor.
Params:
id: The actor's identifier.
force: The force.
mode: The force mode.
autowake: if set to true, wake the actor if he's sleeping.
clearForce(int id, PxForceMode::Enum mode = PxForceMode::eFORCE)
Summary:
Clears the forces staged for the actor.
Params:
id: The actor's identifier.
mode: The force mode to clear.
addTorque(int id, const osg::Vec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true)
Summary:
Adds the torque to the actor.
Params:
id: The actor's identifier.
torque: The torque vector (axis, length is amount).
mode: The force mode.
autowake: if set to true, wake the actor if he's sleeping.
setAngularDamping(int id, const PxReal angularDamping)
Summary:
Sets the angular damping of the actor.
Params:
id: The actor's identifier.
angularDamping: The angular damping.
Returns:
true if the damping was set, false if the actor does not exist or is not dynamic
setLinearDamping(int id, const PxReal linearDamping)
Summary:
Sets the linear damping of the actor.
Params:
id: The actor's identifier.
linearDamping: The linear damping.
Returns:
true if the damping was set, false if the actor does not exist or is not dynamic
setLinearVelocity(int id, const osg::Vec3& linVel, bool autowake = true)
Summary:
Sets the linear velocity of the actor.
Params:
id: The actor's identifier.
linVel: The linear velocity.
autowake: if set to true, wake the actor if he's sleeping.
getLinearVelocity(int id)
Summary:
Gets the linear velocity of the actor.
Params:
id: The actor's identifier.
Returns:
The linear velocity of the actor or an empty vector if the actor does not exist or is not dynamic.
setAngularVelocity(int id, const osg::Vec3& angVel, bool autowake = true)
Summary:
Sets the angular velocity of the actor.
Params:
id: The actor's identifier.
angVel: The angular velocity.
autowake: if set to true, wake the actor if he's sleeping.
getAngularVelocity(int id)
Summary:
Gets the angular velocity of the actor.
Params:
id: The actor's identifier.
Returns:
The angular velocity of the actor or an empty vector if the actor does not exist or is not dynamic.
setMaxAngularVelocity(int id, PxReal maxVelocity)
Summary:
Sets the maximum angular velocity of an actor.
Params:
id: The identifier of the actor.
maxVelocity: The maximum angular velocity.
Returns:
true if the maximum was set, false if the actor does not exist or is not a dynmaic actor.

Simulation parameters

setSimulateCollisions(int id, bool simulate)
Summary:
(De-)activates collision tests for the actor. The parameter will be set on all shapes of the actor except for trigger shapes.
Params:
id: The actor's identifier.
simulate: if set to true the actor will be considered during collision tests.
setSleepThreshold(int id, PxReal threshold)
Summary:
Sets the sleep threshold.
Params:
id: The actor's identifier.
threshold: The sleep threshold.
setForceResponsiveness(int id, ForceResponsiveness forceResponsiveness)
Summary:
Sets the force responsiveness.
Params:
id: The actor's identifier.
forceResponsiveness: The force responsiveness.
setEnableCCD(int id, bool enable)
Summary:
Sets if continuous collision detection is activated for the actor.
Params:
id: The actor's identifier.
enable: if set to true. the actor won't go through other objects at high velocities.
setSendSleepNotifies(int id, bool enable)
Summary:
Sets whether onSleep notification is active for the actor.
Params:
id: The actor's identifier.
enable: if set to true. the actor will notify the onSleep function when it sleeps.

Simulation and contact processing

simulate(double step)
Summary:
Simulates the scene for the specified step count.
Params:
step: The elapsed time to simulate.
areActors(int actorId0, int actorId1, PxRigidActor* const contactActors[2])
Summary:
Checks if the two collided actors correspond to the two given actor ids.
Params:
actorId0: The first actor's id.
actorId1: The second actor's id.
contactActors: The contact actors.
Returns:
true if the actors with the given ids match the collided actors
containsActor(int actorId, PxRigidActor* const contactActors[2])
Summary:
Checks if one of the two collided actors correspond to the given actor id.
Params:
actorId: The actor's id.
contactActors: The contact actors.
Returns:
true if the actor with the given id matchs one of the collided actors
isActor(int actorId, PxRigidActor* const actor)
Summary:
Checks if the the actor corresponds to the given actor id.
Params:
actorId: The actor's id.
actor: The actor.
Returns:
true if the given id matches the actor.
areFilterGroups(int filterGroup1, int filterGroup2, PxShape* const contactShapes[2])
Summary:
Checks if the two filter groups correspond to the contactShapes.
Params:
filterGroup1: The first filterGroup.
filterGroup2: The second filterGroup.
contactShapes: The contact shapes.
Returns:
true if the contact shapes match the given filterGroups.
containsFilterGroup(int filterGroup, PxShape* const contactShapes[2])
Summary:
Checks if the one of the contactShapes corresponds to the filterGroup.
Params:
filterGroup: The filterGroup.
contactShapes: The contact shapes.
Returns:
true if one of the contact shapes matchs the given filterGroup.

Destruction

clearPhysxScene()
Summary:
Clears the physx scene. Releases and deletes all actors, joints and materials. Deletes the unprocessed deferredSceneChanges.