Пример #1
0
        // TODO: redo terrain implementation selection to allow other base types than heightMap.
        private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
        {
            PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}",
                                            LogHeader, PhysicsScene.RegionName, terrainRegionBase,
                                            (BSTerrainPhys.TerrainImplementation)BSParam.TerrainImplementation);
            BSTerrainPhys newTerrainPhys = null;

            switch ((int)BSParam.TerrainImplementation)
            {
            case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
                newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
                                                        heightMap, minCoords, maxCoords);
                break;

            case (int)BSTerrainPhys.TerrainImplementation.Mesh:
                newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
                                                   heightMap, minCoords, maxCoords);
                break;

            default:
                PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}",
                                                LogHeader,
                                                (int)BSParam.TerrainImplementation,
                                                BSParam.TerrainImplementation,
                                                PhysicsScene.RegionName, terrainRegionBase);
                break;
            }
            return(newTerrainPhys);
        }
Пример #2
0
        // Create the initial instance of terrain and the underlying ground plane.
        // This is called from the initialization routine so we presume it is
        //    safe to call Bullet in real time. We hope no one is moving prims around yet.
        public void CreateInitialGroundPlaneAndTerrain()
        {
            // The ground plane is here to catch things that are trying to drop to negative infinity
            BulletShape groundPlaneShape = new BulletShape(
                BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f,
                                                     BSParam.TerrainCollisionMargin),
                BSPhysicsShapeType.SHAPE_GROUNDPLANE);

            m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
                                           BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID,
                                                                                          Vector3.Zero, Quaternion.Identity));
            BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr, Vector3.Zero, Quaternion.Identity);
            BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr);
            // Ground plane does not move
            BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION);
            // Everything collides with the ground plane.
            m_groundPlane.collisionType = CollisionType.Groundplane;
            m_groundPlane.ApplyCollisionMask();

            // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
            BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);

            m_terrains.Add(Vector3.Zero, initialTerrain);
        }
Пример #3
0
 // TODO: redo terrain implementation selection to allow other base types than heightMap.
 private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
 {
     PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}", 
                                         LogHeader, PhysicsScene.RegionName, terrainRegionBase, 
                                         (BSTerrainPhys.TerrainImplementation)BSParam.TerrainImplementation);
     BSTerrainPhys newTerrainPhys = null;
     switch ((int)BSParam.TerrainImplementation)
     {
         case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
             newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
                                         heightMap, minCoords, maxCoords);
             break;
         case (int)BSTerrainPhys.TerrainImplementation.Mesh:
             newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
                                         heightMap, minCoords, maxCoords);
             break;
         default:
             PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}",
                                         LogHeader, 
                                         (int)BSParam.TerrainImplementation, 
                                         BSParam.TerrainImplementation,
                                         PhysicsScene.RegionName, terrainRegionBase);
             break;
     }
     return newTerrainPhys;
 }
Пример #4
0
    // Create the initial instance of terrain and the underlying ground plane.
    // This is called from the initialization routine so we presume it is
    //    safe to call Bullet in real time. We hope no one is moving prims around yet.
    public void CreateInitialGroundPlaneAndTerrain()
    {
        // The ground plane is here to catch things that are trying to drop to negative infinity
        BulletShape groundPlaneShape = new BulletShape(
                    BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, 
                                    BSParam.TerrainCollisionMargin),
                    BSPhysicsShapeType.SHAPE_GROUNDPLANE);
        m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
                        BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID,
                                                            Vector3.Zero, Quaternion.Identity));
        BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr, Vector3.Zero, Quaternion.Identity);
        BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr);
        // Ground plane does not move
        BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION);
        // Everything collides with the ground plane.
        m_groundPlane.collisionType = CollisionType.Groundplane;
        m_groundPlane.ApplyCollisionMask();

        // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
        BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);
        m_terrains.Add(Vector3.Zero, initialTerrain);
    }