1 / 71

Chapter 4 – Object Manipulation in VRML

Chapter 4 – Object Manipulation in VRML. Understanding Coordinate System. VRML defines the unit of measure of the world coordinate system to be metres All other coordinate systems are built from transformations based from the world coordinate system

gage-pierce
Télécharger la présentation

Chapter 4 – Object Manipulation in VRML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 – Object Manipulation in VRML

  2. Understanding Coordinate System • VRML defines the unit of measure of the world coordinate system to be metres • All other coordinate systems are built from transformations based from the world coordinate system • The VRML convention that one unit equals one meter • In VRML, we can create any number of coordinate systems

  3. Understanding Coordinate System • Each new coordinate system is positioned or translated relative to the origin of another coordinate system • When a new coordinate system is relative to another, we say that the new coordinate system is a child coordinate system that is nested within the within the parent coordinate system • The entire family tree of coordinate systems including any shape we build within those coordinate system is called the scene graph

  4. Understanding Coordinate System • Try to visualize the coordinate system as indicated in the diagram below

  5. Understanding Coordinate System • The ability to create coordinate systems is a very powerful feature of VRML • Consider the steps in placing the lamp on the table while the table is inside a room • We need to perform the following steps: • Create a lamp, building each of its components relative to a lamp coordinate system • Create a table, building each of its components relative to a table coordinate system

  6. Understanding Coordinate System • Place the lamp on the table by positioning the lamp coordinate system relative to the table coordinate system • Now the lamp coordinate system is a child of the table coordinate system • Create a room, building each of its components relative to a room coordinate system • Place the table (and its lamp) by positioning the table coordinate system relative to the room coordinate system

  7. Translating and Grouping Coordinate Systems • We need to use a Transform node to create a new coordinate system and specify the position or translation relative to a parent coordinate system • The Transform node is similar to the Group node in that it contains a list of child nodes • These child nodes could be Shape node, Group node or Transform nodes • All of the child nodes are built at the origin within the Transform node’s coordinate system

  8. Translating and Grouping Coordinate Systems • All of the child nodes are built at the origin within the Transform node’s coordinate system • If the position of that node changes, all its child nodes will change accordingly with the changed coordinate system • Like Shape and Group nodes, the Transform node may be the child of a parent Group or Transform node

  9. Translating and Grouping Coordinate Systems • The coordinate system of the parent node is the parent coordinate system of the Transform node coordinate system • If the root node is a Transform node, then the parent coordinate system is the world coordinate system of the VRML file

  10. The Transform Node • The Transform node creates a new coordinate system relative to its parent node coordinate system Transform { children [ ] # exposedField MFNode translation 0.0 0.0 0.0 # exposedField SFVec3f rotation 0.0 0.0 1.0 0.0 # exposedField SFRotation scale 1.0 1.0 1.0 # exposedField SFVec3f scaleOrientation 0.0 0.0 1.0 0.0 # exposedField SFRotation bboxCenter 0.0 0.0 0.0 # field SFVec3f bboxSize -1.0 -1.0 -1.0 # field SFVec3f center 0.0 0.0 0.0 # exposedField SFVec3f addChildren # eventIn MFNode removeChildren # eventOut MFNode }

  11. The Transform Node • The value of the children exposed field specifies a list of child nodes to be included in the group • Typical values in the children are the Shape nodes, Group nodes and Transform nodes • The value of the translation exposed field specify the distances in X, Y, Z directions • The value of the translation exposed field can be changed by routing an event to the exposed field’s implied set_translation eventIn. • When the event is received, the translation field is set and the new translation is sent using the exposed field’s implied translation_changed eventOut.

  12. Translating 2.0 units along x-axis and building Cylinder #VRML V2.0 utf8 Transform { translation 2.0 0.0 0.0 children [ Shape { appearance Appearance { material Material { } } geometry Cylinder { } } ] }

  13. Translating -2.0 units along x-axis and building Cylinder #VRML V2.0 utf8 Transform { translation -2.0 0.0 0.0 children [ Shape { appearance Appearance { material Material { } } geometry Cylinder { } } ] }

  14. Translating 2.0 units along y-axis and building Cylinder #VRML V2.0 utf8 Transform { translation 0.0 2.0 0.0 children [ Shape { appearance Appearance { material Material { } } geometry Cylinder { } } ] }

  15. Translating 2.0 units along z-axis and building Cylinder #VRML V2.0 utf8 Transform { translation 0.0 0.0 2.0 children [ Shape { appearance Appearance { material Material { } } geometry Cylinder { } } ] }

  16. Translating along x-, y-, z-axis and building Cylinder #VRML V2.0 utf8 Transform { translation 2.0 1.0 -2.0 children [ Shape { appearance Appearance { material Material { } } geometry Cylinder { } } ] }

  17. Building Shapes in Multiple Coordinate Systems #VRML V2.0 utf8 Group { children [ # Draw the hut walls Shape { appearance DEF White Appearance { material Material { } } geometry Cylinder { height 2.0 radius 2.0 } },

  18. Building Shapes in Multiple Coordinate Systems # Draw the hut roof Transform { translation 0.0 2.0 0.0 children [ Shape { appearance USE White geometry Cone { height 2.0 bottomRadius 2.5 } } ] } ] }

  19. Constructing Multiple Coordinate Systems #VRML V2.0 utf8 Group { children [ # Ground Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 25.0 0.1 25.0 } },

  20. Constructing Multiple Coordinate Systems # Left Column Transform { translation -2.0 3.0 0.0 children Shape { appearance USE White geometry Cylinder { radius 0.3 height 6.0 } } },

  21. Constructing Multiple Coordinate Systems # Right Column Transform { translation 2.0 3.0 0.0 children Shape { appearance USE White geometry Cylinder { radius 0.3 height 6.0 } } },

  22. Constructing Multiple Coordinate Systems # Archway span Transform { translation 0.0 6.05 0.0 children Shape { appearance USE White geometry Box { size 4.6 0.4 0.6 } } } ] }

  23. Nesting Coordinate Systems #VRML V2.0 utf8 Group { children [ # Ground Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 25.0 0.1 25.0 } },

  24. Nesting Coordinate Systems # First archway # Left Column DEF LeftColumn Transform { translation -2.0 3.0 0.0 children DEF Column Shape { appearance USE White geometry Cylinder { radius 0.3 height 6.0 } } },

  25. Nesting Coordinate Systems # Right Column DEF RightColumn Transform { translation 2.0 3.0 0.0 children USE Column }, # Archway span DEF ArchwaySpan Transform { translation 0.0 6.05 0.0 children Shape { appearance USE White geometry Box { size 4.6 0.4 0.6 } } },

  26. Nesting Coordinate Systems # Second archway Transform { translation 0.0 0.0 -2.0 children [ USE LeftColumn, USE RightColumn, USE ArchwaySpan ] } ] }

  27. Rotating Shapes • In order to make the object more realistic, we must also control the orientation or rotation using the rotation field of the Transform node • A rotation axis is an imaginary line about which a coordinate system in rotated • A rotation axis can point to any direction in space • In order to specify a direction for a rotation axis, one could imagine drawing a line between two coordinates in space

  28. Rotating Shapes • Usually, one coordinate corresponds to the origin. Therefore in specifying a rotation axis, (0, 1.0, 0) and (0, 2.0, 0) are all equivalent as they all point upwards • In addition to specifying a rotation axis, we must also indicate how much we want the new coordinate system to rotate about that axis and this value is measured in radian • By default, the centre of rotation is the origin of that coordinate system

  29. Rotating Shapes • Using the Transform node, we could specify the 3D coordinates for rotation centre within a new coordinate system Transform { children [ ] # exposedField MFNode translation 0.0 0.0 0.0 # exposedField SFVec3f rotation 0.0 0.0 1.0 0.0 # exposedField SFRotation scale 1.0 1.0 1.0 # exposedField SFVec3f scaleOrientation 0.0 0.0 1.0 0.0 # exposedField SFRotation bboxCenter 0.0 0.0 0.0 # field SFVec3f bboxSize -1.0 -1.0 -1.0 # field SFVec3f center 0.0 0.0 0.0 # exposedField SFVec3f addChildren # eventIn MFNode removeChildren # eventOut MFNode }

  30. Rotating Shapes • The values of the rotation exposed field specify a rotation axis about which the new coordinate system and a rotation angle, measured in radian • The rotation exposed field value can be changed by routing an event to the exposed field’s implied set_rotation eventIn. • When the event is received, the rotation field is set and the new rotation is sent using the exposed field’s implied rotation_changed eventOut

  31. Rotating in Different Direction #VRML V2.0 utf8 Transform { rotation 1.0 0.0 0.0 0.785 children [ Shape { appearance Appearance { material Material { } } geometry Box { } } ] }

  32. Rotating in Different Direction #VRML V2.0 utf8 Transform { rotation 1.0 0.0 0.0 - 0.785 children [ Shape { appearance Appearance { material Material { } } geometry Box { } } ] }

  33. Rotating in Different Direction #VRML V2.0 utf8 Transform { rotation 0.0 1.0 0.0 0.785 children [ Shape { appearance Appearance { material Material { } } geometry Box { } } ] }

  34. Rotating in Different Direction #VRML V2.0 utf8 Transform { rotation 0.0 0.0 1.0 -0.785 children [ Shape { appearance Appearance { material Material { } } geometry Box { } } ] }

  35. Constructing Multiple Rotated Coordinate Systems #VRML V2.0 utf8 Group { children [ # Arm 1 DEF Arm1 Shape { appearance Appearance { material Material { } } geometry Cylinder { height 1.0 radius 0.1 } },

  36. Constructing Multiple Rotated Coordinate Systems # Arm 2 Transform { rotation 1.0 0.0 0.0 1.047 children USE Arm1 }, # Arm 3 Transform { rotation 1.0 0.0 0.0 2.094 children USE Arm1 } ] }

  37. Nesting Rotated Coordinate Systems #VRML V2.0 utf8 Group { children [ # Arm 1 DEF Arm1 Shape { appearance Appearance { material Material { } } geometry Cylinder { height 1.0 radius 0.1 } },

  38. Nesting Rotated Coordinate Systems # Arm 2 DEF Arm2 Transform { rotation 1.0 0.0 0.0 1.047 children USE Arm1 }, # Arm 3 DEF Arm3 Transform { rotation 1.0 0.0 0.0 2.094 children USE Arm1 },

  39. Nesting Rotated Coordinate Systems # Arms 4 and 5 Transform { rotation 0.0 1.0 0.0 1.785 children [ USE Arm2, USE Arm3 ] } ] }

  40. Translating and Rotating Coordinate Systems #VRML V2.0 utf8 Group { children [ # Ground Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 25.0 0.1 25.0 } },

  41. Translating and Rotating Coordinate Systems # First archway # Left Column DEF LeftColumn Transform { translation -2.0 3.0 0.0 children DEF Column Shape { appearance USE White geometry Cylinder { radius 0.3 height 6.0 } } },

  42. Translating and Rotating Coordinate Systems # Right Column DEF RightColumn Transform { translation 2.0 3.0 0.0 children USE Column }, # Archway span DEF ArchwaySpan Transform { translation 0.0 6.05 0.0 children Shape { appearance USE White geometry Box{ size 4.6 0.4 0.6 } } },

  43. Translating and Rotating Coordinate Systems # Left Roof DEF LeftRoof Transform { translation -1.15 7.12 0.0 rotation 0.0 0.0 1.0 0.524 children DEF Roof Shape { appearance USE White geometry Box { size 2.86 0.4 0.6 } } },

  44. Translating and Rotating Coordinate Systems # Right Roof DEF LeftRoof Transform { translation 1.15 7.12 0.0 rotation 0.0 0.0 1.0 -0.524 children USE Roof } ] }

  45. Rotating about a Center Point #VRML V2.0 utf8 Group{ children [ # Lamp base Shape { appearance DEF White Appearance { material Material { } } geometry Cylinder { radius 0.1 height 0.01 } },

  46. Rotating about a Center Point # Base joint Transform { translation 0.0 0.15 0.0 rotation 1.0 0.0 0.0 -0.7 center 0.0 -0.15 0.0 children [ # Lower arm Shape { appearance USE White geometry Cylinder { radius 0.01 height 0.3 } } ] } ] }

  47. Scaling Shapes • VRML also enables us to scale a coordinate system, increasing or decreasing the size relative to a parent coordinate system • Shapes created within the scaled coordinate system are built at the new scale of the coordinate system • By scaling coordinate systems, we can enlarge or shrink shapes or groups of shapes • A scale factor is used in scaling and this scale factor is a multiplication factor. • If the value of this scale factor is 0.5, then the original object will shrink in size by half

  48. Scaling Shapes • The Transform node’s scale field uses three scale factors, one along the x-axis, one along the y-axis and one along the z-axis • By default, the centre of scaling is the original of that coordinate system • Now we could make use of the combination of translation, rotation and scaling within the same Transform node to achieve the effect that we want • The value of the scale exposed field specify the scale factors in the X, Y and Z directions for the new coordinate system

  49. Scaling Shapes • All the scale factors have to be a positive value • Values between 0.0 and 1.0 would imply reduction and values above 1.0 would imply expansion • The value of the scaleOrientation field specify a rotation axis and angle which to rotate the new coordinate system prior to scaling, and then unrotate if after scaling • Like the rotation field, the first values specify the X, Y and Z components of a 3D coordinate in the new, translated coordinate system and last value specifies the rotation angle measured in radian

  50. Scaling in Different Direction #VRML V2.0 utf8 Transform { scale 2.0 1.0 1.0 children [ Shape { appearance Appearance { material Material { } } geometry Sphere { } } ] }

More Related