Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Fog.cpp

Go to the documentation of this file.

    00001 //------------------------------------------------------------------------------
    00002 // Lamp : Open source game middleware
    00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
    00004 //
    00005 // This library is free software; you can redistribute it and/or
    00006 // modify it under the terms of the GNU Lesser General Public
    00007 // License as published by the Free Software Foundation; either
    00008 // version 2.1 of the License, or (at your option) any later version.
    00009 //
    00010 // This library is distributed in the hope that it will be useful,
    00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013 // Lesser General Public License for more details.
    00014 //
    00015 // You should have received a copy of the GNU Lesser General Public
    00016 // License along with this library; if not, write to the Free Software
    00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 //------------------------------------------------------------------------------
    00019
    00020 /** @file
    00021  * フォグ実装
    00022  * @author Junpee
    00023  */
    00024
    00025 #include "LampBasic.h"
    00026 #include "Graphics/Fog/Fog.h"
    00027
    00028 namespace Lamp{
    00029
    00030 // リミット値
    00031 const float Fog::limitValue = 10000.f;// 微妙
    00032
    00033 // 指数ドロップオフリミット係数
    00034 const float Fog::exponentLimit = Math::log(64.f);// 256/4
    00035
    00036 // 二乗の指数ドロップオフリミット係数
    00037 const float Fog::exponent2Limit = Math::sqrt(Math::log(64.f));// 256/4
    00038
    00039 //------------------------------------------------------------------------------
    00040 // コンストラクタ
    00041 Fog::Fog() : color_(128, 128, 128, 0), mode_(modeLinear),
    00042     density_(0.5f), fogNear_(1.f), fogFar_(limitValue), enabled_(false){
    00043 }
    00044 //------------------------------------------------------------------------------
    00045 // デストラクタ
    00046 Fog::~Fog(){
    00047 }
    00048 //------------------------------------------------------------------------------
    00049 // 限界値の取得
    00050 float Fog::getLimit(){
    00051     if(enabled_){
    00052         if(mode_ == modeLinear){
    00053             return fogFar_;
    00054         }else if(mode_ == modeExponent){
    00055             return (exponentLimit / density_);
    00056         }else if(mode_ == modeExponent2){
    00057             return (exponent2Limit / density_);
    00058         }
    00059     }
    00060     return limitValue;
    00061 }
    00062 //------------------------------------------------------------------------------
    00063 } // End of namespace Lamp
    00064 //------------------------------------------------------------------------------