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.
createScene(const osg::Vec3& gravity)
gravity
: The gravity vector. 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)
name
: The name. staticFriction
: The static friction. dynamicFriction
: The dynamic friction. restitution
: The restitution. true
if the material was created, false
if the material could not be created or if the name was already taken. ENUM ForceResponsiveness
ALL
NO_GRAVITY
KINEMATIC
createPlane(int id, const string materialName, const osg::Vec3 center, const osg::Vec3 normal, const PxU32 filterGroup = 0, const PxU32 filterMask = 0)
id
: The identifier. materialName
: Name of the material. center
: The center point. normal
: The normal vector. filterGroup
: The filter group. filterMask
: The filter mask. 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)
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. 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)
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. 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)
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. 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)
id
: The identifier. forceResponsiveness
: The force responsiveness. 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)
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. 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)
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. 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)
id
: The identifier. density
: The density. true
if the compound was finished, false
if the compound does not exist or the actor could not be added to the scene getNextJointId()
createSphericalJoint(int jointId, int actorId0, const osg::Matrix& localPose0, int actorId1, const osg::Matrix& localPose1)
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. true
if the joint was created, false
if the two actors are the same. setSphericalJointLimit(int id, PxReal yLimitAngle, PxReal zLimitAngle, PxReal limitContactDistance)
id
: The identifier. yLimitAngle
: The y limit angle. zLimitAngle
: The z limit angle. limitContactDistance
: The limit contact distance. 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)
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. 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)
id
: The identifier. minDistance
: The minimum distance. maxDistance
: The maximum distance. tolerance
: The tolerance of the joint. stiffness
: The stiffness of the joint. 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)
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. 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)
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. true
if the joint was created, false
if the two actors are the same. setRevoluteJointLimit(int id, PxReal lowerAngle, PxReal upperAngle, PxReal contactDistance)
id
: The identifier. lowerAngle
: The lower angle. upperAngle
: The upper angle. contactDistance
: The contact distance limit. 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)
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. true
if the joint was created, false
if the two actors are the same. setPrismaticJointLimit(int id, PxReal minDistance, PxReal maxDistance, PxReal contactDistance)
id
: The identifier. lowerAngle
: The lower angle. upperAngle
: The upper angle. contactDistance
: The contact distance limit. 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)
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. 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)
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. 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)
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. 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)
id
: The joint identifier. targetPose
: The target pose. linearVelocity
: The linear velocity. angularVelocity
: The angular velocity. true
if the parameters were set, false
if the joint does not exist or is not a d6 joint. releaseJoint(int id)
id
: The identifier. getMatrix(int id)
id
: The actor's identifier. setMatrix(int id, const osg::Matrix& matrix)
id
: The actor's identifier. matrix
: The pose matrix. addForce(int id, const osg::Vec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true)
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)
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)
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)
id
: The actor's identifier. angularDamping
: The angular damping. true
if the damping was set, false
if the actor does not exist or is not dynamic setLinearDamping(int id, const PxReal linearDamping)
id
: The actor's identifier. linearDamping
: The linear damping. 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)
id
: The actor's identifier. linVel
: The linear velocity. autowake
: if set to true
, wake the actor if he's sleeping. getLinearVelocity(int id)
id
: The actor's identifier. setAngularVelocity(int id, const osg::Vec3& angVel, bool autowake = true)
id
: The actor's identifier. angVel
: The angular velocity. autowake
: if set to true
, wake the actor if he's sleeping. getAngularVelocity(int id)
id
: The actor's identifier. setMaxAngularVelocity(int id, PxReal maxVelocity)
id
: The identifier of the actor. maxVelocity
: The maximum angular velocity. true
if the maximum was set, false
if the actor does not exist or is not a dynmaic actor. setSimulateCollisions(int id, bool simulate)
id
: The actor's identifier. simulate
: if set to true
the actor will be considered during collision tests. setSleepThreshold(int id, PxReal threshold)
id
: The actor's identifier. threshold
: The sleep threshold. setForceResponsiveness(int id, ForceResponsiveness forceResponsiveness)
id
: The actor's identifier. forceResponsiveness
: The force responsiveness. setEnableCCD(int id, bool enable)
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)
id
: The actor's identifier. enable
: if set to true
. the actor will notify the onSleep function when it sleeps. simulate(double step)
step
: The elapsed time to simulate. areActors(int actorId0, int actorId1, PxRigidActor* const contactActors[2])
actorId0
: The first actor's id. actorId1
: The second actor's id. contactActors
: The contact actors. true
if the actors with the given ids match the collided actors containsActor(int actorId, PxRigidActor* const contactActors[2])
actorId
: The actor's id. contactActors
: The contact actors. true
if the actor with the given id matchs one of the collided actors isActor(int actorId, PxRigidActor* const actor)
actorId
: The actor's id. actor
: The actor. true
if the given id matches the actor. areFilterGroups(int filterGroup1, int filterGroup2, PxShape* const contactShapes[2])
filterGroup1
: The first filterGroup. filterGroup2
: The second filterGroup. contactShapes
: The contact shapes. true
if the contact shapes match the given filterGroups. containsFilterGroup(int filterGroup, PxShape* const contactShapes[2])
filterGroup
: The filterGroup. contactShapes
: The contact shapes. true
if one of the contact shapes matchs the given filterGroup. clearPhysxScene()