00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_LIGHT_H
00021 #define ARCHON_X3D_LIGHT_H
00022
00029 #include <archon/math/vector.H>
00030
00031 #include <archon/x3d/server/core.H>
00032 #include <archon/x3d/server/scene.H>
00033
00034 namespace Archon
00035 {
00036 namespace X3D
00037 {
00038 using namespace Math;
00039
00040
00044 struct LightNode: virtual ChildNode
00045 {
00046 static const NodeType *type;
00047
00048 double getAmbientIntensity() const { return ambientIntensity; }
00049 const Vector3 &getColor() const { return color; }
00050 double getIntensity() const { return intensity; }
00051 bool getOn() const { return on; }
00052
00053 protected:
00054 LightNode():
00055 ambientIntensity(0), color(1, 1, 1),
00056 intensity(1), on(true) {}
00057
00058 private:
00059 friend void initializeLightComponent();
00060
00061 double ambientIntensity;
00062 Vector3 color;
00063 double intensity;
00064 bool on;
00065
00066 EventSource ambientIntensityChanged;
00067 EventSource colorChanged;
00068 EventSource intensityChanged;
00069 EventSource onChanged;
00070
00071 Time ambientIntensityStamp;
00072 Time colorStamp;
00073 Time intensityStamp;
00074 Time onStamp;
00075 };
00076
00077
00081 struct DirectionalLight: LightNode
00082 {
00083 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00084 {
00085 return new DirectionalLight(c);
00086 }
00087
00088 static const NodeType *type;
00089 const NodeType *getType() const { return type; }
00090
00091 DirectionalLight(BackRef<ExecutionContext> c):
00092 NodeBase(c),
00093 direction(0, 0, -1) {}
00094
00095 const Vector3 &getDirection() const { return direction; }
00096
00097 private:
00098 friend void initializeLightComponent();
00099
00100 Vector3 direction;
00101
00102 EventSource directionChanged;
00103
00104 Time directionStamp;
00105 };
00106
00107
00111 struct PointLight: LightNode
00112 {
00113 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00114 {
00115 return new PointLight(c);
00116 }
00117
00118 static const NodeType *type;
00119 const NodeType *getType() const { return type; }
00120
00121 PointLight(BackRef<ExecutionContext> c):
00122 NodeBase(c),
00123 attenuation(1, 0, 0),
00124 location(0, 0, 0),
00125 radius(100) {}
00126
00127 const Vector3 &getAttenuation() const { return attenuation; }
00128 const Vector3 &getLocation() const { return location; }
00129 double getRadius() const { return radius; }
00130
00131 private:
00132 friend void initializeLightComponent();
00133
00134 Vector3 attenuation;
00135 Vector3 location;
00136 double radius;
00137
00138 EventSource attenuationChanged;
00139 EventSource locationChanged;
00140 EventSource radiusChanged;
00141
00142 Time attenuationStamp;
00143 Time locationStamp;
00144 Time radiusStamp;
00145 };
00146
00147
00151 struct SpotLight: LightNode
00152 {
00153 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00154 {
00155 return new SpotLight(c);
00156 }
00157
00158 static const NodeType *type;
00159 const NodeType *getType() const { return type; }
00160
00161 SpotLight(BackRef<ExecutionContext> c):
00162 NodeBase(c),
00163 attenuation(1, 0, 0),
00164 beamWidth(1.570796),
00165 cutOffAngle(0.785398),
00166 direction(0, 0, -1),
00167 location(0, 0, 0),
00168 radius(100) {}
00169
00170 const Vector3 &getAttenuation() const { return attenuation; }
00171 double getBeamWidth() const { return beamWidth; }
00172 double getCutOffAngle() const { return cutOffAngle; }
00173 const Vector3 &getDirection() const { return direction; }
00174 const Vector3 &getLocation() const { return location; }
00175 double getRadius() const { return radius; }
00176
00177 private:
00178 friend void initializeLightComponent();
00179
00180 Vector3 attenuation;
00181 double beamWidth;
00182 double cutOffAngle;
00183 Vector3 direction;
00184 Vector3 location;
00185 double radius;
00186
00187 EventSource attenuationChanged;
00188 EventSource beamWidthChanged;
00189 EventSource cutOffAngleChanged;
00190 EventSource directionChanged;
00191 EventSource locationChanged;
00192 EventSource radiusChanged;
00193
00194 Time attenuationStamp;
00195 Time beamWidthStamp;
00196 Time cutOffAngleStamp;
00197 Time directionStamp;
00198 Time locationStamp;
00199 Time radiusStamp;
00200 };
00201 }
00202 }
00203
00204 #endif // ARCHON_X3D_LIGHT_H