void ShapeVisitor_RestrictedPositionGetter::visit( Shape_Sphere& shape )
{
	if ( ( mOriginalPosition - shape.getCenter() ).length() > shape.getRadius() ) {
		// position outside

		float radiusMin;
		float radiusMax;
		switch ( shape.getRestrictionPolicy() ) {
			case Shape_Sphere::SURFACE:
				radiusMin = shape.getRadius();
				radiusMax = shape.getRadius();
				break;
			case Shape_Sphere::RANDOM_DISTANCE_FROM_CENTER:
				radiusMin = 0;
				radiusMax = shape.getRadius();
				break;
			default:
				radiusMin = 0;
				radiusMax = 0;
		}

		mRestrictedPosition = toSphere( shape.getCenter(), radiusMin, radiusMax, mOriginalPosition );
	}
	else {
		// position in sphere - OK
		mRestrictedPosition = mOriginalPosition;
	}
}
Exemplo n.º 2
0
	void configure() {
		SphericalCoordinates sun(m_sun);
		sun.elevation *= m_stretch;
		m_sunDir = toSphere(sun);

		/* Solid angle covered by the sun */
		m_theta = degToRad(SUN_APP_RADIUS * 0.5f);
		m_solidAngle = 2 * M_PI * (1 - std::cos(m_theta));
		m_radiance = computeSunRadiance(m_sun.elevation, m_turbidity) * m_scale;
	}
void ShapeVisitor_RestrictedPositionGetter::visit( Shape_SphereSurface& shape )
{
	mRestrictedPosition = toSphere( shape.getCenter(), shape.getRadius(), shape.getRadius(), mOriginalPosition );
}