Upload
dana-cross
View
222
Download
1
Tags:
Embed Size (px)
Citation preview
© TMC Computer School
HC20203 VRML 3 - 1
HIGHER DIPLOMA IN COMPUTING
Chapter 3 – Object Definition in VRML
© TMC Computer School
HC20203 VRML 3 - 2
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 3
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 4
HIGHER DIPLOMA IN COMPUTING
The Shape Syntax
All VRML shapes are built using the Shape node. The syntax of Shape node is as follows:
Shape {
appearance NULL # exposedfield SFNodegeometry 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
© TMC Computer School
HC20203 VRML 3 - 5
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 6
HIGHER DIPLOMA IN COMPUTING
The Appearance and Material Node
The Material node specifies material attributes as follows: Material{
ambientIntensity 0.2 # exposedfield SFFloatdiffuseColor 0.8 0.8 0.8 # exposedField SFColoremissiveColor 0.0 0.0 0.0 # exposedField SFColorshininess 0.2 # exposedField SFFloatspecularColor 0.0 0.0 0.0 # exposedField SFColor transparency 0.0 # exposedField SFFloat
}
© TMC Computer School
HC20203 VRML 3 - 7
HIGHER DIPLOMA IN COMPUTING
The Appearance and Material Node
The Appearance node specifies appearance attributes as follows:
Appearance{
material NULL # exposedfield SFNodetexture NULL # exposedField SFNodetextureTransform NULL # exposedField SFNode
} Note that the default values for the Material node create
shaded white shapes
© TMC Computer School
HC20203 VRML 3 - 8
HIGHER DIPLOMA IN COMPUTING
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 SFFloatheight 2.0 # field SFFloatside TRUE # field SFBoolbottom TRUE # field SFBool
}
© TMC Computer School
HC20203 VRML 3 - 9
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 10
HIGHER DIPLOMA IN COMPUTING
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 SFFloatheight 2.0 # field SFFloatside TRUE # field SFBooltop TRUE # fieldSFBoolbottom TRUE # field SFBool
}
© TMC Computer School
HC20203 VRML 3 - 11
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 12
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 13
HIGHER DIPLOMA IN COMPUTING
The Group Node
The Group node is used to group VRML nodes together Group{
children [ ] # exposedField MFNodebboxCenter 0.0 0.0 0.0 # field SFVec3fbboxSize -1.0 -1.0 -1.0 # field SFVec3faddChildren # eventIn MFNoderemoveChildren # 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
© TMC Computer School
HC20203 VRML 3 - 14
HIGHER DIPLOMA IN COMPUTING
Default Box
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
}
© TMC Computer School
HC20203 VRML 3 - 15
HIGHER DIPLOMA IN COMPUTING
Box with Dimension
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Box {
size 1.0 3.0 5.0
}
}
© TMC Computer School
HC20203 VRML 3 - 16
HIGHER DIPLOMA IN COMPUTING
Default Cone
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Cone { }
}
© TMC Computer School
HC20203 VRML 3 - 17
HIGHER DIPLOMA IN COMPUTING
Cone with Dimension
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Cone { bottomRadius 3.5 height 1.5 }}
© TMC Computer School
HC20203 VRML 3 - 18
HIGHER DIPLOMA IN COMPUTING
Default Cylinder
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Cylinder { }
}
© TMC Computer School
HC20203 VRML 3 - 19
HIGHER DIPLOMA IN COMPUTING
Cylinder with Dimension
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Cylinder { radius 4.0 height 1.0 }}
© TMC Computer School
HC20203 VRML 3 - 20
HIGHER DIPLOMA IN COMPUTING
Cylinder with no Top and Bottom
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Cylinder { radius 4.0 height 1.0 top FALSE bottom FALSE }}
© TMC Computer School
HC20203 VRML 3 - 21
HIGHER DIPLOMA IN COMPUTING
Default Sphere
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Sphere { }
}
© TMC Computer School
HC20203 VRML 3 - 22
HIGHER DIPLOMA IN COMPUTING
3D Plus Sign
#VRML V2.0 utf8Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 25.0 2.0 2.0 } },
© TMC Computer School
HC20203 VRML 3 - 23
HIGHER DIPLOMA IN COMPUTING
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 } } ]}
© TMC Computer School
HC20203 VRML 3 - 24
HIGHER DIPLOMA IN COMPUTING
A Space Station
#VRML V2.0 utf8Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Box { size 10.0 10.0 10.0 } },
© TMC Computer School
HC20203 VRML 3 - 25
HIGHER DIPLOMA IN COMPUTING
A Space Station Shape {
appearance USE White geometry Sphere { radius 7.0 } }, Shape { appearance USE White geometry Cylinder { radius 12.5 height 0.5 } },
© TMC Computer School
HC20203 VRML 3 - 26
HIGHER DIPLOMA IN COMPUTING
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 } },
© TMC Computer School
HC20203 VRML 3 - 27
HIGHER DIPLOMA IN COMPUTING
A Space Station
Shape {
appearance USE White
geometry Cylinder {
radius 1.0
height 60.0
}
}
]
}
© TMC Computer School
HC20203 VRML 3 - 28
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 29
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 30
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 31
HIGHER DIPLOMA IN COMPUTING
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 MFStringlength [ ] # exposedField MFFloatmaxExtent 0.0 # exposedField SFFloatfontStyle 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
© TMC Computer School
HC20203 VRML 3 - 32
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 33
HIGHER DIPLOMA IN COMPUTING
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 SFStringstyle “PLAIN” # field SFStringsize 1.0 # field SFFloatspacing 1.0 # field SFFloatjustify “BEGIN” # field SFStringhorizontal TRUE # field SFBoolleftToRight TRUE # field SFBooltopToBottom TRUE # field SFBoollanguage “” # field SFString
}
© TMC Computer School
HC20203 VRML 3 - 34
HIGHER DIPLOMA IN COMPUTING
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”
© TMC Computer School
HC20203 VRML 3 - 35
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 36
HIGHER DIPLOMA IN COMPUTING
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
© TMC Computer School
HC20203 VRML 3 - 37
HIGHER DIPLOMA IN COMPUTING
A Text Shape
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Text {
string "Qwerty"
}
}
© TMC Computer School
HC20203 VRML 3 - 38
HIGHER DIPLOMA IN COMPUTING
A List of Text String
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Text {
string [ "Qwerty", "0123" ]
}
}
© TMC Computer School
HC20203 VRML 3 - 39
HIGHER DIPLOMA IN COMPUTING
Small Length Field Value
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" length 2.0 }}
© TMC Computer School
HC20203 VRML 3 - 40
HIGHER DIPLOMA IN COMPUTING
A List of Text String
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", “Qwerty” ] length [ 3.0, 4.0 ] }}
© TMC Computer School
HC20203 VRML 3 - 41
HIGHER DIPLOMA IN COMPUTING
Text Limited by Maximum Extent
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty Uiop", "Asdf" ] maxExtent 4.0 }}
© TMC Computer School
HC20203 VRML 3 - 42
HIGHER DIPLOMA IN COMPUTING
Using Plain Font#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" fontStyle FontStyle { family "SERIF" style "" } }}
© TMC Computer School
HC20203 VRML 3 - 43
HIGHER DIPLOMA IN COMPUTING
Using Bold Font#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string "Qwerty" fontStyle FontStyle { family "SERIF" style "BOLD" } }}
© TMC Computer School
HC20203 VRML 3 - 44
HIGHER DIPLOMA IN COMPUTING
Using Small Font Text
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material { }
}
geometry Text {
string "Qwerty"
fontStyle FontStyle {
size 0.5
}
}
© TMC Computer School
HC20203 VRML 3 - 45
HIGHER DIPLOMA IN COMPUTING
Text with more than Default Spacing
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", "0123" ] fontStyle FontStyle { spacing 2.0 } }}
© TMC Computer School
HC20203 VRML 3 - 46
HIGHER DIPLOMA IN COMPUTING
Text with less than Default Spacing
#VRML V2.0 utf8Shape { appearance Appearance { material Material { } } geometry Text { string [ "Qwerty", "0123" ] fontStyle FontStyle { spacing 0.5 } }}
© TMC Computer School
HC20203 VRML 3 - 47
HIGHER DIPLOMA IN COMPUTING
Two Text Shape with Different Justification
#VRML V2.0 utf8Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Text { string "First" fontStyle FontStyle { family "SERIF" style "ITALIC" justify "END" size 1.0
© TMC Computer School
HC20203 VRML 3 - 48
HIGHER DIPLOMA IN COMPUTING
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 } } } ]}
© TMC Computer School
HC20203 VRML 3 - 49
HIGHER DIPLOMA IN COMPUTING
Two Text with a Line Between Them
#VRML V2.0 utf8Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Text { string [ "Above", "Below" ] fontStyle FontStyle { justify "MIDDLE" } } },
© TMC Computer School
HC20203 VRML 3 - 50
HIGHER DIPLOMA IN COMPUTING
Two Text with a Line Between Them
Shape {
appearance USE White
geometry Box {
size 5.0 0.01 2.0
}
}
]
}
© TMC Computer School
HC20203 VRML 3 - 51
HIGHER DIPLOMA IN COMPUTING
Using DEF and USE to share Font Properties
#VRML V2.0 utf8Group { children [ Shape { appearance DEF White Appearance { material Material { } } geometry Text { string [ "Over", "Strike" ] fontStyle DEF myFontStyle FontStyle { size 6.0 family "TYPEWRITER" justify "MIDDLE" } } },
© TMC Computer School
HC20203 VRML 3 - 52
HIGHER DIPLOMA IN COMPUTING
Using DEF and USE to share Font Properties
Shape {
appearance USE White
geometry Text {
string [ "----", "------" ]
fontStyle USE myFontStyle
}
}
]
}