Exemple #1
0
        public DX11IndexedGeometry LoadFromMesh(Assimp.Mesh mesh, AssimpLoadInformation loadInfo, bool allowRawView = false)
        {
            uint[] inds = mesh.GetIndices();

            if (inds.Length > 0 && mesh.VertexCount > 0)
            {
                int vertexsize;
                var layout = mesh.InputLayout(loadInfo, out vertexsize);

                BoundingBox bb;
                DataStream  ds = mesh.LoadVertices(loadInfo, vertexsize, out bb);

                DX11IndexedGeometry geom = new DX11IndexedGeometry(device)
                {
                    HasBoundingBox = true,
                    BoundingBox    = bb,
                    IndexBuffer    = DX11IndexBuffer.CreateImmutable(device, inds, allowRawView),
                    InputLayout    = layout,
                    PrimitiveType  = "AssimpModel",
                    Tag            = null,
                    Topology       = SharpDX.Direct3D.PrimitiveTopology.TriangleList,
                    VertexBuffer   = DX11VertexBuffer.CreateImmutable(device, mesh.VertexCount, vertexsize, ds, allowRawView)
                };

                ds.Dispose();
                return(geom);
            }

            return(null);
        }