Upload
verity-ryan
View
238
Download
0
Tags:
Embed Size (px)
Citation preview
MIT EECS 6.837, Teller and Durand 1
Inventor modeling and Scene Graph
MIT EECS 6.837
Frédo Durand and Seth Teller
MIT EECS 6.837, Teller and Durand 2
Calendar
• Assignment 1: Due Friday 20 at 5pm
• Final projects will be due December 4
• Defense and presentation until December 10
• Dates can vary +/- 2days
MIT EECS 6.837, Teller and Durand 3
Hierarchical models
MIT EECS 6.837, Teller and Durand 4
Hierarchical models
MIT EECS 6.837, Teller and Durand 5
Hierarchical models
MIT EECS 6.837, Teller and Durand 6
Hierarchical models
MIT EECS 6.837, Teller and Durand 7
Hierarchical models
MIT EECS 6.837, Teller and Durand 8
Hierarchical models
MIT EECS 6.837, Teller and Durand 9
Hierarchical models
MIT EECS 6.837, Teller and Durand 10
Overview of Inventor• A suite of tools
– Viewer(s)– Utilities
• An API– C++ set of classes for 3D display and
manipulation
• File format– ASCII or binary– Later became VRML
• Virtual Reality Modeling Language• Internet 3D format
MIT EECS 6.837, Teller and Durand 11
Demo
• View models• Show application developed under
inventor• Look at .iv file
MIT EECS 6.837, Teller and Durand 12
Hierarchical modeling & scene graph• Define relative layout of objects
• Basic idea: Hierarchical Tree
• Useful abstraction
• Useful for manipulation– Especially for articulated figures
• Useful for rendering too
• Heavy use of transformations– World/object space
MIT EECS 6.837, Teller and Durand 13
Questions?
MIT EECS 6.837, Teller and Durand 14
Today: Inventor modeling
• A simple modeling example
• Inventor tools
• Inventor representation
• More complex objects
MIT EECS 6.837, Teller and Durand 15
Object and World Space Modeling• Object space a sort of “workbench"
wherecomponents are assembled, combined
• World space is a “canvas" on/in whichfinished objects are placed
• But: often useful to view both ways• Usually, required transformations,
ordering obvious• Example: Boat, sub, articulated
grasper arm, treasure
MIT EECS 6.837, Teller and Durand 16
Simple modeling
• Model a boat with an articulated grasp arm
MIT EECS 6.837, Teller and Durand 17
Simple bottom-up modeling
• Model a boat with an articulated grasp arm
MIT EECS 6.837, Teller and Durand 18
Modeling the boat# boat, version 1Switch { DEF boat Separator {
Material { diffuseColor 1 0 0 } # RGB (red)Coordinate3 {
point [ 0 0 0, 5 0 0, 7 2 0, 4 2 0,
4 1.5 0, 1.5 1.5 0, 1.5 2 0, 0 2 0]} # Coordinate3IndexedFaceSet {
coordIndex [ 0, 1, 2, 3, 4, 5, 6, 7, -1 ] }
} } # Switch
MIT EECS 6.837, Teller and Durand 19
Modeling the robot arm
# grasperSwitch { DEF grasper Separator {
Material { diffuseColor 0 1 1 }Coordinate3 {
point [ -2 -1 0, -0.5 -1 0, 0.5 -1 0, 2 -1 0, 1.5 3 0, 1 3 0, 1 1 0, 0.5 1 0, -0.5 1 0, -1 1 0, -1 3 0, -1.5 3 0 ]
} # Coordinate3IndexedFaceSet {
coordIndex [ 0, 1, 8, 9, 10, 11, -1, 2, 3, 4, 5, 6, 7, -1 ] }
} } # Switch
MIT EECS 6.837, Teller and Durand 20
Exploit symmetry
# grasper alternativeSwitch { DEF grasper Separator {
Material { diffuseColor 0 1 1 }Coordinate3 {
point [ -2 -1 0, -0.5 -1 0, -0.5 1 0, -1 1 0, -1 3 0, -1.5 3 0 ]
} # Coordinate3FaceSet { numVertices [ 6 ] }Scale { scaleFactor -1 1 1 } # why ?FaceSet { numVertices [ 6 ] }
} } # Switch
MIT EECS 6.837, Teller and Durand 21
Forearm (with use of grasper)
# forearmSwitch { DEF forearm Separator {
Material { diffuseColor 1 0 1 } # magentaCoordinate3 {
point [ 0 -0.5 0, 4 -0.5 0,4 0.5 0, 0 0.5 0 ]
} # Coordinate3IndexedFaceSet { coordIndex [ 0, 1, 2, 3, -1 ] }# instance grasperTranslation { translation 3.5 0 0 }RotationXYZ { axis Z angle -1 }USE grasper
} } # Switch
MIT EECS 6.837, Teller and Durand 22
Arm (uses forearm that uses grasper)
# armSwitch { DEF arm Separator {
Material { diffuseColor 1 0.5 0 }Coordinate3 { point [ 0 -0.5 0, 4 -0.5 0,
4 0.5 0, 0 0.5 0 ]} # Coordinate3IndexedFaceSet { coordIndex [ 0, 1, 2, 3, -1 ] }# instance forearmTranslation { translation 3.5 0 0 }Scale { scaleFactor 0.5 0.5 0 }RotationXYZ { axis Z angle -0.25 } # joint angle wrt. mountUSE forearm
} } # Switch
MIT EECS 6.837, Teller and Durand 23
Robot (uses…)
# robotSwitch { DEF robot Separator {
Material { diffuseColor 0 1 0 }Coordinate3 { point [ 0 0 0, 2 0 0, 3 1 0,
2 2 0, 0 2 0 ]} # Coordinate3IndexedFaceSet { coordIndex [ 0, 1, 2, 3, 4, -1 ] }# instance entire armTranslation { translation 2 1 0 }Scale { scaleFactor 0.5 0.5 0 }RotationXYZ { axis Z angle 0.5 } # joint angle wrt. mountUSE arm
} } # Switch
MIT EECS 6.837, Teller and Durand 24
Placing robot on boat
# boat, version 2Switch { DEF boat Separator {
Material { diffuseColor 1 0 0 }Coordinate3 {point [ 0 0 0, 5 0 0,
7 2 0,4 2 0, 4 1.5 0, 1.5 1.5 0, 1.5 2 0, 0 2 0]
} # Coordinate3IndexedFaceSet { coordIndex [ 0, 1, 2, 3, 4, 5, 6, 7, -1 ] }# instance robot wrt boatTranslation { translation 5 2 0 } # on board (up)Scale { scaleFactor 0.5 0.5 0 }USE robot
} } # Switch
MIT EECS 6.837, Teller and Durand 25
Gold coin# coinSwitch { DEF coin Separator {
Material { diffuseColor 0.8 0.6 0 } # goldCoordinate3 { point [ -1 -2 0, 1 -2 0, 2 -1 0,
2 1 0, 1 2 0, -1 2 0, -2 1 0, -2 -1 0 ]} # Coordinate3FaceSet { numVertices [ 8 ] }
} } # Switch
MIT EECS 6.837, Teller and Durand 26
Placing coin and robot in the ocean# boat, version 3Switch { DEF boat Separator {
...# instance robot sub wrt boatTranslation { translation 1.5 -4 0 } # divingScale { scaleFactor 0.5 0.5 0 }USE robot
} } # Switch# place boat on sea surfaceSeparator { Translation { translation -8 -0.5 0 }
Scale { scaleFactor 2.5 2.5 0 }USE boat }
# place coin on sea bottomSeparator { Translation { translation 3 -10 0 }
Scale { scaleFactor 0.25 0.25 0 }USE coin }
MIT EECS 6.837, Teller and Durand 27
How to grasp the coin?
MIT EECS 6.837, Teller and Durand 28
Questions?
MIT EECS 6.837, Teller and Durand 29
Today: Inventor modeling
• A simple modeling example
• Inventor tools
• Inventor representation
• More complex objects
MIT EECS 6.837, Teller and Durand 30
Inventor tools
• SceneViewer
MIT EECS 6.837, Teller and Durand 31
Interaction
• Interaction Modes & Icons
• Default: 3D Viewer (hand icon)
• Trackball, Walk, Fly, Plane view• Also Select, Help, Home, Set Home,• Center, Set Center, Ortho/Perspective
MIT EECS 6.837, Teller and Durand 32
Selection
MIT EECS 6.837, Teller and Durand 33
Manipulators
• Trackball
• Tab Box
• Jack
MIT EECS 6.837, Teller and Durand 34
Light Creation/Editing
• Point, Directional, Spot
MIT EECS 6.837, Teller and Durand 35
Material / Color Editing
• Editors – Material, Color
• Enabled only when some entity is selected
MIT EECS 6.837, Teller and Durand 36
Questions?
MIT EECS 6.837, Teller and Durand 37
Today: Inventor modeling
• A simple modeling example
• Inventor tools
• Inventor representation
• More complex objects
MIT EECS 6.837, Teller and Durand 38
Inventor Representations
• Basic idea: Tree• Comprised of several node types:
– Shape: 3D geometric objects– Transform:
Affect current transformation– Property: Appearance, texture, etc.– Group: Collection of subgraphs
MIT EECS 6.837, Teller and Durand 39
Inventor Representations
• In fact, Scene graph• Directed Acyclic Graph (DAG)• Allows multiple instantiations• Cycle forbidden
– because infinite recursions
MIT EECS 6.837, Teller and Durand 40
Traversal
• Breadth first– Top to bottom, left to right
MIT EECS 6.837, Teller and Durand 41
Traversal State
• The State is updated during traversal– Transformations, properties– Influence of nodes can be complex – E.g. bottom to top
MIT EECS 6.837, Teller and Durand 42
Built-In Geometric Primitives• Trivial example:#Inventor V2.1 asciiCube {}
Primitive attributes:Default W,H,D (for cubes, spheres, cones,
etc.);Default Color; Material; etcTraversal state (all defaulted for now):Transform; Lights; Material; etc.
MIT EECS 6.837, Teller and Durand 43
Definition & InstantiationSwitch { DEF unitcube Cube {}} # Switch
Separator {Scale { scaleFactor 1 1 2 }USE unitcube
} # Separator
MIT EECS 6.837, Teller and Durand 44
Useful scene graph: AxesSeparator {
Translation { translation 2 0 0 }Scale { scaleFactor 4.0 0.25 0.25 }Material { diffuseColor 1 0 0 }Cube {}
} # SeparatorSeparator {...Material { diffuseColor 0 1 0 }Cube {}} # Separator...Separator {... Sphere {}} # Separator
MIT EECS 6.837, Teller and Durand 45
Persistence of Traversal State
# place two boats on surface (surprising result ?)Separator {
Translation { translation -8 3 0 }USE boatTranslation { translation 2 3 0 }USE boat
}
MIT EECS 6.837, Teller and Durand 46
Separator Nodes
# place two boats on surface (expected result)Separator {
Translation { translation -8 3 0 }USE boat
}Separator {
Translation { translation 2 3 0 }USE boat
}
Pushes (saves) state when encountered
Pops (restores) state when encountered
MIT EECS 6.837, Teller and Durand 47
Composing Transformations...
Separator {Rotation { rotation 0 0 1 0.5 }
# axis, angleTranslation { translation 3 0 0 }USE boat
} # Separator
...Separator {
Translation{ translation 3 0 0 }Rotation { rotation 0 0 1 0.5 }
# axis, angleUSE boat
} # Separator
MIT EECS 6.837, Teller and Durand 48
Material Properties
To color with “intrinsic material“(constant color):...LightModel { model BASE_COLOR }File { name "coordaxes.iv" }Separator {
Material { diffuseColor 0.8 0.0 0.0 }Sphere {}
} # Separator
MIT EECS 6.837, Teller and Durand 49
Using a Lighting ModelTo shade with “lighting model":
...LightModel { model PHONG }DirectionalLight {
intensity 1color 1 1 1direction -1 -1 -1 # "shining" this dir
}Separator {
Material {diffuseColor 0.25 0.25 0.25specularColor 0.8 0.8 0.8shininess 0.9
} # MaterialSphere {}
} # Separator
MIT EECS 6.837, Teller and Durand 50
Polyhedral ObjectsSeparator {
Coordinate3 {point [ -1 1 1, -1 -1 1, 1 -1 1, 1 1 1,
-1 1 -1, -1 -1 -1, 1 -1 -1, 1 1 -1 ]} # Coordinate3
IndexedFaceSet { # multiple facescoordIndex [ 0, 1, 2, 3, -1, # vertex ids, -1
ends face3, 2, 6, 7, -1,7, 6, 5, 4, -1,4, 5, 1, 0, -1,0, 3, 7, 4, -1,1, 5, 6, 2, -1 ]
} # IndexedFaceSet} # Separator
MIT EECS 6.837, Teller and Durand 51
Specifying Face Normals, Colors# primarycube.iv
Separator {# cube verticesCoordinate3 {
point [….. ] } #coordinate3 # face normals, per-faceNormal {
vector [-1 0 0, 1 0 0, 0 -1 0,0 1 0, 0 0 -1, 0 0 1, ]
} # Normal# assign normals per faceNormalBinding { value PER_PART }# face colors, per-faceBaseColor { # set diffuse colors
rgb [ 1 0 0, # 0, red0 1 0, # 1, green0 0 1, # 2, blue0 1 1, # 3, ~red1 0 1, # 4, ~green1 1 0, ]# 5, ~blue
} # BaseColor# assign color ids per face
MaterialBinding { value PER_FACE_INDEXED }IndexedFaceSet {
coordIndex [ # define faces with vertex ids4, 5, 1, 0, -1, 3, 2, 6, 7, -1, # -x, +x1, 5, 6, 2, -1, 0, 3, 7, 4, -1, # -y +y7, 6, 5, 4, -1, 0, 1, 2, 3, -1,]# -z +z
materialIndex [ # material ids per face3, 0, 4, 1, 5, 2, -1 ]
} # IndexedFaceSet
} # Separator
MIT EECS 6.837, Teller and Durand 52
Normals, Colors Per Vertex
...MaterialBinding { value PER_VERTEX_INDEXED }...materialIndex [ # color ids; per face, then per
vertex0, 1, 2, 3, -1, # -x0, 1, 2, 3, -1, # +x0, 1, 2, 3, -1, # -y0, 1, 2, 3, -1, # +y0, 1, 2, 3, -1, # -z0, 1, 2, 3, -1 # +z]
MIT EECS 6.837, Teller and Durand 53
Questions?
MIT EECS 6.837, Teller and Durand 54
Today: Inventor modeling
• A simple modeling example
• Inventor tools
• Inventor representation
• More complex objects
MIT EECS 6.837, Teller and Durand 55
File Inclusion
#Inventor V2.1 ascii# file cubesphere.iv, a cube and sphere.Switch {
DEF mycube Separator { Cube { height 4 } }
DEF mysphere Separator { Sphere { radius 2. } }}# top-level Separator is optionalUSE mycubeUSE mysphere# end of cubesphere.iv
MIT EECS 6.837, Teller and Durand 56
File Inclusion & Instancing#Inventor V2.1 ascii
# instance 2 cubespheres.Switch {
DEF cubesphere # call it what you wishFile { name "cubesphere.iv" }
}Separator {
Translation { translation 2 0 0 }Scale { scaleFactor 2 2 1 }USE cubesphere
}Separator {
Translation { translation -2 0 0 }Scale { scaleFactor 1 1 2 }USE cubesphere
}
MIT EECS 6.837, Teller and Durand 57
Hierarchical Instancing#Inventor V2.1 ascii
File { name "coordaxes.iv" }Switch { DEF fourcubes Separator {
Separator {Translation { translation -1 -1 -1 }Scale { scaleFactor 0.5 0.5 0.5 }Cube {}
} # Separator...Separator {
Translation { translation 1 -1 -1 }Scale { scaleFactor 0.5 0.5 0.5 }Cube {}
} # Separator} }USE fourcubesTranslation { translation 0 0 2 }USE fourcubes
MIT EECS 6.837, Teller and Durand 58
Hierarchical Instancing
#Inventor V2.1 asciiSwitch {DEF eightcubes
File { name "eightcubes.iv" }}Switch { DEF fourgroups Separator {
Separator {Translation { translation -1 -1 -1 }Scale { scaleFactor 0.5 0.5 0.5 }USE eightcubes
} # Separator...Separator {
Translation { translation 1 -1 -1 }Scale { scaleFactor 0.5 0.5 0.5 }USE eightcubes } # Separator
} }USE fourgroupsTranslation { translation 0 0 2 }USE fourgroups
MIT EECS 6.837, Teller and Durand 59
Modeling Complex Structures
• Use simple hierarchy when:– natural “ownership" relation exists– repetitive structure occurs– simple shapes reoccur
• Some entities require generalized hierarchy– graphs, networks, etc.
• Some entities have no hierarchical structure– induce one with spatial data structures
MIT EECS 6.837, Teller and Durand 60
Smooth Surfaces with Polygons• Example: Sphere, using Spherical
Coordinates
MIT EECS 6.837, Teller and Durand 61
Example: Faceted Sphere• Method 1: Explicit Parametrization
• What range should , take for sphere?– Advantages? Disadvantages?
MIT EECS 6.837, Teller and Durand 62
Projective Methods
• Start with a regular polyhedron, with cospherical vertices (by definition)
• Subdivide each (planar) face• Project new vertices onto sphere• Recurse
MIT EECS 6.837, Teller and Durand 63
Subdivision
• Center-based, edge-based
MIT EECS 6.837, Teller and Durand 64
Projection• Sphere equation (implicit):
x2 + y2 + z2 = r2
• Ray from origin to vertex vx; vy; vz (explicit):
– (0; 0; 0) + t(vx; vy; vz)
• Plug in: t2 (vx
2 + vy2 + vz
2) = r2
• Solve for t, plug in to explicit expression
MIT EECS 6.837, Teller and Durand 65
Recursion
• How many triangles after n recursion steps?(consider initial tetrahedron as n = 1)
• Does this scheme exhibit any degeneracies?
• What is surface normal at projected vertex (vx; vy; vz)
MIT EECS 6.837, Teller and Durand 66
Regular polyhedra
• Tetrahedron• Cube • Octahedron • Dodecahedron • Icosahedron • Models courtesy of
– The Encyclopedia of Polyhedra By George W. Hart
– http://www.georgehart.com/virtual-polyhedra/vp.html
MIT EECS 6.837, Teller and Durand 67
Quadrics• Implicit surfaces of form
• Or, can be expressed asAx2 + 2Bxy + 2Cxz + 2Dx + Ey2
+2Fyz + 2Gy + Hz2 + 2Iz + J = 0• Quadrica Page
– http://www3.kawase-h.ed.jp/Teachers/~Takahashi/Quadrica.html
• http://amath.colorado.edu/appm/staff/fast/java/qg.html
1
)1(z
y
x
PONM
LKJI
HGFE
DCBA
zyx
MIT EECS 6.837, Teller and Durand 68
Parametrizing Complex Objects
• Example: Torus ???
MIT EECS 6.837, Teller and Durand 69
Free-Form Surfaces: Bézier PatchesSeparator {
Coordinate3 {point [ -1.5 -1.5 0, -0.5 -1.5 0, ...
0.5 1.5 0, 0.5 1.5 0, ]} # Coordinate3IndexedNurbsSurface {
numUControlPoints 4numVControlPoints 4uKnotVector [ 0, 0, 0, 0, 1, 1, 1, 1 ]vKnotVector [ 0, 0, 0, 0, 1, 1, 1, 1 ]coordIndex [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15 ]} # IndexedNurbsSurface
}
MIT EECS 6.837, Teller and Durand 70
Fractals: Self-similar objects
• Recursive construction rules yield regular fractals– von Koch snowflake
– Sub-objects need not be connected:
– Three-D construction rules abound:
MIT EECS 6.837, Teller and Durand 71
Fractal Objects
• Sierpinski's gadget (area, volume in limit?)
• (Credit: Unreal image, rendered on Amiga)
• Other versions possible
MIT EECS 6.837, Teller and Durand 72
Terrain: irregular fractal generation• Usually height fields, i.e., z = f(x; y)
• Displacements can be random– Subdivision and displacement
• Can also use randomness for (e.g.)– geometric perturbations– parameter settings– material properties
MIT EECS 6.837, Teller and Durand 73
Assignment 1 Object Modeling• At least four “things going on" today:
– Defining a single object in Inventor (.iv files)– Viewing such objects with Inventor viewing tools– Inventor's internal representation for SceneGraphs– Writing a C program to output one such le
• Parametrize the program to output one object for each conguration of command-line parameters
• Only the first and last are part of Assignment 1 !• We provide the “template" program uid_object.c
– generalized command-line handling– valid Inventor le (by default)– embedded informational comments
• NOT graded on artistic talent
MIT EECS 6.837, Teller and Durand 74
Parametric Modeling• You should support at least four parameter
types:– Existence - a binary attribute– Continuous - some arbitrary-valued attribute– Discrete - some integer-valued attribute– Material - a modifier for the surface properties
• Extensions:– Animation (Rotor, Shuttle, Engines, etc.)– Constraint: object must render at 5 Hz on a PC
(can use ivview -q to optimize)
MIT EECS 6.837, Teller and Durand 75
Next Time
• Rendering Pipeline