コード例 #1
0
 public MeshConcretize(MeshConcretize copy)
 {
     if (copy.Layout != null)
     {
         Layout = (Software.Vertex.IVertex)copy.Layout.Clone();
     }
     if (copy.MeshDescription != null)
     {
         MeshDescription = (Software.Meshes.IMeshDescription)copy.MeshDescription.Clone();
     }
     if (copy.MetaMesh != null)
     {
         MetaMesh = (MetaResource <Software.Mesh>)copy.MetaMesh.Clone();
     }
     if (copy.Mesh != null)
     {
         Mesh = (DataLink <Software.Mesh>)copy.Mesh.Clone();
     }
     if (copy.XMesh != null)
     {
         XMesh = (DataLink <SlimDX.Direct3D9.Mesh>)copy.Mesh.Clone();
     }
     if (copy.MetaXMesh != null)
     {
         MetaXMesh = (MetaResourceBase)copy.MetaXMesh.Clone();
     }
     XMeshFlags = copy.XMeshFlags;
     Pool       = copy.Pool;
 }
コード例 #2
0
 public MeshConcretize()
 {
     XMeshFlags = SlimDX.Direct3D9.MeshFlags.Managed;
     Pool       = SlimDX.Direct3D9.Pool.Managed;
 }
コード例 #3
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);
        }