2013-11-09 17:46:34 +00:00
|
|
|
#include "SoftwareRenderer.h"
|
|
|
|
|
2013-11-11 14:42:11 +00:00
|
|
|
#include "camera.h"
|
2013-11-10 16:04:38 +00:00
|
|
|
#include "Scenery.h"
|
2013-11-11 14:42:11 +00:00
|
|
|
#include "FluidMediumManager.h"
|
2013-11-12 20:34:35 +00:00
|
|
|
#include "AtmosphereRenderer.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Legacy compatibility
|
|
|
|
static AtmosphereResult _legacyApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
|
|
|
{
|
|
|
|
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->applyAerialPerspective(location, base);
|
|
|
|
}
|
|
|
|
static AtmosphereResult _legacyGetSkyColor(Renderer* renderer, Vector3 direction)
|
|
|
|
{
|
|
|
|
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getSkyColor(direction);
|
|
|
|
}
|
|
|
|
static void _legacyGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque)
|
|
|
|
{
|
|
|
|
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getLightingStatus(status, normal, opaque);
|
|
|
|
}
|
|
|
|
static Vector3 _legacyGetSunDirection(Renderer* renderer)
|
|
|
|
{
|
|
|
|
return ((SoftwareRenderer*)renderer)->getAtmosphereRenderer()->getSunDirection();
|
|
|
|
}
|
|
|
|
|
2013-11-09 17:46:34 +00:00
|
|
|
|
2013-11-10 16:04:38 +00:00
|
|
|
SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
|
2013-11-09 17:46:34 +00:00
|
|
|
{
|
2013-11-12 20:34:35 +00:00
|
|
|
atmosphere_renderer = new BaseAtmosphereRenderer(this);
|
|
|
|
|
2013-11-11 14:42:11 +00:00
|
|
|
fluid_medium = new FluidMediumManager(this);
|
2013-11-10 16:04:38 +00:00
|
|
|
|
|
|
|
if (scenery)
|
|
|
|
{
|
|
|
|
this->scenery = scenery;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->scenery = Scenery::getCurrent();
|
|
|
|
}
|
|
|
|
this->scenery->bindToRenderer(this);
|
2013-11-09 17:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoftwareRenderer::~SoftwareRenderer()
|
|
|
|
{
|
2013-11-12 20:34:35 +00:00
|
|
|
delete atmosphere_renderer;
|
|
|
|
|
2013-11-09 17:46:34 +00:00
|
|
|
delete fluid_medium;
|
|
|
|
}
|
2013-11-10 16:04:38 +00:00
|
|
|
|
2013-11-12 20:34:35 +00:00
|
|
|
void SoftwareRenderer::prepare()
|
2013-11-10 16:04:38 +00:00
|
|
|
{
|
2013-11-12 20:34:35 +00:00
|
|
|
// Prepare sub renderers
|
|
|
|
delete atmosphere_renderer;
|
|
|
|
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
|
|
|
|
|
|
|
|
// Setup transitional renderers (for C-legacy subsystems)
|
|
|
|
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
|
|
|
|
atmosphere->getSkyColor = _legacyGetSkyColor;
|
|
|
|
atmosphere->getLightingStatus = _legacyGetLightingStatus;
|
|
|
|
atmosphere->getSunDirection = _legacyGetSunDirection;
|
|
|
|
|
|
|
|
// Prepare global tools
|
|
|
|
fluid_medium->clearMedia();
|
2013-11-11 14:42:11 +00:00
|
|
|
//fluid_medium->registerMedium(water_renderer);
|
2013-11-10 16:04:38 +00:00
|
|
|
}
|
2013-11-11 14:42:11 +00:00
|
|
|
|
|
|
|
/*Color SoftwareRenderer::applyMediumTraversal(Vector3 location, Color color)
|
|
|
|
{
|
|
|
|
Vector3 eye = cameraGetLocation(scenery->getCamera());
|
|
|
|
return fluid_medium->applyTraversal(eye, location, color);
|
|
|
|
}*/
|