# 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  

object_viewer.h

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 #if !defined(AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_)
00027 #define AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_
00028 
00029 #if _MSC_VER > 1000
00030 #pragma once
00031 #endif // _MSC_VER > 1000
00032 
00033 #ifndef __AFXWIN_H__
00034         #error include 'stdafx.h' before including this file for PCH
00035 #endif
00036 
00037 #define REGKEY_OBJ_VIEW "Software\\Nevrax\\nel\\object_viewer"
00038 #define REGKEY_OBJ_VIEW_OPENGL_WND "Software\\Nevrax\\nel\\object_viewer\\opengl_wnd"
00039 #define REGKEY_OBJ_VIEW_SCENE_DLG "Software\\Nevrax\\nel\\object_viewer\\scene_dlg"
00040 #define REGKEY_OBJ_VIEW_ANIMATION_DLG "Software\\Nevrax\\nel\\object_viewer\\animation_dlg"
00041 #define REGKEY_OBJ_VIEW_ANIMATION_SET_DLG "Software\\Nevrax\\nel\\object_viewer\\animation_set_dlg"
00042 #define REGKEY_OBJ_VIEW_SLOT_DLG "Software\\Nevrax\\nel\\object_viewer\\slot_dlg"
00043 
00044 #include "resource.h"
00045 #include "object_viewer_interface.h"
00046 #include "main_dlg.h"
00047 #include "animation_set_dlg.h"
00048 #include "animation_dlg.h"
00049 #include "scene_dlg.h"
00050 #include <nel/3d/animation_set.h>
00051 #include <nel/3d/channel_mixer.h>
00052 #include <nel/3d/shape.h>
00053 #include <nel/3d/event_mouse_listener.h>
00054 #include <nel/3d/light.h>
00055 #include <nel/misc/event_listener.h>
00056 #include <nel/misc/stream.h>
00057 
00059 // CObject_viewerApp
00060 // See object_viewer.cpp for the implementation of this class
00061 //
00062 
00063 class CObject_viewerApp : public CWinApp
00064 {
00065 public:
00066         CObject_viewerApp();
00067 
00068 // Overrides
00069         // ClassWizard generated virtual function overrides
00070         //{{AFX_VIRTUAL(CObject_viewerApp)
00071         //}}AFX_VIRTUAL
00072 
00073         //{{AFX_MSG(CObject_viewerApp)
00074                 // NOTE - the ClassWizard will add and remove member functions here.
00075                 //    DO NOT EDIT what you see in these blocks of generated code !
00076         //}}AFX_MSG
00077         DECLARE_MESSAGE_MAP()
00078 };
00079 
00080 
00082 
00083 class CMeshDesc
00084 {
00085 public:
00086         CMeshDesc () {};
00087         CMeshDesc (const char* meshName, const char* skeletonName)
00088         {
00089                 MeshName=meshName;
00090                 SkeletonName=skeletonName;
00091         }
00092         std::string             MeshName;
00093         std::string             SkeletonName;
00094         void                    serial (NLMISC::IStream& s)
00095         {
00096                 int ver=s.serialVersion (0);
00097                 s.serial (MeshName);
00098                 s.serial (SkeletonName);
00099         }
00100 };
00101 
00102 class CObjectViewer : public IObjectViewer, public NLMISC::IEventListener
00103 {
00104         friend class CSceneDlg;
00105         friend class CAnimationSetDlg;
00106 public:
00107         CObjectViewer ();
00108         ~CObjectViewer ();
00109 
00110         // Init the UI
00111         void initUI ();
00112 
00113         // Go
00114         void go ();
00115 
00116         // Release the UI
00117         void releaseUI ();
00118 
00119         // Set single animtion.
00120         void setSingleAnimation (NL3D::CAnimation*      pAnim, const char* name);
00121 
00122         // Add a mesh
00123         NL3D::CTransformShape   *addMesh (NL3D::IShape* pMeshShape, NL3D::IShape* pSkelShape, const char* meshName, const char* skelName, const char *animBaseName);
00124 
00125         // Load a mesh
00126         bool loadMesh (const char* meshFilename, const char* skeleton="");
00127 
00128         // Set ambient color
00129         void setAmbientColor (const NLMISC::CRGBA& color);
00130 
00131         // Set ambient color
00132         void setLight (unsigned char id, const NL3D::CLight& light);
00133 
00134         // Load a shape
00135         void resetCamera ();
00136 
00137         // Listener
00138         virtual void operator ()(const NLMISC::CEvent& event);
00139 
00140         // Not exported
00141         void setAnimTime (float animStart, float animEnd);
00142 
00143         // Reset the slots
00144         void resetSlots ();
00145 
00146         // Reinit and refill the channel mixer channels
00147         void reinitChannels ();
00148 
00149         // Return the frame rate
00150         float getFrameRate ();
00151 
00152         // Serial the config
00153         void serial (NLMISC::IStream& f);
00154 
00155 private:
00156         CAnimationDlg                                                           *_AnimationDlg;
00157         CMainDlg                                                                        *_SlotDlg;
00158         CAnimationSetDlg                                                        *_AnimationSetDlg;
00159         CSceneDlg                                                                       *_SceneDlg;
00160         std::vector<std::string>                                        _ListShapeBaseName;
00161         std::vector<CMeshDesc>                                          _ListMeshes;
00162         std::vector<class NL3D::CTransformShape*>       _ListTransformShape;
00163         NL3D::CAnimationSet                                                     _AnimationSet;
00164         NL3D::CChannelMixer                                                     _ChannelMixer;
00165         NL3D::CEvent3dMouseListener                                     _MouseListener;
00166         NLMISC::CRGBA                                                           _HotSpotColor;
00167         float                                                                           _HotSpotSize;
00168 };
00169 
00170 void setRegisterWindowState (const CWnd *pWnd, const char* keyName);
00171 void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize);
00172 
00173 //{{AFX_INSERT_LOCATION}}
00174 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00175 
00176 #endif // !defined(AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_)