瀏覽代碼

textured cube

develop
Robin Thoni 8 年之前
父節點
當前提交
f4c3c52515

+ 63
- 1
TheGame/openglrenderdevice.cpp 查看文件

@@ -1,4 +1,5 @@
1 1
 #include "openglrenderdevice.h"
2
+#include <QRgb>
2 3
 #include "GL/gl.h"
3 4
 #include "GL/glu.h"
4 5
 
@@ -38,6 +39,36 @@ Vector3D OpenGLRenderDevice::get3DFrom2D(int x, int y)
38 39
     return Vector3D(gx, gy, gz);
39 40
 }
40 41
 
42
+void OpenGLRenderDevice::loadTexture(const QVariant &id, const QImage &texture)
43
+{
44
+    OpenGLTextureData data;
45
+    data.id = 0;
46
+    data.image = texture;
47
+    data.rawData = new char[texture.width() * texture.height() * 4];
48
+
49
+    for (int y = 0; y < texture.height(); ++y) {
50
+        for(int x = 0; x < texture.width(); ++x) {
51
+            int p = (y * texture.height() * 4) + x * 4;
52
+            QColor px = QColor(texture.pixel(x, y));
53
+            data.rawData[p] = px.red();
54
+            data.rawData[p + 1] = px.green();
55
+            data.rawData[p + 2] = px.blue();
56
+            data.rawData[p + 3] = 255;
57
+        }
58
+    }
59
+
60
+
61
+    glGenTextures(1, &data.id);
62
+    glBindTexture(GL_TEXTURE_2D, data.id);
63
+
64
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.width(), texture.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.rawData);
65
+
66
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
67
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
68
+
69
+    _textures.insert(id, data);
70
+}
71
+
41 72
 void OpenGLRenderDevice::initialize(int fov, int width, int height)
42 73
 {
43 74
     _fov = fov;
@@ -47,6 +78,19 @@ void OpenGLRenderDevice::initialize(int fov, int width, int height)
47 78
     glClearColor(_clearColor.redF(), _clearColor.greenF(),
48 79
                  _clearColor.blueF(), _clearColor.alphaF());
49 80
 
81
+//    glShadeModel(GL_SMOOTH);
82
+//    glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
83
+//    glColorMaterial(GL_FRONT,GL_SPECULAR);
84
+//    glCullFace(GL_BACK);
85
+
86
+//    glEnable(GL_LIGHTING);
87
+//    glEnable(GL_LIGHT0);
88
+//    glEnable(GL_COLOR_MATERIAL);
89
+//    glEnable(GL_CULL_FACE);
90
+    glEnable(GL_TEXTURE_2D);
91
+
92
+//    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
93
+
50 94
 
51 95
 //    GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0};  /* Red diffuse light. */
52 96
 //    GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};  /* Infinite light location. */
@@ -55,9 +99,14 @@ void OpenGLRenderDevice::initialize(int fov, int width, int height)
55 99
 //    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, light_diffuse);
56 100
 //    glEnable(GL_LIGHT0);
57 101
 //    glEnable(GL_LIGHTING);
58
-    glDisable(GL_LIGHTING);
59 102
 
60 103
     glEnable(GL_DEPTH_TEST);
104
+//    glDisable(GL_BLEND);
105
+//    glDisable(GL_POLYGON_SMOOTH);
106
+//    glEnable(GL_TEXTURE_2D);
107
+//    glColorMaterial(GL_FRONT,GL_SPECULAR);
108
+//    glEnable(GL_COLOR_MATERIAL);
109
+//    glEnable(GL_CULL_FACE);
61 110
 
62 111
     glMatrixMode(GL_PROJECTION);
63 112
     gluPerspective(_fov, _width / _height, 0.1, 100.0);
@@ -120,3 +169,16 @@ void OpenGLRenderDevice::drawPolygon(const QList<ColorVector3D> &points)
120 169
     }
121 170
     glEnd();
122 171
 }
172
+
173
+void OpenGLRenderDevice::drawPolygonTexture(const QList<TextureVector3D> &points, const QVariant &textureId)
174
+{
175
+    const OpenGLTextureData& data = _textures[textureId];
176
+    glBindTexture(GL_TEXTURE_2D, data.id);
177
+    glBegin(GL_POLYGON);
178
+    for (int i = 0; i < points.size(); ++i) {
179
+        TextureVector3D p = points[i];
180
+        glTexCoord2d(p.getTextureCoord().getX(), p.getTextureCoord().getY());
181
+        drawVertex(p);
182
+    }
183
+    glEnd();
184
+}

+ 13
- 0
TheGame/openglrenderdevice.h 查看文件

@@ -3,6 +3,13 @@
3 3
 
4 4
 #include "engine/abstractrenderdevice.h"
5 5
 
6
+struct OpenGLTextureData
7
+{
8
+    unsigned id;
9
+    QImage image;
10
+    char* rawData;
11
+};
12
+
6 13
 class OpenGLRenderDevice : public AbstractRenderDevice
7 14
 {
8 15
     Q_OBJECT
@@ -17,6 +24,8 @@ signals:
17 24
 
18 25
 public slots:
19 26
 
27
+    virtual void loadTexture(const QVariant& id, const QImage& texture);
28
+
20 29
     virtual void initialize(int fov, int width, int height);
21 30
 
22 31
     virtual void resize(int width, int height);
@@ -33,6 +42,8 @@ public slots:
33 42
 
34 43
     virtual void drawPolygon(const QList<ColorVector3D>& points);
35 44
 
45
+    virtual void drawPolygonTexture(const QList<TextureVector3D>& points, const QVariant& textureId);
46
+
36 47
 private:
37 48
     int _width;
38 49
 
@@ -40,6 +51,8 @@ private:
40 51
 
41 52
     int _fov;
42 53
 
54
+    QMap<QVariant, OpenGLTextureData> _textures;
55
+
43 56
 };
44 57
 
45 58
 #endif // OPENGLRENDERDEVICE_H

+ 7
- 4
TheGame/renderwidget.cpp 查看文件

@@ -15,9 +15,11 @@ RenderWidget::RenderWidget(QWidget *parent) :
15 15
 {
16 16
     _device = new OpenGLRenderDevice(this);
17 17
     _engine = new UGameEngine(_device);
18
+
18 19
     UGEEntityCube* cube = new UGEEntityCube(_engine);
20
+    cube->setTextureId("test");
19 21
 //    cube->move(Vector3D(0, 1, 0));
20
-    cube->hide();
22
+//    cube->hide();
21 23
     _engine->addEntity(cube);
22 24
     _engine->addEntity(new UGEEntityAxes(_engine));
23 25
     setMouseTracking(true);
@@ -28,7 +30,7 @@ RenderWidget::RenderWidget(QWidget *parent) :
28 30
 
29 31
     UGEEntityWaveFrontObj* obj = new UGEEntityWaveFrontObj(wavefrontObj, this);
30 32
     _engine->addEntity(obj);
31
-//    obj->hide();
33
+    obj->hide();
32 34
 
33 35
 }
34 36
 
@@ -38,6 +40,7 @@ void RenderWidget::initializeGL()
38 40
     _device->setClearColor(Qt::gray);
39 41
     _device->initialize(70, width(), height());
40 42
 
43
+    _device->loadTextureFromFile("test", "/home/robin/Downloads/test.png");
41 44
 }
42 45
 
43 46
 void RenderWidget::paintGL()
@@ -51,8 +54,8 @@ void RenderWidget::paintGL()
51 54
                 );
52 55
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
53 56
     _engine->draw();
54
-    _device->drawLine(ColorVector3D(Qt::black, 0, 0, 0), ColorVector3D(Qt::black, pos));
55
-    _device->drawPoint(ColorVector3D(Qt::magenta, 0.5, 0.5, 0.5));
57
+//    _device->drawLine(ColorVector3D(Qt::black, 0, 0, 0), ColorVector3D(Qt::black, pos));
58
+//    _device->drawPoint(ColorVector3D(Qt::magenta, 0.5, 0.5, 0.5));
56 59
 }
57 60
 
58 61
 void RenderWidget::resizeGL(int width, int height)

+ 7
- 7
UGameEngine/engine/abstractrenderdevice.cpp 查看文件

@@ -43,13 +43,13 @@ void AbstractRenderDevice::lookAt(const Vector3D &eye, const Vector3D &center, c
43 43
     _lookUp = up;
44 44
 }
45 45
 
46
-//void AbstractRenderDevice::loadTextureFromFile(const QVariant &id, const QString &filename)
47
-//{
48
-//    QImage img;
49
-//    if (img.load(filename)) {
50
-//        loadTexture(id, img);
51
-//    }
52
-//}
46
+void AbstractRenderDevice::loadTextureFromFile(const QVariant &id, const QString &filename)
47
+{
48
+    QImage img;
49
+    if (img.load(filename)) {
50
+        loadTexture(id, img);
51
+    }
52
+}
53 53
 
54 54
 QColor AbstractRenderDevice::getClearColor() const
55 55
 {

+ 5
- 3
UGameEngine/engine/abstractrenderdevice.h 查看文件

@@ -3,7 +3,9 @@
3 3
 
4 4
 #include <QObject>
5 5
 #include <QColor>
6
+#include <QImage>
6 7
 #include "utils/colorvector3d.h"
8
+#include "utils/texturevector3d.h"
7 9
 
8 10
 class AbstractRenderDevice : public QObject
9 11
 {
@@ -34,9 +36,9 @@ public slots:
34 36
 
35 37
     virtual void lookAt(const Vector3D& eye, const Vector3D& center, const Vector3D& up = Vector3D(0.0, 1.0, 0.0));
36 38
 
37
-//    void loadTextureFromFile(const QVariant& id, const QString& filename);
39
+    void loadTextureFromFile(const QVariant& id, const QString& filename);
38 40
 
39
-//    virtual void loadTexture(const QVariant& id, const QImage& texture) = 0;
41
+    virtual void loadTexture(const QVariant& id, const QImage& texture) = 0;
40 42
 
41 43
     virtual void initialize(int fov, int width, int height) = 0;
42 44
 
@@ -52,7 +54,7 @@ public slots:
52 54
 
53 55
     virtual void drawPolygon(const QList<ColorVector3D>& points) = 0;
54 56
 
55
-//    virtual void drawPolygonTexture(const QList<ColorVector3D>& points) = 0;
57
+    virtual void drawPolygonTexture(const QList<TextureVector3D>& points, const QVariant& textureId) = 0;
56 58
 
57 59
 protected:
58 60
     QColor _clearColor;

+ 13
- 0
UGameEngine/entities/ugeentity.cpp 查看文件

@@ -99,6 +99,11 @@ ColorVector3D UGEEntity::getRealPoint(const ColorVector3D &pos)
99 99
     return ColorVector3D(pos.getColor(), getRealPoint((Vector3D)pos));
100 100
 }
101 101
 
102
+TextureVector3D UGEEntity::getRealPoint(const TextureVector3D &pos)
103
+{
104
+    return TextureVector3D(pos.getTextureCoord(), getRealPoint((ColorVector3D)pos));
105
+}
106
+
102 107
 void UGEEntity::drawPoint(AbstractRenderDevice *device, const ColorVector3D &point)
103 108
 {
104 109
     device->drawPoint(getRealPoint(point));
@@ -116,3 +121,11 @@ void UGEEntity::drawPolygon(AbstractRenderDevice *device, QList<ColorVector3D> p
116 121
     }
117 122
     device->drawPolygon(points);
118 123
 }
124
+
125
+void UGEEntity::drawPolygonTexture(AbstractRenderDevice *device, QList<TextureVector3D> points, const QVariant &textureId)
126
+{
127
+    for (int i = 0; i < points.size(); ++i) {
128
+        points[i] = getRealPoint(points[i]);
129
+    }
130
+    device->drawPolygonTexture(points, textureId);
131
+}

+ 3
- 0
UGameEngine/entities/ugeentity.h 查看文件

@@ -37,6 +37,7 @@ public:
37 37
 
38 38
     Vector3D getRealPoint(const Vector3D& pos);
39 39
     ColorVector3D getRealPoint(const ColorVector3D& pos);
40
+    TextureVector3D getRealPoint(const TextureVector3D& pos);
40 41
 
41 42
     virtual void drawPoint(AbstractRenderDevice* device, const ColorVector3D& point);
42 43
 
@@ -44,6 +45,8 @@ public:
44 45
 
45 46
     virtual void drawPolygon(AbstractRenderDevice* device, QList<ColorVector3D> points);
46 47
 
48
+    virtual void drawPolygonTexture(AbstractRenderDevice *device, QList<TextureVector3D> points, const QVariant& textureId);
49
+
47 50
     virtual void draw(AbstractRenderDevice* device) = 0;
48 51
 
49 52
 private:

+ 52
- 10
UGameEngine/entities/ugeentitycube.cpp 查看文件

@@ -13,17 +13,53 @@ float UGEEntityCube::getSize() const
13 13
 
14 14
 void UGEEntityCube::draw(AbstractRenderDevice *device)
15 15
 {
16
-    QColor color = Qt::red;
17 16
     float r = _size / 2;
18
-    QList<ColorVector3D> points;
19
-    points << ColorVector3D(color, -r, -r, r) << ColorVector3D(color, -r, r, r) << ColorVector3D(color, r, r, r) << ColorVector3D(color, r, -r, r);
20
-    points << ColorVector3D(color, -r, -r, -r) << ColorVector3D(color, -r, r, -r) << ColorVector3D(color, r, r, -r) << ColorVector3D(color, r, -r, -r);
21
-    drawPolygon(device, QList<ColorVector3D>() << points[3] << points[2] << points[1] << points[0]);
22
-    drawPolygon(device, QList<ColorVector3D>() << points[2] << points[3] << points[7] << points[6]);
23
-    drawPolygon(device, QList<ColorVector3D>() << points[6] << points[7] << points[4] << points[5]);
24
-    drawPolygon(device, QList<ColorVector3D>() << points[5] << points[4] << points[0] << points[1]);
25
-    drawPolygon(device, QList<ColorVector3D>() << points[1] << points[2] << points[6] << points[5]);
26
-    drawPolygon(device, QList<ColorVector3D>() << points[4] << points[7] << points[3] << points[0]);
17
+    if (_textureId.isNull()) {
18
+        QColor color = Qt::red;
19
+        QList<ColorVector3D> points;
20
+        points << ColorVector3D(color, -r, -r, r)  << ColorVector3D(color, -r, r, r)
21
+               << ColorVector3D(color, r, r, r)    << ColorVector3D(color, r, -r, r)
22
+               << ColorVector3D(color, -r, -r, -r) << ColorVector3D(color, -r, r, -r)
23
+               << ColorVector3D(color, r, r, -r)   << ColorVector3D(color, r, -r, -r);
24
+        drawPolygon(device, QList<ColorVector3D>() << points[3] << points[2] << points[1] << points[0]);
25
+        drawPolygon(device, QList<ColorVector3D>() << points[2] << points[3] << points[7] << points[6]);
26
+        drawPolygon(device, QList<ColorVector3D>() << points[6] << points[7] << points[4] << points[5]);
27
+        drawPolygon(device, QList<ColorVector3D>() << points[5] << points[4] << points[0] << points[1]);
28
+        drawPolygon(device, QList<ColorVector3D>() << points[1] << points[2] << points[6] << points[5]);
29
+        drawPolygon(device, QList<ColorVector3D>() << points[4] << points[7] << points[3] << points[0]);
30
+    }
31
+    else {
32
+        QColor color = Qt::white;
33
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.25, 0.50), color, r, -r, r)
34
+                           << TextureVector3D(Vector2D(0.25, 0.25), color, r, r, r)
35
+                           << TextureVector3D(Vector2D(0.00, 0.25), color, -r, r, r)
36
+                           << TextureVector3D(Vector2D(0.00, 0.50), color, -r, -r, r), _textureId);
37
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.25, 0.50), color, r, r, r)
38
+                           << TextureVector3D(Vector2D(0.25, 0.25), color, r, -r, r)
39
+                           << TextureVector3D(Vector2D(0.50, 0.25), color, r, -r, -r)
40
+                           << TextureVector3D(Vector2D(0.50, 0.50), color, r, r, -r), _textureId);
41
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.50, 0.25), color, r, r, -r)
42
+                           << TextureVector3D(Vector2D(0.50, 0.50), color, r, -r, -r)
43
+                           << TextureVector3D(Vector2D(0.75, 0.50), color, -r, -r, -r)
44
+                           << TextureVector3D(Vector2D(0.75, 0.25), color, -r, r, -r), _textureId);
45
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.75, 0.25), color, -r, r, -r)
46
+                           << TextureVector3D(Vector2D(0.75, 0.50), color, -r, -r, -r)
47
+                           << TextureVector3D(Vector2D(1.00, 0.50), color, -r, -r, r)
48
+                           << TextureVector3D(Vector2D(1.00, 0.25), color, -r, r, r), _textureId);
49
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.25, 0.00), color, -r, r, r)
50
+                           << TextureVector3D(Vector2D(0.25, 0.25), color, r, r, r)
51
+                           << TextureVector3D(Vector2D(0.50, 0.25), color, r, r, -r)
52
+                           << TextureVector3D(Vector2D(0.50, 0.00), color, -r, r, -r), _textureId);
53
+        drawPolygonTexture(device, QList<TextureVector3D>() << TextureVector3D(Vector2D(0.50, 0.75), color, -r, -r, -r)
54
+                           << TextureVector3D(Vector2D(0.50, 0.50), color, r, -r, -r)
55
+                           << TextureVector3D(Vector2D(0.25, 0.5), color, r, -r, r)
56
+                           << TextureVector3D(Vector2D(0.25, 0.75), color, -r, -r, r), _textureId);
57
+    }
58
+}
59
+
60
+QVariant UGEEntityCube::getTextureId() const
61
+{
62
+    return _textureId;
27 63
 }
28 64
 
29 65
 void UGEEntityCube::setSize(float size)
@@ -31,3 +67,9 @@ void UGEEntityCube::setSize(float size)
31 67
     _size = size;
32 68
 }
33 69
 
70
+void UGEEntityCube::setTextureId(const QVariant &textureId)
71
+{
72
+    _textureId = textureId;
73
+}
74
+
75
+

+ 4
- 0
UGameEngine/entities/ugeentitycube.h 查看文件

@@ -13,13 +13,17 @@ public:
13 13
 
14 14
     virtual void draw(AbstractRenderDevice* device);
15 15
 
16
+    QVariant getTextureId() const;
17
+
16 18
 signals:
17 19
 
18 20
 public slots:
19 21
     void setSize(float size);
22
+    void setTextureId(const QVariant &textureId);
20 23
 
21 24
 private:
22 25
     float _size;
26
+    QVariant _textureId;
23 27
 
24 28
 };
25 29
 

+ 14
- 2
UGameEngine/utils/colorvector3d.cpp 查看文件

@@ -1,12 +1,24 @@
1 1
 #include "colorvector3d.h"
2 2
 
3
-ColorVector3D::ColorVector3D(QColor color, double x, double y, double z)
3
+ColorVector3D::ColorVector3D()
4
+    : Vector3D(0.0, 0.0, 0.0)
5
+    , _color(Qt::black)
6
+{
7
+}
8
+
9
+ColorVector3D::ColorVector3D(const QColor &color)
10
+    : Vector3D(0.0, 0.0, 0.0)
11
+    , _color(color)
12
+{
13
+}
14
+
15
+ColorVector3D::ColorVector3D(const QColor &color, double x, double y, double z)
4 16
     : Vector3D(x, y, z)
5 17
     , _color(color)
6 18
 {
7 19
 }
8 20
 
9
-ColorVector3D::ColorVector3D(QColor color, const Vector3D &other)
21
+ColorVector3D::ColorVector3D(const QColor& color, const Vector3D &other)
10 22
     : Vector3D(other)
11 23
     , _color(color)
12 24
 {

+ 4
- 2
UGameEngine/utils/colorvector3d.h 查看文件

@@ -7,8 +7,10 @@
7 7
 class ColorVector3D : public Vector3D
8 8
 {
9 9
 public:
10
-    ColorVector3D(QColor color = Qt::black, double x = 0.0, double y = 0.0, double z = 0.0);
11
-    ColorVector3D(QColor color = Qt::black, const Vector3D& other = Vector3D());
10
+    ColorVector3D();
11
+    ColorVector3D(const QColor& color);
12
+    ColorVector3D(const QColor& color, double x, double y, double z);
13
+    ColorVector3D(const QColor& color, const Vector3D& other);
12 14
     ColorVector3D(const ColorVector3D& other);
13 15
     virtual ~ColorVector3D();
14 16
 

+ 1
- 1
UGameEngine/utils/parser-wavefront-obj.y 查看文件

@@ -94,7 +94,7 @@ vertex_space: VP NUMBER NUMBER NUMBER {};
94 94
 face: F face_vertex_list { $$ = $2; };
95 95
 
96 96
 face_vertex_list: { $$ = new QList<int>(); }
97
-            | face_vertex_list face_vertex { $1->append($2); };
97
+            | face_vertex_list face_vertex { $1->append($2); $$ = $1;};
98 98
 
99 99
 face_vertex: NUMBER { $$ = $1; }
100 100
             | NUMBER SLASH NUMBER { $$ = $1; }

+ 52
- 0
UGameEngine/utils/texturevector3d.cpp 查看文件

@@ -1,5 +1,57 @@
1 1
 #include "texturevector3d.h"
2 2
 
3
+TextureVector3D::TextureVector3D()
4
+    : ColorVector3D(Qt::white, 0.0, 0.0, 0.0)
5
+    , _textureCoord(0.0, 0.0)
6
+{
7
+}
8
+
9
+TextureVector3D::TextureVector3D(const Vector2D &textureCoord)
10
+    : ColorVector3D(Qt::white, 0.0, 0.0, 0.0)
11
+    , _textureCoord(textureCoord)
12
+{
13
+}
14
+
15
+TextureVector3D::TextureVector3D(const Vector2D &textureCoord, const QColor &color)
16
+    : ColorVector3D(color, 0.0, 0.0, 0.0)
17
+    , _textureCoord(textureCoord)
18
+{
19
+}
20
+
21
+TextureVector3D::TextureVector3D(const Vector2D &textureCoord, const QColor &color, double x, double y, double z)
22
+    : ColorVector3D(color, x, y, z)
23
+    , _textureCoord(textureCoord)
24
+{
25
+}
26
+
27
+TextureVector3D::TextureVector3D(const Vector2D &textureCoord, const QColor& color, const Vector3D &other)
28
+    : ColorVector3D(color, other)
29
+    , _textureCoord(textureCoord)
30
+{
31
+}
32
+
33
+TextureVector3D::TextureVector3D(const Vector2D &textureCoord, const ColorVector3D &other)
34
+    : ColorVector3D(other)
35
+    , _textureCoord(textureCoord)
36
+{
37
+}
38
+
39
+TextureVector3D::TextureVector3D(const TextureVector3D &other)
40
+    : ColorVector3D(other)
41
+    , _textureCoord(other._textureCoord)
42
+{
43
+}
44
+
3 45
 TextureVector3D::~TextureVector3D()
4 46
 {
5 47
 }
48
+
49
+Vector2D TextureVector3D::getTextureCoord() const
50
+{
51
+    return _textureCoord;
52
+}
53
+
54
+void TextureVector3D::setTextureCoord(const Vector2D &textureCoord)
55
+{
56
+    _textureCoord = textureCoord;
57
+}

+ 14
- 3
UGameEngine/utils/texturevector3d.h 查看文件

@@ -2,14 +2,25 @@
2 2
 #define TEXTUREVECTOR3D_H
3 3
 
4 4
 #include "colorvector3d.h"
5
+#include "vector2d.h"
5 6
 
6 7
 class TextureVector3D : public ColorVector3D
7 8
 {
8 9
 public:
9
-    TextureVector3D(QColor color = Qt::white, double x = 0.0, double y = 0.0, double z = 0.0);
10
-    TextureVector3D(QColor color = Qt::white, const Vector3D& other = Vector3D());
11
-    TextureVector3D(const ColorVector3D& other);
10
+    TextureVector3D();
11
+    TextureVector3D(const Vector2D& textureCoord);
12
+    TextureVector3D(const Vector2D& textureCoord, const QColor& color);
13
+    TextureVector3D(const Vector2D& textureCoord, const QColor& color, double x, double y, double z);
14
+    TextureVector3D(const Vector2D& textureCoord, const QColor& color, const Vector3D& other);
15
+    TextureVector3D(const Vector2D& textureCoord, const ColorVector3D& other);
16
+    TextureVector3D(const TextureVector3D& other);
12 17
     virtual ~TextureVector3D();
18
+
19
+    Vector2D getTextureCoord() const;
20
+    void setTextureCoord(const Vector2D &textureCoord);
21
+
22
+private:
23
+    Vector2D _textureCoord;
13 24
 };
14 25
 
15 26
 #endif // TEXTUREVECTOR3D_H

Loading…
取消
儲存