src/gl/partrenderer.cpp

changeset 359
73b6c478378e
parent 338
719b909a7d2b
child 360
41b38b9e05a2
equal deleted inserted replaced
358:ef90ed0a5720 359:73b6c478378e
235 Q_EMIT this->viewMatrixChanged(this->viewMatrix); 235 Q_EMIT this->viewMatrixChanged(this->viewMatrix);
236 } 236 }
237 237
238 void PartRenderer::updateModelMatrix() 238 void PartRenderer::updateModelMatrix()
239 { 239 {
240 this->modelMatrix = glm::mat4_cast(this->modelQuaternion); 240 this->modelMatrix = glm::translate(glm::mat4_cast(this->modelQuaternion), -this->modelViewOrigin);
241 gl::setShaderUniformMatrix(&this->shaders, "modelMatrix", modelMatrix); 241 gl::setShaderUniformMatrix(&this->shaders, "modelMatrix", modelMatrix);
242 Q_EMIT this->modelMatrixChanged(this->modelMatrix); 242 Q_EMIT this->modelMatrixChanged(this->modelMatrix);
243 this->update(); 243 this->update();
244 } 244 }
245 245
418 const glm::vec3 p1 = this->unproject({point.x(), point.y(), 0}); 418 const glm::vec3 p1 = this->unproject({point.x(), point.y(), 0});
419 const glm::vec3 p2 = this->unproject({point.x(), point.y(), 1}); 419 const glm::vec3 p2 = this->unproject({point.x(), point.y(), 1});
420 return lineFromPoints(p1, p2); 420 return lineFromPoints(p1, p2);
421 } 421 }
422 422
423 void PartRenderer::setModelViewOrigin(const glm::vec3& newViewOrigin)
424 {
425 this->modelViewOrigin = newViewOrigin;
426 this->updateModelMatrix();
427 }
428
423 /** 429 /**
424 * @brief Unprojects the specified window coordinates to model coordinates 430 * @brief Unprojects the specified window coordinates to model coordinates
425 * @param win Window coordinates to project. Z-coordinate indicates depth 431 * @param win Window coordinates to project. Z-coordinate indicates depth
426 * @return model coordinates 432 * @return model coordinates
427 */ 433 */

mercurial