多年前本人开始从事三维动画方面的学习,后学习了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;
?>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器