vrml实例(vrml场景实例代码)
一、什么是vrml浏览器
VRML文件需要安装专用的浏览器才能运行。由于VRML具有广阔的发展前景,因此对其解释支持的浏览器有很多,一般可分为以下三大类。
(1)单独应用类(standalone application):此类浏览器可直接从Internet上下载.wrl文件并展现其图像,而不需要Web浏览器的支持。这类浏览器有Open Worlds、World View for Developers等。使用这类浏览器需要编译源文件,并利用专用的工具包进行场景浏览。
(2)辅助应用类(helper application):此类浏览器是作为对某种网络浏览器如Netscape Navigator的帮助,源文件不需进行编译。当网络浏览器遇到一个VRML连接时,就会启动帮助浏览器。
(3)插件类(plugin):此类浏览器是作为一种插件安装在网络浏览器上的,比较流行的有World View,也称Microsoft Vrml;还有Parallel Graphics公司的Cortona、SGI公司的Cosmo Player等。一般来说,后两种浏览器是免费的,而且并非某种VRML浏览器专门针对某种网络浏览器,除非有特殊说明,因此选择浏览器原则上不受什么限制。
二、求vrml实例代码!!急!
vrml4-3飞碟.wrl
#VRML V2.0 utf8
#创建多个坐标系
Background{
skyColor[
0.2 0.5 0.6
]
}
#创建飞碟造型
Transform{
translation 0.0 0.0 0.0
scale 2.3 1.6 2.3
children[
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.20#造型外观材料的亮度
}
}
geometry Sphere{#球体
radius 1.0
}
}
]
}
Transform{
translation 0.0 0.0 0.0
scale 4.0 1.0 4.0
children[
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.20#造型外观材料的亮度
}
}
geometry Sphere{#球体
radius 1.0
}
}
]
}
vrml4-4哑铃.wrl
#VRML V2.0 utf8
#创建多个坐标系
Background{
skyColor[
0.2 0.5 0.6
]
}
#创建造型
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.20#造型外观材料的亮度
}
}
geometry Cylinder{#圆柱体
radius 0.4
height 3.5
top TRUE
bottom TRUE
side TRUE
}
}
Transform{
translation 0.0 2.0 0.0
children[
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.20#造型外观材料的亮度
}
}
geometry Sphere{#球体
radius 1.0
}
}
]
}
Transform{
translation 0.0-2.0 0.0
children[
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.20#造型外观材料的亮度
}
}
geometry Sphere{#球体
radius 1.0
}
}
]
}
vrml4-5糖葫芦.wrl
#VRML V2.0 utf8
#创建多个坐标系
Background{
skyColor[
0.2 0.5 0.6
]
}
#创建糖葫芦造型
Group{
bboxCenter 0 0 0
bboxSize 5.0 5.0 5.0
children [
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.3 0.2 0.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.7 0.7 0.6#物体镜面反射光线的颜色
shininess 0.8#造型外观材料的亮度
transparency 0.2
}
}
geometry Cylinder{#
radius 0.1
height 5.0
side TRUE
topTRUE
bottom TRUE
}
}
DEF Shap1 Shape{#将球节点定义为Shap1节点名
appearance Appearance{
material Material{#空间物体造型外观顶
diffuseColor 0.8 0.2 0.2#一种材料的漫反射颜色
ambientIntensity 0.1#多少环境光被该表面反射
specularColor 0.8 0.8 0.8#物体镜面反射光线的颜色
shininess 0.15#造型外观材料的亮度
}
}
geometry Sphere{#球体
radius 0.5
}
}
#利用坐标变换节点和重用Shap1节点,重新使用定位。
Transform{#重用Shap1节点名
translation0 1 0
children USE Shap1
}
Transform{#重用Shap1节点名
translation0 2 0
children USE Shap1
}
Transform{#重用Shap1节点名
translation0-1 0
children USE Shap1
}
]
}
#VRML V2.0 utf8
#创建多个坐标系
#角度 0 30 45 60 90 120 135 150 180
#弧度 0 0.524 0.785 1.047 1.571 2.094 2.356 2.618 3.141
Background{
skyColor[
0.2 0.5 0.6
]
}
#创建警示牌造型---禁止吸烟
DEF pb Group{
bboxCenter 0 0 0
bboxSize 5.0 5.0 5.0
children [
DEF Cylind1
Transform{
translation0 2 0
rotation 1.0 0.0 0.0 1.571
children [
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 0.5 0.5 0.7#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.8 0.8 0.9#物体镜面反射光线的颜色
shininess 0.2#造型外观材料的亮度
transparency 0.0
}
}
geometry Cylinder{#警示牌
radius 1.3
height 0.1
side TRUE
topTRUE
bottom TRUE
}
}
]
}
Transform{
translation-0.6 1.4 0.2
#rotation 0.0 0.0 0.0 1.571
children[
DEF Shap1 Shape{#将球节点定义为Shap1节点名
appearance Appearance{
material Material{#空间物体造型外观顶
diffuseColor 0.8 0.2 0.2#一种材料的漫反射颜色
ambientIntensity 0.1#多少环境光被该表面反射
specularColor 0.8 0.8 0.8#物体镜面反射光线的颜色
shininess 0.15#造型外观材料的亮度
transparency 0.0
}
}
geometry Sphere{#烟头
radius 0.2
}
}
]
}
#利用坐标变换节点和重用Shap1节点,重新使用定位。
Transform{#叉杆
translation0 2 0
rotation 1 1 0 1.571
scale 0.12 0.12 20
children USE Cylind1
}
Transform{
translation0.1 2.1 0.15
rotation 0.0 0.0 1.0 2.356
children [
Shape{
appearance Appearance{
material Material{#空间物体造型外观
diffuseColor 1.0 1.0 1.0#一种材料的漫反射颜色
ambientIntensity 0.4#多少环境光被该表面反射
specularColor 0.8 0.8 0.9#物体镜面反射光线的颜色
shininess 0.2#造型外观材料的亮度
transparency 0.0
}
}
geometry Cylinder{#烟杆
radius 0.16
height 1.9
side TRUE
topTRUE
bottom TRUE
}
}
]
}
Transform{#警示牌立柱
translation0-1.1-0.2
rotation 1 0 0 1.571
scale 0.12 0.12 38
children USE Cylind1
}
Transform{#警示牌底座
translation0-3-2
rotation 1 0 0 1.571
#scale 0.12 0.12 20
children USE Cylind1
}
]
}