#VRML V2.0 utf8 #
# ex-tran2.wrl # Example : Transformation Node # Draw 3 cones at different locations # Observer in (0,0,6) looking at (0,0,1) Viewpoint { position 0 0 10 orientation 0 0 1 0 } # First draw a green (specular) cone located at (0,0,0) Shape{ appearance Appearance { material Material { specularColor .0 1. .0 } } geometry Cone{} } #Transform defines a coordinate system for its children that is relative # to the coordinate system of its parents #EventIn addChildren : used to add new nodes (defined elsewhere) to be transformed #EventIn removeChildren : used to avoid transforming defined nodes #center : 0 0 0 (default) ; defines a translation offset #rotation : 0 0 1 0 (default) #scale : 1 1 1 (default) #scaleOrientation : 0 0 1 0 (default) #translation : translated on x -> 3 0 0 #children : cone #bboxCenter: 0 0 0 (default) #bboxSize : -1 -1 -1 (default) #example : rotate 45 on z (counterclockwise) Transform{ center 0 0 0 #we are rotating on z, 45 degree (counterclockwise) rotation 0 0 1 1 #we are scaling in all directions in 50% scale 1. 1. 1. scaleOrientation 0 0 1 0 #translate of (3,0,0) translation 3 0 0 children [ # Now draw a red (specular) cone Shape{ appearance Appearance { material Material { specularColor 1. 0. .0 } } geometry Cone{} } # add a new transformation to the last transformation # and draw another cone now at (3,0,0) + (0,3,0) # note that this transformation is inside the first child Transform{ center 0 0 0 #we are rotating on z, 45 degree (clockwise) => back to vertical #Remember we are adding transformations rotation 0 0 -1 1 scale 1 1 1 scaleOrientation 0 0 1 0 #translate of (0,3,0) translation 0 3 0 # Pay attention that the cone will note go to (3,3,0) due to # the transformation nesting !!! children [ # Now draw a blue (specular) cone Shape{ appearance Appearance { material Material { specularColor 0. 0. 1. } } geometry Cone{} } ] } ] } #