Browse Source

draw multiple objects

develop
Robin Thoni 8 years ago
parent
commit
71fd696c54
2 changed files with 17 additions and 11 deletions
  1. 16
    10
      TheGame/renderwidget.cpp
  2. 1
    1
      TheGame/renderwidget.h

+ 16
- 10
TheGame/renderwidget.cpp View File

21
 
21
 
22
     _engine->addEntity(new UGEEntityAxes(_engine));
22
     _engine->addEntity(new UGEEntityAxes(_engine));
23
 
23
 
24
-    UGEEntityCube* cube = new UGEEntityCube(_engine);
25
-    cube->setTextureId("test");
26
-    cube->rotate(Vector3D(0.0, 45.0, 45.0));
27
-    cube->move(Vector3D(0, 1, 0));
28
-    cube->setScale(Vector3D(1.0, 2.0, 1.0));
29
-    cube->hide();
30
-    _engine->addEntity(cube);
24
+    for (int i = 0; i < 100; ++i) {
25
+        UGEEntityCube* cube = new UGEEntityCube(_engine);
26
+        cube->setTextureId("test");
27
+        cube->rotate(Vector3D(0.0, 45.0, 45.0));
28
+        cube->move(Vector3D(0, i, i));
29
+        cube->setScale(Vector3D(1.0, 2.0, 1.0));
30
+    //    cube->hide();
31
+        _engine->addEntity(cube);
32
+        _entities.append(cube);
33
+    }
31
 
34
 
32
     WaveFrontObj* wavefrontObj = new WaveFrontObj(this);
35
     WaveFrontObj* wavefrontObj = new WaveFrontObj(this);
33
     wavefrontObj->openFile("/home/robin/Downloads/enterprise/obj/USSEnterprise.obj");
36
     wavefrontObj->openFile("/home/robin/Downloads/enterprise/obj/USSEnterprise.obj");
34
     UGEEntityWaveFrontObj* obj = new UGEEntityWaveFrontObj(wavefrontObj, this);
37
     UGEEntityWaveFrontObj* obj = new UGEEntityWaveFrontObj(wavefrontObj, this);
35
     _engine->addEntity(obj);
38
     _engine->addEntity(obj);
39
+    _entities.append(obj);
36
 //    obj->hide();
40
 //    obj->hide();
37
-    _entity = cube;
38
-//    animate();
41
+//    _entity = cube;
42
+    animate();
39
 }
43
 }
40
 
44
 
41
 void RenderWidget::initializeGL()
45
 void RenderWidget::initializeGL()
141
 void RenderWidget::animate()
145
 void RenderWidget::animate()
142
 {
146
 {
143
 //    _angle += 0.1;
147
 //    _angle += 0.1;
144
-    _entity->rotate(Vector3D(0.0, 2.0, 2.0));
148
+    for (int i = 0; i < _entities.size(); ++i) {
149
+        _entities[i]->rotate(Vector3D(0.0, 2.0, 2.0));
150
+    }
145
     QTimer::singleShot(20, this, SLOT(animate()));
151
     QTimer::singleShot(20, this, SLOT(animate()));
146
     update();
152
     update();
147
 }
153
 }

+ 1
- 1
TheGame/renderwidget.h View File

48
 
48
 
49
     Vector3D pos;
49
     Vector3D pos;
50
 
50
 
51
-    UGEEntity* _entity;
51
+    QList<UGEEntity*> _entities;
52
 };
52
 };
53
 
53
 
54
 #endif // RENDERWIDGET_H
54
 #endif // RENDERWIDGET_H

Loading…
Cancel
Save