You are on page 1of 27

04/30/16 03:06

Instance Transformation

Model
Coordinates

UML

04/30/16 03:06

Instancing in OpenGL
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(...);
glRotate(...);
glScale(...);
glutSolidCylinder(...); /*or some other symbol*/
Symbol
Cylinder
Cylinder

Scale
sx, sy, sz

Rotate
x,y, z

Translate
dx,dy,dz

...

Sphere

Tabular Representation

UML

04/30/16 03:06

Example of a Linked Structure: Robot Arm


y

x
z

UML

04/30/16 03:06

Moving Robot Components and Frames

h2

Base : R y ( )
h1

LowerArm : R y ( )T(0, h1 , 0)R z ( )


UpperArm : R y ( )T(0, h1 , 0)R z ( )T(0,h2 , 0)R z ( )

UML

04/30/16 03:06

Robot Construction
Base : R y ( )
LowerArm : R y ( )T(0, h1 , 0)R z ( )
UpperArm : R y ( )T(0, h1 , 0)R z ( )T(0, h2 , 0)Rz ( )

display()
{
glRotate(theta, 0.0, 1.0, 0.0);
base();
glTranslatef(0.0, h1, 0.0);
glRotatef(phi, 0.0, 0.0, 1.0);
lower_arm();
glTranslatef(0.0, h2, 0.0);
glRotatef(psi, 0.0, 0.0, 1.0);
upper_arm();
}

UML

04/30/16 03:06

Hierarchical Structure
Transform
Base

* Draw Func.
* Child(ren)

display()
{
glRotate(theta, 0.0, 1.0, 0.0);
base();
glTranslatef(0.0, h1, 0.0);
glRotatef(phi, 0.0, 0.0, 1.0);
lower_arm();
glTranslatef(0.0, h2, 0.0);
glRotatef(psi, 0.0, 0.0, 1.0);
upper_arm();
}

Lower
Arm

Upper
Arm

UML

04/30/16 03:06

Tree Representation of More Complex Robot

Torso

Head

Left Upper
Arm

Left Lower
Arm

Right Upper
Arm

Right Lower
Arm

Left Upper
Leg

Left Lower
Leg

Right Upper
Leg

Right Lower
Leg

UML

04/30/16 03:06

Tree with Transformations

Torso

Th
Head

Tlua
Left Upper
Arm

Tlla
Left Lower
Arm

Trua
Right Upper
Arm

Trla
Right Lower
Arm

Tlul
Left Upper
Leg

Tlll
Left Lower
Leg

Trul
Right Upper
Leg

Trll
Right Lower
Leg

UML

04/30/16 03:06

Traversing the Tree


figure()
{
Torso();
glPushMatrix();
glTranslatef(...);
glRotatef(...);
Head();
glPopMatrix(...);
glPushMatrix(...);

Torso

Th
Head

Tlua
Left Upper
Arm

Trua
Right Upper
Arm

Tlla

Trla

Left Lower
Arm

Right Lower
Arm

Tlul
Left Upper
Leg

Tlll
Left Lower
Leg

Trul
Right Upper
Leg

Trll
Right Lower
Leg

Current
Transform.
T
TTh
T

glTranslatef(...);
glRotatef(...);
TTua
LeftUpperArm();
glTranslatef(...);
glRotatef(...);
TTuaTlla
LeftLowerArm();
glPopMatrix(...);
glPushMatrix(...);

glTranslatef(...);
glRotatef(...);
TTrua
RightUpperArm();
glTranslatef(...);
glRotatef(...);
TTruaTrla
RightLowerArm();

UML

04/30/16 03:06

10

Scene Graphs
Scene

Translate

Translate

Rotate

Translate

Rotate

Object 1

Object 2

Object 3

Object 4

UML

04/30/16 03:06

11

Scene Graphs
Traversing the Graph

glPushMatrix();
glTranslate(...);
glRotate(..._;
Object1();

Scene

glPopMatrix();
glPushMatrix();
glTranslate(...);
Translate

Rotate

Translate

Translate

Object 4

Object2();
glPopMatrix();
glPushMatrix();

Rotate

glTranslate(...);
glRotate(...);
Object 1

Object 2

Object 3

Object3();
glPopMatrix();
glPush Matrix();
Object4();

UML

04/30/16 03:06

12

Architecture for Graphics on the Internet

Model

Application

API

UI

Graphics
Pipeline

Display

Browser
Model
Server
TCP/IP

Graphics
Pipeline

TCP/IP

Browser
UI
Display

Graphics
Pipeline

UI
Display

TCP/IP

Network/Internet

UML

04/30/16 03:06

13

VRML Design Goals


0 Composability
0 Scalability
0 Extensibility
0 Simple authoring

UML

04/30/16 03:06

14

VRML 2.0 Scene Graph Structure


Nodes
Group

Transformation

Shape

UML

04/30/16 03:06

15

VRML 2.0
Node Format
Node_Name {
field_name field_value
field_name field_value
.
.
.
field_name field_value
}

Each field has an associated class and type. Field class


is one of:
field, exposedfield, eventIn, enventOut
UML

04/30/16 03:06

16

VRML 2.0
Field Types
SFBool

The Boolean value TRUE or FALSE

SFFloat

A 32-bit floating point value

SFInt32

A 32-bit signed integer

SFTime

An absolute or relative time value

SFVec2f

A pair of floating point values,


usually used to represent texture
coordinates

SFVec3f

Three floating point values, usually


used to represent a 3D position

SFColor

Three floating point values between


zero and one, used to represent RGB

SFRotation

Four floating point values. The first


three represent an axis, the fourth an
angle
UML

04/30/16 03:06

17

VRML 2.0
Field Types
SFImage

A two-dimensional image with one to four


color components

SFString

A UTF8 (international character) string

SFNode

A container for another VRML node

MFFloat

An array of SFFloat values

MFInt32

An array of SFInt32 values

MFVec2f

An array of SFVec2f values

MFVec3f

An array of SFVec3f values

MFColor

An array of SFColor values

MFRotation

An array of SFRotation values

MFString

An array of SFString values


UML

04/30/16 03:06

18

VRML 2.0
Composing Node Hierarchies
Node_name_1 {
field_name field_value
field_name Node_name_2 {
field_name field_value
field_name field_value
}
field_name Node_name_3 {
field_name field_value
field_name field_value
}
}

UML

04/30/16 03:06

19

VRML 2.0
The Shape Node Definition

Node Name
Shape
}
Field Class

Field Name

{
exposedField SFNode appearance NULL
exposedField SFNode geometry NULL

Field Type

Default Value

Bold values are what is actually typed in source file.


UML

04/30/16 03:06

20

VRML 2.0
Geometry Nodes
0 Predefined shapes

0
0
0
0
0
0

- Cone
- Box
- Cylinder
- Sphere
PointSet
IndexedLineSet (polyline)
IndexedFaceSet (polygonal object)
ElevationGrid
Extrusion
Text

UML

04/30/16 03:06

21

VRML 2.0
Cone Definition
Cone {

field
field
field
field

SFFloat
SFFloat
SfBool
SFBool

bottomRadius
height
side
bottom

1
2
TRUE
TRUE

The Cone node specifies a cone centered in the local coordinate


system and whose axis is aligned with the local y axis.
The Boolean fields define whether the sides or bottom
of the cone are visible. All dimensions are in meters.

UML

04/30/16 03:06

22

VRML 2.0
Box Definition
Box {
}

field SFVec3f size

2 2 2

The Box node specifies a rectangular box in the local coordinate


system centered at 0,0,0 and aligned with coordinate axes.

UML

04/30/16 03:06

23

VRML 2.0
Cylinder Definition
Cylinder {
field
field
field
field
field
}

SFBool
SFFloat
SFFloat
SFBool
SFBool

bottom
height
radius
side
top

TRUE
2
1
TRUE
TRUE

Sphere Definition
Sphere {
field SFFloat
}

radius 1

UML

04/30/16 03:06

24

VRML 2.0
Indexed Face Set - Partial Definition
IndexedFaceSet {
exposedField
field
field
field
field
...
}

SFNode coord
NULL
SFBool ccw
TRUE
SFBool convex
TRUE
MFInt32 coordIndex []
SFBool solid
TRUE

Coordinate {
exposedField MFVec3f
}

point

[]

There are 13 other fields in IndexedFaceSet, making it the


most complex and flexible node in VRML.

UML

04/30/16 03:06

25

VRML 2.0
Simplest Possible World
Geometry
Field

Shape Node
Shape{
}

geometry Cone { }

Shape node has no appearance


field: accept all white.

Cone node has


no fields: accept
all default values.

UML

04/30/16 03:06

26

VRML 2.0
Appearance & Material Nodes
Appearance {
exposedField SFNode
exposedField SFNode
exposedField SFNode
}
Material {
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
}

SFFloat
SFColor
SFColor
SFFloat
SFColor
SFFloat

material
NULL
texture
NULL
textureTransform NULL

ambientIntensity 0.2
diffuseColor
0.8 0.8 0.8
emissiveColor 0 0 0
shininess
0.2
specularColor 0 0 0
transparency
0

UML

04/30/16 03:06

27

VRML 2.0
Transform Node Definition
Transform {
enventIn
eventIn
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
field
field
}

MFNode
MFNode
SFVec3f
MFNode
SFRotation
SFVec3f
SFRotation
SFVec3f
SFVec3f
SFVec3f

addChildren
removeChildren
center
children
rotation
scale
scaleOrientation
translation
bboxCenter
bboxSize

0 0 0
[]
0 0 1 0
1 1 1
0 0 1 0
0 0 0
0 0 0
-1 -1 -1

Order of application:
T(translation) T(rotation) T(scale) {children}

UML

You might also like