コード例 #1
0
        /// <summary>
        /// Gets the physics scene held by this plugin.
        /// </summary>
        /// <param name="sceneIdentifier">The name of the scene</param>
        /// <returns>The physics scene</returns>
        public PhysicsScene GetScene(String sceneIdentifier)
        {
            // Check to see if the scene has been created
            if (m_remoteScene == null)
            {
                // Create the remote scene
                m_remoteScene = new RemotePhysicsScene(sceneIdentifier);
            }

            // Return the physics scene held by this plugin
            return(m_remoteScene);
        }
コード例 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parentScene">The scene to which this object
        /// belongs</param>
        /// <param name="localID">The unique identifier of the object</param>
        /// <param name="name">The name of the object</param>
        /// <param name="typeName">The type of the object</param>
        /// <param name="config">The configuration used to initialize this
        /// object</param>
        protected RemotePhysicsObject(RemotePhysicsScene parentScene,
                                      uint localID, String name, String typeName,
                                      RemotePhysicsConfiguration config)
        {
            // Initialize the parent physics scene
            ParentScene = parentScene;

            // Indicate that this object has not been fully initialized
            IsInitialized = false;

            // Initialize the handle to the configuration that will be used
            // initialize other properties
            ParentConfiguration = config;

            // Initialize the local ID of this object
            LocalID = localID;

            // Initialize the name of this physics object
            // Usually this is the same name as the OpenSim object
            Name = name;

            // Initialize the type of this object in string form
            TypeName = typeName;

            // Initialize the gravity modifier to be 1.0, so that the
            // gravity of the scene will be unmodified when it affects
            // this object
            GravModifier = 1.0f;

            // Initialize the gravity vector
            Gravity = new OpenMetaverse.Vector3(0.0f, 0.0f, config.Gravity);

            // Indicate that the object is not hovering
            HoverActive = false;

            // Create the list of pending and sent collisions
            Collisions             = new CollisionEventUpdate();
            CollisionsLastReported = Collisions;

            // Initialize the collision steps to be invalid steps, since no
            // collision has occurred yet
            GroundCollisionStep = RemotePhysicsScene.InvalidStep;
            ObjectCollisionStep = RemotePhysicsScene.InvalidStep;
            LastCollisionStep   = RemotePhysicsScene.InvalidStep;

            // No collisions have occurred, so start the collision count at 0
            NumCollisions = 0;

            // Initialize the object that will ensure the thread safety of the
            // collision step data
            m_collisionStepLock = new Object();
        }
コード例 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="localID">The unique identifier of the avatar</param>
        /// <param name="avatarName">The name of the avatar</param>
        /// <param name="parentScene">The physics scene to which the avatar
        /// belongs</param>
        /// <param name="position">The initial position of the avatar</param>
        /// <param name="velocity">The initial linear velocity of the
        /// avatar</param>
        /// <param name="size">The size of the avatar</param>
        /// <param name="isFlying">Whether the avatar is flying or not</param>
        /// <param name="config">The configuration used to initialize the
        /// avatar</param>
        public RemotePhysicsAvatar(uint localID, String avatarName,
                                   RemotePhysicsScene parentScene, OpenMetaverse.Vector3 position,
                                   OpenMetaverse.Vector3 velocity, OpenMetaverse.Vector3 size,
                                   bool isFlying, RemotePhysicsConfiguration config)
            : base(parentScene, localID, avatarName,
                   "RemotePhysicsCharacter", config)
        {
            OpenMetaverse.Quaternion localPoseQuat;

            // Initialize the unique ID of this avatar
            m_actorID = localID;

            // Indicate that this object is an avatar
            m_actorType = (int)ActorTypes.Agent;

            // Initialize the position to what's given
            Position = position;

            // Initialize the orientation to the default value
            Orientation = OpenMetaverse.Quaternion.Identity;

            // Initialize the velocity based on what's given
            m_velocity = velocity;

            // Initialize the friction values based on the parent scene's
            // friction coefficient for avatars
            Friction          = ParentConfiguration.AvatarKineticFriction;
            m_kineticFriction = ParentConfiguration.AvatarKineticFriction;
            m_staticFriction  = ParentConfiguration.AvatarStaticFriction;

            // Initialize the density based on the parent scene's density
            // value for avatars
            Density = ParentConfiguration.AvatarDensity;

            // Initialize the size of this avatar using the given size
            m_size = size;

            // Check to see if any of the dimensions are zero
            // If they are, use the default sizes
            if (m_size.X == 0.0f)
            {
                m_size.X = ParentConfiguration.AvatarShapeDepth;
            }
            if (m_size.Y == 0.0f)
            {
                m_size.Y = ParentConfiguration.AvatarShapeWidth;
            }
            if (m_size.Z == 0.0f)
            {
                m_size.Z = ParentConfiguration.AvatarShapeHeight;
            }

            // Compute the mass of the avatar, so that it can be referenced
            // for later computations
            ComputeAvatarMass();

            // Send out a message to the remote physics engine to create an
            // actor
            ParentScene.RemoteMessenger.CreateDynamicActor(m_actorID, Position,
                                                           Orientation, 1.0f, m_velocity,
                                                           new OpenMetaverse.Vector3(0.0f, 0.0f, 0.0f), true);

            // Fetch a unique identifier for this avatar's shape
            m_avatarShapeID = ParentScene.GetNewShapeID();

            // Build the avatar's shape in the remote physics engine
            BuildAvatarShape();

            // Add a constraint between the new actor and ground plane such
            // that the actor doesn't fall over on its side due to gravity
            // Use an unused actor ID to denote that this joint is between the
            // avatar and the world frame
            m_fallJointID = ParentScene.GetNewJointID();
            ParentScene.RemoteMessenger.AddJoint(m_fallJointID, m_actorID,
                                                 OpenMetaverse.Vector3.Zero, OpenMetaverse.Quaternion.Identity,
                                                 ParentScene.GetNewActorID(), OpenMetaverse.Vector3.Zero,
                                                 OpenMetaverse.Quaternion.Identity,
                                                 new OpenMetaverse.Vector3(1.0f, 1.0f, 1.0f),
                                                 new OpenMetaverse.Vector3(0.0f, 0.0f, 0.0f),
                                                 new OpenMetaverse.Vector3(0.0f, 0.0f, 0.0f),
                                                 new OpenMetaverse.Vector3(0.0f, 0.0f, 0.0f));

            // Indicate that this object is now initialized
            IsInitialized = true;
        }