|
@@ -25,6 +25,7 @@ RenderWidget::RenderWidget(QWidget *parent) :
|
25
|
25
|
|
26
|
26
|
_engine = new UGameEngine(new OpenGLRenderDevice(this));
|
27
|
27
|
_camera = new FreeFlyCamera(_engine, this);
|
|
28
|
+ _camera->setPosition(Vector3D(0, 1.5, 0));
|
28
|
29
|
|
29
|
30
|
//_engine->addEntity(new UGEEntityAxes(_engine));
|
30
|
31
|
|
|
@@ -40,8 +41,6 @@ RenderWidget::RenderWidget(QWidget *parent) :
|
40
|
41
|
|
41
|
42
|
int xmax = 25;
|
42
|
43
|
int zmax = 25;
|
43
|
|
-// int xmax = 1;
|
44
|
|
-// int zmax = 1;
|
45
|
44
|
for (int x = 0; x < xmax; ++x) {
|
46
|
45
|
for (int z = 0; z < zmax; ++z) {
|
47
|
46
|
UGEEntityCube* cube = new UGEEntityCube(_engine);
|
|
@@ -53,8 +52,25 @@ RenderWidget::RenderWidget(QWidget *parent) :
|
53
|
52
|
WaveFrontObj* wavefrontObj = new WaveFrontObj(this);
|
54
|
53
|
wavefrontObj->openFile(_assetsPath + "objs/enterprise/USSEnterprise.obj");
|
55
|
54
|
UGEEntityWaveFrontObj* obj = new UGEEntityWaveFrontObj(wavefrontObj, _engine);
|
56
|
|
- obj->hide();
|
57
|
|
- _entities.append(obj);
|
|
55
|
+ obj->move(Vector3D(0, 15, 0));
|
|
56
|
+
|
|
57
|
+ UGEEntityCube* cube = new UGEEntityCube(_engine);
|
|
58
|
+ cube->move(Vector3D(5, 17, 5));
|
|
59
|
+ cube->setTextureId("dice");
|
|
60
|
+ _entities.append(cube);
|
|
61
|
+ cube = new UGEEntityCube(_engine);
|
|
62
|
+ cube->move(Vector3D(-5, 17, 5));
|
|
63
|
+ cube->setTextureId("dice");
|
|
64
|
+ _entities.append(cube);
|
|
65
|
+ cube = new UGEEntityCube(_engine);
|
|
66
|
+ cube->move(Vector3D(-5, 17, -5));
|
|
67
|
+ cube->setTextureId("dice");
|
|
68
|
+ _entities.append(cube);
|
|
69
|
+ cube = new UGEEntityCube(_engine);
|
|
70
|
+ cube->move(Vector3D(5, 17, -5));
|
|
71
|
+ cube->setTextureId("dice");
|
|
72
|
+ _entities.append(cube);
|
|
73
|
+
|
58
|
74
|
animate();
|
59
|
75
|
}
|
60
|
76
|
|
|
@@ -97,6 +113,11 @@ void RenderWidget::mousePressEvent(QMouseEvent *event)
|
97
|
113
|
Vector3D bestp;
|
98
|
114
|
UGEEntity* entity = _engine->getVectorNearestIntesection(_camera->getDirection(), _camera->getPosition(), &bestp);
|
99
|
115
|
if (entity) {
|
|
116
|
+ for (int i = 0; i < _entities.size(); ++i) {
|
|
117
|
+ if (_entities[i] == entity) {
|
|
118
|
+ return;
|
|
119
|
+ }
|
|
120
|
+ }
|
100
|
121
|
// UGEEntity* axe = new UGEEntityAxes(_engine);
|
101
|
122
|
// axe->move(bestp);
|
102
|
123
|
if (right) {
|
|
@@ -183,9 +204,9 @@ void RenderWidget::paintEvent(QPaintEvent *event)
|
183
|
204
|
|
184
|
205
|
void RenderWidget::animate()
|
185
|
206
|
{
|
186
|
|
-// for (int i = 0; i < _entities.size(); ++i) {
|
187
|
|
-// _entities[i]->rotate(Vector3D(0.0, 2.0, 2.0));
|
188
|
|
-// }
|
|
207
|
+ for (int i = 0; i < _entities.size(); ++i) {
|
|
208
|
+ _entities[i]->rotate(Vector3D(0.0, 2.0, 2.0));
|
|
209
|
+ }
|
189
|
210
|
QTimer::singleShot(20, this, SLOT(animate()));
|
190
|
211
|
update();
|
191
|
212
|
}
|