FineKernelToolKit  2.9.0
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義 ページ
Material.h
説明を見る。
1 /****************************************************************************
2  *
3  * Copyright (c) 1999-2014, Fine Kernel Project, All rights reserved.
4  *
5  * Redistribution and use in source and binary forms,
6  * with or without modification, are permitted provided that the
7  * following conditions are met:
8  *
9  * - Redistributions of source code must retain the above
10  * copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * - Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the
15  * following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * - Neither the name of the copyright holders nor the names
19  * of its contributors may be used to endorse or promote
20  * products derived from this software without specific
21  * prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  ****************************************************************************/
37 /****************************************************************************
38  *
39  * Copyright (c) 1999-2014, Fine Kernel Project, All rights reserved.
40  *
41  * 本ソフトウェアおよびソースコードのライセンスは、基本的に
42  * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
43  *
44  * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
45  * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
46  *
47  * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
48  * および下記免責条項を含めること。
49  *
50  * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
51  * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
52  * 含めること。
53  *
54  * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
55  * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
56  * コントリビューターの名前を使用してはならない。
57  *
58  * 本ソフトウェアは、著作権者およびコントリビューターによって「現
59  * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
60  * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
61  * に限定されない、いかなる保証もないものとします。著作権者もコン
62  * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
63  * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
64  * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
65  * 能性を知らされていたとしても、本ソフトウェアの使用によって発生
66  * した(代替品または代用サービスの調達、使用の喪失、データの喪失、
67  * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
68  * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
69  * ついて、一切責任を負わないものとします。
70  *
71  ****************************************************************************/
72 #ifndef __FK_MATERIAL_HEADER__
73 #define __FK_MATERIAL_HEADER__
74 
75 #include <FK/Base.h>
76 
77 const float FK_COLOR_EPS = 0.0001f;
78 
80 
92 class fk_Color : public fk_BaseObject {
93  public:
94 
96 
100  float col[4];
101 
103 
111  fk_Color(float r = 0.2f, float g = 0.2f, float b = 0.2f);
112 
114 
121  fk_Color(double r, double g, double b);
122 
124  virtual ~fk_Color() {}
125 
127 
132  friend bool operator ==(fk_Color left, fk_Color right);
133 
135  fk_Color(const fk_Color &col);
136 
138  fk_Color & operator =(const fk_Color &col);
139 
141 
144  void init(void);
145 
147 
155  void init(float r, float g, float b, float a = 1.0f);
156 
158 
166  void init(double r, double g, double b, double a = 1.0);
167 
169 
177  void set(float r, float g, float b, float a = 1.0f);
178 
180 
188  void set(double r, double g, double b, double a = 1.0);
189 
191 
200  void setHSV(double h, double s, double v);
201 
203 
206  void setR(float r);
207 
209 
212  void setG(float g);
213 
215 
218  void setB(float b);
219 
221 
224  void setA(float a);
225 
227 
230  void setR(double r);
231 
233 
236  void setG(double g);
237 
239 
242  void setB(double b);
243 
245 
248  void setA(double a);
249 
251 
254  float getR(void) const;
255 
257 
260  float getG(void) const;
261 
263 
266  float getB(void) const;
267 
269 
272  float getA(void) const;
273 };
274 
276 
311 class fk_Material : public fk_BaseObject {
312 
313  private:
314  float alpha;
315  fk_Color ambient;
316  fk_Color diffuse;
317  fk_Color emission;
318  fk_Color specular;
319  float shininess;
320 
321  public:
322 
324  fk_Material();
325 
327  virtual ~fk_Material() {}
328 
330 
335  friend int operator==(fk_Material left, fk_Material right);
336 
338  fk_Material(const fk_Material &arg);
339 
341  fk_Material & operator =(const fk_Material &arg);
342 
344 
347  void init(void);
348 
350 
351 
366  void setAlpha(float a);
367 
369 
383  void setAlpha(double a);
384 
386 
391  void setAmbient(fk_Color c);
392 
394 
404  void setAmbient(float r, float g, float b);
405 
407 
417  void setAmbient(double r, double g, double b);
418 
420 
425  void setDiffuse(fk_Color c);
426 
428 
438  void setDiffuse(float r, float g, float b);
439 
441 
451  void setDiffuse(double r, double g, double b);
452 
454 
459  void setSpecular(fk_Color c);
460 
462 
472  void setSpecular(float r, float g, float b);
473 
475 
485  void setSpecular(double r, double g, double b);
486 
488 
493  void setEmission(fk_Color c);
494 
496 
506  void setEmission(float r, float g, float b);
507 
509 
519  void setEmission(double r, double g, double b);
520 
522 
527  void setShininess(float s);
528 
530 
535  void setShininess(double s);
536 
538 
543  void setAmbDiff(fk_Color c);
544 
546 
556  void setAmbDiff(float r, float g, float b);
557 
559 
569  void setAmbDiff(double r, double g, double b);
571 
573 
574 
576 
581  float getAlpha(void);
582 
584 
593  fk_Color * getAmbient(void);
594 
596 
605  fk_Color * getDiffuse(void);
606 
608 
617  fk_Color * getSpecular(void);
618 
620 
629  fk_Color * getEmission(void);
630 
632 
637  float getShininess(void);
639 
641 
651  static void initDefault(void);
652 
653 #ifndef FK_DOXYGEN_USER_PROCESS
654 
655  void Print(int, std::string = "");
656 
657 #endif
658 
659 };
660 
661 #endif // __FK_MATERIAL_HEADER__
virtual ~fk_Material()
デストラクタ
Definition: Material.h:327
void setA(float a)
A要素設定関数
friend bool operator==(fk_Color left, fk_Color right)
比較等号演算子
void set(float r, float g, float b, float a=1.0f)
設定関数1
void setB(float b)
B要素設定関数
void setHSV(double h, double s, double v)
HSV変換関数
fk_Color & operator=(const fk_Color &col)
代入演算子
RGB色を管理するクラス
Definition: Material.h:92
fk_Color(float r=0.2f, float g=0.2f, float b=0.2f)
コンストラクタ1
void setAmbient(fk_Color c)
環境反射係数設定関数1
void init(void)
初期化関数
float getG(void) const
G要素参照関数
fk_Color * getDiffuse(void)
拡散反射係数参照関数
friend int operator==(fk_Material left, fk_Material right)
比較等号演算子
float getB(void) const
B要素参照関数
void setEmission(fk_Color c)
放射光係数設定関数1
float col[4]
色要素配列
Definition: Material.h:100
void setG(float g)
G要素設定関数
FK の各クラスの基盤となる基本クラス
Definition: Base.h:212
void setSpecular(fk_Color c)
鏡面反射設定関数1
マテリアル(質感)を管理するクラス
Definition: Material.h:311
void setAmbDiff(fk_Color c)
環境反射・拡散反射同時設定関数1
fk_Material & operator=(const fk_Material &arg)
代入演算子
void setShininess(float s)
鏡面反射ハイライト設定関数1
fk_Color * getAmbient(void)
環境反射係数参照関数
const float FK_COLOR_EPS
Definition: Material.h:77
float getShininess(void)
鏡面反射ハイライト参照関数
virtual ~fk_Color()
デストラクタ
Definition: Material.h:124
void setAlpha(float a)
透明度設定関数1
float getAlpha(void)
透明度参照関数
fk_Color * getSpecular(void)
鏡面反射係数参照関数
void init(void)
初期化関数1
fk_Color * getEmission(void)
放射光係数参照関数
fk_Material()
コンストラクタ
static void initDefault(void)
デフォルトマテリアル初期化関数
void setR(float r)
R要素設定関数
float getR(void) const
R要素参照関数
float getA(void) const
A要素参照関数
void setDiffuse(fk_Color c)
拡散反射係数設定関数1