1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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_
22 #endif // _MSC_VER > 1000
23 // skeleton_scale_dlg.h : header file
26 #include "nel/misc/smart_ptr.h"
33 /////////////////////////////////////////////////////////////////////////////
34 // CSkeletonScaleDlg dialog
36 // Define the decimal precision
37 #define NL_SSD_SCALE_PRECISION 1000
39 class CSkeletonScaleDlg
: public CDialog
43 CSkeletonScaleDlg(CObjectViewer
*viewer
, CWnd
* pParent
= NULL
); // standard constructor
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
;
56 CString _StaticFileName
;
63 CStatic _StaticScaleMarkerBoneSX
;
64 CStatic _StaticScaleMarkerBoneSY
;
65 CStatic _StaticScaleMarkerBoneSZ
;
66 CStatic _StaticScaleMarkerSkinSX
;
67 CStatic _StaticScaleMarkerSkinSY
;
68 CStatic _StaticScaleMarkerSkinSZ
;
73 // ClassWizard generated virtual function overrides
74 //{{AFX_VIRTUAL(CSkeletonScaleDlg)
76 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
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
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();
129 DECLARE_MESSAGE_MAP()
145 CObjectViewer
*_ObjViewer
;
146 NLMISC::CRefPtr
<NL3D::CSkeletonModel
> _SkeletonModel
;
147 std::string _SkeletonFileName
;
148 TScaleId _SliderEdited
;
151 // A mirror to the list of bone
156 SkinScale
= BoneScale
= NLMISC::CVector(1.f
,1.f
,1.f
);
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
166 typedef std::vector
<CBoneMirror
> TBoneMirrorArray
;
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
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
215 // redo the last undoed change, and restore it in the undo queue
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_)