public void Draw(PrimManager PrimManager, Vector3 BottomLeft, float Size) { Vector3 MasterBottomLeftFront = BottomLeft; Vector3 MasterTopRightBack = MasterBottomLeftFront + new Vector3(Size, Size, Size); Vector3 topLeftFront = new Vector3(MasterBottomLeftFront.X, MasterBottomLeftFront.Y, MasterTopRightBack.Z); Vector3 bottomLeftFront = MasterBottomLeftFront; Vector3 topRightFront = new Vector3(MasterTopRightBack.X, MasterBottomLeftFront.Y, MasterTopRightBack.Z); Vector3 bottomRightFront = new Vector3(MasterTopRightBack.X, MasterBottomLeftFront.Y, MasterBottomLeftFront.Z); Vector3 topLeftBack = new Vector3(MasterBottomLeftFront.X, MasterTopRightBack.Y, MasterTopRightBack.Z); Vector3 bottomLeftBack = new Vector3(MasterBottomLeftFront.X, MasterTopRightBack.Y, MasterBottomLeftFront.Z); Vector3 topRightBack = MasterTopRightBack; Vector3 bottomRightBack = new Vector3(MasterTopRightBack.X, MasterTopRightBack.Y, MasterBottomLeftFront.Z); Vector3 frontNormal = new Vector3(0.0f, -1.0f, 0.0f); Vector3 backNormal = new Vector3(0.0f, 1.0f, 0.0f); Vector3 topNormal = new Vector3(0.0f, 0.0f, 1.0f); Vector3 bottomNormal = new Vector3(0.0f, 0.0f, -1.0f); Vector3 leftNormal = new Vector3(-1.0f, 0.0f, 0.0f); Vector3 rightNormal = new Vector3(1.0f, 0.0f, 0.0f); VertexIndexData _returnData = new VertexIndexData(); _returnData.AddData(PrimHelper.GenerateWallVertices(bottomLeftFront, topRightFront, frontNormal, TilesetMain.Tiles[Tex[0]])); _returnData.AddData(PrimHelper.GenerateWallVertices(bottomRightBack, topLeftBack, backNormal, TilesetMain.Tiles[Tex[2]])); _returnData.AddData(PrimHelper.GenerateWallVertices(bottomLeftBack, topLeftFront, leftNormal, TilesetMain.Tiles[Tex[3]])); _returnData.AddData(PrimHelper.GenerateWallVertices(bottomRightFront, topRightBack, rightNormal, TilesetMain.Tiles[Tex[1]])); _returnData.AddData(PrimHelper.GenerateFloorVertices(bottomLeftBack, bottomRightFront, bottomNormal, TilesetMain.Tiles[Tex[4]])); _returnData.AddData(PrimHelper.GenerateFloorVertices(topLeftFront, topRightBack, topNormal, TilesetMain.Tiles[Tex[5]])); PrimManager.DrawVertices(_returnData, TilesetMain.TextureMain); }
/// <summary> /// Draws the player. /// </summary> public override void Draw(Engine engine) { // Gets the bottom left vector of the billboard. Vector3 _pos = new Vector3(DrawPosition.X, DrawPosition.Y + Block.Size / 2, DrawPosition.Z); // Creates a wall. VertexIndexData _wall = PrimHelper.GenerateWallVertices(_pos, _pos + new Vector3(Block.Size, 0, Block.Size), -Vector3.UnitY, animation.texture); // Draws the wall. engine.primManager.DrawVertices(_wall, animation.Texture); }
/// <summary> /// Generates vertex and index information for this block. /// </summary> public VertexIndexData GenerateVertices(Room CurrentRoom, Vector3 Position) { Vector3 MasterBottomLeftFront = new Vector3(Size, Size, Size) * Position; Vector3 MasterTopRightBack = MasterBottomLeftFront + new Vector3(Size, Size, Size); Vector3 topLeftFront = new Vector3(MasterBottomLeftFront.X, MasterBottomLeftFront.Y, MasterTopRightBack.Z); Vector3 bottomLeftFront = MasterBottomLeftFront; Vector3 topRightFront = new Vector3(MasterTopRightBack.X, MasterBottomLeftFront.Y, MasterTopRightBack.Z); Vector3 bottomRightFront = new Vector3(MasterTopRightBack.X, MasterBottomLeftFront.Y, MasterBottomLeftFront.Z); Vector3 topLeftBack = new Vector3(MasterBottomLeftFront.X, MasterTopRightBack.Y, MasterTopRightBack.Z); Vector3 bottomLeftBack = new Vector3(MasterBottomLeftFront.X, MasterTopRightBack.Y, MasterBottomLeftFront.Z); Vector3 topRightBack = MasterTopRightBack; Vector3 bottomRightBack = new Vector3(MasterTopRightBack.X, MasterTopRightBack.Y, MasterBottomLeftFront.Z); Vector3 frontNormal = new Vector3(0.0f, -1.0f, 0.0f); Vector3 backNormal = new Vector3(0.0f, 1.0f, 0.0f); Vector3 topNormal = new Vector3(0.0f, 0.0f, 1.0f); Vector3 bottomNormal = new Vector3(0.0f, 0.0f, -1.0f); Vector3 leftNormal = new Vector3(-1.0f, 0.0f, 0.0f); Vector3 rightNormal = new Vector3(1.0f, 0.0f, 0.0f); VertexIndexData _returnData = new VertexIndexData(); if (Position.Y > 0) { if (CurrentRoom.GetGridBlock((int)Position.X, (int)Position.Y - 1, (int)Position.Z).Culling == false) { if (Tex[0] > 0) { _returnData.AddData(PrimHelper.GenerateWallVertices(bottomLeftFront, topRightFront, frontNormal, TilesetMain.Tiles[Tex[0]])); } } } if (Position.Y < CurrentRoom.Depth - 1) { if (CurrentRoom.GetGridBlock((int)Position.X, (int)Position.Y + 1, (int)Position.Z).Culling == false) { if (Tex[1] > 0) { _returnData.AddData(PrimHelper.GenerateWallVertices(bottomRightBack, topLeftBack, backNormal, TilesetMain.Tiles[Tex[2]])); } } } if (Position.X > 0) { if (CurrentRoom.GetGridBlock((int)Position.X - 1, (int)Position.Y, (int)Position.Z).Culling == false) { if (Tex[2] > 0) { _returnData.AddData(PrimHelper.GenerateWallVertices(bottomLeftBack, topLeftFront, leftNormal, TilesetMain.Tiles[Tex[3]])); } } } if (Position.X < CurrentRoom.Width - 1) { if (CurrentRoom.GetGridBlock((int)Position.X + 1, (int)Position.Y, (int)Position.Z).Culling == false) { if (Tex[3] > 0) { _returnData.AddData(PrimHelper.GenerateWallVertices(bottomRightFront, topRightBack, rightNormal, TilesetMain.Tiles[Tex[1]])); } } } if (Position.Z > 0) { if (CurrentRoom.GetGridBlock((int)Position.X, (int)Position.Y, (int)Position.Z - 1).Culling == false) { if (Tex[4] > 0) { _returnData.AddData(PrimHelper.GenerateFloorVertices(bottomLeftBack, bottomRightFront, bottomNormal, TilesetMain.Tiles[Tex[4]])); } } } if (Position.Z < CurrentRoom.Height - 1) { if (CurrentRoom.GetGridBlock((int)Position.X, (int)Position.Y, (int)Position.Z + 1).Culling == false) { if (Tex[5] > 0) { _returnData.AddData(PrimHelper.GenerateFloorVertices(topLeftFront, topRightBack, topNormal, TilesetMain.Tiles[Tex[5]])); } } } return(_returnData); }