1 /**************************************************************************
2 * stars.c -- data structures and routines for managing and rendering stars.
4 * Written by Curtis Olson, started August 1997.
6 * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * (Log is kept at end of this file)
24 **************************************************************************/
39 #include "../general.h"
42 /* static struct STAR stars[FG_MAX_STARS]; */
46 /* Initialize the Star Management Subsystem */
49 struct general_params *g;
51 char line[256], name[256];
53 double right_ascension, declination, magnitude;
58 /* build the full path name to the stars data base file */
60 strcat(path, g->root_dir);
61 strcat(path, "/Scenery/");
62 strcat(path, "Stars.dat");
64 printf("Loading Stars: %s\n", path);
66 if ( (fd = fopen(path, "r")) == NULL ) {
67 printf("Cannot open star file: '%s'\n", path);
71 stars = glGenLists(1);
72 glNewList( stars, GL_COMPILE );
75 /* read in each line of the file */
77 while ( (fgets(line, 256, fd) != NULL) && (count < FG_MAX_STARS) ) {
80 /* advance to first non-whitespace character */
81 while ( (tmp_ptr[0] == ' ') || (tmp_ptr[0] == '\t') ) {
85 if ( tmp_ptr[0] == '#' ) {
87 } else if ( strlen(tmp_ptr) == 0 ) {
91 fscanf(fd, "%s %lf %lf %lf\n",
92 name, &right_ascension, &declination, &magnitude);
93 /* printf("Found star: %d %s, %.3f %.3f %.3f\n", count,
94 name, right_ascension, declination, magnitude); */
96 glColor3f( magnitude, magnitude, magnitude );
97 glVertex3f( 100.0 * sin(right_ascension) * cos(declination),
98 100.0 * cos(right_ascension) * cos(declination),
99 100.0 * sin(declination) );
101 } /* if valid line */
111 void fgStarsRender() {
117 /* Revision 1.1 1997/08/27 03:34:48 curt