MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
DirectionalLight.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #pragma once
6 
7 #ifndef _MGDIRECTIONAL_LIGHT_HH_
8 #define _MGDIRECTIONAL_LIGHT_HH_
9 
10 #include "mgGL/Light.h"
11 
12 class MGOfstream;
13 class MGIfstream;
14 class MGVector;
15 
20 
25 class MG_DLL_DECLR MGDirectionalLight : public MGLight{
26 
27 public:
28 
30 
33  float intensity,
34  float ambientIntensity,
35  const float color[3],
36  const MGVector& direction
37 );
38 
40 
42 MGDirectionalLight& operator=(const MGGel& gel2);
44 
46 bool operator<(const MGDirectionalLight& gel2)const;
47 bool operator<(const MGGel& gel2)const;
48 
51 
54 int exec()const;
55 
57 
58 void setDirection(const MGVector& direction);
59 void setDirection(const float direction[3]){
60  for(int i=0; i<3; i++) m_direction[i]=direction[i];
61 }
62 void setDirection(float v0, float v1, float v2){
63  m_direction[0]=v0;
64  m_direction[1]=v1;
65  m_direction[2]=v2;
66 }
67 
68 void getDirection(MGVector& direction)const;
69 void getDirection(float direction[3])const{
70  for(int i=0; i<3; i++) direction[i]=m_direction[i];
71 }
72 void getDirection(float& v0, float& v1, float& v2)const{
73  v0=m_direction[0];
74  v1=m_direction[1];
75  v2=m_direction[2];
76 }
77 
79 long identify_type() const{return MGDIRECTIONAL_LIGHT_TID;};
80 
81 std::string whoami()const{return "DirectionalLight";};
82 
84 void ReadMembers(MGIfstream& buf);
86 void WriteMembers(MGOfstream& buf)const;
87 
89 std::ostream& out(std::ostream&) const;
90 
92 
94 void transform(const MGVector& v);
95 
97 void transform(double scale);
98 
100 void transform(const MGMatrix& mat);
101 
103 void transform(const MGTransf& tr);
104 
105 private:
106 
107  float m_direction[3];
108 
109 };
110  // end of GLAttrib group
112 #endif // _MGDIRECTIONAL_LIGHT_HH_
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
void setDirection(const float direction[3])
Definition: DirectionalLight.h:59
std::string whoami() const
Definition: DirectionalLight.h:81
virtual int exec() const
virtual std::ostream & out(std::ostream &) const
Output virtual function.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
void getDirection(float direction[3]) const
Definition: DirectionalLight.h:69
virtual void WriteMembers(MGOfstream &buf) const
Write all member data.
Vector of a general n space dimension.
Definition: Vector.h:26
MGLight is an abstract base class for light sources.
Definition: Light.h:27
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
virtual void transform(const MGVector &v)
Transform the gel by the argument.
Definition: Gel.h:176
virtual void ReadMembers(MGIfstream &buf)
Read all member data.
long identify_type() const
Return This object's typeID.
Definition: DirectionalLight.h:79
virtual bool operator<(const MGLight &gel2) const
comparison
void getDirection(float &v0, float &v1, float &v2) const
Definition: DirectionalLight.h:72
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
virtual MGLight * clone() const
Generate a newed clone object.
virtual MGLight & operator=(const MGGel &gel2)
virtual ~MGLight();
void setDirection(float v0, float v1, float v2)
Definition: DirectionalLight.h:62
MGDirectionalLight is a directional light source that approximates infinite light sources as the sun...
Definition: DirectionalLight.h:25
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30