Virtual Reality Modeling Language VRML

Download Report

Transcript Virtual Reality Modeling Language VRML

3D sprog
X3D: Et 3D sprog til at definere realtime
3D grafik der kan formidles via WWW.
–
XML integreret
–
Baseret på VRML
–
Relativt nyt så der findes endnu ikke godt
tutorials på nettet.
–
Så lad os kikke på stamfaderen nemlig
VRML.
Se evt. WEB3D CONSORTIUM.
Virtual Reality Modeling Language VRML
●
VRML er et sproget til generering af 3D grafik.
●
VRML fortolkes og vises af en VRML-browser.
●
VRML-browsere kan være standalone eller WWW-browser plug-ins.
●
Vha browseren kan man bevæge sig rundt i den genererede 3D grafik.
●
3D grafikken består af en rækker 3D objekter.
●
Disse 3D objekter kan være standart former eller brugerdefinerede former.
●
Hvert objekt placeres og evt roteres i de tre dimensioner.
●
Hvert objekt har en valgt overflade.
●
Objekterne kan animeres mht form, placering, rotation, skalering og farve
●
Objekter kan tilknyttes et ''Anchor'' og andre musestyrede handlinger.
Scene Graph
y
x
z
Man ser default fra Z-axen og med headlight.
Geometry
● Appearance
● Transform
●
Nodes, Fields
Group-note:
#VRML V2.0 utf8
Group {
children [ # En liste af notes
]
}
Note-navn
Field-navn
Shape note
Shape {
appearance Appearance {
material Material {
}
}
geometry Box {
}
}
geometry notes:
●
●
●
●
●
●
●
●
●
●
Box
Cone
Cylinder
ElevationGrid
Extrusion
IndexedFaceSet
IndexedLineSet
PointSet
Sphere
Text
Appearance {
exposedField SFNode material
NULL
exposedField SFNode texture
NULL
exposedField SFNode textureTransform NULL
}
Box og Cone
Box {
field SFVec3f size 2 2 2
}
Cone {
field
field
field
field
}
SFFloat
SFFloat
SFBool
SFBool
# (0, )
bottomRadius 1
# (0,)
height
2
# (0,)
side
TRUE
bottom
TRUE
Material
Material {
exposedField SFFloat ambientIntensity 0.2
# [0,1]
exposedField SFColor diffuseColor 0.8 0.8 0.8 # [0,1]
exposedField SFColor emissiveColor 0 0 0
# [0,1]
exposedField SFFloat shininess
0.2
# [0,1]
exposedField SFColor specularColor 0 0 0
# [0,1]
exposedField SFFloat transparency 0
# [0,1]
}
Shape {
appearance Appearance {
material Material {
emissiveColor 0 0.8 0
transparency 0.5
}
}
geometry Box {
}
}
ambientIntensity: The amount of ambient light that the
object reflects.
diffuseColor: The normal colour of the object.
emissiveColor: The object 'glows' with a light of its own of
this colour.
shininess: How reflective the object is.
specularColor: The colour of highlights on shiny objects.
transparency: How transparent the object is.
Texture
ImageTexture, MovieTexture, or PixelTexture
ImageTexture {
exposedField MFString url []
field
SFBool repeatS TRUE
field
SFBool repeatT TRUE
}
Browsere understøtter: JPEG og PNG.
Browsere understøtter ofte også: CGM og GIF
Appearance {
texture ImageTexture {
url "brick.jpg"
}
}
Transform
Transform {
eventIn
MFNode
addChildren
eventIn
MFNode
removeChildren
exposedField SFVec3f
center
0 0 0 # (-,)
exposedField MFNode
children
[]
exposedField SFRotation rotation
0 0 1 0 # [-1,1],(-,)
exposedField SFVec3f
scale
1 1 1 # (0,)
exposedField SFRotation scaleOrientation 0 0 1 0 # [-1,1],(-,)
exposedField SFVec3f
translation 0 0 0 # (-,)
field
SFVec3f bboxCenter
0 0 0 # (-,)
field
SFVec3f bboxSize
-1 -1 -1 # (0,) or -1,-1,-1
}
Transform {
translation 1 1 1
rotation 0 1 0 0.78
scale 2 1 2
children [
USE FBOX
]
}
DEF FBOX Shape {
appearance Appearance {
material Material {
}
}
geometry Box {
}
}
Browseropsætning
NavigationInfo {
eventIn
SFBool
set_bind
exposedField MFFloat avatarSize
[0.25, 1.6, 0.75]
exposedField SFBool headlight
TRUE
exposedField SFFloat speed
1.0
exposedField MFString type
"WALK"
exposedField SFFloat visibilityLimit 0.0
eventOut
SFBool isBound "WALK"
}
where the user walks around and is affected by gravity,
"FLY"
where the user moves around unaffected by gravity,
"EXAMINE"
where the user remains static, but can rotate the world
around to view it from various angles, and
"NONE"
where the user has no movement controls at all.
Animation
ROUTE SENSOR.touchTime TO SOUND.startTime
Touch og Sound
Group {
children [
Shape {
appearance Appearance {
material Material
diffuseColor 1 0 0
}
}
geometry Sphere {
radius 3.0
}
}
DEF SNDTOUCH TouchSensor {}
Sound {
minFront 10
minBack 10
maxFront 50
maxBack 50
source DEF SOUND AudioClip {
url "pop.wav"
}
}
]
}
ROUTE SNDTOUCH.touchTime TO SOUND.startTime
Interpolators og Animation
DEF TIMER TimeSensor {
cycleInterval 10
loop TRUE
}
DEF POSINT PositionInterpolator {
key [0, 0.25, 0.5, 0.75, 1]
keyValue [1 4 -10,
1 2 -10,
-1 2 -10,
-1 4 -10,
1 4 -10 ]
}
DEF POSTGT Transform {
translation 0 3 -10
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0 1
}
}
geometry Sphere {
}
}
ROUTE TIMER.fraction_changed TO POSINT.set_fraction
ROUTE POSINT.value_changed TO POSTGT.set_translation
Time og Position
TimeSensor {
exposedField SFTime
exposedField SFBool
exposedField SFBool
exposedField SFTime
exposedField SFTime
eventOut
SFTime
eventOut
SFFloat
eventOut
SFBool
eventOut
SFTime
}
cycleInterval 1
enabled
TRUE
loop
FALSE
startTime
0
stopTime
0
cycleTime
fraction_changed
isActive
time
Time og Position
PositionInterpolator {
eventIn
SFFloat set_fraction
exposedField MFFloat key
[]
exposedField MFVec3f keyValue
[]
eventOut
SFVec3f value_changed
}
OrientationInterpolator {
eventIn
SFFloat set_fraction
exposedField MFFloat key
[]
exposedField MFRotation keyValue
[]
eventOut
SFRotation value_changed
}
ColorInterpolator {
eventIn
SFFloat set_fraction
exposedField MFFloat key
[]
exposedField MFColor keyValue
[]
eventOut
SFColor value_changed
}
JavaScript
Script {
eventIn SFBool input
field SFBool boolValue TRUE
eventOut SFBool output
url "javascript:
function input(value, time) {
if (value==boolValue) output = value;
}
}
Java
●VRMLScript
●ECMAscript
●
Anchor
Anchor {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0 1
}
}
geometry Sphere {
}
]
parameter [ "target= name_of_frame" ]
description "Gaa til wrmlkule.html"
url "wrmlkule.html"
}
Viewpoint
Viewpoint {
position 0 5 5
orientation 1 0 0 0.39
fieldOfView 0.39
description "Camera 1"
}
world.wrl#Camera 1
Light
DirectionalLight {
exposedField SFColor color
exposedField SFVec3f direction
exposedField SFFloat intensity
exposedField SFBool on
}
111
0 0 -1
1
TRUE
PointLight {
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
}
SFVec3f
SFColor
SFFloat
SFVec3f
SFBool
SFFloat
attenuation
100
color
111
intensity
1
location
000
on
TRUE
radius
100
SpotLight {
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
exposedField
}
SFVec3f
SFFloat
SFColor
SFFloat
SFVec3f
SFFloat
SFVec3f
SFBool
SFFloat
attenuation
100
beamWidth
1.570796
color
111
cutOffAngle
0.785398
direction
0 0 -1
intensity
1
location
000
on
TRUE
radius
100
Eks.
#VRML V2.0 utf8
WorldInfo {
title "t2"
info ["bla."]
}
Background{
skyColor [
0.0 0.2 0.7
0.0 0.5 1.0
1.0 1.0 1.0
]
skyAngle [ 1.309, 1.571 ]
}
groundColor [
0.1 0.10 0.0
0.4 0.25 0.2
0.6 0.60 0.6
]
groundAngle [ 1.309, 1.571 ]
NavigationInfo {
#avatarSize
[0.25, 1.6, 0.75]
headlight
FALSE
speed
1.0
#type
"WALK"
visibilityLimit 0.0
}
Eks.
Viewpoint {
position -1 1 10
orientation 1 0 0 0
#fieldOfView 0.39
description "Normal"
}
Viewpoint {
position 10 1 0
orientation 0 1 0 1.571
#fieldOfView 0.39
description "Kamera 2"
}Viewpoint {
position -1 1 -10
orientation 0 1 0 3.14
#fieldOfView 0.39
description "Kamera 3"
}
Viewpoint {
position -1 10 2.5
orientation 1 0 0 -1.3
#fieldOfView 0.39
description "TopKamera"
}
Viewpoint {
position -1 -2 4
orientation 1 0 0 0.7
#fieldOfView 0.39
description "bundkamera"
}
DEF TIMER TimeSensor {
cycleInterval 30
loop TRUE
}
Eks
Transform {
rotation 0 1 0 .26
children [
DEF POSINT PositionInterpolator {
key [0, 0.25, 0.5, 0.75, 1]
keyValue [ 0 0 -250,
0 0 -150,
0 0 -50,
0 0 50,
0 0 150 ]
}
DEF POSTGT Transform {
translation 0 0 -50
children [
Transform {
scale 1 0.7 0.7
rotation 1 0 0 -1.56
}]}]}
translation 0 4.9 0
children [
Transform {
rotation 0 0 1 1.56
children [
Inline {
url "XB-70.wrl"
}
]
}
]
ROUTE TIMER.fraction_changed TO POSINT.set_fraction
ROUTE POSINT.value_changed TO POSTGT.set_translation
Eks
Transform {
scale 0.5 .5 .5
translation -3 -0.5 0
}
children [
Inline {
url "ppmskilt.wrl"
}
]
#VRML V2.0 utf8
WorldInfo {
title "Rotor skilt Per P Madsen"
info ["(C) Copyright 2000 Per P. Madsen AAU"
"[email protected]"]
}
NavigationInfo {
type
"NONE"
}
Viewpoint {
position 0 0.5 4.5
}
DEF TIMER TimeSensor {
cycleInterval 10
loop TRUE
}
Transform {
children [ ............
...........