/// <summary> /// This function will add a user's avatar to the physics plugin. /// </summary> /// <param name="localID">The unique ID used by OpenSim to track the /// physical objects inside of the world</param> /// <param name="avName">Given name of the avatar</param> /// <param name="position">The current position of the new user avatar /// inside of the scene</param> /// <param name="velocity">The current velocity of the new user avatar /// inside of the scene</param> /// <param name="size">The size of the new user avatar, that will be /// used to scale the physical object</param> /// <param name="isFlying">A flag that determines if the user's /// physical object avatar is currently flying</param> /// <returns>The physical object that was added to the physics engine /// that will represent the user's avatar</returns> public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) { // Can't add avatar if the scene hasn't been initialized yet if (!m_isInitialized) { return(null); } // Create a physical object to represent the user avatar PxPhysObject actor = new PxPhysObject( localID, avName, this, position, velocity, size, isFlying); // Add the new actor to the dictionary of all physical objects; // lock dictionary to ensure no changes are made during addition lock (m_physObjectsDict) { m_physObjectsDict.Add(localID, actor); } // Add the new avatar to the avatar dictionary to make sure that // OpenSim updates the animations for the avatars, specific to the // avatar sending the collision event lock (m_avatarsSet) { m_avatarsSet.Add(actor); } // Give OpenSim a handle to the physical object of the user's // physical object return(actor); }
/// <summary> /// Add a new prim object to the scene. /// </summary> /// <param name="primName">Given name of the prim object</param> /// <param name="pbs">Basic prim shape info used for /// determining the object's mass and geometry</param> /// <param name="position">Current position of the new prim inside /// the scene</param> /// <param name="size">Size of the new avatar, that will be used /// to scale the physical object</param> /// <param name="rotation">Current rotation of the new prim /// inside the scene</param> /// <param name="isPhysical">Whether the prim should react /// to forces and collisions</param> /// <param name="localid">The unique ID used to track the object /// inside of the world</param> public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid) { // Can't add prim if the scene hasn't been initialized yet if (!m_isInitialized) { m_log.ErrorFormat("{0}: Unable to create prim shape because " + "PxScene has not been initialized.", LogHeader); return(null); } // Create a physical object to represent the primitive object PxPhysObject prim = new PxPhysObject(localid, primName, this, position, size, rotation, pbs, isPhysical); // Lock dictionary to ensure no changes are made during addition lock (m_physObjectsDict) { // Add the new prim to the dictionary of all physical objects m_physObjectsDict.Add(localid, prim); } // Give OpenSim a handle to the physical object of the prim return(prim); }
/// <summary> /// Constructor of the PxActor. /// </summary> /// <param name="physicsScene"> The physics scene that this actor /// will act within. </param> /// <param name="physicsObject"> The physics object that this actor /// will act upon. </param> /// <param name="actorName"> The physics actor name to identify /// the intent. <param> public PxActor(PxScene physicsScene, PxPhysObject physicsObject, string actorName) { PhysicsScene = physicsScene; PhysicsObject = physicsObject; ActorName = actorName; Enabled = true; }
/// <summary> /// Adds a tainted object to the list of tainted objects. These objects /// will be re-built before the next simulation step. /// </summary> /// <param name="obj">The tainted physics object that needs to be /// re-built</param> public void AddTaintedObject(PxPhysObject obj) { // Attempt to add this object to the list of tainted objects in // a thread-safe manner. If the object already exists within // the list, this operation is ignored lock (m_taintedObjects) { m_taintedObjects.GetOrAdd(obj.LocalID, obj); } }
/// <summary> /// Constructor for the buoyancy actor, includes the physics scene, /// the physics object, and the name of this physics actor. /// </summary> /// <param name="physicsScene"> The physics scene that this actor will /// act within. </param> /// <param name="physicsObject"> The physics object that this actor will /// act upon. </param> /// <param name="actorName"> The physics actor name to identify /// the intent. <param> public PxActorBuoyancy(PxScene physicsScene, PxPhysObject physObject, string actorName) : base(physicsScene, physObject, actorName) { m_buoyancyMotor = null; }