protected override bool IsInFloorBounds(Terrain.IHeightMap floor, Vector3 position) { //foreach (ModelMesh mesh in this.model.Meshes) //{ // BoundingSphere sphere = mesh.BoundingSphere.Transform( // mesh.ParentBone.Transform // * this.tankOrientation // * Matrix.CreateTranslation(position)); // probably needs fixing. // if (sphere.Center.X + sphere.Radius > floor.Width * Game1.GameParameters.MapScale // || sphere.Center.X - sphere.Radius < 0 // || sphere.Center.Z + sphere.Radius > 0 // || sphere.Center.Z - sphere.Radius < -floor.Height * Game1.GameParameters.MapScale) // { // return false; // } //} foreach (BoundingSphere sphere in boundingSpheres) { if (sphere.Center.X + sphere.Radius > floor.Width * Game1.GameParameters.MapScale || sphere.Center.X - sphere.Radius < 0 || sphere.Center.Z - sphere.Radius < 0 || sphere.Center.Z + sphere.Radius > floor.Height * Game1.GameParameters.MapScale) { return(false); } } return(true); }
protected override Vector3 OffsetToFloorHeight(Terrain.IHeightMap floor, Vector3 position) { //BoundingSphere mergedSphere = new BoundingSphere(); //foreach (ModelMesh mesh in this.model.Meshes) //{ // mergedSphere = BoundingSphere.CreateMerged(mergedSphere, mesh.BoundingSphere.Transform(mesh.ParentBone.Transform)); //} return(new Vector3( position.X, floor.Data[(int)(position.Z / Game1.GameParameters.MapScale), (int)(position.X / Game1.GameParameters.MapScale)] * Game1.GameParameters.MapScale - floor.HeightOffset, position.Z)); }
protected override bool IsInFloorBounds(Terrain.IHeightMap floor, Vector3 position) { foreach (ModelMesh mesh in this.model.Meshes) { BoundingSphere sphere = mesh.BoundingSphere.Transform( mesh.ParentBone.Transform * this.orientation * Matrix.CreateTranslation(position)); // probably needs fixing. if (sphere.Center.X + sphere.Radius > floor.Width * Game1.GameParameters.MapScale || sphere.Center.X - sphere.Radius < 0 || sphere.Center.Z - sphere.Radius < 0 || sphere.Center.Z + sphere.Radius > floor.Height * Game1.GameParameters.MapScale) { return(false); } } return(true); }
protected override Vector3 OffsetToFloorHeight(Terrain.IHeightMap floor) { return(this.OffsetToFloorHeight(floor, this.Position)); }
protected override bool IsInFloorBounds(Terrain.IHeightMap floor) { return(this.IsInFloorBounds(floor, this.Position)); }