public override void GenerateTerrainVertices(Block block, BlockGeometryGenerator generator, TerrainGeometrySubsets geometry, int value, int x, int y, int z) { BlockMesh drawMesh = new BlockMesh(); Point3 p = new Point3(x, y, z); Terrain terrain = generator.Terrain; for (int i = 0; i < 6; i++) { Point3 pp = p + Fixdirection[i]; int v = terrain.GetCellContents(pp.X, pp.Y, pp.Z); if (v == 1003) { BlockMesh blockMesh = new BlockMesh(); Matrix matrix = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(eles[i]).ParentBone); blockMesh.AppendModelMeshPart(model.FindMesh(eles[i]).MeshParts[0], matrix * Matrix.CreateScale(0.7f), false, false, false, false, Color.White); drawMesh.AppendBlockMesh(blockMesh); } } BlockMesh blockMeshd = new BlockMesh(); Matrix matrixd = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(eles[6]).ParentBone); blockMeshd.AppendModelMeshPart(model.FindMesh(eles[6]).MeshParts[0], matrixd * Matrix.CreateScale(0.7f), false, false, false, false, Color.White); drawMesh.AppendBlockMesh(blockMeshd); drawMesh.TransformPositions(Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)); if (!ComponentPlayUpdate.duliBlocks.ContainsKey(p)) { ComponentPlayUpdate.duliBlocks.Add(p, texture); } generator.GenerateMeshVertices(block, x, y, z, drawMesh, Color.White, Matrix.Identity, ComponentPlayUpdate.GTV(x, y, z, geometry).SubsetTransparent); boundmesh = drawMesh; }
public ItemMekWire(int id, string str) : base(id, str) { model = ContentManager.Get <Model>("Mekiasm/Models/Wire"); texture = ContentManager.Get <Texture2D>("Mekiasm/Textures/Wire"); BlockMesh blockMesh = new BlockMesh(); Matrix matrix = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(eles[1]).ParentBone); blockMesh.AppendModelMeshPart(model.FindMesh(eles[1]).MeshParts[0], matrix, false, false, false, true, Color.White); mainMesh.AppendBlockMesh(blockMesh); mainMesh.TransformPositions(Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)); drawMesh.AppendModelMeshPart(model.FindMesh(eles[6]).MeshParts[0], matrix, false, false, false, true, Color.White); drawMesh.TransformPositions(Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)); }
public void Draw(Camera camera, Vector3 point) { int indecies = blockMesh.Indices.Count / 3; for (int i = 0; i < indecies; i++) { BlockMeshVertex blockMeshVertex = blockMesh.Vertices.Array[blockMesh.Indices.Array[i * 3]]; BlockMeshVertex blockMeshVertex2 = blockMesh.Vertices.Array[blockMesh.Indices.Array[i * 3 + 1]]; BlockMeshVertex blockMeshVertex3 = blockMesh.Vertices.Array[blockMesh.Indices.Array[i * 3 + 2]]; Vector3 p = blockMeshVertex.Position + point; Vector3 p2 = blockMeshVertex2.Position + point; Vector3 p3 = blockMeshVertex3.Position + point; texturedBatch3D.QueueTriangle(p, p2, p3, blockMeshVertex.TextureCoordinates, blockMeshVertex2.TextureCoordinates, blockMeshVertex3.TextureCoordinates, Color.White); } primitives.Flush(camera.ViewProjectionMatrix); blockMesh.TransformPositions(Matrix.CreateFromAxisAngle(new Vector3(0f, 0f, 2f), f)); }
public MekBaseSolarPanel(int id, string str) : base(id, str) { Model model = ContentManager.Get <Model>("Mekiasm/Models/TYN"); texture = ContentManager.Get <Texture2D>("Mekiasm/Textures/solarpanel"); for (int i = 0; i < eles.Count; i++) { BlockMesh blockMesh = new BlockMesh(); Matrix matrix = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(eles[i]).ParentBone); blockMesh.AppendModelMeshPart(model.FindMesh(eles[i]).MeshParts[0], matrix, false, false, false, false, Color.White); mainMesh.AppendBlockMesh(blockMesh); } BlockMesh mesh = mainMesh; mesh.TransformPositions(Matrix.CreateScale(1f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)); boundingBoxes.Add(mesh.CalculateBoundingBox()); }