00001
00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024
00025
00026 #include "std_afx.h"
00027 #include "object_viewer.h"
00028 #include "main_dlg.h"
00029 #include <nel/3d/channel_mixer.h>
00030
00031 #ifdef _DEBUG
00032 #define new DEBUG_NEW
00033 #undef THIS_FILE
00034 static char THIS_FILE[] = __FILE__;
00035 #endif
00036
00037 using namespace NLMISC;
00038 using namespace NL3D;
00039
00041
00042
00043
00044 CMainDlg::CMainDlg(CObjectViewer* main, CWnd* pParent )
00045 : CDialog(CMainDlg::IDD, pParent)
00046 {
00047
00048
00049
00050 Main=main;
00051 }
00052
00053
00054 void CMainDlg::DoDataExchange(CDataExchange* pDX)
00055 {
00056 CDialog::DoDataExchange(pDX);
00057
00058
00059
00060 }
00061
00062
00063 BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
00064
00065 ON_WM_DESTROY()
00066
00067 END_MESSAGE_MAP()
00068
00070
00071
00072 BOOL CMainDlg::OnInitDialog()
00073 {
00074 CDialog::OnInitDialog();
00075
00076
00077 RECT rect;
00078
00079
00080 for (uint s=0; s<CChannelMixer::NumAnimationSlot; s++)
00081 {
00082
00083 BOOL initialized=Slots[s].Create (IDD_SLOT, this);
00084
00085
00086 Slots[s].init (s, AnimationSet, Main);
00087 Slots[s].GetClientRect (&rect);
00088 Slots[s].SetWindowPos( NULL, 0, s*(rect.bottom-rect.top), 0, 0, SWP_NOSIZE|SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_SHOWWINDOW);
00089 Slots[s].setAnimation (0, NULL, NULL);
00090 }
00091
00092
00093 RECT client;
00094 RECT window;
00095 GetClientRect (&client);
00096 GetWindowRect (&window);
00097 SetWindowPos( NULL, 0, 0, rect.right-rect.left+window.right-window.left-client.right+client.left,
00098 NL3D::CChannelMixer::NumAnimationSlot*(rect.bottom-rect.top)+window.bottom-window.top-client.bottom+client.top,
00099 SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_SHOWWINDOW);
00100
00101 return TRUE;
00102
00103 }
00104
00105 void CMainDlg::init (NL3D::CAnimationSet* animationSet)
00106 {
00107 AnimationSet=animationSet;
00108 }
00109
00110 void CMainDlg::setAnimTime (float animStart, float animEnd)
00111 {
00112
00113 for (uint s=0; s<CChannelMixer::NumAnimationSlot; s++)
00114 Slots[s].setAnimTime (animStart, animEnd);
00115 }
00116
00117 void CMainDlg::getSlot ()
00118 {
00119 for (uint id=0; id<NL3D::CChannelMixer::NumAnimationSlot; id++)
00120 {
00121
00122 Slots[id].UpdateData();
00123
00124
00125 if (Slots[id].isEmpty ()||!Slots[id].enable)
00126 Playlist.setAnimation (id, CAnimationPlaylist::empty);
00127 else
00128 Playlist.setAnimation (id, Slots[id].AnimationId);
00129
00130
00131 if (Slots[id].SkeletonWeightTemplate)
00132 Playlist.setSkeletonWeight (id, Slots[id].SkeletonWeightId, Slots[id].SkeletonWeightInverted!=0);
00133 else
00134 Playlist.setSkeletonWeight (id, CAnimationPlaylist::empty, false);
00135
00136
00137 Playlist.setTimeOrigin (id, Slots[id].getTimeOffset());
00138 Playlist.setSpeedFactor (id, Slots[id].SpeedFactor);
00139 Playlist.setStartWeight (id, Slots[id].StartBlend, Slots[id].getStartTime());
00140 Playlist.setEndWeight (id, Slots[id].EndBlend, Slots[id].getEndTime());
00141 Playlist.setWeightSmoothness (id, Slots[id].Smoothness);
00142
00143
00144 switch (Slots[id].ClampMode)
00145 {
00146 case 0:
00147 Playlist.setWrapMode (id, CAnimationPlaylist::Clamp);
00148 break;
00149 case 1:
00150 Playlist.setWrapMode (id, CAnimationPlaylist::Repeat);
00151 break;
00152 case 2:
00153 Playlist.setWrapMode (id, CAnimationPlaylist::Disable);
00154 break;
00155 }
00156 }
00157 }
00158
00159
00160 void CMainDlg::setSlot ()
00161 {
00162 for (uint id=0; id<NL3D::CChannelMixer::NumAnimationSlot; id++)
00163 {
00164
00165 Slots[id].UpdateData();
00166
00167
00168 uint animation=Playlist.getAnimation (id);
00169 if (animation<AnimationSet->getNumAnimation())
00170 Slots[id].setAnimation (animation, AnimationSet->getAnimation (animation), AnimationSet->getAnimationName (animation).c_str());
00171
00172
00173 bool inverted;
00174 uint skeleton=Playlist.getSkeletonWeight (id, inverted);
00175 Slots[id].SkeletonWeightInverted=inverted;
00176 if (skeleton<AnimationSet->getNumSkeletonWeight())
00177 Slots[id].setSkeletonTemplateWeight (skeleton, AnimationSet->getSkeletonWeight (skeleton), AnimationSet->getSkeletonWeightName (skeleton).c_str());
00178
00179
00180 Slots[id].Offset=(int)(Playlist.getTimeOrigin (id)*Main->getFrameRate());
00181 Slots[id].SpeedFactor=Playlist.getSpeedFactor (id);
00182 float time;
00183 Slots[id].StartBlend=Playlist.getStartWeight (id, time);
00184 Slots[id].StartTime=(int)(time*Main->getFrameRate());
00185 Slots[id].EndBlend=Playlist.getEndWeight (id, time);
00186 Slots[id].EndTime=(int)(time*Main->getFrameRate());
00187 Slots[id].Smoothness=Playlist.getWeightSmoothness (id);
00188
00189
00190 switch (Playlist.getWrapMode (id))
00191 {
00192 case CAnimationPlaylist::Clamp:
00193 Slots[id].ClampMode=0;
00194 break;
00195 case CAnimationPlaylist::Repeat:
00196 Slots[id].ClampMode=1;
00197 break;
00198 case CAnimationPlaylist::Disable:
00199 Slots[id].ClampMode=2;
00200 break;
00201 }
00202 Slots[id].UpdateData(FALSE);
00203 Slots[id].updateScrollBar ();
00204 }
00205 }
00206
00207 void CMainDlg::OnDestroy()
00208 {
00209 setRegisterWindowState (this, REGKEY_OBJ_VIEW_SLOT_DLG);
00210
00211 CDialog::OnDestroy();
00212
00213
00214
00215 }