Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ViewerApp.h
Go to the documentation of this file.
1 // Copyright (C) 2008-2012 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This file is part of Core Designer.
7 //
8 // Core Designer is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Core Designer is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 #ifndef VIEWERAPP_H
24 #define VIEWERAPP_H
25 
26 #include "../Libs/Graphics_LIB/GUI.h"
27 #include "../Libs/OgreCore_LIB/OgreCore.h"
28 #include "../Libs/Utils_LIB/UThread.h"
29 
30 #ifndef _WIN32
31 typedef void (__attribute__((stdcall)) *ObjectPickedCallback)(const char* name_, float pos_[3], float rot_[3], float scale_[3]);
32 typedef void (__attribute__((stdcall)) *ObjectListUpdatedCallback)(const char** names_, int count_);
33 #else
34 typedef void (__stdcall *ObjectPickedCallback)(const char* name_, float pos_[3], float rot_[3], float scale_[3]);
35 typedef void (__stdcall *ObjectListUpdatedCallback)(const char** names_, int count_);
36 #endif
37 
38 namespace OpenSkyNet {
39  namespace CoreDesigner3DViewer {
41 
44  public:
45  virtual ~ViewerInputListener() {}
46  virtual bool keyPressed(const OIS::KeyEvent& arg);
47  virtual bool keyReleased(const OIS::KeyEvent& arg);
48  };
49 
57  CEGUI::WindowManager* _wMgr;
58  std::string _sceneGraphXML, _coreObjectsXML;
59  Ogre::SceneNode* _objNode;
60  Core::Cinematographer* _cine;
61  std::set<CD::Volume*> _volumes;
62  const Ogre::Vector3* _vCorners;
63  Math::Point<> _pCorners[8];
64  unsigned int _keysHeldDown;
65  float _scaleSpeed, _scaleScale;
66  OBJECT_EDIT_TYPE _editType;
67 
68  const char* _entityNameToSaveScale;
69  bool _isSavingEntityScales;
70  void saveEntityScaleToMesh();
71 
72  //Showing User Messages
73  std::queue<std::string> _msgs;
74  void showUserMessage(const char* msg_, bool clearQueue_=true, bool queue_=false, bool showCancel_=false);
75 
76  //Critical section for data accessed by the UI thread
78 
79  //Synchronization event between this app and the UI thread
80  Utils::SyncEvent _entityScaleSavedEvent;
81  public:
82  App(const char* coreObjectsXML_, const char* sceneGraphXML_);
83 
86  virtual bool setup(bool restoreOgreConfig_);
87  virtual void setupEventHandlers();
89  virtual void createCamera() {}
91  virtual void createViewports() {}
93 
95  virtual void go();
96 
98  inline void lock() { _cS.lock(); }
99  inline void unlock() { _cS.unlock(); }
100 
102  inline void waitForEntityScaleSavedEvent() { _entityScaleSavedEvent.wait(); }
103 
107  virtual void moveCamera();
108 
110  inline OBJECT_EDIT_TYPE getEditType() const { return _editType; }
111  inline void setEditType(OBJECT_EDIT_TYPE editType_) { _editType = editType_; }
112 
115  virtual bool processUnbufferedKeyInput(const Ogre::FrameEvent& evt);
116  virtual bool frameStarted(const Ogre::FrameEvent& evt);
117  virtual bool frameEnded(const Ogre::FrameEvent& evt);
119 
122  virtual void handleTransformChange(Core::Object* obj_, const Math::Point<>& prevPos_, const Math::Matrix3x3& prevRot_, float dt_);
123  virtual void handleIdle(Core::Object* obj_, float idleSecs_) {}
125 
127  void scaleObject(Core::Object* obj_, const Math::Point<>& factor_);
128 
130  static void updateObjectUI(const Core::Object* obj_);
131 
133  inline void saveEntityScaleToMesh(const char* name_) { _entityNameToSaveScale = name_; }
134  inline void setSavingEntityScales(bool isSaving_) { _isSavingEntityScales = isSaving_; }
135 
138  virtual void destroyScene(bool doDestroyPersistentData_);
140 
141  virtual ~App();
142  };
143  }
144 }
145 
146 #endif //VIEWERAPP_H
Definition: ViewerApp.h:40
void setEditType(OBJECT_EDIT_TYPE editType_)
Definition: ViewerApp.h:111
void setSavingEntityScales(bool isSaving_)
Definition: ViewerApp.h:134
OBJECT_EDIT_TYPE
Definition: ViewerApp.h:40
Definition: ViewerApp.h:40
void unlock()
Definition: UThread.h:58
int count_
Definition: ViewerApp.h:32
virtual bool frameStarted(const Ogre::FrameEvent &evt)
virtual void createViewports()
Definition: ViewerApp.h:91
void lock()
Definition: ViewerApp.h:98
virtual bool keyReleased(const OIS::KeyEvent &arg)
Definition: ViewerEventHandlers.cpp:75
Definition: CCamera.h:41
Definition: ITransformChangeListener.h:29
virtual void handleTransformChange(Core::Object *obj_, const Math::Point<> &prevPos_, const Math::Matrix3x3 &prevRot_, float dt_)
Definition: ViewerEventHandlers.cpp:221
void wait()
Definition: UThread.h:98
void __attribute__((stdcall)) nodePickedCallback(const char *name_)
Definition: ViewerDLL.cpp:55
static void updateObjectUI(const Core::Object *obj_)
Definition: ViewerApp.cpp:171
void scaleObject(Core::Object *obj_, const Math::Point<> &factor_)
Definition: ViewerApp.cpp:150
virtual void createCamera()
Definition: ViewerApp.h:89
void saveEntityScaleToMesh(const char *name_)
Definition: ViewerApp.h:133
void __stdcall ObjectPickedCallback(const char *name_, float pos_[3], float rot_[3], float scale_[3])
Definition: main.cpp:9
void __stdcall ObjectListUpdatedCallback(const char **names_, int count_)
Definition: main.cpp:12
Definition: ViewerApp.h:55
virtual ~ViewerInputListener()
Definition: ViewerApp.h:45
virtual bool frameEnded(const Ogre::FrameEvent &evt)
virtual bool processUnbufferedKeyInput(const Ogre::FrameEvent &evt)
Definition: ViewerEventHandlers.cpp:128
virtual void handleIdle(Core::Object *obj_, float idleSecs_)
Definition: ViewerApp.h:123
Definition: UThread.h:68
float float float scale_[3]
Definition: ViewerApp.h:31
Definition: ViewerApp.h:40
Definition: MPoint.h:33
OBJECT_EDIT_TYPE getEditType() const
Definition: ViewerApp.h:110
void lock()
Definition: UThread.h:57
Definition: IObject.h:36
virtual bool keyPressed(const OIS::KeyEvent &arg)
Definition: ViewerEventHandlers.cpp:34
Definition: UThread.h:38
void unlock()
Definition: ViewerApp.h:99
virtual void destroyScene(bool doDestroyPersistentData_)
App(const char *coreObjectsXML_, const char *sceneGraphXML_)
Definition: ViewerApp.cpp:107
Definition: MMatrix3x3.h:32
void waitForEntityScaleSavedEvent()
Definition: ViewerApp.h:102
typedef void(__attribute__((stdcall))*ObjectPickedCallback)(const char *name_
float float rot_[3]
Definition: ViewerApp.h:31
Definition: GUI.h:82
float pos_[3]
Definition: ViewerApp.h:31
virtual bool setup(bool restoreOgreConfig_)