- first implement for Moon Position
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4792 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 114ab50643a3583fb11984051b2d5e2edda7019b Former-commit-id: d12849ebbf76d7c083a7197f4449eb6750f441c5
This commit is contained in:
parent
6106da1bbf
commit
8d6f045391
3 changed files with 51 additions and 55 deletions
|
@ -5,7 +5,7 @@ SET(SSGGRAPH_SOURCES CarSoundData.cpp CarSoundData.h
|
|||
SoundInterface.cpp SoundInterface.h
|
||||
PlibSoundInterface.cpp PlibSoundInterface.h
|
||||
OpenalSoundInterface.cpp OpenalSoundInterface.h
|
||||
#grCelestialBody.cpp
|
||||
grMoonPos.h grMoonPos.cpp
|
||||
grMoon.cpp grSun.cpp grCloudLayer.cpp grSky.cpp grSky.h
|
||||
grSkyDome.cpp grSphere.cpp grSphere.h grStars.cpp
|
||||
grboard.cpp grboard.h grcam.cpp grcam.h grcar.cpp grcar.h
|
||||
|
|
|
@ -239,52 +239,52 @@ void cGrSky::preDraw()
|
|||
|
||||
void cGrSky::postDraw( float alt )
|
||||
{
|
||||
// Sort clouds in order of distance from alt (furthest to closest)
|
||||
int i, j;
|
||||
int num = clouds.getNum ();
|
||||
if ( num > 0 )
|
||||
{
|
||||
// Initialise cloud index
|
||||
int *index = new int [ num ];
|
||||
for ( i = 0; i < num; i++ )
|
||||
{
|
||||
index [i] = i;
|
||||
}
|
||||
|
||||
// Sort cloud index
|
||||
int temp; // holding variable
|
||||
for ( i = 0; i < ( num - 1 ); i++ ) // to represent element to be compared
|
||||
{
|
||||
for( j = ( i + 1 ); j < num; j++ ) // to represent the rest of the elements
|
||||
{
|
||||
float d1 = (float)(fabs(alt - clouds.get(i)->getElevation()));
|
||||
float d2 = (float)(fabs(alt - clouds.get(j)->getElevation()));
|
||||
|
||||
if (d1 < d2)
|
||||
// Sort clouds in order of distance from alt (furthest to closest)
|
||||
int i, j;
|
||||
int num = clouds.getNum ();
|
||||
if ( num > 0 )
|
||||
{
|
||||
temp = index[i];
|
||||
index[i] = index[j];
|
||||
index[j] = temp;
|
||||
// Initialise cloud index
|
||||
int *index = new int [ num ];
|
||||
for ( i = 0; i < num; i++ )
|
||||
{
|
||||
index [i] = i;
|
||||
}
|
||||
|
||||
// Sort cloud index
|
||||
int temp; // holding variable
|
||||
for ( i = 0; i < ( num - 1 ); i++ ) // to represent element to be compared
|
||||
{
|
||||
for( j = ( i + 1 ); j < num; j++ ) // to represent the rest of the elements
|
||||
{
|
||||
float d1 = (float)(fabs(alt - clouds.get(i)->getElevation()));
|
||||
float d2 = (float)(fabs(alt - clouds.get(j)->getElevation()));
|
||||
|
||||
if (d1 < d2)
|
||||
{
|
||||
temp = index[i];
|
||||
index[i] = index[j];
|
||||
index[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float slop = 5.0; // if we are closer than this to a cloud layer, don't draw cloud
|
||||
|
||||
for ( int i = 0; i < num; i++ )
|
||||
{
|
||||
cGrCloudLayer *cloud = clouds.get(index[i]);
|
||||
|
||||
float asl = cloud->getElevation();
|
||||
float thickness = cloud->getThickness();
|
||||
|
||||
// draw cloud only if below or above cloud layer
|
||||
if ( alt < asl - slop || alt > asl + thickness + slop )
|
||||
cloud->draw();
|
||||
}
|
||||
|
||||
delete [] index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float slop = 5.0; // if we are closer than this to a cloud layer, don't draw cloud
|
||||
|
||||
for ( int i = 0; i < num; i++ )
|
||||
{
|
||||
cGrCloudLayer *cloud = clouds.get(index[i]);
|
||||
|
||||
float asl = cloud->getElevation();
|
||||
float thickness = cloud->getThickness();
|
||||
|
||||
// draw cloud only if below or above cloud layer
|
||||
if ( alt < asl - slop || alt > asl + thickness + slop )
|
||||
cloud->draw();
|
||||
}
|
||||
|
||||
delete [] index;
|
||||
}
|
||||
}
|
||||
|
||||
void cGrSky::modifyVisibility( float alt, float time_factor )
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "grutil.h"
|
||||
#include "grSky.h"
|
||||
#include "grbackground.h"
|
||||
|
||||
#include "grMoonPos.h"
|
||||
|
||||
// Some exported constants.
|
||||
const tdble grSkyDomeNeutralFOVDistance = 20000.0f; // Not the smallest, a medium one.
|
||||
|
@ -54,13 +54,8 @@ static const sgVec4 Black = { 0.0f, 0.0f, 0.0f, 1.0f } ;
|
|||
static const sgVec4 White = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
static const sgVec4 TranslucentWhite = { 1.0f, 1.0f, 1.0f, 0.8f } ;
|
||||
|
||||
//static const sgVec4 BaseSkyColor = { 0.39f, 0.50f, 0.74f, 1.0f } ;
|
||||
static const sgVec4 BaseSkyColor = { 0.31f, 0.43f, 0.69f, 1.0f };
|
||||
|
||||
static const sgVec4 BaseAmbiant = { 0.35f, 0.35f, 0.40f, 1.0f } ;
|
||||
static const sgVec4 BaseDiffuse = { 0.80f, 0.80f, 0.80f, 1.0f } ;
|
||||
static const sgVec4 BaseSpecular = { 0.33f, 0.33f, 0.30f, 1.0f } ;
|
||||
|
||||
static int NStars = 0;
|
||||
static int NPlanets = 0;
|
||||
static int cloudsTextureIndex = 0;
|
||||
|
@ -97,7 +92,6 @@ static ssgBranch *SunAnchor = NULL;
|
|||
static ssgRoot *TheBackground = NULL;
|
||||
static ssgTransform *TheSun = NULL;
|
||||
|
||||
//static cGrCelestialBody *TheCelestBodies[NMaxCelestianBodies] = { NULL, NULL };
|
||||
static cGrSky *TheSky = NULL;
|
||||
|
||||
static sgdVec3 *AStarsData = NULL;
|
||||
|
@ -236,12 +230,14 @@ grInitBackground()
|
|||
timeOfDay / 3600, (timeOfDay % 3600) / 60, timeOfDay % 60,
|
||||
grSunDeclination, RAD2DEG(sunAscension));
|
||||
|
||||
if ( grSunDeclination > 180 )
|
||||
/*if ( grSunDeclination > 180 )
|
||||
grMoonDeclination = 3.0 + (rand() % 40);
|
||||
else
|
||||
grMoonDeclination = (rand() % 270);
|
||||
grMoonDeclination = (rand() % 270);*/
|
||||
|
||||
const float moonAscension = (float)(rand() % 360);
|
||||
grMoonDeclination = grUpdateMoonPos(timeOfDay);
|
||||
|
||||
const float moonAscension = grTrack->local.sunascension;
|
||||
|
||||
TheSky->setMD( DEG2RAD(grMoonDeclination) );
|
||||
TheSky->setMRA( DEG2RAD(moonAscension) );
|
||||
|
|
Loading…
Reference in a new issue