summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2012-10-24 13:29:02 -0700
committerMatt Turner <mattst88@gmail.com>2012-10-24 13:29:02 -0700
commit7ed93eee2116d7d38b1281e339c8d4c183dcb775 (patch)
tree6f2c6d2d88e65b3aceabe572f598cb50bd5a13f0 /src
parenta645d75861bd8db86172007be011df17d2c51fac (diff)
Make cubes stack, rotate, and rotate on hinges
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a9d4c74..7ead051 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -215,9 +215,14 @@ Redisplay(void)
* the world-space origin at a distance of 15 units.
*/
const GLUmat4 vp(projection_matrix * gluTranslate(0.0, 0.0, -15.0));
+ transformations[0] = vp * rotate_y_axis(orbit_angle);
- for (unsigned i = 0; i < ARRAY_SIZE(transformations); i++) {
- transformations[i] = vp;
+ const GLUmat4 translate_up = gluTranslate(0.0f, 2.0f, 0.0f);
+ const GLUmat4 rotate_hinge = gluTranslate(0.0f, -1.0f, 1.0f) * rotate_x_axis(hinge_angle) * gluTranslate(0.0f, 1.0f, -1.0f);
+ const GLUmat4 cube_trans = translate_up * rotate_hinge;
+
+ for (unsigned i = 1; i < ARRAY_SIZE(transformations); i++) {
+ transformations[i] = transformations[i - 1] * cube_trans;
}