Cleaned code

This commit is contained in:
Elderme 2015-08-07 15:11:32 +02:00
parent f583fafd97
commit 87b493aaa2
6 changed files with 23 additions and 64 deletions

View File

@ -1367,32 +1367,12 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &tex
const std::vector<video::ITexture*> &spherical_harmonics_textures)
{
assert(texture.size() == 6);
/*SkyboxTextures = texture;
SphericalHarmonicsTextures = sphericalHarmonics;
SkyboxCubeMap = 0;
SkyboxSpecularProbe = 0;*/
//m_skybox_ready = false;
//TODO
//prepareSkybox();
//m_skybox_ready = true;
m_skybox = new Skybox(texture);
if(spherical_harmonics_textures.size() == 6)
{
m_spherical_harmonics->setTextures(spherical_harmonics_textures);
}
/*if(spherical_harmonics_textures.size() == 6)
{
if(m_spherical_harmonics != NULL)
{
delete m_spherical_harmonics;
}
m_spherical_harmonics = new SphericalHarmonics(spherical_harmonics_textures);
}
else
{
//m_spherical_harmonic = new SphericalHarmonic(m_scene_manager->getAmbientLight().toSColor());
}*/
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
texture[2], texture[3],
@ -1401,21 +1381,8 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &tex
void IrrDriver::suppressSkyBox()
{
//TODO!
/*SkyboxTextures.clear();
SphericalHarmonicsTextures.clear();
m_skybox_ready = false;
if ((SkyboxCubeMap) && (!ProfileWorld::isNoGraphics()))
{
glDeleteTextures(1, &SkyboxCubeMap);
glDeleteTextures(1, &SkyboxSpecularProbe);
}
SkyboxCubeMap = 0;
SkyboxSpecularProbe = 0;*/
delete m_skybox;
m_skybox = NULL;
//delete m_spherical_harmonics;
//m_spherical_harmonics = NULL;
}
// ----------------------------------------------------------------------------
@ -1796,9 +1763,6 @@ void IrrDriver::setAmbientLight(const video::SColorf &light)
{
m_scene_manager->setAmbientLight(light);
m_spherical_harmonics->setAmbientLight(light.toSColor());
//TODO!
} // setAmbientLight
video::SColorf IrrDriver::getAmbientLight() const

View File

@ -186,9 +186,8 @@ void IrrDriver::renderGLSL(float dt)
const core::recti &viewport = camera->getViewport();
//if (World::getWorld() && World::getWorld()->getTrack()->hasShadows() && !SphericalHarmonicsTextures.empty())
//irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
//TODO!
if (World::getWorld() && World::getWorld()->getTrack()->hasShadows() && m_spherical_harmonics->has6Textures())
irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
if (!CVS->isDefferedEnabled())
glEnable(GL_FRAMEBUFFER_SRGB);

View File

@ -497,9 +497,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
else
{
m_post_processing->renderEnvMap(0);
}
//TODO: move in skybox (or IBL?) class
}
}
// Render sunlight if and only if track supports shadow

View File

@ -74,8 +74,6 @@ public:
}; // SpecularIBLGenerator
namespace {
// ----------------------------------------------------------------------------
void swapPixels(char *old_img, char *new_img, unsigned stride, unsigned old_i,
@ -141,16 +139,7 @@ namespace {
} //namespace
// ----------------------------------------------------------------------------
/** Generate an opengl cubemap texture from 6 2d textures.
Out of legacy the sequence of textures maps to :
- 1st texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_Y
- 2nd texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
- 3rd texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_X
- 4th texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_X
- 5th texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
- 6th texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_Z
* \param textures sequence of 6 textures.
*/
/** Generate an opengl cubemap texture from 6 2d textures */
void Skybox::generateCubeMapFromTextures()
{
assert(m_skybox_textures.size() == 6);
@ -218,7 +207,6 @@ void Skybox::generateCubeMapFromTextures()
// ----------------------------------------------------------------------------
void Skybox::generateSpecularCubemap()
{
glGenTextures(1, &m_specular_probe);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_specular_probe);
size_t cubemap_size = 256;
@ -315,6 +303,16 @@ void Skybox::generateSpecularCubemap()
// ----------------------------------------------------------------------------
/** Generate a skybox from 6 2d textures.
Out of legacy the sequence of textures maps to:
- 1st texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_Y
- 2nd texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
- 3rd texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_X
- 4th texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_X
- 5th texture maps to GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
- 6th texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_Z
* \param skybox_textures sequence of 6 textures.
*/
Skybox::Skybox(const std::vector<video::ITexture *> &skybox_textures)
{
m_skybox_textures = skybox_textures;

View File

@ -63,6 +63,8 @@ public:
inline const float* getGreenSHCoeff() const {return m_green_SH_coeff; }
inline const float* getRedSHCoeff () const {return m_red_SH_coeff; }
inline bool has6Textures() const {return m_spherical_harmonics_textures.size()==6;}
void printCoeff();
void unprojectSH (size_t width, size_t height,

View File

@ -1824,12 +1824,6 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
}
m_track_object_manager->enableFog(m_use_fog);
// ---- Set ambient color
// We need to define ambient color before adding Skybox because we will use
// ambient light if the track do not have spherical harmonics textures.
m_ambient_color = m_default_ambient_color;
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
// Sky dome and boxes support
// --------------------------
irr_driver->suppressSkyBox();
@ -1860,8 +1854,6 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
m_all_nodes.push_back(irr_driver->addSkyBox(m_sky_textures, m_spherical_harmonics_textures));
//else
// m_all_nodes.push_back(irr_driver->addSkyBox(m_sky_textures, m_sky_textures));
if (m_spherical_harmonics_textures.size() != 6)
irr_driver->getSphericalHarmonics()->setAmbientLight(m_ambient_color);
}
else if(m_sky_type==SKY_COLOR)
{
@ -1877,6 +1869,12 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath ();
// ---- Set ambient color
m_ambient_color = m_default_ambient_color;
irr_driver->getSceneManager()->setAmbientLight(m_ambient_color);
if (m_spherical_harmonics_textures.size() != 6)
irr_driver->getSphericalHarmonics()->setAmbientLight(m_ambient_color);
// ---- Create sun (non-ambient directional light)
if (m_sun_position.getLengthSQ() < 0.03f)
{