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
16 16
17#include "Application.h"17#include "Application.h"
18#include "MetavoxelSystem.h"18#include "MetavoxelSystem.h"
19#include "renderer/Model.h"
20
21REGISTER_META_OBJECT(StaticModelRenderer)
19 22
20ProgramObject MetavoxelSystem::_program;23ProgramObject MetavoxelSystem::_program;
21int MetavoxelSystem::_pointScaleLocation;24int MetavoxelSystem::_pointScaleLocation;
@@ -226,3 +229,47 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) { · 204 unmodified lines
226 }229 }
227 }230 }
228}231}
232
233StaticModelRenderer::StaticModelRenderer() :
234 _model(new Model(this)) {
235}
236
237void 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
252void StaticModelRenderer::simulate(float deltaTime) {
253 _model->simulate(deltaTime);
254}
255
256void StaticModelRenderer::render(float alpha) {
257 _model->render(alpha);
258}
259
260void StaticModelRenderer::applyTranslation(const glm::vec3& translation) {
261 _model->setTranslation(translation);
262}
263
264void StaticModelRenderer::applyRotation(const glm::vec3& rotation) {
265 _model->setRotation(glm::quat(glm::radians(rotation)));
266}
267
268void StaticModelRenderer::applyScale(float scale) {
269 const float SCALE_MULTIPLIER = 0.0006f;
270 _model->setScale(glm::vec3(scale, scale, scale) * SCALE_MULTIPLIER);
271}
272
273void StaticModelRenderer::applyURL(const QUrl& url) {
274 _model->setURL(url);
275}