From ef37119f4e94c83a6357ebc0b94a39e4e53b20d7 Mon Sep 17 00:00:00 2001 From: ccolin Date: Sat, 26 Dec 2020 21:46:12 +0100 Subject: add some sunlight --- src/drone_controller.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/drone_controller.cc') diff --git a/src/drone_controller.cc b/src/drone_controller.cc index 2c956dd..c41721e 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -62,11 +62,17 @@ Drone::Drone() { tinyobj::real_t vx = attrib.vertices[3*idx.vertex_index+0]; tinyobj::real_t vy = attrib.vertices[3*idx.vertex_index+1]; tinyobj::real_t vz = attrib.vertices[3*idx.vertex_index+2]; + tinyobj::real_t nx = attrib.normals[3*idx.normal_index+0]; + tinyobj::real_t ny = attrib.normals[3*idx.normal_index+1]; + tinyobj::real_t nz = attrib.normals[3*idx.normal_index+2]; tinyobj::real_t ts = attrib.texcoords[2*idx.texcoord_index+0]; tinyobj::real_t tt = attrib.texcoords[2*idx.texcoord_index+1]; verts.append(vx); verts.append(vy); verts.append(vz); + verts.append(nx); + verts.append(ny); + verts.append(nz); verts.append(ts); verts.append(tt); // qDebug() << "vert" << vx << vy << vz << "tex" << ts << tt; @@ -143,12 +149,12 @@ DroneController::DroneController(const QJsonObject &json) OpenGLWidget::instance->makeCurrent(); QOpenGLTexture *ground_tex = new QOpenGLTexture(QImage(":/mdl/ground.jpg").mirrored()); OpenGLMesh *ground = new OpenGLMesh({ - -100, 0, -100, 0, 0, - 100, 0, -100, 1, 0, - -100, 0, 100, 0, 1, - 100, 0, -100, 1, 0, - -100, 0, 100, 0, 1, - 100, 0, 100, 1, 1, + -100, 0, -100, 0, 1, 0, 0, 0, + 100, 0, -100, 0, 1, 0, 1, 0, + -100, 0, 100, 0, 1, 0, 0, 1, + 100, 0, -100, 0, 1, 0, 1, 0, + -100, 0, 100, 0, 1, 0, 0, 1, + 100, 0, 100, 0, 1, 0, 1, 1, }, ground_tex); OpenGLWidget::instance->meshes.append(*ground); OpenGLWidget::instance->doneCurrent(); -- cgit v1.2.3-70-g09d2