520 likes | 530 Views
Learn about building primitive shapes in VRML, including Box, Cone, Cylinder, and Sphere nodes. Understand how appearance and material nodes define the shape's color and texture.
E N D
Building Primitive Shapes • Each node may have the following characteristics • A type name. Examples include Box, Color, Group, Sphere, Sound, or SpotLight • Zero or more fields that define how each node differs from other nodes of the same type • A set of events that it can receive and send • An implementation • A name • The Shape node associates a geometry node with nodes that define that geometry's appearance
Building Primitive Shapes • Shape nodes must be part of the transformation hierarchy to have any visible result • The transformation hierarchy must contain Shape nodes for any geometry to be visible • A Shape node contains exactly one geometry node in its geometry field • The appearance of a shape is being described y the Appearance and Material nodes • Using the default values, we will be able to create shaded white shape • These primitive shapes include Box, Cone, Cylinder and Sphere node
The Shape Syntax • All VRML shapes are built using the Shape node. • The syntax of Shape node is as follows: Shape { appearance NULL # exposedfield SFNode geometry NULL # exposedField SFNode } • The value of the geometry field specifies either a Box, Cone, Cylinder, and Sphere nodes • The default NULL value for this field indicates the absence of geometry
The Shape Syntax • The appearance field specifies a node defining the appearance of the shape including its color and surface texture • The default NULL indicates a glowing white appearance
The Appearance and Material Node • The Material node specifies material attributes as follows: Material { ambientIntensity 0.2 # exposedfield SFFloat diffuseColor 0.8 0.8 0.8 # exposedField SFColor emissiveColor 0.0 0.0 0.0 # exposedField SFColor shininess 0.2 # exposedField SFFloat specularColor 0.0 0.0 0.0 # exposedField SFColor transparency 0.0 # exposedField SFFloat }
The Appearance and Material Node • The Appearance node specifies appearance attributes as follows: Appearance { material NULL # exposedfield SFNode texture NULL # exposedField SFNode textureTransform NULL # exposedField SFNode } • Note that the default values for the Material node create shaded white shapes
The Cone Node • The Cone node creates a cone-shaped primitive geometry and may be used as the value of the geometry field in the Shape node Cone { bottomRadius 1.0 # field SFFloat height 2.0 # field SFFloat side TRUE # field SFBool bottom TRUE # field SFBool }
The Cone Node • The value of the bottomRadius specifies the radius of the bottom of a 3D cone centered at the origin • The height specifies the cone’s height in the Y direction • The side specifies whether or not the sloping sides of the once are built • The bottom specifies whether or not the circular bottom of the cone is built
The Cylinder Node • The Cylinder node creates a cylinder-shaped primitive geometry and may be used as the value of the geometry field in the Shape node Cylinder { radius 1.0 # field SFFloat height 2.0 # field SFFloat side TRUE # field SFBool top TRUE # fieldSFBool bottom TRUE # field SFBool }
The Cylinder Node • The value of the radius specifies the radius of 3D cylinder centered at the origin • The height specifies the cylinder’s height in the Y direction • The side specifies whether or not the curving sides of the cylinder are built • The top specifies whether or not the circular top of the cylinder is built • The bottom specifies whether or not the circular bottom of the cylinder is built
The Sphere Node • The Sphere node creates a sphere-shaped (a ball or globe) primitive geometry and may be used as the value of the geometry field in the Shape node Sphere { radius 1.0 # field SFFloat } • The value of the radius specifies the radius of the 3D sphere centered at the origin
The Group Node • The Group node is used to group VRML nodes together Group { children [ ] # exposedField MFNode bboxCenter 0.0 0.0 0.0 # field SFVec3f bboxSize -1.0 -1.0 -1.0 # field SFVec3f addChildren # eventIn MFNode removeChildren # eventOut MFNode } • The value of the children field specifies a list of child nodes to be included in the group. • Typical children field include Shape nodes and other Group nodes. • In this course, we will not be covering the rest of the fields
Default Box #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } }
Box with Dimension #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Box { size 1.0 3.0 5.0 } }
Default Cone #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Cone { } }
Cone with Dimension #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Cone { bottomRadius 3.5 height 1.5 } }
Default Cylinder #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Cylinder { } }
Cylinder with Dimension #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Cylinder { radius 4.0 height 1.0 } }
Cylinder with no Top and Bottom #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Cylinder { radius 4.0 height 1.0 top FALSE bottom FALSE } }
Default Sphere #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Sphere { } }
3D Plus Sign #VRML V2.0 utf8 Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 25.0 2.0 2.0 } },
3D Plus Sign Shape { appearance USE White geometry Box { size 2.0 25.0 2.0 } }, Shape { appearance USE White geometry Box { size 2.0 2.0 25.0 } } ] }
A Space Station #VRML V2.0 utf8 Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 10.0 10.0 10.0 } },
A Space Station Shape { appearance USE White geometry Sphere { radius 7.0 } }, Shape { appearance USE White geometry Cylinder { radius 12.5 height 0.5 } },
A Space Station Shape { appearance USE White geometry Cylinder { radius 4.0 height 20.0 } }, Shape { appearance USE White geometry Cylinder { radius 3.0 height 30.0 } },
A Space Station Shape { appearance USE White geometry Cylinder { radius 1.0 height 60.0 } } ] }
Building Text Shapes • In order to build text node in VRML, we need to specify the VRML Text node as the value of the Shape node’s geometry field • For each of the text geometry, we can specify a list of text strings and the length of each string • The FontStyle node aids us in controlling the font, style and size of the text
Building Text Shapes • Fields in the Text node enable us to control: • the text string or series of characters to be built • the maximum permissible extent of the lines or columns of text • the exact length of each line or column of text • the font or typeface to use for the text along with its style, justification, and other attributes
Building Text Shapes • The FontStyle node enables us to control: • the font family defining the character shapes used for the text • the font style of the text such as bold, italic or normal • the font size of the text • the spacing of the text lines or columns • the justification of the lines or columns of text • the orientation of the text: horizontal or vertical • the flow direction of the text: from left to right, right to left, top to bottom or bottom to top • the specific language features to use
The Text Node • The Text node is used to create text geometry and may be used as the value for the geometry field in s Shape node Text { string [ ] # exposedField MFString length [ ] # expose dField MFFloat maxExtent 0.0 # exposedField SFFloat fontStyle NULL # exposedField SFNode } • The value of the string exposed field specifies one more or lines of text to build • Each line or column of text is enclosed within quotation mark
The Text Node • The value of string exposed field can be changed by routing an event to the exposed field’s implied set_string eventIn • The value of the length exposed field specifies the desired length, in VRML units of each line of text • A length of 0.0 specifies text strings that are built at their natural length without compressing or expanding • The value of the maxExtent specifies the maximum permissible length in VRML units of any line of column of text • And the value of fontStyle specifies the characteristics defining the look of the text created by the Text node
The FontStyle Node • The FontStyle node is used to control the look of the text geometry created by a Text node • A FontStyle node may be used as the value of the fontStyle field in a Text node FontStyle { family “SERIF” # field SFString style “PLAIN” # field SFString size 1.0 # field SFFloat spacing 1.0 # field SFFloat justify “BEGIN” # field SFString horizontal TRUE # field SFBool leftToRight TRUE # field SFBool topToBottom TRUE # field SFBool language “” # field SFString }
The FontStyle Node • The value of the family field specifies the standard VRML font families to use and the valid font includes: • “SERIF” • “SANS” • “TYPEWRITER” • The value of the style field specifies the text style to use and the valid style includes: • “PLAIN” • “BOLD” • “ITALICS” • “BOLDITALIC”
The FontStyle Node • The value of the size field specifies the height of the characters measured in VRML units • The value of the spacing field specifies the vertical line spacing in VRML unit of horizontal text or the horizontal column spacing of the vertical text • The value of the horizontal field specifies whether text strings are built horizontally or vertically • The values of horizontal, leftToRight and topToBottom fields are used in combination to control horizontal or vertical text placement
The FontStyle Node • The values of justify field specifies the way in which the text shape’s block of text is positioned relative to the X and Y axes • “FIRST” • “BEGIN” • “MIDDLE” • “END” • The value of the language field specifies the context of the language used in values of he Text node’s string field
A Text Shape #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" } }
A List of Text String #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", "0123" ] } }
Small Length Field Value #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" length 2.0 } }
A List of Text String #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", “Qwerty” ] length [ 3.0, 4.0 ] } }
Text Limited by Maximum Extent #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty Uiop", "Asdf" ] maxExtent 4.0 } }
Using Plain Font #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" fontStyle FontStyle { family "SERIF" style "" } } }
Using Bold Font #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" fontStyle FontStyle { family "SERIF" style "BOLD" } } }
Using Small Font Text #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" fontStyle FontStyle { size 0.5 } }
Text with more than Default Spacing #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", "0123" ] fontStyle FontStyle { spacing 2.0 } } }
Text with less than Default Spacing #VRML V2.0 utf8 Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", "0123" ] fontStyle FontStyle { spacing 0.5 } } }
Two Text Shape with Different Justification #VRML V2.0 utf8 Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Text { string "First" fontStyle FontStyle { family "SERIF" style "ITALIC" justify "END" size 1.0
Two Text Shape with Different Justification Shape { appearance USE White geometry Text { string "Second" fontStyle FontStyle { family "SANS" style "BOLD" justify "BEGIN" size 1.0 } } } ] }
Two Text with a Line Between Them #VRML V2.0 utf8 Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Text { string [ "Above", "Below" ] fontStyle FontStyle { justify "MIDDLE" } } },
Two Text with a Line Between Them Shape { appearance USE White geometry Box { size 5.0 0.01 2.0 } } ] }