Browse Source

added axes entity

develop
Robin Thoni 7 years ago
parent
commit
f721ad455a

+ 2
- 12
TheGame/renderwidget.cpp View File

@@ -3,6 +3,7 @@
3 3
 #include <math.h>
4 4
 #include <QDebug>
5 5
 #include "entities/ugeentitycube.h"
6
+#include "entities/ugeentityaxes.h"
6 7
 
7 8
 RenderWidget::RenderWidget(QWidget *parent) :
8 9
     QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
@@ -17,6 +18,7 @@ RenderWidget::RenderWidget(QWidget *parent) :
17 18
     UGEEntityCube* cube = new UGEEntityCube(_engine);
18 19
     cube->move(Vector3D(0, 1, 0));
19 20
     _engine->addEntity(cube);
21
+    _engine->addEntity(new UGEEntityAxes(_engine));
20 22
     setMouseTracking(false);
21 23
     setFocusPolicy(Qt::StrongFocus);
22 24
 }
@@ -40,8 +42,6 @@ void RenderWidget::paintGL()
40 42
                 );
41 43
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
42 44
     _engine->draw();
43
-
44
-    drawAxes();
45 45
 }
46 46
 
47 47
 void RenderWidget::resizeGL(int width, int height)
@@ -110,13 +110,3 @@ void RenderWidget::rotate(float phi, float theta)
110 110
     }
111 111
     update();
112 112
 }
113
-
114
-void RenderWidget::drawAxes()
115
-{
116
-    _device->drawLine(ColorVector3D(Qt::red, 0.0, 0.0, 0.0), ColorVector3D(Qt::red, 1.0, 0.0, 0.0), 2.5);
117
-    _device->drawLine(ColorVector3D(Qt::green, 0.0, 0.0, 0.0), ColorVector3D(Qt::green, 0.0, 1.0, 0.0), 2.5);
118
-    _device->drawLine(ColorVector3D(Qt::blue, 0.0, 0.0, 0.0), ColorVector3D(Qt::blue, 0.0, 0.0, 1.0), 2.5);
119
-
120
-    _device->drawPolygon(QList<ColorVector3D>() << ColorVector3D(Qt::red, 0, 0, 0) << ColorVector3D(Qt::green, 1, 0, 0) << ColorVector3D(Qt::transparent, 1, 1, 0) << ColorVector3D(Qt::blue, 0, 1, 0));
121
-
122
-}

+ 0
- 1
TheGame/renderwidget.h View File

@@ -31,7 +31,6 @@ protected:
31 31
 signals:
32 32
 
33 33
 public slots:
34
-    void drawAxes();
35 34
 
36 35
 private:
37 36
     OpenGLRenderDevice* _device;

+ 4
- 2
UGameEngine/UGameEngine.pro View File

@@ -16,14 +16,16 @@ SOURCES += engine/ugameengine.cpp \
16 16
     entities/ugeentity.cpp \
17 17
     utils/vector3d.cpp \
18 18
     utils/colorvector3d.cpp \
19
-    entities/ugeentitycube.cpp
19
+    entities/ugeentitycube.cpp \
20
+    entities/ugeentityaxes.cpp
20 21
 
21 22
 HEADERS += engine/ugameengine.h\
22 23
     engine/abstractrenderdevice.h \
23 24
     entities/ugeentity.h \
24 25
     utils/vector3d.h \
25 26
     utils/colorvector3d.h \
26
-    entities/ugeentitycube.h
27
+    entities/ugeentitycube.h \
28
+    entities/ugeentityaxes.h
27 29
 
28 30
 unix {
29 31
     target.path = /usr/lib

+ 13
- 0
UGameEngine/entities/ugeentityaxes.cpp View File

@@ -0,0 +1,13 @@
1
+#include "ugeentityaxes.h"
2
+
3
+UGEEntityAxes::UGEEntityAxes(QObject *parent) :
4
+    UGEEntity(parent)
5
+{
6
+}
7
+
8
+void UGEEntityAxes::draw(AbstractRenderDevice *device)
9
+{
10
+    drawLine(device, ColorVector3D(Qt::red, 0.0, 0.0, 0.0), ColorVector3D(Qt::red, 1.0, 0.0, 0.0), 2.5);
11
+    drawLine(device, ColorVector3D(Qt::green, 0.0, 0.0, 0.0), ColorVector3D(Qt::green, 0.0, 1.0, 0.0), 2.5);
12
+    drawLine(device, ColorVector3D(Qt::blue, 0.0, 0.0, 0.0), ColorVector3D(Qt::blue, 0.0, 0.0, 1.0), 2.5);
13
+}

+ 20
- 0
UGameEngine/entities/ugeentityaxes.h View File

@@ -0,0 +1,20 @@
1
+#ifndef UGEENTITYAXES_H
2
+#define UGEENTITYAXES_H
3
+
4
+#include "entities/ugeentity.h"
5
+
6
+class UGEEntityAxes : public UGEEntity
7
+{
8
+    Q_OBJECT
9
+public:
10
+    explicit UGEEntityAxes(QObject *parent = 0);
11
+
12
+    virtual void draw(AbstractRenderDevice* device);
13
+
14
+signals:
15
+
16
+public slots:
17
+
18
+};
19
+
20
+#endif // UGEENTITYAXES_H

Loading…
Cancel
Save