Palomino - Sky Module

©2004,2009  Jim E. Brooks   http://www.palomino3d.org



Sky

[2008/04]

The Sky object is a Singleton that contains the sky-related objects such as the SkyDome, Stars, clouds, etc.


Sky Dome

[2008/04]

The SkyDome class models a 3D sphere that is rendered using smooth shading (vertex color interpolation). The sky can be painted by specifying a RGBA in terms of a (lat,lon) coordinate. SkyDome will correlate a (lat,lon) with the nearest vertex and change its color.

SkyDome defines a full sphere, but its drawable geometry can be limited to a northern hemisphere for speed. This setting is appropriate to whether the Planet is spherical or flat.

In STL terms, SkyDome is a general data container, and a SkyDomePainter is a specific algorithm.


SkyDomePainter

[2008/04]

Algorithms to paint the SkyDome are innately specific, so they are separated as the SkyDomePainter class (functions turned into class methods). This separation is for factoring, and to allow possibility of painting a Martian sky with a different implementation of SkyDomePainter.


Clouds

[2008/08]

Implemented using ParticleSystem. Currently, cloud textures are rendered from pre-loaded images (procedural clouds aren't used). ParticleSystem provides a timer-tick that could animate clouds (but for speed that capability isn't used).

Cloud Sprites and Roll Degree

Sprites are view-plane-aligned 3D quads. When the player rolls the view, the sprites must roll too (Z rotation in eye space). Every time the view matrix is recomputed, the View class tracks the degree of roll. This can be done by measuring the angle of the Y axis between the previous and current view matrixs.

Degree
ComputeMatrixRollDegree( const Matrix& matrix, const Matrix& nextMatrix )
{
    // Invert mapping of current matrix.
    Matrix inverseMatrix = MatrixTranspose( matrix );
    inverseMatrix.SetPosition( Vector3(0,0,0) );

    // Transform the Y axis of the next matrix thru the inverse of the current one.
    const Vector3 nextYAxis = inverseMatrix * Vector3( nextMatrix[Yx],
                                                       nextMatrix[Yy],
                                                       nextMatrix[Yz] );

    // Transformations produce results in absolute space which
    // allows measuring angles in 2D by ignoring a 3rd dimension.
    // Compute 2D angle of current and next Y axis.
    const Vector3 currYAxis( 0.0f, 1.0f, 0.0f );
    const Radian rad = Angle2( Vector2( currYAxis[XX], currYAxis[YY] ),
                               Vector2( nextYAxis[XX], nextYAxis[YY] ) );
    if ( nextYAxis[XX] < 0 )  // for full 360 range
        return Rad2Deg( -rad );
    else
        return Rad2Deg( rad );
}

Sun

[2008/04]

Sun is a stub class. It just holds the sun's (lat,lon) coordinates. The sun is actually rendered by SkyDomePainter which paints the sun's aura. In the future, Sun could be improved by rendering a Sprite image.


Moon

[2008/04]

Moon is rendered as a Sprite specified by (lat,lon).


Stars

[2008/04]

Stars are simply random white points (no attempt to model real constellations). The SkyDome can be used to help compute stars, but the graphical objects for stars would be contained by the Sky object.


Last modified: Sat Nov 7 14:58:32 CST 2009