Beispiel #1
0
        public HeightmapObject(Game game, Model model, Vector2 shift)
            : base(game, model)
        {
            body      = new Body(); // just a dummy. The PhysicObject uses its position to get the draw pos
            collision = new CollisionSkin(null);

            heightMapInfo = model.Tag as HeightMapInfo;
            Array2D field = new Array2D(heightMapInfo.heights.GetUpperBound(0), heightMapInfo.heights.GetUpperBound(1));

            for (int x = 0; x < heightMapInfo.heights.GetUpperBound(0); x++)
            {
                for (int z = 0; z < heightMapInfo.heights.GetUpperBound(1); z++)
                {
                    field.SetAt(x, z, heightMapInfo.heights[x, z]);
                }
            }

            // move the body. The body (because its not connected to the collision
            // skin) is just a dummy. But the base class shoudl know where to
            // draw the model.
            body.MoveTo(new Vector3(shift.X, 0, shift.Y), Matrix.Identity);
            //HeightmapProcessor.HeightMapInfoContent hmic = (HeightmapProcessor.HeightMapInfoContent)model.Tag;
            //float ts = hmic.TerrainScale;
            collision.AddPrimitive(new Heightmap(field, shift.X, shift.Y, 5, 5), (int)MaterialTable.MaterialID.NotBouncySmooth);//new MaterialProperties(0.7f,0.7f,0.6f));

            PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.AddCollisionSkin(collision);
        }
Beispiel #2
0
 protected override void LoadContent()
 {
     navMeshModel  = Game.Content.Load <Model>(navMeshName);
     heihgtMapInfo = navMeshModel.Tag as HeightMapInfo;
     base.LoadContent();
 }