Beispiel #1
0
        private void ChangeCharacter()
        {
            if (raceInfo == null)
            {
                return;
            }

            WowDatabase _wowDatabase = Engine.Instance.WowDatabase;
            string      path         = _wowDatabase.GetCharacterPath(raceInfo.ShortName, female, ModelEditorService.Instance.IsCharacterHD);
            M2SceneNode node         = ModelSceneService.Instance.SetMainM2SceneNode(path, false);

            if (node == null && ModelEditorService.Instance.IsCharacterHD)
            {
                path = _wowDatabase.GetCharacterPath(raceInfo.ShortName, female, false);
                node = ModelSceneService.Instance.SetMainM2SceneNode(path, false);
            }
            UpdateMaxCharFeature();
            UpdateCurrentCharFeature();
            UpdateStartOutfitClasses();
            SelectClass(classShortName, true);

            Player player = Client.Instance.GetPlayer();

            if (EngineService.Instance.IsGameMode && node != null && (node.Type == M2Type.MT_CHARACTER || node.Type == M2Type.MT_CREATRUE))
            {
                player.SetM2AsTarget(node, 15, (float)(Math.PI / 6.0f));
            }
            else
            {
                player.SetM2AsTarget(null, 15, (float)(Math.PI / 6.0f));
            }
        }
Beispiel #2
0
        public void UseStartOutfit(string shortname)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance == null)
                {
                    return;
                }

                int startOutfitId = GetStartOutfitId(shortname);
                appearance.LoadStartOutfitId(startOutfitId, shortname == "DEATHKNIGHT");

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                if (StartOutfitUpdated != null)
                {
                    StartOutfitUpdated.Invoke(this, node);
                }
            }
        }
        private void playExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            M2SceneNode      node    = ModelSceneService.Instance.MainM2SceneNode;
            AnimationContent content = ShellService.Instance.AnimationContent;
            int animIndex            = content.GetCurrentAnimaitonIndex();

            if (node == null || animIndex == -1 || Client.Instance.GetPlayer().GetRideNpcId() != 0)
            {
                return;
            }

            if (animIndex != node.AnimationPlayer.CurrentAnimationIndex ||
                node.AnimationPlayer.Loop != content._animationSelect._animationToolbar.Loop)
            {
                if (node.M2Fsm != null)
                {
                    node.M2Fsm.ResetState();
                }

                node.AnimationPlayer.Loop = content._animationSelect._animationToolbar.Loop;

                node.PlayAnimation((uint)animIndex, node.AnimationPlayer.Loop, 200);
            }

            node.AnimationPlayer.Resume();
        }
        void app_ApplicationLanguageChanged(object sender, Languages current)
        {
            if (statesView != null)
            {
                statesView.Filter = null;
            }

            States.Clear();

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                for (int i = 0; i < (int)E_M2_STATES.EMS_COUNT; ++i)
                {
                    if (node.IsStateValid((E_M2_STATES)i))
                    {
                        M2State s = new M2State();
                        s.State = (E_M2_STATES)i;
                        s.Name  = s.GetStateName(current);
                        States.Add(s);
                    }
                }
            }

            statesView = CollectionViewSource.GetDefaultView(States);

            FilterState();
        }
Beispiel #5
0
 public void SetWireFrame(M2SceneNode node)
 {
     if (node != null)
     {
         node.SetWireFrame(M2WireFrame);
     }
 }
Beispiel #6
0
        void _mapM2Names_MapM2_Selected(object sender, Entry entry)
        {
            FileADT adt = ModelSceneService.Instance.CurrentADT;

            if (adt == null)
            {
                return;
            }
            string      path = adt.GetM2FileName((uint)entry.Id, false);
            M2SceneNode node = ModelSceneService.Instance.SetMainM2SceneNode(path, false);

            if (node != null)
            {
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                node.BuildVisibleGeosets();

                //update property
                ShellService.Instance.PropertyContent.UpdateNormalM2Node(node);
            }

            Player player = Client.Instance.GetPlayer();

            player.SetM2AsTarget(null, 15, (float)(Math.PI / 6.0f));
        }
        public void UpdateProperties()
        {
            M2SceneNode  m2Node  = ModelSceneService.Instance.MainM2SceneNode;
            WMOSceneNode wmoNode = ModelSceneService.Instance.MainWMOSceneNode;

            _propertyGrid.SelectedObject = null;

            if (m2Node != null)
            {
                if (m2Node.Type == M2Type.MT_CHARACTER)
                {
                    UpdateCharacterNode(m2Node);
                }
                else if (m2Node.Type == M2Type.MT_CREATRUE)
                {
                    UpdateNpcNode(m2Node);
                }
                else
                {
                    UpdateNormalM2Node(m2Node);
                }
            }
            else if (wmoNode != null)
            {
                UpdateWmoNode(wmoNode);
            }
        }
Beispiel #8
0
        private void ExportObjExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            FolderBrowserDialog.FolderBrowserDialog dialog = new FolderBrowserDialog.FolderBrowserDialog
            {
                ShowEditBox  = true,
                BrowseShares = true
            };

            dialog.RootType = FolderBrowserDialog.RootType.Path;
            //dialog.RootPath = Engine.Instance.GetBaseDirectory();

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            string dirPath = dialog.SelectedPath;

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            bool success = mwTool.Instance.ExportM2SceneNodeToOBJ(node, dirPath);

            if (success)
            {
                NativeMethods.ShellExecute(
                    IntPtr.Zero,
                    "open",
                    "Explorer.exe",
                    dirPath,
                    "",
                    NativeMethods.ShowCommands.SW_NORMAL);
            }
        }
Beispiel #9
0
        private void ItemContent_ItemSelected(object sender, Item item)
        {
            int         slot = 0;
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                node.TakeItem(item.Id, out slot);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                if (node.SlotHasModel((E_CHAR_SLOTS)slot))
                {
                    if (slot == (int)E_CHAR_SLOTS.CS_HEAD)
                    {
                        node.BuildVisibleGeosets();
                    }
                }
                else
                {
                    node.UpdateCharacter();
                }

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
                ShellService.Instance.EquipmentsWindow.Update();
            }
        }
Beispiel #10
0
        private void ResetClothesAllExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            node.ResetSlot(E_CHAR_SLOTS.CS_HEAD);
            node.ResetSlot(E_CHAR_SLOTS.CS_SHOULDER);
            node.ResetSlot(E_CHAR_SLOTS.CS_SHIRT);
            node.ResetSlot(E_CHAR_SLOTS.CS_CHEST);
            node.ResetSlot(E_CHAR_SLOTS.CS_BELT);
            node.ResetSlot(E_CHAR_SLOTS.CS_PANTS);
            node.ResetSlot(E_CHAR_SLOTS.CS_BOOTS);
            node.ResetSlot(E_CHAR_SLOTS.CS_BRACERS);
            node.ResetSlot(E_CHAR_SLOTS.CS_GLOVES);
            node.ResetSlot(E_CHAR_SLOTS.CS_CAPE);
            node.ResetSlot(E_CHAR_SLOTS.CS_TABARD);

            node.UpdateCharacter();

            //update property
            ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

            if (ShellService.Instance.EquipmentsWindow.IsVisible)
            {
                ShellService.Instance.EquipmentsWindow.Update();
            }

            if (ShellService.Instance.EquipmentSelectWindow.IsVisible)
            {
                ShellService.Instance.EquipmentSelectWindow.Update();
            }
        }
        private bool LoadCharacter()
        {
            string      shortname    = Engine.Instance.WowDatabase.GetRaceName(raceId);
            WowDatabase _wowDatabase = Engine.Instance.WowDatabase;
            string      path         = _wowDatabase.GetCharacterPath(shortname, female, true);
            M2SceneNode node         = ModelSceneService.Instance.SetMainM2SceneNode(path, false);

            if (node == null)
            {
                path = _wowDatabase.GetCharacterPath(shortname, female, true);
                node = ModelSceneService.Instance.SetMainM2SceneNode(path, false);
            }

            if (node != null)
            {
                node.M2Instance.CharFeature = charFeature;
            }

            Player player = Client.Instance.GetPlayer();

            if (EngineService.Instance.IsGameMode && node != null &&
                (node.Type == M2Type.MT_CHARACTER || node.Type == M2Type.MT_CREATRUE))
            {
                player.SetM2AsTarget(node, 15, (float)(Math.PI / 6.0f));
            }
            else
            {
                player.SetM2AsTarget(null, 15, (float)(Math.PI / 6.0f));
            }

            return(node != null);
        }
        private void ResetClothesSlotExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            E_CHAR_SLOTS?slot = e.Parameter as E_CHAR_SLOTS?;
            M2SceneNode  node = ModelSceneService.Instance.MainM2SceneNode;

            if (slot != null)
            {
                node.ResetSlot(slot.Value);
                if (node.SlotHasModel(slot.Value))
                {
                    if (slot.Value == E_CHAR_SLOTS.CS_HEAD)
                    {
                        node.BuildVisibleGeosets();
                    }
                }
                else
                {
                    node.UpdateCharacter();
                }
            }

            //update property
            ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
            ShellService.Instance.EquipmentsWindow.Update();
        }
        private void M2ScaleDefault_Click(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                float scale = 1.0f;

                M2Move move = node.M2Move;
                if (move != null)
                {
                    move.Scale = new vector3df(scale, scale, scale);
                }
                else
                {
                    matrix4 mat = new matrix4(true);
                    node.GetRelativeTransformation(out mat);

                    matrix4 newMat = new matrix4(true);
                    newMat.RotationRadians = mat.RotationRadians;
                    newMat.Scale           = new vector3df(scale, scale, scale);
                    newMat.Translation     = mat.Translation;
                    node.SetRelativeTransformation(ref newMat);
                }

                node.Update(true);
            }
        }
        private void M2SliderScale_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                float scale = (float)e.NewValue;

                M2Move move = node.M2Move;
                if (move != null)
                {
                    move.Scale = new vector3df(scale, scale, scale);
                }
                else
                {
                    matrix4 mat = new matrix4(true);
                    node.GetRelativeTransformation(out mat);

                    matrix4 newMat = new matrix4(true);
                    newMat.RotationRadians = mat.RotationRadians;
                    newMat.Scale           = new vector3df(scale, scale, scale);
                    newMat.Translation     = mat.Translation;
                    node.SetRelativeTransformation(ref newMat);
                }

                node.Update(true);
            }
        }
Beispiel #15
0
        void _listView_PreviewDrop(object sender, DragEventArgs args)
        {
            args.Handled = true;

            string fileName = IsSingleFile(args);

            if (fileName == null)
            {
                return;
            }

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node == null)
            {
                return;
            }

            StreamReader reader = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string txt = reader.ReadLine();
                int    id;
                if (Int32.TryParse(txt, out id))
                {
                    int slot;
                    node.TakeItem(id, out slot);
                }
            }

            reader.Dispose();
            node.UpdateCharacter();
            SlotItems.GetAllSlotItems(node);
        }
Beispiel #16
0
        void _setSelect_Set_Selected(object sender, Set set)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance == null)
                {
                    return;
                }

                appearance.LoadSet(set.Id);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

                if (ShellService.Instance.EquipmentsWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentsWindow.Update();
                }

                if (ShellService.Instance.EquipmentSelectWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentSelectWindow.Update();
                }
            }
        }
Beispiel #17
0
        public void FromM2SceneNode(M2SceneNode node)
        {
            SFileM2 filem2 = node.FileM2;

            M2FileName     = filem2.name;
            M2LongFileName = filem2.longname;
            M2TextureNames = node.TextureNames;
        }
Beispiel #18
0
        public M2SceneNode SetMainM2SceneNode(string filename, bool npc)
        {
            if (Client.Instance.GetPlayer().GetRideNpcId() != 0)
            {
                Client.Instance.GetPlayer().RideOnModel(0, E_M2_STATES.EMS_STAND);
            }

            RemoveMainSceneNode();

            M2SceneNode node = Engine.Instance.SceneManager.AddM2SceneNode(filename, null, npc);

            if (node != null)
            {
                switch (node.Type)
                {
                case M2Type.MT_INTERFACE:
                {
                    if (node.M2Fsm != null)
                    {
                        node.M2Fsm.ResetState();
                    }
                    node.PlayAnimation("Stand", 0, true, 0);
                    node.SetCamera(0);
                }
                break;

                default:
                {
                    M2Move move = node.M2Move;
                    if (move != null)
                    {
                        move.Dir = new vector3df(0, 0, -1);
                    }
                    else
                    {
                        matrix4 mat = new matrix4(true);
                        mat.RotationDegrees = new vector3df(0, 90, 0);
                        node.SetRelativeTransformation(ref mat);
                    }

                    if (node.M2Fsm != null)
                    {
                        node.M2Fsm.ResetState();
                    }
                    node.PlayAnimation("Stand", 0, true, 0);
                }
                break;
                }
            }

            Engine.Instance.SceneManager.SetDebugM2SceneNode(node);

            mainM2SceneNode = node;

            RaiseMainM2SceneNodeChanged();

            return(node);
        }
        private void M2SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                node.ModelAlpha = (float)e.NewValue;
            }
        }
        private void loopCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                node.AnimationPlayer.Loop = false;
            }
        }
        void _stateSelect_State_Selected(object sender, M2State state)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.M2Fsm != null)
            {
                node.M2Fsm.ChangeState(state.State);
            }
        }
        private void menuModelOpacity_SubmenuOpened(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                m2SliderOpacity.Value = node.ModelAlpha;
            }
        }
        private void M2OpacityDefault_Click(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                node.ModelAlpha = 1.0f;
            }
        }
Beispiel #24
0
 public void ShowEditPart(M2SceneNode node)
 {
     if (node != null)
     {
         node.ShowEditPart(E_MODEL_EDIT_PART.EEP_MODEL, isShowModel);
         node.ShowEditPart(E_MODEL_EDIT_PART.EEP_PARTICLES, isShowParticles);
         node.ShowEditPart(E_MODEL_EDIT_PART.EEP_BOUNDINGBOX, isShowModelBoundingBox);
         node.ShowEditPart(E_MODEL_EDIT_PART.EEP_BONES, isShowBones);
         node.ShowEditPart(E_MODEL_EDIT_PART.EEP_ATTACHMENTPOINTS, isShowAttachmentPoints);
     }
 }
Beispiel #25
0
 public void SheathM2NodeWeapon(M2SceneNode node)
 {
     if (node != null)
     {
         M2Appearance appearance = node.M2Appearance;
         if (appearance != null)
         {
             appearance.SheathLeftHand = appearance.SheathRightHand = sheathWeapon;
         }
     }
 }
        private void ResetWeaponAllExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            node.ResetSlot(E_CHAR_SLOTS.CS_HAND_LEFT);
            node.ResetSlot(E_CHAR_SLOTS.CS_HAND_RIGHT);

            //update property
            ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
            ShellService.Instance.EquipmentsWindow.Update();
        }
Beispiel #27
0
        public void FromM2SceneNode(M2SceneNode node)
        {
            SFileM2 filem2 = node.FileM2;

            M2FileName      = filem2.name;
            M2LongFileName  = filem2.longname;
            M2TextureNames  = node.TextureNames;
            TexNpc1FileName = node.GetReplaceTextureFileName(E_MODEL_REPLACE_TEXTURE.EMRT_NPC1);
            TexNpc2FileName = node.GetReplaceTextureFileName(E_MODEL_REPLACE_TEXTURE.EMRT_NPC2);
            TexNpc3FileName = node.GetReplaceTextureFileName(E_MODEL_REPLACE_TEXTURE.EMRT_NPC3);
        }
        private void menuModelScale_SubmenuOpened(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                matrix4 mat = new matrix4(true);
                node.GetRelativeTransformation(out mat);
                m2SliderScale.Value = mat.Scale.X;
            }
        }
Beispiel #29
0
        public void Update()
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node == null)
            {
                return;
            }

            SlotItems.GetAllSlotItems(node);
        }
        private void SheathWeaponExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ModelEditorService.Instance.SheathWeapon = !ModelEditorService.Instance.SheathWeapon;

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null)
            {
                ModelEditorService.Instance.SheathM2NodeWeapon(node);
            }
        }