lab manual virtual reality

40
Week 1 Introduction to VRML Virtual Reality Modeling Language (VRML97) Introduction to VRML Virtual Reality Modeling Language • A file format to describe 3D scenes – identified by “.wrl” extension • Also a description of a run-time system for animating worlds. • Designed to be used in network situations. • Supports interaction and simulation of behavior of objects. • Designed to run on desktop PCs through to highend workstations VRML Basics VRML file contains Nodes that describe the scene A Node is defined with several Fields Each line gives the field, the type of the field, the name and the default value. How to Start You need, let’s say 3 things to get started. - A notepad document opens (start/execute/notepad)

Upload: shmook-alaez

Post on 08-May-2015

308 views

Category:

Design


6 download

DESCRIPTION

course of vrlm

TRANSCRIPT

Page 1: Lab manual virtual reality

Week 1

Introduction to VRML

Virtual Reality Modeling Language(VRML97)Introduction to VRML

Virtual Reality Modeling Language• A file format to describe 3D scenes– identified by “.wrl” extension• Also a description of a run-time system foranimating worlds.• Designed to be used in network situations.• Supports interaction and simulation of behavior of objects.• Designed to run on desktop PCs through to highend workstations

VRML BasicsVRML file contains Nodes that describe the sceneA Node is defined with several FieldsEach line gives the field, the type of the field, the name and the default value.

How to Start You need, let’s say 3 things to get started.- A notepad document opens (start/execute/notepad)- A VRML plugin installed for your browser: http://www.parallelgraphics.com/products/cortona/- Your browser openExample Node specificationCone {bottomRadius 1height 2}

Page 2: Lab manual virtual reality

Prog1:Sample VRML File to create a sphere “example1.wrl”#VRML V2.0 utf8Transform {children [Shape {appearance Appearance {material Material {diffuseColor 0.1 0.7 0.2}}geometry Sphere {radius 2} }]}

Classes of Node1. Shapes• Geometry• Appearance2.Transformations

1. Lights2. Groups

3.ShapesEach Shape has a geometry field that contains geometrynode and an appearance field that contains an appearancenode.Shape {appearance <some appearance>geometry <some geometry>}

Page 3: Lab manual virtual reality

Prog 2:Example (from example1.wrl)Shape {appearance Appearance {material Material {diffuseColor 0.1 0.7 0.2}}geometry Sphere {radius 2}

Geometry NodesBasic types• Box• Sphere• Cylinder• Cone• Text1.Box• defined by its size fieldBox {size 2.0 2.0 2.0}2.Sphere• defined by its radius fieldSphere {radius 1.5}Geometry Nodes1.Cylinder: defined by its height and radius fieldsCylinder {

Page 4: Lab manual virtual reality

height 2.0radius 1.0}2.Cone: defined by its height and radius fieldsCone {radius 1.3height 1.8} 3.Text:• defined by the string and the fontgeometry Text {string ["Hi!"]fontStyle FontStyle {family "TYPEWRITER"style "ITALIC"}}

Complex GeometryMany objects cannot be described with standard solids.Programs discussed in Lab

Program1 – Write a program in VRML to draw a box with desired size and colour.#VRML V2.0 utf8Transform {

children [

Page 5: Lab manual virtual reality

Shape {appearance Appearance {

material Material {

diffuseColor 0.0 0.5 0.5 }

}geometry Box { size 2 2 2}

}]

}

Program2 – Write a program in VRML to draw a Sphere#VRML V2.0 utf8

Transform {children [

Shape {appearance Appearance {

material Material {

diffuseColor 0.0 0.5 0.1}

}geometry Sphere{

radius 3}

}]

}

Page 6: Lab manual virtual reality

Program3– Write a program in VRML to draw a Cylinder#VRML V2.0 utf8Transform{

children[

Shape{

appearance Appearance{

material Material{

diffuseColor 1.0 0.0 0.0}

}geometry Cylinder{ radius 2 height5}

}]

}

Program 4– Write a program in VRML to draw a Cone#VRML V2.0 utf8Transform{

children[

Shape{

appearance Appearance{

material Material{

Page 7: Lab manual virtual reality

diffuseColor 1.0 0.0 0.0}

}geometry Cone{ bottomRadius 3 height 5}

}]

}

Program5– Write a program in VRML to draw a house like structure combine different shapes like Cone, Cylinder, Box.

#VRML V2.0 utf8# Cone is used as roof of the houseTransform{

translation 0.0 1.5 0.0children[

Shape{

appearance Appearance{

material Material{

diffuseColor 1.0 0.0 0.0}

}geometry Cone{

bottomRadius 2 height 2}

}]

Page 8: Lab manual virtual reality

}

# Cylinder is used as body of the houseTransform{

translation 0.0 -1.0 0.0children[

Shape{

appearance Appearance{

material Material{

diffuseColor 1.0 0.0 0.0}

}geometry Cylinder{

radius 2 height 3}

}]

}

# Box is used as door of the house.Transform{

translation 0.0 -1.95 2.0children[

Shape{

appearance Appearance{

Page 9: Lab manual virtual reality

material Material{

diffuseColor 0.0 1.0 0.0}

}geometry Box{

size 0.5 1.0 0.1}

}]

}

# Cone is used as shade above the entrance gate of the house. Transform{

translation 0.0 -1.4 2.0children[

Shape{

appearance Appearance{

material Material{

diffuseColor 0.0 1.0 0.0}

}geometry Cone{

bottomRadius 0.5 height 0.5}

}]

}

Page 10: Lab manual virtual reality

# Box is used as the base.Transform{

translation 0.0 -3.5 2.0children[

Shape{

appearance Appearance{

material Material{

diffuseColor 0.0 1.0 0.0}

}geometry Box{

size 50 2.0 50}

}]

}

Page 11: Lab manual virtual reality

Q.6 Write a program in VRML to draw the below design.

Solution: #VRML V2.0 utf8

Transform {translation 2 0 0

Page 12: Lab manual virtual reality

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Box {

size 6 3.5 3}

}]

}

Transform {translation -3 0 0children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Box {

size 2 3.5 3}

}]

}

Transform {translation 0 -1.8 1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

}}geometry Cylinder {

radius 0.5 height 0.3}

}

Page 13: Lab manual virtual reality

]}Transform {

translation 4 -1.8 1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

}}geometry Cylinder {

radius 0.5 height 0.3}

}]

}

Transform {translation -3 -1.8 1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

}}geometry Cylinder {

radius 0.5 height 0.3}

}]

}Transform {

translation 0 -1.8 -1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

Page 14: Lab manual virtual reality

}}geometry Cylinder {

radius 0.5 height 0.3}

}]

}Transform {

translation 4 -1.8 -1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

}}geometry Cylinder {

radius 0.5 height 0.3}

}]

}

Transform {translation -3 -1.8 -1.4rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .33 .34 .6

}}geometry Cylinder {

radius 0.5 height 0.3}

}]

}Transform {

translation -3 -1.8 0

Page 15: Lab manual virtual reality

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .24 .24 .24

}}geometry Cylinder {

radius 0.1 height 3.3}

}]

}Transform {

translation 0 -1.8 0rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .24 .24 .24

}}geometry Cylinder {

radius 0.1 height 3.3}

}]

}Transform {

translation 4 -1.8 0rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor .24 .24 .24

}}geometry Cylinder {

radius 0.1 height 3.3}

Page 16: Lab manual virtual reality

}]

}

Transform {translation -1 -1.5 0children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Box {

size 2 0.3 3}

}]

}

Q.7 Write a program in VRML to draw the below design.

Page 17: Lab manual virtual reality

Solution: #VRML V2.0 utf8Transform {

translation 0 1 0children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Cone {

bottomRadius 2 height 2}

}]

}

Transform {translation 0 -1.5 0

Page 18: Lab manual virtual reality

children [Shape {

appearance Appearance {material Material {

diffuseColor 2 0 2}

}geometry Cylinder {

radius 2 height 3}

}]

}

Transform {translation 0 -2.4 2.05children [

Shape {appearance Appearance {

material Material {diffuseColor 0 2 0

}}geometry Box {

size 0.5 1.0 0.2}

}]

}Transform {

translation 0 -1.5 2.0children [Shape {

appearance Appearance {material Material {

diffuseColor 2 0 2}

}geometry Cone {

bottomRadius 1 height 1}

}]

}Transform {

translation 0 2.4 0

Page 19: Lab manual virtual reality

children [Shape {

appearance Appearance {material Material {

ambientIntensity 0shininess 0

}}geometry Cylinder {

radius 0.1 height 2}

}]

}

Transform {translation 0 3.1 0.2rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Cylinder {

radius 0.1 height 0.5}

}]

}Transform {

translation 0 3.1 0.3rotation 1 0 0 0.13children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Box {

size 2 0.2 0.01

Page 20: Lab manual virtual reality

}}

]}

Transform {translation 0 3.1 0.3rotation 0 0 1 1.70children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Box {

size 2 0.2 0.01}

}]

}

Q.8 Write a program in VRML to draw the below design.

Solution: #VRML V2.0 utf8

Page 21: Lab manual virtual reality

Transform {rotation 0 0 1 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Cylinder {

height 3.8 radius 1.5}

}]

}Transform {

translation 2.4 0 0rotation 0 0 1 -1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Cone {

height 1 bottomRadius 1.5}

}]

}Transform {

translation -2.4 0 0rotation 0 0 1 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Cone {

height 1 bottomRadius 1.5}

}

Page 22: Lab manual virtual reality

]}Transform {

translation 1.5 -1.5 1children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}] }

Transform {translation -1.5 -1.5 1

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}]

}

Transform {translation -1.5 -1.5 -1

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}]

Page 23: Lab manual virtual reality

}

Transform {translation 1.5 -1.5 -1

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}] }

Transform {translation 1.5 2.3 0

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}]

}Transform {

translation 1.6 3.75 0rotation 0 0 1 1.57

children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 0.4 radius 0.15}

}]

Page 24: Lab manual virtual reality

}Transform {

translation 1.1 1.2 0children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 3 radius 0.15}

}]

}Transform {

translation 0 0.6 0children [Shape {

appearance Appearance {material Material {

diffuseColor 1 0 0}

}geometry Cylinder {

height 2 radius 0.4}

}]

}

Q.9 Write a program in VRML to draw the below design.

Page 25: Lab manual virtual reality

Solution:#VRML V2.0 utf8

Transform {translation 0 -2.7 0children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder {

radius 4 height 0.2}

}]

}

Transform {translation 2.5 -0.8 2.5

Page 26: Lab manual virtual reality

children [Shape {

appearance Appearance {material Material {

diffuseColor 0 0 1}

}geometry Cylinder {

radius 0.3 height 4}

}]

}Transform {

translation -2.5 -0.8 2.5children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder {

radius 0.3 height 4}

}]

}

Transform {translation 2.5 -0.8 -2.5children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder {

radius 0.3 height 4}

}]

}Transform {

translation -2.5 -0.8 -2.5

Page 27: Lab manual virtual reality

children [Shape {

appearance Appearance {material Material {

diffuseColor 0 0 1}

}geometry Cylinder {

radius 0.3 height 4}

}]

}Transform {

translation 0 1.7 0children [

Shape {appearance Appearance {

material Material {diffuseColor 1 1 1

}}geometry Cone {

bottomRadius 4.5 height 1.5}

}]

}Transform {

translation 0 2.4 0children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Cylinder {

radius 0.1 height 2}

}]

}Transform {

translation 0 3.1 0.2

Page 28: Lab manual virtual reality

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Cylinder {

radius 0.1 height 0.5}

}]

}

Transform {translation 0 3.1 0.3rotation 1 0 0 0.13children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Box {

size 2 0.2 0.01}

}]

}Transform {

translation 0 3.1 0.3rotation 0 0 1 1.70children [

Shape {appearance Appearance {

material Material {ambientIntensity 0shininess 0

}}geometry Box {

Page 29: Lab manual virtual reality

size 2 0.2 0.01}

}]

}

Q.10 Write a program in VRML to draw the below design.

#VRML V2.0 utf8

Transform {children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

}}geometry Box {

size 5 0.75 2}

}]

}

Transform {translation 0 0.65 0children [

Shape {appearance Appearance {

material Material {diffuseColor 1 0 0

Page 30: Lab manual virtual reality

}}geometry Box {

size 2.5 0.75 2}

}]

}

Transform {translation -0.5 0.65 0children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 0

}}geometry Box {

size 0.8 0.5 2.1}

}]

}

Transform {translation 0.5 0.65 0children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 0

}}geometry Box {

size 0.8 0.5 2.1}

}]

}

Transform { translation -1 -0.35 1

rotation 1 0 0 1.57children [

Shape {

Page 31: Lab manual virtual reality

appearance Appearance {material Material {

diffuseColor 0 0 1}

}geometry Cylinder{

radius 0.4 height 0.2}

}]

}

Transform { translation 1 -0.35 1

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder{

radius 0.4 height 0.2}

}]

}

Transform { translation -1 -0.35 -1

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder{

radius 0.4 height 0.2}

}]

}

Page 32: Lab manual virtual reality

Transform { translation 1 -0.35 -1

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder{

radius 0.4 height 0.2}

}]

}

Transform { translation 1 -0.35 0

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

}}geometry Cylinder{

radius 0.1 height 2}

}]

}

Transform { translation -1 -0.35 0

rotation 1 0 0 1.57children [

Shape {appearance Appearance {

material Material {diffuseColor 0 0 1

Page 33: Lab manual virtual reality

}}geometry Cylinder{

radius 0.1 height 2}

}]

}

More geometries.

Page 34: Lab manual virtual reality