private static M.GeometryModelContent BuildModel(List <MeshContent> meshes, Dictionary <GeometryContent, M.MaterialContent> materials)
        {
            var model = new M.GeometryModelContent();

            var meshCounter = 0;

            foreach (var mesh in meshes)
            {
                var meshName = string.IsNullOrWhiteSpace(mesh.Name) ? $"{meshCounter}" : mesh.Name;
                meshCounter++;

                var geometryCounter = 0;
                foreach (var geometry in mesh.Geometry)
                {
                    var geometryName = string.IsNullOrWhiteSpace(geometry.Name) ? $"{geometryCounter}" : geometry.Name;
                    geometryCounter++;

                    StripVertexChannels(geometry);

                    var name         = string.Join(".", meshName, geometryName);
                    var vertexBuffer = geometry.Vertices.CreateVertexBuffer();
                    var indices      = geometry.Indices;
                    var bounds       = BoundingSphere.CreateFromPoints(mesh.Positions);

                    var geometryData = new M.GeometryDataContent(name, vertexBuffer, indices, bounds);

                    var material     = materials[geometry];
                    var geometryMesh = new M.GeometryMeshContent(geometryData, material, mesh.AbsoluteTransform);

                    model.Add(geometryMesh);
                }
            }

            return(model);
        }
Exemple #2
0
 public GeometryMeshContent(GeometryDataContent geometryData, MaterialContent material, Matrix offset)
 {
     this.GeometryData = geometryData;
     this.Material     = material;
     this.Offset       = offset;
 }