Esempio n. 1
0
        // This minCoords and maxCoords passed in give the size of the terrain (min and max Z
        //         are the high and low points of the heightmap).
        public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap,
                                  Vector3 minCoords, Vector3 maxCoords)
            : base(physicsScene, regionBase, id)
        {
            m_mapInfo                   = new BulletHeightMapInfo(id, initialMap, null);
            m_mapInfo.minCoords         = minCoords;
            m_mapInfo.maxCoords         = maxCoords;
            m_mapInfo.minZ              = minCoords.Z;
            m_mapInfo.maxZ              = maxCoords.Z;
            m_mapInfo.terrainRegionBase = TerrainBase;

            // Don't have to free any previous since we just got here.
            BuildHeightmapTerrain();
        }
Esempio n. 2
0
 // If there is information in m_mapInfo pointing to physical structures, release same.
 private void ReleaseHeightMapTerrain()
 {
     if (m_mapInfo != null)
     {
         if (m_mapInfo.terrainBody.HasPhysicalBody)
         {
             BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
             // Frees both the body and the shape.
             BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
             BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr);
         }
     }
     m_mapInfo = null;
 }
    // This minCoords and maxCoords passed in give the size of the terrain (min and max Z
    //         are the high and low points of the heightmap).
    public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, 
                                                    Vector3 minCoords, Vector3 maxCoords)
        : base(physicsScene, regionBase, id)
    {
        m_mapInfo = new BulletHeightMapInfo(id, initialMap, null);
        m_mapInfo.minCoords = minCoords;
        m_mapInfo.maxCoords = maxCoords;
        m_mapInfo.minZ = minCoords.Z;
        m_mapInfo.maxZ = maxCoords.Z;
        m_mapInfo.terrainRegionBase = TerrainBase;

        // Don't have to free any previous since we just got here.
        BuildHeightmapTerrain();
    }
 // Constructor to build a default, flat heightmap terrain.
 public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize)
     : base(physicsScene, regionBase, id)
 {
     Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE);
     Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION);
     int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y;
     float[] initialMap = new float[totalHeights];
     for (int ii = 0; ii < totalHeights; ii++)
     {
         initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION;
     }
     m_mapInfo = new BulletHeightMapInfo(id, initialMap, null);
     m_mapInfo.minCoords = minTerrainCoords;
     m_mapInfo.maxCoords = maxTerrainCoords;
     m_mapInfo.terrainRegionBase = TerrainBase;
     // Don't have to free any previous since we just got here.
     BuildHeightmapTerrain();
 }
Esempio n. 5
0
        // Constructor to build a default, flat heightmap terrain.
        public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize)
            : base(physicsScene, regionBase, id)
        {
            Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE);
            Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION);
            int     totalHeights     = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y;

            float[] initialMap = new float[totalHeights];
            for (int ii = 0; ii < totalHeights; ii++)
            {
                initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION;
            }
            m_mapInfo                   = new BulletHeightMapInfo(id, initialMap, null);
            m_mapInfo.minCoords         = minTerrainCoords;
            m_mapInfo.maxCoords         = maxTerrainCoords;
            m_mapInfo.terrainRegionBase = TerrainBase;
            // Don't have to free any previous since we just got here.
            BuildHeightmapTerrain();
        }
Esempio n. 6
0
    //PhysicsScene.World.ptr, m_mapInfo.ID, m_mapInfo.minCoords, m_mapInfo.maxCoords,  m_mapInfo.heightMap, PhysicsScene.Params.terrainCollisionMargin
    internal static object CreateHeightMapInfo2(object pWorld, uint pId, Vector3 pminCoords, Vector3 pmaxCoords, float[] pheightMap, float pCollisionMargin)
    {
        BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(pId, pheightMap, null);
        mapInfo.heightMap = null;
        mapInfo.minCoords = pminCoords;
        mapInfo.maxCoords = pmaxCoords;
        mapInfo.sizeX = (int) (pmaxCoords.X - pminCoords.X);
        mapInfo.sizeY = (int) (pmaxCoords.Y - pminCoords.Y);
        mapInfo.ID = pId;
        mapInfo.minZ = pminCoords.Z;
        mapInfo.maxZ = pmaxCoords.Z;
        mapInfo.collisionMargin = pCollisionMargin;
        if (mapInfo.minZ == mapInfo.maxZ)
            mapInfo.minZ -= 0.2f;
        mapInfo.heightMap = pheightMap;

        return mapInfo;

    }
 // If there is information in m_mapInfo pointing to physical structures, release same.
 private void ReleaseHeightMapTerrain()
 {
     if (m_mapInfo != null)
     {
         if (m_mapInfo.terrainBody.HasPhysicalBody)
         {
             BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
             // Frees both the body and the shape.
             BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
             BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr);
         }
     }
     m_mapInfo = null;
 }