Fix bug with new Sky code
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4750 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 8a3ffcba48f3d16b03fb8d10ee9386db287ce0d6 Former-commit-id: ba2795268b7267aa435678f5954b4fa9b1aaed9d
This commit is contained in:
parent
ceb957a3e8
commit
f52c4fc8d2
4 changed files with 403 additions and 438 deletions
|
@ -75,12 +75,12 @@ ssgBranch * cGrMoon::build( double moon_size )
|
|||
moon_state->enable( GL_ALPHA_TEST );
|
||||
moon_state->setAlphaClamp( 0.01 );
|
||||
|
||||
cl = new ssgColourArray( 1 );
|
||||
moon_cl = new ssgColourArray( 1 );
|
||||
sgVec4 color;
|
||||
sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
|
||||
cl->add( color );
|
||||
moon_cl->add( color );
|
||||
|
||||
ssgBranch *moon = grMakeSphere( moon_state, cl, moon_size, 15, 15,
|
||||
ssgBranch *moon = grMakeSphere( moon_state, moon_cl, moon_size, 15, 15,
|
||||
grMoonOrbPreDraw, grMoonOrbPostDraw );
|
||||
|
||||
repaint( 0.0 );
|
||||
|
@ -112,14 +112,14 @@ bool cGrMoon::repaint( double moon_angle )
|
|||
grGammaCorrectRGB( color );
|
||||
|
||||
float *ptr;
|
||||
ptr = cl->get( 0 );
|
||||
ptr = moon_cl->get( 0 );
|
||||
sgCopyVec4( ptr, color );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cGrMoon::reposition(sgVec3 p, double moonangle, double moonrightAscension, double moondeclination, double moon_dist)
|
||||
bool cGrMoon::reposition(sgVec3 p, double moon_angle, double moonrightAscension, double moondeclination, double moon_dist)
|
||||
{
|
||||
sgMat4 T1, T2, GST, RA, DEC;
|
||||
sgVec3 axis;
|
||||
|
@ -128,11 +128,11 @@ bool cGrMoon::reposition(sgVec3 p, double moonangle, double moonrightAscension,
|
|||
sgMakeTransMat4( T1, p );
|
||||
|
||||
sgSetVec3( axis, 0.0, 0.0, -1.0 );
|
||||
sgMakeRotMat4( GST, (float)moonangle, axis );
|
||||
sgMakeRotMat4( GST, moon_angle, axis );
|
||||
sgSetVec3( axis, 0.0, 0.0, 1.0 );
|
||||
sgMakeRotMat4( RA, ((float)moonrightAscension * SGD_RADIANS_TO_DEGREES) - 90.0, axis );
|
||||
sgMakeRotMat4( RA, (moonrightAscension * SGD_RADIANS_TO_DEGREES) - 90.0, axis );
|
||||
sgSetVec3( axis, 1.0, 0.0, 0.0 );
|
||||
sgMakeRotMat4( DEC, (float)moondeclination * SGD_RADIANS_TO_DEGREES, axis );
|
||||
sgMakeRotMat4( DEC, moondeclination * SGD_RADIANS_TO_DEGREES, axis );
|
||||
sgSetVec3( v, 0.0, moon_dist, 0.0 );
|
||||
sgMakeTransMat4( T2, v );
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void cGrSky::build( double h_radius, double v_radius,
|
|||
sun->setSunDistance( sun_dist );
|
||||
|
||||
moon = new cGrMoon;
|
||||
moon_transform ->addKid( sun->build( moon_size));
|
||||
moon_transform ->addKid( moon->build( moon_size));
|
||||
moon->setMoonDist(moon_dist);
|
||||
|
||||
planets = new cGrStars;
|
||||
|
@ -150,6 +150,7 @@ bool cGrSky::repositionFlat( sgVec3 view_pos, double spin, double dt )
|
|||
double rotation;
|
||||
sgCoord pos;
|
||||
|
||||
|
||||
sun->reposition( view_pos, 0 );
|
||||
moon->reposition( view_pos, 0 );
|
||||
|
||||
|
|
|
@ -143,12 +143,8 @@ class cGrMoon
|
|||
private:
|
||||
ssgTransform *moon_transform;
|
||||
ssgSimpleState *moon_state;
|
||||
ssgSimpleState *halo_state;
|
||||
|
||||
ssgColourArray *cl;
|
||||
|
||||
ssgVertexArray *halo_vl;
|
||||
ssgTexCoordArray *halo_tl;
|
||||
ssgColourArray *moon_cl;
|
||||
|
||||
double prev_moon_angle;
|
||||
double moon_angle;
|
||||
|
@ -174,12 +170,7 @@ public:
|
|||
// 0 degrees = high noon
|
||||
// 90 degrees = moon rise/set
|
||||
// 180 degrees = darkest midnight
|
||||
|
||||
//bool repaint(double moon_angle);
|
||||
|
||||
/*bool reposition( sgVec3 p, double angle,
|
||||
double rightAscension, double declination,
|
||||
double moon_dist );*/
|
||||
bool repaint(double moon_angle);
|
||||
|
||||
bool reposition(sgVec3 p, double moon_angle)
|
||||
{
|
||||
|
@ -187,7 +178,7 @@ public:
|
|||
}
|
||||
|
||||
bool reposition(sgVec3 p, double moon_angle, double moonAscension, double moondeclination, double moon_dist);
|
||||
bool repaint(double moon_angle);
|
||||
|
||||
|
||||
void getMoonPosition (sgCoord* p)
|
||||
{
|
||||
|
@ -224,11 +215,9 @@ private:
|
|||
ssgColourArray *ihalo_cl;
|
||||
ssgColourArray *ohalo_cl;
|
||||
|
||||
ssgVertexArray *sun_vl;
|
||||
ssgVertexArray *ihalo_vl;
|
||||
ssgVertexArray *ohalo_vl;
|
||||
|
||||
ssgTexCoordArray *sun_tl;
|
||||
ssgTexCoordArray *ihalo_tl;
|
||||
ssgTexCoordArray *ohalo_tl;
|
||||
|
||||
|
|
|
@ -101,45 +101,20 @@ ssgBranch * cGrSun::build( double sun_size )
|
|||
sun_state = new ssgSimpleState();
|
||||
sun_state->setShadeModel( GL_SMOOTH );
|
||||
sun_state->disable( GL_LIGHTING );
|
||||
sun_state->disable( GL_CULL_FACE );
|
||||
sun_state->setTexture( "data/textures/inner_halo.png");
|
||||
sun_state->enable( GL_TEXTURE_2D );
|
||||
sun_state->enable( GL_CULL_FACE );
|
||||
sun_state->disable( GL_TEXTURE_2D );
|
||||
sun_state->enable( GL_COLOR_MATERIAL );
|
||||
sun_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
|
||||
sun_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
|
||||
sun_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
|
||||
sun_state->enable( GL_BLEND );
|
||||
sun_state->disable( GL_BLEND );
|
||||
sun_state->setAlphaClamp( 0.01 );
|
||||
sun_state->enable( GL_ALPHA_TEST );
|
||||
|
||||
// Build ssg structure
|
||||
|
||||
sgVec3 va;
|
||||
sun_vl = new ssgVertexArray;
|
||||
sgSetVec3( va, -sun_size, 0.0, -sun_size );
|
||||
sun_vl->add( va );
|
||||
sgSetVec3( va, sun_size, 0.0, -sun_size );
|
||||
sun_vl->add( va );
|
||||
sgSetVec3( va, -sun_size, 0.0, sun_size );
|
||||
sun_vl->add( va );
|
||||
sgSetVec3( va, sun_size, 0.0, sun_size );
|
||||
sun_vl->add( va );
|
||||
|
||||
sgVec2 vb;
|
||||
sun_tl = new ssgTexCoordArray;
|
||||
sgSetVec2( vb, 0.0f, 0.0f );
|
||||
sun_tl->add( vb );
|
||||
sgSetVec2( vb, 1.0, 0.0 );
|
||||
sun_tl->add( vb );
|
||||
sgSetVec2( vb, 0.0, 1.0 );
|
||||
sun_tl->add( vb );
|
||||
sgSetVec2( vb, 1.0, 1.0 );
|
||||
sun_tl->add( vb );
|
||||
sun_state->disable( GL_ALPHA_TEST );
|
||||
|
||||
ssgBranch *sun = grMakeSphere( sun_state, sun_cl, sun_size, 15, 15,
|
||||
grSunPreDraw, grSunPostDraw );
|
||||
|
||||
repaint( 0.0, 1.0 );
|
||||
repaint( 0.0, 10000.0 );
|
||||
|
||||
ihalo_state = new ssgSimpleState();
|
||||
ihalo_state->setTexture( "data/textures/inner_halo.png" );
|
||||
|
|
Loading…
Reference in a new issue