introduction to hierarchical modeling and animation using
TRANSCRIPT
Introduction to Hierarchical Modelingand Animation using Inventor
François Faure
Grenoble Universities, INRIA, CNRS
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
A graphical model
Composed of :geometric shapesdisplacementscolors
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
A sphere
Text file :� �# I nven to r V2.0 a s c i i
Sphere { }� �File format : Inventor V2.0 ascii
One single object with default values
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adding a cylinder
Text file :� �# I nven to r V2.0 a s c i i
Sphere { }Cy l inder { }� �or, equivalently :� �# I nven to r V2.0 a s c i i
Cy l inder { }Sphere { }� �
The cylinder has default values tooThe order does not matter here
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Tuning the parameters
Text file :� �# I nven to r V2.0 a s c i i
Sphere {rad ius 0.1
}Cy l inder {
rad ius 0.05he igh t 1
}� �Objects have attributesPosition and orientation are notshape attributes
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Changing the coordinate system
Text file :� �# I nven to r V2.0 a s c i i
Sphere {rad ius 0.1
}T rans la t i on {
t r a n s l a t i o n 0 0.5 0}Cy l inder {
rad ius 0.05he igh t 1
}� �Objects are drawn in their localcoordinate system
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adding a cone
� �# I nven to r V2.0 a s c i i
Sphere {rad ius 0.1
}T rans la t i on {
t r a n s l a t i o n 0 0.5 0}Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on {
t r a n s l a t i o n 0 0.4 0}Cone {
bottomRadius 0.1he igh t 0.1
}� �Geometric transforms are combinedBasic shapes are centered at the origin of thecurrent coordinate system
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adding the X arrow
� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}
# Rotate then draw the arrow againRotationXYZ { ax is Z angle −1.5708 }
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}� �
Rotate along Z
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adding the X arrow
� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}
# Rotate then draw the arrow againRotationXYZ { ax is Z angle −1.5708 }
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}� �
Rotate along ZTransformations are applied in thecurrent reference frame
Need a translation to start back fromthe origin.
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Better� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}
# back to o r i g i n then draw againT rans la t i on { t r a n s l a t i o n 0 −0.9 0 }RotationXYZ { ax is Z angle −1.5708 }
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}� �François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Groups
� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
DEF arrow Group {T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}}
# back to the o r i g i nT rans la t i on { t r a n s l a t i o n 0 −0.9 0 }
# then r o t a t e and redrawRotationXYZ { ax is Z angle −1.5708 }USE arrow� � Groups define hierarchical
structuresNaming a group allows us to re-useit
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Separators
Separators push/pop statevaluesSeparators leave the stateunchanged� �
# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
DEF arrow Separator {T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}}# a u t o m a t i c a l l y back to prev ious s ta te
# then r o t a t e and redrawRotationXYZ { ax is Z angle −1.5708 }USE arrow� �
Groups “contaminate” the restof the scene and may inducedata dependency� �
# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
DEF arrow Group {T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder {
rad ius 0.05he igh t 0.8
}T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone {
bottomRadius 0.1he igh t 0.1
}}
# back to the o r i g i nT rans la t i on { t r a n s l a t i o n 0 −0.9 0 }
# then r o t a t e and redrawRotationXYZ { ax is Z angle −1.5708 }USE arrow� �
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Colors
� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
Ma te r i a l { d i f f u s e C o l o r 0 1 0 }DEF arrow Separator{
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder { rad ius 0.05
he igh t 0 .8 }T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone { bottomRadius 0.1
he igh t 0.1 }}
RotationXYZ { ax is Z angle −1.5708 }Ma te r i a l { d i f f u s e C o l o r 1 0 0 }
USE arrow� �Separators leave the stateunchanged
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adding the Z axis
� �# I nven to r V2.0 a s c i i
Sphere { rad ius 0.1 }
Ma te r i a l { d i f f u s e C o l o r 0 1 0 }DEF arrow Separator{
T rans la t i on { t r a n s l a t i o n 0 0.5 0 }Cy l inder { rad ius 0.05
he igh t 0 .8 }T rans la t i on { t r a n s l a t i o n 0 0.4 0 }Cone { bottomRadius 0.1
he igh t 0.1 }}
RotationXYZ { ax is Z angle −1.5708 }Ma te r i a l { d i f f u s e C o l o r 1 0 0 }
USE arrow
RotationXYZ { ax is X angle 1.5708 }Ma te r i a l { d i f f u s e C o l o r 0 0 1 }
USE arrow� �François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Scene graph
The scene is modeled as a tree-like structure (DirectedAcyclic Graph)Three families of rendering nodes :
Shape nodes, which represent 3D geometric objectsProperty nodes, which represent appearance and otherqualitative characteristics of the sceneGroup nodes, which are containers that collect nodes intographs
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
The Traversal state
Scene processing is performed by depth-first graphtraversalsThe drawings depend of the traversal state :
Current geometric transformationCurrent material componentsCurrent lighting modelCurrent drawing styleCurrent text fontCurrent coordinatesCurrent normalsCurrent lightsCurrent viewing specification
Separators push/pop the traversal stateSee chapter 3 of The Inventor Mentor
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Actions
Different actions (graph traversals) can be applied to the scenegraph :
Draw, or render, the scene graphCompute a 3D bounding box for objects in the scene graphCompute a cumulative transformation matrix (and itsinverse)Write the scene graph to a fileSearch for nodesAllow objects in the scene graph to handle an eventPick objects in the scene graph along a rayTraverse the scene graph and accumulate traversal state,then perform your own action using callback functionsSee chapter 9 of The Inventor Mentor
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Modeling the Water Molecule in C++
� �/ / Code from ‘ ‘ The Inven to r mentor ’ ’ , Jos ie Wernecke , Addison−Wesley/ / Const ruct a l l pa r t sSoGroup ∗waterMolecule = new SoGroup ; / / water molecule
SoGroup ∗oxygen = new SoGroup ; / / oxygen atomSoMater ia l ∗ r e d P l a s t i c = new SoMater ia l ;SoSphere ∗sphere1 = new SoSphere ;
SoGroup ∗hydrogen1 = new SoGroup ; / / hydrogen atomsSoGroup ∗hydrogen2 = new SoGroup ;SoTransform ∗hydrogenXform1 = new SoTransform ;SoTransform ∗hydrogenXform2 = new SoTransform ;SoMater ia l ∗w h i t e P l a s t i c = new SoMater ia l ;SoSphere ∗sphere2 = new SoSphere ;SoSphere ∗sphere3 = new SoSphere ;
/ / Set a l l f i e l d values f o r the oxygen atomr edP las t i c−>ambientColor . setValue ( 1 . 0 , 0 .0 , 0 .0 ) ;r edP las t i c−>d i f f u s e C o l o r . setValue ( 1 . 0 , 0 .0 , 0 .0 ) ;r edP las t i c−>specu larColor . setValue ( 0 . 5 , 0 .5 , 0 .5 ) ;r edP las t i c−>sh in iness = 0 . 5 ;� �
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Modeling the Water Molecule in C++ (continued)
� �/ / Code from ‘ ‘ The Inven to r mentor ’ ’ , Jos ie Wernecke , Addison−Wesley/ / Set a l l f i e l d values f o r the hydrogen atomshydrogenXform1−>sca leFactor . setValue (0 .75 , 0.75 , 0 .75) ;hydrogenXform1−>t r a n s l a t i o n . setValue ( 0 . 0 , −1.2, 0 .0 ) ;hydrogenXform2−>t r a n s l a t i o n . setValue (1.1852 , 1.3877 , 0 .0 ) ;wh i t eP las t i c−>ambientColor . setValue ( 1 . 0 , 1 .0 , 1 .0 ) ;wh i t eP las t i c−>d i f f u s e C o l o r . setValue ( 1 . 0 , 1 .0 , 1 .0 ) ;wh i t eP las t i c−>specu larColor . setValue ( 0 . 5 , 0 .5 , 0 .5 ) ;wh i t eP las t i c−>sh in iness = 0 . 5 ;
/ / Create a h ie ra rchywaterMolecule−>addChild ( oxygen ) ;waterMolecule−>addChild ( hydrogen1 ) ;waterMolecule−>addChild ( hydrogen2 ) ;
oxygen−>addChild ( r e d P l a s t i c ) ;oxygen−>addChild ( sphere1 ) ;hydrogen1−>addChi ld ( hydrogenXform1 ) ;hydrogen1−>addChi ld ( w h i t e P l a s t i c ) ;hydrogen1−>addChi ld ( sphere2 ) ;hydrogen2−>addChi ld ( hydrogenXform2 ) ;hydrogen2−>addChi ld ( sphere3 ) ;� �
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Scenegraph Built-in Animation Using Engines
Engines :Are part of the scene graph (can be read from file andwritten to file)Have built-in functionsAre evaluated automaticallyHave inputs fields and outputs fields of a fixed typeCan affect only other nodes or engines in a scene graph
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
A Simple Field Connection
A digital clock connected to the global field “realTime”
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Example of Engines
Translation as a function of time
SoElapsedTime engine isconnected to realTime perdefaultSoComposeVec3f has 3scalar inputs and one 3Dvector outputThe model slidescontinuously from left toright
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
SoRotor
An embedded engine animates a rotation.
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference frame
r1(0,0, θ1) : yearly earthrotationt2(x2,0,0) : sun-earthoffsetr3(0,0, θ3) : dayly earthrotationr4(0,0, θ4) : monthly moonrotationt5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference framer1(0,0, θ1) : yearly earthrotation
t2(x2,0,0) : sun-earthoffsetr3(0,0, θ3) : dayly earthrotationr4(0,0, θ4) : monthly moonrotationt5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference framer1(0,0, θ1) : yearly earthrotationt2(x2,0,0) : sun-earthoffset
r3(0,0, θ3) : dayly earthrotationr4(0,0, θ4) : monthly moonrotationt5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference framer1(0,0, θ1) : yearly earthrotationt2(x2,0,0) : sun-earthoffsetr3(0,0, θ3) : dayly earthrotation
r4(0,0, θ4) : monthly moonrotationt5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference framer1(0,0, θ1) : yearly earthrotationt2(x2,0,0) : sun-earthoffsetr3(0,0, θ3) : dayly earthrotationr4(0,0, θ4) : monthly moonrotation
t5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Frame Hierarchies
Example : a simple planetary system
sun at the center of theworld reference framer1(0,0, θ1) : yearly earthrotationt2(x2,0,0) : sun-earthoffsetr3(0,0, θ3) : dayly earthrotationr4(0,0, θ4) : monthly moonrotationt5(x5,0,0) : earth-moonoffset
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
A Frame Hierarchy in Inventor
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Visualizing the local coordinate system
include an external fileits content is drawn in thelocal coordinate systemwe reuse the initialexample
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Changing the point of view
sun fixed, moving earth earth fixed, moving sun
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Adapting a scene graph
Sun fixed, moving earthand moon
Moon fixed, moving sunand earth
François Faure Introduction to Hierarchical Modeling and Animation using Inventor
A graphical model
Resources
Free implementation of OpenInventor : www.coin3d.orgLinux : install packages SoQt-dev, libsimageWindows/Mac : download and compile Coin, SoWin,simage
Additional resources onwww-evasion.imag.fr/Membres/Francois.Faure/enseignement/ressources/openinventor.html
Inventor Mentor : reference bookDeveloper documentation (doxygen-html, also onwww.coin3d.org)Code and project files of the Inventor Mentor examplesInventor Toolmaker : to extend OpenInventor
François Faure Introduction to Hierarchical Modeling and Animation using Inventor