_Fog

雾。保存有雾的距离和颜色等数据。 全部展开

属性展开

  • + color : uint

    雾的颜色。

    • 示例

       fog.color = _Color.Red
  • + down: number

    高度雾过度的最低点。

    • 示例

       fog.down = -50
  • + far : number

    雾到达最大浓度的距离。

    • 示例

       fog.far = 5
  • + heightColor : uint

    高度雾的颜色。

    • 示例

       fog.heightColor = _Color.Red
  • + name : string

    雾的名称。

    • 示例

       fog.name = 'fog'
  • + near: number

    开始起雾的距离。

    • 示例

       fog.near = 5
  • + up: number

    高度雾开始的高度。

    • 示例

       fog.up = 5

构造方法展开

  • + function _Fog() : _Fog

    构造一个雾

    • 示例

       fog = _Fog.new()

代码示例

    _sys:addPath('res')
    _dofile('cameracontrol.lua')
    fog = _Fog.new()
    fog.near, fog.far, fog.color = 20, 70, _Color.DarkGreen
    _rd.bgColor = fog.color
    _rd.camera.eye = _Vector3.new(50, 50, 50)
    _rd:useLight(_AmbientLight.new())
    _rd:useLight(_SkyLight.new())

    pp = _ParticlePlayer.new()
    pp:play('pfx_env_huoba.pfx', _Matrix3D.new():setTranslation(20, 0, 0))
    pp:play('pfx_env_huoba.pfx', _Matrix3D.new():setTranslation(-20, 0, 0))
    pp:play('pfx_env_huoba.pfx', _Matrix3D.new():setTranslation(0, 20, 0))
    pp:play('pfx_env_huoba.pfx', _Matrix3D.new():setTranslation(0, -20, 0))

    teapot = _mf:createTeapot()
    teapot.transform:setScaling(5, 5, 5)
    mats = {}
    mats[1] = _Matrix3D.new():setTranslation(20, 20, 0)
    mats[2] = _Matrix3D.new():setTranslation(-20, 20, 0)
    mats[3] = _Matrix3D.new():setTranslation(20, -20, 0)
    mats[4] = _Matrix3D.new():setTranslation(-20, -20, 0)

    font = _Font.new('Arial', 10)
    font.textColor = _Color.Yellow

    distance = fog.far - fog.near

    function newfog()
    fog.far = distance + fog.near
    _rd:popFog()
    _rd:useFog(fog)
    end

    _app:onKeyDown(function(key)
    if key == _System.KeyW then
    if fog.near < 100 then
    fog.near = fog.near + 2
    newfog()
    end
    elseif key == _System.KeyS then
    if fog.near > 0 then
    fog.near = fog.near - 2
    newfog()
    end
    elseif key == _System.KeyE then
    if distance < 100 then
    distance = distance + 2
    newfog()
    end
    elseif key == _System.KeyD then
    if distance > 0 then
    distance = distance - 2
    newfog()
    end
    end
    end)

    _rd:useFog(fog)

    _app:onIdle(function(e)
    font:drawText(0, 0, 'Press WS to adjust fog near')
    font:drawText(0, 14, 'Press ED to adjust fog far')
    for i = 1, 4 do
    _rd:pushMatrix3D(mats[i])
    teapot:drawMesh()
    _rd:popMatrix3D()
    end
    _rd:drawAxis(100)
    end)
问题反馈(登录才可以发表哦!)