コード例 #1
0
ファイル: Mesh.cs プロジェクト: realn/exptor3D
 public void AddVertex(MeshVertex vertex)
 {
     var index = this.Vertices.FindIndex((vert) => { return vert == vertex; });
     if (index < 0)
     {
         index = this.Vertices.Count;
         this.Vertices.Add(vertex);
     }
     this.Indices.Add((ushort)index);
 }
コード例 #2
0
ファイル: Mesh.cs プロジェクト: realn/exptor3D
        public void AddPlane(float width, float height, int slicesX, int slicesY, Color4 color)
        {
            float stepX = width / (float)(slicesX + 1);
            float stepY = height / (float)(slicesY + 1);

            Vector3 normal = new Vector3(0.0f, 1.0f, 0.0f);
            for (int y = 0; y < slicesY; y++)
            {
                for (int x = 0; x < slicesX; x++)
                {
                    var pos1 = new Vector3((x + 0) * stepX, 0.0f, (y + 0) * stepY);
                    var pos2 = new Vector3((x + 1) * stepX, 0.0f, (y + 0) * stepY);
                    var pos3 = new Vector3((x + 1) * stepX, 0.0f, (y + 1) * stepY);
                    var pos4 = new Vector3((x + 0) * stepX, 0.0f, (y + 1) * stepY);

                    var v1 = new MeshVertex() { Position = pos1, TexCoord = new Vector2(0.0f, 0.0f), Color = color, Normal = normal };
                    var v2 = new MeshVertex() { Position = pos2, TexCoord = new Vector2(1.0f, 0.0f), Color = color, Normal = normal };
                    var v3 = new MeshVertex() { Position = pos3, TexCoord = new Vector2(1.0f, 1.0f), Color = color, Normal = normal };
                    var v4 = new MeshVertex() { Position = pos4, TexCoord = new Vector2(0.0f, 1.0f), Color = color, Normal = normal };

                    this.AddQuad(v1, v2, v3, v4);
                }
            }
        }
コード例 #3
0
ファイル: Mesh.cs プロジェクト: realn/exptor3D
        public void AddQuad(MeshVertex v1, MeshVertex v2, MeshVertex v3, MeshVertex v4)
        {
            switch (RenderPrimitive)
            {
                case PrimitiveType.Points:
                    AddVertex(v1);
                    AddVertex(v2);
                    AddVertex(v3);
                    AddVertex(v4);
                    break;

                case PrimitiveType.Lines:
                    AddLine(v1, v2);
                    AddLine(v2, v3);
                    AddLine(v3, v4);
                    AddLine(v4, v1);
                    break;

                case PrimitiveType.Triangles:
                    AddVertex(v1);
                    AddVertex(v2);
                    AddVertex(v3);

                    AddVertex(v1);
                    AddVertex(v3);
                    AddVertex(v4);
                    break;
            }
        }
コード例 #4
0
ファイル: Mesh.cs プロジェクト: realn/exptor3D
        public void AddLine(MeshVertex v1, MeshVertex v2)
        {
            if (RenderPrimitive == PrimitiveType.Triangles)
                return;

            AddVertex(v1);
            AddVertex(v2);
        }