00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef POINT_LIHGT_H_
00026 #define POINT_LIHGT_H_
00027
00028 #include <Graphics/Light/LocalLight.h>
00029
00030 namespace Lamp{
00031
00032
00033
00034
00035
00036 class PointLight : public LocalLight{
00037 friend class LightManager;
00038 public:
00039
00040
00041
00042
00043
00044
00045 virtual SceneLeaf* copy(u_int copyMask = 0) const{
00046 return copyPointLight();
00047 }
00048
00049
00050
00051
00052
00053 virtual Light* copyLight() const{ return copyPointLight(); }
00054
00055
00056
00057
00058
00059 virtual PointLight* copyPointLight() const;
00060
00061
00062
00063
00064
00065
00066 virtual void setColor(const Color3f& color){
00067 diffuseColor_ = specularColor_ = color;
00068 }
00069
00070
00071
00072
00073
00074 virtual Color3f getColor() const{
00075 Color3f result(Math::maximum(diffuseColor_.r, specularColor_.r),
00076 Math::maximum(diffuseColor_.g, specularColor_.g),
00077 Math::maximum(diffuseColor_.b, specularColor_.b));
00078 return result;
00079 }
00080
00081
00082
00083
00084
00085
00086 virtual void setDiffuseColor(const Color3f& color){ diffuseColor_ = color; }
00087
00088
00089
00090
00091
00092 virtual const Color3f& getDiffuseColor() const{ return diffuseColor_; }
00093
00094
00095
00096
00097
00098
00099 virtual void setSpecularColor(const Color3f& color){
00100 specularColor_ = color;
00101 }
00102
00103
00104
00105
00106
00107 virtual const Color3f& getSpecularColor() const{ return specularColor_; }
00108
00109
00110
00111
00112
00113
00114 virtual void setPosition(const Vector3& position){ position_ = position; }
00115
00116
00117
00118
00119
00120 virtual const Vector3& getPosition() const{ return position_; }
00121
00122
00123
00124
00125
00126 virtual const Vector3& getWorldPosition() const{
00127 Assert(getParent() != NULL);
00128 return worldPosition_;
00129 }
00130
00131
00132
00133
00134
00135
00136 virtual void setRange(float range){ range_ = range; }
00137
00138
00139
00140
00141
00142 virtual float getRange() const{ return range_; }
00143
00144
00145
00146
00147
00148 virtual float getGlobalRange() const{ return globalRange_; }
00149
00150
00151
00152
00153
00154
00155
00156
00157 virtual void setAttenuation(
00158 float attenuation0, float attenuation1, float attenuation2){
00159 attenuation0_ = attenuation0;
00160 attenuation1_ = attenuation1;
00161 attenuation2_ = attenuation2;
00162 }
00163
00164
00165
00166
00167
00168
00169 virtual void setAttenuation0(float attenuation0){
00170 attenuation0_ = attenuation0;
00171 }
00172
00173
00174
00175
00176
00177 virtual float getAttenuation0() const{ return attenuation0_; }
00178
00179
00180
00181
00182
00183
00184 virtual void setAttenuation1(float attenuation1){
00185 attenuation1_ = attenuation1;
00186 }
00187
00188
00189
00190
00191
00192 virtual float getAttenuation1() const{ return attenuation1_; }
00193
00194
00195
00196
00197
00198
00199 virtual void setAttenuation2(float attenuation2){
00200 attenuation2_ = attenuation2;
00201 }
00202
00203
00204
00205
00206
00207 virtual float getAttenuation2() const{ return attenuation2_; }
00208
00209
00210
00211
00212
00213
00214 virtual void setSquaredCameraDistance(float squaredCameraDistance){
00215 squaredCameraDistance_ = squaredCameraDistance;
00216 }
00217
00218
00219
00220
00221
00222 virtual float getSquaredCameraDistance() const{
00223 return squaredCameraDistance_;
00224 }
00225
00226
00227
00228
00229
00230
00231 virtual bool isPointLight() const{ return true; }
00232
00233 protected:
00234
00235
00236
00237
00238
00239
00240 PointLight(const String& name, Scene* scene);
00241
00242
00243
00244
00245 virtual ~PointLight();
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 virtual void traverse(const Matrix34& parentMatrix, bool parentEnabled,
00256 bool parentScaled, bool parentChanged);
00257
00258
00259 private:
00260
00261 Color3f diffuseColor_;
00262
00263 Color3f specularColor_;
00264
00265 Vector3 position_;
00266
00267 Vector3 worldPosition_;
00268
00269 float range_;
00270
00271 float globalRange_;
00272
00273 float attenuation0_;
00274
00275 float attenuation1_;
00276
00277 float attenuation2_;
00278
00279 float squaredCameraDistance_;
00280
00281 };
00282
00283
00284 }
00285 #endif // End of POINT_LIHGT_H_
00286
00287