|
|
This article explains TerraPOV's global geometric model for a scene. This
involves Earth's and Sun's geometric parameters.
Just before we begin, we have to define some distance units we will often
use in TerraPOV:
#declare m = 0.1; // A value of 1 makes the sun's distance ouside POV's
numerical domain.
#declare km = 1000*m;
#declare mm = 0.001*m;
And, like POV-SDL, TerraPOV uses degrees for angles.
0) Outer space
--------------
Outer space is considered as fully dark. This is the case in POV-SDL if no
background is specified.
1) Earth
---------
For current applications such as GPS, the reference Earth is an ellipsoid
with semi-major axis of 6378.137 km and semi-minor axis of 6354.4523 km
(WGS84 model). In many scientific applications and calculations, the Earth
is simplified to a sphere with a radius of semi-major axis. TerraPOV
expresses it as:
#declare TP_EARTH_RADIUS = 6378.137*km;
TerraPOV sets the origin at the surface of the Earth, that is:
#declare _tp_earth = sphere
{
0, TP_EARTH_RADIUS
pigment {White} // Could be any predefined texture, but normally, the
terrain hides the sphere
finish {ambient 0}
translate -TP_EARTH_RADIUS*y
}
And that's enough for Earth.
2) Sun
------
The sun is the main light source for TerraPOV scenes. The sun's apparent
aperture, due to real distance, allows to assume that the rays are
parallel. At first, we use a simple parallel white light_source that
looks_like a shere. The necessity to have a more advanced model for the
sun depends on the type of sky used in the scene, whether clouds are
present and if the sun is totally/partially hidden behind, its elevation.
Until now I could not find a general model of the sun that can fit a few
frequent situations. I'll come back to it later. The color of the
light_source is expressed through 2 values: a color and a brightness,
multiplied together. Later, the color could be normalized in order to
match the energy of white (white carries an energy The brightness is used
to compensate lightness diminution when the sun is hidden behind clouds or
at low elevations.
For now, let's express what we have:
// User defined values
#declare TP_SUN_HEADING = 0;
#declare TP_SUN_ELEVATION = 15;
#declare TP_BRIGHTNESS = 1;
#declare TP_SUN_COLOR = White;
#declare TP_SUN_APPARENT_APERTURE = 0.5; // Commonly admitted value
// Computed values
#declare TP_SUN_DISTANCE = 10*TP_EARTH_RADIUS; // Far enough. Actual
distance in the scene is not very critical, as the light ays are parallel
#declare TP_SUN_RADIUS =
TP_SUN_DISTANCE*tan(radians(TP_SUN_APPARENT_APERTURE/2));
// Sun
#declare _tp_basic_sun = light_source
{
<0, 0, 0>
TP_SUN_COLOR*TP_BRIGHTNESS
looks_like {sphere{0, TP_SUN_RADIUS pigment{Yellow} finish {diffuse 0
ambient 1}}}
translate TP_SUN_DISTANCE*z
parallel point_at -z
rotate -TP_SUN_ELEVATION*x
rotate TP_SUN_HEADING*y
}
3) Camera
---------
We use a standard persepective camera, and the main parametes are
contallable. In a normal lanscape scene, we can drop the camera above the
terrain, helped by a preview image, and rough and fine offsets can be be
applied. The camera can also be placed with respect to an object. For now,
we just position the camera above the ground, at humain height. Let's also
imagine that TerraPOV can provide several cameras, for different pusposes.
So, let's define the default camera.
#declare TP_DEFCAM_HEIGHT = 2*m; // Let's be tall
#declare TP_DEFCAM_HEADING = 0;
#declare TP_DEFCAM_ELEVATION = 5;
#declare TP_DEFCAM_ANGLE = 40;
#declare _tp_default_camera = camera
{
location 0
angle TP_DEFCAM_ANGLE
right x*image_width/image_height
look_at z
rotate -TP_DEFCAM_ELEVATION*x
rotate TP_DEFCAM_HEADING*y
translate TP_DEFCAM_HEIGHT*y; // Could use trace() to make sure we are
above the surface. But no terrain yet ...
}
Now we have someting that expresses the global geometry of a TerraPOV
scene. However it's still very basic, but we have already separated
interesting parameters from the 'engine'.
// Scene
object {_tp_earth}
object {_tp_basic_sun}
camera {_tp_default_camera}
We put all together and render the scene. One can play with parameters.
REMARK: In a while, we will have many parameters. They will be split among
several include files, and used by a standard main scene file.
// ------------------------------------
#include "colors.inc"
global_settings
{
#if (version < 3.7) assumed_gamma 1 #end
max_trace_level 20
}
// Units
#declare m = 0.1; // A value of 1 makes the sun's distance ouside POV's
numerical domain.
#declare km = 1000*m;
#declare mm = 0.001*m;
// Earth parameters
#declare TP_EARTH_RADIUS = 6378.137*km;
// Sun parameters
#declare TP_SUN_HEADING = 0;
#declare TP_SUN_ELEVATION = 15;
#declare TP_BRIGHTNESS = 1;
#declare TP_SUN_COLOR = White;
#declare TP_SUN_APPARENT_APERTURE = 0.5; // Commonly admitted value
// Default camera parameters
#declare TP_DEFCAM_HEIGHT = 2*m; // Let's be tall
#declare TP_DEFCAM_HEADING = 0;
#declare TP_DEFCAM_ELEVATION = 5; // Let's look up a little
#declare TP_DEFCAM_ANGLE = 40;
// Computed values
#declare TP_SUN_DISTANCE = 10*TP_EARTH_RADIUS; // Far enough. Actual
distance in the scene is not very critical, as the light ays are parallel
#declare TP_SUN_RADIUS =
TP_SUN_DISTANCE*tan(radians(TP_SUN_APPARENT_APERTURE/2));
// Earth
#declare _tp_earth = sphere
{
0, TP_EARTH_RADIUS
pigment {White} // Could be any predefined texture, but normally, the
terrain hides the sphere
finish {ambient 0}
translate -TP_EARTH_RADIUS*y
}
// Sun
#declare _tp_basic_sun = light_source
{
<0, 0, 0>
color rgb TP_SUN_COLOR*TP_BRIGHTNESS
looks_like {sphere{0, TP_SUN_RADIUS pigment{Yellow} finish {diffuse 0
ambient 1}}}
translate TP_SUN_DISTANCE*z
parallel point_at -z
rotate -TP_SUN_ELEVATION*x
rotate TP_SUN_HEADING*y
}
// Default camera
#declare _tp_default_camera = camera
{
location 0
angle TP_DEFCAM_ANGLE
right x*image_width/image_height
look_at z
rotate -TP_DEFCAM_ELEVATION*x
rotate TP_DEFCAM_HEADING*y
translate TP_DEFCAM_HEIGHT*y // Could use trace() to make sure we are
above the surface. But no terrain yet ...
}
// Scene
object {_tp_earth}
object {_tp_basic_sun}
camera {_tp_default_camera}
// ------------------------------------
Ok folks, I have finished for this part. Next article will add an
atmosphere, and we'll get a blue sky ... automatically....
Coming next: TerraPOV - Sky system - Atmosphere - Part3, A Blue Sky
Bruno
--
http://www.opera.com/mail/
Post a reply to this message
Attachments:
Download 'globalgeometry.jpg' (46 KB)
Download 'firstterrapov.png' (3 KB)
Preview of image 'globalgeometry.jpg'
Preview of image 'firstterrapov.png'
|
|