예제 #1
0
        /// <summary>
        /// Static method to construct physics description
        /// </summary>
        /// <param name="position"></param>
        /// <param name="heightMapTexture"></param>
        /// <param name="scale"></param>
        /// <param name="isStatic"></param>
        /// <returns></returns>
        private static PhysicsDescription GeneratePhysicsDescription(Vector3 position, Texture2D heightMapTexture, double scale, Boolean isStatic)
        {
            var terrainData = ProcessHeightMap(heightMapTexture);
            var minHeight = 255f;
            foreach (var h in terrainData)
            {
                if (h < minHeight)
                {
                    minHeight = h;
                }
            }
            var collisionShape = new TerrainShape(terrainData, (float) scale, (float) scale);
            var rigidBody = new RigidBody(collisionShape)
            {
                Position = PhysicsSystem.toJVector(position - new Vector3(0f, 255f, 0f)),
                IsStatic = isStatic,
                EnableDebugDraw = true,
            };

            var description = new PhysicsDescription()
            {
                IsStatic = isStatic,
                CollisionShape = collisionShape,
                IsDebugDrawable = true,
                RigidBody = rigidBody,
                Position = position
            };

            return description;
        }
예제 #2
0
 private static PhysicsDescription GeneratePhyicsDescription(Vector3 position, int xScale, int yScale, float frontHeight, float backHeight, bool isStatic)
 {
     float[,] terrainData = new float[,] { 
         {frontHeight, backHeight} ,
         {frontHeight, backHeight}
     };
     var collisionShape = new TerrainShape(terrainData, (float) xScale, (float) yScale);
     var rigidBody = new RigidBody(collisionShape)
     {
         Position = PhysicsSystem.toJVector(position),
         IsStatic = isStatic,
         EnableDebugDraw = true,
     };
     var description = new PhysicsDescription()
     {
         IsStatic = isStatic,
         CollisionShape = collisionShape,
         IsDebugDrawable = true,
         RigidBody = rigidBody,
         Position = position
     };
     
     return description;
 }
예제 #3
0
 private Terrain(Project2Game game, PhysicsDescription physicsDescription) 
     : base(game, physicsDescription)
 {       
     // This is the old super constructor call. Needs to be updated
 }
예제 #4
0
        private static PhysicsDescription GeneratePhysicsDescription(Vector3 position, int density, double scale, double amplitude, Boolean isStatic)
        {
            var terrainData = GenerateDiamondSquare(density, (float)amplitude);
            var collisionShape = new TerrainShape(terrainData, (float) scale, (float) scale);
            var rigidBody = new RigidBody(collisionShape)
            {
                Position = PhysicsSystem.toJVector(position),
                IsStatic = isStatic,
                EnableDebugDraw = true,
            };

            var description = new PhysicsDescription()
            {
                IsStatic = isStatic,
                CollisionShape = collisionShape,
                IsDebugDrawable = true,
                RigidBody = rigidBody,
                Position = position
            };

            return description;
        }