|
|
@@ -3,7 +3,6 @@
|
|
|
|
|
|
#include "anki/scene/SceneNode.h"
|
|
|
#include "anki/scene/Movable.h"
|
|
|
-#include "anki/scene/Renderable.h"
|
|
|
#include "anki/scene/Frustumable.h"
|
|
|
#include "anki/scene/Spatial.h"
|
|
|
#include "anki/resource/Material.h"
|
|
|
@@ -29,8 +28,7 @@ namespace anki {
|
|
|
/// Specular intensity of light: Sl
|
|
|
/// Specular intensity of material: Sm
|
|
|
/// @endcode
|
|
|
-class Light: public SceneNode, public Movable, public Renderable,
|
|
|
- public Spatial
|
|
|
+class Light: public SceneNode, public Movable, public Spatial
|
|
|
{
|
|
|
public:
|
|
|
enum LightType
|
|
|
@@ -56,55 +54,77 @@ public:
|
|
|
{
|
|
|
return type;
|
|
|
}
|
|
|
- /// @}
|
|
|
|
|
|
- /// @name SceneNode virtuals
|
|
|
- /// @{
|
|
|
- Movable* getMovable()
|
|
|
+ const Vec4& getColor() const
|
|
|
{
|
|
|
- return this;
|
|
|
+ return color;
|
|
|
}
|
|
|
-
|
|
|
- Renderable* getRenderable()
|
|
|
+ Vec4& getColor()
|
|
|
{
|
|
|
- return this;
|
|
|
+ return color;
|
|
|
+ }
|
|
|
+ void setColor(const Vec4& x)
|
|
|
+ {
|
|
|
+ color = x;
|
|
|
}
|
|
|
|
|
|
- Spatial* getSpatial()
|
|
|
+ const Vec4& getSpecularColor() const
|
|
|
{
|
|
|
- return this;
|
|
|
+ return specColor;
|
|
|
+ }
|
|
|
+ Vec4& getSpecularColor()
|
|
|
+ {
|
|
|
+ return specColor;
|
|
|
+ }
|
|
|
+ void setSpecularColor(const Vec4& x)
|
|
|
+ {
|
|
|
+ specColor = x;
|
|
|
}
|
|
|
|
|
|
- /// Override SceneNode::frameUpdate
|
|
|
- void frameUpdate(float prevUpdateTime, float crntTime, int frame)
|
|
|
+ bool getShadow() const
|
|
|
{
|
|
|
- SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
|
|
|
- Movable::update();
|
|
|
+ return shadow;
|
|
|
+ }
|
|
|
+ bool& getShadow()
|
|
|
+ {
|
|
|
+ return shadow;
|
|
|
+ }
|
|
|
+ void setShadow(const bool x)
|
|
|
+ {
|
|
|
+ shadow = x;
|
|
|
}
|
|
|
/// @}
|
|
|
|
|
|
- /// @name Renderable virtuals
|
|
|
+ /// @name SceneNode virtuals
|
|
|
/// @{
|
|
|
- const ModelPatchBase& getModelPatchBase() const
|
|
|
+ Movable* getMovable()
|
|
|
{
|
|
|
- ANKI_ASSERT(0 && "Lights don't support it");
|
|
|
- throw ""; // Make the compiler not to complain about return val
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
- Material& getMaterial()
|
|
|
+ Spatial* getSpatial()
|
|
|
{
|
|
|
- return *mtl;
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
Light* getLight()
|
|
|
{
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
+ /// Override SceneNode::frameUpdate
|
|
|
+ void frameUpdate(float prevUpdateTime, float crntTime, int frame)
|
|
|
+ {
|
|
|
+ SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
|
|
|
+ Movable::update();
|
|
|
+ }
|
|
|
/// @}
|
|
|
|
|
|
private:
|
|
|
LightType type;
|
|
|
- MaterialResourcePointer mtl;
|
|
|
+ Vec4 color;
|
|
|
+ Vec4 specColor;
|
|
|
+ bool shadow;
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -112,8 +132,6 @@ private:
|
|
|
class PointLight: public Light
|
|
|
{
|
|
|
public:
|
|
|
- ANKI_OBSERVING(PointLight)
|
|
|
-
|
|
|
/// @name Constructors/Destructor
|
|
|
/// @{
|
|
|
PointLight(const char* fmtl,
|
|
|
@@ -121,6 +139,22 @@ public:
|
|
|
uint movableFlags, Movable* movParent);
|
|
|
/// @}
|
|
|
|
|
|
+ /// @name Accessors
|
|
|
+ /// @{
|
|
|
+ float getRadius() const
|
|
|
+ {
|
|
|
+ return sphereL.getRadius();
|
|
|
+ }
|
|
|
+ float& getRadius()
|
|
|
+ {
|
|
|
+ return sphereL.getRadius();
|
|
|
+ }
|
|
|
+ void setRadius(const float x)
|
|
|
+ {
|
|
|
+ sphereL.setRadius(x);
|
|
|
+ }
|
|
|
+ /// @}
|
|
|
+
|
|
|
/// @name Movable virtuals
|
|
|
/// @{
|
|
|
|
|
|
@@ -136,12 +170,6 @@ public:
|
|
|
public:
|
|
|
Sphere sphereW;
|
|
|
Sphere sphereL;
|
|
|
-
|
|
|
- void updateRadius(const float& r)
|
|
|
- {
|
|
|
- sphereL.setRadius(r);
|
|
|
- }
|
|
|
- ANKI_SLOT(updateRadius, const float&)
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -158,6 +186,27 @@ public:
|
|
|
uint movableFlags, Movable* movParent);
|
|
|
/// @}
|
|
|
|
|
|
+ /// @name Accessors
|
|
|
+ /// @{
|
|
|
+ float getFov() const
|
|
|
+ {
|
|
|
+ return frustum.getFovX();
|
|
|
+ }
|
|
|
+ void setFov(float x)
|
|
|
+ {
|
|
|
+ fovProp->setValue(x);
|
|
|
+ }
|
|
|
+
|
|
|
+ float getDistance() const
|
|
|
+ {
|
|
|
+ return frustum.getFar();
|
|
|
+ }
|
|
|
+ void setDistance(float x)
|
|
|
+ {
|
|
|
+ distProp->setValue(x);
|
|
|
+ }
|
|
|
+ /// @}
|
|
|
+
|
|
|
/// @name Movable virtuals
|
|
|
/// @{
|
|
|
|
|
|
@@ -186,6 +235,8 @@ private:
|
|
|
PerspectiveFrustum frustum;
|
|
|
Mat4 projectionMat;
|
|
|
Mat4 viewMat;
|
|
|
+ ReadWriteProperty<float>* fovProp; ///< Have it here for updates
|
|
|
+ ReadWriteProperty<float>* distProp; ///< Have it here for updates
|
|
|
|
|
|
void updateZFar(const float& f)
|
|
|
{
|