# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

slot_dlg.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #include "std_afx.h"
00027 #include "object_viewer.h"
00028 #include "select_string.h"
00029 #include "slot_dlg.h"
00030 #include <nel/misc/common.h>
00031 
00032 #ifdef _DEBUG
00033 #define new DEBUG_NEW
00034 #undef THIS_FILE
00035 static char THIS_FILE[] = __FILE__;
00036 #endif
00037 
00038 #define DELTA_BLEND 0.1f
00039 #define DELTA_TIME (getTimeIncrement ())
00040 #define DELTA_MUL 0.1f
00041 
00042 using namespace NLMISC;
00043 using namespace NL3D;
00044 
00046 // CSlotDlg dialog
00047 
00048 
00049 CSlotDlg::CSlotDlg(CWnd* pParent /*=NULL*/)
00050         : CDialog(CSlotDlg::IDD, pParent)
00051 {
00052         //{{AFX_DATA_INIT(CSlotDlg)
00053         EndBlend = 1.0f;
00054         Smoothness = 0.0f;
00055         SpeedFactor = 1.0f;
00056         StartBlend = 1.0f;
00057         ClampMode = 0;
00058         SkeletonWeightInverted = FALSE;
00059         Offset = 0;
00060         StartTime = 0;
00061         EndTime = 0;
00062         StartAnimTime=0.f;
00063         EndAnimTime=1.f;
00064         enable = TRUE;
00065         //}}AFX_DATA_INIT
00066         AnimationSet=NULL;
00067         Animation=NULL;
00068         SkeletonWeightTemplate=NULL;
00069         MainDlg=NULL;
00070 }
00071 
00072 void CSlotDlg::init (uint id, NL3D::CAnimationSet* animationSet, CObjectViewer* mainDlg)
00073 {
00074         AnimationSet=animationSet;
00075         Id=id;
00076         MainDlg=mainDlg;
00077 }
00078 
00079 void CSlotDlg::DoDataExchange(CDataExchange* pDX)
00080 {
00081         CDialog::DoDataExchange(pDX);
00082         //{{AFX_DATA_MAP(CSlotDlg)
00083         DDX_Control(pDX, IDC_INVERT_SKELETON_WEIGHT, InvertSkeletonWeightCtrl);
00084         DDX_Control(pDX, IDC_ALIGN_BLEND, AlignBlendCtrl);
00085         DDX_Control(pDX, IDC_CLAMP, ClampCtrl);
00086         DDX_Control(pDX, IDC_SCROLLBAR, ScrollBarCtrl);
00087         DDX_Control(pDX, IDC_OFFSET_SPIN, OffsetSpinCtrl);
00088         DDX_Control(pDX, IDC_OFFSET, OffsetCtrl);
00089         DDX_Control(pDX, IDC_START_TIME_SPIN, StartTimeSpinCtrl);
00090         DDX_Control(pDX, IDC_START_BLEND_SPIN, StartBlendSpinCtrl);
00091         DDX_Control(pDX, IDC_SPEED_FACTOR_SPIN, SpeedFactorSpinCtrl);
00092         DDX_Control(pDX, IDC_SMOOTHNESS_SPIN, SmoothnessSpinCtrl);
00093         DDX_Control(pDX, IDC_END_TIME_SPIN, EndTimeSpinCtrl);
00094         DDX_Control(pDX, IDC_END_BLEND_SPIN, EndBlendSpinCtrl);
00095         DDX_Control(pDX, IDC_START_TIME, StartTimeCtrl);
00096         DDX_Control(pDX, IDC_START_BLEND, StartBlendCtrl);
00097         DDX_Control(pDX, IDC_SPEED_FACTOR, SpeddFactorCtrl);
00098         DDX_Control(pDX, IDC_SMOOTHNESS, SmoothnessCtrl);
00099         DDX_Control(pDX, IDC_END_TIME, EndTimeCtrl);
00100         DDX_Control(pDX, IDC_END_BLEND, EndBlendCtrl);
00101         DDX_Text(pDX, IDC_END_BLEND, EndBlend);
00102         DDX_Text(pDX, IDC_SMOOTHNESS, Smoothness);
00103         DDV_MinMaxFloat(pDX, Smoothness, 0.f, 1.f);
00104         DDX_Text(pDX, IDC_SPEED_FACTOR, SpeedFactor);
00105         DDV_MinMaxFloat(pDX, SpeedFactor, 1.e-002f, 100.f);
00106         DDX_Text(pDX, IDC_START_BLEND, StartBlend);
00107         DDV_MinMaxFloat(pDX, StartBlend, 0.f, 1.f);
00108         DDX_Radio(pDX, IDC_CLAMP, ClampMode);
00109         DDX_Check(pDX, IDC_INVERT_SKELETON_WEIGHT, SkeletonWeightInverted);
00110         DDX_Text(pDX, IDC_OFFSET, Offset);
00111         DDX_Text(pDX, IDC_START_TIME, StartTime);
00112         DDX_Text(pDX, IDC_END_TIME, EndTime);
00113         DDX_Check(pDX, IDC_ENABLE, enable);
00114         //}}AFX_DATA_MAP
00115 }
00116 
00117 
00118 BEGIN_MESSAGE_MAP(CSlotDlg, CDialog)
00119         //{{AFX_MSG_MAP(CSlotDlg)
00120         ON_WM_PAINT()
00121         ON_NOTIFY(UDN_DELTAPOS, IDC_END_BLEND_SPIN, OnDeltaposEndBlendSpin)
00122         ON_NOTIFY(UDN_DELTAPOS, IDC_END_TIME_SPIN, OnDeltaposEndTimeSpin)
00123         ON_NOTIFY(UDN_DELTAPOS, IDC_SMOOTHNESS_SPIN, OnDeltaposSmoothnessSpin)
00124         ON_NOTIFY(UDN_DELTAPOS, IDC_SPEED_FACTOR_SPIN, OnDeltaposSpeedFactorSpin)
00125         ON_NOTIFY(UDN_DELTAPOS, IDC_START_BLEND_SPIN, OnDeltaposStartBlendSpin)
00126         ON_NOTIFY(UDN_DELTAPOS, IDC_START_TIME_SPIN, OnDeltaposStartTimeSpin)
00127         ON_EN_CHANGE(IDC_END_BLEND, OnChangeEndBlend)
00128         ON_EN_CHANGE(IDC_END_TIME, OnChangeEndTime)
00129         ON_EN_CHANGE(IDC_SMOOTHNESS, OnChangeSmoothness)
00130         ON_EN_CHANGE(IDC_SPEED_FACTOR, OnChangeSpeedFactor)
00131         ON_EN_CHANGE(IDC_START_BLEND, OnChangeStartBlend)
00132         ON_EN_CHANGE(IDC_START_TIME, OnChangeStartTime)
00133         ON_BN_CLICKED(IDC_SET_ANIMATION, OnSetAnimation)
00134         ON_BN_CLICKED(IDC_SET_SKELETON, OnSetSkeleton)
00135         ON_EN_CHANGE(IDC_OFFSET, OnChangeOffset)
00136         ON_NOTIFY(UDN_DELTAPOS, IDC_OFFSET_SPIN, OnDeltaposOffsetSpin)
00137         ON_WM_HSCROLL()
00138         ON_BN_CLICKED(IDC_CLAMP, OnClamp)
00139         ON_BN_CLICKED(IDC_REPEAT, OnRepeat)
00140         ON_BN_CLICKED(IDC_DISABLE, OnDisable)
00141         ON_BN_CLICKED(IDC_ALIGN_BLEND, OnAlignBlend)
00142         ON_WM_DESTROY()
00143         //}}AFX_MSG_MAP
00144 END_MESSAGE_MAP()
00145 
00147 // CSlotDlg message handlers
00148 
00149 BOOL CSlotDlg::OnInitDialog() 
00150 {
00151         CDialog::OnInitDialog();
00152         
00153         // Init the blend window
00154         setWindowName ();
00155         
00156         return TRUE;  // return TRUE unless you set the focus to a control
00157                       // EXCEPTION: OCX Property Pages should return FALSE
00158 }
00159 
00160 // ***************************************************************************
00161 
00162 void CSlotDlg::OnPaint() 
00163 {
00164         //CPaintDC dc(this); // device context for painting
00165         PAINTSTRUCT paint;
00166         CDC* pDc=BeginPaint(&paint);
00167         
00168         // TODO: Add your message handler code here
00169         // Draw the blend
00170         RECT rect;
00171         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&rect);
00172         ScreenToClient (&rect);
00173         Blend.OnPaint (rect, pDc, StartBlend, EndBlend, (float)StartTime, (float)EndTime, 
00174                 Smoothness, StartAnimTime, EndAnimTime, !isEmpty());
00175         
00176         // Do not call CDialog::OnPaint() for painting messages
00177         EndPaint(&paint);
00178 }
00179 
00180 // ***************************************************************************
00181 
00182 void CSlotDlg::OnDeltaposEndBlendSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00183 {
00184         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00185         // TODO: Add your control notification handler code here
00186         
00187         *pResult = 0;
00188 
00189         UpdateData ();
00190 
00191         if (pNMUpDown->iDelta<0)
00192                 EndBlend+=DELTA_BLEND;
00193         if (pNMUpDown->iDelta>0)
00194                 EndBlend-=DELTA_BLEND;
00195         clamp (EndBlend, 0.f, 1.f);
00196 
00197         UpdateData (FALSE);
00198 
00199         RECT bar;
00200         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00201         ScreenToClient (&bar);
00202         InvalidateRect (&bar);
00203 }
00204 
00205 // ***************************************************************************
00206 
00207 void CSlotDlg::OnDeltaposEndTimeSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00208 {
00209         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00210         // TODO: Add your control notification handler code here
00211         
00212         *pResult = 0;
00213 
00214         UpdateData ();
00215 
00216         if (pNMUpDown->iDelta<0)
00217                 EndTime++;
00218         if (pNMUpDown->iDelta>0)
00219                 EndTime--;
00220         clamp (EndTime, (int)StartAnimTime, (int)EndAnimTime);
00221         if (EndTime<StartTime)
00222                 StartTime=EndTime;
00223 
00224         UpdateData (FALSE);
00225 
00226         RECT bar;
00227         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00228         ScreenToClient (&bar);
00229         InvalidateRect (&bar);
00230 }
00231 
00232 // ***************************************************************************
00233 
00234 void CSlotDlg::OnDeltaposSmoothnessSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00235 {
00236         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00237         // TODO: Add your control notification handler code here
00238         
00239         *pResult = 0;
00240 
00241         UpdateData ();
00242 
00243         if (pNMUpDown->iDelta<0)
00244                 Smoothness+=DELTA_BLEND;
00245         if (pNMUpDown->iDelta>0)
00246                 Smoothness-=DELTA_BLEND;
00247         clamp (Smoothness, 0.f, 1.f);
00248 
00249         UpdateData (FALSE);
00250 
00251         RECT bar;
00252         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00253         ScreenToClient (&bar);
00254         InvalidateRect (&bar);
00255 }
00256 
00257 // ***************************************************************************
00258 
00259 void CSlotDlg::OnDeltaposSpeedFactorSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00260 {
00261         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00262         // TODO: Add your control notification handler code here
00263         
00264         *pResult = 0;
00265 
00266         UpdateData ();
00267 
00268         if (pNMUpDown->iDelta<0)
00269                 SpeedFactor+=DELTA_MUL;
00270         if (pNMUpDown->iDelta>0)
00271                 SpeedFactor-=DELTA_MUL;
00272         clamp (SpeedFactor, 0.01f, 100.f);
00273 
00274         UpdateData (FALSE);
00275 
00276         validateTime ();
00277         updateScrollBar ();
00278 
00279         RECT bar;
00280         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00281         ScreenToClient (&bar);
00282         InvalidateRect (&bar);
00283 }
00284 
00285 // ***************************************************************************
00286 
00287 void CSlotDlg::OnDeltaposStartBlendSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00288 {
00289         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00290         // TODO: Add your control notification handler code here
00291         
00292         *pResult = 0;
00293 
00294         UpdateData ();
00295 
00296         if (pNMUpDown->iDelta<0)
00297                 StartBlend+=DELTA_BLEND;
00298         if (pNMUpDown->iDelta>0)
00299                 StartBlend-=DELTA_BLEND;
00300         clamp (StartBlend, 0.f, 1.f);
00301 
00302         UpdateData (FALSE);
00303         
00304         RECT bar;
00305         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00306         ScreenToClient (&bar);
00307         InvalidateRect (&bar);
00308 }
00309 
00310 // ***************************************************************************
00311 
00312 void CSlotDlg::OnDeltaposStartTimeSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00313 {
00314         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00315         // TODO: Add your control notification handler code here
00316         
00317         *pResult = 0;
00318 
00319         UpdateData ();
00320 
00321         if (pNMUpDown->iDelta<0)
00322                 StartTime++;
00323         if (pNMUpDown->iDelta>0)
00324                 StartTime--;
00325         clamp (StartTime, (int)StartAnimTime, (int)EndAnimTime);
00326         if (EndTime<StartTime)
00327                 EndTime=StartTime;
00328 
00329         UpdateData (FALSE);
00330         
00331         RECT bar;
00332         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00333         ScreenToClient (&bar);
00334         InvalidateRect (&bar);
00335 }
00336 
00337 // ***************************************************************************
00338 
00339 void CSlotDlg::OnChangeEndBlend() 
00340 {
00341         // TODO: If this is a RICHEDIT control, the control will not
00342         // send this notification unless you override the CDialog::OnInitDialog()
00343         // function and call CRichEditCtrl().SetEventMask()
00344         // with the ENM_CHANGE flag ORed into the mask.
00345         
00346         // TODO: Add your control notification handler code here
00347         UpdateData ();
00348 
00349         clamp (EndBlend, 0.f, 1.f);
00350 
00351         UpdateData (FALSE);
00352 
00353         RECT bar;
00354         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00355         ScreenToClient (&bar);
00356         InvalidateRect (&bar);
00357 }
00358 
00359 // ***************************************************************************
00360 
00361 void CSlotDlg::OnChangeEndTime() 
00362 {
00363         // TODO: If this is a RICHEDIT control, the control will not
00364         // send this notification unless you override the CDialog::OnInitDialog()
00365         // function and call CRichEditCtrl().SetEventMask()
00366         // with the ENM_CHANGE flag ORed into the mask.
00367         
00368         // TODO: Add your control notification handler code here
00369         UpdateData ();
00370 
00371         clamp (EndTime, (int)StartAnimTime, (int)EndAnimTime);
00372         if (EndTime<StartTime)
00373                 StartTime=EndTime;
00374 
00375         UpdateData (FALSE);
00376 
00377         RECT bar;
00378         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00379         ScreenToClient (&bar);
00380         InvalidateRect (&bar);
00381 }
00382 
00383 // ***************************************************************************
00384 
00385 void CSlotDlg::OnChangeSmoothness() 
00386 {
00387         // TODO: If this is a RICHEDIT control, the control will not
00388         // send this notification unless you override the CDialog::OnInitDialog()
00389         // function and call CRichEditCtrl().SetEventMask()
00390         // with the ENM_CHANGE flag ORed into the mask.
00391         
00392         // TODO: Add your control notification handler code here
00393         UpdateData ();
00394 
00395         clamp (Smoothness, 0.f, 1.f);
00396 
00397         UpdateData (FALSE);
00398 
00399         RECT bar;
00400         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00401         ScreenToClient (&bar);
00402         InvalidateRect (&bar);
00403 }
00404 
00405 // ***************************************************************************
00406 
00407 void CSlotDlg::OnChangeSpeedFactor() 
00408 {
00409         // TODO: If this is a RICHEDIT control, the control will not
00410         // send this notification unless you override the CDialog::OnInitDialog()
00411         // function and call CRichEditCtrl().SetEventMask()
00412         // with the ENM_CHANGE flag ORed into the mask.
00413         
00414         // TODO: Add your control notification handler code here
00415         UpdateData ();
00416 
00417         clamp (SpeedFactor, 0.01f, 100.f);
00418 
00419         UpdateData (FALSE);
00420         validateTime ();
00421         updateScrollBar ();
00422 }
00423 
00424 // ***************************************************************************
00425 
00426 void CSlotDlg::OnChangeStartBlend() 
00427 {
00428         // TODO: If this is a RICHEDIT control, the control will not
00429         // send this notification unless you override the CDialog::OnInitDialog()
00430         // function and call CRichEditCtrl().SetEventMask()
00431         // with the ENM_CHANGE flag ORed into the mask.
00432         
00433         // TODO: Add your control notification handler code here
00434         UpdateData ();
00435 
00436         clamp (StartBlend, 0.f, 1.f);
00437 
00438         UpdateData (FALSE);
00439 
00440         RECT bar;
00441         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00442         ScreenToClient (&bar);
00443         InvalidateRect (&bar);
00444 }
00445 
00446 // ***************************************************************************
00447 
00448 void CSlotDlg::OnChangeStartTime() 
00449 {
00450         // TODO: If this is a RICHEDIT control, the control will not
00451         // send this notification unless you override the CDialog::OnInitDialog()
00452         // function and call CRichEditCtrl().SetEventMask()
00453         // with the ENM_CHANGE flag ORed into the mask.
00454         
00455         // TODO: Add your control notification handler code here
00456         UpdateData ();
00457 
00458         clamp (StartTime, (int)StartAnimTime, (int)EndAnimTime);
00459         if (EndTime<StartTime)
00460                 EndTime=StartTime;
00461 
00462         UpdateData (FALSE);
00463 
00464         RECT bar;
00465         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00466         ScreenToClient (&bar);
00467         InvalidateRect (&bar);
00468         
00469 }
00470 
00471 // ***************************************************************************
00472 
00473 void CSlotDlg::OnSetAnimation() 
00474 {
00475         // List of string
00476         std::vector<std::string> vectString;
00477 
00478         // Build a list of string
00479         for (uint a=0; a<AnimationSet->getNumAnimation (); a++)
00480                 vectString.push_back (AnimationSet->getAnimationName (a));
00481 
00482         // Select a string
00483         CSelectString select (vectString, "Select your animation", this);
00484         if (select.DoModal ()==IDOK)
00485         {
00486                 // Set the animation
00487                 if (select.Selection!=-1)
00488                 {
00489                         setAnimation (select.Selection, AnimationSet->getAnimation (select.Selection), vectString[select.Selection].c_str());
00490                         validateTime ();
00491                         updateScrollBar ();
00492                 }
00493                 else
00494                         setAnimation (0, NULL, NULL);
00495 
00496                 setWindowName ();
00497                 Invalidate ();
00498         }
00499 }
00500 
00501 // ***************************************************************************
00502 
00503 void CSlotDlg::OnSetSkeleton() 
00504 {
00505         // List of string
00506         std::vector<std::string> vectString;
00507 
00508         // Build a list of string
00509         for (uint s=0; s<AnimationSet->getNumSkeletonWeight (); s++)
00510                 vectString.push_back (AnimationSet->getSkeletonWeightName (s));
00511 
00512         // Select a string
00513         CSelectString select (vectString, "Select your skeleton weight template", this);
00514         if (select.DoModal ()==IDOK)
00515         {
00516                 // Set the animation
00517                 if (select.Selection!=-1)
00518                         setSkeletonTemplateWeight (select.Selection, AnimationSet->getSkeletonWeight (select.Selection), vectString[select.Selection].c_str());
00519                 else
00520                         setSkeletonTemplateWeight (0, NULL, "");
00521 
00522                 setWindowName ();
00523                 Invalidate ();
00524         }
00525 }
00526 
00527 // ***************************************************************************
00528 
00529 void CSlotDlg::setWindowName ()
00530 {
00531         char tmp[512];
00532         _snprintf (tmp, 512, "Slot %d : ", Id);
00533         if (isEmpty())
00534                 strcat (tmp, "empty");
00535         else
00536                 strcat (tmp, AnimationName.c_str());
00537 
00538         if (SkeletonWeightTemplate)     
00539         {
00540                 strcat (tmp, " (");
00541                 strcat (tmp, SkeletonName.c_str());
00542                 strcat (tmp, ")");
00543         }
00544 
00545         GetDlgItem (IDC_SLOT_NAME)->SetWindowText (tmp);
00546 }
00547 
00548 // ***************************************************************************
00549 
00550 void CSlotDlg::OnChangeOffset() 
00551 {
00552         // TODO: If this is a RICHEDIT control, the control will not
00553         // send this notification unless you override the CDialog::OnInitDialog()
00554         // function and call CRichEditCtrl().SetEventMask()
00555         // with the ENM_CHANGE flag ORed into the mask.
00556         
00557         // TODO: Add your control notification handler code here
00558         validateTime ();
00559         updateScrollBar ();
00560 }
00561 
00562 // ***************************************************************************
00563 
00564 void CSlotDlg::OnDeltaposOffsetSpin(NMHDR* pNMHDR, LRESULT* pResult) 
00565 {
00566         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
00567         // TODO: Add your control notification handler code here
00568 
00569         UpdateData ();
00570         if (pNMUpDown->iDelta<0)
00571                 Offset++;
00572         if (pNMUpDown->iDelta>0)
00573                 Offset--;
00574         UpdateData (FALSE);
00575         validateTime ();
00576         updateScrollBar ();
00577 
00578         *pResult = 0;
00579 }
00580 
00581 // ***************************************************************************
00582 
00583 void CSlotDlg::validateTime ()
00584 {
00585         bool reinit=false;
00586         if ((float)Offset<StartAnimTime)
00587         {
00588                 StartAnimTime=(float)Offset;
00589                 reinit=true;
00590         }
00591         if ((float)Offset+AnimationLength/SpeedFactor>EndAnimTime)
00592         {
00593                 EndAnimTime=(float)Offset+AnimationLength/SpeedFactor;
00594                 reinit=true;
00595         }
00596         if (reinit)
00597                 MainDlg->setAnimTime (StartAnimTime, EndAnimTime);
00598 }
00599 
00600 // ***************************************************************************
00601 
00602 void CSlotDlg::updateScrollBar ()
00603 {
00604         // Scroll info
00605         SCROLLINFO info;
00606         memset (&info, 0, sizeof (info));
00607 
00608         // Fill the infos
00609         info.fMask=SIF_ALL;
00610         info.nMin=0;
00611         info.nMax=10000;
00612         if (fabs(EndAnimTime-StartAnimTime)<0.00001f)
00613         {
00614                 info.nPage=1;
00615                 info.nPos=0;
00616         }
00617         else
00618         {
00619                 info.nPage=(int)(10000.f*(AnimationLength/SpeedFactor)/(EndAnimTime-StartAnimTime));
00620                 info.nPos=(int)(10000.f*((float)Offset-StartAnimTime)/(EndAnimTime-StartAnimTime));
00621         }
00622 
00623         // Set scrollbar infos
00624         ScrollBarCtrl.SetScrollInfo (&info, TRUE);
00625 
00626         // Invalidate blend bar
00627         RECT bar;
00628         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00629         ScreenToClient (&bar);
00630         InvalidateRect (&bar);
00631 }
00632 
00633 // ***************************************************************************
00634 
00635 void CSlotDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
00636 {
00637         // TODO: Add your message handler code here and/or call default
00638         if (pScrollBar==GetDlgItem (IDC_SCROLLBAR))
00639         {
00640                 // Only drag and drop
00641                 if (nSBCode==SB_THUMBTRACK)
00642                 {
00643                         int DeltaOffset=Offset;
00644                         UpdateData ();
00645                         Offset=(int)((EndAnimTime-StartAnimTime)*(float)nPos/10000.f+StartAnimTime);
00646                         DeltaOffset=Offset-DeltaOffset;
00647                         StartTime+=DeltaOffset;
00648                         EndTime+=DeltaOffset;
00649                         UpdateData (FALSE);
00650                         updateScrollBar ();
00651                 }
00652         }
00653         CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
00654 }
00655 
00656 // ***************************************************************************
00657 
00658 void CSlotDlg::setAnimTime (float animStart, float animEnd)
00659 {
00660         StartAnimTime=animStart;
00661         EndAnimTime=animEnd;
00662         updateScrollBar ();
00663         computeLength ();
00664 }
00665 
00666 // ***************************************************************************
00667 
00668 float CSlotDlg::getTimeIncrement ()
00669 {
00670         return (EndAnimTime-StartAnimTime)/100.f;
00671 }
00672 
00673 // ***************************************************************************
00674 
00675 void CSlotDlg::OnClamp() 
00676 {
00677         // TODO: Add your control notification handler code here
00678         
00679 }
00680 
00681 // ***************************************************************************
00682 
00683 void CSlotDlg::OnRepeat() 
00684 {
00685         // TODO: Add your control notification handler code here
00686         
00687 }
00688 
00689 // ***************************************************************************
00690 
00691 void CSlotDlg::OnDisable() 
00692 {
00693         // TODO: Add your control notification handler code here
00694         
00695 }
00696 
00697 // ***************************************************************************
00698 
00699 void CSlotDlg::OnAlignBlend() 
00700 {
00701         // Refresh data
00702         UpdateData ();
00703 
00704         // Change some of them
00705         StartTime=Offset;
00706         EndTime=(int)((float)Offset+AnimationLength/SpeedFactor);
00707 
00708         // Invalidate UI
00709         UpdateData (FALSE);
00710 
00711         // Invalidate blend bar
00712         RECT bar;
00713         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00714         ScreenToClient (&bar);
00715         InvalidateRect (&bar);
00716 }
00717 
00718 // ***************************************************************************
00719 
00720 void CSlotDlg::setAnimation (uint animationId, NL3D::CAnimation *animation, const char* name)
00721 {
00722         Animation=animation;
00723         AnimationId=animationId;
00724         if (animation)
00725         {
00726                 nlassert (name);
00727                 AnimationName=name;
00728                 computeLength ();
00729         }
00730         OffsetCtrl.EnableWindow (Animation!=NULL);
00731         StartTimeCtrl.EnableWindow (Animation!=NULL);
00732         StartBlendCtrl.EnableWindow (Animation!=NULL);
00733         SpeddFactorCtrl.EnableWindow (Animation!=NULL);
00734         SmoothnessCtrl.EnableWindow (Animation!=NULL);
00735         EndTimeCtrl.EnableWindow (Animation!=NULL);
00736         EndBlendCtrl.EnableWindow (Animation!=NULL);
00737         OffsetSpinCtrl.EnableWindow (Animation!=NULL);
00738         StartTimeSpinCtrl.EnableWindow (Animation!=NULL);
00739         StartBlendSpinCtrl.EnableWindow (Animation!=NULL);
00740         SpeedFactorSpinCtrl.EnableWindow (Animation!=NULL);
00741         SmoothnessSpinCtrl.EnableWindow (Animation!=NULL);
00742         EndTimeSpinCtrl.EnableWindow (Animation!=NULL);
00743         EndBlendSpinCtrl.EnableWindow (Animation!=NULL);
00744         ScrollBarCtrl.EnableWindow (Animation!=NULL);
00745         AlignBlendCtrl.EnableWindow (Animation!=NULL);
00746         InvertSkeletonWeightCtrl.EnableWindow (Animation!=NULL);
00747         GetDlgItem (IDC_CLAMP)->EnableWindow (Animation!=NULL);
00748         GetDlgItem (IDC_REPEAT)->EnableWindow (Animation!=NULL);
00749         GetDlgItem (IDC_DISABLE)->EnableWindow (Animation!=NULL);
00750         setWindowName ();
00751 
00752         // Invalidate blend bar
00753         RECT bar;
00754         GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
00755         ScreenToClient (&bar);
00756         InvalidateRect (&bar);
00757 }
00758 
00759 // ***************************************************************************
00760 
00761 float CSlotDlg::getTimeOffset ()
00762 {
00763         return (float)Offset/MainDlg->getFrameRate ();
00764 }
00765 
00766 // ***************************************************************************
00767 
00768 float CSlotDlg::getStartTime ()
00769 {
00770         return (float)StartTime/MainDlg->getFrameRate ();
00771 }
00772 
00773 // ***************************************************************************
00774 
00775 float CSlotDlg::getEndTime ()
00776 {
00777         return (float)EndTime/MainDlg->getFrameRate ();
00778 }
00779 
00780 // ***************************************************************************
00781 
00782 void CSlotDlg::computeLength ()
00783 {
00784         if (Animation)
00785                 AnimationLength=(Animation->getEndTime()-Animation->getBeginTime())*MainDlg->getFrameRate();
00786 }
00787 
00788 // ***************************************************************************
00789 
00790 
00791 void CSlotDlg::OnDestroy() 
00792 {
00793         // TODO: Add your message handler code here
00794         CDialog::OnDestroy();
00795 }