Casting shadows in PV3D

 

偶然发现一个外国人写的基于PV3D的阴影投射类——Papervision Shadow Casting。除了效率比较低(这是PV3D的通病了,和这个类没任何关系 - -!),还算是比较强了。

 

先不多说,我们先看看如何使用。

 

首先,我们需要光源

 

Code

 

然后创建一个DisplayObject3D,例子里用了DAE

 

Code

 

为了加强光影效果,这里做一个小小的Hack。我们复制多一个3D对象,然后给他一个FlatShadeMaterial材质(或者GouraudMaterial材质),让3D对象能够“反光”

 

Code

 

添加一个平面,用于呈现投影。注意:这个平面的材质必须是MovieMaterial类或其子类。

 

Code

 

然后主角登场了,我们看看如何使用这个ShadowCaster类。只有两行代码,很简单。

 

Code

 

参数: 

  • uid : String - a unique identifier that tells the shadowCaster what layer to draw on. It will create this layer in your MovieMaterial on its first cast.
  • color : uint - Color of the shadow
  • blend : String - BlendMode to use. Defaults to Multiply for nice shading.
  • alpha: alpha of the shadow
  • filters: an array of filters to apply to the shadow. If you pass null a default BlurFilter will be used.

     

    最后,监听Event.ENTER_FRAME

     

    Code

     

    Preview:http://niuniuzhu.cn/p/3DRenderDemo/index.html?p=4

     

    Hope you enjoy it!

  • posted @ 2008-08-11 11:23  牛牛猪  阅读(2631)  评论(0编辑  收藏  举报