VRML e-book

61
VRML V 1.0 & V 2.0 Practical For Beginner E-BOOK CONTOH LATIHAN 3D MENGGUNAKAN VRML UNIVERSITAS NASIONAL TEKNIK INFORMATIKA

description

buku VRML

Transcript of VRML e-book

Page 1: VRML e-book

VRML V 1.0 & V 2.0

Practical

For Beginner

E-BOOK CONTOH LATIHAN 3D MENGGUNAKAN VRML

UNIVERSITAS NASIONAL TEKNIK INFORMATIKA

Page 2: VRML e-book

1.STRINGSoftware => cortona3D viewer ,VRMLpad

HIMPUNAN MAHASISWA TEKNIK INFORMATIKA

Page 3: VRML e-book
Page 4: VRML e-book
Page 5: VRML e-book

#VRML V1.0 asciiSeparator { FontStyle{style ITALICsize 11

}

AsciiText{ string [ "selamat datang", "di", "Dunia anak"] justification CENTER}}

Page 6: VRML e-book

2.CUBE

#VRML V1.0 asciiSeparator { Material { diffuseColor 0 1 1} Cube { }}

Page 7: VRML e-book

3.CONE

#VRML V1.0 asciiSeparator { Material { diffuseColor 1 0 1} Cone { }}

Page 8: VRML e-book

4.CYLINDER

#VRML V1.0 asciiSeparator { Material { diffuseColor 0 1 0} Cylinder { }}

Page 9: VRML e-book

5.SPHERE

#VRML V1.0 asciiSeparator { Material { diffuseColor 1 1 1} Sphere { }}

Page 10: VRML e-book

6.SPECULAR

#VRML V1.0 asciiMaterial{ diffuseColor [ 1 0 0 ]specularColor[ 0. 1 0. 1 0. 1 ] }Sphere { }

Material{ diffuseColor [ 1 0 0 ]specularColor[ 0. 5 0. 5 0. 5] }Transform { translation 3 0 0 }Sphere { }

Material{ diffuseColor [ 1 0 0 ]specularColor[ 0. 9 0. 9 0. 9] }Transform { translation 3 0 0 }Sphere { }

Page 11: VRML e-book

7.TRANSPARENCY

#VRML V1.0 asciiMaterial{ diffuseColor [ 1 0 0 ]transparency[ 0. 1 ] }Transform { translation 3 0 0 }Cylinder { }

Material{ diffuseColor [ 1 0 0 ]transparency[ 0. 5 ] }Transform { translation 3 0 0 }Cone { }

Material{ diffuseColor [ 1 0 0 ]transparency[ 0. 1 ] }Transform { translation 3 0 0 }Cone { }

Page 12: VRML e-book

#VRML V1.0 asciiMaterial{ diffuseColor [ 1 0 1 ]transparency[ 0. 1 ] }Transform { translation 3 0 0 }Cylinder { }Material{ diffuseColor [ 0 1 0 ]transparency[ 0. 5 ] }Transform { translation 3 0 0 }Cone { }Material{ diffuseColor [ 0 1 1 ]transparency[ 0. 1 ] }Transform { translation 3 0 0 }Cube { }Material{ diffuseColor [ 1 0 0 ]transparency[ 0. 1 ] }Transform { translation 3 0 0 }Sphere { }

Page 13: VRML e-book

8.EMISSIVE

#VRML V1.0 asciiMaterial{ diffuseColor [ 1 0 0 ]emissiveColor[ 1 0 0 ] }Cone { }

Material{ diffuseColor [ 1 0 0 ]emissiveColor[ 0 0 0 ] }Transform { translation 3 0 0 }Cone { }

Material{ diffuseColor [ 1 0 0 ]emissiveColor[ 0. 9 0. 9 0. 9] }Transform { translation 3 0 0 }Cone { }

Page 14: VRML e-book

9.TEXTURE

#VRML V1.0 asciiTexture2 { filename "merak.png" }Cube { }

Page 15: VRML e-book

10.TEXTURE3D

#VRML V1.0 asciiTexture2 { filename "merak.png" }Transform { translation 3 0 0 }Cube { }

Texture2 { filename "merak.png" }Transform { translation 3 0 0 }Cone { }

Texture2 { filename "merak.png" }Transform { translation 3 0 0 }Cylinder { }

Page 16: VRML e-book

#VRML V1.0 asciiTexture2 { filename "rails.png" }Transform { translation 3 0 0 }Cone { }

Texture2 { filename "rails.png" }Transform { translation 3 0 0 }Cylinder { }

Texture2 { filename "rails.png" }Transform { translation 3 0 0 }Cube { }

Page 17: VRML e-book

#VRML V1.0 asciiTexture2 { filename "emas.jpg" }Transform { translation 3 0 0 }Cone { }

Texture2 { filename "emas.jpg" }Transform { translation 3 0 0 }Cylinder { }

Texture2 { filename "emas.jpg" }Transform { translation 3 0 0 }Cube { }

Texture2 { filename "emas.jpg" }Transform { translation 3 0 0 }Sphere { }

Page 18: VRML e-book

#VRML V1.0 ascii

Texture2 { filename "unas.jpg" }Cube { }

Texture2 { filename "unas.jpg" }Transform { translation 3 0 0 }Cone { }

Texture2 { filename "unas.jpg" }Transform { translation 3 0 0 }Cylinder { }

Texture2 { filename "unas.jpg" }Transform { translation 3 0 0 }Cube { }

Texture2 { filename "unas.jpg" }Transform { translation 3 0 0 }Sphere { }

Page 19: VRML e-book

#VRML V1.0 asciiSeparator { Separator { #Lantai menggunakan Garis

Material { ambientColor 0 1 0 } Coordinate3 { point [ -5 0 -5, -5 0 5, 5 0 5, 5 0 -5 ] } IndexedLineSet { coordIndex [ 0, 1, 2, 3, 0, -1 ] } } Separator { #Dinding Tengah Transform { translation 0 2.5 -3.5 } Material { ambientColor 0 1 1 } DEF Wall Cube { # Memberi nama objek width 5 height 5 depth 0.2 } } Separator { #Dinding Kanan Transform { translation 3.5 2.5 0 rotation 0 1 0 1.57 } Material { ambientColor 0 1 1 } USE Wall # pembentukan objek } }Separator { #Dinding kiri

Page 20: VRML e-book

Transform { translation -3.5 2.5 0 rotation 0 1 0 1.57 } Material { ambientColor 0 1 1 } USE Wall # pembentukan objek } }}

Page 21: VRML e-book

#VRML V1.0 asciiSeparator {

Separator {#lantai Texture2 { filename "kayu.jpg"} Coordinate3 { point [ -5 0 -5, -5 0 5, 5 0 5, 5 0 -5 ]}IndexedLineSet { coordIndex [ 0, 1, 2, 3, 0, -1 ]}}Separator {# dinding tengahTransform { translation 0 2.5 -3.5 }Texture2 { filename "batu.jpg"}

DEF wall Cube { width 5 height 5 depth 0.2}}Separator { #dinding kanan Transform { translation 3.5 2.5 0 rotation 0 1 0 1.57 }Texture2 { filename "kayu.jpg"}USE wall # pembentukan objek }

Page 22: VRML e-book

} Separator { #dinding kiri Transform { translation -3.5 2.5 0 rotation 0 1 0 1.57 }Texture2 { filename "kayu.jpg"}USE wall # pembentukan objek }}}

Page 23: VRML e-book

VRML V2.0

Latihan menggunakan VRML V2.0

#VRML V2.0 utf8Shape { geometry Cone { bottomRadius 2 height 2 }}

Page 24: VRML e-book

#VRML V2.0 utf8#Copper ConeShape { appearance Appearance { material Material { diffuseColor 0.3 0.11 0 specularColor 0.75 0.33 0.00 shininess 0.08 ambientIntensity 0.26 } }geometry Cone { bottomRadius 2 height 2 } }

Page 25: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance { material Material { diffuseColor 0 1 0 } } geometry Cone { bottomRadius 2 height 2 }} Shape { geometry Cone {}}

Page 26: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance { material Material { diffuseColor 1 1 0 transparency 0.25 } } geometry Cone { bottomRadius 2 height 2 }} Shape { geometry Cone {}}

Page 27: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0 0 1 } } geometry Cone { bottomRadius 2 height 2 }}

Page 28: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance { material Material {diffuseColor 0 0 1 transparency 0.25 } } geometry Cone { bottomRadius 2 height 2 } } Shape { geometry Cone {}}

Page 29: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.2 0.2 0.71 specularColor 0.83 0.83 0.83 shininess 0.12 ambientIntensity 0.1

} } geometry Cone { bottomRadius 1 height 3 }}

Page 30: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.27 0 0 specularColor 0.61 0.13 0.18 shininess 0.20 ambientIntensity 0.15

} } geometry Cone { bottomRadius 1 height 3 }}

Page 31: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.1 0.03 0.22 specularColor 0.64 0 0.98 shininess 0.20 ambientIntensity 0.17

} } geometry Cone { bottomRadius 1 height 3 }}

Page 32: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.22 0.15 0 specularColor 0.71 0.7 0.56 shininess 0.16 ambientIntensity 0.4

} } geometry Cone { bottomRadius 1 height 3 }}

Page 33: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.3 0.3 0.5 specularColor 0.7 0.7 0.8 shininess 0.1 ambientIntensity 0.3

} } geometry Cone { bottomRadius 1 height 3 }}

Page 34: VRML e-book

#VRML V2.0 utf8Shape { appearance Appearance{ material Material{ diffuseColor 0.3 0.11 0 specularColor 0.75 0.33 0.00 shininess 0.08 ambientIntensity 0.26

} } geometry Cone { bottomRadius 1 height 3 }}

Page 35: VRML e-book
Page 36: VRML e-book

#VRML V2.0 utf8Transform {children [NavigationInfo { headlight FALSE } # We’ll add our own lightDirectionalLight { # First childdirection 0 0 -1 # Light illuminating the scene}Transform { # Second child - a red sphere translation 3 0 1 children [ Shape { geometry Sphere { radius 2.3 } appearance Appearance { material Material { diffuseColor 1 0 0 } # Red } } ]}Transform { # Third child - a blue box translation -2.4 .2 1 rotation 0 1 1 .9 children [ Shape { geometry Box {} appearance Appearance { material Material { diffuseColor 0 0 1 } # Blue } } ] }] # end of children for world}

Page 37: VRML e-book
Page 38: VRML e-book

#VRML V2.0 utf8PROTO TwoColorStool [ field SFColor legColor .8 .4 .7field SFColor seatColor .6 .6 .1 ]{ Transform { children [ Transform { # stool seat translation 0 0.6 0 childrenShape {appearance Appearance {material Material { diffuseColor IS seatColor } } geometry Box { size 1.2 0.2 1.2 } } }Transform { # first stool legtranslation -.5 0 -.5childrenDEF Leg Shape {appearance Appearance {material Material { diffuseColor IS legColor } }geometry Cylinder { height 1 radius .1 } } }Transform { # another stool legtranslation .5 0 -.5children USE Leg}Transform { # another stool legtranslation -.5 0 .5children USE Leg}Transform { # another stool legtranslation .5 0 .5children USE Leg}] # End of root Transform’s children} # End of root Transform} # End of prototype

# The prototype is now defined. Although it contains a number of # only the legColor and seatColor fields are public. Instead of

Page 39: VRML e-book

# default legColor and seatColor, this instance of the stool has # and a green seat:TwoColorStool {legColor 1 0 0 seatColor 0 1 0}NavigationInfo { type "EXAMINE" } # Use the Examine viewer

Page 40: VRML e-book

#VRML V2.0 utf8Transform {translation 0 2 0children [Shape {appearance Appearance {material Material {diffuseColor 1 0 0}}geometry Cone { }},Transform {scale 2 2 2children [Shape {appearance Appearance {material Material {diffuseColor 0 0 1}}geometry Sphere { }},Transform {translation 2 0 0children [Shape {appearance Appearance {material Material {diffuseColor 0 1 0}}geometry Cylinder { }}]}]

}]}

Page 41: VRML e-book
Page 42: VRML e-book

#VRML V2.0 utf8# right_side_up# ice cream

Transform{rotation 1 0 0 3.14children Shape {appearance Appearance {material Material {diffuseColor 0.5 0.5 0} # end material} # end appearancegeometry Cone {bottom FALSE # make bottom invisible} # end cone} # end shape} # end transform

Page 43: VRML e-book

#VRML V2.0 utf8#DEF USE example...

DEF shorttower Group{children [Transform{translation 0 1 0children [Transform {translation 0 1.5 0children Shape{appearance Appearance {material Material {diffuseColor 1 0 0} # end material} # end appearancegeometry Cone { }} # end shape} # end transformShape{appearance Appearance {material Material {diffuseColor 0 1 0} # end material} # end appearancegeometry Cylinder { height 1 }} # end shape] # end children} # end Transform] # end children} # end groupTransform{translation 0 1 0rotation 1 0 0 3.14children USE shorttower} # end transform

Page 44: VRML e-book
Page 45: VRML e-book

#VRML V2.0 utf8#openbox example...Transform{rotation 0 1 0 .78 # rotate 90 degrees about y axischildren Shape {appearance Appearance {material Material {diffuseColor 0 1 0.5 # light green color} # end material} # end appearancegeometry IndexedFaceSet {solid FALSE # make visible from top and bottomcoord Coordinate {point [1 1 1, 1 -1 1, -1 -1 1, -1 1 1,-1 1 -1, -1 -1 -1, 1 -1 -1, 1 1 -1,1.5 1.5 1, 1.5 1.5 -1,-1.5 1.5 1, -1.5 1.5 -1]} # end coordinatecoordIndex [0,1,2,3,-1, # 5 sides0,1,6,7,-1,1,6,5,2,-1,3,2,5,4,-1,5,6,7,4,-1,0,7,9,8,-1, # 2 flaps4,3,10,11,-1]} # end indexedfaceset} # end shape} # end transform

Page 46: VRML e-book
Page 47: VRML e-book

#VRML V2.0 utf8#simple elevation example...Shape {appearance Appearance {material Material {diffuseColor 0 1 0}} #end appearancegeometry ElevationGrid {solid FALSEheight [0, 0.1, 0.1, 0,1.2, 2.1, 1.9, 1.4,0.2, 0.2, 0.5, 0]xDimension 4 #4 vertices in the x planezDimension 3 #3 vertices in the z planexSpacing 1 #spacing of 1 meter for x planezSpacing 2 #spacing of 2 meters for z plane} #end elevationgrid} #end shape

Page 48: VRML e-book

Contoh desain menggunakan VRML V1.0rumah

#VRML V1.0 asciiDEF BackgroundColor Info { string "1 1 1"}

DEF Dinding Separator{Texture2 {filename "batubata.jpg"}

Cube{ width 1.5

height 1depth 1.5 }

} DEF Atap Separator {

Texture2 {filename "batik.jpg"} Transform {translation -1 0.5 1}

Coordinate3 {point [0 0 0,

2 0 0, 2 0 -2, 0 0 -2, 1 1 -1] }

IndexedFaceSet{ coordIndex

[0, 1, 2, 3, 0, -1, 0, 1, 4, -1, 1, 2, 4, -1, 2, 3, 4, -1, 0, 3, 4, -1] }

}

DEF Pintu Separator {

Texture2 {filename "kayu.jpg"}Coordinate3{ point [0.25 -0.5 0.75,

0.25 0.25 0.75, -0.25 0.25 0.75, -0.25 -0.5 0.75] }

IndexedFaceSet { coordIndex

[0, 1, 2, 3, -1] } }

Page 49: VRML e-book
Page 50: VRML e-book

Membuat Meja

#VRML V1.0 ascii

DEF BackgroundColor Info {string "1 1 1"}### objek meja #DEF Meja Separator{

#Alas meja#DEF Alas Separator{Texture2 {filename "kayu.jpg"}

Cube{ width 10 height 1.5 depth 7}

}

Separator {

Transform { translation 3 -2 -2} #kaki meja# DEF Kaki Separator {

Texture2 {filename "batu.jpg"} Cylinder { radius 0.5

height 5 } }

} }# kaki meja ke-2# Separator {Transform {translation -3 -2 -2}

USE Kaki}

# kaki meja ke-3# Separator { Transform {translation 3 -2 2 }

USE Kaki}#kaki meja ke -4# Separator { Transform {translation -3 -2 2}

USE Kaki} } #akhir objek meja#

Page 51: VRML e-book
Page 52: VRML e-book

Membuat Roket

#VRML V1.0 asciiDEF BackgroundColor Info { string "1 1 1"}

DEF Roket Separator{

Material {diffuseColor 1 1 0}

DEF Pertama Separator{

Transform {translation 0.5 0 0.5}DEF Kaki Separator{ Cylinder {radius 0.5 height 1 } }Transform {translation -1 0 0}USE Kaki

Transform {translation 0 0 -1}USE KakiTransform {translation 1 0 0}USE Kaki

}Transform {translation 0 1 0}DEF Kedua Separator{

Material {diffuseColor 1 0 0}Cylinder { }

}

DEF Ketiga Separator{

Material {diffuseColor 0 0 1}Transform {translation 0.5 2 0.5}DEF Tiang Separator{

Cylinder { radius 0.25 }}Transform {translation -1 0 0}USE Tiang

Transform {translation 0 0 -1}USE TiangTransform {translation 1 0 0}USE Tiang

}DEF Keempat Separator{

Material {diffuseColor 0 1 0}

Page 53: VRML e-book

Transform {translation 0 4 0}Cylinder { }

}DEF Kelima Separator {

Material {diffuseColor 1 0 0}Transform {translation 0 6 0}Cone { }

}}

Page 54: VRML e-book

Membuat Monas

#VRML V1.0 ascii#membuat groud tanah#DEF Tanah Separator{

Texture2 {filename "silver.jpg"}Cube {width 10

height 0.05 depth 10

} } #bagian bawah monas# DEF Dasar Separator {

Texture2 {filename "silver.jpg"} Transform {rotation 1 0 0 3.14} Coordinate3

{ point [

1 0 1, 1 0 -1, -1 0 -1, -1 0 1, 2 -1 2, 2 -1 -2, -2 -1 -2, -2 -1 2] } IndexedFaceSet { coordIndex

[0, 1, 2, 3, -1, 4, 5, 6, 7, -1, 0, 1, 5, 4, -1, 1, 2, 6, 5, -1, 2, 3, 7, 6, -1, 3, 0, 4, 7, -1] }

}#alas penutup poligon#DEF Alas Separator{

Texture2 {filename "silver.jpg" }Transform{translation 0 1 0}Cube {width 3.5

depth 3.5 height 0.05}

}#tiang monas#DEF Tiang Separator{

Texture2 {filename "silver.jpg" }

Page 55: VRML e-book

Transform {translation 0 3 0}Cube {width 0.75

depth 0.75height 5 }

}#bagian atas monas#

DEF Atap Separator{

Transform {translation 0 5.5 0 }Transform {scaleFactor 0.5 0.5 0.5 }USE DasarUSE Alas

}#Emas monas#

DEF Emas Separator{

Texture2 {filename "gold.jpg" }Transform {translation 0 7 0}Cone {bottomRadius 0.4

height 1.75}}

Page 56: VRML e-book

Puri Inggris

#VRML V1.0 ascii#DEF BackgroundImage Info { string " "}DEF BackgroundColor Info { string "1 1 1" }#objek menara bigbenDEF Bigben Separator{

#dinding ke-1DEF Kubus Separator{

Texture2 {filename "batu.jpg"}Cube {}

}#dinding ke-2DEF Silinder Separator{

Texture2 {filename "silver.jpg"}Transform {translation 0 2 0}

Page 57: VRML e-book

Cylinder {}}#dinding ke-3Separator{

Transform {translation 0 4 0}USE Kubus

}#jamDEF Bola Separator{

Transform {translation 0 4 0}Texture2 {filename "rose.jpg"}Sphere {radius 1.25}

}#atap menaraDEF Kerucut Separator{

Texture2 {filename "gold.jpg"}Transform {translation 0 6 0}Cone {}

}}#objek pagar sekeliling menara#DEF Wall Separator{

Texture2 {filename "seratkayu.jpg"}Transform {translation 3 0 0}Cube{width 5

height 2depth 1}

}#mengkopi menara sebanyak 3 kali#

Separator{ Transform {translation 6 0 0}

USE BigbenTransform {translation 0 0 -6}USE BigbenTransform {translation -6 0 0}USE Bigben }

#mengkopi pager sebanyak 3 kali#Separator{Transform {translation 0 0 -6}

USE Wall }Separator

Page 58: VRML e-book

{Transform {rotation 0 1 0 1.5707}#Transform {translation 0 0 0}USE WallTransform {translation 0 0 6}USE Wall

}

Page 59: VRML e-book
Page 60: VRML e-book
Page 61: VRML e-book

Perhatian :Koding diatas adalah VRML V1.0 dan VRML V2.0

------TUTORIAL INI GRATIS-----

Rilis Januari 2011

By: HIMTI (HIMPUNAN MAHASISWA TEKNIK INFORMATIKA)DIVISI LITBANG

Dibuat untuk Mahasiswa yang ingin mempelajari VRML

Fakultas Teknologi Komunikasi dan InformatikaJurusan Teknik Informatika

Faculty of Information and Communication technology Department of Informatic Engineering

www.unas.ac.id