zoukankan      html  css  js  c++  java
  • away3d 4.0学习(6) SkyBox

    /**
    * A SkyBox class is used to render a sky in the scene. It's always considered static and 'at infinity', and as
    * such it's always centered at the camera's position and sized to exactly fit within the camera's frustum, ensuring
    * the sky box is always as large as possible without being clipped.
    */

    Skybox类用来渲染场景的天空。他永远被认为是静态的与“无限的”,得益于此,它永远是以相机的位置和尺寸为中心的圆台,保证了天空盒永远大得你无法触摸。

    以上这是Skybox类的说明信息,翻译得差,贱笑了。

    可以从SkyBox的定义看出来,Skybox主要用来渲染天空的。

    Create a new SkyBox object.

    以上是Skybox的构造器,里面需要传入一个CubeTextureBase类型的纹理,CubeTextureBase,顾名思义,基本方体纹理,天空盒是个四四方方的东西,所以需要这么特殊的一个纹理,不知道这个纹理是否可以传到Mesh创建直接创建一个方形盒子呢。

    Package away3d.textures
    Class public class CubeTextureBase
    Inheritance CubeTextureBase Inheritance TextureProxyBase Inheritance NamedAssetBase Inheritance flash.events.EventDispatcher
    Subclasses BitmapCubeTexture, RenderCubeTexture

    以上是这个纹理的继承树,他包含了两个实现类,在这里我们使用的是BitmapCubeTexture,问我为啥要用这个?因为我看到后面那个名字的时候,感觉他就挺复杂的,所以用比较熟悉的名字,当然,后续还是会检查一下他们之间的区别的。

    public function BitmapCubeTexture(posX : BitmapData, negX : BitmapData, posY : BitmapData, negY : BitmapData, posZ : BitmapData, negZ : BitmapData)

    以上是BitmapCubeTexture的构造器,里面需要传入6个BitmapData作为盒子6个面的纹理之用,pos代表正,nag代表负,这个是参考(0,0,0)的.

    额,都跑了,我也下班找老婆去。

    代码附上:

    package samples
    {
        import assets.Resource;
        
        import away3d.controllers.FirstPersonController;
        import away3d.primitives.SkyBox;
        import away3d.textures.BitmapCubeTexture;
        
        import flash.display3D.textures.CubeTexture;
        import flash.geom.Vector3D;
        
        import template.AwayTemplate;
    
        [SWF(width=1000,height=600,frameRate=30)]
        public class SkyboxTest extends AwayTemplate
        {
            private var skyBox:SkyBox;
            private var cubeTexture:BitmapCubeTexture
            public function SkyboxTest()
            {
                super();
            }
            override protected function initView():void
            {
                super.initView();
                cubeTexture = new BitmapCubeTexture(
                    new Resource.SKY_RIGHT().bitmapData,
                    new Resource.SKY_LEFT().bitmapData,
                    new Resource.SKY_TOP().bitmapData,
                    new Resource.SKY_BOTTOM().bitmapData,
                    new Resource.SKY_FRONT().bitmapData,
                    new Resource.SKY_BACK().bitmapData);
                skyBox = new SkyBox(cubeTexture);
                _view.scene.addChild(skyBox);
            }
            override protected function render():void
            {
                _view.camera.yaw(1);
                _view.camera.roll(1);
                _view.camera.pitch(1);
                super.render();
            }
        }
    }

    效果图附上:

     

  • 相关阅读:
    数据库_初学
    数据库—修改表的列
    做一个导航栏(bootstrap)
    几个比较常用的特效
    当、你想给一个目标挂上一个事件时
    图片轮播的几个小程序
    JS练习题 ( 下拉菜单;好友选中输入)
    Bootstrap 按钮和折叠插件
    Bootstrap 轮播插件
    Bootstrap 弹出框和警告框插件
  • 原文地址:https://www.cnblogs.com/adoontheway/p/2708854.html
Copyright © 2011-2022 走看看