コード例 #1
0
        public Software.Vertex.IVertex this[int index]
        {
            get
            {
                switch (index)
                {
                case 0: return(A);

                case 1: return(B);

                case 2: return(C);

                default: throw new ArgumentOutOfRangeException();
                }
            }
            set
            {
                switch (index)
                {
                case 0: A = value; break;

                case 1: B = value; break;

                case 2: C = value; break;

                default: throw new ArgumentOutOfRangeException();
                }
            }
        }
コード例 #2
0
 public Mesh ConvertTo(Software.Vertex.IVertex layout)
 {
     return(new Mesh
     {
         NFaces = NFaces,
         NVertices = NVertices,
         VertexStreamLayout = layout,
         MeshType = MeshType,
         IndexBuffer = IndexBuffer != null ? new IndexBuffer(IndexBuffer) : null,
         VertexBuffer = VertexBuffer.ConvertTo(layout)
     });
 }
コード例 #3
0
 public Software.Vertex.IVertex this[int index]
 {
     get
     {
         switch (index)
         {
             case 0: return A;
             case 1: return B;
             case 2: return C;
             default: throw new ArgumentOutOfRangeException();
         }
     }
     set
     {
         switch (index)
         {
             case 0: A = value; break;
             case 1: B = value; break;
             case 2: C = value; break;
             default: throw new ArgumentOutOfRangeException();
         }
     }
 }
コード例 #4
0
        public static Mesh10 Concretize10(ContentPool content, Software.Mesh sysmemMesh, Software.Vertex.IVertex layout)
        {
            if (sysmemMesh == null)
            {
                return(null);
            }
            if (layout != null && layout.GetType() != sysmemMesh.VertexStreamLayout.GetType())
            {
                sysmemMesh = sysmemMesh.ConvertTo(layout);
            }

            Graphics.Content.Mesh10 mesh = new Mesh10
            {
                MeshType           = sysmemMesh.MeshType,
                NFaces             = sysmemMesh.NFaces,
                NVertices          = sysmemMesh.NVertices,
                VertexStreamLayout = sysmemMesh.VertexStreamLayout
            };

            mesh.VertexBuffer = sysmemMesh.VertexBuffer.GetD3DBuffer(content.Device10);

            if (sysmemMesh.IndexBuffer != null)
            {
                var indices = new DataStream((sysmemMesh.ShortIndices ? sizeof(short) : sizeof(int)) * sysmemMesh.NFaces * 3, false, true);
                sysmemMesh.IndexBuffer.WriteToStream(indices, sysmemMesh.ShortIndices);
                indices.Seek(0, System.IO.SeekOrigin.Begin);
                mesh.IndexBuffer = new SlimDX.Direct3D10.Buffer(content.Device10, indices, new SlimDX.Direct3D10.BufferDescription
                {
                    BindFlags      = SlimDX.Direct3D10.BindFlags.IndexBuffer,
                    CpuAccessFlags = SlimDX.Direct3D10.CpuAccessFlags.None,
                    OptionFlags    = SlimDX.Direct3D10.ResourceOptionFlags.None,
                    SizeInBytes    = (int)indices.Length,
                    Usage          = SlimDX.Direct3D10.ResourceUsage.Default
                });
            }

            return(mesh);
        }
コード例 #5
0
        public static Mesh9 Concretize9(ContentPool content, Software.Mesh sysmemMesh, Software.Vertex.IVertex layout, SlimDX.Direct3D9.Pool pool)
        {
            if (sysmemMesh == null)
            {
                return(null);
            }
            if (layout != null && layout.GetType() != sysmemMesh.VertexStreamLayout.GetType())
            {
                sysmemMesh = sysmemMesh.ConvertTo(layout);
            }

            Graphics.Content.Mesh9 mesh = new Mesh9
            {
                MeshType           = sysmemMesh.MeshType,
                NFaces             = sysmemMesh.NFaces,
                NVertices          = sysmemMesh.NVertices,
                VertexStreamLayout = sysmemMesh.VertexStreamLayout
            };
            mesh.VertexBuffer = new SlimDX.Direct3D9.VertexBuffer(content.Device9,
                                                                  mesh.VertexStreamLayout.Size * mesh.NVertices,
                                                                  SlimDX.Direct3D9.Usage.None, mesh.VertexStreamLayout.VertexFormat,
                                                                  pool);

            sysmemMesh.VertexBuffer.WriteToD3DBuffer(mesh.VertexBuffer);

            if (sysmemMesh.IndexBuffer != null)
            {
                mesh.IndexBuffer = new SlimDX.Direct3D9.IndexBuffer(content.Device9, (sysmemMesh.ShortIndices ? sizeof(short) : sizeof(int)) * mesh.NFaces * 3,
                                                                    SlimDX.Direct3D9.Usage.None, pool, sysmemMesh.ShortIndices);
                var indices = mesh.IndexBuffer.Lock(0, (sysmemMesh.ShortIndices ? sizeof(short) : sizeof(int)) * mesh.NFaces * 3,
                                                    SlimDX.Direct3D9.LockFlags.None);
                sysmemMesh.IndexBuffer.WriteToStream(indices, sysmemMesh.ShortIndices);
                mesh.IndexBuffer.Unlock();
            }

            return(mesh);
        }