Exemplo n.º 1
0
        // --------------------------------------------------------------------

        private int ImportMesh(Assimp.Mesh newMesh, List<ModelSupportData.MeshData> previousMeshes)
        {
            Onyx3D.Mesh onyxMesh = newMesh.ToOnyx3D();
            onyxMesh.Scale(sMeshScalar);
            string name = GetSafeFileName(newMesh.Name);
            string meshPath = ProjectContent.GetMeshPath(name);
            AssetLoader<Onyx3D.Mesh>.Save(onyxMesh, meshPath, false);

            int id = -1;
            for (int prevIndex = 0; prevIndex < previousMeshes.Count; ++prevIndex)
            {
                ModelSupportData.MeshData mesh = previousMeshes[prevIndex];
                if (mesh.Name == name)
                {
                    id = mesh.Id;
                    previousMeshes.Remove(mesh);
                    break;
                }
            }

            if (id < 0)
            {
                id = ProjectManager.Instance.Content.AddMesh(meshPath, false, onyxMesh).Guid;
            }
            else
            {
                OnyxProjectAsset asset = ProjectManager.Instance.Content.GetAsset(id);
                if (asset == null)
                {
                    ProjectManager.Instance.Content.AddObject(meshPath, false, ProjectManager.Instance.Content.Meshes, id, onyxMesh);
                }
                else
                {
                    onyxMesh.LinkedProjectAsset = asset;
                }
            }


            ModelSupportData.MeshData data = new ModelSupportData.MeshData();
            data.Id = id;
            data.Name = name;
            mSupportFile.Meshes.Add(data);
            
            ProjectManager.Instance.Content.MarkDirty(id);

            return id;
        }