# 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  

main_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 "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 // CMainDlg dialog
00042 
00043 
00044 CMainDlg::CMainDlg(CObjectViewer* main, CWnd* pParent /*=NULL*/)
00045         : CDialog(CMainDlg::IDD, pParent)
00046 {
00047         //{{AFX_DATA_INIT(CMainDlg)
00048                 // NOTE: the ClassWizard will add member initialization here
00049         //}}AFX_DATA_INIT
00050         Main=main;
00051 }
00052 
00053 
00054 void CMainDlg::DoDataExchange(CDataExchange* pDX)
00055 {
00056         CDialog::DoDataExchange(pDX);
00057         //{{AFX_DATA_MAP(CMainDlg)
00058                 // NOTE: the ClassWizard will add DDX and DDV calls here
00059         //}}AFX_DATA_MAP
00060 }
00061 
00062 
00063 BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
00064         //{{AFX_MSG_MAP(CMainDlg)
00065         ON_WM_DESTROY()
00066         //}}AFX_MSG_MAP
00067 END_MESSAGE_MAP()
00068 
00070 // CMainDlg message handlers
00071 
00072 BOOL CMainDlg::OnInitDialog() 
00073 {
00074         CDialog::OnInitDialog();
00075 
00076         // Get size
00077         RECT rect;
00078                 
00079         // Init Slots
00080         for (uint s=0; s<CChannelMixer::NumAnimationSlot; s++)
00081         {
00082                 // Init the slot s
00083                 BOOL initialized=Slots[s].Create (IDD_SLOT, this);
00084 
00085                 // Position
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         // Resize the main window
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;  // return TRUE unless you set the focus to a control
00102                       // EXCEPTION: OCX Property Pages should return FALSE
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         // Init Slots
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                 // Update slots UI values
00122                 Slots[id].UpdateData();
00123 
00124                 // Set the animation
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                 // Set the skeleton weight
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                 // Set others values
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                 // Switch between wrap modes
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                 // Update slots UI values
00165                 Slots[id].UpdateData();
00166 
00167                 // Set the animation
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                 // Set the skeleton weight
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                 // Set others values
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                 // Switch between wrap modes
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         // TODO: Add your message handler code here
00214         
00215 }