Browse Source

added axes entity

develop
Robin Thoni 7 years ago
parent
commit
f721ad455a

+ 2
- 12
TheGame/renderwidget.cpp View File

3
 #include <math.h>
3
 #include <math.h>
4
 #include <QDebug>
4
 #include <QDebug>
5
 #include "entities/ugeentitycube.h"
5
 #include "entities/ugeentitycube.h"
6
+#include "entities/ugeentityaxes.h"
6
 
7
 
7
 RenderWidget::RenderWidget(QWidget *parent) :
8
 RenderWidget::RenderWidget(QWidget *parent) :
8
     QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
9
     QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
17
     UGEEntityCube* cube = new UGEEntityCube(_engine);
18
     UGEEntityCube* cube = new UGEEntityCube(_engine);
18
     cube->move(Vector3D(0, 1, 0));
19
     cube->move(Vector3D(0, 1, 0));
19
     _engine->addEntity(cube);
20
     _engine->addEntity(cube);
21
+    _engine->addEntity(new UGEEntityAxes(_engine));
20
     setMouseTracking(false);
22
     setMouseTracking(false);
21
     setFocusPolicy(Qt::StrongFocus);
23
     setFocusPolicy(Qt::StrongFocus);
22
 }
24
 }
40
                 );
42
                 );
41
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
43
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
42
     _engine->draw();
44
     _engine->draw();
43
-
44
-    drawAxes();
45
 }
45
 }
46
 
46
 
47
 void RenderWidget::resizeGL(int width, int height)
47
 void RenderWidget::resizeGL(int width, int height)
110
     }
110
     }
111
     update();
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
 signals:
31
 signals:
32
 
32
 
33
 public slots:
33
 public slots:
34
-    void drawAxes();
35
 
34
 
36
 private:
35
 private:
37
     OpenGLRenderDevice* _device;
36
     OpenGLRenderDevice* _device;

+ 4
- 2
UGameEngine/UGameEngine.pro View File

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

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

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

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