<span class="unnamed3">多年前本人开始从事三维动画方面的学习,后学习了PHP,发现可以通过PHP动态生成VRML文档,有点类似于Generator动态生成Flash的方式。 <br>由于VRML博大精深,这里只介绍一个简单的例子,还可以将各种VRML结点存入数据库中,这样的虚拟现实网页将……,爽! <br>下面是源程序。注意:在服务器上,要将让PHP处理wrl格式的文档,否则后果将是没有任何虚拟现实。本源程序直接存成wrl文件,在浏览器中要安装插件,可以到我的另一个主页上去下载:http://go.163.com/~sjtucaocao/ <br><br><?php header("Content-type: application/x-vrml");$txt="#VRML V2.0 utf8 <br/><br>DEF leftBox Transform <br>{ <br>translation -5 0 0 <br>children <br>[ <br>Shape <br>{ <br>appearance Appearance <br>{ <br>material Material <br>{ <br>diffuseColor 1 0 0 <br>} <br>} <br>geometry Box{} <br>} <br>DEF SphereChild Shape <br>{ <br>appearance Appearance <br>{ <br>material Material <br>{ <br>diffuseColor 1 0 1 <br>} <br>} <br>geometry Sphere <br>{ <br>radius 1.2 <br>} <br>} <br>] <br>} <br><br>DEF rightBox Transform <br>{ <br>translation 5 0 0 <br>children <br>[ <br>Shape <br>{ <br>appearance Appearance <br>{ <br>material Material <br>{ <br>diffuseColor 0 0 1 <br>} <br>} <br>geometry Box{} <br>} <br>] <br>} <br><br>DEF onoff Transform <br>{ <br>translation 0 -1 0 <br>children <br>[ <br>Shape <br>{ <br>appearance Appearance <br>{ <br>material Material <br>{ <br>diffuseColor 0 1 0 <br>} <br>} <br>geometry Box{} <br>} <br>DEF TS TouchSensor{} <br>] <br>} <br><br>DEF S Script <br>{ <br>eventIn SFBool isActive <br>eventOut MFNode child <br>field MFNode testNode USE SphereChild <br>url <br>"javascript: <br>function isActive(value) <br>{ <br>if (value) <br>{ <br>child=testNode; <br>} <br>} <br>" <br>} <br><br>ROUTE TS.isActive TO S.isActive <br>ROUTE S.child TO leftBox.removeChildren <br>ROUTE S.child TO rightBox.addChildren";echo $txt; <br>?> <br> <br></span> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p> <p style="width:100%;text-align:center;margin:10px 0"> </p> <p class="clear"></p>