Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / skeleton_scale_dlg.h
blobe2d205ac1ef139ee23604a08aeac0d6efbb5e123
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #if !defined(AFX_SKELETON_SCALE_DLG_H__4684D63E_9A55_47E7_BE43_F5C4CD86F211__INCLUDED_)
18 #define AFX_SKELETON_SCALE_DLG_H__4684D63E_9A55_47E7_BE43_F5C4CD86F211__INCLUDED_
20 #if _MSC_VER > 1000
21 #pragma once
22 #endif // _MSC_VER > 1000
23 // skeleton_scale_dlg.h : header file
26 #include "nel/misc/smart_ptr.h"
28 namespace NL3D
30 class CSkeletonModel;
33 /////////////////////////////////////////////////////////////////////////////
34 // CSkeletonScaleDlg dialog
36 // Define the decimal precision
37 #define NL_SSD_SCALE_PRECISION 1000
39 class CSkeletonScaleDlg : public CDialog
41 // Construction
42 public:
43 CSkeletonScaleDlg(CObjectViewer *viewer, CWnd* pParent = NULL); // standard constructor
44 ~CSkeletonScaleDlg();
46 // Dialog Data
47 //{{AFX_DATA(CSkeletonScaleDlg)
48 enum { IDD = IDD_SKELETON_SCALE_DLG };
49 CSliderCtrl _SliderSkinZ;
50 CSliderCtrl _SliderSkinY;
51 CSliderCtrl _SliderSkinX;
52 CSliderCtrl _SliderBoneZ;
53 CSliderCtrl _SliderBoneY;
54 CSliderCtrl _SliderBoneX;
55 CListBox _BoneList;
56 CString _StaticFileName;
57 CString _EditBoneSX;
58 CString _EditBoneSY;
59 CString _EditBoneSZ;
60 CString _EditSkinSX;
61 CString _EditSkinSY;
62 CString _EditSkinSZ;
63 CStatic _StaticScaleMarkerBoneSX;
64 CStatic _StaticScaleMarkerBoneSY;
65 CStatic _StaticScaleMarkerBoneSZ;
66 CStatic _StaticScaleMarkerSkinSX;
67 CStatic _StaticScaleMarkerSkinSY;
68 CStatic _StaticScaleMarkerSkinSZ;
69 //}}AFX_DATA
72 // Overrides
73 // ClassWizard generated virtual function overrides
74 //{{AFX_VIRTUAL(CSkeletonScaleDlg)
75 protected:
76 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
77 //}}AFX_VIRTUAL
80 public:
81 // call when a skeleton is loaded. set NULL when released
82 void setSkeletonToEdit(NL3D::CSkeletonModel *skel, const std::string &fileName);
84 // call each frame to display scaled bboxes around selected bones
85 void drawSelection();
87 // Implementation
88 protected:
90 // Generated message map functions
91 //{{AFX_MSG(CSkeletonScaleDlg)
92 afx_msg void OnDestroy();
93 virtual BOOL OnInitDialog();
94 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
95 afx_msg void OnReleasedcaptureSsdSliderBoneSx(NMHDR* pNMHDR, LRESULT* pResult);
96 afx_msg void OnReleasedcaptureSsdSliderBoneSy(NMHDR* pNMHDR, LRESULT* pResult);
97 afx_msg void OnReleasedcaptureSsdSliderBoneSz(NMHDR* pNMHDR, LRESULT* pResult);
98 afx_msg void OnReleasedcaptureSsdSliderSkinSx(NMHDR* pNMHDR, LRESULT* pResult);
99 afx_msg void OnReleasedcaptureSsdSliderSkinSy(NMHDR* pNMHDR, LRESULT* pResult);
100 afx_msg void OnReleasedcaptureSsdSliderSkinSz(NMHDR* pNMHDR, LRESULT* pResult);
101 afx_msg void OnChangeSsdEditBoneSx();
102 afx_msg void OnChangeSsdEditBoneSy();
103 afx_msg void OnChangeSsdEditBoneSz();
104 afx_msg void OnChangeSsdEditSkinSx();
105 afx_msg void OnChangeSsdEditSkinSy();
106 afx_msg void OnChangeSsdEditSkinSz();
107 afx_msg void OnKillfocusSsdEditBoneSx();
108 afx_msg void OnKillfocusSsdEditBoneSy();
109 afx_msg void OnKillfocusSsdEditBoneSz();
110 afx_msg void OnKillfocusSsdEditSkinSx();
111 afx_msg void OnKillfocusSsdEditSkinSy();
112 afx_msg void OnKillfocusSsdEditSkinSz();
113 afx_msg void OnSetfocusSsdEditBoneSx();
114 afx_msg void OnSetfocusSsdEditBoneSy();
115 afx_msg void OnSetfocusSsdEditBoneSz();
116 afx_msg void OnSetfocusSsdEditSkinSx();
117 afx_msg void OnSetfocusSsdEditSkinSy();
118 afx_msg void OnSetfocusSsdEditSkinSz();
119 afx_msg void OnSelchangeSsdList();
120 afx_msg void OnSsdButtonUndo();
121 afx_msg void OnSsdButtonRedo();
122 afx_msg void OnSsdButtonSave();
123 afx_msg void OnSsdButtonSaveas();
124 afx_msg void OnSsdButtonMirror();
125 afx_msg void OnSsdButtonSaveScale();
126 afx_msg void OnSsdButtonLoadScale();
127 afx_msg void OnClose();
128 //}}AFX_MSG
129 DECLARE_MESSAGE_MAP()
131 private:
132 enum TScaleId
134 SidBoneX= 0,
135 SidBoneY,
136 SidBoneZ,
137 SidSkinX,
138 SidSkinY,
139 SidSkinZ,
140 SidCount,
141 SidNone= SidCount
144 private:
145 CObjectViewer *_ObjViewer;
146 NLMISC::CRefPtr<NL3D::CSkeletonModel> _SkeletonModel;
147 std::string _SkeletonFileName;
148 TScaleId _SliderEdited;
149 bool _SaveDirty;
151 // A mirror to the list of bone
152 struct CBoneMirror
154 CBoneMirror()
156 SkinScale= BoneScale= NLMISC::CVector(1.f,1.f,1.f);
157 Selected= false;
160 // Current Scale * NL_SSD_SCALE_PRECISION, and rounded
161 NLMISC::CVector SkinScale;
162 NLMISC::CVector BoneScale;
163 // If the bone is selected in the multi List
164 bool Selected;
166 typedef std::vector<CBoneMirror> TBoneMirrorArray;
167 // The current bones
168 TBoneMirrorArray _Bones;
169 // Backup of bones when slider start moving
170 TBoneMirrorArray _BkupBones;
173 // For selection drawing, the local bbox
174 std::vector<NLMISC::CAABBox> _BoneBBoxes;
175 bool _BoneBBoxNeedRecompute;
178 // points to controls for each ScaleId
179 CSliderCtrl *_ScaleSliders[SidCount];
180 CString *_ScaleEdits[SidCount];
181 CStatic *_StaticScaleMarkers[SidCount];
183 void applyScaleSlider(sint scrollValue);
184 void onSliderReleased(TScaleId sid);
185 void applyMirrorToSkeleton();
186 void applySkeletonToMirror();
187 void refreshTextViews();
188 void refreshTextViewWithScale(TScaleId sid, float scale, float diff);
189 void roundClampScale(NLMISC::CVector &v) const;
190 TScaleId getScaleIdFromSliderCtrl(CSliderCtrl *sliderCtrl) const;
191 TScaleId getScaleIdFromEditId(UINT ctrlId) const;
192 void onSelectEditText(UINT ctrlId);
193 void onChangeEditText(UINT ctrlId);
194 void onQuitEditText(UINT ctrlId);
195 void updateScalesFromText(UINT ctrlId);
196 void applySelectionToView();
197 void refreshUndoRedoView();
198 bool saveCurrentInStream(NLMISC::IStream &f);
199 void refreshSaveButton();
200 sint getBoneForMirror(uint boneId, std::string &mirrorName);
201 bool saveSkelScaleInStream(NLMISC::IStream &f);
202 bool loadSkelScaleFromStream(NLMISC::IStream &f);
204 /// \name undo/redo mgt
205 // @{
206 enum {MaxUndoRedo= 100};
207 std::deque<TBoneMirrorArray> _UndoQueue;
208 std::deque<TBoneMirrorArray> _RedoQueue;
210 // bkup the current _Bones in the undo queue, and clear the redo. dirtSave indicate the skel need saving
211 // NB: compare precState with _Bones. if same, then no-op!
212 void pushUndoState(const TBoneMirrorArray &precState, bool dirtSave);
213 // undo the last change, and store it in the redo queue
214 void undo();
215 // redo the last undoed change, and restore it in the undo queue
216 void redo();
218 // @}
221 //{{AFX_INSERT_LOCATION}}
222 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
224 #endif // !defined(AFX_SKELETON_SCALE_DLG_H__4684D63E_9A55_47E7_BE43_F5C4CD86F211__INCLUDED_)