Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adapted to Magnum changes.

Most of the changes improve code readability, also using a few older
tricks such as simplified Object::scale() and deg() function for
entering angle in degrees.
  • Loading branch information...
commit e9cb7795a285de34467a6b9dc63b2cad667c5d4b 1 parent 6f93825
Vladimír Vondruš authored
10 src/cubemap/CubeMap.cpp
@@ -40,7 +40,7 @@ CubeMap::CubeMap(Trade::AbstractImporter* importer, const string& prefix, Object
40 40 cube.bindAttribute<Vector4>(buffer, CubeMapShader::Vertex);
41 41 MeshTools::compressIndices(&cube, Buffer::Usage::StaticDraw, *cubeData.indices());
42 42
43   - scale(20.0f, 20.0f, 20.0f);
  43 + scale(20.0f);
44 44
45 45 /* Textures */
46 46 Trade::ImageData2D* image;
@@ -74,12 +74,12 @@ CubeMap::CubeMap(Trade::AbstractImporter* importer, const string& prefix, Object
74 74 texture.generateMipmap();
75 75
76 76 reflector = new Reflector(&texture, scene());
77   - reflector->scale(0.5f, 0.5f, 0.5f);
78   - reflector->translate(-0.5f, 0.0f, 0.0f);
  77 + reflector->scale(0.5f);
  78 + reflector->translate(Vector3::xAxis(-0.5f));
79 79
80 80 reflector = new Reflector(&texture, scene());
81   - reflector->scale(0.3f, 0.3f, 0.3f);
82   - reflector->translate(0.3f, 0.0f, 0.0f);
  81 + reflector->scale(0.3f);
  82 + reflector->translate(Vector3::xAxis(0.3f));
83 83 }
84 84
85 85 void CubeMap::draw(const Matrix4& transformationMatrix, Camera* camera) {
6 src/cubemap/CubeMapExample.cpp
@@ -36,7 +36,7 @@ class CubeMapExample: public AbstractExample {
36 36 /* Every scene needs a camera */
37 37 camera = new Camera(&scene);
38 38 camera->setPerspective(deg(75), 0.001f, 100);
39   - camera->translate(0, 0, 3);
  39 + camera->translate(Vector3::zAxis(3));
40 40
41 41 /* Load TGA importer plugin */
42 42 PluginManager<Trade::AbstractImporter> manager(PLUGIN_IMPORTER_DIR);
@@ -75,12 +75,12 @@ class CubeMapExample: public AbstractExample {
75 75
76 76 if(key == Key::Left || key == Key::Right) {
77 77 GLfloat yTransform = camera->transformation().at(2, 3);
78   - camera->translate(0, -yTransform, 0);
  78 + camera->translate(Vector3::yAxis(-yTransform));
79 79 if(key == Key::Left)
80 80 camera->rotate(deg(10.0f), Vector3::yAxis(), true);
81 81 else
82 82 camera->rotate(deg(-10.0f), Vector3::yAxis(), true);
83   - camera->translate(0, yTransform, 0);
  83 + camera->translate(Vector3::yAxis(yTransform));
84 84 }
85 85
86 86 redraw();
22 src/motionblur/MotionBlurExample.cpp
@@ -34,9 +34,9 @@ class MotionBlurExample: public AbstractExample {
34 34 MotionBlurExample(int& argc, char** argv): AbstractExample(argc, argv, "Motion blur example") {
35 35 scene.setFeature(Scene::DepthTest, true);
36 36 camera = new MotionBlurCamera(&scene);
37   - camera->setClearColor(0.9f, 0.9f, 0.9f, 1.0f);
  37 + camera->setClearColor({0.1f, 0.1f, 0.1f});
38 38 camera->setPerspective(deg(35.0f), 0.001f, 100);
39   - camera->translate(Vector3::zAxis()*3.0f);
  39 + camera->translate(Vector3::zAxis(3.0f));
40 40
41 41 Primitives::Icosphere<3> data;
42 42 MeshTools::compressIndices(&mesh, Buffer::Usage::StaticDraw, *data.indices());
@@ -50,32 +50,32 @@ class MotionBlurExample: public AbstractExample {
50 50
51 51 spheres[0] = new Object(&scene);
52 52 i = new Icosphere(&mesh, &shader, {1.0f, 0.0f, 0.0f}, spheres[0]);
53   - i->translate(Vector3::yAxis()*0.25f);
  53 + i->translate(Vector3::yAxis(0.25f));
54 54 i = new Icosphere(&mesh, &shader, {1.0f, 0.0f, 0.0f}, spheres[0]);
55   - i->translate(Vector3::yAxis()*0.25f);
  55 + i->translate(Vector3::yAxis(0.25f));
56 56 i->rotate(deg(120), Vector3::zAxis());
57 57 i = new Icosphere(&mesh, &shader, {1.0f, 0.0f, 0.0f}, spheres[0]);
58   - i->translate(Vector3::yAxis()*0.25f);
  58 + i->translate(Vector3::yAxis(0.25f));
59 59 i->rotate(deg(240), Vector3::zAxis());
60 60
61 61 spheres[1] = new Object(&scene);
62 62 i = new Icosphere(&mesh, &shader, {0.0f, 1.0f, 0.0f}, spheres[1]);
63   - i->translate(Vector3::yAxis()*0.50f);
  63 + i->translate(Vector3::yAxis(0.50f));
64 64 i = new Icosphere(&mesh, &shader, {0.0f, 1.0f, 0.0f}, spheres[1]);
65   - i->translate(Vector3::yAxis()*0.50f);
  65 + i->translate(Vector3::yAxis(0.50f));
66 66 i->rotate(deg(120), Vector3::zAxis());
67 67 i = new Icosphere(&mesh, &shader, {0.0f, 1.0f, 0.0f}, spheres[1]);
68   - i->translate(Vector3::yAxis()*0.50f);
  68 + i->translate(Vector3::yAxis(0.50f));
69 69 i->rotate(deg(240), Vector3::zAxis());
70 70
71 71 spheres[2] = new Object(&scene);
72 72 i = new Icosphere(&mesh, &shader, {0.0f, 0.0f, 1.0f}, spheres[2]);
73   - i->translate(Vector3::yAxis()*0.75f);
  73 + i->translate(Vector3::yAxis(0.75f));
74 74 i = new Icosphere(&mesh, &shader, {0.0f, 0.0f, 1.0f}, spheres[2]);
75   - i->translate(Vector3::yAxis()*0.75f);
  75 + i->translate(Vector3::yAxis(0.75f));
76 76 i->rotate(deg(120), Vector3::zAxis());
77 77 i = new Icosphere(&mesh, &shader, {0.0f, 0.0f, 1.0f}, spheres[2]);
78   - i->translate(Vector3::yAxis()*0.75f);
  78 + i->translate(Vector3::yAxis(0.75f));
79 79 i->rotate(deg(240), Vector3::zAxis());
80 80 }
81 81
16 src/viewer/ViewerExample.cpp
@@ -69,7 +69,7 @@ class ViewerExample: public AbstractExample {
69 69 /* Every scene needs a camera */
70 70 camera = new Camera(&scene);
71 71 camera->setPerspective(deg(35.0f), 0.001f, 100);
72   - camera->translate(0, 0, 5);
  72 + camera->translate(Vector3::zAxis(5));
73 73
74 74 /* Load file */
75 75 if(!colladaImporter->open(argv[1]))
@@ -132,22 +132,22 @@ class ViewerExample: public AbstractExample {
132 132 void keyEvent(Key key, const Math::Vector2<int>& position) {
133 133 switch(key) {
134 134 case Key::Up:
135   - o->rotate(PI/18, -1, 0, 0);
  135 + o->rotate(deg(10.0f), Vector3::xAxis(-1));
136 136 break;
137 137 case Key::Down:
138   - o->rotate(PI/18, 1, 0, 0);
  138 + o->rotate(deg(10.0f), Vector3::xAxis(1));
139 139 break;
140 140 case Key::Left:
141   - o->rotate(PI/18, 0, -1, 0, false);
  141 + o->rotate(deg(10.0f), Vector3::yAxis(-1), false);
142 142 break;
143 143 case Key::Right:
144   - o->rotate(PI/18, 0, 1, 0, false);
  144 + o->rotate(deg(10.0f), Vector3::yAxis(1), false);
145 145 break;
146 146 case Key::PageUp:
147   - camera->translate(0, 0, -0.5);
  147 + camera->translate(Vector3::zAxis(-0.5));
148 148 break;
149 149 case Key::PageDown:
150   - camera->translate(0, 0, 0.5);
  150 + camera->translate(Vector3::zAxis(0.5));
151 151 break;
152 152 case Key::Home:
153 153 glPolygonMode(GL_FRONT_AND_BACK, wireframe ? GL_FILL : GL_LINE);
@@ -187,7 +187,7 @@ class ViewerExample: public AbstractExample {
187 187 distance *= 1 - 1/0.85f;
188 188 else
189 189 distance *= 1 - 0.85f;
190   - camera->translate(0, 0, distance);
  190 + camera->translate(Vector3::zAxis(distance));
191 191
192 192 redraw();
193 193 break;

0 comments on commit e9cb779

Please sign in to comment.
Something went wrong with that request. Please try again.