Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.

Similar presentations


Presentation on theme: "CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY."— Presentation transcript:

1 CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY

2 class Widget { public: void dump() const ; virtual void spin(); virtual void toss() =0 ; void flip() { toss() ; } //... } ; Remembering OO Widget FastWidget SlowWidget SlowWidget sw ; FastWidget fw ; play( sw ) ; play( fw ) ; void play( Widget* p ) { p->toss() ; //... } void play( Widget* p ) { p->toss() ; //... } class SlowWidget : public Widget { public: void toss() { /*...*/ } ; void spin() { /*...*/ } ; //... } ; class FastWidget : public Widget { public: void toss() { /*...*/ } ; //... } ; NKU CSC 480 KIRBY

3 sphere: GlutSphere center: TransformNodewest: TransformNodeeast: TransformNode redMat: MaterialNodegreenMat: MaterialNodeblueMat: MaterialNode light: LightNodelight2: LightNode scene: Node A simple scene graph instance This is a DAG (directed acyclic graph) NKU CSC 480 KIRBY

4 Node TransformNode EnvironmentNode AppearanceNode LightNode MaterialNode ArtifactNode Mesh GlutSphere GlutTeapot A Simple Scene Graph Class Hierarchy NKU CSC 480 KIRBY

5 Implementation Issues for Discussion How do we implement a DAG ? What does a TransformNode do? How to we handle rendering of sub-scenes? How do clients assemble a scene graph in an OpenGL program? NKU CSC 480 KIRBY See SceneGraph.h, SceneGraph.cpp, DemoSceneGraph.cpp

6 R(0) R(1) Frame 442Frame 482 Frame 462 R(0.5) = 0.5 R(0) + 0.5 R(1) ???? Bad. Why? Rotation matrices and Tweening NKU CSC 480 KIRBY

7 Points – as pure quaternions p = xi + yj + zk Rotations (u^,  ) – as unit quaternions r = cos ½  + (sin ½  ) u 1 i + u 2 j + u 3 k Implementing rotations: p´ = r p r* SLERPing quaternions (“spherical linear interpolation”) r(t) = [ sin(1-t)  r(0) + sin t  r(1) ] / sin  where cos  = r(0) r(1). NKU CSC 480 KIRBY


Download ppt "CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY."

Similar presentations


Ads by Google