CS 455 Lecture 4 – 2-D Transformations
January 31, 2013 by Chris Johnson. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
cs455, lectures, spring 2013.
Before class
Scaling, Translation, and Shear
- Watch http://youtu.be/Vfs7eOjcKuo. (I misspeak at one point: only translation and rotation are rigid-body transforms.)
- Read about transforms for a different graphics API at http://processing.org/learning/transform2d/, stopping before The Transformation Matrix.
Rotation
- Watch http://youtu.be/qKgYarnLT94.
- Another brief perspective: http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm.
- For the inclined, read the sin and cosine summation section of http://oakroadsystems.com/twt/sumdiff.htm.
In class
First, here’s a fix to an annoyance several of you have encountered: you add a shader to src/shaders, you configure, you build, you run. Then you edit the shader but the changes don’t show up. That’s because there’s a line in CMakeLists.txt that copies the shaders directory to your build directory at configure time. Long story short, you have two versions of your shaders lying around, and you are changing the wrong one. I’ve looked for the simplest fix possible, and I think this might be it:
- Delete this line from CMakeLists.txt:
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/shaders DESTINATION ${CMAKE_BINARY_DIR})
- Add the line:
add_definitions(-DSHADERS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/shaders")
- With that change, you will only have one shaders directory, sitting inside your project source. (That also means you can’t just take your builds around and run them anywhere. They depend on your source being there too.) When you load up your shaders, you will need to fix your paths to the GLSL source:
program = td::ShaderProgram::FromFiles(SHADERS_DIR "/vanilla.vert.glsl", SHADERS_DIR "/vanilla.frag.glsl");
Second, make sure you’ve completed the exercises from last time or at least have some geometry set up that you can visualize.
Third, implement the canonical bounce animation. Every frame, move your geometry along some defined velocity vector. If the geometry’s center position moves outside of the [-1, 1] x [-1, 1] window, reflect that velocity vector. (Consider velocity as the slope a line. What’s the slope of a perpendicular line?) Also, add some spin. If your geometry is circular, that spin will be hard to detect. Go into wireframe mode with:
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
Haiku
Ay! Con permiso.
Sorry. I’ll translate for you.
Gracias, senor.