zoukankan      html  css  js  c++  java
  • away3d 4.1 环境反射总结

    在三维中,当我们的环境要反射在物体上的时候我们需要给物体添加反射贴图或开启环境反射。away3d无法自动识别周围创建物体的环境,所以物体的反射要用BitmapCubeTexture建立一个环境贴图,然后在通过EnvMapMethod类的方法添加到物体的材质上

    这里我们要用到BitmapCubeTexture

    看看BitmapCubeTexture的API

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

    简单的说就是

    BitmapCubeTexture(右:BitmapData, 左:BitmapData, 上:BitmapData, 下:BitmapData, 后:BitmapData, 前:BitmapData)

     EnvMapMethod(envMap:CubeTextureBase, alpha:Number = 1)

    this.cubeTextures = new BitmapCubeTexture(new this.EnvPosXGarage().bitmapData, 
                        new this.EnvNegXGarage().bitmapData, 
                        new this.EnvPosYGarage().bitmapData, 
                        new this.EnvNegYGarage().bitmapData, 
                        new this.EnvPosZGarage().bitmapData, 
                        new this.EnvNegZGarage().bitmapData);
                
                
    this.environmentReflectionMetrial= new EnvMapMethod(this.cubeTextures)
    
    this.sphereMetrial.addMethod(this.environmentReflectionMetrial)

    那既然环境可以反射到物体上,那物体肯定也是可以反射到环境上,比如镜子,物体可以反射到镜子上面

    away3d 为我们提供了许多方法,这些方法可以在away3d.textures下找到,例如 CubeReflectionTexture  PlanarReflectionTexture

                //反射贴图
                this.planarReflectionTexture=new PlanarReflectionTexture()
                //反射方法
                
                var planeReflectionMethod:PlanarReflectionMethod = new PlanarReflectionMethod(planarReflectionTexture);
    
                //添加反射方法到材质上
                this.sphereMatrail.addMethod(planeReflectionMethod);
          //通过矩阵反射到平面
            planarReflectionTexture.applyTransform(sphereMesh.sceneTransform);
            private function renderScene(event:Event):void
            {
                cameraLight.position = viewport.camera.position;
                viewport.render();
                planarReflectionTexture.render(viewport);
            //必须时刻更新
    this.selfController.update();
                this.orbitController.update();
            }

     如果我们单纯的把 PlanarReflectionTexture贴到球上,是实现不了的,只能部分实现反色

    效果将如下

     也就是说 先在4.1版本 有:

    PlanarReflectionTexture+PlanarReflectionMethod
    CubeReflectionTexture + 无CubeReflectionMethod  

    这是4.1新功能

    因为away3d4.1版本对CubeReflectionTexture 的环境反射没实现,所以暂时整理到这 ,如果想反射环境还是得EnvMapMethod

    等官方更新下一个版本估计就出来了

  • 相关阅读:
    Charles抓包工具
    JQuery 实现表单验证,所有验证通过方可提交
    卡巴斯基注册信息清除
    Nginx 404 Not Found 解决办法
    php mysql 多表查询之子查询语句
    搜狗拼音、QQ拼音输入法、2345拼音输入法、百度输入法 、手心输入法对比。(个人体会)
    Notepad++使用-如何导出/导入配置文件
    深蓝词库转换2.4版发布,支持最新的搜狗用户词库备份bin格式
    网站更换服务器,百度站长后台抓取诊断时间
    阿里云代金券领取
  • 原文地址:https://www.cnblogs.com/bulolo/p/2820901.html
Copyright © 2011-2022 走看看