public Pipe(int id = 0) : base("Pipe" + id.ToString()) { var model = ContentManager.Get <Model>("Models/Battery"); var meshes = new BlockMesh[6]; int i; BlockMesh blockMesh; ModelMeshPart meshPart = model.FindMesh("Battery").MeshParts[0]; Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Battery").ParentBone); for (i = 0; i < 6; i++) { blockMesh = new BlockMesh(); var vector = CellFace.FaceToVector3(i); blockMesh.AppendModelMeshPart(meshPart, boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.2f, 0f) * Matrix.CreateScale(1f, 0.66f, 1f) * ((i < 4) ? (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationX(i * 3.14159274f / 2f + 3.14159274f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)) : ((i != 4) ? (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationZ(-1.57079637f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)) : (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationZ(1.57079637f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)))), false, false, false, false, Color.LightGray); blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-2f / 16f, 4f / 16f, 0f)); blockMesh.TransformPositions(Matrix.CreateTranslation(new Vector3(0.5f))); meshes[i] = blockMesh; } for (i = 0; i < 63; i++) { Meshes[i] = new BlockMesh(); for (int j = 0; j < 6; j++) { if (((i + 1) >> j & 1) != 0) { Meshes[i].AppendBlockMesh(meshes[j]); } } } }