Example #1
0
        public void SetEquipModel(string theModel, EquipWeaponSlot theSlot)
        {
            if (ModelEntity != null && ModelEntity.HasSkeleton)
            {
                string boneName = theSlot.ToString();

                string nameOnly = "Equip" + Path.GetFileNameWithoutExtension(theModel);
                string filename = Path.GetFileName(theModel);
                string modelDir = Path.GetDirectoryName(theModel);

                AddResourcesDirectory(nameOnly, modelDir);

                //Entity ent = null;
                if (sceneMgr.HasEntity(nameOnly))
                {
                    sceneMgr.DestroyEntity(nameOnly);
                }

                var EquipedModel = sceneMgr.CreateEntity(nameOnly, filename, nameOnly);
                if (EquipEntities[(int)theSlot] != null)
                {
                    ModelEntity.DetachObjectFromBone(EquipEntities[(int)theSlot]);
                    // TODO: destroy
                    EquipEntities[(int)theSlot] = null;
                }

                EquipEntities[(int)theSlot] = EquipedModel;

                ModelEntity.AttachObjectToBone(boneName, EquipedModel);
                //ModelEntity.Skeleton.GetBone(boneName).

                // check for material textures
                foreach (var subMesh in EquipedModel.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();
                    }
                }
            }
        }
 private void SetEquipModel(string theModel, EquipWeaponSlot theSlot)
 {
     if (!string.IsNullOrEmpty(theModel))
     {
         mogreWin.SetEquipModel(theModel, theSlot);
     }
     this.Refresh();
     myEquips[(int)theSlot] = theModel;
     CheckEquips();
     // TODO: need this to force update of bone position/orient so that
     // attached objects get updated to current pose (not the bind pose)
     mogreWin.SetActiveAnimationTimePos(((float)this.trackBarAnimPosition.Value) / 100f + 0.001f);
     mogreWin.SetActiveAnimationTimePos(((float)this.trackBarAnimPosition.Value) / 100f);
 }
Example #3
0
 public bool HasWeaponSlot(EquipWeaponSlot theEqSlot)
 {
     if (ModelEntity != null && ModelEntity.HasSkeleton)
     {
         if (ModelEntity.Skeleton.HasBone(theEqSlot.ToString()))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
 private void SetEquipModel(string theModel, EquipWeaponSlot theSlot)
 {
     if (!string.IsNullOrEmpty(theModel))
     {
         mogreWin.SetEquipModel(theModel, theSlot);
     }
     this.Refresh();
     myEquips[(int)theSlot] = theModel;
     CheckEquips();
     // TODO: need this to force update of bone position/orient so that
     // attached objects get updated to current pose (not the bind pose)
     mogreWin.SetActiveAnimationTimePos(((float)this.trackBarAnimPosition.Value) / 100f + 0.001f);
     mogreWin.SetActiveAnimationTimePos(((float)this.trackBarAnimPosition.Value) / 100f);
 }
 public bool HasWeaponSlot(EquipWeaponSlot theEqSlot)
 {
     if (ModelEntity != null && ModelEntity.HasSkeleton)
     {
         if(ModelEntity.Skeleton.HasBone(theEqSlot.ToString())) return true;
         else return false;
     }
     else return false;
 }
        public void SetEquipModel(string theModel, EquipWeaponSlot theSlot)
        {
            if (ModelEntity!=null && ModelEntity.HasSkeleton)
            {
                string boneName = theSlot.ToString();

                string nameOnly = "Equip" + Path.GetFileNameWithoutExtension(theModel);
                string filename = Path.GetFileName(theModel);
                string modelDir = Path.GetDirectoryName(theModel);

                AddResourcesDirectory(nameOnly, modelDir);

                //Entity ent = null;
                if (sceneMgr.HasEntity(nameOnly))
                {
                    sceneMgr.DestroyEntity(nameOnly);
                }
                
                var EquipedModel = sceneMgr.CreateEntity(nameOnly, filename, nameOnly);
                if (EquipEntities[(int)theSlot] != null)
                {
                    ModelEntity.DetachObjectFromBone(EquipEntities[(int)theSlot]);
                    // TODO: destroy
                    EquipEntities[(int)theSlot] = null;
                }

                EquipEntities[(int)theSlot] = EquipedModel;

                ModelEntity.AttachObjectToBone(boneName, EquipedModel);
                //ModelEntity.Skeleton.GetBone(boneName).

                // check for material textures
                foreach (var subMesh in EquipedModel.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();
                }
            }
        }