用PHP动态生成虚拟现实VRML网页
程序员文章站
2022-09-08 17:52:57
多年前本人开始从事三维动画方面的学习,后学习了php,发现可以通过php动态生成vrml文档,有点类似于generator动态生成flash的方式。 由于vrml博大精深,...
多年前本人开始从事三维动画方面的学习,后学习了php,发现可以通过php动态生成vrml文档,有点类似于generator动态生成flash的方式。
由于vrml博大精深,这里只介绍一个简单的例子,还可以将各种vrml结点存入数据库中,这样的虚拟现实网页将……,爽!
下面是源程序。注意:在服务器上,要将让php处理wrl格式的文档,否则后果将是没有任何虚拟现实。本源程序直接存成wrl文件,在浏览器中要安装插件,可以到我的另一个主页上去下载:http://go.163.com/~sjtucaocao/
<?php header("content-type: application/x-vrml");$txt="#vrml v2.0 utf8
def leftbox transform
{
translation -5 0 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 1 0 0
}
}
geometry box{}
}
def spherechild shape
{
appearance appearance
{
material material
{
diffusecolor 1 0 1
}
}
geometry sphere
{
radius 1.2
}
}
]
}
def rightbox transform
{
translation 5 0 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 0 0 1
}
}
geometry box{}
}
]
}
def onoff transform
{
translation 0 -1 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 0 1 0
}
}
geometry box{}
}
def ts touchsensor{}
]
}
def s script
{
eventin sfbool isactive
eventout mfnode child
field mfnode testnode use spherechild
url
"javascript:
function isactive(value)
{
if (value)
{
child=testnode;
}
}
"
}
route ts.isactive to s.isactive
route s.child to leftbox.removechildren
route s.child to rightbox.addchildren";echo $txt;
?>
由于vrml博大精深,这里只介绍一个简单的例子,还可以将各种vrml结点存入数据库中,这样的虚拟现实网页将……,爽!
下面是源程序。注意:在服务器上,要将让php处理wrl格式的文档,否则后果将是没有任何虚拟现实。本源程序直接存成wrl文件,在浏览器中要安装插件,可以到我的另一个主页上去下载:http://go.163.com/~sjtucaocao/
<?php header("content-type: application/x-vrml");$txt="#vrml v2.0 utf8
def leftbox transform
{
translation -5 0 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 1 0 0
}
}
geometry box{}
}
def spherechild shape
{
appearance appearance
{
material material
{
diffusecolor 1 0 1
}
}
geometry sphere
{
radius 1.2
}
}
]
}
def rightbox transform
{
translation 5 0 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 0 0 1
}
}
geometry box{}
}
]
}
def onoff transform
{
translation 0 -1 0
children
[
shape
{
appearance appearance
{
material material
{
diffusecolor 0 1 0
}
}
geometry box{}
}
def ts touchsensor{}
]
}
def s script
{
eventin sfbool isactive
eventout mfnode child
field mfnode testnode use spherechild
url
"javascript:
function isactive(value)
{
if (value)
{
child=testnode;
}
}
"
}
route ts.isactive to s.isactive
route s.child to leftbox.removechildren
route s.child to rightbox.addchildren";echo $txt;
?>
上一篇: 猫的食堂不见了
下一篇: 使用htaccess规范化网址的配置