Added lighting done by moon

This commit is contained in:
Michaël Lemaire 2013-12-26 18:28:25 +01:00
parent 3786b21e15
commit 0e837f00c6
3 changed files with 21 additions and 1 deletions

View file

@ -171,7 +171,8 @@ SoftwareBrunetonAtmosphereRenderer::~SoftwareBrunetonAtmosphereRenderer()
void SoftwareBrunetonAtmosphereRenderer::getLightingStatus(LightStatus* status, Vector3 normal, int opaque) void SoftwareBrunetonAtmosphereRenderer::getLightingStatus(LightStatus* status, Vector3 normal, int opaque)
{ {
return model->fillLightingStatus(status, normal, opaque); model->fillLightingStatus(status, normal, opaque);
parent->getNightSky()->fillLightingStatus(status, normal, opaque);
} }
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vector3 location, Color base) AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vector3 location, Color base)

View file

@ -7,6 +7,8 @@
#include "Scenery.h" #include "Scenery.h"
#include "AtmosphereDefinition.h" #include "AtmosphereDefinition.h"
#include "SurfaceMaterial.h" #include "SurfaceMaterial.h"
#include "LightComponent.h"
#include "LightStatus.h"
#define WORLD_SCALING 0.05 #define WORLD_SCALING 0.05
#define MOON_DISTANCE 384403.0 #define MOON_DISTANCE 384403.0
@ -86,3 +88,18 @@ const Color NightSky::getColor(double altitude, const Vector3 &direction)
return result; return result;
} }
void NightSky::fillLightingStatus(LightStatus *status, const Vector3 &, int)
{
LightComponent moon;
AtmosphereDefinition* atmosphere = renderer->getScenery()->getAtmosphere();
VectorSpherical moon_location_s = {MOON_DISTANCE_SCALED, atmosphere->moon_theta, -atmosphere->moon_phi};
moon.color = Color(0.03, 0.03, 0.03); // TODO take moon phase into account
moon.direction = Vector3(moon_location_s).normalize().scale(-1.0);
moon.reflection = 0.2;
moon.altered = 1;
status->pushComponent(moon);
}

View file

@ -26,6 +26,8 @@ public:
*/ */
virtual const Color getColor(double altitude, const Vector3 &direction); virtual const Color getColor(double altitude, const Vector3 &direction);
virtual void fillLightingStatus(LightStatus *status, const Vector3 &normal, int opaque);
private: private:
SoftwareRenderer* renderer; SoftwareRenderer* renderer;
}; };