public override MeshContainer CreateMeshContainer(string name, MeshData meshData, ExtendedMaterial[] materials, EffectInstance[] effectInstances, GraphicsStream adjacency, SkinInformation skinInfo) { if (meshData.Mesh == null) { throw new ArgumentException(); } if (meshData.Mesh.VertexFormat == VertexFormats.None) { throw new ArgumentException(); } MeshContainerDerived mesh = new MeshContainerDerived(); mesh.Name = name; int numFaces = meshData.Mesh.NumberFaces; Device dev = meshData.Mesh.Device; if ((meshData.Mesh.VertexFormat & VertexFormats.Normal) == 0) { Mesh tempMesh = meshData.Mesh.Clone(meshData.Mesh.Options.Value, meshData.Mesh.VertexFormat | VertexFormats.Normal, dev); meshData.Mesh = tempMesh; meshData.Mesh.ComputeNormals(); } mesh.SetMaterials(materials); mesh.SetAdjacency(adjacency); Texture[] meshTextures = new Texture[materials.Length]; for (int i = 0; i < materials.Length; i++) { if (!string.IsNullOrEmpty(materials[i].TextureFilename)) { meshTextures[i] = TextureLoader.FromStream(dev, ResourcesLoader.LoadStream(materials[i].TextureFilename)); } } mesh.meshTextures = meshTextures; mesh.MeshData = meshData; if (skinInfo != null) { mesh.SkinInformation = skinInfo; int numBones = skinInfo.NumberBones; Matrix[] offsetMatrices = new Matrix[numBones]; for (int i = 0; i < numBones; i++) { offsetMatrices[i] = skinInfo.GetBoneOffsetMatrix(i); } mesh.offsetMatrices = offsetMatrices; MeshContainerDerived.GenerateSkinnedMesh(mesh); } return(mesh); }
/// <summary>Create a new mesh container</summary> public override MeshContainer CreateMeshContainer(string name, MeshData meshData, ExtendedMaterial[] materials, EffectInstance[] effectInstances, GraphicsStream adjacency, SkinInformation skinInfo) { // We only handle meshes here if (meshData.Mesh == null) { throw new ArgumentException(); } // We must have a vertex format mesh if (meshData.Mesh.VertexFormat == VertexFormats.None) { throw new ArgumentException(); } AnimationMeshContainer mesh = new AnimationMeshContainer(); mesh.adjency = adjacency; mesh.Name = name; int numFaces = meshData.Mesh.NumberFaces; Device dev = meshData.Mesh.Device; // Store the materials mesh.SetMaterials(materials); mesh.SetAdjacency(adjacency); Texture[] meshTextures = new Texture[materials.Length]; mesh.MeshData = meshData; // If there is skinning info, save any required data if (skinInfo != null) { mesh.SkinInformation = skinInfo; int numBones = skinInfo.NumberBones; Matrix[] offsetMatrices = new Matrix[numBones]; for (int i = 0; i < numBones; i++) { offsetMatrices[i] = skinInfo.GetBoneOffsetMatrix(i); } mesh.SetOffsetMatrices(offsetMatrices); GenerateSkinnedMesh(mesh, adjacency); } return(mesh); }
/// <summary> /// Create a new packmesh container /// </summary> /// <returns>The newly created container</returns> /// public override MeshContainer CreateMeshContainer(string name, MeshData meshData, ExtendedMaterial[] materials, EffectInstance effectInstances, GraphicsStream adjacency, SkinInformation skinInfo) { // We only handle meshes here if (meshData.Mesh == null) { throw new ArgumentException(); } // We must have a vertex format packmesh if (meshData.Mesh.VertexFormat == VertexFormats.None) { throw new ArgumentException(); } Packmesh packmesh = new Packmesh(); packmesh.Name = name; int numFaces = meshData.Mesh.NumberFaces; Device dev = meshData.Mesh.Device; // Make sure there are normals if ((meshData.Mesh.VertexFormat & VertexFormats.Normal) == 0) { // Clone the packmesh Mesh tempMesh = meshData.Mesh.Clone(meshData.Mesh.Options.Value, meshData.Mesh.VertexFormat | VertexFormats.Normal, dev); meshData.Mesh = tempMesh; meshData.Mesh.ComputeNormals(); } // Store the materials packmesh.SetMaterials(materials); packmesh.SetAdjacency(adjacency); Texture[] texturas = new Texture[materials.Length]; // Create any textures for (int i = 0; i < materials.Length; i++) { if (materials[i].TextureFilename != null) { texturas[i] = TextureLoader.FromFile(dev, @"..\..\" + materials[i].TextureFilename); } } packmesh.SetTextures(texturas); packmesh.MeshData = meshData; // If there is skinning info, save any required data if (skinInfo != null) { packmesh.SkinInformation = skinInfo; int nOssos = skinInfo.NumberBones; Matrix[] offsetMatrices = new Matrix[nOssos]; for (int i = 0; i < nOssos; i++) { offsetMatrices[i] = skinInfo.GetBoneOffsetMatrix(i); } packmesh.SetOffsetMatrices(offsetMatrices); app.gerarModeloElastico(packmesh); } return(packmesh); }