RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
qglgameeditorviewport.h
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #ifndef RIOENGINE_EDITOR_QGLGAMEEDITORVIEWPORT_QGLGAMEEDITORVIEWPORT_H_
31 #define RIOENGINE_EDITOR_QGLGAMEEDITORVIEWPORT_QGLGAMEEDITORVIEWPORT_H_
32 
33 #include "misc/transform.h"
36 
37 class CGameObject;
38 
40  Q_OBJECT
41  public:
42  enum AxisTypes { NOAXIS, X, Y, Z };
45 
46  QGLGameEditorViewport(CLScene* collada_scene, CGameScene* game_scene);
47 
48  void setSelectedGameObjectUID(uint);
49  uint selectedGameObjectUID() const;
50 
51  int cameraSpeed() const;
52  int nextCameraSpeed();
53 
54  bool autoRecalcAABBOnResize() const;
55  void setAutoRecalcAABBOnResize(bool);
56 
59 
62 
64 
65 protected:
70  float getMotionThroughAxis(btVector3&, Vector2);
71 
77  btVector3 calcTranslationVec(btVector3&, Vector2, btMatrix3x3&, float, Transform::TransformMode, AxisTypes);
78 
83  btVector3 calcScaleVec(AxisTypes, float, bool);
84 
85  void mousePressEvent(QMouseEvent * event);
86  void mouseMoveEvent(QMouseEvent *event);
87  void wheelEvent(QWheelEvent* event);
88  void mouseReleaseEvent(QMouseEvent *event);
89 
90  void drawSolidCone(GLdouble, GLdouble, GLint, GLint);
91 
96  void drawManipulatorsForGameObject(uint uid);
98  ManipulatorTypes manipulator_type,
99  Transform::TransformMode transform_mode,
100  btVector3 &scale);
102  Transform::TransformMode transform_mode,
103  btVector3 &scale);
104  void manipulatorMoved(ManipulatorTypes manipulator_type,
105  int dx,
106  int dy);
107 
111  AxisTypes selectAxis(int x, int y);
112 
116  uint selectObject(int x, int y);
117 
118  // from QGLBaseViewport
119  virtual void paintGL();
120  virtual void step();
121  virtual void preDraw();
122  virtual void customDraw();
123  virtual void postDraw();
124  // ---------------------
125 
126  // from QGLGameViewport
127  virtual void drawGameObject(CGameObject * game_object);
128  virtual void drawSkybox();
129  virtual void drawCrosshair();
130  // ---------------------
131 
133  QPoint m_lastPos;
140  QMap<uint, QColor> m_nodesColor;
141 
142 private:
143  int m_cameraSpeed;
144  bool m_autoRecalcAABBOnResize;
145  bool m_isFirstStep;
146  btVector3 x_axis, y_axis, z_axis;
147 
148  ManipulatorTypes m_selectedManipulatorType;
149  Transform::TransformMode m_selectedTransformMode;
150 
151 signals:
152  void newGameObjectSelected(uint);
154 };
155 
156 #endif // RIOENGINE_EDITOR_QGLGAMEEDITORVIEWPORT_QGLGAMEEDITORVIEWPORT_H_
void newGameObjectSelected(uint)
btVector3 calcScaleVec(AxisTypes, float, bool)
Calculates the differential scale vector based upon the given axis direction and differential size...
AxisTypes selectAxis(int x, int y)
Returns the picked axis by the user.
void mouseMoveEvent(QMouseEvent *event)
void drawRotationManipulatorsForNode(CLNode *node, Transform::TransformMode transform_mode, btVector3 &scale)
Definition: clnode.h:37
float getMotionThroughAxis(btVector3 &, Vector2)
Determines how parallel is the mouse movement to a manipulator axis.
uint selectObject(int x, int y)
Returns the selected game object (if any) at the given coordinates.
btVector3 calcTranslationVec(btVector3 &, Vector2, btMatrix3x3 &, float, Transform::TransformMode, AxisTypes)
Calculates the differential translation vector based upon the object's position, rotation, and the motion vector.
void wheelEvent(QWheelEvent *event)
void drawSolidCone(GLdouble, GLdouble, GLint, GLint)
void drawCommonManipulatorsForNode(CLNode *node, ManipulatorTypes manipulator_type, Transform::TransformMode transform_mode, btVector3 &scale)
QGLGameEditorViewport(CLScene *collada_scene, CGameScene *game_scene)
void manipulatorMoved(ManipulatorTypes manipulator_type, int dx, int dy)
virtual void drawGameObject(CGameObject *game_object)
void mousePressEvent(QMouseEvent *event)
Transform::TransformMode selectedTransformMode() const
void mouseReleaseEvent(QMouseEvent *event)
void drawManipulatorsForGameObject(uint uid)
Draws the Translation, Rotation or Scale manipulators for the given game object's unique id...
ManipulatorTypes selectedManipulatorType() const
QMap< uint, QColor > m_nodesColor
void setSelectedTransformMode(const Transform::TransformMode &value)
void selectedGameObjectTransformChanged(QGLGameEditorViewport::ManipulatorTypes)
void setSelectedManipulatorType(const ManipulatorTypes &value)