public List<String> SetViewModel(String _model) { String nameOnly = Path.GetFileNameWithoutExtension(_model); String filename = Path.GetFileName(_model); String modelDir = Path.GetDirectoryName(_model); AddResourcesDirectory(nameOnly, modelDir); if (sceneMgr.HasEntity(nameOnly)) sceneMgr.DestroyEntity(nameOnly); modelEntity = sceneMgr.CreateEntity(nameOnly, filename, nameOnly); if (sceneMgr.HasSceneNode(MODEL_NODE)) sceneMgr.DestroySceneNode(MODEL_NODE); modelNode = sceneMgr.RootSceneNode.CreateChildSceneNode(MODEL_NODE); modelNode.SetInitialState(); modelNode.DetachAllObjects(); modelNode.AttachObject(modelEntity); // check for material textures foreach (var subMesh in modelEntity.GetMesh().GetSubMeshIterator()) { bool needsReload = false; var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName); if (matPtr != null) { foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator()) { foreach (var mtrTex in mtrPass.GetTextureUnitStateIterator()) { if (mtrTex.IsTextureLoadFailing) { mtrTex.SetTextureName(mtrTex.TextureName.Replace(".png", ".dds")); needsReload = true; } } } } if (needsReload) matPtr.Reload(); } //if (modelEntity.HasSkeleton) //{ // foreach (String skltFiles in Directory.GetFiles(modelDir, "*.skeleton")) // { // try // { // SkeletonPtr source = SkeletonManager.Singleton.Load(Path.GetFileName(skltFiles), "General"); // Skeleton.BoneHandleMap boneHandleMap = new Skeleton.BoneHandleMap(); // source._buildMapBoneByHandle(source, boneHandleMap); // modelEntity.Skeleton._mergeSkeletonAnimations(source, boneHandleMap); // modelEntity.Skeleton._refreshAnimationState(modelEntity.AllAnimationStates); // } // catch { } // } // modelEntity.DisplaySkeleton = true; //} SetInitialCamera(modelEntity, modelNode); if (sceneMgr.HasLight("SimpleLight")) sceneMgr.DestroyLight("SimpleLight"); Light light = sceneMgr.CreateLight("SimpleLight"); sceneMgr.RootSceneNode.AttachObject(light); light.DiffuseColour = new ColourValue(1f, 1f, 1f); light.Position = this.camera.Position; light.Direction = this.camera.Direction; return GetAnimationNames(modelEntity); }