Universe.Physics.BulletSPlugin.BSTerrainManager.CreateInitialGroundPlaneAndTerrain C# (CSharp) Method

CreateInitialGroundPlaneAndTerrain() public method

public CreateInitialGroundPlaneAndTerrain ( ) : void
return void
        public void CreateInitialGroundPlaneAndTerrain()
        {
            DetailLog("{0},BSTerrainManager.CreateInitialGroundPlaneAndTerrain,region={1}", BSScene.DetailLogZero,
                PhysicsScene.RegionName);
            // The ground plane is here to catch things that are trying to drop to negative infinity
            BulletShape groundPlaneShape = PhysicsScene.PE.CreateGroundPlaneShape(BSScene.GROUNDPLANE_ID, 1f,
                BSParam.TerrainCollisionMargin);
            Vector3 groundPlaneAltitude = new Vector3(0f, 0f, BSParam.TerrainGroundPlane);
            m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape,
                BSScene.GROUNDPLANE_ID, groundPlaneAltitude, Quaternion.Identity);

            PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_groundPlane);
            PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_groundPlane);
            // Ground plane does not move
            PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION);
            // Everything collides with the ground plane.
            m_groundPlane.collisionType = CollisionType.Groundplane;
            m_groundPlane.ApplyCollisionMask(PhysicsScene);

            m_terrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, m_worldMax);
        }

Usage Example

Example #1
0
        public override void Initialize(IMesher meshmerizer, IScene scene)
        {
            Scene = scene;
            mesher = meshmerizer;
            _taintOperations = new List<TaintCallbackEntry>();
            _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
            _postStepOperations = new List<TaintCallbackEntry>();
            PhysObjects = new Dictionary<uint, BSPhysObject>();
            Shapes = new BSShapeCollection(this);

            // some identifiers
            RegionName = scene.RegionInfo.RegionName;
            PhysicsSceneName = RegionName;

            // Allocate pinned memory to pass parameters.
            UnmanagedParams = new ConfigurationParameters[1];

            // Set default values for physics parameters plus any overrides from the ini file
            GetInitialParameterValues(scene.Config);

            // Get the connection to the physics engine (could be native or one of many DLLs)
            PE = SelectUnderlyingBulletEngine(BulletEngineName);

            // Enable very detailed logging.
            // By creating an empty logger when not logging, the log message invocation code
            //     can be left in and every call doesn't have to check for null.
            /*if (m_physicsLoggingEnabled)
            {
                PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
                PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages.
            }
            else
            {
                PhysicsLogging = new Logging.LogWriter();
            }*/

            // Allocate memory for returning of the updates and collisions from the physics engine
            m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
            m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];

            // The bounding box for the simulated world. The origin is 0,0,0 unless we're
            //    a child in a mega-region.
            // Bullet actually doesn't care about the extents of the simulated
            //    area. It tracks active objects no matter where they are.
            Vector3 worldExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeX, Constants.RegionHeight);
               // Vector3 worldExtent = regionExtent;

            World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray,
                m_maxUpdatesPerFrame, ref m_updateArray);

            Constraints = new BSConstraintCollection(World);

            TerrainManager = new BSTerrainManager(this);
            TerrainManager.CreateInitialGroundPlaneAndTerrain();

            MainConsole.Instance.WarnFormat("{0} Linksets implemented with {1}", LogHeader,
                (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);

            InTaintTime = false;
            m_initialized = true;
        }
All Usage Examples Of Universe.Physics.BulletSPlugin.BSTerrainManager::CreateInitialGroundPlaneAndTerrain