private static Mesh BuildQuarterBoxMesh(MeshBuilder mb, ContentManager c) { float width = 1f; float height = 0.5f; float depth = 0.5f; mb.Begin(); //front mb.AddQuad(new Vector3(-(width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), (depth / 2)), false, front[0] + new Vector2(0, .25f), front[1] + new Vector2(0, .25f), front[2], front[3]); //left mb.AddQuad(new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), (height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), false, left[0] + new Vector2(0, .25f), left[1] + new Vector2(0, .25f), left[2], left[3]); //back mb.AddQuad(new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), false, front[1] + new Vector2(0, .25f), front[0] + new Vector2(0, .25f), front[3], front[2]); //right mb.AddQuad(new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), false, left[1] + new Vector2(0, .25f), left[0] + new Vector2(0, .25f), left[3], left[2]); //top mb.AddQuad(new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3(-(width / 2), (height / 2), (depth / 2)), false, top[0], top[1], top[2] - new Vector2(0, .25f), top[3] - new Vector2(0, .25f)); //bottom mb.AddQuad(new Vector3(-(width / 2), -(height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), false, bottom[0] + new Vector2(0, .25f), bottom[1] + new Vector2(0, .25f), bottom[2], bottom[3]); mb.OffsetAllVerts(new Vector3(0, -0.25f, -0.25f)); //Offset the verts, because the above code centers the tile over the wrong position Mesh m = mb.End(); m.Texture = c.Load<Texture2D>("Textures/BlockTextures/Block2"); m.NormalMap = c.Load<Texture2D>("Textures/BlockTextures/Block1N"); return m; }
private static Mesh BuildHalfBoxMesh(MeshBuilder mb, ContentManager c) { float width = 1f; float height = 0.5f; float depth = 1f; Vector2[] localFront = new Vector2[4]; Vector2[] localLeft = new Vector2[4]; Array.Copy(front, localFront, localFront.Length); Array.Copy(left, localLeft, localLeft.Length); for (int i = 0; i < 2; i++) { localFront[i].Y = (front[i].Y - 1) / 2 + 1; localLeft[i].Y = (left[i].Y - 1) / 2 + 1; } mb.Begin(); //front mb.AddQuad(new Vector3(-(width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), (depth / 2)), false, localFront[0], localFront[1], localFront[2], localFront[3]); //left mb.AddQuad(new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), (height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), (depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), false, localLeft[0], localLeft[1], localLeft[2], localLeft[3]); //back mb.AddQuad(new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), false, localFront[1], localFront[0], localFront[3], localFront[2]); //right mb.AddQuad(new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), false, localLeft[1], localLeft[0], localLeft[3], localLeft[2]); //top mb.AddQuad(new Vector3(-(width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), (height / 2), -(depth / 2)), new Vector3((width / 2), (height / 2), (depth / 2)), new Vector3(-(width / 2), (height / 2), (depth / 2)), false, top[0], top[1], top[2], top[3]); //bottom mb.AddQuad(new Vector3(-(width / 2), -(height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), (depth / 2)), new Vector3((width / 2), -(height / 2), -(depth / 2)), new Vector3(-(width / 2), -(height / 2), -(depth / 2)), false, bottom[0], bottom[1], bottom[2], bottom[3]); mb.OffsetAllVerts(new Vector3(0, -0.25f, 0)); //Offset the verts, because the above code centers the tile over the wrong position Mesh m = mb.End(); m.Texture = c.Load<Texture2D>("Textures/BlockTextures/Block2"); m.NormalMap = c.Load<Texture2D>("Textures/BlockTextures/Block1N"); return m; }