论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash AS教程
Tag:2.0,3.0菜鸟,游戏,,cs,技巧,源码,,文本,文字,函数,音乐,随机,拖拽,asp,access,xml,mc,视频教程

Flash as1&2中 Papervision3d 的优势

文章类别:Flash AS | 发表日期:2009-8-2 14:53:17

Flash as1&2中 Papervision3d 的优势

Papervision3d又一个AS2的3D开源引擎(现在处于beta阶段).和Sandy相比,更加简洁,使用起来也很简单.速度也很快,如果改成AS3的话,应该会非常快.

例子:
复制内容到剪贴板
代码:
/**
*使用MTASC编译,命令如下
* @mtasc -swf helloPlaneWorld.swf -main -cp src -header 600:500:40 HelloPlaneWorld.as -version 8
*/
import flash.display.BitmapData;
import org.papervision3d.*;
import org.papervision3d.objects.Plane;
class HelloPlaneWorld {
    // _______________________________________________________________________
    //                                                                  vars3D
    private static var canvas    :MovieClip;//最终显示的地方.
    private static var scene     :Papervision3D;
    private static var camera    :Camera3D;
    private static var app : HelloPlaneWorld;
    private function HelloPlaneWorld(){
        init3D();
    // _______________________________________________________________________
    //                                             循环
        _root.onEnterFrame =function()
         {
             var camera:Camera3D=HelloPlaneWorld.camera;
             var scene:Papervision3D=HelloPlaneWorld.scene;
             var canvas:MovieClip=HelloPlaneWorld.canvas;
            camera.x = -canvas._xmouse;
            camera.y = -canvas._ymouse;
             // Render
            scene.renderCamera( camera );
        }
    }
    // _______________________________________________________________________
    //                                                                  初始化
    private function init3D()
    {
        // Create canvas movieclip and center it
        canvas = _root.createEmptyMovieClip( "canvas", _root.getNextHighestDepth() );
        canvas._x = 320;
        canvas._y = 240;
        // Create scene
        scene = new Papervision3D( canvas );
        // Create camera
        camera = new Camera3D();
        // Create material
        var texture  :BitmapData =new BitmapData(400,400,false,0x00ff00);
        var material :Material3D = new Material3D( texture );
        material.oneSide = false; // Make it double sided
        // Create Planes x50
        var radius:Number = 2500;
        for( var i:Number = 0; i < 50; i++ )
        {
            var plane :Plane = new Plane( material );
            // Randomize position
            plane.x = Math.random() * radius - radius/2;
            plane.y = Math.random() * radius - radius/2;
            plane.z = Math.random() * radius - radius/2;
            // Randomize rotation
            plane.rotationX = Math.random() * 360;
            plane.rotationY = Math.random() * 360;
            plane.rotationZ = Math.random() * 360;
            // Include in scene
            scene.push( plane );
        }
    }                                                               
    static function main() {
        app = new HelloPlaneWorld();
    }
}

视频教程列表
文章教程搜索
 
Flash AS推荐教程
Flash AS热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058