vrml实例源代码(摆球、风扇、书柜代码)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1. 会动的摆球
#VRML V2.0 utf8
Background {skyColor .6 .6 1}
Transform {translation 0 -2.5 0 children [Shape {appearance Appearance { material
Material{diffuseColor 0 1 1} } geometry Box {size 10 1 1}}
]}
Transform {translation 4 0 0
children [Shape {appearance Appearance{
material Material {diffuseColor 1 0 1} }geometry Box {size 0.5 5.8 0.6}} ]}
Transform {translation -4 0 0
children [Shape {appearance Appearance{
material Material {diffuseColor 1 0 1} }geometry Box {size 0.5 5.8 0.6}} ]}
Transform {translation 0 2.5 0 rotation 0 0 1
1.571 children [Shape { appearance
Appearance {material
Material {
diffuseColor .5 0 1}} geometry Cylinder {radius 0.2 height 7.5}}]}
material Material {diffuseColor
2 1 1}}
geometry Sphere {radius
0.3}
}]}
Transform {translation 0 0.6 0 children [Shape {appearance Appearance {
material Material {diffuseColor 0 .8 1}}
geometry Cylinder {radius 0.1 height 3.5}
}]}
]}
]}
DEF left Transform { translation -1.2 0 0 center 0
2.35 0 children [USE hk ]}
Transform {
translation 0.6 0 0 rotation 0 0 1 0 children
[USE hk ]}
Transform { translation -.6 0 0 rotation 0 0 1
0 children [USE hk ]}
DEF right Transform {
translation 1.2 0 0
center 0 2.35 0
children [USE hk ]}
DEF hk Transform {
children [Group {children [
Transform {translation 0 -1.42 0
children [Shape {appearance Appearance { DEF time TimeSensor { cycleInterval 1 loop TRUE enabled TRUE } DEF z1 OrientationInterpolator { key [0 0.25 0.5 0.75 1] keyValue [
0 0 1 0,
0 0 1 0.5,
0 0 1 0,
0 0 1 0,
0 0 1 0,]}
DEF z2 OrientationInterpolator {
key [0 0.25 0.5 0.75 1] keyValue [
0 0 1 0, 0 0 1 0, 0 0 1 0,
0 0 1 -0.5, 0 0 1 0,]}
ROUTE time.fraction_changed TO z1.set_fraction
ROUTE time.fraction_changed TO z2.set_fraction
ROUTE z1.value_changed TO right.rotation
ROUTE z2.value_changed TO left.rotation
2. 不用电的电风扇
#VRML V2.0 utf8
Background {skyColor [1 1 0.9]}
DEF a Transform { translation 0 1.3 -0.2 children [
Shape {
appearance Appearance { material
Material { diffuseColor 1 1 1}} geometry Sphere
{radius 0.2}}
Transform {translation 1 0 0 scale 0.9 0.3 0.1 center -1
0 0 rotation 0 0 1 0 children [
appearance Appearance {
material Material { diffuseColor
0 0 1}} geometry Sphere {radius 1}}]}
Transform {translation 1 0 0 scale 0.9 0.3 0.1 center -
1 0 0 rotation 0 0 1 2.094 children [
Shape { appearance Appearance { material
Material { diffuseColor 0 1 0}} geometry Sphere
{radius 1}}]}
Shape { Transform {translation 1 0 0
scale 0.9 0.3 0.1
center -1 0 0
rotation 0 0 1 4.18
children [
Shape {
appearance Appearance {
material Material { diffuseColor
1 0 0 }} geometry Sphere {radius 1}}]}]} Transform {translation 0 1.3 0
scale 7 7 1.5
center 0 0 0
rotation 0 0 1 0 children [
Shape {
appearance Appearance {
material Material { diffuseColor 0 1 1 transparency 0.77}} geometry Sphere {radius 0.3}}]}
Transform {translation 0 1.3 -0.72
rotation 1 0 0 1.57
children [
Shape {
appearance Appearance { material Material { diffuseColor 1 0 1 }} geometry Cylinder
{height 0.75 radius 0.2}}]}
children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0.5 1 }} geometry Box {size 3 0.2 2.3}}]}
Transform {
translation 1 -1.3 0.8
children [
Shape {
appearance Appearance { material
Material { diffuseColor 1 0 0}}
geometry Sphere {radius
0.2}}]}
Transform {
translation -1 -1.3 0.8
children [
Shape {
appearance Appearance {
material Material { diffuseColor
0 1 0}} geometry Sphere {radius 0.2}}]}
Transform {translation 0 0 -0.8 DEF sj TimeSensor {
enabled TRUE
cycleInterval 1 loop TRUE
appearance Appearance {
material Material {
diffuseColor 1 1 1 }}
geometry Cylinder {height 2.8 radius 0.13}}]}
}
DEF zhuan OrientationInterpolator { key [0 0.25 0.5
0.75 1] keyValue [0 0 1 0
0 0 1 1.57 0 0 1 3.14
0 0 1 4.71
0 0 1 6.28]
children [
Shape {
Transform {translation 0 -1.4 0
DEF you Transform { center -0.8 0 0
}]}
Transform
{ children [ Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} }
geometry Box {size 0.2 4 2} }]}
Transform { translation -1.5 1.1 0
children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} }
geometry Box {size 0.2 4 2} }]}
Transform { translation 0 1.1 -0.9 children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} } geometry Box {size 3 4 0.2} }]}
3. 见鬼似的书柜
#VRML V2.0 utf8
#VRML V2.0 utf8
Background {skyColor [0.8 0.8 09.8]} Transform { translation 0 3 0
children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} } geometry Box {size 3 0.2 2}
DEF zuo Transform {
center 0.8 0 0
translation 0.8 1.1 1 children [
Shape {
appearance Appearance { material Material { diffuseColor 0 1 1} } geometry Box {size 1.6 4 0.2} }]}
translation 1.5 1.1 0
ROUTE sj.fraction_changed TO zhuan.set_fraction ROUTE zhuan.value_changed TO a.rotation
Shape {
appearance Appearance {
appearance Appearance { material Material
{ diffuseColor 0 1 1}
}
geometry Box {size 1.6 4 0.2} }]}
Transform { translation 0 1 0
children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} } geometry Box {size 3 0.2 2} }]}
material Material { diffuseColor 0 0 1} }
geometry Box {size 0.2 1.5 2} }]}
Transform { translation 0 -2.3 0 children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} } geometry Box {size 3 0.2 2} }]}
Transform { translation 0 -1 0 children [
Shape {
appearance Appearance {
material Material { diffuseColor
0 0 1}
Transform { translation 0 -1.65 -0.9 children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1} } geometry Box {size 3 1.5 0.2} }]}
Transform { translation -1.5 -1.65 0 children [
Shape {
appearance Appearance { material Material { diffuseColor 0 0 1}
}
geometry Box {size 0.2 1.5 2} }]}
}
geometry Box {size 3 0.2 2}
}]}
DEF ct Transform
{ children [
Shape {
appearance Appearance {
material Material { diffuseColor
1 0 1}
}
geometry Box {size 2.8 1.1
1.9}
}]}
DEF sj TimeSensor { loop TRUE
cycleInterval 2}
DEF zhuan
translation -0.8 1.1 1 children [
Transform { translation 1.5 -1.65 0
OrientationInterpolator {
children [
Shape {
translation 0 -1.65 0.05
key [0 0.25 0.5 0.75 1]
keyValue [
0 1 0 0
0 1 0 1.57
0 1 0 1.57
0 1 0 1.57 0 1 0 0]
}
DEF zhuan1 OrientationInterpolator {
key [0 0.25 0.5 0.75 1]
keyValue [
0 1 0 0
0 1 0 -1.57
0 1 0 -1.57
0 1 0 0
0 1 0 0]
} DEF ctd PositionInterpolator {
key [0 0.5 1]
keyValue [ 0 -1.65 0.05
0 -
1.65 2
-1.65 0.05]
}
ROUTE sj.fraction_changed TO
ctd.set_fraction
ROUTE sj.fraction_changed TO zhuan.set_fraction
ROUTE sj.fraction_changed TO zhuan1.set_fraction
ROUTE zhuan.value_changed TO zuo.rotation
ROUTE zhuan1.value_changed TO you.rotation
ROUTE ctd.value_changed TO
ct.translation。