Initial revision.
This commit is contained in:
parent
c8d2e72433
commit
57ae31aa50
2 changed files with 180 additions and 0 deletions
125
Scenery/astro.c
Normal file
125
Scenery/astro.c
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/**************************************************************************
|
||||||
|
* astro.c
|
||||||
|
*
|
||||||
|
* Written by Durk Talsma. Started November 1997, for use with the flight
|
||||||
|
* gear project.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* (Log is kept at end of this file)
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
#include "astro.h"
|
||||||
|
#include "moon.h"
|
||||||
|
#include "orbits.h"
|
||||||
|
#include "planets.h"
|
||||||
|
#include "stars.h"
|
||||||
|
#include "sun.h"
|
||||||
|
|
||||||
|
#include "../constants.h"
|
||||||
|
#include "../general.h"
|
||||||
|
|
||||||
|
#include "../Main/views.h"
|
||||||
|
#include "../Aircraft/aircraft.h"
|
||||||
|
#include "../Time/fg_time.h"
|
||||||
|
|
||||||
|
static double prevUpdate = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize Astronomical Objects */
|
||||||
|
void fgAstroInit() {
|
||||||
|
struct fgTIME *t;
|
||||||
|
t = &cur_time_params;
|
||||||
|
|
||||||
|
/* Initialize the orbital elements of sun, moon and mayor planets */
|
||||||
|
fgSolarSystemInit(*t);
|
||||||
|
|
||||||
|
/* Intialize the moon's position */
|
||||||
|
fgMoonInit();
|
||||||
|
|
||||||
|
/* Initialize the sun's position */
|
||||||
|
fgSunInit();
|
||||||
|
|
||||||
|
/* Initialize the Stars subsystem */
|
||||||
|
fgStarsInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Render Astronomical Objects */
|
||||||
|
void fgAstroRender() {
|
||||||
|
struct FLIGHT *f;
|
||||||
|
struct VIEW *v;
|
||||||
|
struct fgTIME *t;
|
||||||
|
double angle;
|
||||||
|
|
||||||
|
f = ¤t_aircraft.flight;
|
||||||
|
t = &cur_time_params;
|
||||||
|
v = ¤t_view;
|
||||||
|
|
||||||
|
/* a hack: Force sun and moon position to be updated on an hourly basis */
|
||||||
|
if (((t->gst - prevUpdate) > 1) || (t->gst < prevUpdate)) {
|
||||||
|
prevUpdate = t->gst;
|
||||||
|
fgSunInit();
|
||||||
|
fgMoonInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disable fog effects */
|
||||||
|
glDisable( GL_FOG );
|
||||||
|
|
||||||
|
/* reverse light direction so the moon is displayed properly */
|
||||||
|
glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec_inv );
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
/* Translate to view position */
|
||||||
|
glTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
|
||||||
|
|
||||||
|
/* Rotate based on gst (side real time) */
|
||||||
|
angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Rotating astro objects by %.2f degrees\n",angle);
|
||||||
|
#endif
|
||||||
|
glRotatef( angle, 0.0, 0.0, -1.0 );
|
||||||
|
|
||||||
|
/* render the stars */
|
||||||
|
fgStarsRender();
|
||||||
|
|
||||||
|
/* render the moon */
|
||||||
|
fgMoonRender();
|
||||||
|
|
||||||
|
/* render the sun */
|
||||||
|
fgSunRender();
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
/* reenable fog effects */
|
||||||
|
glEnable( GL_FOG );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* $Log$
|
||||||
|
/* Revision 1.1 1997/11/25 23:20:22 curt
|
||||||
|
/* Initial revision.
|
||||||
|
/*
|
||||||
|
*/
|
55
Scenery/astro.h
Normal file
55
Scenery/astro.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/**************************************************************************
|
||||||
|
* astro.h
|
||||||
|
*
|
||||||
|
* Written by Durk Talsma. Started November 1997, for use with the flight
|
||||||
|
* gear project.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* (Log is kept at end of this file)
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _ASTRO_H_
|
||||||
|
#define _ASTRO_H_
|
||||||
|
|
||||||
|
#include <GL/glut.h>
|
||||||
|
#include "stars.h"
|
||||||
|
|
||||||
|
extern struct CelestialCoord
|
||||||
|
moonPos;
|
||||||
|
|
||||||
|
extern float xMoon, yMoon, zMoon, xSun, ySun, zSun;
|
||||||
|
extern GLint moon, sun;
|
||||||
|
extern GLint stars[FG_STAR_LEVELS];
|
||||||
|
extern GLfloat fgClearColor[4];
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize Astronomical Objects */
|
||||||
|
void fgAstroInit();
|
||||||
|
|
||||||
|
/* Render Astronomical objects */
|
||||||
|
void fgAstroRender();
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _ASTRO_H_ */
|
||||||
|
|
||||||
|
|
||||||
|
/* $Log$
|
||||||
|
/* Revision 1.1 1997/11/25 23:20:23 curt
|
||||||
|
/* Initial revision.
|
||||||
|
/*
|
||||||
|
*/
|
Loading…
Add table
Reference in a new issue