The establishment of the Sky

Xtreme3D

Lesson 14
The establishment of the Sky

Level: medium
Version of the Xtreme3D: 3.0.x
Author: Gecko

Many games an important part of the graphics and gameplay is smooth change of day and night (for example, in the RPG and games in the GTA style). In the Xtreme3D This functionality provides an object Skydome, the literal translation means "heavenly dome", "a firmament." This is a spherical form, the stage and changes color depending on the time of day. On the dome in the literal sense of the "suspended" The sun and stars. The sun goes smoothly across the sky: when it is lowered toward the horizon, we are witnessing a sunset. And then the sky darkens and there comes the night. Sparkling stars as the real thing. The only minus - no clouds. They would have to do on their own. It probably was assumed not to deprive the developer to make, for example, The �������������: so that you can as fall to the ground and climb to the clouds and see them from a close distance.

The color of the sky in the skydome is composed of three components: Deep, Haze, the Night and the Sky.
Deep - the color of the so-called nadir - the point opposite the ������; it is located under our feet. Usually in real life to see nadir is impossible, the earth obstructs :) But the color of this point is important as it determines how shade mixes up the color of the sky as the care of the horizon line.
Haze - the color of the horizon. Usually corresponds to the color of the mist.
Sky is the color of the zenith. In this color painted the entire heavenly bubble up to the line of the horizon.
Night - the color of the night. When the sun goes below the horizon, this color is gradually filled in all the components of the sky, in addition to the Deep. This is most often black or dark blue, although there may be other options.



Below is the code that creates the sky:

Sky = SkydomeCreate(24, 48, global.back);
SkydomeSetOptions(sky, true, true);
ObjectRotate(sky, 90, 0, 0).
SkydomeSetNightColor(sky, make color_rgb(0, 0, 180);
Angle = 0;
SkydomeSetSunElevation(sky, angle);
SkydomeAddRandomStars(sky, 50, c_white);

The sun moved across the sky, you need every step of time to change the angle at which it is on the horizon. The angle of 90 degrees, ������ -90 - Nader.

SkydomeSetSunElevation(sky, angle);
Angle = angle of + 1.0 * dt;

You can also create a realistic starry sky with the familiar us constellations, although this is not as simple as it may seem. To do this you need to understand the celestial coordinates. In the Xtreme3D the position of the stars in the sky is set during the second equatorial coordinate system, which includes two values - direct ascent (right ascension) and declination (declination). The two values are in degrees, although the Astronomy of the direct ascent traditionally measured in hours, minutes, and seconds (1 hour is equal to 360 / 24 = 15 degrees). To simplify the translation of these units in degrees, in the Xtreme3D SDK is The RightAscension script(hours, minutes, seconds). There is also a script(Declination degrees, minutes, seconds), with which you can get a float value from the degrees of angular minutes and angular seconds.

Here is an example of the creation of the well-known of the bucket - the seven major stars of the Big Dipper (coordinates i took from Wikipedia):

SkydomeAddStar(sky, RightAscension(11, 3, 44), the Declination(61, 45, 0), 1.79, c_white); // �����
SkydomeAddStar(sky, RightAscension(11, 1, 50), Declination(56, 22, 57), 2.37, c_white); // �����
SkydomeAddStar(sky, RightAscension(11, 53, 50), Declination(53, 41, 41), 2.44, c_white); // �����
SkydomeAddStar(sky, RightAscension(12, 15, 25), the Declination(57, 01, 57), 3.31, c_white); // ������
SkydomeAddStar(sky, RightAscension(12, 54, 0), the Declination(55, 57, 35), 1.77, c_white); // Suites
SkydomeAddStar(sky, RightAscension(13, 23, 55), the Declination(54, 55, 31), 2.27, c_white); // The �����
SkydomeAddStar(sky, RightAscension(13, 47, 32), the Declination(49, 18, 48), 1.86, c_white); // �������

It will be more convenient to, of course, to create something like the star directory in the file and read it when loading, creating the stars procedurally.