#include <_src_sky_sky_dome.hh>
Public Member Functions | |
| virtual fp | GetRadius (void) |
| virtual NodeSort | GetNodeSort (void) |
| WorldVertex | ComputeVertexOnDome (const Degree lat, const Degree lon, const fp radiusScale) |
| uint | GetPointCount (void) |
| void | SetColor (const RGBA color, const Degree lat, const Degree lon) |
| void | SetColor (const RGBA color, const uint flatIdx) |
| void | SetColorAll (const RGBA color) |
| RGBA | GetColor (const Degree lat, const Degree lon) |
| uint | GetSliceCount (void) const |
| bool | IfInside (const WorldVertex &pos, const fp radius) |
Private Member Functions | |
| SkyDome (const WorldVertex ¢er, const fp radius, const RGBA color, const int sliceCount) | |
| virtual | ~SkyDome () |
| void | SetColor_ (const RGBA color, const pair< int, int > idx) |
| pair< int, int > | Deg2Idx (const Degree lat, const Degree lon) |
| Point & | GetPoint (const pair< int, int > idx) |
| Patch & | GetPatch (const pair< int, int > idx) |
| void | JoinPointAndPatch (const int pointLat, const int pointLon, const int patchLat, const int patchLon) |
Private Attributes | |
| fp | mRadius |
| HIDES Object::mRadius (ok, better than mDomeRadius). | |
| RGBA | mColor |
| default color | |
| const int | mLatSliceCount |
| latitude slices | |
| const int | mLonSliceCount |
| longitude slices | |
| Array2D< Point > | mPoints |
| vertexs on dome (rely on Array2D clamping indexs) | |
| Array2D< Patch > | mPatches |
| primitives of dome | |
| const Degree | mLatLimit |
| latitudes beyond this won't be drawn | |
Friends | |
| class | shptr< SkyDome > |
| class | Sky |
| class | Point |
| class | Patch |
Classes | |
| class | Patch |
| Defines a quad of sky-dome. More... | |
| class | Point |
| Defines one vertex on dome which will be shared by multiple Patches. Using an index, rather than a ptr, avoids the invalid iterator pitfall. More... | |
Latitude vs. longitude: ----------------------- Latitude defines a half-circle {0',...,180'}. Longitude defines a full-circle {0',...,360'}.
SkyDome vs. SkyDomePainter: --------------------------- SkyDome is a general data container (in terms of vertex colors). Algorithms to paint the sky are innately specific, so they're separated as the SkyDomePainter class. This separation would allow painting an Earth or Martian sky using different SkyDomePainter implementations.
Implementation of the sky dome: ------------------------------- The construction of the sky dome accords with the requirement that a 2D (lat,lon) coordinate has to be correlated to a 3D vertex, and also to OSG nodes in order to modify a vertex's color.
The first phase is a multi-level loop that computes vertexs of a ring on the dome where a latitude indexes a ring, and a longitude indexes a vertex in the ring. The OSG nodes for a vertex on the dome is collected into the SkyDome::Point class, and points are organized as a 2D array.
The second phase builds graphics primitives for each patch of the dome. Imagine the dome divided into horizontal bands (two connected rings), then each band is divided into quads.
When a client (SkyDomePainter) requests to change a color by (lat,lon), SkyDome does a lookup into the 2D array of Points. Note that one Point will be shared by multiple quads, each having its own color array, so more than one color array (etc) must be updated for a color modification. Therefore, the OSG nodes for a patch of the dome is defined by the class Patch, and a Point will have multiple references to a Patch.
Edge-cases (implementation): ---------------------------- The 2D array of Points is plus one. lon=0 and lon=360 reference different vertexs. A bad design would be to require the client to make two calls (worse, 360 is technically an overrun case). SetColor( color, lat=0, lon=0 ); SetColor( color, lat=0, lon=360 ); The implementation, as a special-case, will automatically change both vertexs if lon is almost equal to 0.0 or 360.0.
Problems: --------- Increasing sky dome will affect the view frustum. If its radius is too large, frustum clipping will occur.
| sky::SkyDome::SkyDome | ( | const WorldVertex & | center, | |
| const fp | radius, | |||
| const RGBA | color, | |||
| const int | sliceCount | |||
| ) | [private] |
| sky::SkyDome::~SkyDome | ( | ) | [private, virtual] |
| virtual fp sky::SkyDome::GetRadius | ( | void | ) | [inline, virtual] |
| NodeSort sky::SkyDome::GetNodeSort | ( | void | ) | [virtual] |
For scene-graph to render optimally, nodes should be sorted by state.
| uint sky::SkyDome::GetPointCount | ( | void | ) | [inline] |
| void sky::SkyDome::SetColor | ( | const RGBA | color, | |
| const uint | flatIdx | |||
| ) |
| void sky::SkyDome::SetColorAll | ( | const RGBA | color | ) |
Get the color of a vertex on the dome. This finds the vertex nearest the (lat,lon) coordinates.
| uint sky::SkyDome::GetSliceCount | ( | void | ) | const [inline] |
| bool sky::SkyDome::IfInside | ( | const WorldVertex & | pos, | |
| const fp | radius | |||
| ) |
| void sky::SkyDome::SetColor_ | ( | const RGBA | color, | |
| const pair< int, int > | idx | |||
| ) | [private] |
| Point& sky::SkyDome::GetPoint | ( | const pair< int, int > | idx | ) | [inline, private] |
| Patch& sky::SkyDome::GetPatch | ( | const pair< int, int > | idx | ) | [inline, private] |
| void sky::SkyDome::JoinPointAndPatch | ( | const int | pointLat, | |
| const int | pointLon, | |||
| const int | patchLat, | |||
| const int | patchLon | |||
| ) | [inline, private] |
friend class shptr< SkyDome > [friend] |
friend class Sky [friend] |
friend class Point [friend] |
friend class Patch [friend] |
fp sky::SkyDome::mRadius [private] |
HIDES Object::mRadius (ok, better than mDomeRadius).
RGBA sky::SkyDome::mColor [private] |
default color
const int sky::SkyDome::mLatSliceCount [private] |
latitude slices
const int sky::SkyDome::mLonSliceCount [private] |
longitude slices
Array2D<Point> sky::SkyDome::mPoints [private] |
vertexs on dome (rely on Array2D clamping indexs)
Array2D<Patch> sky::SkyDome::mPatches [private] |
primitives of dome
const Degree sky::SkyDome::mLatLimit [private] |
latitudes beyond this won't be drawn
Palomino Flight Simulator documents generated by doxygen 1.5.6 on Tue Sep 28 11:37:50 2010