History

Various bits of work on spanners.

Andrzej Kapolka committed 12 years ago

Commit 49468511 parent 3e4092711 files · +274 −3Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 11 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+47−0
@@ -16,6 +16,9 @@ · 15 unmodified lines
1616
1717 #include "Application.h"
1818 #include "MetavoxelSystem.h"
19+#include "renderer/Model.h"
20+
21+REGISTER_META_OBJECT(StaticModelRenderer)
1922
2023 ProgramObject MetavoxelSystem::_program;
2124 int MetavoxelSystem::_pointScaleLocation;
@@ -226,3 +229,47 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) { · 204 unmodified lines
226229 }
227230 }
228231 }
232+
233+StaticModelRenderer::StaticModelRenderer() :
234+ _model(new Model(this)) {
235+}
236+
237+void StaticModelRenderer::init(Spanner* spanner) {
238+ _model->init();
239+
240+ StaticModel* staticModel = static_cast<StaticModel*>(spanner);
241+ applyTranslation(staticModel->getTranslation());
242+ applyRotation(staticModel->getRotation());
243+ applyScale(staticModel->getScale());
244+ applyURL(staticModel->getURL());
245+
246+ connect(spanner, SIGNAL(translationChanged(const glm::vec3&)), SLOT(applyTranslation(const glm::vec3&)));
247+ connect(spanner, SIGNAL(rotationChanged(const glm::vec3&)), SLOT(applyRotation(const glm::vec3&)));
248+ connect(spanner, SIGNAL(scaleChanged(float)), SLOT(applyScale(float)));
249+ connect(spanner, SIGNAL(urlChanged(const QUrl&)), SLOT(applyURL(const QUrl&)));
250+}
251+
252+void StaticModelRenderer::simulate(float deltaTime) {
253+ _model->simulate(deltaTime);
254+}
255+
256+void StaticModelRenderer::render(float alpha) {
257+ _model->render(alpha);
258+}
259+
260+void StaticModelRenderer::applyTranslation(const glm::vec3& translation) {
261+ _model->setTranslation(translation);
262+}
263+
264+void StaticModelRenderer::applyRotation(const glm::vec3& rotation) {
265+ _model->setRotation(glm::quat(glm::radians(rotation)));
266+}
267+
268+void StaticModelRenderer::applyScale(float scale) {
269+ const float SCALE_MULTIPLIER = 0.0006f;
270+ _model->setScale(glm::vec3(scale, scale, scale) * SCALE_MULTIPLIER);
271+}
272+
273+void StaticModelRenderer::applyURL(const QUrl& url) {
274+ _model->setURL(url);
275+}