FineKernelToolKit  2.8.10
FK/Material.h
説明を見る。
00001 /****************************************************************************
00002  *
00003  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00004  *
00005  *  Redistribution and use in source and binary forms,
00006  *  with or without modification, are permitted provided that the
00007  *  following conditions are met:
00008  *
00009  *      - Redistributions of source code must retain the above
00010  *          copyright notice, this list of conditions and the
00011  *          following disclaimer.
00012  *
00013  *      - Redistributions in binary form must reproduce the above
00014  *          copyright notice, this list of conditions and the
00015  *          following disclaimer in the documentation and/or
00016  *          other materials provided with the distribution.
00017  *
00018  *      - Neither the name of the copyright holders nor the names
00019  *          of its contributors may be used to endorse or promote
00020  *          products derived from this software without specific
00021  *          prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00031  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00032  *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00033  *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE. 
00035  *
00036  ****************************************************************************/
00037 /****************************************************************************
00038  *
00039  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00040  *
00041  *  本ソフトウェアおよびソースコードのライセンスは、基本的に
00042  *  「修正 BSD ライセンス」に従います。以下にその詳細を記します。
00043  *
00044  *  ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
00045  *  以下の条件を満たす場合に限り、再頒布および使用が許可されます。
00046  *
00047  *  - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
00048  *      および下記免責条項を含めること。
00049  *
00050  *  - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
00051  *      資料に、上記の著作権表示、本条件一覧、および下記免責条項を
00052  *      含めること。
00053  *
00054  *  - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
00055  *      宣伝または販売促進に、本ソフトウェアの著作権者の名前または
00056  *      コントリビューターの名前を使用してはならない。
00057  *
00058  *  本ソフトウェアは、著作権者およびコントリビューターによって「現
00059  *  状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
00060  *  および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
00061  *  に限定されない、いかなる保証もないものとします。著作権者もコン
00062  *  トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
00063  *  問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
00064  *  他の)不法行為であるかを問わず、仮にそのような損害が発生する可
00065  *  能性を知らされていたとしても、本ソフトウェアの使用によって発生
00066  *  した(代替品または代用サービスの調達、使用の喪失、データの喪失、
00067  *  利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
00068  *  間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
00069  *  ついて、一切責任を負わないものとします。
00070  *
00071  ****************************************************************************/
00072 #ifndef __FK_MATERIAL_HEADER__
00073 #define __FK_MATERIAL_HEADER__
00074 
00075 #include <FK/Base.h>
00076 
00077 const float FK_COLOR_EPS = 0.0001f;
00078 
00080 
00092 class fk_Color : public fk_BaseObject {
00093  public:
00094 
00096 
00100     float col[4];
00101 
00103 
00111     fk_Color(float r = 0.2f, float g = 0.2f, float b = 0.2f);
00112 
00114 
00121     fk_Color(double r, double g, double b);
00122 
00124     virtual ~fk_Color() {}
00125 
00127 
00132     friend bool operator ==(fk_Color left, fk_Color right);
00133 
00135     fk_Color(const fk_Color &col);
00136 
00138     fk_Color & operator =(const fk_Color &col);
00139 
00141 
00144     void        init(void);
00145 
00147 
00155     void        init(float r, float g, float b, float a = 1.0f);
00156 
00158 
00166     void        init(double r, double g, double b, double a = 1.0);
00167 
00169 
00177     void        set(float r, float g, float b, float a = 1.0f);
00178 
00180 
00188     void        set(double r, double g, double b, double a = 1.0);
00189 
00191 
00194     void        setR(float r);
00195 
00197 
00200     void        setG(float g);
00201 
00203 
00206     void        setB(float b);
00207 
00209 
00212     void        setA(float a);
00213 
00215 
00218     void        setR(double r);
00219 
00221 
00224     void        setG(double g);
00225 
00227 
00230     void        setB(double b);
00231 
00233 
00236     void        setA(double a);
00237 
00239 
00242     float       getR(void) const;
00243 
00245 
00248     float       getG(void) const;
00249 
00251 
00254     float       getB(void) const;
00255 
00257 
00260     float       getA(void) const;
00261 };
00262 
00264 
00299 class fk_Material : public fk_BaseObject {
00300 
00301  private:
00302     float       alpha;
00303     fk_Color    ambient;
00304     fk_Color    diffuse;
00305     fk_Color    emission;
00306     fk_Color    specular;
00307     float       shininess;
00308 
00309  public:
00310 
00312     fk_Material();
00313 
00315     virtual ~fk_Material() {}
00316 
00318 
00323     friend int operator==(fk_Material left, fk_Material right);
00324 
00326     fk_Material(const fk_Material &arg);
00327 
00329     fk_Material & operator =(const fk_Material &arg);
00330 
00332 
00335     void        init(void);
00336 
00338     //@(
00340 
00354     void        setAlpha(float a);
00355 
00357 
00371     void        setAlpha(double a);
00372 
00374 
00379     void        setAmbient(fk_Color c);
00380 
00382 
00392     void        setAmbient(float r, float g, float b);
00393 
00395 
00405     void        setAmbient(double r, double g, double b);
00406 
00408 
00413     void        setDiffuse(fk_Color c);
00414 
00416 
00426     void        setDiffuse(float r, float g, float b);
00427 
00429 
00439     void        setDiffuse(double r, double g, double b);
00440 
00442 
00447     void        setSpecular(fk_Color c);
00448 
00450 
00460     void        setSpecular(float r, float g, float b);
00461 
00463 
00473     void        setSpecular(double r, double g, double b);
00474 
00476 
00481     void        setEmission(fk_Color c);
00482 
00484 
00494     void        setEmission(float r, float g, float b);
00495 
00497 
00507     void        setEmission(double r, double g, double b);
00508 
00510 
00515     void        setShininess(float s);
00516 
00518 
00523     void        setShininess(double s);
00524 
00526 
00531     void        setAmbDiff(fk_Color c);
00532 
00534 
00544     void        setAmbDiff(float r, float g, float b);
00545 
00547 
00557     void        setAmbDiff(double r, double g, double b);
00558     //@)
00559 
00561     //@(
00562 
00564 
00569     float       getAlpha(void);
00570 
00572 
00581     fk_Color *  getAmbient(void);
00582 
00584 
00593     fk_Color *  getDiffuse(void);
00594 
00596 
00605     fk_Color *  getSpecular(void);
00606 
00608 
00617     fk_Color *  getEmission(void);
00618 
00620 
00625     float       getShininess(void);
00626     //@)
00627 
00629 
00639     static void initDefault(void);
00640 
00641 #ifndef FK_DOXYGEN_USER_PROCESS
00642 
00643     void        Print(int, std::string = "");
00644 
00645 #endif
00646 
00647 };
00648 
00649 #endif // __FK_MATERIAL_HEADER__
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義