Fixed lighting issues (was caused by having two sets of ambient light : the scene one, and the sun one. Only one ambient light is needed.)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4164 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8e1ee567b5
commit
29355419e5
@ -143,7 +143,7 @@ void Track::cleanup()
|
|||||||
}
|
}
|
||||||
m_physical_objects.clear();
|
m_physical_objects.clear();
|
||||||
|
|
||||||
irr_driver->removeNode(m_light);
|
irr_driver->removeNode(m_sun);
|
||||||
|
|
||||||
delete m_non_collision_mesh;
|
delete m_non_collision_mesh;
|
||||||
m_non_collision_mesh = new TriangleMesh();
|
m_non_collision_mesh = new TriangleMesh();
|
||||||
@ -188,11 +188,12 @@ void Track::loadTrackInfo(const std::string &filename)
|
|||||||
m_fog_start = 0.0f;
|
m_fog_start = 0.0f;
|
||||||
m_fog_end = 1000.0f;
|
m_fog_end = 1000.0f;
|
||||||
m_gravity = 9.80665f;
|
m_gravity = 9.80665f;
|
||||||
m_fog_color = video::SColor( 77, 179, 230, 255);
|
/* ARGB */
|
||||||
|
m_fog_color = video::SColor(255, 77, 179, 230);
|
||||||
m_default_ambient_color = video::SColor(255, 120, 120, 120);
|
m_default_ambient_color = video::SColor(255, 120, 120, 120);
|
||||||
m_sun_ambient_color = video::SColor(255, 120, 120, 120);
|
//m_sun_ambient_color = video::SColor(255, 255, 255, 255);
|
||||||
m_sun_specular_color = video::SColor(255, 255, 255, 255);
|
m_sun_specular_color = video::SColor(255, 255, 255, 255);
|
||||||
m_sun_diffuse_color = video::SColor(128, 128, 128, 128);
|
m_sun_diffuse_color = video::SColor(255, 255, 255, 255);
|
||||||
XMLNode *root = file_manager->createXMLTree(m_filename);
|
XMLNode *root = file_manager->createXMLTree(m_filename);
|
||||||
|
|
||||||
if(!root || root->getName()!="track")
|
if(!root || root->getName()!="track")
|
||||||
@ -528,7 +529,7 @@ void Track::handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml)
|
|||||||
void Track::update(float dt)
|
void Track::update(float dt)
|
||||||
{
|
{
|
||||||
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
|
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
|
||||||
m_light->getLightData().AmbientColor = m_ambient_color;
|
//m_sun->getLightData().AmbientColor = m_ambient_color;
|
||||||
|
|
||||||
for(unsigned int i=0; i<m_animated_textures.size(); i++)
|
for(unsigned int i=0; i<m_animated_textures.size(); i++)
|
||||||
{
|
{
|
||||||
@ -729,7 +730,7 @@ void Track::loadTrackModel(unsigned int mode_id)
|
|||||||
{
|
{
|
||||||
node->get("xyz", &m_sun_position );
|
node->get("xyz", &m_sun_position );
|
||||||
node->get("ambient-color", &m_default_ambient_color);
|
node->get("ambient-color", &m_default_ambient_color);
|
||||||
node->get("sun-color", &m_sun_ambient_color);
|
//node->get("sun-color", &m_sun_ambient_color);
|
||||||
node->get("sun-specular", &m_sun_specular_color);
|
node->get("sun-specular", &m_sun_specular_color);
|
||||||
node->get("sun-diffuse", &m_sun_diffuse_color);
|
node->get("sun-diffuse", &m_sun_diffuse_color);
|
||||||
node->get("fog", &m_use_fog);
|
node->get("fog", &m_use_fog);
|
||||||
@ -789,15 +790,22 @@ void Track::loadTrackModel(unsigned int mode_id)
|
|||||||
file_manager->popTextureSearchPath();
|
file_manager->popTextureSearchPath();
|
||||||
file_manager->popModelSearchPath ();
|
file_manager->popModelSearchPath ();
|
||||||
|
|
||||||
|
// ---- Set ambient color
|
||||||
|
m_ambient_color = m_default_ambient_color;
|
||||||
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
|
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
|
||||||
|
|
||||||
m_light = irr_driver->getSceneManager()->addLightSceneNode(NULL, m_sun_position,
|
// ---- Create sun (non-ambient directional light)
|
||||||
m_sun_ambient_color);
|
m_sun = irr_driver->getSceneManager()->addLightSceneNode(NULL, m_sun_position,
|
||||||
m_light->setLightType(video::ELT_DIRECTIONAL);
|
m_sun_diffuse_color);
|
||||||
m_light->setRotation( core::vector3df(180, 45, 45) );
|
m_sun->setLightType(video::ELT_DIRECTIONAL);
|
||||||
m_light->getLightData().AmbientColor = m_sun_ambient_color;
|
m_sun->setRotation( core::vector3df(180, 45, 45) ); // TODO: make sun orientation configurable
|
||||||
m_light->getLightData().DiffuseColor = m_sun_diffuse_color;
|
|
||||||
m_light->getLightData().SpecularColor = m_sun_specular_color;
|
// We should NOT give the sun an ambient color, we already have a scene-wide ambient color.
|
||||||
|
// No need for two ambient colors.
|
||||||
|
//m_sun->getLightData().AmbientColor = m_sun_ambient_color;
|
||||||
|
|
||||||
|
//m_sun->getLightData().DiffuseColor = m_sun_diffuse_color;
|
||||||
|
m_sun->getLightData().SpecularColor = m_sun_specular_color;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
m_light = irr_driver->getSceneManager()->addLightSceneNode(0, m_sun_position);
|
m_light = irr_driver->getSceneManager()->addLightSceneNode(0, m_sun_position);
|
||||||
@ -807,7 +815,8 @@ void Track::loadTrackModel(unsigned int mode_id)
|
|||||||
m_light->setLightData(light);
|
m_light->setLightData(light);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(m_use_fog)
|
// ---- Fog
|
||||||
|
if (m_use_fog)
|
||||||
{
|
{
|
||||||
#if IRRLICHT_VERSION_MAJOR > 1 || IRRLICHT_VERSION_MINOR >= 6
|
#if IRRLICHT_VERSION_MAJOR > 1 || IRRLICHT_VERSION_MINOR >= 6
|
||||||
irr_driver->getVideoDriver()->setFog(m_fog_color, video::EFT_FOG_LINEAR, m_fog_start, m_fog_end, m_fog_density);
|
irr_driver->getVideoDriver()->setFog(m_fog_color, video::EFT_FOG_LINEAR, m_fog_start, m_fog_end, m_fog_density);
|
||||||
@ -818,8 +827,7 @@ void Track::loadTrackModel(unsigned int mode_id)
|
|||||||
|
|
||||||
// Note: the physics world for irrlicht is created in loadMainTrack
|
// Note: the physics world for irrlicht is created in loadMainTrack
|
||||||
createPhysicsModel(main_track_count);
|
createPhysicsModel(main_track_count);
|
||||||
if(UserConfigParams::m_track_debug)
|
if (UserConfigParams::m_track_debug) m_quad_graph->createDebugMesh();
|
||||||
m_quad_graph->createDebugMesh();
|
|
||||||
} // loadTrackModel
|
} // loadTrackModel
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -70,7 +70,7 @@ private:
|
|||||||
std::vector<std::string> m_groups;
|
std::vector<std::string> m_groups;
|
||||||
std::vector<scene::ISceneNode*> m_all_nodes;
|
std::vector<scene::ISceneNode*> m_all_nodes;
|
||||||
std::vector<scene::IMesh*> m_all_meshes;
|
std::vector<scene::IMesh*> m_all_meshes;
|
||||||
scene::ILightSceneNode *m_light;
|
scene::ILightSceneNode *m_sun;
|
||||||
TriangleMesh* m_track_mesh;
|
TriangleMesh* m_track_mesh;
|
||||||
TriangleMesh* m_non_collision_mesh;
|
TriangleMesh* m_non_collision_mesh;
|
||||||
bool m_has_final_camera;
|
bool m_has_final_camera;
|
||||||
@ -136,7 +136,7 @@ private:
|
|||||||
core::vector3df m_sun_position;
|
core::vector3df m_sun_position;
|
||||||
video::SColor m_ambient_color;
|
video::SColor m_ambient_color;
|
||||||
video::SColor m_default_ambient_color;
|
video::SColor m_default_ambient_color;
|
||||||
video::SColor m_sun_ambient_color;
|
//video::SColor m_sun_ambient_color;
|
||||||
video::SColor m_sun_specular_color;
|
video::SColor m_sun_specular_color;
|
||||||
video::SColor m_sun_diffuse_color;
|
video::SColor m_sun_diffuse_color;
|
||||||
video::SColor m_fog_color;
|
video::SColor m_fog_color;
|
||||||
|
Loading…
Reference in New Issue
Block a user