用PHP動態產生虛擬現實VRML網頁

來源:互聯網
上載者:User

多年前本人開始從事三維動畫方面的學習,後學習了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;
?>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.