Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / object_viewer.h
blobc00c5490dca272cde8597590ca392a51a294e83e
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #if !defined(AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_)
18 #define AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_
20 #if _MSC_VER > 1000
21 #pragma once
22 #endif // _MSC_VER > 1000
25 #define REGKEY_OBJ_VIEW _T("Software\\Nevrax\\nel\\object_viewer")
26 #define REGKEY_OBJ_VIEW_OPENGL_WND _T("Software\\Nevrax\\nel\\object_viewer\\opengl_wnd")
27 #define REGKEY_OBJ_VIEW_SCENE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\scene_dlg")
28 #define REGKEY_OBJ_VIEW_ANIMATION_DLG _T("Software\\Nevrax\\nel\\object_viewer\\animation_dlg")
29 #define REGKEY_OBJ_VIEW_ANIMATION_SET_DLG _T("Software\\Nevrax\\nel\\object_viewer\\animation_set_dlg")
30 #define REGKEY_OBJ_VIEW_SLOT_DLG _T("Software\\Nevrax\\nel\\object_viewer\\slot_dlg")
31 #define REGKEY_OBJ_PARTICLE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\particle_dlg")
32 #define REGKEY_OBJ_DAYNIGHT_DLG _T("Software\\Nevrax\\nel\\object_viewer\\daynight_dlg")
33 #define REGKEY_OBJ_WATERPOOL_DLG _T("Software\\Nevrax\\nel\\object_viewer\\daynight_dlg")
34 #define REGKEY_OBJ_VIEW_VEGETABLE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\vegetable_dlg")
35 #define REGKEY_OBJ_GLOBAL_WIND_DLG _T("Software\\Nevrax\\nel\\object_viewer\\global_wind_dlg")
36 #define REGKEY_OBJ_SOUND_ANIM_DLG _T("Software\\Nevrax\\nel\\object_viewer\\sound_anim_dlg")
37 #define REGKEY_OBJ_LIGHT_GROUP_DLG _T("Software\\Nevrax\\nel\\object_viewer\\light_group_dlg")
38 #define REGKEY_CHOOSE_FRAME_DELAY_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_frame_delay_dlg")
39 #define REGKEY_CHOOSE_BG_COLOR_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_bg_color_dlg")
40 #define REGKEY_CHOOSE_SUN_COLOR_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_sun_color_dlg")
41 #define REGKEY_SKELETON_SCALE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\skeleton_scale_dlg")
42 #define REGKEY_TUNE_MRM_DLG _T("Software\\Nevrax\\nel\\object_viewer\\tune_mrm_dlg")
46 #include "resource.h"
47 #include "object_viewer_interface.h"
48 #include "main_dlg.h"
49 #include "animation_set_dlg.h"
50 #include "animation_dlg.h"
52 #include "nel/3d/animation_set.h"
53 #include "nel/3d/channel_mixer.h"
54 #include "nel/3d/shape.h"
55 #include "nel/3d/event_mouse_listener.h"
56 #include "nel/3d/light.h"
57 #include "nel/3d/font_manager.h"
58 #include "nel/3d/cloud_scape.h"
59 #include "nel/misc/event_listener.h"
60 #include "nel/misc/stream.h"
62 #include "nel/3d/logic_info.h"
63 #include "nel/pacs/u_global_position.h"
65 namespace NL3D
67 class CFontGenerator;
68 class CWaterPoolManager;
69 class CTileVegetableDesc;
70 class CLandscapeModel;
71 class CVisualCollisionManager;
72 class CVisualCollisionEntity;
75 class CMainFrame;
77 class CParticleDlg;
78 class CDayNightDlg;
79 class CWaterPoolEditor;
80 class CVegetableDlg;
81 class CGlobalWindDlg;
82 class CSoundAnimDlg;
83 class CLightGroupFactor;
84 class CChooseFrameDelay;
85 class CChooseBGColorDlg;
86 class CChooseSunColorDlg;
87 class CSkeletonScaleDlg;
88 class CTuneMrmDlg;
92 /////////////////////////////////////////////////////////////////////////////
93 // CObject_viewerApp
94 // See object_viewer.cpp for the implementation of this class
97 class CObject_viewerApp : public CWinApp
99 public:
100 CObject_viewerApp();
102 // Overrides
103 // ClassWizard generated virtual function overrides
104 //{{AFX_VIRTUAL(CObject_viewerApp)
105 //}}AFX_VIRTUAL
107 //{{AFX_MSG(CObject_viewerApp)
108 //}}AFX_MSG
109 DECLARE_MESSAGE_MAP()
113 /////////////////////////////////////////////////////////////////////////////
115 class CSlotInfo
117 public:
118 CSlotInfo ();
119 std::string Animation;
120 std::string Skeleton;
121 sint32 Offset;
122 sint32 StartTime;
123 sint32 EndTime;
124 float StartBlend;
125 float EndBlend;
126 float Smoothness;
127 float SpeedFactor;
128 sint32 ClampMode;
129 bool SkeletonInverted;
130 bool Enable;
132 // Serial
133 void serial (NLMISC::IStream& s);
136 /////////////////////////////////////////////////////////////////////////////
138 class CInstanceSave
140 public:
141 CInstanceSave ();
143 // Play list of this object
144 std::vector<std::string> PlayList;
146 // Slot info for this object
147 CSlotInfo SlotInfo[NL3D::CChannelMixer::NumAnimationSlot];
149 // Camera info
150 NL3D::CCameraInfo CameraInfo;
152 // Camera ?
153 bool Camera;
155 // Input file
156 std::string ShapeFilename;
158 // Skeleton id
159 uint32 SkeletonId;
161 // Bin bone name
162 std::string BindBoneName;
164 // Is a skeleton
165 bool IsSkeleton;
167 // Animation input file
168 std::vector<std::string> AnimationFileName;
170 // Skeleton weight input file
171 std::vector<std::string> SWTFileName;
173 // Serial
174 void serial (NLMISC::IStream& s);
177 /////////////////////////////////////////////////////////////////////////////
179 class CInstanceInfo
181 public:
182 CInstanceInfo ();
183 ~CInstanceInfo ();
185 // Camera pointer
186 NL3D::CCamera *Camera;
188 // Transform shape pointer
189 NL3D::CTransformShape *TransformShape;
191 // Animation set of this instance
192 NL3D::CAnimationSet AnimationSet;
194 // Channel mixer of this instance
195 NL3D::CChannelMixer ChannelMixer;
197 // True, must delete this shape
198 bool MustDelete;
200 // Save information
201 CInstanceSave Saved;
203 // The current playlist
204 NL3D::CAnimationPlaylist Playlist;
206 // Set an animation playlist
207 void setAnimationPlaylist (float frameRate);
211 /////////////////////////////////////////////////////////////////////////////
213 class CObjectViewer : public IObjectViewer
215 public:
216 // Name of particle workspace, just used to save config file
217 std::string ParticleWorkspaceFilename;
218 friend class CMainFrame;
219 friend class CAnimationSetDlg;
220 public:
221 CObjectViewer ( );
222 virtual ~CObjectViewer ();
224 // Init the UI
225 bool initUI (HWND parent=NULL);
228 // Go
229 void go ();
231 virtual bool isInstanceRunning() { return _InstanceRunning; }
233 // Release the UI
234 void releaseUI ();
236 // Set single animtion.
237 void setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance);
239 // Set automatic animation
240 void setAutoAnimation (NL3D::CAnimationSet* pAnimSet);
242 // Add a mesh
243 uint addMesh(NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true);
245 // Add a camera
246 uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName);
248 // Add a skel
249 uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName);
251 // remove all instances from the scene
252 void removeAllInstancesFromScene();
254 // Start / stop fxs (remanence for now..)
255 void enableFXs(bool enabled);
258 /// Force all the instances of the scene to use the given texture set (if available)
259 void activateTextureSet(uint index);
261 /// Select random textures sets
262 void shuffleTextureSet();
264 // Load a mesh
265 bool loadMesh (std::vector<std::string> &meshFilename, const std::string &skeleton = "");
267 // Load an instance group
268 bool loadInstanceGroup(const std::string &igFilename);
270 // Set ambient color
271 void setAmbientColor (const NLMISC::CRGBA& color);
273 // Set ambient color
274 void setLight (unsigned char id, const NL3D::CLight& light);
276 // Get edited object, 0xffffffff if no object edited
277 uint getEditedObject ();
279 // Set edited object, 0xffffffff if no object edited
280 void setEditedObject (uint selected);
282 // Get an instance
283 CInstanceInfo *getInstance (uint instance);
285 // Get the slot dialog
286 CMainDlg *getSlotDlg ();
288 // Get number of instances
289 uint getNumInstance () const;
291 // Add an animation
292 void addAnimation (NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance);
294 // Update all objects that depend on the animation set
295 void refreshAnimationListeners();
297 // Load a shape
298 void resetCamera ();
300 // get the mouse listener
301 NL3D::CEvent3dMouseListener &getMouseListener(void) { return _MouseListener ; }
302 const NL3D::CEvent3dMouseListener &getMouseListener(void) const { return _MouseListener ; }
304 // get the particle dialog
305 CParticleDlg *getParticleDialog(void) const { return _ParticleDlg ; }
307 // get the frame delay dialog
308 CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; }
310 // Load animation
311 void loadAnimation(const std::string &fileName, uint instance);
313 // Load a skeleton template
314 void loadSWT(const std::string &fileName, uint instance);
317 /// Not exported
318 // @{
320 void setAnimTime (float animStart, float animEnd);
322 // Reset the slots
323 void resetSlots (uint instance);
325 // Reinit and refill the channel mixer channels
326 void reinitChannels ();
328 // Return the frame rate
329 float getFrameRate ();
331 // Serial the config
332 void serial (NLMISC::IStream& f);
334 /// set the backgournd color
335 void setBackGroundColor(const NLMISC::CRGBA& col) { _BackGroundColor = col ; }
337 /// get the background color
338 NLMISC::CRGBA getBackGroundColor(void) { return _BackGroundColor ; }
340 /// Get font manager
341 NL3D::CFontManager *getFontManager () { return &_FontManager; };
343 /// Get font generator
344 NL3D::CFontGenerator *getFontGenerator () { return _FontGenerator; };
345 // @}
347 /** an interface for objects that want to be called during the loop
348 * First use : display of an optional bbox for a particle system
350 struct IMainLoopCallBack
352 /// this will be called each time the main loop is processed
353 virtual void goPostRender() = 0;
354 virtual void goPreRender() = 0;
357 /** add an object that will be notified each time a frame is processed
358 * \see removeMainLoopCallBack()
360 void registerMainLoopCallBack(IMainLoopCallBack *i) ;
362 /// remove an object that was registered with registerMainLoopCallBack()
363 void removeMainLoopCallBack(IMainLoopCallBack *i) ;
365 /// set the lag in milliseconds between each frame; 0 is the default
366 void setFrameDelay(uint32 milliSec) { _FrameDelay = milliSec; }
368 /// get the frame delay in milliseconds
369 uint32 getFrameDelay() const { return _FrameDelay; }
371 /// eval sound tracks
372 void evalSoundTrack (float lastTime, float currentTime);
374 /// Setup the playlist with the playlist
375 void setupPlaylist (float time);
377 /// Enable disable channels
378 void enableChannels ();
380 /// Setup transform positions
381 void setupPositions ();
383 /// Manage matrix increment
384 void addTransformation (NLMISC::CMatrix &current, NL3D::CAnimation *anim, float begin, float end, NL3D::ITrack *posTrack, NL3D::ITrack *rotquatTrack,
385 NL3D::ITrack *nextPosTrack, NL3D::ITrack *nextRotquatTrack, bool removeLast);
387 /// inherited from CObjectViewerInterface
388 void setWaterPoolManager(NL3D::CWaterPoolManager &wpm) { _Wpm = &wpm; }
390 NL3D::CWaterPoolManager &getWaterPoolManager() const { return *_Wpm; }
392 // Reload textures
393 void reloadTextures ();
395 /** inherited from CObjectViewerInterface
397 virtual uint addInstanceGroup(NL3D::CInstanceGroup *ig);
399 /** inherited from CObjectViewerInterface
401 virtual void setupSceneLightingSystem(bool enable, const NLMISC::CVector &sunDir, NLMISC::CRGBA sunAmbiant, NLMISC::CRGBA sunDiffuse, NLMISC::CRGBA sunSpecular);
403 /** inherited from CObjectViewerInterface
405 virtual void enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *globalRetriever, NL3D::CInstanceGroup *ig);
407 /// \name Landscape Vegetable Edition
408 // @{
410 /// true if landscape is created
411 bool isVegetableLandscapeCreated() const {return _VegetableLandscape!=NULL;}
413 /// load the landscape with help of setup in object_viewer.cfg. return true if OK.
414 bool createVegetableLandscape();
416 /// if created, show the landscape
417 void showVegetableLandscape();
418 /// if created, hide the landscape
419 void hideVegetableLandscape();
421 /// display vegetable with landscape
422 void enableLandscapeVegetable(bool enable);
424 /// refresh the vegetables in landscape, with the new vegetableSet
425 void refreshVegetableLandscape(const NL3D::CTileVegetableDesc &tvdesc);
428 /// get vegetable Wind wetup.
429 float getVegetableWindPower() const {return _VegetableWindPower;}
430 float getVegetableWindBendStart() const {return _VegetableWindBendMin;}
431 float getVegetableWindFrequency() const {return _VegetableWindFreq;}
432 /// set vegetable Wind wetup (updat view if possible)
433 void setVegetableWindPower(float w);
434 void setVegetableWindBendStart(float w);
435 void setVegetableWindFrequency(float w);
437 /// if enable, snap the camera to the ground of the landscape.
438 void snapToGroundVegetableLandscape(bool enable);
440 // @}
443 /// Get/Set global Scene wind setup
444 float getGlobalWindPower() const;
445 void setGlobalWindPower(float w);
447 /// Get the scene roor for manip.
448 NL3D::CTransform *getSceneRoot() const {return _SceneRoot;}
450 // Shoot the scene
451 void shootScene ();
453 // Camera methods
455 // Return -1 if no current camera
456 sint getCurrentCamera () const;
458 // -1 If no current camera
459 void setCurrentCamera (sint currentCamera);
461 // Get the instance id of a camera
462 uint getCameraInstance (uint cameraId) const;
464 // Get the camera count
465 uint getNumCamera () const;
467 // Reinit camera
468 void initCamera ();
470 /** popup a dialog to choose a bone in the scene
471 * \return true is a bone has been selected
473 bool chooseBone(const std::string &caption, NL3D::CSkeletonModel *&skel, uint &boneIndex, std::string *skelName = NULL, std::string *boneName = NULL);
475 // test if there's a skeleton in the scene
476 bool isSkeletonPresent() const;
478 // get the main frame
479 CMainFrame *getMainFrame() const { return _MainFrame; }
481 const NLMISC::CMatrix &getFXUserMatrix() const { return _FXUserMatrix; }
482 void setFXUserMatrix(const NLMISC::CMatrix &fxUserMatrix) { _FXUserMatrix = fxUserMatrix; }
484 void setSceneMatrixVisible(bool visible) { _SceneMatrixVisible = visible; }
485 bool getSceneMatrixVisible() const { return _SceneMatrixVisible; }
486 void setFXMatrixVisible(bool visible) { _FXMatrixVisible = visible; }
487 bool getFXMatrixVisible() const { return _FXMatrixVisible; }
488 void setFXUserMatrixVisible(bool visible) { _FXUserMatrixVisible = visible; }
489 bool getFXUserMatrixVisible() const { return _FXUserMatrixVisible; }
490 void setOcclusionTestMeshsVisible(bool visible) { _OcclusionTestMeshsVisible = visible; }
491 bool getOcclusionTestMeshsVisible() const { return _OcclusionTestMeshsVisible; }
495 private:
497 CMainFrame *_MainFrame;
498 CAnimationDlg *_AnimationDlg;
499 CMainDlg *_SlotDlg;
500 CAnimationSetDlg *_AnimationSetDlg;
501 CParticleDlg *_ParticleDlg;
502 CDayNightDlg *_DayNightDlg;
503 CWaterPoolEditor *_WaterPoolDlg;
504 CVegetableDlg *_VegetableDlg;
505 CSoundAnimDlg *_SoundAnimDlg;
506 CLightGroupFactor *_LightGroupDlg;
507 CChooseFrameDelay *_ChooseFrameDelayDlg;
508 CChooseBGColorDlg *_ChooseBGColorDlg;
509 CChooseSunColorDlg *_ChooseSunColorDlg;
510 CSkeletonScaleDlg *_SkeletonScaleDlg;
511 CTuneMrmDlg *_TuneMRMDlg;
512 uint32 _SelectedObject;
513 sint _CurrentCamera;
515 // FX user matrix
516 NLMISC::CMatrix _FXUserMatrix;
518 // Vector of camera
519 std::vector<uint> _Cameras;
521 // Vector of loaded instance
522 std::vector<CInstanceInfo*> _ListInstance;
524 CGlobalWindDlg *_GlobalWindDlg;
525 NL3D::CEvent3dMouseListener _MouseListener;
526 NLMISC::CRGBA _HotSpotColor;
527 float _HotSpotSize;
528 NLMISC::CRGBA _BackGroundColor;
529 NLMISC::CVector _SceneCenter;
530 // List of static InstanceGroup.
531 std::vector<class NL3D::CInstanceGroup*> _ListIG;
533 // Font mgt
534 NL3D::CFontManager _FontManager;
535 NL3D::CFontGenerator *_FontGenerator;
536 std::string _FontPath;
537 std::vector<IMainLoopCallBack *> _CallBackList;
538 uint32 _FrameDelay;
539 float _CameraFocal;
540 float _LastTime;
541 NL3D::CWaterPoolManager *_Wpm;
543 /// \name Vegetable Edition
544 // @{
545 /// Our landscape
546 NL3D::CLandscapeModel *_VegetableLandscape;
548 // File info to build it
549 std::string _VegetableLandscapeTileBank;
550 std::string _VegetableLandscapeTileFarBank;
551 std::vector<std::string> _VegetableLandscapeZoneNames;
553 // Misc.
554 float _VegetableLandscapeThreshold;
555 float _VegetableLandscapeTileNear;
556 NLMISC::CRGBA _VegetableLandscapeAmbient;
557 NLMISC::CRGBA _VegetableLandscapeDiffuse;
558 std::string _VegetableTexture;
559 NLMISC::CRGBA _VegetableAmbient;
560 NLMISC::CRGBA _VegetableDiffuse;
561 NLMISC::CVector _VegetableLightDir;
562 // Vegetable wind.
563 NLMISC::CVector _VegetableWindDir;
564 float _VegetableWindFreq;
565 float _VegetableWindPower;
566 float _VegetableWindBendMin;
568 bool _VegetableEnabled;
570 // Collision
571 bool _VegetableSnapToGround;
572 float _VegetableSnapHeight;
573 NL3D::CVisualCollisionManager *_VegetableCollisionManager;
574 NL3D::CVisualCollisionEntity *_VegetableCollisionEntity;
576 // load cfg.
577 void loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf);
579 // @}
581 // Lightigng Setup (from cfg).
582 bool _SceneLightEnabled;
583 NLMISC::CVector _SceneLightSunDir;
584 NLMISC::CRGBA _SceneLightSunAmbiant;
585 NLMISC::CRGBA _SceneLightSunDiffuse;
586 NLMISC::CRGBA _SceneLightSunSpecular;
588 /// \name dynamic object lighting testing
589 // @{
590 NLPACS::CGlobalRetriever *_GlobalRetriever;
591 NL3D::CTransformShape *_ObjectLightTest;
592 std::string _ObjectLightTestShape;
593 // The matrix not snapped by pacs.
594 NLMISC::CMatrix _ObjectLightTestMatrix;
596 bool _FXMatrixVisible;
597 bool _FXUserMatrixVisible;
598 bool _SceneMatrixVisible;
599 bool _OcclusionTestMeshsVisible;
601 // the lightInfo linked to the ig.
602 class COVLogicInfo : public NL3D::ILogicInfo
604 public:
605 NLPACS::UGlobalPosition GPos;
606 NL3D::CInstanceGroup *Ig;
607 NLPACS::CGlobalRetriever *GlobalRetriever;
609 virtual void getStaticLightSetup(NLMISC::CRGBA sunAmbient, std::vector<NL3D::CPointLightInfluence> &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &ambient);
611 // instnace
612 COVLogicInfo _ObjectLightTestLogicInfo;
614 // @}
616 static bool _InstanceRunning;
618 // Scale the pos of the skeleton
619 float _CharacterScalePos;
621 // Driver in direct3d ?
622 bool _Direct3d;
624 // Fog
625 bool _Fog;
626 float _FogStart;
627 float _FogEnd;
628 NLMISC::CRGBA _FogColor;
630 // Cloud scape
631 NL3D::SCloudScapeSetup _CSS;
632 NL3D::CCloudScape *_CS;
634 // The root of all objects added to the scene. Rotated for user convenience
635 NL3D::CTransform *_SceneRoot;
639 // load the config file
640 void loadConfigFile();
641 // get path of the dll
642 std::string getModulePath() const;
643 // load driver name from the config file
644 void loadDriverName();
646 void drawFXUserMatrix();
647 void drawFXMatrix();
648 void drawSceneMatrix();
650 void drawNamedMatrix(const NLMISC::CMatrix &matrix, const std::string &name, NLMISC::CRGBA color, float textZOffset, float testSize);
653 void setRegisterWindowState (const CWnd *pWnd, const TCHAR* keyName);
654 void getRegisterWindowState (CWnd *pWnd, const TCHAR* keyName, bool resize);
656 /** display a localized message box. Caption an message text are retrieved from the string table
657 * \param parentWindow Pointer to initiator of the message box
658 * \param messageStringID ID in string table of the message box content
659 * \param captionStringID ID in string table of the message box caption
660 * \param nType Type of message box (the same as the last parameter of ::MessageBox)
661 * \return Same value than ::MessageBox
663 int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStringID, UINT nType);
664 int localizedMessageBox(HWND parentWindow, const TCHAR *message, int captionStringID, UINT nType);
666 // Return a string from the string table
667 CString getStrRsc(uint stringID);
670 bool browseFolder(const CString &caption, CString &destFolder, HWND parent);
673 //{{AFX_INSERT_LOCATION}}
674 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
676 #endif // !defined(AFX_OBJECT_VIEWER_H__9B22CB84_1929_11D5_9CD4_0050DAC3A412__INCLUDED_)