modeling objects
play

Modeling Objects A prototype has a default size, position, and - PowerPoint PPT Presentation

Modeling Objects A prototype has a default size, position, and Modeling orientation You need to perform modeling transformations to position it within the scene Hierarchical Transformations myCube() - Create a unit cube with its origin


  1. Modeling Objects � A prototype has a default size, position, and Modeling orientation � You need to perform modeling transformations to position it within the scene Hierarchical Transformations myCube() - Create a unit cube with its origin at (0,0,0) Hierarchical Models Scene Graphs To create a 2 x 0.1 x 2 table top - need to call glScalef(2, 0.1, 2) Instance Transformation Symbol-Instance Table Can store a model � Start with a prototype object (a symbol ) by assigning a � Each appearance of the object in the number to each model is an instance symbol and � Must scale, orient, position storing the parameters for � Defines instance transformation the instance transformation

  2. Structure Through Function Relationships in Car Model Calls � Symbol-instance table does not show car(speed) { relationships between parts of model chassis() � Consider model of car wheel(right_front); � Chassis + 4 identical wheels wheel(left_front); wheel(right_rear); � Two symbols wheel(left_rear); } • Fails to show relationships well � Rate of forward motion determined by • Look at problem using a graph rotational speed of wheels Graphs Tree � Set of nodes and edges (links) � Graph in which each node (except the root) has exactly one parent node � Edge connects a pair of nodes � May have multiple children � Directed or undirected � Leaf or terminal node: no children � Cycle : directed path that is a loop root node loop leaf node

  3. Tree Model of Car DAG Model � If we use the fact that all the wheels are identical, we get a directed acyclic graph � Not much different than dealing with a tree Modeling with Trees Robot Arm � Must decide what information to place in nodes and what to put in edges � Nodes � What to draw � Pointers to children parts in their own � Edges robot arm coordinate systems � May have information on incremental changes to transformation matrices (can also store in nodes)

  4. Articulated Models Relationships in Robot Arm � Base rotates independently � Robot arm is an example of an � Single angle determines position articulated model � Lower arm attached to base � Parts connected at joints � Its position depends on rotation � Can specify state of model by of base giving all joint angles � Must also translate relative to base and rotate about connecting joint Relationships in Robot Arm Required Matrices � Rotation of base: R b � Upper arm attached to lower arm � Apply M = R b to base � Translate lower arm relative to base: T la � Its position depends on both base and lower arm � Rotate lower arm around joint: R la � Must translate relative to � Apply M = R b T la R la to lower arm lower arm and rotate � Translate upper arm relative to upper arm: about joint connecting to T ua lower arm � Rotate upper arm around joint: R ua � Apply M = R b T la R la T ua R ua to upper arm

  5. OpenGL Code for Robot Tree Model of Robot robot_arm() � Note code shows relationships between { parts of model glRotate(theta, 0.0, 1.0, 0.0); � Can change “look” of parts base(); easily without altering glTranslate(0.0, h1, 0.0); relationships glRotate(phi, 0.0, 1.0, 0.0); � Simple example of tree model lower_arm(); glTranslate(0.0, h2, 0.0); � Want a general node structure glRotate(psi, 0.0, 1.0, 0.0); for nodes upper_arm(); } Scene Graphs Hierarchical Modeling � Triangles, parametric curves and � Encoding this information in the code is surfaces are the building blocks not very productive. Want it to be from which more complex real- flexible, data-driven and extensible. world objects are modeled. � Scene-graphs provide this functionality. � Hierarchical modeling creates � OpenInventor (http://www.coin3d.org/) complex real-world objects by � Open Scene Graph ( http://www.openscenegraph.com/) combining simple primitive shapes into more complex � Many others aggregate objects.

  6. Articulated Models Multiple Components � Different Materials Scene Layout – Worlds Hierarchical models

  7. Hierarchical models Hierarchical models Hierarchical models Hierarchical models

  8. Hierarchical Grouping of Simple Example with Groups Objects Group { � Logical organization of scene numObjects 3 Group { fruits numObjects 3 chair Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { table numObjects 2 Group { Box { <BOX PARAMS> } ground Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } } Adding Materials Group { Adding Transformations numObjects 3 Material { <BLUE> } Group { numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { numObjects 2 Material { <BROWN> } Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Material { <GREEN> } Box { <BOX PARAMS> } Material { <RED> } Sphere { <SPHERE PARAMS> } Material { <ORANGE> } Sphere { <SPHERE PARAMS> } } } Material { <BLACK> } Plane { <PLANE PARAMS> } }

  9. Simple Example with Transforms Hierarchical Transformation of Group { numObjects 3 Objects Transform { ZRotate { 45 } Group { � Transforms position numObjects 3 logical groupings of Box { <BOX PARAMS> } Box { <BOX PARAMS> } objects within the Box { <BOX PARAMS> } } } Transform { scene Translate { -2 0 0 } Group { numObjects 2 Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } } Plane { <PLANE PARAMS> } } Separating types of transformation Hierarchical modeling in OpenGL � Note that we have treated translations, � Commands to change current transformation rotations, etc. as separate � glTranslate, glScale, etc. � But they are all represented by 4x4 matrices � Affects the state , i.e. all following commands and there is no technical reason not to will undergo this transformation combine them into the resulting matrix � Utilities to maintain a matrix stack (to revert � It’s just simpler for the human programmer, to previous state) and corresponds to the handle of 3D � Difference between model and view matrix modeling/animation packages

  10. Model vs. Projection matrix Managing the state It is almost the same to rotate the camera or the objects � � To reset everything: Main difference: � glLoadI dentity(); Lighting � This is why OpenGL has two transforms: model and projection � � OpenGL stores a glMatrixMode( GL_MODELVIEW ); stack of matrices Tells openGL that next matrix commands deal with the objects. � � You don’t need to typically used for modeling & animation � remember, OpenGL remembers glMatrixMode(GL_PROJECTION); Tells OpenGL we deal with the camera space ( � glPushMatrix() � typically used to change viewpoint & focal length � � glPopMatrix Scene Graph Managing the state � Convenient Data structure for scene � Push matrix when representation you start rendering � Transformations a group � Materials, color � Pop once you are � Multiple instances done � Basic idea: Hierarchical Tree � Useful for manipulation/animation � Especially for articulated figures � Useful for rendering too � Multi-pass rendering, occlusion culling

  11. Scene Graphs Traversal � Basic idea: Tree � Depth first � Comprised of several node � Top to bottom, left to right types: � Shape: 3D geometric objects � Transform: Affect current transformation � Property: Appearance, texture, etc. � Group: Collection of subgraphs Traversal State Other Scene Nodes � Switch or Selector Nodes � The State is updated during traversal � Level of detail � Transformations, properties � Different rendering styles � Influence of nodes can be complex � Damaged v. undamaged states � E.g. bottom to top � Sequence Nodes � Animated sequence � Objects � Textures � Transformations

  12. Object Following or Tethering Camera Tethering � Can attach an object to the node of � Many times, we want the camera to follow an entity. another object (or group them in a parent node. � Need to get the coordinate frame for the entity. � Provide an offset to have the other � Traverse the scene graph to the entity. object tag along with the object under � Or, need to get the current camera system control. � Attach camera and determine transformations to the root of the scene graph.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend