コード例 #1
0
 protected override Jitter.Dynamics.RigidBody GeneratePhysicsDescription()
 {
     var collisionShape = new TerrainShape(TerrainData, xScale, zScale);
     return new RigidBody(collisionShape)
     {
         Position = PhysicsSystem.toJVector(Position),
         IsStatic = true,
         EnableDebugDraw = false,
     };
 }
コード例 #2
0
 protected override RigidBody GeneratePhysicsDescription()
 {
     var collisionShape = new TerrainShape(TerrainData, (float)xScale, (float)zScale);
     var rigidBody = new RigidBody(collisionShape)
     {
         Position = PhysicsSystem.toJVector(Position),
         IsStatic = true,
         EnableDebugDraw = true,
     };
     return rigidBody;
 }
コード例 #3
0
ファイル: TerrainShape.cs プロジェクト: af3dgce/EntitasUnity
        protected override Multishape CreateWorkingClone()
        {
            TerrainShape clone = new TerrainShape();

            clone.heights            = this.heights;
            clone.scaleX             = this.scaleX;
            clone.scaleZ             = this.scaleZ;
            clone.boundings          = this.boundings;
            clone.heightsLength0     = this.heightsLength0;
            clone.heightsLength1     = this.heightsLength1;
            clone.sphericalExpansion = this.sphericalExpansion;
            return(clone);
        }
コード例 #4
0
        protected override Multishape CreateWorkingClone()
        {
            var clone = new TerrainShape
            {
                heights            = heights,
                scaleX             = scaleX,
                scaleZ             = scaleZ,
                boundings          = boundings,
                heightsLength0     = heightsLength0,
                heightsLength1     = heightsLength1,
                SphericalExpansion = SphericalExpansion
            };

            return(clone);
        }
コード例 #5
0
ファイル: Terrain.cs プロジェクト: reidyd/jitterphysics
        public override void Build()
        {
            terrain = new Primitives3D.TerrainPrimitive(Demo.GraphicsDevice,
                ((a,b)=>
            {
                return (float)(Math.Cos(a * 0.2f) * Math.Sin(b * 0.2f) * 2.0f);
            }));

            TerrainShape shape = new TerrainShape(terrain.heights, 1.0f, 1.0f);

            RigidBody body = new RigidBody(shape);
            body.Position -= new JVector(50, 0, 50);
            body.IsStatic = true;
            body.Tag = BodyTag.DontDrawMe;
            //body.EnableDebugDraw = true;
            Demo.World.AddBody(body);

            AddCar(new JVector(0, 4, 0));
        }
コード例 #6
0
        public override void Initialize()
        {
            base.Initialize();
            primitive = new TerrainPrimitive(GraphicsDevice,
                (int a, int b) =>
                { return (float)(Math.Sin(a * 0.1f) * Math.Cos(b * 0.1f))*3; });

            JitterDemo demo = this.Game as JitterDemo;

            TerrainShape terrainShape = new TerrainShape(primitive.heights, 1.0f, 1.0f);

            terrainBody = new RigidBody(terrainShape);
            terrainBody.IsStatic = true;
            terrainBody.Tag = true;

            demo.World.AddBody(terrainBody);

            World = Matrix.CreateTranslation(-50, 0, -50);
        }
コード例 #7
0
ファイル: TerrainShape.cs プロジェクト: RainsSoft/Jitter
 protected override Multishape CreateWorkingClone()
 {
     TerrainShape clone = new TerrainShape();
     clone.heights = this.heights;
     clone.scaleX = this.scaleX;
     clone.scaleZ = this.scaleZ;
     clone.boundings = this.boundings;
     clone.heightsLength0 = this.heightsLength0;
     clone.heightsLength1 = this.heightsLength1;
     clone.sphericalExpansion = this.sphericalExpansion;
     return clone;
 }
コード例 #8
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;
        }
コード例 #9
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;
 }
コード例 #10
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;
        }