Lab manual virtual reality

  • View
    231

  • Download
    6

  • Category

    Design

Preview:

DESCRIPTION

course of vrlm

Citation preview

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}

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>}

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 {

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 [

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}

}]

}

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{

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}

}]

}

# 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{

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}

}]

}

# 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}

}]

}

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

Solution: #VRML V2.0 utf8

Transform {translation 2 0 0

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}

}

]}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

}}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

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}

}]

}

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.

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

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

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

}}

]}

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

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}

}

]}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}

}]

}

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}

}]

}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.

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

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

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

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 {

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

}}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 {

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}

}]

}

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

}}geometry Cylinder{

radius 0.1 height 2}

}]

}

More geometries.

Recommended