Exemplo n.º 1
0
        /// <summary>
        /// Set the terrain for the physics scene.
        /// </summary>
        /// <param name="heightMap">The height values for the height map.
        /// Should contain enough elements to fill the region size</param>
        public override void SetTerrain(float[] heightMap)
        {
            OpenMetaverse.Quaternion hfOrienation;

            if (m_terrainBuilt)
            {
                // Detach old terrain shape and remove it, so that
                // only the new terrain will be attached to the terrain actor
                RemoteMessenger.DetachShape(m_terrainID, m_terrainShapeID);
                RemoteMessenger.RemoveShape(m_terrainShapeID);
            }
            else
            {
                // Send a message that creates an actor for the height map
                RemoteMessenger.CreateStaticActor(m_terrainID,
                                                  OpenMetaverse.Vector3.Zero,
                                                  OpenMetaverse.Quaternion.Identity, false);
            }

            // Create the shape for the height map
            hfOrienation = OpenMetaverse.Quaternion.CreateFromEulers(
                (float)Math.PI / 2.0f, (float)Math.PI / 2.0f, 0.0f);
            RemoteMessenger.AddHeightField(m_terrainShapeID,
                                           (uint)m_regionExtents.X, (uint)m_regionExtents.Y, 1.0f, 1.0f,
                                           heightMap);

            // Attach the height map shape to the actor
            RemoteMessenger.AttachShape(m_terrainID, m_terrainShapeID,
                                        RemoteConfiguration.DefaultDensity,
                                        RemoteConfiguration.DefaultFriction,
                                        RemoteConfiguration.DefaultFriction,
                                        RemoteConfiguration.DefaultRestitution, hfOrienation,
                                        OpenMetaverse.Vector3.Zero);

            // Indicate that the terrain has been built in the remote
            // physics engine
            m_terrainBuilt = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cleans up resources used by this scene.
        /// </summary>
        public override void Dispose()
        {
            // Indicate that the scene is no longer initialized, so that no
            // simulation happens while disposing is occurring
            m_initialized = false;

            // Check to see if a terrain has been set for this scene in the
            // remote physics engine
            if (m_terrainBuilt)
            {
                // Detach the old terrain shape and remove it, so that
                // only the new terrain will be attached to the terrain actor
                RemoteMessenger.DetachShape(m_terrainID, m_terrainShapeID);
                RemoteMessenger.RemoveShape(m_terrainShapeID);
            }

            // Log out of the remote physics engine
            RemoteMessenger.Logoff(RemoteConfiguration.SimulationID);

            // Clean up the remote messenger
            m_remoteMessenger.Dispose();
            m_remotePacketManager.Dispose();
        }