用PHP動態(tài)生成虛擬現(xiàn)實(shí)VRML網(wǎng)頁
更新時(shí)間:2006年10月09日 00:00:00 作者:
多年前本人開始從事三維動畫方面的學(xué)習(xí),后學(xué)習(xí)了PHP,發(fā)現(xiàn)可以通過PHP動態(tài)生成VRML文檔,有點(diǎn)類似于Generator動態(tài)生成Flash的方式。
由于VRML博大精深,這里只介紹一個(gè)簡單的例子,還可以將各種VRML結(jié)點(diǎn)存入數(shù)據(jù)庫中,這樣的虛擬現(xiàn)實(shí)網(wǎng)頁將……,爽!
下面是源程序。注意:在服務(wù)器上,要將讓PHP處理wrl格式的文檔,否則后果將是沒有任何虛擬現(xiàn)實(shí)。本源程序直接存成wrl文件,在瀏覽器中要安裝插件,可以到我的另一個(gè)主頁上去下載: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博大精深,這里只介紹一個(gè)簡單的例子,還可以將各種VRML結(jié)點(diǎn)存入數(shù)據(jù)庫中,這樣的虛擬現(xiàn)實(shí)網(wǎng)頁將……,爽!
下面是源程序。注意:在服務(wù)器上,要將讓PHP處理wrl格式的文檔,否則后果將是沒有任何虛擬現(xiàn)實(shí)。本源程序直接存成wrl文件,在瀏覽器中要安裝插件,可以到我的另一個(gè)主頁上去下載: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;
?>
相關(guān)文章
PHP 第二節(jié) 數(shù)據(jù)類型之?dāng)?shù)值型
編程語言的兩大功能是數(shù)據(jù)處理和流程控制;數(shù)據(jù)處理的基礎(chǔ)是數(shù)據(jù)類型和數(shù)據(jù)接口;流程控制是各種控制語句;程序的組織協(xié)調(diào)是各種編程范式;這一節(jié)先看下PHP有哪些基本的數(shù)據(jù)類型2012-04-04新手學(xué)PHP之?dāng)?shù)據(jù)庫操作詳解及亂碼解決!
這篇文章主要介紹了新手學(xué)PHP之?dāng)?shù)據(jù)庫操作詳解及亂碼解決!2007-01-01BS結(jié)構(gòu)中使用PHP訪問ORACLE LOB
這篇文章主要介紹了BS結(jié)構(gòu)中使用PHP訪問ORACLE LOB2006-10-10