Codul fisierului miscaPuc.wrl

38

Inline {
url "Background.wrl"
}
Inline {
url "floor.wrl"
}
PointLight {
intensity 10.0
ambientIntensity 0.9
color 0.8 0.4 0.0
location 5.0 12.0 -1.5
}

Transform {
rotation 1 0 0 1.571
children [
DEF BazaS PlaneSensor {}
DEF Baza Transform {
translation 0 0 0
rotation 1 0 0 -1.571
children [
#placa de baza
Shape {
appearance Appearance {
material Material { diffuseColor 0.5 0.5 0.5 }
}
geometry Cylinder {radius 1 height 0.1}
}
]
}
]
}

DEF Bila Transform {
translation 0 4 0
children [
Shape {
appearance DEF App Appearance {
material Material {
diffuseColor 0.3 0.31 0
ambientIntensity 0.3
specularColor 0.75 0.73 0
shininess 0.08
}
}
geometry Sphere {radius 0.3 }
}
]
}

DEF UmbraBila Transform {
translation 0 0 0
scale 1 0.3 1
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0 0 0
ambientIntensity 0.3
specularColor 0.75 0.73 0
shininess 0.08
}
}
geometry Sphere {radius 0.3 }
}
]
}


DEF Bara Transform {
translation 0 0 0
children [
Shape {
geometry IndexedLineSet {
coord DEF CooBara Coordinate {
point [0 0 0, 0 4 0]
}
coordIndex [0, 1, -1]
}
}
]
}


DEF Compute Script {
field SFNode bilaN USE Bila
field SFNode ubilaN USE UmbraBila
field SFNode bazaN USE Baza
field SFNode baraN USE CooBara

field SFVec3f tr 0 0 0
field SFVec3f nul 0 0 0
eventIn SFVec3f set_translation

url "vrmlscript:

function set_translation (tr,ts){
bazaN.set_translation=tr;
ubilaN.set_translation[0]=tr[0]/2;
bilaN.set_translation[0]=tr[0]/2;
baraN.set_point[1][0]=tr[0]/2;

ubilaN.set_translation[2]=tr[1]/2;
bilaN.set_translation[2]=tr[1]/2;
baraN.set_point[1][2]=tr[1]/2;
}
"
}

ROUTE BazaS.translation_changed TO Compute.set_translation

© Cornel Mironel Niculae, 2003-2004

13-Nov-2009