MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
PointLight.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #pragma once
6 
7 #ifndef _MGPOINTLIGHT_HH_
8 #define _MGPOINTLIGHT_HH_
9 
10 #include "mgGL/Light.h"
11 
12 class MGOfstream;
13 class MGIfstream;
14 class MGPosition;
15 
20 
24 class MG_DLL_DECLR MGPointLight:public MGLight{
25 
26 public:
27 
29 
30 MGPointLight();
32  float intensity,
33  float ambientIntensity,
34  const float color[3],
35  const MGPosition& location,
36  float radius,
37  const float attenuation[3]
38 );
41 
43 
45 MGPointLight& operator=(const MGGel& gel2);
46 MGPointLight& operator=(const MGPointLight& gel2);
47 
49 bool operator<(const MGPointLight& gel2)const;
50 bool operator<(const MGGel& gel2)const;
51 
53 virtual MGPointLight* clone()const;
54 
56 
57 void setLocation(const MGPosition& location);
58 void setLocation(const float location[3]){
59  for(int i=0; i<3; i++) m_location[i]=location[i];
60 }
61 void setLocation(float x, float y, float z){
62  m_location[0]=x;
63  m_location[1]=y;
64  m_location[2]=z;
65 }
66 void getLocation(MGPosition& location)const;
67 void getLocation(float location[3])const{
68  for(int i=0; i<3; i++) location[i]=m_location[i];
69 }
70 void getLocation(float& x, float& y, float& z)const{
71  x=m_location[0];
72  y=m_location[1];
73  z=m_location[2];
74 }
75 
76 void setRadius(float radius){m_radius=radius;};
77 float getRadius()const{return m_radius;};
78 
79 void setAttenuation(const float attenuation[3]){
80  for(int i=0; i<3; i++) m_attenuation[i]=attenuation[i];
81 }
82 void setAttenuation(float const_att, float linear_att, float quadratic_att){
83  m_attenuation[0]=const_att;
84  m_attenuation[1]=linear_att;
85  m_attenuation[2]=quadratic_att;
86 }
87 void getAttenuation(float attenuation[3])const{
88  for(int i=0; i<3; i++) attenuation[i]=m_attenuation[i];
89 }
90 void getAttenuation(float& const_att, float& linear_att, float& quadratic_att)const{
91  const_att=m_attenuation[0];
92  linear_att=m_attenuation[1];
93  quadratic_att=m_attenuation[2];
94 }
95 
98 virtual int exec()const;
99 
101 long identify_type() const{return MGPOINT_LIGHT_TID;};
102 
103 std::string whoami()const{return "PointLight";};
104 
106 virtual void ReadMembers(MGIfstream& buf);
108 virtual void WriteMembers(MGOfstream& buf)const;
109 
111 virtual std::ostream& out(std::ostream&) const;
112 
114 
116 virtual void transform(const MGVector& v);
117 
119 virtual void transform(double scale);
120 
122 virtual void transform(const MGMatrix& mat);
123 
125 virtual void transform(const MGTransf& tr);
126 
127 private:
128 
129  float m_location[4];
130  float m_radius;
131  float m_attenuation[3];
132 
135 };
136  // end of GLAttrib group
138 #endif // _MGPOINTLIGHT_HH_
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
MGPointLight is a point light source that radiates equally in all directions.
Definition: PointLight.h:24
void getLocation(float location[3]) const
Definition: PointLight.h:67
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 setRadius(float radius)
Definition: PointLight.h:76
void getAttenuation(float &const_att, float &linear_att, float &quadratic_att) const
Definition: PointLight.h:90
virtual void WriteMembers(MGOfstream &buf) const
Write all member data.
void setAttenuation(float const_att, float linear_att, float quadratic_att)
Definition: PointLight.h:82
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
void setLocation(float x, float y, float z)
Definition: PointLight.h:61
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.
Represent a positional data.
Definition: Position.h:28
virtual bool operator<(const MGLight &gel2) const
comparison
void getAttenuation(float attenuation[3]) const
Definition: PointLight.h:87
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.
void getLocation(float &x, float &y, float &z) const
Definition: PointLight.h:70
void setLocation(const float location[3])
Definition: PointLight.h:58
virtual MGLight & operator=(const MGGel &gel2)
virtual ~MGLight();
long identify_type() const
Return This object's typeID.
Definition: PointLight.h:101
void setAttenuation(const float attenuation[3])
Definition: PointLight.h:79
std::string whoami() const
Definition: PointLight.h:103
float getRadius() const
Definition: PointLight.h:77
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30