实验报告
学号级: 数媒 091 班 姓名:丁超 实验目的:
学号:1、理解接触监测器 TouchSensor 的一般使用方法
2、掌握各种检测器的功能和使用方法
3、掌握在 VRML 场景中实现交互的设计方法
实验内容:
1、灯的开关
设计要求:
设计代码:
DEF word Transform { translation 0 4 0 children [
Shape {
appearance Appearance { material Material { diffuseColor .95 .32 .32 specularColor .07 .02 .01 ambientIntensity .13 shininess .02
}
}
geometry Text {
string [
"Welcome!"
]
}
}
]
}
Transform {
children [
DEF kg TouchSensor {}
Shape {
appearance Appearance {
material Material {
diffuseColor .23 .39 .19 specularColor .2 .3 .29 ambientIntensity .06
shininess .39
}} geometry Text { string [ "Click"
]
}
}
]
}
DEF light DirectionalLight { direction 0 0 -1 intensity 0.2
}
DEF clock TimeSensor { cycleInterval 3
}
DEF path ScalarInterpolator {
key [0 1] keyValue [0.2 1]
}
ROUTE kg.touchTime TO clock.startTime
ROUTE clock.fraction_changed TO path.set_fraction
ROUTE path.value_changed TO light.intensity 效果图:
2、平移门
设计要求: 设计代码:
Tran sform {
tran slatio n 0 0.8 0
childre n [
Shape {
appeara nee Appeara nee { material Material { ambie ntlnten sity 0 }
}
geometry Box {
size 3.4 0.2 0.3
}
}
]
}
Tran sform {
tran slation -1.6 0 0 children [
DEF k Shape { appearance Appearance { material Material { ambientIntensity 0 }
} geometry Box { size 0.2 1.6 0.3
}
}
]
}
Transform {
translation 1.6 0 0 children [
USE k
]
}
Group {
children [
DEF m Transform {
children [ Shape { appearance Appearance { material Material { diffuseColor .23 .39 .19 specularColor .2 .3 .29 ambientIntensity .06 shininess .39
}
} geometry Box { size 3 1.5 0.2
}
}
]
}
DEF m_sensor PlaneSensor {
maxPosition 2.9 0
minPosition 0 0
}
}
]
]
}
ROUTE m_se nsor.tra nslati on _cha nged TO m.tra nslati on
效果图:
3、旋转
设计要求:
设计代码:
Tran sform {
tran slatio n 0 0.8 0
childre n [
Shape {
appeara nee Appeara nee { material Material { ambie ntlnten sity 0 }
}
geometry Box {
size 3.4 0.2 0.3
Transform {
translation -1.6 0 0 children [ DEF k Shape { appearance Appearance { material Material { ambientIntensity 0
}
} geometry Box { size 0.2 1.6 0.3
}
}
]
}
Transform {
translation 1.6 0 0 children [
USE k
]
}
Group {
children [
DEF m Transform {
children [ Shape { appearance Appearance { material Material { diffuseColor .23 .39 .19 specularColor .2 .3 .29 ambientIntensity .06 shininess .39
}
}
geometry Box {
size 3 1.5 0.2
DEF m_se nsor Cyli nderSe nsor {
}
]
}
ROUTE m_se nsor.rotati on _cha nged TO m.rotati on
效果图: