Light: Import distance properly.
Also remove some silly default param for addlight that could make argument passing not obvious.
This commit is contained in:
@@ -2305,7 +2305,7 @@ void IrrDriver::applyObjectPassShader()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
|
||||
scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy, float radius,
|
||||
float r, float g, float b, bool sun, scene::ISceneNode* parent)
|
||||
{
|
||||
if (m_glsl)
|
||||
@@ -2314,7 +2314,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
|
||||
LightNode *light = NULL;
|
||||
|
||||
if (!sun)
|
||||
light = new LightNode(m_scene_manager, parent, energy, r, g, b);
|
||||
light = new LightNode(m_scene_manager, parent, energy, radius, r, g, b);
|
||||
else
|
||||
light = new SunNode(m_scene_manager, parent, r, g, b);
|
||||
|
||||
|
||||
@@ -563,8 +563,8 @@ public:
|
||||
void applyObjectPassShader();
|
||||
void applyObjectPassShader(scene::ISceneNode * const node, bool rimlit = false);
|
||||
// ------------------------------------------------------------------------
|
||||
scene::ISceneNode *addLight(const core::vector3df &pos, float energy = 1., float r = 1.0f,
|
||||
float g = 1.0f, float b = 1.0f, bool sun = false, scene::ISceneNode* parent = NULL);
|
||||
scene::ISceneNode *addLight(const core::vector3df &pos, float energy, float radius, float r,
|
||||
float g, float b, bool sun = false, scene::ISceneNode* parent = NULL);
|
||||
// ------------------------------------------------------------------------
|
||||
void clearLights();
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -34,10 +34,11 @@ using namespace core;
|
||||
aabbox3df LightNode::box;
|
||||
|
||||
|
||||
LightNode::LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float e, float r, float g, float b):
|
||||
LightNode::LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float e, float d, float r, float g, float b):
|
||||
ISceneNode(parent == NULL ? mgr->getRootSceneNode() : parent, mgr, -1)
|
||||
{
|
||||
m_energy = e;
|
||||
m_radius = d;
|
||||
m_energy_multiplier = 1.0f;
|
||||
m_color[0] = r;
|
||||
m_color[1] = g;
|
||||
|
||||
@@ -40,7 +40,7 @@ class LightNode: public scene::ISceneNode
|
||||
#endif
|
||||
|
||||
public:
|
||||
LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float energy, float r, float g, float b);
|
||||
LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float energy, float d, float r, float g, float b);
|
||||
virtual ~LightNode();
|
||||
|
||||
virtual void render() OVERRIDE;
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
virtual u32 getMaterialCount() const OVERRIDE { return 1; }
|
||||
virtual bool isPointLight() { return true; }
|
||||
|
||||
//float getRadius() const { return m_radius; }
|
||||
float getRadius() const { return m_radius; }
|
||||
float getEnergy() const { return m_energy; }
|
||||
float getEffectiveEnergy() const { return m_energy_multiplier * m_energy; }
|
||||
core::vector3df getColor() const { return core::vector3df(m_color[0], m_color[1], m_color[2]); }
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
protected:
|
||||
static core::aabbox3df box;
|
||||
|
||||
//float m_radius;
|
||||
float m_radius;
|
||||
float m_color[3];
|
||||
float m_energy;
|
||||
|
||||
|
||||
@@ -874,7 +874,7 @@ void IrrDriver::renderLights(scene::ICameraSceneNode * const camnode, float dt)
|
||||
PointLightsInfo[lightnum].blue = col.Z;
|
||||
|
||||
// Light radius
|
||||
PointLightsInfo[lightnum].radius = 20 * light_node->getEffectiveEnergy();
|
||||
PointLightsInfo[lightnum].radius = light_node->getRadius();
|
||||
}
|
||||
}
|
||||
if (lightnum > MAXLIGHT)
|
||||
|
||||
@@ -35,7 +35,7 @@ using namespace scene;
|
||||
using namespace core;
|
||||
|
||||
SunNode::SunNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float r, float g, float b):
|
||||
LightNode(mgr, parent, 0., r, g, b)
|
||||
LightNode(mgr, parent, 0., 0., r, g, b)
|
||||
{
|
||||
m_color[0] = r;
|
||||
m_color[1] = g;
|
||||
|
||||
@@ -302,7 +302,7 @@ void FeatureUnlockedCutScene::init()
|
||||
120, 120));
|
||||
|
||||
const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f );
|
||||
m_light = irr_driver->addLight(sun_pos, 10000.0f, 1, 1, 1);
|
||||
m_light = irr_driver->addLight(sun_pos, 10000.0f, 1., 1, 1, 1);
|
||||
#ifdef DEBUG
|
||||
m_light->setName("light");
|
||||
#endif
|
||||
|
||||
@@ -675,15 +675,15 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(const XMLNode& xml_no
|
||||
xml_node.get("color", &m_color);
|
||||
const video::SColorf colorf(m_color);
|
||||
|
||||
//m_distance = 25.0f;
|
||||
//xml_node.get("distance", &m_distance);
|
||||
|
||||
m_energy = 1.0f;
|
||||
xml_node.get("energy", &m_energy);
|
||||
|
||||
m_distance = 20. * m_energy;
|
||||
xml_node.get("distance", &m_distance);
|
||||
|
||||
if (irr_driver->isGLSL())
|
||||
{
|
||||
m_node = irr_driver->addLight(m_init_xyz, m_energy, colorf.r, colorf.g, colorf.b, false, parent);
|
||||
m_node = irr_driver->addLight(m_init_xyz, m_energy, m_distance, colorf.r, colorf.g, colorf.b, false, parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -307,7 +307,7 @@ class TrackObjectPresentationLight : public TrackObjectPresentationSceneNode
|
||||
{
|
||||
private:
|
||||
video::SColor m_color;
|
||||
//float m_distance;
|
||||
float m_distance;
|
||||
float m_energy;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user