From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/animation_set_dlg_cpp-source.html | 349 +++++++++++++++++++++ 1 file changed, 349 insertions(+) create mode 100644 docs/doxygen/nel/animation_set_dlg_cpp-source.html (limited to 'docs/doxygen/nel/animation_set_dlg_cpp-source.html') diff --git a/docs/doxygen/nel/animation_set_dlg_cpp-source.html b/docs/doxygen/nel/animation_set_dlg_cpp-source.html new file mode 100644 index 00000000..b30907dc --- /dev/null +++ b/docs/doxygen/nel/animation_set_dlg_cpp-source.html @@ -0,0 +1,349 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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  
+

animation_set_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 "animation_set_dlg.h"
+00029 #include <nel/misc/file.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 // CAnimationSetDlg dialog
+00042 
+00043 
+00044 CAnimationSetDlg::CAnimationSetDlg(CObjectViewer* objView, CWnd* pParent /*=NULL*/)
+00045         : CDialog(CAnimationSetDlg::IDD, pParent)
+00046 {
+00047         //{{AFX_DATA_INIT(CAnimationSetDlg)
+00048                 // NOTE: the ClassWizard will add member initialization here
+00049         //}}AFX_DATA_INIT
+00050 
+00051         _ObjView=objView;
+00052 }
+00053 
+00054 
+00055 void CAnimationSetDlg::DoDataExchange(CDataExchange* pDX)
+00056 {
+00057         CDialog::DoDataExchange(pDX);
+00058         //{{AFX_DATA_MAP(CAnimationSetDlg)
+00059         DDX_Control(pDX, IDC_TREE2, SkelTree);
+00060         DDX_Control(pDX, IDC_TREE, Tree);
+00061         //}}AFX_DATA_MAP
+00062 }
+00063 
+00064 
+00065 BEGIN_MESSAGE_MAP(CAnimationSetDlg, CDialog)
+00066         //{{AFX_MSG_MAP(CAnimationSetDlg)
+00067         ON_BN_CLICKED(IDC_ADD_ANIMATION, OnAddAnimation)
+00068         ON_BN_CLICKED(IDC_RESET, OnReset)
+00069         ON_BN_CLICKED(IDC_ADD_SKEL_WT, OnAddSkelWt)
+00070         ON_WM_DESTROY()
+00071         //}}AFX_MSG_MAP
+00072 END_MESSAGE_MAP()
+00073 
+00075 // CAnimationSetDlg message handlers
+00076 
+00077 // ***************************************************************************
+00078 
+00079 void CAnimationSetDlg::OnAddAnimation () 
+00080 {
+00081         // TODO: Add your control notification handler code here
+00082         static char BASED_CODE szFilter[] = "NeL Animation Files (*.anim)|*.anim|All Files (*.*)|*.*||";
+00083         CFileDialog fileDlg( TRUE, ".anim", "*.anim", OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter);
+00084         if (fileDlg.DoModal()==IDOK)
+00085         {
+00086                 // Open the file
+00087                 try
+00088                 {
+00089                         // Get first file
+00090                         POSITION pos=fileDlg.GetStartPosition( );
+00091                         while (pos)
+00092                         {
+00093                                 // Get the name
+00094                                 CString filename=fileDlg.GetNextPathName(pos);
+00095 
+00096                                 // Load the animation
+00097                                 loadAnimation (filename);
+00098 
+00099                                 // Touch the channel mixer
+00100                                 _ObjView->reinitChannels ();
+00101                         }
+00102                 }
+00103                 catch (Exception& e)
+00104                 {
+00105                         MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
+00106                 }
+00107         }
+00108 }
+00109 
+00110 // ***************************************************************************
+00111 
+00112 void CAnimationSetDlg::OnAddSkelWt() 
+00113 {
+00114         // TODO: Add your control notification handler code here
+00115         static char BASED_CODE szFilter[] = "NeL Skeleton Weight Template Files (*.swt)|*.swt|All Files (*.*)|*.*||";
+00116         CFileDialog fileDlg( TRUE, ".swt", "*.swt", OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter);
+00117         if (fileDlg.DoModal()==IDOK)
+00118         {
+00119                 // Open the file
+00120                 try
+00121                 {
+00122                         // Get first file
+00123                         POSITION pos=fileDlg.GetStartPosition( );
+00124                         while (pos)
+00125                         {
+00126                                 // Get the name
+00127                                 CString filename=fileDlg.GetNextPathName(pos);
+00128 
+00129                                 // Load the animation
+00130                                 loadSkeleton (filename);
+00131 
+00132                                 // Touch the channel mixer
+00133                                 _ObjView->reinitChannels  ();
+00134                         }
+00135                 }
+00136                 catch (Exception& e)
+00137                 {
+00138                         MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
+00139                 }
+00140         }
+00141 }
+00142 
+00143 // ***************************************************************************
+00144 
+00145 void CAnimationSetDlg::OnReset () 
+00146 {
+00147         // Reset the channel mixer slots
+00148         _ObjView->resetSlots ();
+00149 
+00150         // Clear the filename array
+00151         _ListAnimation.clear();
+00152         _ListSkeleton.clear();
+00153 
+00154         // Clear the TREE
+00155         Tree.DeleteAllItems ();
+00156 
+00157         // Clear the TREE
+00158         SkelTree.DeleteAllItems ();
+00159 }
+00160 
+00161 // ***************************************************************************
+00162 
+00163 void CAnimationSetDlg::loadAnimation (const char* fileName)
+00164 {
+00165         // Open the file
+00166         CIFile file;
+00167         if (file.open (fileName))
+00168         {
+00169                 // Get the animation name
+00170                 char name[256];
+00171                 _splitpath (fileName, NULL, NULL, name, NULL);
+00172 
+00173                 // Make an animation
+00174                 CAnimation *anim=new CAnimation;
+00175 
+00176                 // Serial it
+00177                 anim->serial (file);
+00178 
+00179                 // Add the animation
+00180                 addAnimation (anim, name);
+00181 
+00182                 // Add the filename in the list
+00183                 _ListAnimation.push_back (fileName);
+00184         }
+00185         else
+00186         {
+00187                 // Create a message
+00188                 char msg[512];
+00189                 _snprintf (msg, 512, "Can't open the file %s for reading.", fileName);
+00190                 MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
+00191         }
+00192 
+00193 }
+00194 
+00195 // ***************************************************************************
+00196 
+00197 void CAnimationSetDlg::addAnimation (NL3D::CAnimation* anim, const char* name)
+00198 {
+00199         // Add an animation
+00200         _ObjView->_AnimationSet.addAnimation (name, anim);
+00201 
+00202         // Rebuild the animationSet
+00203         _ObjView->_AnimationSet.build ();
+00204 
+00205         // Insert an intem
+00206         HTREEITEM item=Tree.InsertItem (name);
+00207         nlassert (item!=NULL);
+00208 
+00209         // For all tracks in the animation
+00210         std::set<std::string> setString;
+00211         anim->getTrackNames (setString);
+00212         std::set<std::string>::iterator ite=setString.begin();
+00213         while (ite!=setString.end())
+00214         {
+00215                 // Add this string
+00216                 Tree.InsertItem (ite->c_str(), item);
+00217 
+00218                 ite++;
+00219         }
+00220 }
+00221 
+00222 // ***************************************************************************
+00223 
+00224 void CAnimationSetDlg::loadSkeleton (const char* fileName)
+00225 {
+00226         // Open the file
+00227         CIFile file;
+00228         if (file.open (fileName))
+00229         {
+00230                 // Get the animation name
+00231                 char name[256];
+00232                 _splitpath (fileName, NULL, NULL, name, NULL);
+00233 
+00234                 // Make an animation
+00235                 CAnimation *anim=new CAnimation;
+00236 
+00237                 // Add an animation
+00238                 uint id=_ObjView->_AnimationSet.addSkeletonWeight (name);
+00239 
+00240                 // Get the skeleton pointer
+00241                 CSkeletonWeight* skel=_ObjView->_AnimationSet.getSkeletonWeight (id);
+00242 
+00243                 // Serial it
+00244                 skel->serial (file);
+00245 
+00246                 // Add the filename in the list
+00247                 _ListSkeleton.push_back (fileName);
+00248 
+00249                 // Insert an intem
+00250                 HTREEITEM item=SkelTree.InsertItem (name);
+00251                 nlassert (item!=NULL);
+00252 
+00253                 // Get number of node in this skeleton weight
+00254                 uint numNode=skel->getNumNode ();
+00255 
+00256                 // Add the nodein the tree
+00257                 for (uint n=0; n<numNode; n++)
+00258                 {
+00259                         char percent[512];
+00260                         sprintf (percent, "%s (%f%%)", skel->getNodeName (n).c_str(), skel->getNodeWeight(n));
+00261                         // Add this string
+00262                         SkelTree.InsertItem (percent, item);
+00263                 }
+00264         }
+00265         else
+00266         {
+00267                 // Create a message
+00268                 char msg[512];
+00269                 _snprintf (msg, 512, "Can't open the file %s for reading.", fileName);
+00270                 MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
+00271         }
+00272 
+00273 }
+00274 
+00275 void CAnimationSetDlg::OnDestroy() 
+00276 {
+00277         setRegisterWindowState (this, REGKEY_OBJ_VIEW_ANIMATION_SET_DLG);
+00278 
+00279         CDialog::OnDestroy();
+00280         
+00281         // TODO: Add your message handler code here     
+00282 }
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1