Presentation is loading. Please wait.

Presentation is loading. Please wait.

Seminar 1 Scene graph & Hierarchical animation EDA221 Introduction to Computer Graphics Carl Johan Gribel, PhD student

Similar presentations


Presentation on theme: "Seminar 1 Scene graph & Hierarchical animation EDA221 Introduction to Computer Graphics Carl Johan Gribel, PhD student"— Presentation transcript:

1 Seminar 1 Scene graph & Hierarchical animation EDA221 Introduction to Computer Graphics Carl Johan Gribel, PhD student (cjgribel@cs.lth.se)

2 Today Hierarchical animation – T*R*S More on Visual Studio/RenderChimp – Debugging – Atom program Assignment 1 – Solar system

3 Hierarchical transform torso lower arm upper arm torso lower arm upper arm lower_arm->rotateZ(0, 0, PI/6);upper_arm->rotateZ(0, 0, PI/6);

4 Compound transform Transformations stored in each node: translation (3d-vector) rotation (3x3-matrix) scaling (3d-vector) Applied in T*R*S order What if further transformations are needed? E.g.: Rotation around arbitrary point p requires a T(p)*R*T(-p) sequence; not achievable by T*R*S only Solution:an extra node, containing another set of transformations

5 Compound transform: Spin vs orbit world earth sun rotate translate earth pivot rotate earth translate world sun earth spinearth orbit extra node

6 Decouple spin from orbit world earth pivot sun earth translate rotate earth pivot earth translate world sun rotate sun spin coupled with earth’s orbitsun spin decoupled from earth’s orbit (somewhat more correct astrophysically)

7 Compound transform: camera world camera camera pivot camera world rotate translate rotate translate ”FP-style””Pivot-style”

8 Visual Studio Debugging breakpoints DataTips printf precompiler

9 Breakpoints Toggle breakpoint on current line with F9 Pauses execution: enters break mode Right-click on the breakpoint symbol to add conditions, hit-counters, filters...

10 DataTips Available during break mode Display / edit variables by hovering them: Can even expand hierarchically into class members, pointer-targets etc Right-click and select ”Watch” to pin variable to a Watch-window

11 printf The brute force way: print whatever you need to monitor to the standard output (console window) printf(”I want to monitor this value: %f\n”, var); Can format the output Can monitor output continuously as the program executes Messy code

12 Precompiler Dictates what (not) to compile #define DEBUG_MODE. #if defined DEBUG_MODE // will be compiled only if DEBUG_MODE is defined #endif

13 Enable debugging To debug, select the ”OpenGL 2.0, Debug” configuration Build + Run (F5)

14 RenderChimp: SceneGraph class All creation and deletion of Nodes and Resources must go through the SceneGraph class new and delete are not permitted for any RenderChimp objects Light *light = SceneGraph::createLight(“MyLight”); SceneGraph::deleteNode(light); Light *light = new Light(“MyLight”); delete light; Yep! Nope!

15 RenderChimp: Atom program my_scenegraph.cpp #include "RenderChimp.h” // <-- declare global variables, scene graph nodes... void RCInit() { // <-- initialize variables, nodes...(called ONCE) } int RCUpdate() { // <-- apply transformations... (called EVERY FRAME) } void RCDestroy() { // <-- release allocated memory (called as program exits) }

16 RenderChimp: Animation Apply animation transformations in the update-routine float earth_spin = 0.6f;// earth spin (rad/s) int RCUpdate() { earth->rotateY( earth_spin * Platform::getFrameTimeStep() ).. } length of a frame (s)

17 Interaction ”WASD” forward/left/down/right (in camera space) Mouse: Pivot camera left button: absolute angle right button: relative angle

18 Assignment 1 Model the solar system! Sun, planets, moons, comets...spaceships? It’s up to you. Resources included in RenderChimp are at your disposal Models, textures, shaders Code for how to add shaders is included (more in assignment 3-4) See assignment description for details

19 Assignment 1 Hint Add planetary rings like this VertexArray *ring_va = createCircleRing(...); Geometry *ring = SceneGraph::createGeometry(“rings”, ring_va); You’ll need #include ”ParametricShapes.h” in the top of your cpp-file

20 Textures http://planetpixelemporium.com/planets.html

21 End


Download ppt "Seminar 1 Scene graph & Hierarchical animation EDA221 Introduction to Computer Graphics Carl Johan Gribel, PhD student"

Similar presentations


Ads by Google