CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.
-
Upload
lucy-gordon -
Category
Documents
-
view
214 -
download
2
Transcript of CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.
![Page 1: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/1.jpg)
CSC 480 / 580
Computer Graphics
K. Kirby
Scene Graphsand Slerping Quaternions
NKU CSC 480 KIRBY
![Page 2: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/2.jpg)
class Widget{public: void dump() const ; virtual void spin(); virtual void toss() =0 ; void flip() { toss() ; } // ... } ;
Remembering OO
Widget
FastWidgetSlowWidget
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
![Page 3: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/3.jpg)
sphere: GlutSphere
center: TransformNode west: TransformNode east: TransformNode east: TransformNode
redMat: MaterialNodegreenMat: MaterialNode blueMat: MaterialNode
light: LightNodelight2: LightNode
scene: Node
A simple scene graph instance
This is a DAG(directed acyclic graph)
NKU CSC 480 KIRBY
![Page 4: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/4.jpg)
NodeNode
TransformNodeTransformNode EnvironmentNodeEnvironmentNode AppearanceNodeAppearanceNode
LightNodeLightNode MaterialNodeMaterialNode
ArtifactNodeArtifactNode
MeshMesh GlutSphereGlutSphere GlutTeapotGlutTeapot
A Simple Scene Graph Class Hierarchy
NKU CSC 480 KIRBY
![Page 5: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/5.jpg)
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
![Page 6: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/6.jpg)
R(0) R(1)
Frame 442 Frame 482
Frame 462 R(0.5) = 0.5 R(0) + 0.5 R(1) ????
Bad. Why?
Rotation matrices and Tweening
NKU CSC 480 KIRBY
![Page 7: CSC 480 / 580 Computer Graphics K. Kirby Scene Graphs and Slerping Quaternions NKU CSC 480 KIRBY.](https://reader035.fdocuments.in/reader035/viewer/2022072005/56649cdc5503460f949a789b/html5/thumbnails/7.jpg)
Points – as pure quaternionsp = xi + yj + zk
Rotations (u^, ) – as unit quaternionsr = cos ½ + (sin ½) u1i + u2j + u3k
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