36 lines
1,005 B
C++
36 lines
1,005 B
C++
#include "SkyIntersector.h"
|
|
|
|
#include "AtmosphereRenderer.h"
|
|
#include "AtmosphereResult.h"
|
|
#include "Color.h"
|
|
#include "Maths.h"
|
|
#include "Scenery.h"
|
|
#include "Vector3.h"
|
|
#include <cassert>
|
|
|
|
SkyIntersector::SkyIntersector(BaseAtmosphereRenderer *atmosphere) : atmosphere(atmosphere) {
|
|
}
|
|
|
|
int SkyIntersector::getPriority() const {
|
|
return 1000;
|
|
}
|
|
|
|
bool SkyIntersector::findIntersection(const Vector3 &eye, const Vector3 &direction, double, Vector3 *out_hit) const {
|
|
assert(direction.isNormalized());
|
|
|
|
if (eye.y >= Scenery::ATMOSPHERE_WIDTH_SCALED) {
|
|
// Above atmosphere, intersect right in front of the eye
|
|
*out_hit = eye.add(direction.scale(0.00001));
|
|
} else {
|
|
// Intersect with upper atmosphere boundary
|
|
// TODO
|
|
*out_hit = eye.add(direction.scale(0.00001));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
Color SkyIntersector::getColorAtHit(const Vector3 &eye, const Vector3 &location) const {
|
|
return atmosphere->getSkyColor(location.sub(eye).normalize()).final;
|
|
}
|