public static Software.Mesh IndexedCollada(List<ColladaLoader.Vertex> inVertices, List<int> inIndices)
        {
            var mesh = new Software.Mesh
            {
                MeshType = MeshType.Indexed,
                VertexStreamLayout = Graphics.Software.Vertex.Position3Normal3Texcoord3.Instance,
                NVertices = inVertices.Count,
                NFaces = inIndices.Count / 3
            };

            List<Graphics.Software.Vertex.Position3Normal3Texcoord3> verts = new List<Graphics.Software.Vertex.Position3Normal3Texcoord3>();
            foreach (var v in inVertices)
                verts.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(v.Position, v.Normal, v.Texcoord));

            mesh.VertexBuffer = new Software.VertexBuffer<Graphics.Software.Vertex.Position3Normal3Texcoord3>(verts.ToArray());

            inIndices.Reverse();
            mesh.IndexBuffer = new Software.IndexBuffer(inIndices.ToArray());

            return mesh;
        }
        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);
        }
        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);
        }
Ejemplo n.º 4
0
        public static Software.Mesh IndexedCollada(List <ColladaLoader.Vertex> inVertices, List <int> inIndices)
        {
            var mesh = new Software.Mesh
            {
                MeshType           = MeshType.Indexed,
                VertexStreamLayout = Graphics.Software.Vertex.Position3Normal3Texcoord3.Instance,
                NVertices          = inVertices.Count,
                NFaces             = inIndices.Count / 3
            };

            List <Graphics.Software.Vertex.Position3Normal3Texcoord3> verts = new List <Graphics.Software.Vertex.Position3Normal3Texcoord3>();

            foreach (var v in inVertices)
            {
                verts.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(v.Position, v.Normal, v.Texcoord));
            }

            mesh.VertexBuffer = new Software.VertexBuffer <Graphics.Software.Vertex.Position3Normal3Texcoord3>(verts.ToArray());

            inIndices.Reverse();
            mesh.IndexBuffer = new Software.IndexBuffer(inIndices.ToArray());

            return(mesh);
        }