Compare commits
172 Commits
RELEASE_0_
...
RELEASE_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fefaef31e | ||
|
|
689a942f19 | ||
|
|
cb9654f1f4 | ||
|
|
a8f8cef484 | ||
|
|
6cf51c3222 | ||
|
|
0d8ae0cabe | ||
|
|
49d6f93d8b | ||
|
|
5173d709e0 | ||
|
|
778c3ab25c | ||
|
|
aa17d9ac9a | ||
|
|
ffe1d9485e | ||
|
|
71abebe837 | ||
|
|
ca07b64af0 | ||
|
|
2fde2ce581 | ||
|
|
cb0da2ca5e | ||
|
|
c0422839b9 | ||
|
|
862b884f02 | ||
|
|
708e745cfd | ||
|
|
63c9dcdd96 | ||
|
|
770ec00901 | ||
|
|
4c6fe0328a | ||
|
|
bb882a1239 | ||
|
|
29e3a4e231 | ||
|
|
ca444b07bd | ||
|
|
510b9ef07a | ||
|
|
d59a6218ab | ||
|
|
5f26ba99bc | ||
|
|
8fcfb73a57 | ||
|
|
c9fb802b9e | ||
|
|
cbb1a37f5a | ||
|
|
42f9964e76 | ||
|
|
81c8f4c065 | ||
|
|
0703cb0027 | ||
|
|
2487e696b8 | ||
|
|
50227c435c | ||
|
|
256aaa362f | ||
|
|
2198498e29 | ||
|
|
46f79f17c8 | ||
|
|
ed870aac76 | ||
|
|
663964d94c | ||
|
|
8b1784e0d9 | ||
|
|
e6c07f088d | ||
|
|
6ef9ecdda0 | ||
|
|
aecea627e1 | ||
|
|
e2d428d8ba | ||
|
|
c0e1031a4a | ||
|
|
dea5eec440 | ||
|
|
23a8ff8a04 | ||
|
|
a3c95154f5 | ||
|
|
f9e52ea53d | ||
|
|
001a2c89e7 | ||
|
|
38631c9eb3 | ||
|
|
07e9467507 | ||
|
|
a9d109b3ce | ||
|
|
5cbbd7a14e | ||
|
|
424ef2f6e9 | ||
|
|
26a6fa864d | ||
|
|
01327ebd4c | ||
|
|
23be422477 | ||
|
|
1f47fbafff | ||
|
|
19f58936a8 | ||
|
|
0e7c76a38f | ||
|
|
193092ed67 | ||
|
|
ec8667a63c | ||
|
|
554581b099 | ||
|
|
31b3f10cc8 | ||
|
|
bbfd2f802b | ||
|
|
b7c12ea879 | ||
|
|
453b041f0d | ||
|
|
e45190bee4 | ||
|
|
e9ee8471a9 | ||
|
|
854bc45e59 | ||
|
|
4066df3229 | ||
|
|
7710f8f076 | ||
|
|
2dd9bcbd50 | ||
|
|
b6b93c74ea | ||
|
|
c68a524d35 | ||
|
|
3af8529843 | ||
|
|
798ae43c84 | ||
|
|
8a8bb3cf7e | ||
|
|
df79de455f | ||
|
|
978226a275 | ||
|
|
0c5a60713d | ||
|
|
20cf326fec | ||
|
|
3e386f51a1 | ||
|
|
28e2a0560c | ||
|
|
9797633e5c | ||
|
|
b6184dcf29 | ||
|
|
f28bfa6d62 | ||
|
|
f1f01451cc | ||
|
|
cb1bcb398a | ||
|
|
0e53f221cf | ||
|
|
1413fae16c | ||
|
|
fa9d78ffb6 | ||
|
|
327ccd93a4 | ||
|
|
24b5f05d5e | ||
|
|
ccc3af8937 | ||
|
|
b6b503a190 | ||
|
|
fdda5da598 | ||
|
|
86e571f18b | ||
|
|
7b3b55f6ef | ||
|
|
6b2bf2fa8e | ||
|
|
2640b43355 | ||
|
|
d201e9b5c5 | ||
|
|
8f0f79506c | ||
|
|
121d2f92cb | ||
|
|
87e641aeda | ||
|
|
27403e2fef | ||
|
|
b5ceef5e68 | ||
|
|
5d68470c95 | ||
|
|
e176b4d8b6 | ||
|
|
218821f694 | ||
|
|
a8f4a61dc2 | ||
|
|
9221604424 | ||
|
|
5bddbd0ca9 | ||
|
|
f8dde93e05 | ||
|
|
489b562232 | ||
|
|
294a0dde63 | ||
|
|
53fbb98d4f | ||
|
|
8a2c08a0c1 | ||
|
|
b15b40ea10 | ||
|
|
0c865f540f | ||
|
|
ef4a92859c | ||
|
|
2a7b06f648 | ||
|
|
6c2ca22b3f | ||
|
|
592690f8f2 | ||
|
|
1eb87e7c73 | ||
|
|
a0e40c1fc1 | ||
|
|
2c920ae1df | ||
|
|
bbde3b36bf | ||
|
|
88a016c516 | ||
|
|
22d4058564 | ||
|
|
79e6c529ea | ||
|
|
7b22b8cd92 | ||
|
|
bc2ae82e81 | ||
|
|
764f4037b0 | ||
|
|
a60454a786 | ||
|
|
d136ad3e57 | ||
|
|
739588f9c3 | ||
|
|
0363628a55 | ||
|
|
f2e7704853 | ||
|
|
66651d0648 | ||
|
|
5909595442 | ||
|
|
bf92d30877 | ||
|
|
9bd9645b3e | ||
|
|
5c5e4fff7b | ||
|
|
de235cc8be | ||
|
|
e4890297a6 | ||
|
|
13d4d0777f | ||
|
|
982d714749 | ||
|
|
4c18fbcafd | ||
|
|
37ec7421aa | ||
|
|
d289222b39 | ||
|
|
ad2947e407 | ||
|
|
41f441bdde | ||
|
|
e24203fb2f | ||
|
|
5997339730 | ||
|
|
b54a4d1f92 | ||
|
|
8f7a446ec8 | ||
|
|
3304526093 | ||
|
|
f711a02a62 | ||
|
|
5b779f5200 | ||
|
|
5bf6d83d2d | ||
|
|
7ea54d28cd | ||
|
|
268a59d0a9 | ||
|
|
9477aad950 | ||
|
|
8feb45fa72 | ||
|
|
b6f07f3058 | ||
|
|
5730a47b00 | ||
|
|
3c35a317d4 | ||
|
|
0c270d61d8 | ||
|
|
1b14d43341 |
139
Audio/CHANGES
139
Audio/CHANGES
@@ -1,139 +0,0 @@
|
||||
|
||||
/**********************************************\
|
||||
* *
|
||||
* W A R N I N G *
|
||||
* *
|
||||
* This file is now kept in reverse chronolog- *
|
||||
* ical order so recent changes are now at the *
|
||||
* top. *
|
||||
* *
|
||||
\**********************************************/
|
||||
|
||||
* 28th Sept 1889 -- Fixed a bug associated with exiting the
|
||||
program with sounds still playing.
|
||||
Fixed a bug associated with using the
|
||||
package in the absence of a sound card.
|
||||
Added a new member function "working"
|
||||
which is the opposite of "not_working",
|
||||
(as demanded by a bunch of rabid optimists)!
|
||||
Fixed a couple of typo's in the manual.
|
||||
|
||||
* 23rd Sept 1998 -- The Good News: Finally got around to
|
||||
getting the pitch envelope working. (Hooray)
|
||||
The Bad News: This costs quite a bit in
|
||||
performance - and it was a MAJOR rewrite
|
||||
of significant parts of the internals,
|
||||
so we may need some bug fixes.
|
||||
This version is 0.5
|
||||
|
||||
* 7th July 1998 -- Fixed some error checking in slSample.cxx and
|
||||
a missing declaration in sl.h
|
||||
|
||||
* 6th July 1998 -- Fixed an initialisation problem when
|
||||
slScheduler was not a static/global.
|
||||
|
||||
Tom Knienieder's port to SGI/IRIX is now
|
||||
working, documentation updated to reflect that.
|
||||
|
||||
* 16th June 1998 -- Added some slPortability.h fixes for
|
||||
FreeBSD and the Cygnus WIN32 compiler.
|
||||
Many thanks to Curt.
|
||||
|
||||
* 14th June 1998 -- Tom Knienieder's port to OpenBSD is now
|
||||
working, documentation updated to reflect that.
|
||||
Tom's improved Makefiles included, also some
|
||||
example sound samples that were accidentally
|
||||
left out of the release are now present.
|
||||
A couple of typo's in the WIN32 section
|
||||
have been fixed. The top level Makefile
|
||||
now requires you to type 'make linux',
|
||||
'make win' or 'make openbsd'.
|
||||
|
||||
* 13th June 1998 -- Tom Knienieder's port to WIN32 engine is now
|
||||
working, documentation updated to reflect that
|
||||
revised status. Some default constructor parameters
|
||||
have changed, slDSP no longer supports setRate/setBps/setStereo.
|
||||
You now have to delete the slDSP and recreate it with
|
||||
new parameters. This makes porting a little easier.
|
||||
'sound_test' renamed 'example'.
|
||||
|
||||
* 7th June 1998 -- Volume envelopes (and inverse volume envelopes)
|
||||
now work correctly. Pan envelopes won't work
|
||||
until stereo is implemented. Pitch and filter
|
||||
envelopes turn out to be a major pain to implement
|
||||
with the present slSceduler/slSamplePlayer interface,
|
||||
so some significant internal changes are to be
|
||||
expected.
|
||||
|
||||
Changed the CHANGES file to be in reverse
|
||||
chronological order.
|
||||
|
||||
This version is officially SL v0.3 (beta)
|
||||
|
||||
* 3rd June 1998 -- Moved sample program and it's data files into
|
||||
'example', moved documents into 'doc' and sources
|
||||
into 'src'. Final library goes into 'lib'.
|
||||
|
||||
The entire preempting mechanism was broken -
|
||||
now it's fixed.
|
||||
|
||||
Added a callback mechanism that allows
|
||||
applications to know when a sound
|
||||
loops, finishes playing, is pre-empted, etc.
|
||||
|
||||
New mechanisms added to stop/pause/resume a
|
||||
playing sample.
|
||||
|
||||
All the documentation - and some of the code -
|
||||
for slEnvelopes has been added, they don't
|
||||
work yet - so don't bother with them for now.
|
||||
|
||||
Made some code a little more bullet-proof.
|
||||
slSample's are now reference-counted so you
|
||||
can't accidentally delete one while it's
|
||||
playing without getting a FATAL error.
|
||||
|
||||
* 2nd June 1998 -- Fixed bug in initialisation that prevented SL
|
||||
from functioning correctly in the case were there
|
||||
is no sound card present.
|
||||
|
||||
This version is officially SL v0.2 (beta)
|
||||
|
||||
* 1st June 1998 -- Split library into two parts - libsm and
|
||||
libsl. libsm contains only the Mixer class
|
||||
since it is likely to be hard to port to
|
||||
a lot of non-OSS systems - and most programs
|
||||
won't need it anyway. Hence the documentation
|
||||
has blossomed into three files and all the
|
||||
'slMixer' references have turned into 'smMixer'.
|
||||
Also, I finally got a hold of the OSS documentation,
|
||||
which is a lot more complete - and straightened
|
||||
me out on a few points. slDSP has changed
|
||||
(internally) somewhat as a result and in particular,
|
||||
you can no longer mess with the sampling rate,
|
||||
stereo and bps settings after the slDSP or
|
||||
slScheduler has been created. This also allows the
|
||||
scheduler to enforce it's rule about only mono/8bps
|
||||
operations.
|
||||
|
||||
I also added an 'autoMatch' function to the slSample
|
||||
class to automagically match incoming samples to the
|
||||
current slDSP/slScheduler. This makes using the library
|
||||
a lot less painful and error-prone.
|
||||
|
||||
This version is officially SL v0.1 (beta)
|
||||
|
||||
We need a better name!
|
||||
|
||||
* 30th May 1998 -- Almost total rewrite, library can now
|
||||
play multiple sounds without interruption,
|
||||
supports '.WAV' and '.AU' file formats as
|
||||
well as raw binary files. Able to copy with
|
||||
much shorter safetyMargin on sound buffers,
|
||||
and play without using the 'stop' call.
|
||||
All class and external symbols now begin
|
||||
with 'sl' or 'SL'. HTML documentation now
|
||||
available.
|
||||
|
||||
* 27th May 1998 -- First hack
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
SUBDIRS = src example
|
||||
@@ -1,9 +0,0 @@
|
||||
NOTICE: This Sound Library (SL) distribution contains source code that is
|
||||
placed into the public domain without copyright. These programs are freely
|
||||
distributable without licensing fees. These programs are provided without
|
||||
guarantee or warrantee expressed or implied.
|
||||
|
||||
If you use SL in a commercial or shareware product, it would be nice if you
|
||||
gave credit where it is due. If you make any modifications or improvements
|
||||
to SL, I would greatly appreciate a copy of the improved code.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
Hi!
|
||||
|
||||
This is the fifth prototype of Steve's 'SL' sound library.
|
||||
|
||||
Check out 'CHANGES' and the new HTML documentation.
|
||||
|
||||
Steve
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
Building SL for Linux.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
% make freebsd
|
||||
% su root
|
||||
% make install
|
||||
|
||||
...that's all folks.
|
||||
|
||||
Header files go into /usr/include/SL (analogous to /usr/include/GL for graphics)
|
||||
Library file(s) go into /usr/lib
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
Building SL for Linux.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
% make linux
|
||||
% su root
|
||||
% make install
|
||||
|
||||
...that's all folks.
|
||||
|
||||
Header files go into /usr/include/SL (analogous to /usr/include/GL for graphics)
|
||||
Library file(s) go into /usr/lib
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
Building SL for OpenBSD.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
% make openbsd
|
||||
% su root
|
||||
% make install
|
||||
|
||||
...that's all folks.
|
||||
|
||||
Header files go into /usr/include/SL (analogous to /usr/include/GL for graphics)
|
||||
Library file(s) go into /usr/lib
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
Building SL for SGI.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
There are two options, depending on whether you want to use GCC or
|
||||
the standard SGI C++ compiler.
|
||||
|
||||
GNU G++:
|
||||
|
||||
% make sgigcc
|
||||
% su root
|
||||
% make install
|
||||
|
||||
SGI C++:
|
||||
|
||||
% make sgi
|
||||
% su root
|
||||
% make install
|
||||
|
||||
...that's all folks.
|
||||
|
||||
Header files go into /usr/include/SL (analogous to /usr/include/GL for graphics)
|
||||
Library file(s) go into /usr/lib
|
||||
|
||||
When you link, be sure to include to -laudio
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
Building SL for UNIX
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If your UNIX box is Linux or OpenBSD then
|
||||
check out README.linux or README.openbsd.
|
||||
|
||||
If your UNIX box supports OSS (the Open
|
||||
Sound System) then in principal, you should
|
||||
only need to type:
|
||||
|
||||
% make oss
|
||||
% su root
|
||||
% make install
|
||||
|
||||
...however, your milage may vary. If you succeed
|
||||
in getting a non-Linux, non-OpenBSD version to
|
||||
work, I'd like to hear about it.
|
||||
|
||||
Steve Baker <sjbaker1@airmail.net>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
Building SL for win32 (msvc)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
C:>nmake win32
|
||||
|
||||
|
||||
don't forget to set the environment !
|
||||
|
||||
example:
|
||||
|
||||
set include=c:\msdev\include;
|
||||
set lib=c:\msdev\lib
|
||||
|
||||
path c:\msdev\bin;c:\bin;c:\winnt;......
|
||||
@@ -1,12 +0,0 @@
|
||||
noinst_LIBRARIES = libBucket.a
|
||||
|
||||
libBucket_a_SOURCES = bucketutils.c bucketutils.h bucketutils.hxx \
|
||||
newbucket.cxx newbucket.hxx
|
||||
|
||||
bin_PROGRAMS = testbucket
|
||||
|
||||
testbucket_SOURCES = testbucket.cxx
|
||||
|
||||
testbucket_LDADD = $(top_builddir)/Lib/Bucket/libBucket.a
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
@@ -1,326 +0,0 @@
|
||||
// bucketutils.c -- support routines to handle fgBUCKET operations
|
||||
//
|
||||
// Written by Curtis Olson, started January 1998.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// 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 <Include/fg_constants.h>
|
||||
|
||||
#include "bucketutils.h"
|
||||
|
||||
|
||||
/* Generate the unique scenery tile index containing the specified
|
||||
lon/lat parameters.
|
||||
|
||||
The index is constructed as follows:
|
||||
|
||||
9 bits - to represent 360 degrees of longitude (-180 to 179)
|
||||
8 bits - to represent 180 degrees of latitude (-90 to 89)
|
||||
|
||||
Each 1 degree by 1 degree tile is further broken down into an 8x8
|
||||
grid. So we also need:
|
||||
|
||||
3 bits - to represent x (0 to 7)
|
||||
3 bits - to represent y (0 to 7) */
|
||||
long int fgBucketGenIndex( const fgBUCKET *p) {
|
||||
long index = 0;
|
||||
|
||||
index = ((p->lon + 180) << 14) + ((p->lat + 90) << 6) + (p->y << 3) + p->x;
|
||||
// printf(" generated index = %ld\n", index);
|
||||
|
||||
return(index);
|
||||
}
|
||||
|
||||
|
||||
// Parse a unique scenery tile index and find the lon, lat, x, and y
|
||||
void fgBucketParseIndex(long int index, fgBUCKET *p) {
|
||||
p->lon = index >> 14;
|
||||
index -= p->lon << 14;
|
||||
p->lon -= 180;
|
||||
|
||||
p->lat = index >> 6;
|
||||
index -= p->lat << 6;
|
||||
p->lat -= 90;
|
||||
|
||||
p->y = index >> 3;
|
||||
index -= p->y << 3;
|
||||
|
||||
p->x = index;
|
||||
}
|
||||
|
||||
|
||||
// Build a path name from an tile index
|
||||
void fgBucketGenBasePath( const fgBUCKET *p, char *path) {
|
||||
long int index;
|
||||
int top_lon, top_lat, main_lon, main_lat;
|
||||
char hem, pole;
|
||||
|
||||
index = fgBucketGenIndex(p);
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
top_lon = p->lon / 10;
|
||||
main_lon = p->lon;
|
||||
if ( (p->lon < 0) && (top_lon * 10 != p->lon) ) {
|
||||
top_lon -= 1;
|
||||
}
|
||||
top_lon *= 10;
|
||||
if ( top_lon >= 0 ) {
|
||||
hem = 'e';
|
||||
} else {
|
||||
hem = 'w';
|
||||
top_lon *= -1;
|
||||
}
|
||||
if ( main_lon < 0 ) {
|
||||
main_lon *= -1;
|
||||
}
|
||||
|
||||
top_lat = p->lat / 10;
|
||||
main_lat = p->lat;
|
||||
if ( (p->lat < 0) && (top_lat * 10 != p->lat) ) {
|
||||
top_lat -= 1;
|
||||
}
|
||||
top_lat *= 10;
|
||||
if ( top_lat >= 0 ) {
|
||||
pole = 'n';
|
||||
} else {
|
||||
pole = 's';
|
||||
top_lat *= -1;
|
||||
}
|
||||
if ( main_lat < 0 ) {
|
||||
main_lat *= -1;
|
||||
}
|
||||
|
||||
sprintf(path, "%c%03d%c%03d/%c%03d%c%03d",
|
||||
hem, top_lon, pole, top_lat,
|
||||
hem, main_lon, pole, main_lat);
|
||||
}
|
||||
|
||||
|
||||
// offset an bucket struct by the specified amounts in the X & Y direction
|
||||
void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
|
||||
int diff, temp;
|
||||
int dist_lat;
|
||||
|
||||
out->lon = in->lon;
|
||||
out->lat = in->lat;
|
||||
out->x = in->x;
|
||||
out->y = in->y;
|
||||
|
||||
// do X direction
|
||||
diff = out->x + x;
|
||||
// printf(" reducing x (%d)\n", diff);
|
||||
if ( diff >= 0 ) {
|
||||
temp = diff / 8;
|
||||
} else if ( diff < -7 ) {
|
||||
temp = (diff + 1) / 8 - 1;
|
||||
} else {
|
||||
temp = diff / 8 - 1;
|
||||
}
|
||||
out->x = ((diff % 8) + 8) % 8;
|
||||
out->lon = ( (out->lon + 180 + 360 + temp) % 360 ) - 180;
|
||||
|
||||
// do Y direction
|
||||
diff = out->y + y;
|
||||
// printf(" reducing x (%d)\n", diff);
|
||||
if ( diff >= 0 ) {
|
||||
temp = diff / 8;
|
||||
} else if ( diff < -7 ) {
|
||||
temp = (diff + 1) / 8 - 1;
|
||||
} else {
|
||||
temp = diff / 8 - 1;
|
||||
}
|
||||
out->y = ((diff % 8) + 8) % 8;
|
||||
out->lat = out->lat + temp;
|
||||
|
||||
if ( out->lat >= 90 ) {
|
||||
dist_lat = out->lat - 90;
|
||||
// printf(" +lat = %d +y = %d\n", dist_lat, out->y);
|
||||
|
||||
out->lat = 90 - (dist_lat + 1);
|
||||
out->lon = ( (out->lon + 180 + 180) % 360 ) - 180;
|
||||
out->y = 7 - out->y;
|
||||
}
|
||||
|
||||
if ( out->lat < -90 ) {
|
||||
dist_lat = -90 - out->lat;
|
||||
// printf(" +lat = %d +y = %d\n", dist_lat, out->y);
|
||||
|
||||
out->lat = -90 + (dist_lat - 1);
|
||||
out->lon = ( (out->lon + 180 + 180) % 360 ) - 180;
|
||||
out->y = 7 - out->y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Given a lat/lon in degrees, find the "bucket" or tile that it falls
|
||||
// within
|
||||
void fgBucketFind(double lon, double lat, fgBUCKET *p) {
|
||||
double diff;
|
||||
|
||||
diff = lon - (double)(int)lon;
|
||||
// printf("diff = %.2f\n", diff);
|
||||
if ( (lon >= 0) || (fabs(diff) < FG_EPSILON) ) {
|
||||
p->lon = (int)lon;
|
||||
} else {
|
||||
p->lon = (int)lon - 1;
|
||||
}
|
||||
// printf(" p->lon = %d\n", p->lon);
|
||||
|
||||
diff = lat - (double)(int)lat;
|
||||
// printf("diff = %.2f\n", diff);
|
||||
if ( (lat >= 0) || (fabs(diff) < FG_EPSILON) ) {
|
||||
p->lat = (int)lat;
|
||||
} else {
|
||||
p->lat = (int)lat - 1;
|
||||
}
|
||||
// printf(" p->lat = %d\n", p->lat);
|
||||
|
||||
p->x = (int)((lon - p->lon) * 8);
|
||||
p->y = (int)((lat - p->lat) * 8);
|
||||
// printf( "Bucket = lon,lat = %d,%d x,y index = %d,%d\n",
|
||||
// p->lon, p->lat, p->x, p->y);
|
||||
}
|
||||
|
||||
|
||||
// Given a lat/lon, fill in the local tile index array
|
||||
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height) {
|
||||
fgBUCKET *p2;
|
||||
int dw, dh, i, j;
|
||||
|
||||
dh = height / 2;
|
||||
dw = width / 2;
|
||||
for ( j = 0; j < height; j++ ) {
|
||||
for ( i = 0; i < width; i++ ) {
|
||||
fgBucketOffset(p1, &tiles[(j*width)+i], i - dw, j - dh);
|
||||
p2 = &tiles[(j*width)+i];
|
||||
/* printf( " bucket = %d %d %d %d index = %ld\n",
|
||||
p2->lon, p2->lat, p2->x, p2->y,
|
||||
fgBucketGenIndex(&tiles[(j*width)+i])); */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* sample main for testing
|
||||
int main() {
|
||||
fgBUCKET p1;
|
||||
long int tile[49];
|
||||
char path[256];
|
||||
double lon, lat;
|
||||
int i, j;
|
||||
|
||||
p1.lon = 180;
|
||||
p1.lat = 90;
|
||||
p1.x = 7;
|
||||
p1.y = 7;
|
||||
|
||||
printf("Max index = %ld\n", gen_index(&p1));
|
||||
|
||||
lon = -50.0;
|
||||
lat = -50.0;
|
||||
find_bucket(lon, lat, &p1);
|
||||
gen_idx_array(&p1, tile, 7, 7);
|
||||
for ( j = 0; j < 7; j++ ) {
|
||||
for ( i = 0; i < 7; i++ ) {
|
||||
gen_path(tile[(j*7)+i], path);
|
||||
printf(" path = %s\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
lon = 50.0;
|
||||
lat = 50.0;
|
||||
find_bucket(lon, lat, &p1);
|
||||
gen_idx_array(&p1, tile, 7, 7);
|
||||
for ( j = 0; j < 7; j++ ) {
|
||||
for ( i = 0; i < 7; i++ ) {
|
||||
gen_path(tile[(j*7)+i], path);
|
||||
printf(" path = %s\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
return(1);
|
||||
} */
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.5 1998/12/09 18:48:08 curt
|
||||
// Use C++ style comments.
|
||||
//
|
||||
// Revision 1.4 1998/12/07 21:08:01 curt
|
||||
// Added a const in a couple places to get rid of annoying compiler warnings.
|
||||
//
|
||||
// Revision 1.3 1998/07/04 00:46:47 curt
|
||||
// typedef'd struct fgBUCKET.
|
||||
//
|
||||
// Revision 1.2 1998/04/25 22:06:22 curt
|
||||
// Edited cvs log messages in source files ... bad bad bad!
|
||||
//
|
||||
// Revision 1.1 1998/04/08 23:28:58 curt
|
||||
// Adopted Gnu automake/autoconf system.
|
||||
//
|
||||
// Revision 1.6 1998/02/09 15:07:51 curt
|
||||
// Minor tweaks.
|
||||
//
|
||||
// Revision 1.5 1998/01/29 00:51:38 curt
|
||||
// First pass at tile cache, dynamic tile loading and tile unloading now works.
|
||||
//
|
||||
// Revision 1.4 1998/01/27 03:26:41 curt
|
||||
// Playing with new fgPrintf command.
|
||||
//
|
||||
// Revision 1.3 1998/01/27 00:48:01 curt
|
||||
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||
// system and commandline/config file processing code.
|
||||
//
|
||||
// Revision 1.2 1998/01/24 00:03:28 curt
|
||||
// Initial revision.
|
||||
//
|
||||
// Revision 1.1 1998/01/23 20:06:51 curt
|
||||
// tileutils.* renamed to bucketutils.*
|
||||
//
|
||||
// Revision 1.6 1998/01/19 19:27:18 curt
|
||||
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
// This should simplify things tremendously.
|
||||
//
|
||||
// Revision 1.5 1998/01/14 02:19:04 curt
|
||||
// Makde offset_bucket visible to outside.
|
||||
//
|
||||
// Revision 1.4 1998/01/13 00:23:12 curt
|
||||
// Initial changes to support loading and management of scenery tiles. Note,
|
||||
// there's still a fair amount of work left to be done.
|
||||
//
|
||||
// Revision 1.3 1998/01/10 00:01:47 curt
|
||||
// Misc api changes and tweaks.
|
||||
//
|
||||
// Revision 1.2 1998/01/08 02:22:28 curt
|
||||
// Continue working on basic features.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 23:50:52 curt
|
||||
// "area" renamed to "tile"
|
||||
//
|
||||
// Revision 1.1 1998/01/07 23:23:40 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
// bucketutils.h -- support routines to handle fgBUCKET operations
|
||||
//
|
||||
// Written by Curtis Olson, started January 1998.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// 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 _BUCKETUTILS_H
|
||||
#define _BUCKETUTILS_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int lon; // longitude (-180 to 179)
|
||||
int lat; // latitude (-90 to 89)
|
||||
int x; // x (0 to 7)
|
||||
int y; // y (0 to 7)
|
||||
} fgBUCKET;
|
||||
|
||||
|
||||
/* Generate the unique scenery tile index containing the specified
|
||||
lon/lat parameters.
|
||||
|
||||
The index is constructed as follows:
|
||||
|
||||
9 bits - to represent 360 degrees of longitude (-180 to 179)
|
||||
8 bits - to represent 180 degrees of latitude (-90 to 89)
|
||||
|
||||
Each 1 degree by 1 degree tile is further broken down into an 8x8
|
||||
grid. So we also need:
|
||||
|
||||
3 bits - to represent x (0 to 7)
|
||||
3 bits - to represent y (0 to 7) */
|
||||
long int fgBucketGenIndex( const fgBUCKET *p);
|
||||
|
||||
|
||||
// Parse a unique scenery tile index and find the lon, lat, x, and y
|
||||
void fgBucketParseIndex(long int index, fgBUCKET *p);
|
||||
|
||||
|
||||
// Build a path name from an tile index
|
||||
void fgBucketGenBasePath( const fgBUCKET *p, char *path);
|
||||
|
||||
|
||||
// offset a bucket struct by the specified amounts in the X & Y direction
|
||||
void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y);
|
||||
|
||||
|
||||
// Given a lat/lon in degrees, find the "bucket" or tile that it falls
|
||||
// within
|
||||
void fgBucketFind(double lon, double lat, fgBUCKET *p);
|
||||
|
||||
|
||||
// Given a lat/lon, fill in the local tile index array
|
||||
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _BUCKETUTILS_H
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.5 1999/02/08 23:52:15 curt
|
||||
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
||||
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
||||
// width towards the poles to ensure the tiles are at least 8 miles wide.
|
||||
//
|
||||
// Revision 1.4 1998/12/09 18:48:09 curt
|
||||
// Use C++ style comments.
|
||||
//
|
||||
// Revision 1.3 1998/12/07 21:08:03 curt
|
||||
// Added a const in a couple places to get rid of annoying compiler warnings.
|
||||
//
|
||||
// Revision 1.2 1998/07/04 00:46:48 curt
|
||||
// typedef'd struct fgBUCKET.
|
||||
//
|
||||
// Revision 1.1 1998/04/08 23:28:59 curt
|
||||
// Adopted Gnu automake/autoconf system.
|
||||
//
|
||||
// Revision 1.2 1998/01/24 00:03:28 curt
|
||||
// Initial revision.
|
||||
//
|
||||
// Revision 1.1 1998/01/23 20:06:52 curt
|
||||
// tileutils.* renamed to bucketutils.*
|
||||
//
|
||||
// Revision 1.6 1998/01/22 02:59:42 curt
|
||||
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||
//
|
||||
// Revision 1.5 1998/01/14 02:19:05 curt
|
||||
// Makde offset_bucket visible to outside.
|
||||
//
|
||||
// Revision 1.4 1998/01/13 00:23:12 curt
|
||||
// Initial changes to support loading and management of scenery tiles. Note,
|
||||
// there's still a fair amount of work left to be done.
|
||||
//
|
||||
// Revision 1.3 1998/01/10 00:01:48 curt
|
||||
// Misc api changes and tweaks.
|
||||
//
|
||||
// Revision 1.2 1998/01/08 02:22:28 curt
|
||||
// Continue working on basic features.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 23:50:52 curt
|
||||
// "area" renamed to "tile"
|
||||
//
|
||||
// Revision 1.1 1998/01/07 23:23:40 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/**************************************************************************
|
||||
* bucketutils.hxx -- support routines to handle fgBUCKET operations
|
||||
*
|
||||
* Written by Bernie Bright, started January 1998.
|
||||
*
|
||||
* Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
|
||||
*
|
||||
* 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 _BUCKETUTILS_HXX
|
||||
#define _BUCKETUTILS_HXX
|
||||
|
||||
#include <string>
|
||||
|
||||
FG_USING_NAMESPACE(std);
|
||||
|
||||
#include "bucketutils.h"
|
||||
|
||||
#include <Include/compiler.h>
|
||||
FG_USING_STD(string);
|
||||
|
||||
inline bool
|
||||
operator== ( const fgBUCKET& b1, const fgBUCKET& b2 )
|
||||
{
|
||||
return ( b1.lon == b2.lon &&
|
||||
b1.lat == b2.lat &&
|
||||
b1.x == b2.x &&
|
||||
b1.y == b2.y );
|
||||
}
|
||||
|
||||
inline string
|
||||
fgBucketGenIndex( const fgBUCKET& p )
|
||||
{
|
||||
char index_str[256];
|
||||
sprintf( index_str, "%ld", fgBucketGenIndex( &p ) );
|
||||
return string( index_str );
|
||||
}
|
||||
|
||||
inline string
|
||||
fgBucketGenBasePath( const fgBUCKET& p )
|
||||
{
|
||||
char base_path[256];
|
||||
fgBucketGenBasePath( &p, base_path );
|
||||
return string( base_path );
|
||||
}
|
||||
|
||||
inline ostream&
|
||||
operator<< ( ostream& out, const fgBUCKET& b )
|
||||
{
|
||||
return out << b.lon << "," << b.lat << " " << b.x << "," << b.y;
|
||||
}
|
||||
|
||||
#endif /* _BUCKETUTILS_HXX */
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1999/01/19 20:56:53 curt
|
||||
// MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
|
||||
//
|
||||
// Revision 1.1 1998/11/09 23:42:12 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// test new bucket routines
|
||||
|
||||
#include "newbucket.cxx"
|
||||
|
||||
main() {
|
||||
double lat = 21.9625;
|
||||
double lon = -110.0 + 0.0625;
|
||||
|
||||
/*
|
||||
while ( lon < 180 ) {
|
||||
FGBucket b1( lon, lat );
|
||||
long int index = b1.gen_index();
|
||||
FGBucket b2( index );
|
||||
|
||||
cout << lon << "," << lat << " ";
|
||||
cout << b2 << " " << b2.get_center_lon() << ","
|
||||
<< b2.get_center_lat() << endl;
|
||||
|
||||
lon += 0.125;
|
||||
}
|
||||
*/
|
||||
|
||||
FGBucket b1;
|
||||
|
||||
for ( int j = 2; j >= -2; j-- ) {
|
||||
for ( int i = -2; i < 3; i++ ) {
|
||||
b1 = fgBucketOffset(lon, lat, i, j);
|
||||
cout << "(" << i << "," << j << ")" << b1 << "\t";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# The "checkoutlist" file is used to support additional version controlled
|
||||
# administrative files in $CVSROOT/CVSROOT, such as template files.
|
||||
#
|
||||
# The first entry on a line is a filename which will be checked out from
|
||||
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
|
||||
# The remainder of the line is an error message to use if the file cannot
|
||||
# be checked out.
|
||||
#
|
||||
# File format:
|
||||
#
|
||||
# [<whitespace>]<filename><whitespace><error message><end-of-line>
|
||||
#
|
||||
# comment lines begin with '#'
|
||||
@@ -1,15 +0,0 @@
|
||||
# The "commitinfo" file is used to control pre-commit checks.
|
||||
# The filter on the right is invoked with the repository and a list
|
||||
# of files to check. A non-zero exit of the filter program will
|
||||
# cause the commit to be aborted.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being committed to, relative
|
||||
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||
# of the line is the name of the filter to run.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
@@ -1,22 +0,0 @@
|
||||
# This file describes wrappers and other binary files to CVS.
|
||||
#
|
||||
# Wrappers are the concept where directories of files are to be
|
||||
# treated as a single file. The intended use is to wrap up a wrapper
|
||||
# into a single tar such that the tar archive can be treated as a
|
||||
# single binary file in CVS.
|
||||
#
|
||||
# To solve the problem effectively, it was also necessary to be able to
|
||||
# prevent rcsmerge from merging these files.
|
||||
#
|
||||
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
|
||||
#
|
||||
# wildcard [option value][option value]...
|
||||
#
|
||||
# where option is one of
|
||||
# -f from cvs filter value: path to filter
|
||||
# -t to cvs filter value: path to filter
|
||||
# -m update methodology value: MERGE or COPY
|
||||
#
|
||||
# and value is a single-quote delimited value.
|
||||
#
|
||||
# For example:
|
||||
@@ -1,21 +0,0 @@
|
||||
# The "editinfo" file is used to allow verification of logging
|
||||
# information. It works best when a template (as specified in the
|
||||
# rcsinfo file) is provided for the logging procedure. Given a
|
||||
# template with locations for, a bug-id number, a list of people who
|
||||
# reviewed the code before it can be checked in, and an external
|
||||
# process to catalog the differences that were code reviewed, the
|
||||
# following test can be applied to the code:
|
||||
#
|
||||
# Making sure that the entered bug-id number is correct.
|
||||
# Validating that the code that was reviewed is indeed the code being
|
||||
# checked in (using the bug-id number or a seperate review
|
||||
# number to identify this particular code set.).
|
||||
#
|
||||
# If any of the above test failed, then the commit would be aborted.
|
||||
#
|
||||
# Actions such as mailing a copy of the report to each reviewer are
|
||||
# better handled by an entry in the loginfo file.
|
||||
#
|
||||
# One thing that should be noted is the the ALL keyword is not
|
||||
# supported. There can be only one entry that matches a given
|
||||
# repository.
|
||||
@@ -1,19 +0,0 @@
|
||||
# The "loginfo" file is used to control where "cvs commit" log information is
|
||||
# sent. The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being made to, relative to the
|
||||
# $CVSROOT. For the first match that is found, the remainder of the line is a
|
||||
# filter program that should expect log information on its standard input
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in the
|
||||
# first field of this file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
#
|
||||
# The filter program may use one and only one "%s" modifier (ala printf). If
|
||||
# such a "%s" is specified in the filter program, a brief title is included
|
||||
# (as one argument, enclosed in single quotes) showing the relative directory
|
||||
# name and listing the modified file names.
|
||||
#
|
||||
# For example:
|
||||
#DEFAULT (echo ""; who am i; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
|
||||
@@ -1,26 +0,0 @@
|
||||
# Three different line formats are valid:
|
||||
# key -a aliases...
|
||||
# key [options] directory
|
||||
# key [options] directory files...
|
||||
#
|
||||
# Where "options" are composed of:
|
||||
# -i prog Run "prog" on "cvs commit" from top-level of module.
|
||||
# -o prog Run "prog" on "cvs checkout" of module.
|
||||
# -e prog Run "prog" on "cvs export" of module.
|
||||
# -t prog Run "prog" on "cvs rtag" of module.
|
||||
# -u prog Run "prog" on "cvs update" of module.
|
||||
# -d dir Place module in directory "dir" instead of module name.
|
||||
# -l Top-level directory only -- do not recurse.
|
||||
#
|
||||
# NOTE: If you change any of the "Run" options above, you'll have to
|
||||
# release and re-checkout any working directories of these modules.
|
||||
#
|
||||
# And "directory" is a path to a directory relative to $CVSROOT.
|
||||
#
|
||||
# The "-a" option specifies an alias. An alias is interpreted as if
|
||||
# everything on the right of the "-a" had been typed on the command line.
|
||||
#
|
||||
# You can encode a module within a module by using the special '&'
|
||||
# character to interpose another module into the current module. This
|
||||
# can be useful for creating a module that consists of many directories
|
||||
# spread out over the entire source repository.
|
||||
@@ -1,12 +0,0 @@
|
||||
# The "notify" file controls where notifications from watches set by
|
||||
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
|
||||
# a regular expression which is tested against the directory that the
|
||||
# change is being made to, relative to the $CVSROOT. If it matches,
|
||||
# then the remainder of the line is a filter program that should contain
|
||||
# one occurrence of %s for the user to notify, and information on its
|
||||
# standard input.
|
||||
#
|
||||
# "ALL" or "DEFAULT" can be used in place of the regular expression.
|
||||
#
|
||||
# For example:
|
||||
#ALL mail %s -s "CVS notification"
|
||||
@@ -1,13 +0,0 @@
|
||||
# The "rcsinfo" file is used to control templates with which the editor
|
||||
# is invoked on commit and import.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being made to, relative to the
|
||||
# $CVSROOT. For the first match that is found, then the remainder of the
|
||||
# line is the name of the file that contains the template.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
@@ -1,20 +0,0 @@
|
||||
# The "taginfo" file is used to control pre-tag checks.
|
||||
# The filter on the right is invoked with the following arguments:
|
||||
#
|
||||
# $1 -- tagname
|
||||
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
|
||||
# $3 -- repository
|
||||
# $4-> file revision [file revision ...]
|
||||
#
|
||||
# A non-zero exit of the filter program will cause the tag to be aborted.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being committed to, relative
|
||||
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||
# of the line is the name of the filter to run.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
@@ -1,11 +0,0 @@
|
||||
EXTRA_DIST = logtest.cxx
|
||||
|
||||
noinst_LIBRARIES = libDebug.a
|
||||
|
||||
libDebug_a_SOURCES = \
|
||||
debug_types.h \
|
||||
logstream.cxx logstream.hxx
|
||||
|
||||
# fg_debug.c fg_debug.h \
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
310
Debug/fg_debug.c
310
Debug/fg_debug.c
@@ -1,310 +0,0 @@
|
||||
/* -*- Mode: C++ -*-
|
||||
*
|
||||
* fg_debug.c -- Flight Gear debug utility functions
|
||||
*
|
||||
* Written by Paul Bleisch, started January 1998.
|
||||
*
|
||||
* Copyright (C) 1998 Paul Bleisch, pbleisch@acm.org
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Include/cmdargs.h> // Line to command line arguments
|
||||
|
||||
#include "fg_debug.h"
|
||||
|
||||
|
||||
static int fg_DebugSem = 1;
|
||||
fgDebugClass fg_DebugClass = FG_NONE; // Need visibility for
|
||||
fgDebugPriority fg_DebugPriority = FG_INFO; // command line processing.
|
||||
static fgDebugCallback fg_DebugCallback = NULL;
|
||||
|
||||
FILE *fg_DebugOutput = NULL; // Visibility needed for command line processor.
|
||||
// This can be set to a FILE from the command
|
||||
// line. If not, it will be set to stderr.
|
||||
|
||||
/* TODO: Actually make this thing thread safe */
|
||||
#ifdef USETHREADS
|
||||
#define FG_GRABDEBUGSEM while( --fg_DebugSem < 0 ) { fg_DebugSem++; }
|
||||
#define FG_RELEASEDEBUGSEM fg_DebugSem++;
|
||||
#else
|
||||
#define FG_GRABDEBUGSEM
|
||||
#define FG_RELEASEDEBUGSEM
|
||||
#endif
|
||||
|
||||
/* Used for convienence initialization from env variables.
|
||||
*/
|
||||
static struct {
|
||||
char *str;
|
||||
fgDebugClass dbg_class;
|
||||
} fg_DebugClasses[] = {
|
||||
{ "FG_NONE", 0x00000000 },
|
||||
{ "FG_TERRAIN", 0x00000001 },
|
||||
{ "FG_ASTRO", 0x00000002 },
|
||||
{ "FG_FLIGHT", 0x00000004 },
|
||||
{ "FG_INPUT", 0x00000008 },
|
||||
{ "FG_GL", 0x00000010 },
|
||||
{ "FG_VIEW", 0x00000020 },
|
||||
{ "FG_COCKPIT", 0x00000040 },
|
||||
{ "FG_GENERAL", 0x00000080 },
|
||||
{ "FG_MATH", 0x00000100 },
|
||||
{ "FG_EVENT", 0x00000200 },
|
||||
{ "FG_AIRCRAFT", 0x00000400 },
|
||||
{ "FG_AUTOPILOT", 0x00000800 },
|
||||
|
||||
/* Do not edit below here, last entry should be null */
|
||||
{ "FG_ALL", 0xFFFFFFFF },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static fgDebugClass fgDebugStrToClass( char *str );
|
||||
|
||||
|
||||
/* fgInitDebug =============================================================*/
|
||||
void fgInitDebug( void ) {
|
||||
char *pszClass, *pszPrio, *pszFile;
|
||||
|
||||
// Support for log file/alt debug output via command line, environment or
|
||||
// reasonable default.
|
||||
|
||||
/*
|
||||
if( strlen( logArgbuf ) > 3) { // First check for command line option
|
||||
// Assumed that we will append.
|
||||
fg_DebugOutput = fopen(logArgbuf, "a+" );
|
||||
}
|
||||
*/
|
||||
|
||||
if( !fg_DebugOutput ) { // If not set on command line, environment?
|
||||
pszFile = getenv( "FG_DEBUGFILE" );
|
||||
if( pszFile ) { // There is such an environmental variable.
|
||||
fg_DebugOutput = fopen( pszFile, "a+" );
|
||||
}
|
||||
}
|
||||
|
||||
if( !fg_DebugOutput ) { // If neither command line nor environment
|
||||
fg_DebugOutput = stderr; // then we use the fallback position
|
||||
}
|
||||
|
||||
FG_GRABDEBUGSEM;
|
||||
fg_DebugSem = fg_DebugSem; /* shut up GCC */
|
||||
|
||||
// Test command line option overridge of debug priority. If the value
|
||||
// is in range (properly optioned) the we will override both defaults
|
||||
// and the environmental value.
|
||||
|
||||
/*
|
||||
if ((priorityArgValue >= FG_BULK) && (priorityArgValue <= FG_ABORT)) {
|
||||
fg_DebugPriority = priorityArgValue;
|
||||
} else { // Either not set or out of range. We will not warn the user.
|
||||
*/
|
||||
pszPrio = getenv( "FG_DEBUGPRIORITY" );
|
||||
if( pszPrio ) {
|
||||
fg_DebugPriority = atoi( pszPrio );
|
||||
fprintf( stderr,
|
||||
"fg_debug.c: Environment overrides default debug priority (%d)\n",
|
||||
fg_DebugPriority );
|
||||
}
|
||||
/* } */
|
||||
|
||||
|
||||
/*
|
||||
if ((debugArgValue >= FG_ALL) && (debugArgValue < FG_UNDEFD)) {
|
||||
fg_DebugPriority = priorityArgValue;
|
||||
} else { // Either not set or out of range. We will not warn the user.
|
||||
*/
|
||||
pszClass = getenv( "FG_DEBUGCLASS" );
|
||||
if( pszClass ) {
|
||||
fg_DebugClass = fgDebugStrToClass( pszClass );
|
||||
fprintf( stderr,
|
||||
"fg_debug.c: Environment overrides default debug class (0x%08X)\n",
|
||||
fg_DebugClass );
|
||||
}
|
||||
/* } */
|
||||
|
||||
FG_RELEASEDEBUGSEM;
|
||||
}
|
||||
|
||||
/* fgDebugStrToClass ======================================================*/
|
||||
fgDebugClass fgDebugStrToClass( char *str ) {
|
||||
char *hex = "0123456789ABCDEF";
|
||||
char *hexl = "0123456789abcdef";
|
||||
char *pt, *p, *ph, ps = 1;
|
||||
unsigned int val = 0, i;
|
||||
|
||||
if( str == NULL ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check for 0xXXXXXX notation */
|
||||
p = strstr( str, "0x");
|
||||
if( p ) {
|
||||
p++; p++;
|
||||
while (*p) {
|
||||
ph = strchr(hex,*p);
|
||||
if ( ph ) {
|
||||
val <<= 4;
|
||||
val += ph-hex;
|
||||
p++;
|
||||
} else {
|
||||
ph = strchr(hexl,*p);
|
||||
if ( ph ) {
|
||||
val <<= 4;
|
||||
val += ph-hex;
|
||||
p++;
|
||||
} else {
|
||||
// fprintf( stderr, "Error in hex string '%s'\n", str );
|
||||
return FG_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Must be in string format */
|
||||
p = str;
|
||||
ps = 1;
|
||||
while( ps ) {
|
||||
while( *p && (*p==' ' || *p=='\t') ) p++; /* remove whitespace */
|
||||
pt = p; /* mark token */
|
||||
while( *p && (*p!='|') ) p++; /* find OR or EOS */
|
||||
ps = *p; /* save value at p so we can attempt to be bounds safe */
|
||||
*p++ = 0; /* terminate token */
|
||||
/* determine value for token */
|
||||
i=0;
|
||||
while( fg_DebugClasses[i].str &&
|
||||
strncmp( fg_DebugClasses[i].str, pt,
|
||||
strlen(fg_DebugClasses[i].str)) ) i++;
|
||||
if( fg_DebugClasses[i].str == NULL ) {
|
||||
fprintf( stderr,
|
||||
"fg_debug.c: Could not find message class '%s'\n",
|
||||
pt );
|
||||
} else {
|
||||
val |= fg_DebugClasses[i].dbg_class;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (fgDebugClass)val;
|
||||
}
|
||||
|
||||
|
||||
/* fgSetDebugOutput =======================================================*/
|
||||
void fgSetDebugOutput( FILE *out ) {
|
||||
FG_GRABDEBUGSEM;
|
||||
fflush( fg_DebugOutput );
|
||||
fg_DebugOutput = out;
|
||||
FG_RELEASEDEBUGSEM;
|
||||
}
|
||||
|
||||
|
||||
/* fgSetDebugLevels =======================================================*/
|
||||
void fgSetDebugLevels( fgDebugClass dbg_class, fgDebugPriority prio ) {
|
||||
FG_GRABDEBUGSEM;
|
||||
fg_DebugClass = dbg_class;
|
||||
fg_DebugPriority = prio;
|
||||
FG_RELEASEDEBUGSEM;
|
||||
}
|
||||
|
||||
|
||||
/* fgRegisterDebugCallback ================================================*/
|
||||
fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback ) {
|
||||
fgDebugCallback old;
|
||||
FG_GRABDEBUGSEM;
|
||||
old = fg_DebugCallback;
|
||||
fg_DebugCallback = callback;
|
||||
FG_RELEASEDEBUGSEM;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
/* fgPrintf ===============================================================*/
|
||||
int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... ) {
|
||||
char szOut[1024+1];
|
||||
va_list ap;
|
||||
int ret = 0;
|
||||
|
||||
// If no action to take, then don't bother with the semaphore
|
||||
// activity Slight speed benefit.
|
||||
|
||||
// printf("dbg_class = %d fg_DebugClass = %d\n", dbg_class, fg_DebugClass);
|
||||
// printf("prio = %d fg_DebugPriority = %d\n", prio, fg_DebugPriority);
|
||||
|
||||
if( !(dbg_class & fg_DebugClass) ) {
|
||||
// Failed to match a specific debug class
|
||||
if ( prio < fg_DebugPriority ) {
|
||||
// priority is less than requested
|
||||
|
||||
// "ret" is zero anyway. But we might think about changing
|
||||
// it upon some error condition?
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
FG_GRABDEBUGSEM;
|
||||
|
||||
/* ret = vsprintf( szOut, fmt, (&fmt+1)); (but it didn't work, thus ... */
|
||||
va_start (ap, fmt);
|
||||
ret = vsprintf( szOut, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
if( fg_DebugCallback!=NULL && fg_DebugCallback(dbg_class, prio, szOut) ) {
|
||||
FG_RELEASEDEBUGSEM;
|
||||
return ret;
|
||||
} else {
|
||||
fprintf( fg_DebugOutput, szOut );
|
||||
FG_RELEASEDEBUGSEM;
|
||||
if( prio == FG_EXIT ) {
|
||||
exit(0);
|
||||
} else if( prio == FG_ABORT ) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.4 1998/06/01 17:49:44 curt
|
||||
/* Rewrote a slightly ambiguous code fragment (contributed by Charlie Hotchkiss)
|
||||
/*
|
||||
* Revision 1.3 1998/05/07 23:03:54 curt
|
||||
* Added an entry for AUTOPILOT.
|
||||
*
|
||||
* Revision 1.2 1998/04/21 17:03:45 curt
|
||||
* Prepairing for C++ integration.
|
||||
*
|
||||
* Revision 1.1 1998/04/18 03:52:04 curt
|
||||
* Moved to Lib directory and created a libDebug.
|
||||
*
|
||||
* Revision 1.10 1998/03/14 00:31:21 curt
|
||||
* Beginning initial terrain texturing experiments.
|
||||
*
|
||||
* Revision 1.9 1998/03/09 22:44:58 curt
|
||||
* Modified so that you can specify FG_DEBUGCLASS ***or*** FG_DEBUG_PRIORITY
|
||||
*
|
||||
* Revision 1.8 1998/03/09 22:11:00 curt
|
||||
* Processed through the format-o-matic.
|
||||
*
|
||||
* Revision 1.7 1998/02/16 13:39:43 curt
|
||||
* Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
|
||||
* tiles to occasionally be missing.
|
||||
*
|
||||
*/
|
||||
156
Debug/fg_debug.h
156
Debug/fg_debug.h
@@ -1,156 +0,0 @@
|
||||
/* -*- Mode: C++ -*-
|
||||
*
|
||||
* fg_debug.h -- Flight Gear debug utility functions
|
||||
*
|
||||
* Written by Paul Bleisch, started January 1998.
|
||||
*
|
||||
* Copyright (C) 1998 Paul Bleisch, pbleisch@acm.org
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#error "use logstream"
|
||||
|
||||
#ifndef _FG_DEBUG_H
|
||||
#define _FG_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* NB: To add a dbg_class, add it here, and add it to the structure in
|
||||
fg_debug.c */
|
||||
typedef enum {
|
||||
FG_NONE = 0x00000000,
|
||||
|
||||
FG_TERRAIN = 0x00000001,
|
||||
FG_ASTRO = 0x00000002,
|
||||
FG_FLIGHT = 0x00000004,
|
||||
FG_INPUT = 0x00000008,
|
||||
FG_GL = 0x00000010,
|
||||
FG_VIEW = 0x00000020,
|
||||
FG_COCKPIT = 0x00000040,
|
||||
FG_GENERAL = 0x00000080,
|
||||
FG_MATH = 0x00000100,
|
||||
FG_EVENT = 0x00000200,
|
||||
FG_AIRCRAFT = 0x00000400,
|
||||
FG_AUTOPILOT = 0x00000800,
|
||||
FG_UNDEFD = 0x00001000, // For range checking
|
||||
|
||||
FG_ALL = 0xFFFFFFFF
|
||||
} fgDebugClass;
|
||||
|
||||
/* NB: To add a priority, add it here. */
|
||||
typedef enum {
|
||||
FG_BULK, /* For frequent messages */
|
||||
FG_DEBUG, /* Less frequent debug type messages */
|
||||
FG_INFO, /* Informatory messages */
|
||||
FG_WARN, /* Possible impending problem */
|
||||
FG_ALERT, /* Very possible impending problem */
|
||||
FG_EXIT, /* Problem (no core) */
|
||||
FG_ABORT /* Abandon ship (core) */
|
||||
} fgDebugPriority;
|
||||
|
||||
|
||||
/* Initialize the debuggin stuff. */
|
||||
void fgInitDebug( void );
|
||||
|
||||
|
||||
/* fgPrintf
|
||||
|
||||
Expects:
|
||||
class fgDebugClass mask for this message.
|
||||
prio fgDebugPriority of this message.
|
||||
fmt printf like string format
|
||||
... var args for fmt
|
||||
|
||||
Returns:
|
||||
number of items in fmt handled.
|
||||
|
||||
This function works like the standard C library function printf() with
|
||||
the addition of message classes and priorities (see fgDebugClasses
|
||||
and fgDebugPriorities). These additions allow us to classify messages
|
||||
and disable sets of messages at runtime. Only messages with a prio
|
||||
greater than or equal to fg_DebugPriority and in the current debug class
|
||||
(fg_DebugClass) are printed.
|
||||
*/
|
||||
int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... );
|
||||
|
||||
|
||||
/* fgSetDebugLevels()
|
||||
|
||||
Expects:
|
||||
dbg_class Bitmask representing classes to display.
|
||||
prio Minimum priority of messages to display.
|
||||
*/
|
||||
void fgSetDebugLevels( fgDebugClass dbg_class, fgDebugPriority prio );
|
||||
|
||||
/* fgSetDebugOutput()
|
||||
|
||||
Expects:
|
||||
file A FILE* to a stream to send messages to.
|
||||
|
||||
It is assumed the file stream is open and writable. The system
|
||||
defaults to stderr. The current stream is flushed but not
|
||||
closed.
|
||||
*/
|
||||
void fgSetDebugOutput( FILE *out );
|
||||
|
||||
|
||||
/* fgRegisterDebugCallback
|
||||
|
||||
Expects:
|
||||
callback A function that takes parameters as defined by the
|
||||
fgDebugCallback type.
|
||||
|
||||
Returns:
|
||||
a pointer to the previously registered callback (if any)
|
||||
|
||||
Install a user defined debug log callback. This callback is called w
|
||||
whenever fgPrintf is called. The parameters passed to the callback are
|
||||
defined above by fgDebugCallback. outstr is the string that is to be
|
||||
printed. If callback returns nonzero, it is assumed that the message
|
||||
was handled fully by the callback and **fgPrintf need do no further
|
||||
processing of the message.** Only one callback may be installed at a
|
||||
time.
|
||||
*/
|
||||
|
||||
//typedef int (*fgDebugCallback)(fgDebugClass, fgDebugPriority, char *outstr);
|
||||
//fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
|
||||
|
||||
typedef int (*fgDebugCallback)( int DebugClass, int DebugPriority, char *outstr);
|
||||
fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
|
||||
|
||||
|
||||
// Leave these alone. Access intended for fg_debug and command line processing.
|
||||
//
|
||||
extern fgDebugClass fg_DebugClass;
|
||||
extern fgDebugPriority fg_DebugPriority;
|
||||
|
||||
extern FILE * fg_DebugOutput;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _FG_DEBUG_H */
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
if ENABLE_AUDIO_SUPPORT
|
||||
AUDIO_DIRS = Audio
|
||||
else
|
||||
AUDIO_DIRS =
|
||||
endif
|
||||
|
||||
if ENABLE_UNIX_SERIAL
|
||||
SERIAL_DIRS = Serial
|
||||
else
|
||||
SERIAL_DIRS =
|
||||
endif
|
||||
|
||||
SUBDIRS = \
|
||||
$(AUDIO_DIRS) \
|
||||
Bucket \
|
||||
Debug \
|
||||
Math \
|
||||
Misc \
|
||||
PUI \
|
||||
$(SERIAL_DIRS) \
|
||||
XGL\
|
||||
zlib
|
||||
6
Makefile.am
Normal file
6
Makefile.am
Normal file
@@ -0,0 +1,6 @@
|
||||
EXTRA_DIST = mksymlinks.sh
|
||||
|
||||
dist-hook:
|
||||
tar cf - src/metar | (cd $(distdir); tar xvf -)
|
||||
|
||||
SUBDIRS = src
|
||||
@@ -1,16 +0,0 @@
|
||||
noinst_LIBRARIES = libMath.a
|
||||
|
||||
libMath_a_SOURCES = \
|
||||
MAT3geom.c \
|
||||
MAT3inv.c \
|
||||
MAT3mat.c \
|
||||
MAT3vec.c \
|
||||
fg_geodesy.cxx fg_geodesy.hxx \
|
||||
fg_random.c fg_random.h \
|
||||
interpolater.cxx interpolater.hxx \
|
||||
mat3.h mat3defs.h mat3err.h \
|
||||
point3d.hxx \
|
||||
polar3d.cxx polar3d.hxx \
|
||||
vector.cxx vector.hxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
|
||||
@@ -1,293 +0,0 @@
|
||||
// fg_geodesy.cxx -- routines to convert between geodetic and geocentric
|
||||
// coordinate systems.
|
||||
//
|
||||
// Copied and adapted directly from LaRCsim/ls_geodesy.c
|
||||
//
|
||||
// See below for the complete original LaRCsim comments.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
#include "Include/compiler.h"
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cerrno>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_geodesy.hxx>
|
||||
#include <Math/point3d.hxx>
|
||||
|
||||
FG_USING_STD(cout);
|
||||
|
||||
// ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator
|
||||
#define ONE_SECOND 4.848136811E-6
|
||||
|
||||
|
||||
// fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
|
||||
// INPUTS:
|
||||
// lat_geoc Geocentric latitude, radians, + = North
|
||||
// radius C.G. radius to earth center (meters)
|
||||
//
|
||||
// OUTPUTS:
|
||||
// lat_geod Geodetic latitude, radians, + = North
|
||||
// alt C.G. altitude above mean sea level (meters)
|
||||
// sea_level_r radius from earth center to sea level at
|
||||
// local vertical (surface normal) of C.G. (meters)
|
||||
|
||||
|
||||
void fgGeocToGeod( double lat_geoc, double radius, double
|
||||
*lat_geod, double *alt, double *sea_level_r )
|
||||
{
|
||||
double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha;
|
||||
double sin_mu_a, denom,delt_lambda, lambda_sl, sin_lambda_sl;
|
||||
|
||||
if( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|
||||
|| ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole
|
||||
{
|
||||
*lat_geod = lat_geoc;
|
||||
*sea_level_r = EQUATORIAL_RADIUS_M*E;
|
||||
*alt = radius - *sea_level_r;
|
||||
} else {
|
||||
t_lat = tan(lat_geoc);
|
||||
x_alpha = E*EQUATORIAL_RADIUS_M/sqrt(t_lat*t_lat + E*E);
|
||||
double tmp = RESQ_M - x_alpha * x_alpha;
|
||||
if ( tmp < 0.0 ) { tmp = 0.0; }
|
||||
mu_alpha = atan2(sqrt(tmp),E*x_alpha);
|
||||
if (lat_geoc < 0) mu_alpha = - mu_alpha;
|
||||
sin_mu_a = sin(mu_alpha);
|
||||
delt_lambda = mu_alpha - lat_geoc;
|
||||
r_alpha = x_alpha/cos(lat_geoc);
|
||||
l_point = radius - r_alpha;
|
||||
*alt = l_point*cos(delt_lambda);
|
||||
|
||||
// check for domain error
|
||||
if ( errno == EDOM ) {
|
||||
cout << "Domain ERROR in fgGeocToGeod!!!!\n";
|
||||
*alt = 0.0;
|
||||
}
|
||||
|
||||
denom = sqrt(1-EPS*EPS*sin_mu_a*sin_mu_a);
|
||||
rho_alpha = EQUATORIAL_RADIUS_M*(1-EPS)/
|
||||
(denom*denom*denom);
|
||||
delt_mu = atan2(l_point*sin(delt_lambda),rho_alpha + *alt);
|
||||
*lat_geod = mu_alpha - delt_mu;
|
||||
lambda_sl = atan( E*E * tan(*lat_geod) ); // SL geoc. latitude
|
||||
sin_lambda_sl = sin( lambda_sl );
|
||||
*sea_level_r =
|
||||
sqrt(RESQ_M / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl));
|
||||
|
||||
// check for domain error
|
||||
if ( errno == EDOM ) {
|
||||
cout << "Domain ERROR in fgGeocToGeod!!!!\n";
|
||||
*sea_level_r = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
|
||||
// INPUTS:
|
||||
// lat_geod Geodetic latitude, radians, + = North
|
||||
// alt C.G. altitude above mean sea level (meters)
|
||||
//
|
||||
// OUTPUTS:
|
||||
// sl_radius SEA LEVEL radius to earth center (meters)
|
||||
// (add Altitude to get true distance from earth center.
|
||||
// lat_geoc Geocentric latitude, radians, + = North
|
||||
//
|
||||
|
||||
|
||||
void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
|
||||
double *lat_geoc )
|
||||
{
|
||||
double lambda_sl, sin_lambda_sl, cos_lambda_sl, sin_mu, cos_mu, px, py;
|
||||
|
||||
lambda_sl = atan( E*E * tan(lat_geod) ); // sea level geocentric latitude
|
||||
sin_lambda_sl = sin( lambda_sl );
|
||||
cos_lambda_sl = cos( lambda_sl );
|
||||
sin_mu = sin(lat_geod); // Geodetic (map makers') latitude
|
||||
cos_mu = cos(lat_geod);
|
||||
*sl_radius =
|
||||
sqrt(RESQ_M / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl));
|
||||
py = *sl_radius*sin_lambda_sl + alt*sin_mu;
|
||||
px = *sl_radius*cos_lambda_sl + alt*cos_mu;
|
||||
*lat_geoc = atan2( py, px );
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
TITLE: ls_geodesy
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
FUNCTION: Converts geocentric coordinates to geodetic positions
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
MODULE STATUS: developmental
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
DESIGNED BY: E. B. Jackson
|
||||
|
||||
CODED BY: E. B. Jackson
|
||||
|
||||
MAINTAINED BY: E. B. Jackson
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
MODIFICATION HISTORY:
|
||||
|
||||
DATE PURPOSE BY
|
||||
|
||||
930208 Modified to avoid singularity near polar region. EBJ
|
||||
930602 Moved backwards calcs here from ls_step. EBJ
|
||||
931214 Changed erroneous Latitude and Altitude variables to
|
||||
*lat_geod and *alt in routine ls_geoc_to_geod. EBJ
|
||||
940111 Changed header files from old ls_eom.h style to ls_types,
|
||||
and ls_constants. Also replaced old DATA type with new
|
||||
SCALAR type. EBJ
|
||||
|
||||
CURRENT RCS HEADER:
|
||||
|
||||
$Header$
|
||||
$Log$
|
||||
Revision 1.5 1999/01/27 04:46:14 curt
|
||||
Portability tweaks by Bernie Bright.
|
||||
|
||||
Revision 1.4 1998/11/20 01:00:36 curt
|
||||
Patch in fgGeoc2Geod() to avoid a floating explosion.
|
||||
point3d.hxx include math.h for FreeBSD
|
||||
|
||||
Revision 1.3 1998/11/11 00:18:36 curt
|
||||
Check for domain error in fgGeoctoGeod()
|
||||
|
||||
Revision 1.2 1998/10/16 23:36:36 curt
|
||||
c++-ifying.
|
||||
|
||||
Revision 1.1 1998/10/16 19:30:40 curt
|
||||
Renamed .c -> .h so we can start adding c++ supporting routines.
|
||||
|
||||
Revision 1.6 1998/07/08 14:40:07 curt
|
||||
polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
||||
Updated fg_geodesy comments to reflect that routines expect and produce
|
||||
meters.
|
||||
|
||||
Revision 1.5 1998/04/25 22:06:23 curt
|
||||
Edited cvs log messages in source files ... bad bad bad!
|
||||
|
||||
Revision 1.4 1998/01/27 00:47:59 curt
|
||||
Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||
system and commandline/config file processing code.
|
||||
|
||||
Revision 1.3 1998/01/19 19:27:12 curt
|
||||
Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
This should simplify things tremendously.
|
||||
|
||||
Revision 1.2 1997/12/15 23:54:54 curt
|
||||
Add xgl wrappers for debugging.
|
||||
Generate terrain normals on the fly.
|
||||
|
||||
Revision 1.1 1997/07/31 23:13:14 curt
|
||||
Initial revision.
|
||||
|
||||
Revision 1.1 1997/05/29 00:09:56 curt
|
||||
Initial Flight Gear revision.
|
||||
|
||||
* Revision 1.5 1994/01/11 18:47:05 bjax
|
||||
* Changed include files to use types and constants, not ls_eom.h
|
||||
* Also changed DATA type to SCALAR type.
|
||||
*
|
||||
* Revision 1.4 1993/12/14 21:06:47 bjax
|
||||
* Removed global variable references Altitude and Latitude. EBJ
|
||||
*
|
||||
* Revision 1.3 1993/06/02 15:03:40 bjax
|
||||
* Made new subroutine for calculating geodetic to geocentric; changed name
|
||||
* of forward conversion routine from ls_geodesy to ls_geoc_to_geod.
|
||||
*
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
REFERENCES:
|
||||
|
||||
[ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft
|
||||
Control and Simulation", Wiley and Sons, 1992.
|
||||
ISBN 0-471-61397-5
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
CALLED BY: ls_aux
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
CALLS TO:
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
INPUTS:
|
||||
lat_geoc Geocentric latitude, radians, + = North
|
||||
radius C.G. radius to earth center, ft
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
OUTPUTS:
|
||||
lat_geod Geodetic latitude, radians, + = North
|
||||
alt C.G. altitude above mean sea level, ft
|
||||
sea_level_r radius from earth center to sea level at
|
||||
local vertical (surface normal) of C.G.
|
||||
|
||||
--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.5 1999/01/27 04:46:14 curt
|
||||
// Portability tweaks by Bernie Bright.
|
||||
//
|
||||
// Revision 1.4 1998/11/20 01:00:36 curt
|
||||
// Patch in fgGeoc2Geod() to avoid a floating explosion.
|
||||
// point3d.hxx include math.h for FreeBSD
|
||||
//
|
||||
// Revision 1.3 1998/11/11 00:18:36 curt
|
||||
// Check for domain error in fgGeoctoGeod()
|
||||
//
|
||||
// Revision 1.2 1998/10/16 23:36:36 curt
|
||||
// c++-ifying.
|
||||
//
|
||||
// Revision 1.1 1998/10/16 19:30:40 curt
|
||||
// Renamed .c -> .h so we can start adding c++ supporting routines.
|
||||
//
|
||||
// Revision 1.6 1998/07/08 14:40:07 curt
|
||||
// polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
||||
// Updated fg_geodesy comments to reflect that routines expect and produce
|
||||
// meters.
|
||||
//
|
||||
// Revision 1.5 1998/04/25 22:06:23 curt
|
||||
// Edited cvs log messages in source files ... bad bad bad!
|
||||
//
|
||||
// Revision 1.4 1998/01/27 00:47:59 curt
|
||||
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||
// system and commandline/config file processing code.
|
||||
//
|
||||
// Revision 1.3 1998/01/19 19:27:12 curt
|
||||
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
// This should simplify things tremendously.
|
||||
//
|
||||
// Revision 1.2 1997/12/15 23:54:54 curt
|
||||
// Add xgl wrappers for debugging.
|
||||
// Generate terrain normals on the fly.
|
||||
//
|
||||
// Revision 1.1 1997/07/31 23:13:14 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
// vector.hxx -- additional vector routines
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// 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 _VECTOR_HXX
|
||||
#define _VECTOR_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include "mat3.h"
|
||||
|
||||
|
||||
// Map a vector onto the plane specified by normal
|
||||
#if defined( USE_XTRA_MAT3_INLINES )
|
||||
# define map_vec_onto_cur_surface_plane(normal, v0, vec, result) { \
|
||||
double scale = ((normal[0]*vec[0]+normal[1]*vec[1]+normal[2]*vec[2]) / \
|
||||
(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2])); \
|
||||
result[0] = vec[0]-normal[0]*scale; \
|
||||
result[1] = vec[1]-normal[1]*scale; \
|
||||
result[2] = vec[2]-normal[2]*scale; \
|
||||
}
|
||||
#else
|
||||
void map_vec_onto_cur_surface_plane(MAT3vec normal, MAT3vec v0, MAT3vec vec,
|
||||
MAT3vec result);
|
||||
#endif //defined( USE_XTRA_MAT3_INLINES )
|
||||
|
||||
|
||||
// Given a point p, and a line through p0 with direction vector d,
|
||||
// find the shortest distance from the point to the line
|
||||
double fgPointLine(MAT3vec p, MAT3vec p0, MAT3vec d);
|
||||
|
||||
|
||||
// Given a point p, and a line through p0 with direction vector d,
|
||||
// find the shortest distance (squared) from the point to the line
|
||||
double fgPointLineSquared(MAT3vec p, MAT3vec p0, MAT3vec d);
|
||||
|
||||
|
||||
#endif // _VECTOR_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.4 1998/10/16 23:36:39 curt
|
||||
// c++-ifying.
|
||||
//
|
||||
// Revision 1.3 1998/08/24 20:04:13 curt
|
||||
// Various "inline" code optimizations contributed by Norman Vine.
|
||||
//
|
||||
// Revision 1.2 1998/07/24 21:34:38 curt
|
||||
// fgPointLine() rewritten into fgPointLineSquared() ... this ultimately saves
|
||||
// us from doing a sqrt().
|
||||
//
|
||||
// Revision 1.1 1998/07/08 14:40:10 curt
|
||||
// polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
||||
// Updated fg_geodesy comments to reflect that routines expect and produce
|
||||
// meters.
|
||||
//
|
||||
// Revision 1.4 1998/04/21 17:03:51 curt
|
||||
// Prepairing for C++ integration.
|
||||
//
|
||||
// Revision 1.3 1998/01/22 02:59:39 curt
|
||||
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||
//
|
||||
// Revision 1.2 1998/01/19 19:27:14 curt
|
||||
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
// This should simplify things tremendously.
|
||||
//
|
||||
// Revision 1.1 1997/12/22 04:13:18 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
16
Misc/CREDITS
16
Misc/CREDITS
@@ -1,16 +0,0 @@
|
||||
The following files were unashamedly borrowed from other projects:
|
||||
|
||||
zfstream.hxx
|
||||
zfstream.cxx
|
||||
zlib/contrib/iostream
|
||||
|
||||
stopwatch.hxx was (blitz/time.h)
|
||||
blitz
|
||||
|
||||
Some modifications have been made to fit in with the FlightGear scheme of things.
|
||||
|
||||
As far as I'm aware they are all covered by GNU's licensing agreements.
|
||||
|
||||
Many thanks to their respective authors.
|
||||
|
||||
Bernie Bright (bbright@c031.aone.net.au)
|
||||
@@ -1,11 +0,0 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
noinst_LIBRARIES = libMisc.a
|
||||
|
||||
libMisc_a_SOURCES = \
|
||||
fgstream.cxx fgstream.hxx \
|
||||
stopwatch.hxx \
|
||||
strutils.cxx strutils.hxx \
|
||||
zfstream.cxx zfstream.hxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib
|
||||
@@ -1,24 +0,0 @@
|
||||
noinst_LIBRARIES = libPUI.a
|
||||
|
||||
EXTRA_DIST = complex.cxx simple.cxx
|
||||
|
||||
libPUI_a_SOURCES = \
|
||||
pu.h puLocal.h \
|
||||
pu.cxx \
|
||||
puBox.cxx \
|
||||
puButton.cxx \
|
||||
puButtonBox.cxx \
|
||||
puDialogBox.cxx \
|
||||
puFrame.cxx \
|
||||
puInput.cxx \
|
||||
puInterface.cxx \
|
||||
puMenuBar.cxx \
|
||||
puObject.cxx \
|
||||
puOneShot.cxx \
|
||||
puPopup.cxx \
|
||||
puPopupMenu.cxx \
|
||||
puSlider.cxx \
|
||||
puText.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
|
||||
332
PUI/complex.cxx
332
PUI/complex.cxx
@@ -1,332 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
#include "pu.h"
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* These are the PUI widget pointers *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
puMenuBar *main_menu_bar ;
|
||||
puButton *hide_menu_button ;
|
||||
puDialogBox *dialog_box ;
|
||||
puText *dialog_box_message ;
|
||||
puOneShot *dialog_box_ok_button ;
|
||||
puText *timer_text ;
|
||||
puSlider *rspeedSlider;
|
||||
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* This is a generic tumbling cube *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
GLfloat light_diffuse [] = {0.0, 1.0, 0.0, 1.0} ; /* Red diffuse light. */
|
||||
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0} ; /* Infinite light location. */
|
||||
|
||||
GLfloat cube_n[6][3] = /* Normals */
|
||||
{
|
||||
{-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
|
||||
{ 0.0,-1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0,-1.0}
|
||||
} ;
|
||||
|
||||
GLint cube_i[6][4] = /* Vertex indices */
|
||||
{
|
||||
{0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
|
||||
{4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3}
|
||||
} ;
|
||||
|
||||
GLfloat cube_v[8][3] = /* Vertices */
|
||||
{
|
||||
{-1.0,-1.0, 1.0}, {-1.0,-1.0,-1.0}, {-1.0, 1.0,-1.0}, {-1.0, 1.0, 1.0},
|
||||
{ 1.0,-1.0, 1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, { 1.0, 1.0, 1.0}
|
||||
} ;
|
||||
|
||||
|
||||
static int firsttime;
|
||||
|
||||
void drawCube (void)
|
||||
{
|
||||
|
||||
if ( firsttime )
|
||||
{
|
||||
/*
|
||||
Deliberately do this only once - it's a better test of
|
||||
PUI's attempts to leave the OpenGL state undisturbed
|
||||
*/
|
||||
|
||||
firsttime = FALSE ;
|
||||
glLightfv ( GL_LIGHT0, GL_DIFFUSE , light_diffuse ) ;
|
||||
glLightfv ( GL_LIGHT0, GL_POSITION, light_position ) ;
|
||||
glEnable ( GL_LIGHT0 ) ;
|
||||
glEnable ( GL_LIGHTING ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
gluPerspective ( 40.0, 1.0, 1.0, 10.0 ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
gluLookAt ( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ) ;
|
||||
glTranslatef ( 0.0, 0.0, -1.0 ) ;
|
||||
glRotatef ( 60.0, 1.0, 0.0, 0.0 ) ;
|
||||
}
|
||||
|
||||
glCullFace ( GL_FRONT ) ;
|
||||
glEnable ( GL_CULL_FACE ) ;
|
||||
// glRotatef ( 1.0f, 0.0, 0.0, 1.0 ) ; /* Tumble that cube! */
|
||||
|
||||
glBegin ( GL_QUADS ) ;
|
||||
|
||||
for ( int i = 0 ; i < 6 ; i++ )
|
||||
{
|
||||
glNormal3fv ( &cube_n[i][0] ) ;
|
||||
glVertex3fv ( cube_v[cube_i[i][0]] ) ; glVertex3fv ( cube_v[cube_i[i][1]] ) ;
|
||||
glVertex3fv ( cube_v[cube_i[i][2]] ) ; glVertex3fv ( cube_v[cube_i[i][3]] ) ;
|
||||
}
|
||||
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
/********************************\
|
||||
* *
|
||||
* End of cube renderer in OpenGL *
|
||||
* *
|
||||
\********************************/
|
||||
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* These three functions capture mouse *
|
||||
* and keystrokes (special and mundane) *
|
||||
* from GLUT and pass them on to PUI. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void specialfn ( int key, int, int )
|
||||
{
|
||||
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void keyfn ( unsigned char key, int, int )
|
||||
{
|
||||
puKeyboard ( key, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
puMouse ( x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
puMouse ( button, updown, x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* This function redisplays the PUI and *
|
||||
* the tumbling cube, flips the double *
|
||||
* buffer and then asks GLUT to post a *
|
||||
* redisplay command - so we re-render *
|
||||
* at maximum rate. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void displayfn (void)
|
||||
{
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.0, 0.0, 0.0, 1.0 ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Draw the tumbling cube */
|
||||
|
||||
float val ; rspeedSlider->getValue ( &val ) ;
|
||||
|
||||
glRotatef( 4*val, 15.0, 10.0 , 5.0 );
|
||||
|
||||
drawCube () ;
|
||||
|
||||
/* Update the 'timer' */
|
||||
|
||||
time_t t = time ( NULL ) ;
|
||||
timer_text -> setLabel ( ctime ( & t ) ) ;
|
||||
|
||||
/* Make PUI redraw */
|
||||
|
||||
puDisplay () ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* Here are the PUI widget callback *
|
||||
* functions. *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
void hide_menu_cb ( puObject *cb )
|
||||
{
|
||||
if ( cb -> getValue () )
|
||||
{
|
||||
main_menu_bar -> reveal () ;
|
||||
hide_menu_button->setLegend ( "Hide Menu" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
main_menu_bar -> hide () ;
|
||||
hide_menu_button->setLegend ( "Show Menu" ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void go_away_cb ( puObject * )
|
||||
{
|
||||
/*
|
||||
Delete the dialog box when its 'OK' button is pressed.
|
||||
|
||||
This seems to crash on MSVC compilers - probably because
|
||||
I delete dialog_box - whose member function is calling
|
||||
this function. Hence we return to something that is
|
||||
in a distinctly 'iffy' state.
|
||||
*/
|
||||
|
||||
delete dialog_box ;
|
||||
dialog_box = NULL ;
|
||||
}
|
||||
|
||||
void mk_dialog ( char *txt )
|
||||
{
|
||||
dialog_box = new puDialogBox ( 150, 50 ) ;
|
||||
{
|
||||
new puFrame ( 0, 0, 400, 100 ) ;
|
||||
dialog_box_message = new puText ( 10, 70 ) ;
|
||||
dialog_box_message -> setLabel ( txt ) ;
|
||||
dialog_box_ok_button = new puOneShot ( 180, 10, 240, 50 ) ;
|
||||
dialog_box_ok_button -> setLegend ( "OK" ) ;
|
||||
dialog_box_ok_button -> makeReturnDefault ( TRUE ) ;
|
||||
dialog_box_ok_button -> setCallback ( go_away_cb ) ;
|
||||
}
|
||||
dialog_box -> close () ;
|
||||
dialog_box -> reveal () ;
|
||||
}
|
||||
|
||||
void ni_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "Sorry, that function isn't implemented" ) ;
|
||||
}
|
||||
|
||||
void about_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "This is the PUI 'complex' program" ) ;
|
||||
}
|
||||
|
||||
void help_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "Sorry, no help is available for this demo" ) ;
|
||||
}
|
||||
|
||||
void edit_cb ( puObject * )
|
||||
{
|
||||
}
|
||||
|
||||
void exit_cb ( puObject * )
|
||||
{
|
||||
fprintf ( stderr, "Exiting PUI demo program.\n" ) ;
|
||||
exit ( 1 ) ;
|
||||
}
|
||||
|
||||
/* Menu bar entries: */
|
||||
|
||||
char *file_submenu [] = { "Exit", "Close", "--------", "Print", "--------", "Save", "New", NULL } ;
|
||||
puCallback file_submenu_cb [] = { exit_cb, exit_cb, NULL, ni_cb , NULL, ni_cb, ni_cb, NULL } ;
|
||||
|
||||
char *edit_submenu [] = { "Edit text", NULL } ;
|
||||
puCallback edit_submenu_cb [] = { edit_cb, NULL } ;
|
||||
|
||||
char *help_submenu [] = { "About...", "Help", NULL } ;
|
||||
puCallback help_submenu_cb [] = { about_cb, help_cb, NULL } ;
|
||||
|
||||
|
||||
void sliderCB( puObject *sliderObj)
|
||||
{
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
firsttime = TRUE;
|
||||
|
||||
#ifdef VOODOO
|
||||
glutInitWindowPosition( 0, 0 ) ;
|
||||
#endif
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( "Complex PUI Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
glutIdleFunc ( displayfn ) ;
|
||||
|
||||
puInit () ;
|
||||
|
||||
#ifdef VOODOO
|
||||
puShowCursor () ;
|
||||
#endif
|
||||
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.8, 0.8, 0.8 ) ;
|
||||
|
||||
timer_text = new puText ( 300, 10 ) ;
|
||||
timer_text -> setColour ( PUCOL_LABEL, 1.0, 1.0, 1.0 ) ;
|
||||
|
||||
/* Make a button to hide the menu bar */
|
||||
|
||||
hide_menu_button = new puButton ( 10, 10, 150, 50 ) ;
|
||||
hide_menu_button->setValue ( TRUE ) ;
|
||||
hide_menu_button->setLegend ( "Hide Menu" ) ;
|
||||
hide_menu_button->setCallback ( hide_menu_cb ) ;
|
||||
hide_menu_button->makeReturnDefault ( TRUE ) ;
|
||||
|
||||
/* Make the menu bar */
|
||||
|
||||
main_menu_bar = new puMenuBar () ;
|
||||
{
|
||||
main_menu_bar -> add_submenu ( "File", file_submenu, file_submenu_cb ) ;
|
||||
main_menu_bar -> add_submenu ( "Edit", edit_submenu, edit_submenu_cb ) ;
|
||||
main_menu_bar -> add_submenu ( "Help", help_submenu, help_submenu_cb ) ;
|
||||
}
|
||||
main_menu_bar -> close () ;
|
||||
|
||||
rspeedSlider = new puSlider (20,80,150,TRUE);
|
||||
rspeedSlider->setDelta(0.1);
|
||||
rspeedSlider->setCBMode( PUSLIDER_DELTA );
|
||||
rspeedSlider->setCallback(sliderCB);
|
||||
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
332
PUI/pu.cxx
332
PUI/pu.cxx
@@ -1,332 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
#include <assert.h>
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
#define PU_STRING_X_FUDGE 6
|
||||
#define PU_STRING_Y_FUDGE 6
|
||||
|
||||
int puRefresh = TRUE ;
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
|
||||
static int puWindowWidth = 400 ;
|
||||
static int puWindowHeight = 400 ;
|
||||
|
||||
int puGetWindowHeight () { return puWindowHeight ; }
|
||||
int puGetWindowWidth () { return puWindowWidth ; }
|
||||
|
||||
void puSetWindowSize ( int width, int height )
|
||||
{
|
||||
puWindowWidth = width ;
|
||||
puWindowHeight = height ;
|
||||
}
|
||||
|
||||
static int fontBase = 0;
|
||||
static int fontSize[257];
|
||||
#else
|
||||
|
||||
int puGetWindowHeight () { return glutGet ( (GLenum) GLUT_WINDOW_HEIGHT ) ; }
|
||||
int puGetWindowWidth () { return glutGet ( (GLenum) GLUT_WINDOW_WIDTH ) ; }
|
||||
|
||||
void puSetWindowSize ( int width, int height )
|
||||
{
|
||||
fprintf ( stderr, "PUI: puSetWindowSize shouldn't be used with GLUT.\n" ) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
puColour _puDefaultColourTable[] =
|
||||
{
|
||||
{ 0.5f, 0.5f, 0.5f, 1.0f }, /* PUCOL_FOREGROUND */
|
||||
{ 0.3f, 0.3f, 0.3f, 1.0f }, /* PUCOL_BACKGROUND */
|
||||
{ 0.7f, 0.7f, 0.7f, 1.0f }, /* PUCOL_HIGHLIGHT */
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }, /* PUCOL_LABEL */
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f }, /* PUCOL_TEXT */
|
||||
|
||||
{ 0.0f, 0.0f, 0.0f, 0.0f } /* ILLEGAL */
|
||||
} ;
|
||||
|
||||
|
||||
puValue::~puValue () {}
|
||||
|
||||
static int _puCursor_enable = FALSE ;
|
||||
static int _puCursor_x = 0 ;
|
||||
static int _puCursor_y = 0 ;
|
||||
static float _puCursor_bgcolour [4] = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
static float _puCursor_fgcolour [4] = { 0.0f, 0.0f, 0.0f, 1.0f } ;
|
||||
|
||||
void puHideCursor ( void ) { _puCursor_enable = FALSE ; }
|
||||
void puShowCursor ( void ) { _puCursor_enable = TRUE ; }
|
||||
int puCursorIsHidden ( void ) { return ! _puCursor_enable ; }
|
||||
|
||||
void puCursor ( int x, int y )
|
||||
{
|
||||
_puCursor_x = x ;
|
||||
_puCursor_y = y ;
|
||||
}
|
||||
|
||||
int puGetStringDescender ( void *fnt )
|
||||
{
|
||||
if ( fnt == NULL )
|
||||
fnt = PUFONT_9_BY_15 ;
|
||||
|
||||
if ( fnt == PUFONT_8_BY_13 ) return 2 ;
|
||||
if ( fnt == PUFONT_9_BY_15 ) return 3 ;
|
||||
if ( fnt == PUFONT_TIMES_ROMAN_10 ) return 2 ;
|
||||
if ( fnt == PUFONT_TIMES_ROMAN_24 ) return 5 ;
|
||||
if ( fnt == PUFONT_HELVETICA_10 ) return 2 ;
|
||||
if ( fnt == PUFONT_HELVETICA_12 ) return 3 ;
|
||||
if ( fnt == PUFONT_HELVETICA_18 ) return 4 ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int puGetStringHeight ( void *fnt )
|
||||
{
|
||||
/* Height *excluding* descender */
|
||||
if ( fnt == NULL )
|
||||
fnt = PUFONT_9_BY_15 ;
|
||||
|
||||
if ( fnt == PUFONT_8_BY_13 ) return 9 ;
|
||||
if ( fnt == PUFONT_9_BY_15 ) return 10 ;
|
||||
if ( fnt == PUFONT_TIMES_ROMAN_10 ) return 7 ;
|
||||
if ( fnt == PUFONT_TIMES_ROMAN_24 ) return 17 ;
|
||||
if ( fnt == PUFONT_HELVETICA_10 ) return 8 ;
|
||||
if ( fnt == PUFONT_HELVETICA_12 ) return 9 ;
|
||||
if ( fnt == PUFONT_HELVETICA_18 ) return 14 ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int puGetStringWidth ( void *fnt, char *str )
|
||||
{
|
||||
|
||||
if ( str == NULL )
|
||||
return 0 ;
|
||||
|
||||
int res = 0 ;
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
while ( *str != '\0' )
|
||||
{
|
||||
res += fontSize [ *str ] ;
|
||||
str++ ;
|
||||
}
|
||||
#else
|
||||
if ( fnt == NULL )
|
||||
fnt = PUFONT_9_BY_15 ;
|
||||
|
||||
while ( *str != '\0' )
|
||||
{
|
||||
res += glutBitmapWidth ( fnt, *str ) ;
|
||||
str++ ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
|
||||
void puDrawString ( void *fnt, char *str, int x, int y )
|
||||
{
|
||||
if ( str == NULL )
|
||||
return ;
|
||||
|
||||
glRasterPos2f((float)x, (float)y);
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
/*
|
||||
Display a string:
|
||||
indicate start of glyph display lists
|
||||
*/
|
||||
|
||||
glListBase (fontBase);
|
||||
|
||||
/* Now draw the characters in a string */
|
||||
|
||||
int len = strlen(str);
|
||||
glCallLists(len, GL_UNSIGNED_BYTE, str);
|
||||
glListBase(0);
|
||||
#else
|
||||
if ( fnt == NULL )
|
||||
fnt = PUFONT_9_BY_15 ;
|
||||
|
||||
while ( *str != '\0' )
|
||||
{
|
||||
glutBitmapCharacter ( fnt, *str ) ;
|
||||
str++ ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void puDrawCursor ( int x, int y )
|
||||
{
|
||||
glColor4fv ( _puCursor_bgcolour ) ;
|
||||
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( x, y ) ;
|
||||
glVertex2i ( x + 13, y - 4 ) ;
|
||||
glVertex2i ( x + 4, y - 13 ) ;
|
||||
|
||||
glVertex2i ( x + 8, y - 3 ) ;
|
||||
glVertex2i ( x + 17, y - 12 ) ;
|
||||
glVertex2i ( x + 12, y - 17 ) ;
|
||||
|
||||
glVertex2i ( x + 12, y - 17 ) ;
|
||||
glVertex2i ( x + 3, y - 8 ) ;
|
||||
glVertex2i ( x + 8, y - 3 ) ;
|
||||
glEnd () ;
|
||||
|
||||
glColor4fv ( _puCursor_fgcolour ) ;
|
||||
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( x+1, y-1 ) ;
|
||||
glVertex2i ( x + 11, y - 4 ) ;
|
||||
glVertex2i ( x + 4, y - 11 ) ;
|
||||
|
||||
glVertex2i ( x + 8, y - 5 ) ;
|
||||
glVertex2i ( x + 15, y - 12 ) ;
|
||||
glVertex2i ( x + 12, y - 15 ) ;
|
||||
|
||||
glVertex2i ( x + 12, y - 15 ) ;
|
||||
glVertex2i ( x + 5, y - 8 ) ;
|
||||
glVertex2i ( x + 8, y - 5 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
void puInit ( void )
|
||||
{
|
||||
static int firsttime = TRUE ;
|
||||
|
||||
if ( firsttime )
|
||||
{
|
||||
puInterface *base_interface = new puInterface ( 0, 0 ) ;
|
||||
puPushInterface ( base_interface ) ;
|
||||
puPushLiveInterface ( base_interface ) ;
|
||||
firsttime = FALSE ;
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
|
||||
/* Create bitmaps for the device context font's first 256 glyphs */
|
||||
|
||||
fontBase = glGenLists(256);
|
||||
assert(fontBase);
|
||||
HDC hdc = wglGetCurrentDC();
|
||||
|
||||
/* Make the system font the device context's selected font */
|
||||
|
||||
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
|
||||
|
||||
int *tempSize = &fontSize[1];
|
||||
|
||||
if ( ! GetCharWidth32 ( hdc, 1, 255, tempSize ) &&
|
||||
! GetCharWidth ( hdc, 1, 255, tempSize ) )
|
||||
{
|
||||
LPVOID lpMsgBuf ;
|
||||
|
||||
FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0, NULL ) ;
|
||||
|
||||
fprintf ( stderr, "PUI: Error: %s\n", (char *)lpMsgBuf ) ;
|
||||
LocalFree ( lpMsgBuf ) ;
|
||||
}
|
||||
|
||||
wglUseFontBitmaps ( hdc, 0, 256, fontBase ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void puSetOpenGLState ( void )
|
||||
{
|
||||
int w = puGetWindowWidth () ;
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
glPushAttrib ( GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT ) ;
|
||||
glDisable ( GL_LIGHTING ) ;
|
||||
glDisable ( GL_FOG ) ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glDisable ( GL_DEPTH_TEST ) ;
|
||||
glDisable ( GL_CULL_FACE ) ;
|
||||
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
gluOrtho2D ( 0, w, 0, h ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
}
|
||||
|
||||
static void puRestoreOpenGLState ( void )
|
||||
{
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPopMatrix () ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPopMatrix () ;
|
||||
glPopAttrib () ;
|
||||
}
|
||||
|
||||
|
||||
void puDisplay ( void )
|
||||
{
|
||||
puSetOpenGLState () ;
|
||||
puGetUltimateLiveInterface () -> draw ( 0, 0 ) ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
if ( _puCursor_enable )
|
||||
puDrawCursor ( _puCursor_x,
|
||||
h - _puCursor_y ) ;
|
||||
|
||||
puRestoreOpenGLState () ;
|
||||
}
|
||||
|
||||
int puKeyboard ( int key, int updown )
|
||||
{
|
||||
return puGetBaseLiveInterface () -> checkKey ( key, updown ) ;
|
||||
}
|
||||
|
||||
|
||||
static int last_buttons = 0 ;
|
||||
int puMouse ( int button, int updown, int x, int y )
|
||||
{
|
||||
puCursor ( x, y ) ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
if ( updown == PU_DOWN )
|
||||
last_buttons |= ( 1 << button ) ;
|
||||
else
|
||||
last_buttons &= ~( 1 << button ) ;
|
||||
|
||||
return puGetBaseLiveInterface () -> checkHit ( button, updown, x,
|
||||
h - y ) ;
|
||||
}
|
||||
|
||||
int puMouse ( int x, int y )
|
||||
{
|
||||
puCursor ( x, y ) ;
|
||||
|
||||
if ( last_buttons == 0 )
|
||||
return FALSE ;
|
||||
|
||||
int button = (last_buttons & (1<<PU_LEFT_BUTTON )) ? PU_LEFT_BUTTON :
|
||||
(last_buttons & (1<<PU_MIDDLE_BUTTON)) ? PU_MIDDLE_BUTTON :
|
||||
(last_buttons & (1<<PU_RIGHT_BUTTON )) ? PU_RIGHT_BUTTON : 0 ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
return puGetBaseLiveInterface () -> checkHit ( button, PU_DRAG, x,
|
||||
h - y ) ;
|
||||
}
|
||||
|
||||
805
PUI/pu.h
805
PUI/pu.h
@@ -1,805 +0,0 @@
|
||||
#ifndef _PU_H_
|
||||
#define _PU_H_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Webster's Dictionary (for American English) permits
|
||||
Color or Colour as acceptable spellings - but
|
||||
The Oxford English Dictionary (for English) only
|
||||
permits Colour.
|
||||
|
||||
Hence, the logical thing to do is to use 'colour',
|
||||
which *ought* to be acceptable on both sides of
|
||||
the atlantic.
|
||||
|
||||
However, as a concession to the illogical:
|
||||
*/
|
||||
|
||||
#define setColorScheme setColourScheme
|
||||
#define setColor setColour
|
||||
#define getColor getColour
|
||||
#define puColor puColour
|
||||
#define puSetColor puSetColour
|
||||
#define puSetDefaultColorScheme puSetDefaultColourScheme
|
||||
#define puGetDefaultColorScheme puGetDefaultColourScheme
|
||||
|
||||
|
||||
typedef void *puFont ;
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
#define PU_LEFT_BUTTON 0
|
||||
#define PU_LEFT_BUTTON 0
|
||||
#define PU_MIDDLE_BUTTON 1
|
||||
#define PU_RIGHT_BUTTON 2
|
||||
#define PU_DOWN 0
|
||||
#define PU_UP 1
|
||||
|
||||
#define PUFONT_8_BY_13 ((void*)3)
|
||||
#define PUFONT_9_BY_15 ((void*)2)
|
||||
#define PUFONT_TIMES_ROMAN_10 ((void*)4)
|
||||
#define PUFONT_TIMES_ROMAN_24 ((void*)5)
|
||||
#define PUFONT_HELVETICA_10 ((void*)6)
|
||||
#define PUFONT_HELVETICA_12 ((void*)7)
|
||||
#define PUFONT_HELVETICA_18 ((void*)8)
|
||||
|
||||
#else
|
||||
|
||||
#define PUFONT_8_BY_13 GLUT_BITMAP_8_BY_13
|
||||
#define PUFONT_9_BY_15 GLUT_BITMAP_9_BY_15
|
||||
#define PUFONT_TIMES_ROMAN_10 GLUT_BITMAP_TIMES_ROMAN_10
|
||||
#define PUFONT_TIMES_ROMAN_24 GLUT_BITMAP_TIMES_ROMAN_24
|
||||
#define PUFONT_HELVETICA_10 GLUT_BITMAP_HELVETICA_10
|
||||
#define PUFONT_HELVETICA_12 GLUT_BITMAP_HELVETICA_12
|
||||
#define PUFONT_HELVETICA_18 GLUT_BITMAP_HELVETICA_18
|
||||
|
||||
#define PU_LEFT_BUTTON GLUT_LEFT_BUTTON
|
||||
#define PU_MIDDLE_BUTTON GLUT_MIDDLE_BUTTON
|
||||
#define PU_RIGHT_BUTTON GLUT_RIGHT_BUTTON
|
||||
#define PU_DOWN GLUT_DOWN
|
||||
#define PU_UP GLUT_UP
|
||||
#endif // PU_NOT_USING_GLUT
|
||||
|
||||
#define PU_UP_AND_DOWN 254
|
||||
#define PU_DRAG 255
|
||||
#define PU_CONTINUAL PU_DRAG
|
||||
|
||||
#define PU_KEY_GLUT_SPECIAL_OFFSET 256
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
#define PU_KEY_F1 (1 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F2 (2 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F3 (3 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F4 (4 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F5 (5 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F6 (6 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F7 (7 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F8 (8 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F9 (9 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F10 (10 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F11 (11 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F12 (12 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_LEFT (100 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_UP (101 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_RIGHT (102 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_DOWN (103 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_PAGE_UP (104 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_PAGE_DOWN (105 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_HOME (106 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_END (107 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_INSERT (108 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
|
||||
#else
|
||||
#define PU_KEY_F1 (GLUT_KEY_F1 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F2 (GLUT_KEY_F2 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F3 (GLUT_KEY_F3 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F4 (GLUT_KEY_F4 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F5 (GLUT_KEY_F5 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F6 (GLUT_KEY_F6 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F7 (GLUT_KEY_F7 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F8 (GLUT_KEY_F8 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F9 (GLUT_KEY_F9 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F10 (GLUT_KEY_F10 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F11 (GLUT_KEY_F11 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_F12 (GLUT_KEY_F12 + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_LEFT (GLUT_KEY_LEFT + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_UP (GLUT_KEY_UP + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_RIGHT (GLUT_KEY_RIGHT + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_DOWN (GLUT_KEY_DOWN + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_PAGE_UP (GLUT_KEY_PAGE_UP + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_PAGE_DOWN (GLUT_KEY_PAGE_DOWN + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_HOME (GLUT_KEY_HOME + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_END (GLUT_KEY_END + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#define PU_KEY_INSERT (GLUT_KEY_INSERT + PU_KEY_GLUT_SPECIAL_OFFSET)
|
||||
#endif // PU_NOT_USING_GLUT
|
||||
|
||||
#define PUPLACE_DEFAULT PUPLACE_RIGHT
|
||||
#define PUPLACE_ABOVE 0
|
||||
#define PUPLACE_BELOW 1
|
||||
#define PUPLACE_LEFT 2
|
||||
#define PUPLACE_RIGHT 3
|
||||
|
||||
#define PUCOL_FOREGROUND 0
|
||||
#define PUCOL_BACKGROUND 1
|
||||
#define PUCOL_HIGHLIGHT 2
|
||||
#define PUCOL_LABEL 3
|
||||
#define PUCOL_LEGEND 4
|
||||
#define PUCOL_MAX 5
|
||||
|
||||
#define PUSLIDER_CLICK 0
|
||||
#define PUSLIDER_ALWAYS 1
|
||||
#define PUSLIDER_DELTA 2
|
||||
|
||||
/* These styles may be negated to get 'highlighted' graphics */
|
||||
|
||||
#define PUSTYLE_DEFAULT PUSTYLE_SHADED
|
||||
#define PUSTYLE_NONE 0
|
||||
#define PUSTYLE_PLAIN 1
|
||||
#define PUSTYLE_BEVELLED 2
|
||||
#define PUSTYLE_BOXED 3
|
||||
#define PUSTYLE_DROPSHADOW 4
|
||||
#define PUSTYLE_SPECIAL_UNDERLINED 5
|
||||
#define PUSTYLE_SMALL_BEVELLED 6
|
||||
#define PUSTYLE_RADIO 7
|
||||
#define PUSTYLE_SHADED 8
|
||||
#define PUSTYLE_SMALL_SHADED 9
|
||||
#define PUSTYLE_MAX 10
|
||||
|
||||
/* These are the gaps that we try to leave around text objects */
|
||||
|
||||
#define PUSTR_TGAP 5
|
||||
#define PUSTR_BGAP 5
|
||||
#define PUSTR_LGAP 5
|
||||
#define PUSTR_RGAP 5
|
||||
#define PUSTR_MAX_HEIGHT ( 25 + PUSTR_TGAP + PUSTR_BGAP )
|
||||
|
||||
#define PU_RADIO_BUTTON_SIZE 16
|
||||
|
||||
extern int puRefresh ;
|
||||
|
||||
#define PUCLASS_VALUE 0x00000001
|
||||
#define PUCLASS_OBJECT 0x00000002
|
||||
#define PUCLASS_INTERFACE 0x00000004
|
||||
#define PUCLASS_FRAME 0x00000008
|
||||
#define PUCLASS_TEXT 0x00000010
|
||||
#define PUCLASS_BUTTON 0x00000020
|
||||
#define PUCLASS_ONESHOT 0x00000040
|
||||
#define PUCLASS_POPUP 0x00000080
|
||||
#define PUCLASS_POPUPMENU 0x00000100
|
||||
#define PUCLASS_MENUBAR 0x00000200
|
||||
#define PUCLASS_INPUT 0x00000400
|
||||
#define PUCLASS_BUTTONBOX 0x00000800
|
||||
#define PUCLASS_SLIDER 0x00001000
|
||||
#define PUCLASS_DIALOGBOX 0x00002000
|
||||
|
||||
/* This function is not required for GLUT programs */
|
||||
void puSetWindowSize ( int width, int height ) ;
|
||||
|
||||
int puGetWindowHeight () ;
|
||||
int puGetWindowWidth () ;
|
||||
|
||||
class puValue ;
|
||||
class puObject ;
|
||||
class puInterface ;
|
||||
class puButtonBox ;
|
||||
class puFrame ;
|
||||
class puText ;
|
||||
class puButton ;
|
||||
class puOneShot ;
|
||||
class puPopup ;
|
||||
class puPopupMenu ;
|
||||
class puMenuBar ;
|
||||
class puInput ;
|
||||
class puSlider ;
|
||||
|
||||
typedef float puColour [ 4 ] ; /* RGBA */
|
||||
|
||||
struct puBox
|
||||
{
|
||||
int min [ 2 ] ;
|
||||
int max [ 2 ] ;
|
||||
|
||||
void draw ( int dx, int dy, int style, puColour colour[], int am_default ) ;
|
||||
void extend ( puBox *bx ) ;
|
||||
|
||||
void empty ( void ) { min[0]=min[1]=1000000 ; max[0]=max[1]=-1000000 ; }
|
||||
int isEmpty ( void ) { return min[0]>max[0] || min[1]>max[1] ; }
|
||||
} ;
|
||||
|
||||
#define PUSTRING_MAX 80
|
||||
|
||||
/* If you change - or add to these, be sure to change _puDefaultColourTable */
|
||||
|
||||
extern puColour _puDefaultColourTable[] ;
|
||||
|
||||
|
||||
inline void puSetColour ( puColour dst, puColour src )
|
||||
{
|
||||
dst[0] = src[0] ; dst[1] = src[1] ; dst[2] = src[2] ; dst[3] = src[3] ;
|
||||
}
|
||||
|
||||
inline void puSetColour ( puColour c, float r, float g, float b, float a = 1.0f )
|
||||
{
|
||||
c [ 0 ] = r ; c [ 1 ] = g ; c [ 2 ] = b ; c [ 3 ] = a ;
|
||||
}
|
||||
|
||||
|
||||
void puInit ( void ) ;
|
||||
void puDisplay ( void ) ;
|
||||
int puMouse ( int button, int updown, int x, int y ) ;
|
||||
int puMouse ( int x, int y ) ;
|
||||
int puKeyboard ( int key, int updown ) ;
|
||||
void puHideCursor ( void ) ;
|
||||
void puShowCursor ( void ) ;
|
||||
int puCursorIsHidden ( void ) ;
|
||||
|
||||
void puDrawString ( puFont fnt, char *str, int x, int y ) ;
|
||||
int puGetStringWidth ( puFont fnt, char *str ) ;
|
||||
int puGetStringHeight ( puFont fnt = NULL ) ;
|
||||
int puGetStringDescender ( puFont fnt = NULL ) ;
|
||||
|
||||
class puValue
|
||||
{
|
||||
protected:
|
||||
int type ;
|
||||
int integer ;
|
||||
float floater ;
|
||||
char string [ PUSTRING_MAX ] ;
|
||||
public:
|
||||
puValue () { type = PUCLASS_VALUE ; clrValue () ; }
|
||||
|
||||
virtual ~puValue () ;
|
||||
|
||||
int getType ( void ) { return type ; }
|
||||
char *getTypeString ( void ) ;
|
||||
void clrValue ( void ) { setValue ( "" ) ; }
|
||||
|
||||
void setValue ( puValue *pv )
|
||||
{
|
||||
integer = pv -> integer ;
|
||||
floater = pv -> floater ;
|
||||
strcpy ( string, pv -> string ) ;
|
||||
puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
void setValue ( int i ) { integer = i ; floater = (float) i ; sprintf ( string, "%d", i ) ; puRefresh = TRUE ; }
|
||||
void setValue ( float f ) { integer = (int) f ; floater = f ; sprintf ( string, "%g", f ) ; puRefresh = TRUE ; }
|
||||
void setValue ( char *s ) {
|
||||
if ( s == NULL || s[0] == '\0' )
|
||||
{
|
||||
integer = 0 ;
|
||||
floater = 0.0f ;
|
||||
s = "" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
integer = atoi(s) ;
|
||||
floater = (float)atof(s) ;
|
||||
|
||||
if ( string != s ) strcpy ( string, s ) ;
|
||||
}
|
||||
puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
void getValue ( int *i ) { *i = integer ; }
|
||||
void getValue ( float *f ) { *f = floater ; }
|
||||
void getValue ( char **s ) { *s = string ; }
|
||||
void getValue ( char *s ) { strcpy ( s, string ) ; }
|
||||
|
||||
int getValue ( void ) { return integer ; }
|
||||
} ;
|
||||
|
||||
typedef void (*puCallback)(class puObject *) ;
|
||||
|
||||
void puSetDefaultStyle ( int style ) ;
|
||||
int puGetDefaultStyle ( void ) ;
|
||||
void puSetDefaultFonts ( puFont legendFont, puFont labelFont ) ;
|
||||
void puGetDefaultFonts ( puFont *legendFont, puFont *labelFont ) ;
|
||||
void puSetDefaultColourScheme ( float r, float g, float b, float a = 1.0 ) ;
|
||||
void puGetDefaultColourScheme ( float *r, float *g, float *b, float *a = NULL );
|
||||
|
||||
class puObject : public puValue
|
||||
{
|
||||
protected:
|
||||
puValue default_value ;
|
||||
|
||||
puBox bbox ; /* Bounding box of entire Object */
|
||||
puBox abox ; /* Active (clickable) area */
|
||||
puColour colour [ PUCOL_MAX ] ;
|
||||
puInterface *parent ;
|
||||
|
||||
int active_mouse_edge ; /* is it PU_UP or PU_DOWN (or both) that activates this? */
|
||||
int style ;
|
||||
int visible ;
|
||||
int active ;
|
||||
int highlighted ;
|
||||
int am_default ;
|
||||
|
||||
char *label ; puFont labelFont ; int labelPlace ;
|
||||
char *legend ; puFont legendFont ;
|
||||
|
||||
void *user_data ;
|
||||
puCallback cb ;
|
||||
|
||||
virtual void draw_label ( int dx, int dy ) ;
|
||||
virtual int isHit ( int x, int y ) { return isVisible() && isActive() &&
|
||||
x >= abox.min[0] &&
|
||||
x <= abox.max[0] &&
|
||||
y >= abox.min[1] &&
|
||||
y <= abox.max[1] ; }
|
||||
virtual void doHit ( int button, int updown, int x, int y ) ;
|
||||
|
||||
public:
|
||||
puObject ( int minx, int miny, int maxx, int maxy ) ;
|
||||
~puObject () ;
|
||||
|
||||
puObject *next ;
|
||||
puObject *prev ;
|
||||
|
||||
puBox *getBBox ( void ) { return & bbox ; }
|
||||
puBox *getABox ( void ) { return & abox ; }
|
||||
|
||||
void setPosition ( int x, int y )
|
||||
{
|
||||
if ( abox.isEmpty() )
|
||||
{
|
||||
abox.max[0] = abox.min[0] = x ;
|
||||
abox.max[1] = abox.min[1] = y ;
|
||||
}
|
||||
else
|
||||
{
|
||||
abox.max[0] += x - abox.min[0] ;
|
||||
abox.max[1] += y - abox.min[1] ;
|
||||
abox.min[0] = x ;
|
||||
abox.min[1] = y ;
|
||||
}
|
||||
recalc_bbox() ; puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
void setSize ( int w, int h )
|
||||
{
|
||||
abox.max[0] = abox.min[0] + w ;
|
||||
abox.max[1] = abox.min[1] + h ;
|
||||
recalc_bbox() ; puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
void getPosition ( int *x, int *y )
|
||||
{
|
||||
if ( abox . isEmpty () )
|
||||
{
|
||||
if ( x ) *x = 0 ;
|
||||
if ( y ) *y = 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( x ) *x = abox.min[0] ;
|
||||
if ( y ) *y = abox.min[1] ;
|
||||
}
|
||||
}
|
||||
|
||||
void getSize ( int *w, int *h )
|
||||
{
|
||||
if ( abox . isEmpty () )
|
||||
{
|
||||
if ( w ) *w = 0 ;
|
||||
if ( h ) *h = 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( w ) *w = abox.max[0] - abox.min[0] ;
|
||||
if ( h ) *h = abox.max[1] - abox.min[1] ;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void recalc_bbox ( void ) ;
|
||||
virtual int checkHit ( int button, int updown, int x, int y ) ;
|
||||
virtual int checkKey ( int key , int updown ) ;
|
||||
virtual void draw ( int dx, int dy ) = 0 ;
|
||||
|
||||
puInterface *getParent ( void ) { return parent ; }
|
||||
puObject *getNextObject ( void ) { return next ; }
|
||||
puObject *getPrevObject ( void ) { return prev ; }
|
||||
|
||||
void setCallback ( puCallback c ) { cb = c ; }
|
||||
puCallback getCallback ( void ) { return cb ; }
|
||||
void invokeCallback ( void ) { if ( cb ) (*cb)(this) ; }
|
||||
|
||||
void makeReturnDefault ( int def ) { am_default = def ; }
|
||||
int isReturnDefault ( void ) { return am_default ; }
|
||||
|
||||
void setActiveDirn ( int e ) { active_mouse_edge = e ; }
|
||||
int getActiveDirn ( void ) { return active_mouse_edge ; }
|
||||
|
||||
void setLegend ( char *l ) { legend = l ; recalc_bbox() ; puRefresh = TRUE ; }
|
||||
char *getLegend ( void ) { return legend ; }
|
||||
|
||||
void setLegendFont ( puFont f ) { legendFont = f ; recalc_bbox() ; puRefresh = TRUE ; }
|
||||
puFont getLegendFont ( void ) { return legendFont ; }
|
||||
|
||||
void setLabel ( char *l ) { label = l ; recalc_bbox() ; puRefresh = TRUE ; }
|
||||
char *getLabel ( void ) { return label ; }
|
||||
|
||||
void setLabelFont ( puFont f ) { labelFont = f ; recalc_bbox() ; puRefresh = TRUE ; }
|
||||
puFont getLabelFont ( void ) { return labelFont ; }
|
||||
|
||||
void setLabelPlace ( int lp ) { labelPlace = lp ; recalc_bbox() ; puRefresh = TRUE ; }
|
||||
int getLabelPlace ( void ) { return labelPlace ; }
|
||||
|
||||
void activate ( void ) { if ( ! active ) { active = TRUE ; puRefresh = TRUE ; } }
|
||||
void greyOut ( void ) { if ( active ) { active = FALSE ; puRefresh = TRUE ; } }
|
||||
int isActive ( void ) { return active ; }
|
||||
|
||||
void highlight ( void ) { if ( ! highlighted ) { highlighted = TRUE ; puRefresh = TRUE ; } }
|
||||
void lowlight ( void ) { if ( highlighted ) { highlighted = FALSE ; puRefresh = TRUE ; } }
|
||||
int isHighlighted( void ){ return highlighted ; }
|
||||
|
||||
void reveal ( void ) { if ( ! visible ) { visible = TRUE ; puRefresh = TRUE ; } }
|
||||
void hide ( void ) { if ( visible ) { visible = FALSE ; puRefresh = TRUE ; } }
|
||||
int isVisible ( void ) { return visible ; }
|
||||
|
||||
void setStyle ( int which )
|
||||
{
|
||||
style = which ;
|
||||
recalc_bbox () ;
|
||||
puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
int getStyle ( void ) { return style ; }
|
||||
|
||||
void setColourScheme ( float r, float g, float b, float a = 1.0f ) ;
|
||||
|
||||
void setColour ( int which, float r, float g, float b, float a = 1.0f )
|
||||
{
|
||||
puSetColour ( colour [ which ], r, g, b, a ) ;
|
||||
puRefresh = TRUE ;
|
||||
}
|
||||
|
||||
void getColour ( int which, float *r, float *g, float *b, float *a = NULL )
|
||||
{
|
||||
if ( r ) *r = colour[which][0] ;
|
||||
if ( g ) *g = colour[which][1] ;
|
||||
if ( b ) *b = colour[which][2] ;
|
||||
if ( a ) *a = colour[which][3] ;
|
||||
}
|
||||
|
||||
void setUserData ( void *data ) { user_data = data ; }
|
||||
void *getUserData ( void ) { return user_data ; }
|
||||
|
||||
void defaultValue ( void ) { setValue ( & default_value ) ; }
|
||||
|
||||
void setDefaultValue ( int i ) { default_value . setValue ( i ) ; }
|
||||
void setDefaultValue ( float f ) { default_value . setValue ( f ) ; }
|
||||
void setDefaultValue ( char *s ) { default_value . setValue ( s ) ; }
|
||||
|
||||
void getDefaultValue ( int *i ) { default_value . getValue ( i ) ; }
|
||||
void getDefaultValue ( float *f ) { default_value . getValue ( f ) ; }
|
||||
void getDefaultValue ( char **s ) { default_value . getValue ( s ) ; }
|
||||
int getDefaultValue ( void ) { return default_value . getValue () ; }
|
||||
} ;
|
||||
|
||||
/*
|
||||
The 'live' interface stack is used for clicking and rendering.
|
||||
*/
|
||||
|
||||
void puPushLiveInterface ( puInterface *in ) ;
|
||||
void puPopLiveInterface ( void ) ;
|
||||
int puNoLiveInterface ( void ) ;
|
||||
puInterface *puGetBaseLiveInterface ( void ) ;
|
||||
puInterface *puGetUltimateLiveInterface ( void ) ;
|
||||
|
||||
/*
|
||||
The regular interface stack is used for adding widgets
|
||||
*/
|
||||
|
||||
void puPushInterface ( puInterface *in ) ;
|
||||
void puPopInterface ( void ) ;
|
||||
int puNoInterface ( void ) ;
|
||||
puInterface *puGetCurrInterface ( void ) ;
|
||||
|
||||
class puInterface : public puObject
|
||||
{
|
||||
protected:
|
||||
int num_children ;
|
||||
puObject *dlist ;
|
||||
|
||||
void doHit ( int button, int updown, int x, int y ) ;
|
||||
|
||||
public:
|
||||
|
||||
puInterface ( int x, int y ) : puObject ( x, y, x, y )
|
||||
{
|
||||
type |= PUCLASS_INTERFACE ;
|
||||
dlist = NULL ;
|
||||
num_children = 0 ;
|
||||
puPushInterface ( this ) ;
|
||||
puPushLiveInterface ( this ) ;
|
||||
}
|
||||
|
||||
~puInterface () ;
|
||||
|
||||
void recalc_bbox ( void ) ;
|
||||
virtual void add ( puObject *new_object ) ;
|
||||
virtual void remove ( puObject *old_object ) ;
|
||||
|
||||
void draw ( int dx, int dy ) ;
|
||||
int checkHit ( int button, int updown, int x, int y ) ;
|
||||
int checkKey ( int key , int updown ) ;
|
||||
|
||||
puObject *getFirstChild ( void ) { return dlist ; }
|
||||
int getNumChildren ( void ) { return num_children ; }
|
||||
|
||||
virtual void close ( void )
|
||||
{
|
||||
if ( puGetCurrInterface () != this )
|
||||
fprintf ( stderr, "PUI: puInterface::close() is mismatched!\n" ) ;
|
||||
else
|
||||
puPopInterface () ;
|
||||
}
|
||||
} ;
|
||||
|
||||
class puFrame : public puObject
|
||||
{
|
||||
protected:
|
||||
virtual int isHit ( int /* x */, int /* y */ ) { return FALSE ; }
|
||||
public:
|
||||
void draw ( int dx, int dy ) ;
|
||||
puFrame ( int minx, int miny, int maxx, int maxy ) :
|
||||
puObject ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_FRAME ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class puText : public puObject
|
||||
{
|
||||
protected:
|
||||
virtual int isHit ( int /* x */, int /* y */ ) { return FALSE ; }
|
||||
public:
|
||||
void draw ( int dx, int dy ) ;
|
||||
puText ( int x, int y ) : puObject ( x, y, x, y )
|
||||
{
|
||||
type |= PUCLASS_TEXT ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class puButton : public puObject
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
void doHit ( int button, int updown, int x, int y ) ;
|
||||
void draw ( int dx, int dy ) ;
|
||||
puButton ( int minx, int miny, char *l ) :
|
||||
puObject ( minx, miny,
|
||||
minx + puGetStringWidth ( NULL, l ) + PUSTR_LGAP + PUSTR_RGAP,
|
||||
miny + puGetStringHeight () + puGetStringDescender () + PUSTR_TGAP + PUSTR_BGAP )
|
||||
{
|
||||
type |= PUCLASS_BUTTON ;
|
||||
setLegend ( l ) ;
|
||||
}
|
||||
|
||||
puButton ( int minx, int miny, int maxx, int maxy ) :
|
||||
puObject ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_BUTTON ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class puSlider : public puObject
|
||||
{
|
||||
protected:
|
||||
int vert ;
|
||||
float last_cb_value ;
|
||||
float cb_delta ;
|
||||
int cb_mode ;
|
||||
float slider_fraction ;
|
||||
public:
|
||||
void doHit ( int button, int updown, int x, int y ) ;
|
||||
void draw ( int dx, int dy ) ;
|
||||
puSlider ( int minx, int miny, int sz, int vertical = FALSE ) :
|
||||
puObject ( minx, miny, vertical ?
|
||||
( minx + puGetStringWidth ( NULL, "W" ) +
|
||||
PUSTR_LGAP + PUSTR_RGAP ) :
|
||||
( minx + sz ),
|
||||
vertical ?
|
||||
( miny + sz ) :
|
||||
( miny + puGetStringHeight () +
|
||||
puGetStringDescender () +
|
||||
PUSTR_TGAP + PUSTR_BGAP )
|
||||
)
|
||||
{
|
||||
type |= PUCLASS_SLIDER ;
|
||||
slider_fraction = 0.1f ;
|
||||
getValue ( & last_cb_value ) ;
|
||||
vert = vertical ;
|
||||
cb_delta = 0.1f ;
|
||||
cb_mode = PUSLIDER_ALWAYS ;
|
||||
}
|
||||
|
||||
void setCBMode ( int m ) { cb_mode = m ; }
|
||||
float getCBMode ( void ) { return (float)cb_mode ; }
|
||||
|
||||
int isVertical ( void ) { return vert ; }
|
||||
|
||||
void setDelta ( float f ) { cb_delta = (f<=0.0f) ? 0.1f : (f>=1.0f) ? 0.9f : f ; }
|
||||
float getDelta ( void ) { return cb_delta ; }
|
||||
|
||||
void setSliderFraction ( float f ) { slider_fraction = (f<=0.0f) ? 0.1f : (f>=1.0f) ? 0.9f : f ; }
|
||||
float getSliderFraction ( void ) { return slider_fraction ; }
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
class puOneShot : public puButton
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
void doHit ( int button, int updown, int x, int y ) ;
|
||||
|
||||
puOneShot ( int minx, int miny, char *l ) : puButton ( minx, miny, l )
|
||||
{
|
||||
type |= PUCLASS_ONESHOT ;
|
||||
}
|
||||
|
||||
puOneShot ( int minx, int miny, int maxx, int maxy ) :
|
||||
puButton ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_ONESHOT ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
class puPopup : public puInterface
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
puPopup ( int x, int y ) : puInterface ( x, y )
|
||||
{
|
||||
type |= PUCLASS_POPUP ;
|
||||
hide () ;
|
||||
}
|
||||
} ;
|
||||
|
||||
class puPopupMenu : public puPopup
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
puPopupMenu ( int x, int y ) : puPopup ( x, y )
|
||||
{
|
||||
type |= PUCLASS_POPUPMENU ;
|
||||
}
|
||||
|
||||
puObject *add_item ( char *str, puCallback cb ) ;
|
||||
int checkHit ( int button, int updown, int x, int y ) ;
|
||||
int checkKey ( int key , int updown ) ;
|
||||
void close ( void ) ;
|
||||
} ;
|
||||
|
||||
class puMenuBar : public puInterface
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
puMenuBar ( int h = -1 ) :
|
||||
|
||||
puInterface ( 0, h < 0 ? puGetWindowHeight() -
|
||||
( puGetStringHeight() + PUSTR_TGAP + PUSTR_BGAP ) : h )
|
||||
{
|
||||
type |= PUCLASS_MENUBAR ;
|
||||
}
|
||||
|
||||
void add_submenu ( char *str, char *items[], puCallback cb[] ) ;
|
||||
void close ( void ) ;
|
||||
} ;
|
||||
|
||||
|
||||
class puInput : public puObject
|
||||
{
|
||||
int accepting ;
|
||||
int cursor_position ;
|
||||
int select_start_position ;
|
||||
int select_end_position ;
|
||||
|
||||
void normalize_cursors ( void ) ;
|
||||
|
||||
public:
|
||||
void draw ( int dx, int dy ) ;
|
||||
void doHit ( int button, int updown, int x, int y ) ;
|
||||
int checkKey ( int key, int updown ) ;
|
||||
|
||||
int isAcceptingInput ( void ) { return accepting ; }
|
||||
void rejectInput ( void ) { accepting = FALSE ; }
|
||||
void acceptInput ( void ) { accepting = TRUE ;
|
||||
cursor_position = strlen ( string ) ;
|
||||
select_start_position = select_end_position = -1 ; }
|
||||
|
||||
int getCursor ( void ) { return cursor_position ; }
|
||||
void setCursor ( int c ) { cursor_position = c ; }
|
||||
|
||||
void setSelectRegion ( int s, int e )
|
||||
{
|
||||
select_start_position = s ;
|
||||
select_end_position = e ;
|
||||
}
|
||||
|
||||
void getSelectRegion ( int *s, int *e )
|
||||
{
|
||||
if ( s ) *s = select_start_position ;
|
||||
if ( e ) *e = select_end_position ;
|
||||
}
|
||||
|
||||
puInput ( int minx, int miny, int maxx, int maxy ) :
|
||||
puObject ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_INPUT ;
|
||||
|
||||
accepting = FALSE ;
|
||||
|
||||
cursor_position = 0 ;
|
||||
select_start_position = -1 ;
|
||||
select_end_position = -1 ;
|
||||
|
||||
setColourScheme ( 0.8f, 0.7f, 0.7f ) ; /* Yeukky Pink */
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class puButtonBox : public puObject
|
||||
{
|
||||
protected:
|
||||
int one_only ;
|
||||
int num_kids ;
|
||||
char **button_labels ;
|
||||
|
||||
public:
|
||||
|
||||
puButtonBox ( int minx, int miny, int maxx, int maxy,
|
||||
char **labels, int one_button ) ;
|
||||
|
||||
int isOneButton ( void ) { return one_only ; }
|
||||
|
||||
int checkKey ( int key , int updown ) ;
|
||||
int checkHit ( int button, int updown, int x, int y ) ;
|
||||
void draw ( int dx, int dy ) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
class puDialogBox : public puPopup
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
|
||||
puDialogBox ( int x, int y ) : puPopup ( x, y )
|
||||
{
|
||||
type |= PUCLASS_DIALOGBOX ;
|
||||
}
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
319
PUI/puBox.cxx
319
PUI/puBox.cxx
@@ -1,319 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#define PU_BEVEL 5
|
||||
#define PU_SMALL_BEVEL 2
|
||||
#define PU_DFLT_OFFSET 8
|
||||
#define PU_BOX_WIDTH 2
|
||||
#define PU_DROPSHADOW_OFFSET 5
|
||||
|
||||
void puBox::extend ( puBox *bx )
|
||||
{
|
||||
if ( bx -> isEmpty () ) return ;
|
||||
|
||||
if ( min[0]>bx->min[0] ) min[0] = bx->min[0] ;
|
||||
if ( min[1]>bx->min[1] ) min[1] = bx->min[1] ;
|
||||
if ( max[0]<bx->max[0] ) max[0] = bx->max[0] ;
|
||||
if ( max[1]<bx->max[1] ) max[1] = bx->max[1] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void puBox::draw ( int dx, int dy, int style, puColour colour[], int am_default )
|
||||
{
|
||||
int hi, mid, lo ;
|
||||
|
||||
/* Colour assignments */
|
||||
|
||||
switch ( style )
|
||||
{
|
||||
case PUSTYLE_NONE :
|
||||
return ;
|
||||
|
||||
case PUSTYLE_PLAIN :
|
||||
case PUSTYLE_DROPSHADOW :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SMALL_SHADED :
|
||||
case PUSTYLE_SHADED :
|
||||
case PUSTYLE_SMALL_BEVELLED :
|
||||
case PUSTYLE_BEVELLED :
|
||||
case PUSTYLE_BOXED :
|
||||
case PUSTYLE_SPECIAL_UNDERLINED :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
hi = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_RADIO :
|
||||
case -PUSTYLE_RADIO :
|
||||
hi = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case -PUSTYLE_PLAIN :
|
||||
case -PUSTYLE_DROPSHADOW :
|
||||
mid = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case -PUSTYLE_SMALL_BEVELLED :
|
||||
case -PUSTYLE_BEVELLED :
|
||||
case -PUSTYLE_SMALL_SHADED :
|
||||
case -PUSTYLE_SHADED :
|
||||
case -PUSTYLE_BOXED :
|
||||
case -PUSTYLE_SPECIAL_UNDERLINED :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
hi = PUCOL_BACKGROUND ;
|
||||
lo = PUCOL_HIGHLIGHT ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
fprintf ( stderr, "PUI: Unrecognised 'style' %d\n", style ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( abs(style) )
|
||||
{
|
||||
case PUSTYLE_PLAIN :
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SMALL_BEVELLED :
|
||||
case PUSTYLE_SMALL_SHADED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL, dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL, dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL, dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL, dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL, dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL, dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( abs(style) == PUSTYLE_SMALL_BEVELLED )
|
||||
{
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0] + PU_SMALL_BEVEL, dy + min[1] + PU_SMALL_BEVEL,
|
||||
dx + max[0] - PU_SMALL_BEVEL, dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_POLYGON);
|
||||
glColor4fv( colour [ mid ] );
|
||||
glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL );
|
||||
if(style==PUSTYLE_SMALL_SHADED)
|
||||
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] );
|
||||
else
|
||||
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] );
|
||||
glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL );
|
||||
glColor4fv( colour [ mid ] );
|
||||
glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL );
|
||||
if(style==-PUSTYLE_SMALL_SHADED)
|
||||
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] );
|
||||
else
|
||||
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] );
|
||||
glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL );
|
||||
glEnd();
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
if(style == -PUSTYLE_SMALL_SHADED)
|
||||
{
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL/2 , dy + min[1] + PU_SMALL_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL/2 , dy + max[1] - PU_SMALL_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL/2 , dy + max[1] - PU_SMALL_BEVEL/2 ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL/2 , dy + min[1] + PU_SMALL_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL/2 , dy + min[1] + PU_SMALL_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL/2 , dy + max[1] - PU_SMALL_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSTYLE_BEVELLED :
|
||||
case PUSTYLE_SHADED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL, dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL, dy + max[1] - PU_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL, dy + max[1] - PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL, dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL, dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL, dy + max[1] - PU_BEVEL ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( abs(style) == PUSTYLE_BEVELLED )
|
||||
{
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0] + PU_BEVEL, dy + min[1] + PU_BEVEL,
|
||||
dx + max[0] - PU_BEVEL, dy + max[1] - PU_BEVEL ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_POLYGON);
|
||||
glColor4fv( colour [ mid ] );
|
||||
glVertex2i( dx + min[0] + PU_BEVEL , dy + min[1] + PU_BEVEL );
|
||||
if(style==PUSTYLE_SHADED)
|
||||
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] );
|
||||
else
|
||||
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] );
|
||||
glVertex2i( dx + min[0] + PU_BEVEL , dy + max[1] - PU_BEVEL );
|
||||
glColor4fv( colour [ mid ] );
|
||||
glVertex2i( dx + max[0] - PU_BEVEL , dy + max[1] - PU_BEVEL );
|
||||
if(style==-PUSTYLE_SHADED)
|
||||
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] );
|
||||
else
|
||||
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] );
|
||||
glVertex2i( dx + max[0] - PU_BEVEL , dy + min[1] + PU_BEVEL );
|
||||
glEnd();
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
if(style == -PUSTYLE_SHADED)
|
||||
{
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL , dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL/2 , dy + min[1] + PU_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL , dy + max[1] - PU_BEVEL ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL/2 , dy + max[1] - PU_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL , dy + max[1] - PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL/2 , dy + max[1] - PU_BEVEL/2 ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL/2 , dy + min[1] + PU_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_BEVEL , dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL/2 , dy + min[1] + PU_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL , dy + min[1] + PU_BEVEL ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL/2 , dy + max[1] - PU_BEVEL/2 ) ;
|
||||
glVertex2i ( dx + max[0] - PU_BEVEL , dy + max[1] - PU_BEVEL ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSTYLE_BOXED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0]+PU_BOX_WIDTH, dy + min[1]+PU_BOX_WIDTH,
|
||||
dx + max[0]-PU_BOX_WIDTH, dy + max[1]-PU_BOX_WIDTH ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_RADIO :
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + PU_RADIO_BUTTON_SIZE ) ;
|
||||
glVertex2i ( dx + min[0] , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( style < 0 )
|
||||
{
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUADS ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + 2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE-2, dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + PU_RADIO_BUTTON_SIZE-2 ) ;
|
||||
glVertex2i ( dx + min[0] + 2 , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SPECIAL_UNDERLINED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + min[1]+2 ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1]+1,
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_DROPSHADOW :
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glRecti ( dx + min[0] + PU_DROPSHADOW_OFFSET, dy + min[1] - PU_DROPSHADOW_OFFSET,
|
||||
dx + max[0] + PU_DROPSHADOW_OFFSET, dy + max[1] - PU_DROPSHADOW_OFFSET ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( am_default )
|
||||
{
|
||||
glColor4fv ( colour [ PUCOL_BACKGROUND ] ) ;
|
||||
glLineStipple ( 1, 0xF0F0 ) ;
|
||||
glEnable ( GL_LINE_STIPPLE ) ;
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ;
|
||||
glEnd () ;
|
||||
glDisable ( GL_LINE_STIPPLE ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puButton::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible ) return ;
|
||||
|
||||
/* If button is pushed or highlighted - use inverse style for button itself */
|
||||
|
||||
int tempStyle;
|
||||
|
||||
if ( parent && ( ( parent->getType() & PUCLASS_POPUPMENU ) ||
|
||||
( parent->getType() & PUCLASS_MENUBAR ) ) )
|
||||
tempStyle = ( getValue() ^ highlighted ) ? PUSTYLE_SMALL_SHADED : style ;
|
||||
else
|
||||
tempStyle = ( getValue() ^ highlighted ) ? -style : style ;
|
||||
|
||||
abox . draw ( dx, dy, tempStyle, colour, isReturnDefault() ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
int xx = ( abox.max[0] - abox.min[0] - puGetStringWidth(legendFont,legend) ) / 2 ;
|
||||
int yy = ( abox.max[1] - abox.min[1] - puGetStringHeight(legendFont) ) / 2 ;
|
||||
|
||||
puDrawString ( legendFont, legend,
|
||||
dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + yy ) ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puButton::doHit ( int button, int updown, int, int )
|
||||
{
|
||||
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
setValue ( (int) ! getValue () ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
puButtonBox::puButtonBox ( int minx, int miny, int maxx, int maxy,
|
||||
char **labels, int one_button ) :
|
||||
puObject ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_BUTTONBOX ;
|
||||
one_only = one_button ;
|
||||
|
||||
button_labels = labels ;
|
||||
|
||||
for ( num_kids = 0 ; button_labels [ num_kids ] != NULL ; num_kids++ )
|
||||
/* Count number of labels */ ;
|
||||
}
|
||||
|
||||
|
||||
int puButtonBox::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( updown == PU_UP ||
|
||||
! isReturnDefault() ||
|
||||
( key != '\r' && key != '\n' ) )
|
||||
return FALSE ;
|
||||
|
||||
int v = getValue () ;
|
||||
|
||||
if ( ! one_only )
|
||||
v = ~v ;
|
||||
else
|
||||
if ( v++ > num_kids )
|
||||
v = 0 ;
|
||||
|
||||
setValue ( v ) ;
|
||||
invokeCallback() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
int puButtonBox::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( ! isHit ( x, y ) ||
|
||||
( updown != active_mouse_edge &&
|
||||
active_mouse_edge != PU_UP_AND_DOWN ) )
|
||||
return FALSE ;
|
||||
|
||||
int i = num_kids - 1 - (( y - abox.min[1] - PUSTR_BGAP ) * num_kids ) /
|
||||
( abox.max[1] - abox.min[1] - PUSTR_BGAP - PUSTR_TGAP ) ;
|
||||
|
||||
if ( i < 0 ) i = 0 ;
|
||||
if ( i >= num_kids ) i = num_kids - 1 ;
|
||||
|
||||
if ( one_only )
|
||||
setValue ( i ) ;
|
||||
else
|
||||
setValue ( getValue () ^ ( 1 << i ) ) ;
|
||||
|
||||
invokeCallback () ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
void puButtonBox::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible ) return ;
|
||||
|
||||
abox . draw ( dx, dy, style, colour, isReturnDefault() ) ;
|
||||
|
||||
for ( int i = 0 ; i < num_kids ; i++ )
|
||||
{
|
||||
puBox tbox ;
|
||||
|
||||
tbox . min [ 0 ] = abox.min [ 0 ] + PUSTR_LGAP + PUSTR_LGAP ;
|
||||
tbox . min [ 1 ] = abox.min [ 1 ] + ((abox.max[1]-abox.min[1]-PUSTR_TGAP-PUSTR_BGAP)/num_kids) * (num_kids-1-i) ;
|
||||
tbox . max [ 0 ] = tbox.min [ 0 ] ;
|
||||
tbox . max [ 1 ] = tbox.min [ 1 ] ;
|
||||
|
||||
if (( one_only && i == getValue() ) ||
|
||||
( !one_only && ((1<<i) & getValue() ) != 0 ) )
|
||||
tbox . draw ( dx, dy + PUSTR_BGAP + PUSTR_BGAP, -PUSTYLE_RADIO, colour, FALSE ) ;
|
||||
else
|
||||
tbox . draw ( dx, dy + PUSTR_BGAP + PUSTR_BGAP, PUSTYLE_RADIO, colour, FALSE ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
puDrawString ( legendFont, button_labels[i],
|
||||
dx + tbox.min[0] + PU_RADIO_BUTTON_SIZE + PUSTR_LGAP,
|
||||
dy + tbox.min[1] + puGetStringDescender(legendFont) + PUSTR_BGAP + PUSTR_BGAP) ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puFrame::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible ) return ;
|
||||
|
||||
abox . draw ( dx, dy, style, colour, FALSE ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
int xx = ( abox.max[0] - abox.min[0] - puGetStringWidth ( legendFont, legend ) ) / 2 ;
|
||||
|
||||
puDrawString ( legendFont, legend,
|
||||
dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + puGetStringDescender ( legendFont ) + PUSTR_BGAP ) ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
226
PUI/puInput.cxx
226
PUI/puInput.cxx
@@ -1,226 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puInput::normalize_cursors ( void )
|
||||
{
|
||||
char val [ PUSTRING_MAX ] ;
|
||||
getValue ( val ) ;
|
||||
int sl = strlen ( val ) ;
|
||||
|
||||
/* Clamp the positions to the limits of the text. */
|
||||
|
||||
if ( cursor_position < 0 ) cursor_position = 0 ;
|
||||
if ( select_start_position < 0 ) select_start_position = 0 ;
|
||||
if ( select_end_position < 0 ) select_end_position = 0 ;
|
||||
if ( cursor_position > sl ) cursor_position = sl ;
|
||||
if ( select_start_position > sl ) select_start_position = sl ;
|
||||
if ( select_end_position > sl ) select_end_position = sl ;
|
||||
|
||||
/* Swap the ends of the select window if they get crossed over */
|
||||
|
||||
if ( select_end_position < select_start_position )
|
||||
{
|
||||
int tmp = select_end_position ;
|
||||
select_end_position = select_start_position ;
|
||||
select_start_position = tmp ;
|
||||
}
|
||||
}
|
||||
|
||||
void puInput::draw ( int dx, int dy )
|
||||
{
|
||||
normalize_cursors () ;
|
||||
|
||||
if ( !visible ) return ;
|
||||
|
||||
/* 3D Input boxes look nicest if they are always in inverse style. */
|
||||
|
||||
abox . draw ( dx, dy, ( (style==PUSTYLE_SMALL_BEVELLED ||
|
||||
style==PUSTYLE_SMALL_SHADED) ) ? -style :
|
||||
(accepting ? -style : style ), colour, FALSE ) ;
|
||||
|
||||
int xx = puGetStringWidth ( legendFont, " " ) ;
|
||||
int yy = ( abox.max[1] - abox.min[1] - puGetStringHeight(legendFont) ) / 2 ;
|
||||
|
||||
if ( accepting )
|
||||
{
|
||||
char val [ PUSTRING_MAX ] ;
|
||||
getValue ( val ) ;
|
||||
|
||||
/* Highlight the select area */
|
||||
|
||||
if ( select_end_position > 0 &&
|
||||
select_end_position != select_start_position )
|
||||
{
|
||||
val [ select_end_position ] = '\0' ;
|
||||
int cpos2 = puGetStringWidth ( legendFont, val ) + xx + dx + abox.min[0] ;
|
||||
val [ select_start_position ] = '\0' ;
|
||||
int cpos1 = puGetStringWidth ( legendFont, val ) + xx + dx + abox.min[0] ;
|
||||
|
||||
glColor3f ( 1.0f, 1.0f, 0.7f ) ;
|
||||
glRecti ( cpos1, dy + abox.min[1] + 6 ,
|
||||
cpos2, dy + abox.max[1] - 6 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the text */
|
||||
|
||||
{
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
char val [ PUSTRING_MAX ] ;
|
||||
getValue ( val ) ;
|
||||
|
||||
puDrawString ( legendFont, val,
|
||||
dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + yy ) ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
if ( accepting )
|
||||
{
|
||||
char val [ PUSTRING_MAX ] ;
|
||||
getValue ( val ) ;
|
||||
|
||||
/* Draw the 'I' bar cursor. */
|
||||
|
||||
if ( cursor_position >= 0 )
|
||||
{
|
||||
val [ cursor_position ] = '\0' ;
|
||||
|
||||
int cpos = puGetStringWidth ( legendFont, val ) + xx + dx + abox.min[0] ;
|
||||
|
||||
glColor3f ( 0.1f, 0.1f, 1.0f ) ;
|
||||
glBegin ( GL_LINES ) ;
|
||||
glVertex2i ( cpos , dy + abox.min[1] + 7 ) ;
|
||||
glVertex2i ( cpos , dy + abox.max[1] - 7 ) ;
|
||||
glVertex2i ( cpos - 1, dy + abox.min[1] + 7 ) ;
|
||||
glVertex2i ( cpos - 1, dy + abox.max[1] - 7 ) ;
|
||||
glVertex2i ( cpos - 4, dy + abox.min[1] + 7 ) ;
|
||||
glVertex2i ( cpos + 3, dy + abox.min[1] + 7 ) ;
|
||||
glVertex2i ( cpos - 4, dy + abox.max[1] - 7 ) ;
|
||||
glVertex2i ( cpos + 3, dy + abox.max[1] - 7 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puInput::doHit ( int button, int updown, int x, int /* y */ )
|
||||
{
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
/* Most GUI's activate a button on button-UP not button-DOWN. */
|
||||
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
|
||||
char *strval ;
|
||||
getValue ( & strval ) ;
|
||||
char *tmpval = new char [ strlen(strval) + 1 ] ;
|
||||
strcpy ( tmpval, strval ) ;
|
||||
|
||||
int i = strlen ( tmpval ) ;
|
||||
|
||||
while ( x <= puGetStringWidth ( legendFont, tmpval ) + abox.min[0] &&
|
||||
i >= 0 )
|
||||
tmpval[--i] = '\0' ;
|
||||
|
||||
accepting = TRUE ;
|
||||
cursor_position = i ;
|
||||
normalize_cursors () ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
int puInput::checkKey ( int key, int updown )
|
||||
{
|
||||
(updown,updown);
|
||||
|
||||
if ( ! isAcceptingInput() || ! isActive () || ! isVisible () )
|
||||
return FALSE ;
|
||||
|
||||
normalize_cursors () ;
|
||||
|
||||
char *p ;
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case PU_KEY_PAGE_UP :
|
||||
case PU_KEY_PAGE_DOWN :
|
||||
case PU_KEY_INSERT : return FALSE ;
|
||||
|
||||
case PU_KEY_UP :
|
||||
case PU_KEY_DOWN :
|
||||
case 0x1B /* ESC */ :
|
||||
case '\t' :
|
||||
case '\r' :
|
||||
case '\n' : /* Carriage return/Line Feed/TAB -- End of input */
|
||||
rejectInput () ;
|
||||
normalize_cursors () ;
|
||||
invokeCallback () ;
|
||||
break ;
|
||||
|
||||
case '\b' : /* Backspace */
|
||||
if ( cursor_position > 0 )
|
||||
for ( p = & string [ --cursor_position ] ; *p != '\0' ; p++ )
|
||||
*p = *(p+1) ;
|
||||
break ;
|
||||
|
||||
case 0x7F : /* DEL */
|
||||
if ( select_start_position != select_end_position )
|
||||
{
|
||||
char *p1 = & string [ select_start_position ] ;
|
||||
char *p2 = & string [ select_end_position ] ;
|
||||
|
||||
while ( *p1 != '\0' )
|
||||
*p1++ = *p2++ ;
|
||||
|
||||
select_end_position = select_start_position ;
|
||||
}
|
||||
else
|
||||
for ( p = & string [ cursor_position ] ; *p != '\0' ; p++ )
|
||||
*p = *(p+1) ;
|
||||
break ;
|
||||
|
||||
case 0x15 /* ^U */ : string [ 0 ] = '\0' ; break ;
|
||||
case PU_KEY_HOME : cursor_position = 0 ; break ;
|
||||
case PU_KEY_END : cursor_position = PUSTRING_MAX ; break ;
|
||||
case PU_KEY_LEFT : cursor_position-- ; break ;
|
||||
case PU_KEY_RIGHT : cursor_position++ ; break ;
|
||||
|
||||
default:
|
||||
if ( key < ' ' || key > 127 ) return FALSE ;
|
||||
|
||||
if ( strlen ( string ) >= PUSTRING_MAX )
|
||||
return FALSE ;
|
||||
|
||||
for ( p = & string [ strlen(string) ] ;
|
||||
p != &string[cursor_position] ; p-- )
|
||||
*(p+1) = *p ;
|
||||
|
||||
*p = key ;
|
||||
cursor_position++ ;
|
||||
break ;
|
||||
}
|
||||
|
||||
setValue ( string ) ;
|
||||
normalize_cursors () ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#define PUSTACK_MAX 100
|
||||
|
||||
static int currLiveInterface = -1 ;
|
||||
static puInterface *liveInterfaceStack [ PUSTACK_MAX ] ;
|
||||
static int currInterface = -1 ;
|
||||
static puInterface *interfaceStack [ PUSTACK_MAX ] ;
|
||||
|
||||
void puPushLiveInterface ( puInterface *in )
|
||||
{
|
||||
if ( currLiveInterface < PUSTACK_MAX )
|
||||
liveInterfaceStack [ ++currLiveInterface ] = in ;
|
||||
else
|
||||
fprintf ( stderr, "PUI: Too many live puInterfaces open at once!\n" ) ;
|
||||
}
|
||||
|
||||
void puPushInterface ( puInterface *in )
|
||||
{
|
||||
if ( currInterface < PUSTACK_MAX )
|
||||
interfaceStack [ ++currInterface ] = in ;
|
||||
else
|
||||
fprintf ( stderr, "PUI: Too many puInterfaces open at once!\n" ) ;
|
||||
}
|
||||
|
||||
void puPopLiveInterface ( void )
|
||||
{
|
||||
if ( currLiveInterface > 0 )
|
||||
--currLiveInterface ;
|
||||
else
|
||||
fprintf ( stderr, "PUI: Live puInterface stack is empty!\n" ) ;
|
||||
}
|
||||
|
||||
void puPopInterface ( void )
|
||||
{
|
||||
if ( currInterface > 0 )
|
||||
--currInterface ;
|
||||
else
|
||||
fprintf ( stderr, "PUI: puInterface stack is empty!\n" ) ;
|
||||
}
|
||||
|
||||
int puNoLiveInterface ( void )
|
||||
{
|
||||
return currLiveInterface < 0 ;
|
||||
}
|
||||
|
||||
int puNoInterface ( void )
|
||||
{
|
||||
return currInterface < 0 ;
|
||||
}
|
||||
|
||||
puInterface *puGetUltimateLiveInterface ( void )
|
||||
{
|
||||
if ( currLiveInterface < 0 )
|
||||
{
|
||||
fprintf ( stderr, "PUI: No Live Interface!\n" ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return liveInterfaceStack [ 0 ] ;
|
||||
}
|
||||
|
||||
|
||||
puInterface *puGetBaseLiveInterface ( void )
|
||||
{
|
||||
if ( currLiveInterface < 0 )
|
||||
{
|
||||
fprintf ( stderr, "PUI: No Live Interface!\n" ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*
|
||||
Work down the interface stack until you
|
||||
either get to the bottom or find a block
|
||||
in the form of a puDialogBox.
|
||||
*/
|
||||
|
||||
for ( int i = currLiveInterface ; i > 0 ; i-- )
|
||||
if ( liveInterfaceStack [ i ] -> getType () & PUCLASS_DIALOGBOX )
|
||||
return liveInterfaceStack [ i ] ;
|
||||
|
||||
return liveInterfaceStack [ 0 ] ;
|
||||
}
|
||||
|
||||
puInterface *puGetCurrInterface ( void )
|
||||
{
|
||||
if ( currInterface < 0 )
|
||||
{
|
||||
fprintf ( stderr, "PUI: No Interface!\n" ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return interfaceStack [ currInterface ] ;
|
||||
}
|
||||
|
||||
void puInterface::remove ( puObject *obj )
|
||||
{
|
||||
if ( dlist == NULL )
|
||||
return ;
|
||||
|
||||
/* Are we the first object in the list */
|
||||
|
||||
if ( obj -> prev == NULL )
|
||||
dlist = obj -> next ;
|
||||
else
|
||||
obj -> prev -> next = obj -> next ;
|
||||
|
||||
/* Are we the last object in the list */
|
||||
|
||||
if ( obj -> next != NULL )
|
||||
obj -> next -> prev = obj -> prev ;
|
||||
|
||||
obj -> next = NULL ;
|
||||
obj -> prev = NULL ;
|
||||
|
||||
num_children-- ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puInterface::add ( puObject *new_obj )
|
||||
{
|
||||
if ( dlist == NULL )
|
||||
{
|
||||
dlist = new_obj ;
|
||||
new_obj -> next = NULL ;
|
||||
new_obj -> prev = NULL ;
|
||||
}
|
||||
else
|
||||
{
|
||||
puObject *last ;
|
||||
|
||||
for ( last = dlist ; last->next != NULL ; last = last->next )
|
||||
/* Search for end of list. */ ;
|
||||
|
||||
last -> next = new_obj ;
|
||||
new_obj -> prev = last ;
|
||||
new_obj -> next = NULL ;
|
||||
}
|
||||
|
||||
num_children++ ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
int puInterface::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo->prev )
|
||||
if ( bo -> checkKey ( key, updown ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
int puInterface::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
/*
|
||||
This might be a bit redundant - but it's too hard to keep
|
||||
track of changing abox sizes when daughter objects are
|
||||
changing sizes.
|
||||
*/
|
||||
|
||||
recalc_bbox () ;
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
x -= abox.min[0] ;
|
||||
y -= abox.min[1] ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo->prev )
|
||||
if ( bo -> checkHit ( button, updown, x, y ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
void puInterface::draw ( int dx, int dy )
|
||||
{
|
||||
if ( ! isVisible () )
|
||||
return ;
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
|
||||
{
|
||||
/* June 16th, 98, Shammi :
|
||||
* The next if statement checks if the object is
|
||||
* a menu bar and makes sure it is repositioned
|
||||
* correctly.
|
||||
*/
|
||||
|
||||
if ( bo->getType() & PUCLASS_MENUBAR )
|
||||
{
|
||||
int obWidth, obHeight ;
|
||||
bo -> getSize ( &obWidth, &obHeight ) ;
|
||||
bo -> setPosition ( 0, puGetWindowHeight() - obHeight ) ;
|
||||
}
|
||||
|
||||
bo -> draw ( dx + abox.min[0], dy + abox.min[1] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puInterface::recalc_bbox ( void )
|
||||
{
|
||||
puBox contents ;
|
||||
contents . empty () ;
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
|
||||
contents . extend ( bo -> getBBox() ) ;
|
||||
|
||||
if ( contents . isEmpty () )
|
||||
{
|
||||
abox . max[0] = abox . min[0] ;
|
||||
abox . max[1] = abox . min[1] ;
|
||||
}
|
||||
else
|
||||
{
|
||||
abox . max[0] = abox . min[0] + contents . max[0] ;
|
||||
abox . max[1] = abox . min[1] + contents . max[1] ;
|
||||
}
|
||||
|
||||
puObject::recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
void puInterface::doHit ( int, int, int, int )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
puInterface::~puInterface ()
|
||||
{
|
||||
puPopLiveInterface () ;
|
||||
|
||||
puObject *bo = dlist ;
|
||||
|
||||
while ( bo != NULL ) {
|
||||
puObject *tmp_bo = bo->next ;
|
||||
delete bo ;
|
||||
bo = tmp_bo ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifndef PU_NOT_USING_GLUT
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#include "pu.h"
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void drop_down_the_menu ( puObject *b )
|
||||
{
|
||||
puPopupMenu *p = (puPopupMenu *) b -> getUserData () ;
|
||||
|
||||
if ( b -> getValue () )
|
||||
p->reveal () ;
|
||||
else
|
||||
p->hide () ;
|
||||
|
||||
for ( puObject *child = b -> getParent () -> getFirstChild () ;
|
||||
child != NULL ; child = child -> next )
|
||||
{
|
||||
if (( child -> getType() & PUCLASS_BUTTON ) != 0 && child != b ) child -> clrValue () ;
|
||||
if (( child -> getType() & PUCLASS_POPUPMENU ) != 0 && child != p ) child -> hide () ;
|
||||
}
|
||||
}
|
||||
|
||||
void puMenuBar::add_submenu ( char *str, char *items[], puCallback cb[] )
|
||||
{
|
||||
int w, h ;
|
||||
getSize ( &w, &h ) ;
|
||||
|
||||
puOneShot *b = new puOneShot ( w+10, 0, str ) ;
|
||||
b -> setStyle ( PUSTYLE_SPECIAL_UNDERLINED ) ;
|
||||
b -> setColourScheme ( colour[PUCOL_FOREGROUND][0],
|
||||
colour[PUCOL_FOREGROUND][1],
|
||||
colour[PUCOL_FOREGROUND][2],
|
||||
colour[PUCOL_FOREGROUND][3] ) ;
|
||||
b -> setCallback ( drop_down_the_menu ) ;
|
||||
b -> setActiveDirn ( PU_UP_AND_DOWN ) ;
|
||||
|
||||
puPopupMenu *p = new puPopupMenu ( w+10, 0 ) ;
|
||||
|
||||
b -> setUserData ( p ) ;
|
||||
|
||||
for ( int i = 0 ; items[i] != NULL ; i++ )
|
||||
p -> add_item ( items[i], cb[i] ) ;
|
||||
|
||||
p->close () ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puMenuBar::close (void)
|
||||
{
|
||||
puInterface::close () ;
|
||||
|
||||
if ( dlist == NULL )
|
||||
return ;
|
||||
|
||||
int width = 0 ;
|
||||
puObject *ob ;
|
||||
|
||||
/*
|
||||
Use alternate objects - which gets the puOneShot/puPopupMenu pairs
|
||||
*/
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> next )
|
||||
{
|
||||
int w, h ;
|
||||
|
||||
/* Reposition the button so it looks nice */
|
||||
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
ob -> setPosition ( width, 0 ) ;
|
||||
ob = ob -> next ;
|
||||
|
||||
/* Reposition the submenu so it sits under the button */
|
||||
|
||||
int w2, h2 ;
|
||||
ob -> getSize ( &w2, &h2 ) ;
|
||||
ob -> setPosition ( width, -h2 ) ;
|
||||
|
||||
/* Next please! */
|
||||
width += w ;
|
||||
}
|
||||
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
222
PUI/puObject.cxx
222
PUI/puObject.cxx
@@ -1,222 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
inline float clamp01 ( float x )
|
||||
{
|
||||
return (x >= 1.0f) ? 1.0f : x ;
|
||||
}
|
||||
|
||||
static void load_colour_scheme ( float col[][4], float r, float g,
|
||||
float b, float a )
|
||||
{
|
||||
puSetColour ( col [ PUCOL_FOREGROUND ], r, g, b, a ) ;
|
||||
puSetColour ( col [ PUCOL_BACKGROUND ], r/2, g/2, b/2, a ) ;
|
||||
puSetColour ( col [ PUCOL_HIGHLIGHT ], clamp01(r*1.3f), clamp01(g*1.3f),
|
||||
clamp01(b*1.3f), a ) ;
|
||||
|
||||
if ( 4 * g + 3 * r + b > 0.5 )
|
||||
puSetColour ( col [ PUCOL_LEGEND ], 0.0, 0.0, 0.0, a ) ;
|
||||
else
|
||||
puSetColour ( col [ PUCOL_LEGEND ], 1.0, 1.0, 1.0, a ) ;
|
||||
}
|
||||
|
||||
|
||||
static int defaultStyle = PUSTYLE_DEFAULT ;
|
||||
static puFont defaultLegendFont = NULL ;
|
||||
static puFont defaultLabelFont = NULL ;
|
||||
static float defaultColourScheme [ 4 ] ;
|
||||
|
||||
void puSetDefaultStyle ( int style ) { defaultStyle = style ; }
|
||||
int puGetDefaultStyle ( void ) { return defaultStyle ; }
|
||||
|
||||
void puSetDefaultFonts ( puFont legendFont, puFont labelFont )
|
||||
{
|
||||
defaultLegendFont = legendFont ;
|
||||
defaultLabelFont = labelFont ;
|
||||
}
|
||||
|
||||
void puGetDefaultFonts ( puFont *legendFont, puFont *labelFont )
|
||||
{
|
||||
if ( legendFont ) *legendFont = defaultLegendFont ;
|
||||
if ( labelFont ) *labelFont = defaultLabelFont ;
|
||||
}
|
||||
|
||||
void puSetDefaultColourScheme ( float r, float g, float b, float a )
|
||||
{
|
||||
defaultColourScheme[0] = r ;
|
||||
defaultColourScheme[1] = g ;
|
||||
defaultColourScheme[2] = b ;
|
||||
defaultColourScheme[3] = a ;
|
||||
load_colour_scheme ( _puDefaultColourTable, r, g, b, a ) ;
|
||||
}
|
||||
|
||||
void puGetDefaultColourScheme ( float *r, float *g, float *b, float *a )
|
||||
{
|
||||
if ( r ) *r = defaultColourScheme[0] ;
|
||||
if ( g ) *g = defaultColourScheme[1] ;
|
||||
if ( b ) *b = defaultColourScheme[2] ;
|
||||
if ( a ) *a = defaultColourScheme[3] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void puObject::setColourScheme ( float r, float g, float b, float a )
|
||||
{
|
||||
load_colour_scheme ( colour, r, g, b, a ) ;
|
||||
}
|
||||
|
||||
puObject::puObject ( int minx, int miny, int maxx, int maxy ) : puValue ()
|
||||
{
|
||||
type |= PUCLASS_OBJECT ;
|
||||
bbox.min[0] = abox.min[0] = minx ;
|
||||
bbox.min[1] = abox.min[1] = miny ;
|
||||
bbox.max[0] = abox.max[0] = maxx ;
|
||||
bbox.max[1] = abox.max[1] = maxy ;
|
||||
|
||||
active_mouse_edge = PU_UP ;
|
||||
style = defaultStyle ;
|
||||
visible = active = TRUE ;
|
||||
highlighted = FALSE ;
|
||||
am_default = FALSE ;
|
||||
|
||||
cb = NULL ;
|
||||
user_data = NULL ;
|
||||
next = prev = NULL ;
|
||||
label = NULL ;
|
||||
labelPlace = PUPLACE_DEFAULT ;
|
||||
labelFont = defaultLabelFont ;
|
||||
legend = NULL ;
|
||||
legendFont = defaultLegendFont ;
|
||||
|
||||
for ( int i = 0 ; i < PUCOL_MAX ; i++ )
|
||||
puSetColour ( colour[i], _puDefaultColourTable[i] ) ;
|
||||
|
||||
if ( ! puNoInterface() )
|
||||
{
|
||||
parent = puGetCurrInterface() ;
|
||||
parent -> add ( this ) ;
|
||||
}
|
||||
else
|
||||
parent = NULL ;
|
||||
}
|
||||
|
||||
|
||||
puObject::~puObject ()
|
||||
{
|
||||
if ( parent != this && parent != NULL )
|
||||
parent -> remove ( this ) ;
|
||||
}
|
||||
|
||||
void puObject::recalc_bbox ( void )
|
||||
{
|
||||
bbox = abox ;
|
||||
|
||||
if ( label != NULL )
|
||||
switch ( labelPlace )
|
||||
{
|
||||
case PUPLACE_ABOVE : bbox.max[1] += puGetStringHeight ( getLabelFont() ) + puGetStringDescender ( getLabelFont () ) + PUSTR_TGAP + PUSTR_BGAP ; break ;
|
||||
case PUPLACE_BELOW : bbox.min[1] -= puGetStringHeight ( getLabelFont() ) + puGetStringDescender ( getLabelFont () ) + PUSTR_TGAP + PUSTR_BGAP ; break ;
|
||||
case PUPLACE_LEFT : bbox.min[0] -= puGetStringWidth ( getLabelFont(), getLabel() ) + PUSTR_LGAP + PUSTR_RGAP ; break ;
|
||||
case PUPLACE_RIGHT : bbox.max[0] += puGetStringWidth ( getLabelFont(), getLabel() ) + PUSTR_LGAP + PUSTR_RGAP ; break ;
|
||||
}
|
||||
|
||||
if ( parent != NULL )
|
||||
parent -> recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puObject::draw_label ( int dx, int dy )
|
||||
{
|
||||
if ( !visible ) return ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LABEL ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LABEL ][0],
|
||||
colour [ PUCOL_LABEL ][1],
|
||||
colour [ PUCOL_LABEL ][2],
|
||||
colour [ PUCOL_LABEL ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
switch ( labelPlace )
|
||||
{
|
||||
case PUPLACE_ABOVE : puDrawString ( labelFont, label, dx + abox.min[0] + PUSTR_LGAP, dy + abox.max[1] + puGetStringDescender(labelFont) + PUSTR_BGAP ) ; break ;
|
||||
case PUPLACE_BELOW : puDrawString ( labelFont, label, dx + abox.min[0] + PUSTR_LGAP, dy + bbox.min[1] + puGetStringDescender(labelFont) + PUSTR_BGAP ) ; break ;
|
||||
case PUPLACE_LEFT : puDrawString ( labelFont, label, dx + bbox.min[0] + PUSTR_LGAP, dy + abox.min[1] + puGetStringDescender(labelFont) + PUSTR_BGAP ) ; break ;
|
||||
case PUPLACE_RIGHT : puDrawString ( labelFont, label, dx + abox.max[0] + PUSTR_LGAP, dy + abox.min[1] + puGetStringDescender(labelFont) + PUSTR_BGAP ) ; break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int puObject::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( updown == PU_UP )
|
||||
return FALSE ;
|
||||
|
||||
if ( isReturnDefault() && ( key == '\r' || key == '\n' ) )
|
||||
{
|
||||
checkHit ( PU_LEFT_BUTTON, PU_DOWN, (abox.min[0]+abox.max[0])/2,
|
||||
(abox.min[1]+abox.max[1])/2 ) ;
|
||||
checkHit ( PU_LEFT_BUTTON, PU_UP , (abox.min[0]+abox.max[0])/2,
|
||||
(abox.min[1]+abox.max[1])/2 ) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
void puObject::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
(x,x);(y,y);
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
int puObject::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( isHit( x, y ) )
|
||||
{
|
||||
doHit ( button, updown, x, y ) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
lowlight () ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
char *puValue::getTypeString ( void )
|
||||
{
|
||||
int i = getType () ;
|
||||
|
||||
if ( i & PUCLASS_DIALOGBOX ) return "puDialogBox" ;
|
||||
if ( i & PUCLASS_SLIDER ) return "puSlider" ;
|
||||
if ( i & PUCLASS_BUTTONBOX ) return "puButtonBox" ;
|
||||
if ( i & PUCLASS_INPUT ) return "puInput" ;
|
||||
if ( i & PUCLASS_MENUBAR ) return "puMenuBar" ;
|
||||
if ( i & PUCLASS_POPUPMENU ) return "puPopupMenu" ;
|
||||
if ( i & PUCLASS_POPUP ) return "puPopup" ;
|
||||
if ( i & PUCLASS_ONESHOT ) return "puOneShot" ;
|
||||
if ( i & PUCLASS_BUTTON ) return "puButton" ;
|
||||
if ( i & PUCLASS_TEXT ) return "puText" ;
|
||||
if ( i & PUCLASS_FRAME ) return "puFrame" ;
|
||||
if ( i & PUCLASS_INTERFACE ) return "puInterface" ;
|
||||
if ( i & PUCLASS_OBJECT ) return "puObject" ;
|
||||
if ( i & PUCLASS_VALUE ) return "puValue" ;
|
||||
|
||||
return "Unknown Object type." ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puOneShot::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
puButton::doHit ( button, updown, x, y ) ;
|
||||
setValue ( 0 ) ;
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
#include "puLocal.h"
|
||||
|
||||
#define PUMENU_BUTTON_HEIGHT 25
|
||||
#define PUMENU_BUTTON_EXTRA_WIDTH 25
|
||||
|
||||
puObject *puPopupMenu::add_item ( char *str, puCallback cb )
|
||||
{
|
||||
int w, h ;
|
||||
getSize ( &w, &h ) ;
|
||||
puOneShot *b = new puOneShot ( 0, h, str ) ;
|
||||
b->setStyle ( PUSTYLE_PLAIN ) ;
|
||||
b->setColourScheme ( colour[PUCOL_FOREGROUND][0],
|
||||
colour[PUCOL_FOREGROUND][1],
|
||||
colour[PUCOL_FOREGROUND][2],
|
||||
colour[PUCOL_FOREGROUND][3] ) ;
|
||||
b->setCallback ( cb ) ;
|
||||
recalc_bbox () ;
|
||||
return b ;
|
||||
}
|
||||
|
||||
void puPopupMenu::close ( void )
|
||||
{
|
||||
puPopup::close () ;
|
||||
|
||||
int widest = 0 ;
|
||||
puObject *ob = dlist ;
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi
|
||||
* There seems to be some mismatch with the
|
||||
* #define pumenusize and the actual size
|
||||
* There seems to be some overlap resulting
|
||||
* in more than one option being highlighted.
|
||||
* By setting the size to the actual values,
|
||||
* the overlap area seems to be less now.
|
||||
*/
|
||||
|
||||
int w, h ;
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> next )
|
||||
{
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
|
||||
if ( w > widest ) widest = w ;
|
||||
}
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> next )
|
||||
{
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
ob -> setSize ( widest, h ) ;
|
||||
}
|
||||
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
int puPopupMenu::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
if ( updown == PU_DOWN )
|
||||
{
|
||||
hide () ;
|
||||
|
||||
/* Turn everything off ready for next time. */
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
|
||||
bo -> clrValue () ;
|
||||
}
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo->prev )
|
||||
if ( bo -> checkKey ( key, updown ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
int puPopupMenu::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
/* Must test 'isHit' before making the menu invisible! */
|
||||
|
||||
int hit = isHit ( x, y ) ;
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi :
|
||||
* There seemed to be a miscalculation with the menus initially
|
||||
* Therefore I moved the recalculation stuff before the clearing.
|
||||
*/
|
||||
|
||||
/*
|
||||
This might be a bit redundant - but it's too hard to keep
|
||||
track of changing abox sizes when daughter objects are
|
||||
changing sizes.
|
||||
*/
|
||||
|
||||
recalc_bbox();
|
||||
x -= abox.min[0] ;
|
||||
y -= abox.min[1] ;
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi :
|
||||
* Also clear the menu when the dragging the mouse and not hit.
|
||||
*/
|
||||
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ||
|
||||
( updown == PU_DRAG && !hit ) )
|
||||
{
|
||||
|
||||
/* June 17th, 1998, Shammi :
|
||||
* Do not hide the menu if mouse is dragged out
|
||||
*/
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
hide () ;
|
||||
|
||||
/* Turn everything off ready for next time. */
|
||||
|
||||
/* June 17th, 1998, Shammi:
|
||||
* Make sure we check for a hit, if the mouse is moved
|
||||
* out of the menu.
|
||||
*/
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
|
||||
{
|
||||
if ( ! hit )
|
||||
bo -> checkHit ( button, updown, x , y ) ;
|
||||
|
||||
bo -> clrValue () ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! hit )
|
||||
return FALSE ;
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
/* June 17th, 1998, Shammi :
|
||||
* If the mouse is dragged and the menuItem is not hit,
|
||||
* clear it
|
||||
*/
|
||||
|
||||
for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
|
||||
if ( updown == PU_DRAG && ! bo -> checkHit ( button, updown, x, y ) )
|
||||
bo -> clrValue () ;
|
||||
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo->prev )
|
||||
if ( bo -> checkHit ( button, updown, x, y ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
107
PUI/puSlider.cxx
107
PUI/puSlider.cxx
@@ -1,107 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puSlider::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible ) return ;
|
||||
|
||||
abox . draw ( dx, dy,
|
||||
(style==PUSTYLE_BEVELLED||
|
||||
style==PUSTYLE_SHADED) ? -PUSTYLE_BOXED : -style,
|
||||
colour, FALSE ) ;
|
||||
|
||||
int sd, od ;
|
||||
|
||||
if ( isVertical() ) { sd = 1 ; od = 0 ; } else { sd = 0 ; od = 1 ; }
|
||||
|
||||
int sz = abox.max [sd] - abox.min [sd] ;
|
||||
|
||||
float val ;
|
||||
|
||||
getValue ( & val ) ;
|
||||
|
||||
if ( val < 0.0f ) val = 0.0f ;
|
||||
if ( val > 1.0f ) val = 1.0f ;
|
||||
|
||||
val *= (float) sz * (1.0f - slider_fraction) ;
|
||||
|
||||
puBox bx ;
|
||||
|
||||
bx . min [ sd ] = abox . min [ sd ] + (int) val ;
|
||||
bx . max [ sd ] = (int) ( (float) bx . min [ sd ] + (float) sz * slider_fraction ) ;
|
||||
bx . min [ od ] = abox . min [ od ] + 2 ;
|
||||
bx . max [ od ] = abox . max [ od ] - 2 ;
|
||||
|
||||
bx . draw ( dx, dy, PUSTYLE_SMALL_SHADED, colour, FALSE ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
int xx = ( abox.max[0] - abox.min[0] - puGetStringWidth(legendFont,legend) ) / 2 ;
|
||||
int yy = ( abox.max[1] - abox.min[1] - puGetStringHeight(legendFont) ) / 2 ;
|
||||
|
||||
puDrawString ( legendFont, legend,
|
||||
dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + yy ) ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puSlider::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
int sd = isVertical() ;
|
||||
int sz = abox.max [sd] - abox.min [sd] ;
|
||||
int coord = isVertical() ? y : x ;
|
||||
|
||||
float next_value ;
|
||||
|
||||
if ( sz == 0 )
|
||||
next_value = 0.5f ;
|
||||
else
|
||||
{
|
||||
next_value = ( (float)coord - (float)abox.min[sd] - (float)sz * slider_fraction / 2.0f ) /
|
||||
( (float) sz * (1.0f - slider_fraction) ) ;
|
||||
}
|
||||
|
||||
next_value = (next_value < 0.0f) ? 0.0f : (next_value > 1.0) ? 1.0f : next_value ;
|
||||
|
||||
setValue ( next_value ) ;
|
||||
|
||||
switch ( cb_mode )
|
||||
{
|
||||
case PUSLIDER_CLICK :
|
||||
if ( updown == active_mouse_edge )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_DELTA :
|
||||
if ( fabs ( last_cb_value - next_value ) >= cb_delta )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_ALWAYS :
|
||||
default :
|
||||
last_cb_value = next_value ;
|
||||
invokeCallback () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
void puText::draw ( int dx, int dy )
|
||||
{
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
bin_PROGRAMS = testserial
|
||||
|
||||
noinst_LIBRARIES = libSerial.a
|
||||
|
||||
libSerial_a_SOURCES = serial.cxx serial.hxx
|
||||
|
||||
testserial_SOURCES = testserial.cxx
|
||||
|
||||
testserial_LDADD = \
|
||||
$(top_builddir)/Lib/Serial/libSerial.a \
|
||||
$(top_builddir)/Lib/Debug/libDebug.a
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib
|
||||
1
VERSION.in
Normal file
1
VERSION.in
Normal file
@@ -0,0 +1 @@
|
||||
@VERSION@
|
||||
@@ -1,5 +0,0 @@
|
||||
lib_LIBRARIES = libXGL.a
|
||||
|
||||
libXGL_a_SOURCES = xgl.c xgl.h xglUtils.c
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator
|
||||
324
acconfig.h
Normal file
324
acconfig.h
Normal file
@@ -0,0 +1,324 @@
|
||||
/* acconfig.h
|
||||
This file is in the public domain.
|
||||
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the distributed Autoconf macros can define.
|
||||
No software package will use all of them; autoheader copies the ones
|
||||
your configure.in uses into your configuration header file templates.
|
||||
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). Although this order
|
||||
can split up related entries, it makes it easier to check whether
|
||||
a given entry is in the file.
|
||||
|
||||
Leave the following blank line there!! Autoheader needs it. */
|
||||
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
#undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define if type char is unsigned and you are not using gcc. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
#undef __CHAR_UNSIGNED__
|
||||
#endif
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define for DGUX with <sys/dg_sys_info.h>. */
|
||||
#undef DGUX
|
||||
|
||||
/* Define if you have <dirent.h>. */
|
||||
#undef DIRENT
|
||||
|
||||
/* Define to enable audio support */
|
||||
#undef ENABLE_AUDIO_SUPPORT
|
||||
|
||||
/* Define to enable GLUT joystick support (limited to 3 axes) */
|
||||
#undef ENABLE_GLUT_JOYSTICK
|
||||
|
||||
/* Define to enable plib joystick support (recommended) */
|
||||
#undef ENABLE_PLIB_JOYSTICK
|
||||
|
||||
/* Define to eliminate all trace of debugging messages such as for a
|
||||
release build */
|
||||
#undef FG_NDEBUG
|
||||
|
||||
/* Define to include Oliver's networking support */
|
||||
#undef FG_NETWORK_OLK
|
||||
|
||||
/* Define to avoid Christian's new weather code */
|
||||
#undef FG_OLD_WEATHER
|
||||
|
||||
/* Define if we are building FGFS (should always be defined) */
|
||||
#undef FGFS
|
||||
|
||||
/* Define to enable 3dfx/glide render in a window hack under unix.
|
||||
This probably won't work under windows. */
|
||||
#undef XMESA
|
||||
#undef FX
|
||||
|
||||
/* Define to the type of elements in the array set by `getgroups'.
|
||||
Usually this is either `int' or `gid_t'. */
|
||||
#undef GETGROUPS_T
|
||||
|
||||
/* Define if the `getloadavg' function needs to be run setuid or setgid. */
|
||||
#undef GETLOADAVG_PRIVILEGED
|
||||
|
||||
/* Define if the `getpgrp' function takes no argument. */
|
||||
#undef GETPGRP_VOID
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define if you external variables daylight. */
|
||||
#undef HAVE_DAYLIGHT
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if your system has a working fnmatch function. */
|
||||
#undef HAVE_FNMATCH
|
||||
|
||||
/* Define if your system has its own `getloadavg' function. */
|
||||
#undef HAVE_GETLOADAVG
|
||||
|
||||
/* Define if you have getrusage() */
|
||||
#undef HAVE_GETRUSAGE
|
||||
|
||||
/* Define if you have the getmntent function. */
|
||||
#undef HAVE_GETMNTENT
|
||||
|
||||
/* Define if you have the gpc library and headers installed. */
|
||||
#undef HAVE_GPC_H
|
||||
|
||||
/* Define if the `long double' type works. */
|
||||
#undef HAVE_LONG_DOUBLE
|
||||
|
||||
/* Define if you support file names longer than 14 characters. */
|
||||
#undef HAVE_LONG_FILE_NAMES
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define if system calls automatically restart after interruption
|
||||
by a signal. */
|
||||
#undef HAVE_RESTARTABLE_SYSCALLS
|
||||
|
||||
/* Define if you have rint() which rounds to closest int but returns
|
||||
result as a double data type. */
|
||||
#undef HAVE_RINT
|
||||
|
||||
/* Define if your struct stat has st_blksize. */
|
||||
#undef HAVE_ST_BLKSIZE
|
||||
|
||||
/* Define if your struct stat has st_blocks. */
|
||||
#undef HAVE_ST_BLOCKS
|
||||
|
||||
/* Define if you have the strcoll function and it is properly defined. */
|
||||
#undef HAVE_STRCOLL
|
||||
|
||||
/* Define if your struct stat has st_rdev. */
|
||||
#undef HAVE_ST_RDEV
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define if you have <sys/param.h> */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have <sys/stat.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have timegm() */
|
||||
#undef HAVE_TIMEGM
|
||||
|
||||
/* Define if you external variables timezone. */
|
||||
#undef HAVE_TIMEZONE
|
||||
|
||||
/* Define if your struct tm has tm_zone. */
|
||||
#undef HAVE_TM_ZONE
|
||||
|
||||
/* Define if you don't have tm_zone but do have the external array
|
||||
tzname. */
|
||||
#undef HAVE_TZNAME
|
||||
|
||||
/* Define if you have <unistd.h>. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if utime(file, NULL) sets file's timestamp to the present. */
|
||||
#undef HAVE_UTIME_NULL
|
||||
|
||||
/* Define if you have <vfork.h>. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if you have the wait3 system call. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
||||
/* Define if int is 16 bits instead of 32. */
|
||||
#undef INT_16_BITS
|
||||
|
||||
/* Define if long int is 64 bits. */
|
||||
#undef LONG_64_BITS
|
||||
|
||||
/* Define if major, minor, and makedev are declared in <mkdev.h>. */
|
||||
#undef MAJOR_IN_MKDEV
|
||||
|
||||
/* Define if major, minor, and makedev are declared in <sysmacros.h>. */
|
||||
#undef MAJOR_IN_SYSMACROS
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef mode_t
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <ndir.h>. */
|
||||
#undef NDIR
|
||||
|
||||
/* Define if you have <memory.h>, and <string.h> doesn't declare the
|
||||
mem* functions. */
|
||||
#undef NEED_MEMORY_H
|
||||
|
||||
/* Define if your struct nlist has an n_un member. */
|
||||
#undef NLIST_NAME_UNION
|
||||
|
||||
/* Define if you have <nlist.h>. */
|
||||
#undef NLIST_STRUCT
|
||||
|
||||
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to package name */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define if the `setpgrp' function takes no argument. */
|
||||
#undef SETPGRP_VOID
|
||||
|
||||
/* Define if the setvbuf function takes the buffering type as its second
|
||||
argument and the buffer pointer as the third, as on System V
|
||||
before release 3. */
|
||||
#undef SETVBUF_REVERSED
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define on System V Release 4. */
|
||||
#undef SVR4
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <sys/dir.h>. */
|
||||
#undef SYSDIR
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <sys/ndir.h>. */
|
||||
#undef SYSNDIR
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h>. */
|
||||
#undef SYS_SIGLIST_DECLARED
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
|
||||
/* Define for Encore UMAX. */
|
||||
#undef UMAX
|
||||
|
||||
/* Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
|
||||
instead of <sys/cpustats.h>. */
|
||||
#undef UMAX4_3
|
||||
|
||||
/* Define if you do not have <strings.h>, index, bzero, etc.. */
|
||||
#undef USG
|
||||
|
||||
/* Define to version number */
|
||||
#undef VERSION
|
||||
|
||||
/* Define vfork as fork if vfork does not work. */
|
||||
#undef vfork
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef VOID_CLOSEDIR
|
||||
|
||||
/* Define if compiling on a Winbloze (95, NT, etc.) platform */
|
||||
#undef WIN32
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#undef WORDS_BIGENDIAN
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
/* Define if lex declares yytext as a char * by default, not a char[]. */
|
||||
#undef YYTEXT_POINTER
|
||||
|
||||
|
||||
/* Leave that blank line there!! Autoheader needs it.
|
||||
If you're adding to this file, keep in mind:
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). */
|
||||
|
||||
149
aclocal.m4
vendored
Normal file
149
aclocal.m4
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.3
|
||||
|
||||
dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
dnl This Makefile.in is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AM_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
|
||||
AC_REQUIRE([AM_SANITY_CHECK])
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])])
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_PROG_INSTALL,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
|
||||
AC_SUBST(INSTALL_SCRIPT)dnl
|
||||
])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "[$]*" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
if test "[$]*" != "X $srcdir/configure conftestfile" \
|
||||
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Define a conditional.
|
||||
|
||||
AC_DEFUN(AM_CONDITIONAL,
|
||||
[AC_SUBST($1_TRUE)
|
||||
AC_SUBST($1_FALSE)
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
dnl This file resides in the same directory as the config header
|
||||
dnl that is generated. We must strip everything past the first ":",
|
||||
dnl and everything past the last "/".
|
||||
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
|
||||
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
|
||||
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
|
||||
<<am_indx=1
|
||||
for am_file in <<$1>>; do
|
||||
case " <<$>>CONFIG_HEADERS " in
|
||||
*" <<$>>am_file "*<<)>>
|
||||
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
|
||||
;;
|
||||
esac
|
||||
am_indx=`expr "<<$>>am_indx" + 1`
|
||||
done<<>>dnl>>)
|
||||
changequote([,]))])
|
||||
|
||||
394
acsite.m4
Normal file
394
acsite.m4
Normal file
@@ -0,0 +1,394 @@
|
||||
dnl
|
||||
dnl originally from ncftp 2.3.0
|
||||
dnl added wi_EXTRA_PDIR and wi_ANSI_C
|
||||
dnl $Id$
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_IDIR, [
|
||||
incdir="$1"
|
||||
if test -r $incdir ; then
|
||||
case "$CPPFLAGS" in
|
||||
*-I${incdir}*)
|
||||
# echo " + already had $incdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$CPPFLAGS" = "" ; then
|
||||
CPPFLAGS="-I$incdir"
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I$incdir"
|
||||
fi
|
||||
echo " + found $incdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_LDIR, [
|
||||
mylibdir="$1"
|
||||
if test -r $mylibdir ; then
|
||||
case "$LDFLAGS" in
|
||||
*-L${mylibdir}*)
|
||||
# echo " + already had $mylibdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$LDFLAGS" = "" ; then
|
||||
LDFLAGS="-L$mylibdir"
|
||||
else
|
||||
LDFLAGS="$LDFLAGS -L$mylibdir"
|
||||
fi
|
||||
echo " + found $mylibdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl __FP__
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_PDIR, [
|
||||
progdir="$1"
|
||||
if test -r $progdir ; then
|
||||
case "$PATH" in
|
||||
*:${progdir}*)
|
||||
# echo " + already had $progdir" 1>&6
|
||||
;;
|
||||
*${progdir}:*)
|
||||
# echo " + already had $progdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$PATH" = "" ; then
|
||||
PATH="$progdir"
|
||||
else
|
||||
PATH="$PATH:$progdir"
|
||||
fi
|
||||
echo " + found $progdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl If you want to also look for include and lib subdirectories in the
|
||||
dnl $HOME tree, you supply "yes" as the first argument to this macro.
|
||||
dnl
|
||||
dnl If you want to look for subdirectories in include/lib directories,
|
||||
dnl you pass the names in argument 3, otherwise pass a dash.
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_DIRS, [echo "checking for extra include and lib directories..." 1>&6
|
||||
ifelse([$1], yes, [dnl
|
||||
b1=`cd .. ; pwd`
|
||||
b2=`cd ../.. ; pwd`
|
||||
exdirs="$HOME $j $b1 $b2 $prefix $2"
|
||||
],[dnl
|
||||
exdirs="$prefix $2"
|
||||
])
|
||||
subexdirs="$3"
|
||||
if test "$subexdirs" = "" ; then
|
||||
subexdirs="-"
|
||||
fi
|
||||
for subexdir in $subexdirs ; do
|
||||
if test "$subexdir" = "-" ; then
|
||||
subexdir=""
|
||||
else
|
||||
subexdir="/$subexdir"
|
||||
fi
|
||||
for exdir in $exdirs ; do
|
||||
if test "$exdir" != "/usr" || test "$subexdir" != ""; then
|
||||
incdir="${exdir}/include${subexdir}"
|
||||
wi_EXTRA_IDIR($incdir)
|
||||
|
||||
mylibdir="${exdir}/lib${subexdir}"
|
||||
wi_EXTRA_LDIR($mylibdir)
|
||||
|
||||
progdir="${exdir}/bin${subexdirr}"
|
||||
wi_EXTRA_PDIR($progdir)
|
||||
fi
|
||||
done
|
||||
done
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_HPUX_CFLAGS,
|
||||
[AC_MSG_CHECKING(if HP-UX ansi C compiler flags are needed)
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
os=`uname -s | tr '[A-Z]' '[a-z]'`
|
||||
ac_cv_hpux_flags=no
|
||||
if test "$os" = hp-ux ; then
|
||||
if test "$ac_cv_prog_gcc" = yes ; then
|
||||
if test "$CFLAGS" != "" ; then
|
||||
# Shouldn't be in there.
|
||||
CFLAGS=`echo "$CFLAGS" | sed 's/-Aa//g'`
|
||||
fi
|
||||
else
|
||||
# If you're not using gcc, then you better have a cc/c89
|
||||
# that is usable. If you have the barebones compiler, it
|
||||
# won't work. The good compiler uses -Aa for the ANSI
|
||||
# compatible stuff.
|
||||
x=`echo $CFLAGS | grep 'Aa' 2>/dev/null`
|
||||
if test "$x" = "" ; then
|
||||
CFLAGS="$CFLAGS -Aa"
|
||||
fi
|
||||
ac_cv_hpux_flags=yes
|
||||
fi
|
||||
# Also add _HPUX_SOURCE to get the extended namespace.
|
||||
x=`echo $CFLAGS | grep '_HPUX_SOURCE' 2>/dev/null`
|
||||
if test "$x" = "" ; then
|
||||
CFLAGS="$CFLAGS -D_HPUX_SOURCE"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv_hpux_flags)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_CFLAGS, [AC_REQUIRE([AC_PROG_CC])
|
||||
wi_HPUX_CFLAGS
|
||||
if test "$CFLAGS" = "" ; then
|
||||
CFLAGS="-O"
|
||||
elif test "$ac_cv_prog_gcc" = "yes" ; then
|
||||
case "$CFLAGS" in
|
||||
*"-g -O"*)
|
||||
#echo "using -g as default gcc CFLAGS" 1>&6
|
||||
CFLAGS=`echo $CFLAGS | sed 's/-g\ -O/-O/'`
|
||||
;;
|
||||
*"-O -g"*)
|
||||
# Leave the -g, but remove all -O options.
|
||||
#echo "using -g as default gcc CFLAGS" 1>&6
|
||||
CFLAGS=`echo $CFLAGS | sed 's/-O\ -g/-O/'`
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_PROTOTYPES, [
|
||||
AC_MSG_CHECKING(if the compiler supports function prototypes)
|
||||
AC_TRY_COMPILE(,[extern void exit(int status);],[wi_cv_prototypes=yes
|
||||
AC_DEFINE(PROTOTYPES)],wi_cv_prototypes=no)
|
||||
AC_MSG_RESULT($wi_cv_prototypes)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_ANSI_C, [
|
||||
AC_MSG_CHECKING(ANSI-style function definitions)
|
||||
AC_TRY_COMPILE(,[int blubb(int x) { return 0; }],[wi_cv_ansi_funcs=yes
|
||||
AC_DEFINE(ANSI_FUNCS)],wi_cv_ansi_funcs=no)
|
||||
AC_MSG_RESULT($wi_cv_ansi_funcs)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_HEADER_SYS_SELECT_H, [
|
||||
# See if <sys/select.h> is includable after <sys/time.h>
|
||||
if test "$ac_cv_header_sys_time_h" = no ; then
|
||||
AC_CHECK_HEADERS(sys/time.h sys/select.h)
|
||||
else
|
||||
AC_CHECK_HEADERS(sys/select.h)
|
||||
fi
|
||||
if test "$ac_cv_header_sys_select_h" = yes ; then
|
||||
AC_MSG_CHECKING([if <sys/select.h> is compatible with <sys/time.h>])
|
||||
selecth=yes
|
||||
if test "$ac_cv_header_sys_time_h" = yes ; then
|
||||
AC_TRY_COMPILE([#include <sys/time.h>
|
||||
#include <sys/select.h>],[
|
||||
fd_set a;
|
||||
struct timeval tmval;
|
||||
|
||||
tmval.tv_sec = 0;],selecth=yes,selecth=no)
|
||||
|
||||
if test "$selecth" = yes ; then
|
||||
AC_DEFINE(CAN_USE_SYS_SELECT_H)
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($selecth)
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_LIB_RESOLV, [
|
||||
# See if we could access two well-known sites without help of any special
|
||||
# libraries, like resolv.
|
||||
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
main()
|
||||
{
|
||||
struct hostent *hp1, *hp2;
|
||||
int result;
|
||||
|
||||
hp1 = gethostbyname("gatekeeper.dec.com");
|
||||
hp2 = gethostbyname("ftp.ncsa.uiuc.edu");
|
||||
result = ((hp1 != (struct hostent *) 0) && (hp2 != (struct hostent *) 0));
|
||||
exit(! result);
|
||||
}],look_for_resolv=no,look_for_resolv=yes,look_for_resolv=yes)
|
||||
|
||||
AC_MSG_CHECKING([if we need to look for -lresolv])
|
||||
AC_MSG_RESULT($look_for_resolv)
|
||||
if test "$look_for_resolv" = yes ; then
|
||||
AC_CHECK_LIB(resolv,main)
|
||||
else
|
||||
ac_cv_lib_resolv=no
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
AC_DEFUN(wi_LIB_NSL, [
|
||||
AC_MSG_CHECKING(if we can use -lnsl)
|
||||
ac_save_LIBS="$LIBS";
|
||||
LIBS="$LIBS -lnsl";
|
||||
AC_CACHE_VAL(r_cv_use_libnsl, [
|
||||
AC_TRY_RUN(
|
||||
main() { if (getpwuid(getuid())) exit(0); exit(-1); },
|
||||
nc_cv_use_libnsl=yes, nc_cv_use_libnsl=no, nc_cv_use_libnsl=no)
|
||||
])
|
||||
if test "$nc_cv_use_libnsl" = "no"; then LIBS="$ac_save_LIBS"; fi
|
||||
AC_MSG_RESULT($nc_cv_use_libnsl)
|
||||
])dnl
|
||||
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
AC_DEFUN(nc_PATH_PROG_ZCAT, [
|
||||
AC_PATH_PROG(GZCAT,gzcat)
|
||||
AC_PATH_PROG(ZCAT,zcat)
|
||||
if test "x$GZCAT" = x ; then
|
||||
if test "x$ZCAT" != x ; then
|
||||
# See if zcat is really gzcat. gzcat has a --version option, regular
|
||||
# zcat does not.
|
||||
AC_MSG_CHECKING(if zcat is really gzcat in disguise)
|
||||
if $ZCAT --version 2> /dev/null ; then
|
||||
AC_DEFINE_UNQUOTED(GZCAT, "$ZCAT")
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
else
|
||||
AC_DEFINE_UNQUOTED(GZCAT, "$GZCAT")
|
||||
fi
|
||||
|
||||
if test "x$ZCAT" != x ; then
|
||||
AC_DEFINE_UNQUOTED(ZCAT, "$ZCAT")
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_SYSV_EXTRA_DIRS, [
|
||||
# Use System V because their curses extensions are required. This must
|
||||
# be done early so we use the -I and -L in the library checks also.
|
||||
# This is mostly a Solaris/SunOS hack. Note that doing this will also
|
||||
# use all of the other System V libraries and headers.
|
||||
|
||||
AC_MSG_CHECKING(for alternative System V libraries)
|
||||
if test -f /usr/5include/curses.h ; then
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/5include"
|
||||
LDFLAGS="$LDFLAGS -L/usr/5lib"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_DEFINE_UNAME, [
|
||||
# Get first 127 chars of all uname information. Some folks have
|
||||
# way too much stuff there, so grab only the first 127.
|
||||
unam=`uname -a 2>/dev/null | cut -c1-127`
|
||||
if test "$unam" != "" ; then
|
||||
AC_DEFINE_UNQUOTED(UNAME, "$unam")
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_READLINE_WITH_NCURSES, [
|
||||
# Readline and Ncurses could both define "backspace".
|
||||
# Warn about this if we have both things in our definitions list.
|
||||
|
||||
if test "$ac_cv_lib_readline" = yes && test "$ac_cv_lib_ncurses" = yes ; then
|
||||
|
||||
AC_MSG_CHECKING(if readline and ncurses will link together)
|
||||
j="$LIBS"
|
||||
LIBS="-lreadline -lncurses"
|
||||
AC_TRY_LINK(,[
|
||||
readline("prompt");
|
||||
endwin();
|
||||
],k=yes,k=no)
|
||||
if test "$k" = no ; then
|
||||
AC_MSG_RESULT(no)
|
||||
# Remove '-lreadline' from LIBS.
|
||||
LIBS=`echo $j | sed s/-lreadline//g`
|
||||
ac_cv_lib_readline=no
|
||||
AC_WARN([The versions of GNU readline and ncurses you have installed on this system
|
||||
can't be used together, because they use the same symbol, backspace. If
|
||||
possible, recompile one of the libraries with -Dbackspace=back_space, then
|
||||
re-run configure.])
|
||||
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBS="$j"
|
||||
fi
|
||||
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
dnl AC_EXT_DAYLIGHT
|
||||
dnl Check for an external variable daylight. Stolen from w3c-libwww.
|
||||
AC_DEFUN(AC_EXT_DAYLIGHT,
|
||||
[ AC_MSG_CHECKING(int daylight variable)
|
||||
AC_TRY_COMPILE([#include <time.h>], [return daylight;],
|
||||
have_daylight=yes,
|
||||
have_daylight=no)
|
||||
AC_MSG_RESULT($have_daylight)
|
||||
])dnl
|
||||
|
||||
dnl AC_EXT_TIMEZONE
|
||||
dnl Check for an external variable timezone. Stolen from tcl-8.0.
|
||||
AC_DEFUN(AC_EXT_TIMEZONE,
|
||||
[
|
||||
#
|
||||
# Its important to include time.h in this check, as some systems (like convex)
|
||||
# have timezone functions, etc.
|
||||
#
|
||||
have_timezone=no
|
||||
AC_MSG_CHECKING([long timezone variable])
|
||||
AC_TRY_COMPILE([#include <time.h>],
|
||||
[extern long timezone;
|
||||
timezone += 1;
|
||||
exit (0);],
|
||||
[have_timezone=yes
|
||||
AC_MSG_RESULT(yes)],
|
||||
AC_MSG_RESULT(no))
|
||||
|
||||
#
|
||||
# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
|
||||
#
|
||||
if test "$have_timezone" = no; then
|
||||
AC_MSG_CHECKING([time_t timezone variable])
|
||||
AC_TRY_COMPILE([#include <time.h>],
|
||||
[extern time_t timezone;
|
||||
timezone += 1;
|
||||
exit (0);],
|
||||
[have_timezone=yes
|
||||
AC_MSG_RESULT(yes)],
|
||||
AC_MSG_RESULT(no))
|
||||
fi
|
||||
])dnl
|
||||
259
configure.in
Normal file
259
configure.in
Normal file
@@ -0,0 +1,259 @@
|
||||
dnl Process this file with aclocal ; automake -a ; autoconf to produce a
|
||||
dnl working configure script.
|
||||
dnl
|
||||
dnl $Id$
|
||||
|
||||
AC_INIT(src/bucket/newbucket.cxx)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.0.1)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
if echo $includedir | egrep "simgear$" > /dev/null; then
|
||||
echo "includedir is" $includedir "libdir is" $libdir
|
||||
else
|
||||
includedir="${includedir}/simgear"
|
||||
echo "includedir changed to" $includedir "libdir is" $libdir
|
||||
fi
|
||||
|
||||
|
||||
dnl Specify if we want logging (testing build) or not (release build)
|
||||
# set logging default value
|
||||
# with_logging=yes
|
||||
AC_ARG_WITH(logging, [ --with-logging Include logging output (default)])
|
||||
if test "x$with_logging" = "xno" ; then
|
||||
AC_DEFINE(FG_NDEBUG)
|
||||
fi
|
||||
|
||||
dnl specify if we are building with "checker"
|
||||
AC_ARG_WITH(efence, [ --with-efence Specify if we are building with "electric-fence"])
|
||||
|
||||
if test "x$with_efence" = "xyes" ; then
|
||||
echo "Building with efence"
|
||||
LIBS= "$LIBS -lefence"
|
||||
fi
|
||||
|
||||
dnl Check for MS Windows environment
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
dnl extra library and include directories
|
||||
EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6"
|
||||
|
||||
if test -d /opt/X11R6 ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
|
||||
# elif test `uname -s` = "SunOS" ; then
|
||||
# EXTRA_DIRS="${EXTRA_DIRS} `pwd`/SunOS"
|
||||
fi
|
||||
wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
|
||||
|
||||
dnl Using AM_CONDITIONAL is a step out of the protected little
|
||||
dnl automake fold so it is potentially dangerous. But, we are
|
||||
dnl beginning to run into cases where the standard checks are not
|
||||
dnl enough. AM_CONDITIONALS are then referenced to conditionally
|
||||
dnl build a Makefile.in from a Makefile.am which lets us define custom
|
||||
dnl includes, compile alternative source files, etc.
|
||||
|
||||
dnl Enable serial support on Unix type systems
|
||||
AM_CONDITIONAL(ENABLE_UNIX_SERIAL, true)
|
||||
|
||||
dnl Check for X11 (fancy)
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
null_LIBS="$LIBS"
|
||||
|
||||
AC_CHECK_LIB(m, cos)
|
||||
|
||||
base_LIBS="$LIBS"
|
||||
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(X11, XCreateWindow)
|
||||
AC_CHECK_LIB(Xext, XShmCreateImage)
|
||||
AC_CHECK_LIB(Xi, XGetExtensionVersion)
|
||||
AC_CHECK_LIB(ICE, IceOpenConnection)
|
||||
AC_CHECK_LIB(SM, SmcOpenConnection)
|
||||
AC_CHECK_LIB(Xt, XtMalloc)
|
||||
AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
|
||||
|
||||
dnl check for OpenGL related libraries
|
||||
|
||||
if test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
dnl Reasonable stuff for non-windoze variants ... :-)
|
||||
|
||||
AC_CHECK_LIB(GLcore, glNewList)
|
||||
if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
|
||||
dnl if no GLcore, check for GL
|
||||
AC_CHECK_LIB(GL, glNewList)
|
||||
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
|
||||
dnl if no GL, check for MesaGL
|
||||
AC_CHECK_LIB(MesaGL, glNewList)
|
||||
fi
|
||||
else
|
||||
dnl if GLcore found, then also check for GL
|
||||
AC_CHECK_LIB(GL, glXCreateContext)
|
||||
fi
|
||||
|
||||
dnl if using mesa, check for xmesa.h
|
||||
if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
|
||||
AC_CHECK_HEADER(GL/xmesa.h)
|
||||
if test "x$ac_cv_header_GL_xmesa_h" = "xyes"; then
|
||||
AC_DEFINE( XMESA )
|
||||
AC_DEFINE( FX )
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(GLU, gluLookAt)
|
||||
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
|
||||
dnl if no GLU, check for MesaGLU
|
||||
AC_CHECK_LIB(MesaGLU, gluLookAt)
|
||||
fi
|
||||
|
||||
dnl check for glut
|
||||
AC_CHECK_LIB(glut, glutGetModifiers)
|
||||
|
||||
dnl test for glutGameModeString, but avoid adding glut a second time into
|
||||
dnl the list of libraries
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(glut, glutGameModeString)
|
||||
LIBS="$save_LIBS"
|
||||
else
|
||||
dnl Win32 is a little wierd because it has to try to handle the various
|
||||
dnl winbloze-isms. We'll just do this manually for now.
|
||||
|
||||
echo Win32 specific hacks...
|
||||
AC_DEFINE(WIN32)
|
||||
|
||||
dnl force a failed check since we will be building under windoze
|
||||
AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
|
||||
|
||||
dnl just define these to true and hope for the best
|
||||
ac_cv_lib_glut_glutGetModifiers="yes"
|
||||
ac_cv_lib_glut_glutGameModeString="yes"
|
||||
|
||||
if test "x$with_sgi_opengl" = "xyes" ; then
|
||||
echo "Building with glut.dll, glu.dll, and opengl.dll"
|
||||
WIN32_GLUT=glut
|
||||
WIN32_GLU=glu
|
||||
WIN32_OPENGL=opengl
|
||||
else
|
||||
echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
|
||||
WIN32_GLUT=glut32
|
||||
WIN32_GLU=glu32
|
||||
WIN32_OPENGL=opengl32
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
|
||||
LIBS="$LIBS -luser32 -lgdi32"
|
||||
echo "Will link apps with $LIBS"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
|
||||
echo
|
||||
echo "Unable to find the necessary OpenGL or GLUT libraries."
|
||||
echo "See config.log for automated test details and results ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
|
||||
echo
|
||||
echo "Your version of glut doesn't support game mode."
|
||||
echo "You need to fetch and install the latest version of glut from:"
|
||||
echo
|
||||
echo " http://reality.sgi.com/opengl/glut3/glut3.html"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
opengl_LIBS="$LIBS"
|
||||
LIBS="$base_LIBS"
|
||||
|
||||
AC_SUBST(base_LIBS)
|
||||
AC_SUBST(opengl_LIBS)
|
||||
|
||||
AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
|
||||
|
||||
dnl Check for "plib" without which we cannot go on
|
||||
AC_CHECK_HEADER(plib/pu.h)
|
||||
if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
|
||||
echo
|
||||
echo "You *must* have the plib library installed on your system to build"
|
||||
echo "the FGFS simulator!"
|
||||
echo
|
||||
echo "Please see README.plib for more details."
|
||||
echo
|
||||
echo "configure aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
dnl Check for system installed zlib
|
||||
AC_CHECK_HEADER(zlib.h)
|
||||
if test "x$ac_cv_header_zlib_h" != "xyes"; then
|
||||
echo "no zlib found, building."
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_ZLIB, test "x$ac_cv_header_zlib_h" = "xyes" )
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS( \
|
||||
fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
|
||||
sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS( ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
|
||||
random setitimer getitimer signal GetLocalTime rint getrusage )
|
||||
|
||||
AM_CONFIG_HEADER(src/include/config.h)
|
||||
|
||||
AC_OUTPUT( \
|
||||
VERSION \
|
||||
Makefile \
|
||||
src/Makefile \
|
||||
src/include/Makefile \
|
||||
src/bucket/Makefile \
|
||||
src/debug/Makefile \
|
||||
src/math/Makefile \
|
||||
src/misc/Makefile \
|
||||
src/screen/Makefile \
|
||||
src/serial/Makefile \
|
||||
src/xgl/Makefile \
|
||||
src/zlib/Makefile \
|
||||
)
|
||||
|
||||
AC_OUTPUT_COMMANDS([./mksymlinks.sh])
|
||||
|
||||
echo ""
|
||||
echo "Configure Summary"
|
||||
echo "================="
|
||||
|
||||
echo "Prefix: $prefix"
|
||||
|
||||
if test "x$with_logging" != "x"; then
|
||||
echo "Debug messages: $with_logging"
|
||||
else
|
||||
echo "Debug messages: yes"
|
||||
fi
|
||||
|
||||
if test "x$with_efence" != "x"; then
|
||||
echo "Electric fence: $with_efence"
|
||||
else
|
||||
echo "Electric fence: no"
|
||||
fi
|
||||
@@ -1,17 +0,0 @@
|
||||
bin_PROGRAMS = example
|
||||
|
||||
example_SOURCES = example.cxx
|
||||
|
||||
example_LDADD = \
|
||||
$(top_builddir)/Lib/Audio/src/libsl.a \
|
||||
$(top_builddir)/Lib/Audio/src/libsm.a
|
||||
|
||||
INCLUDES += -I$(top_builddir)/Lib/Audio/src
|
||||
|
||||
if ENABLE_IRIX_AUDIO
|
||||
LIBS += -laudio
|
||||
endif
|
||||
|
||||
if ENABLE_WIN32_AUDIO
|
||||
LIBS += -lwinmm
|
||||
endif
|
||||
@@ -1,89 +0,0 @@
|
||||
|
||||
|
||||
#include "sl.h"
|
||||
#include "sm.h"
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
Construct a sound scheduler and a mixer.
|
||||
*/
|
||||
|
||||
slScheduler sched ( 8000 ) ;
|
||||
smMixer mixer ;
|
||||
|
||||
int main ()
|
||||
{
|
||||
mixer . setMasterVolume ( 30 ) ;
|
||||
sched . setSafetyMargin ( 0.128 ) ;
|
||||
|
||||
/* Just for fun, let's make a one second synthetic engine sample... */
|
||||
|
||||
Uchar buffer [ 8000 ] ;
|
||||
|
||||
for ( int i = 0 ; i < 8000 ; i++ )
|
||||
{
|
||||
/* Sum some sin waves and convert to range 0..1 */
|
||||
|
||||
float level = ( sin ( (double) i * 2.0 * M_PI / (8000.0/ 50.0) ) +
|
||||
sin ( (double) i * 2.0 * M_PI / (8000.0/149.0) ) +
|
||||
sin ( (double) i * 2.0 * M_PI / (8000.0/152.0) ) +
|
||||
sin ( (double) i * 2.0 * M_PI / (8000.0/192.0) )
|
||||
) / 8.0f + 0.5f ;
|
||||
|
||||
/* Convert to unsigned byte */
|
||||
|
||||
buffer [ i ] = (Uchar) ( level * 255.0 ) ;
|
||||
}
|
||||
|
||||
/* Set up four samples and a loop */
|
||||
|
||||
slSample *s = new slSample ( buffer, 8000 ) ;
|
||||
slSample *s1 = new slSample ( "scream.ub", & sched ) ;
|
||||
slSample *s2 = new slSample ( "zzap.wav" , & sched ) ;
|
||||
slSample *s3 = new slSample ( "cuckoo.au", & sched ) ;
|
||||
slSample *s4 = new slSample ( "wheeee.ub", & sched ) ;
|
||||
|
||||
/* Mess about with some of the samples... */
|
||||
|
||||
s1 -> adjustVolume ( 2.2 ) ;
|
||||
s2 -> adjustVolume ( 0.5 ) ;
|
||||
s3 -> adjustVolume ( 0.2 ) ;
|
||||
|
||||
/* Play the engine sample continuously. */
|
||||
|
||||
sched . loopSample ( s ) ;
|
||||
|
||||
int tim = 0 ; /* My periodic event timer. */
|
||||
|
||||
while ( SL_TRUE )
|
||||
{
|
||||
tim++ ; /* Time passes */
|
||||
|
||||
if ( tim % 200 == 0 ) sched.playSample ( s1 ) ;
|
||||
if ( tim % 180 == 0 ) sched.playSample ( s2 ) ;
|
||||
if ( tim % 150 == 0 ) sched.playSample ( s3 ) ;
|
||||
if ( tim % 120 == 0 ) sched.playSample ( s4 ) ;
|
||||
|
||||
/*
|
||||
For the sake of realism, I'll delay for 1/30th second to
|
||||
simulate a graphics update process.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep ( 1000 / 30 ) ; /* 30Hz */
|
||||
#elif defined(sgi)
|
||||
sginap( 3 ); /* ARG */
|
||||
#else
|
||||
usleep ( 1000000 / 30 ) ; /* 30Hz */
|
||||
#endif
|
||||
|
||||
/*
|
||||
This would normally be called just before the graphics buffer swap
|
||||
- but it could be anywhere where it's guaranteed to get called
|
||||
fairly often.
|
||||
*/
|
||||
|
||||
sched . update () ;
|
||||
}
|
||||
}
|
||||
|
||||
39
mksymlinks.sh
Executable file
39
mksymlinks.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#! /bin/sh
|
||||
|
||||
echo ""
|
||||
echo "running $0 to rebuild simgear include links"
|
||||
|
||||
# toast the old directory
|
||||
rm -rf src/simgear
|
||||
mkdir src/simgear
|
||||
mkdir src/simgear/bucket
|
||||
mkdir src/simgear/debug
|
||||
mkdir src/simgear/math
|
||||
mkdir src/simgear/misc
|
||||
mkdir src/simgear/screen
|
||||
mkdir src/simgear/serial
|
||||
mkdir src/simgear/xgl
|
||||
mkdir src/simgear/zlib
|
||||
|
||||
# build new links
|
||||
ln -s ../include/compiler.h src/simgear/compiler.h
|
||||
ln -s ../include/constants.h src/simgear/constants.h
|
||||
ln -s ../include/fg_traits.hxx src/simgear/fg_traits.hxx
|
||||
ln -s ../include/fg_zlib.h src/simgear/fg_zlib.h
|
||||
|
||||
ln -s ../../bucket/newbucket.hxx src/simgear/bucket/newbucket.hxx
|
||||
|
||||
ln -s ../../debug/debug_types.h src/simgear/debug/debug_types.h
|
||||
ln -s ../../debug/logstream.hxx src/simgear/debug/logstream.hxx
|
||||
|
||||
ln -s ../../math/fg_memory.h src/simgear/math/fg_memory.h
|
||||
ln -s ../../math/fg_types.hxx src/simgear/math/fg_types.hxx
|
||||
ln -s ../../math/mat3.h src/simgear/math/mat3.h
|
||||
ln -s ../../math/point3d.hxx src/simgear/math/point3d.hxx
|
||||
ln -s ../../math/polar3d.hxx src/simgear/math/polar3d.hxx
|
||||
|
||||
ln -s ../../misc/fgpath.hxx src/simgear/misc/fgpath.hxx
|
||||
ln -s ../../misc/fgstream.hxx src/simgear/misc/fgstream.hxx
|
||||
ln -s ../../misc/zfstream.hxx src/simgear/misc/zfstream.hxx
|
||||
|
||||
ln -s ../../xgl/xgl.h src/simgear/xgl/xgl.h
|
||||
27
simgear/Makefile.am
Normal file
27
simgear/Makefile.am
Normal file
@@ -0,0 +1,27 @@
|
||||
if ENABLE_UNIX_SERIAL
|
||||
SERIAL_DIRS = serial
|
||||
else
|
||||
SERIAL_DIRS =
|
||||
endif
|
||||
|
||||
if HAVE_ZLIB
|
||||
ZLIB_DIRS =
|
||||
else
|
||||
ZLIB_DIRS = zlib
|
||||
endif
|
||||
|
||||
METAR_DIRS =
|
||||
# METAR_DIRS = metar
|
||||
|
||||
SUBDIRS = \
|
||||
include \
|
||||
bucket \
|
||||
debug \
|
||||
math \
|
||||
$(METAR_DIRS) \
|
||||
misc \
|
||||
screen \
|
||||
$(SERIAL_DIRS) \
|
||||
xgl \
|
||||
$(ZLIB_DIRS)
|
||||
|
||||
17
simgear/bucket/Makefile.am
Normal file
17
simgear/bucket/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
||||
includedir = @includedir@/bucket
|
||||
|
||||
lib_LIBRARIES = libsgbucket.a
|
||||
|
||||
include_HEADERS = newbucket.hxx
|
||||
|
||||
libsgbucket_a_SOURCES = newbucket.cxx
|
||||
|
||||
# noinst_PROGRAMS = testbucket
|
||||
|
||||
# testbucket_SOURCES = testbucket.cxx
|
||||
|
||||
# testbucket_LDADD = \
|
||||
# $(top_builddir)/bucket/libsgbucket.a \
|
||||
# $(top_builddir)/misc/libsgmisc.a
|
||||
|
||||
INCLUDES += -I$(top_builddir)/src
|
||||
@@ -20,29 +20,28 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
|
||||
#include "newbucket.hxx"
|
||||
|
||||
|
||||
// Build the path name for this bucket
|
||||
string FGBucket::gen_base_path() {
|
||||
long int index;
|
||||
string FGBucket::gen_base_path() const {
|
||||
// long int index;
|
||||
int top_lon, top_lat, main_lon, main_lat;
|
||||
char hem, pole;
|
||||
char path[256];
|
||||
char raw_path[256];
|
||||
|
||||
index = gen_index();
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
top_lon = lon / 10;
|
||||
main_lon = lon;
|
||||
if ( (lon < 0) && (top_lon * 10 != lon) ) {
|
||||
@@ -75,11 +74,13 @@ string FGBucket::gen_base_path() {
|
||||
main_lat *= -1;
|
||||
}
|
||||
|
||||
sprintf(path, "%c%03d%c%02d/%c%03d%c%02d",
|
||||
hem, top_lon, pole, top_lat,
|
||||
sprintf(raw_path, "%c%03d%c%02d/%c%03d%c%02d",
|
||||
hem, top_lon, pole, top_lat,
|
||||
hem, main_lon, pole, main_lat);
|
||||
|
||||
return path;
|
||||
FGPath path( raw_path );
|
||||
|
||||
return path.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +99,14 @@ FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
|
||||
double span = bucket_span( clat );
|
||||
|
||||
// walk dx units in the lon direction
|
||||
result.set_bucket( dlon + dx * span, clat );
|
||||
double tmp = dlon + dx * span;
|
||||
while ( tmp < -180.0 ) {
|
||||
tmp += 360.0;
|
||||
}
|
||||
while ( tmp >= 180.0 ) {
|
||||
tmp -= 360.0;
|
||||
}
|
||||
result.set_bucket( tmp, clat );
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -145,12 +153,3 @@ void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1999/02/11 01:09:33 curt
|
||||
// Added a routine to calculate the offset in bucket units between two buckets.
|
||||
//
|
||||
// Revision 1.1 1999/02/08 23:52:16 curt
|
||||
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
||||
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
||||
// width towards the poles to ensure the tiles are at least 8 miles wide.
|
||||
//
|
||||
@@ -20,28 +20,48 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef _NEWBUCKET_HXX
|
||||
#define _NEWBUCKET_HXX
|
||||
|
||||
#include <Include/compiler.h>
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include <string>
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio> // sprintf()
|
||||
# include <iostream>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <stdio.h> // sprintf()
|
||||
# include <iostream.h>
|
||||
#endif
|
||||
|
||||
// I don't understand ... <math.h> or <cmath> should be included
|
||||
// already depending on how you defined FG_HAVE_STD_INCLUDES, but I
|
||||
// can go ahead and add this -- CLO
|
||||
#ifdef __MWERKS__
|
||||
# include <math.h> // needed fabs()
|
||||
#endif
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
FG_USING_STD(string);
|
||||
FG_USING_NAMESPACE(std);
|
||||
|
||||
#include <stdio.h> // sprintf()
|
||||
#if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
|
||||
FG_USING_STD(ostream);
|
||||
#endif
|
||||
|
||||
#include <Include/fg_constants.h>
|
||||
|
||||
|
||||
#define FG_BUCKET_SPAN 0.125 // 1/8 of a degree
|
||||
#define FG_HALF_BUCKET_SPAN 0.0625 // 1/2 of 1/8 of a degree = 1/16 = 0.0625
|
||||
|
||||
class FGBucket;
|
||||
ostream& operator<< ( ostream&, const FGBucket& );
|
||||
bool operator== ( const FGBucket&, const FGBucket& );
|
||||
|
||||
class FGBucket {
|
||||
|
||||
@@ -63,23 +83,40 @@ public:
|
||||
// create a bucket based on "long int" index
|
||||
FGBucket(const long int bindex);
|
||||
|
||||
// create an impossible bucket if false
|
||||
FGBucket(const bool is_good);
|
||||
|
||||
~FGBucket();
|
||||
|
||||
// Set the bucket params for the specified lat and lon
|
||||
void set_bucket( double dlon, double dlat );
|
||||
void make_bad ( void );
|
||||
|
||||
// Generate the unique scenery tile index for this bucket
|
||||
long int gen_index();
|
||||
string gen_index_str() const;
|
||||
|
||||
// Build the path name for this bucket
|
||||
string gen_base_path();
|
||||
string gen_base_path() const;
|
||||
|
||||
// return the center lon of a tile
|
||||
double get_center_lon() const;
|
||||
|
||||
// return width of the tile
|
||||
double get_width() const;
|
||||
|
||||
// return the center lat of a tile
|
||||
double get_center_lat() const;
|
||||
|
||||
// return height of the tile
|
||||
double get_height() const;
|
||||
|
||||
// Informational methods
|
||||
inline int get_lon() const { return lon; }
|
||||
inline int get_lat() const { return lat; }
|
||||
inline int get_x() const { return x; }
|
||||
inline int get_y() const { return y; }
|
||||
|
||||
// friends
|
||||
friend ostream& operator<< ( ostream&, const FGBucket& );
|
||||
friend bool operator== ( const FGBucket&, const FGBucket& );
|
||||
@@ -89,7 +126,7 @@ public:
|
||||
// return the horizontal tile span factor based on latitude
|
||||
inline double bucket_span( double l ) {
|
||||
if ( l >= 89.0 ) {
|
||||
return 0.0;
|
||||
return 360.0;
|
||||
} else if ( l >= 88.0 ) {
|
||||
return 8.0;
|
||||
} else if ( l >= 86.0 ) {
|
||||
@@ -117,7 +154,7 @@ inline double bucket_span( double l ) {
|
||||
} else if ( l >= -89.0 ) {
|
||||
return 8.0;
|
||||
} else {
|
||||
return 0.0;
|
||||
return 360.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +220,15 @@ inline FGBucket::FGBucket(const double dlon, const double dlat) {
|
||||
}
|
||||
|
||||
|
||||
// create an impossible bucket if false
|
||||
inline FGBucket::FGBucket(const bool is_good) {
|
||||
set_bucket(0.0, 0.0);
|
||||
if ( !is_good ) {
|
||||
lon = -1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse a unique scenery tile index and find the lon, lat, x, and y
|
||||
inline FGBucket::FGBucket(const long int bindex) {
|
||||
long int index = bindex;
|
||||
@@ -223,6 +269,13 @@ inline long int FGBucket::gen_index() {
|
||||
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x;
|
||||
}
|
||||
|
||||
inline string FGBucket::gen_index_str() const {
|
||||
char tmp[20];
|
||||
sprintf(tmp, "%ld",
|
||||
(((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
|
||||
return (string)tmp;
|
||||
}
|
||||
|
||||
|
||||
// return the center lon of a tile
|
||||
inline double FGBucket::get_center_lon() const {
|
||||
@@ -242,6 +295,25 @@ inline double FGBucket::get_center_lat() const {
|
||||
}
|
||||
|
||||
|
||||
// return width of the tile
|
||||
inline double FGBucket::get_width() const {
|
||||
return bucket_span( get_center_lat() );
|
||||
}
|
||||
|
||||
|
||||
// return height of the tile
|
||||
inline double FGBucket::get_height() const {
|
||||
return FG_BUCKET_SPAN;
|
||||
}
|
||||
|
||||
|
||||
// create an impossible bucket
|
||||
inline void FGBucket::make_bad( void ) {
|
||||
set_bucket(0.0, 0.0);
|
||||
lon = -1000;
|
||||
}
|
||||
|
||||
|
||||
// offset a bucket struct by the specified tile units in the X & Y
|
||||
// direction
|
||||
FGBucket fgBucketOffset( double dlon, double dlat, int x, int y );
|
||||
@@ -273,28 +345,7 @@ operator== ( const FGBucket& b1, const FGBucket& b2 )
|
||||
b1.y == b2.y );
|
||||
}
|
||||
|
||||
/*
|
||||
inline string
|
||||
fgBucketGenIndex( const fgBUCKET& p )
|
||||
{
|
||||
char index_str[256];
|
||||
sprintf( index_str, "%ld", fgBucketGenIndex( &p ) );
|
||||
return string( index_str );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#endif // _NEWBUCKET_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1999/02/11 01:09:34 curt
|
||||
// Added a routine to calculate the offset in bucket units between two buckets.
|
||||
//
|
||||
// Revision 1.1 1999/02/08 23:52:16 curt
|
||||
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
||||
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
||||
// width towards the poles to ensure the tiles are at least 8 miles wide.
|
||||
//
|
||||
11
simgear/debug/Makefile.am
Normal file
11
simgear/debug/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
includedir = @includedir@/debug
|
||||
|
||||
EXTRA_DIST = logtest.cxx
|
||||
|
||||
lib_LIBRARIES = libsgdebug.a
|
||||
|
||||
include_HEADERS = debug_types.h logstream.hxx
|
||||
|
||||
libsgdebug_a_SOURCES = logstream.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir)/src
|
||||
@@ -16,9 +16,10 @@ typedef enum {
|
||||
FG_EVENT = 0x00000200,
|
||||
FG_AIRCRAFT = 0x00000400,
|
||||
FG_AUTOPILOT = 0x00000800,
|
||||
FG_SERIAL = 0x00001000,
|
||||
FG_IO = 0x00001000,
|
||||
FG_CLIPPER = 0x00002000,
|
||||
FG_UNDEFD = 0x00004000, // For range checking
|
||||
FG_NETWORK = 0x00004000,
|
||||
FG_UNDEFD = 0x00008000, // For range checking
|
||||
|
||||
FG_ALL = 0xFFFFFFFF
|
||||
} fgDebugClass;
|
||||
@@ -19,7 +19,6 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
#include "logstream.hxx"
|
||||
|
||||
@@ -62,10 +61,3 @@ logstream::setLogLevels( fgDebugClass c, fgDebugPriority p )
|
||||
logbuf::set_log_level( c, p );
|
||||
}
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1999/01/19 20:53:34 curt
|
||||
// Portability updates by Bernie Bright.
|
||||
//
|
||||
// Revision 1.1 1998/11/06 21:20:41 curt
|
||||
// Initial revision.
|
||||
//
|
||||
@@ -19,7 +19,6 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
#ifndef _LOGSTREAM_H
|
||||
#define _LOGSTREAM_H
|
||||
@@ -29,23 +28,30 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "Include/compiler.h"
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <streambuf>
|
||||
# include <iostream>
|
||||
//# include <ostream>
|
||||
#else
|
||||
# include <iostream.h>
|
||||
# include "Include/fg_traits.hxx"
|
||||
# include <simgear/fg_traits.hxx>
|
||||
#endif
|
||||
|
||||
#include "debug_types.h"
|
||||
#include <simgear/debug/debug_types.h>
|
||||
|
||||
#ifndef FG_HAVE_NATIVE_SGI_COMPILERS
|
||||
FG_USING_STD(streambuf);
|
||||
FG_USING_STD(ostream);
|
||||
FG_USING_STD(cerr);
|
||||
FG_USING_STD(endl);
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# define cerr std::cerr
|
||||
# define endl std::endl
|
||||
FG_USING_STD(iostream);
|
||||
#endif
|
||||
|
||||
//
|
||||
// TODO:
|
||||
@@ -204,21 +210,11 @@ fglog()
|
||||
|
||||
#ifdef FG_NDEBUG
|
||||
# define FG_LOG(C,P,M)
|
||||
#elif defined( __MWERKS__ )
|
||||
# define FG_LOG(C,P,M) ::fglog() << ::loglevel(C,P) << M << std::endl
|
||||
#else
|
||||
# define FG_LOG(C,P,M) fglog() << loglevel(C,P) << M << endl
|
||||
#endif
|
||||
|
||||
#endif // _LOGSTREAM_H
|
||||
|
||||
// $Log$
|
||||
// Revision 1.3 1999/01/19 20:53:35 curt
|
||||
// Portability updates by Bernie Bright.
|
||||
//
|
||||
// Revision 1.2 1998/11/07 19:07:02 curt
|
||||
// Enable release builds using the --without-logging option to the configure
|
||||
// script. Also a couple log message cleanups, plus some C to C++ comment
|
||||
// conversion.
|
||||
//
|
||||
// Revision 1.1 1998/11/06 21:20:42 curt
|
||||
// Initial revision.
|
||||
//
|
||||
19
simgear/ephemeris/Makefile.am
Normal file
19
simgear/ephemeris/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
||||
noinst_LIBRARIES = libAstro.a
|
||||
|
||||
libAstro_a_SOURCES = \
|
||||
celestialBody.cxx celestialBody.hxx \
|
||||
jupiter.cxx jupiter.hxx \
|
||||
mars.cxx mars.hxx \
|
||||
mercury.cxx mercury.hxx \
|
||||
moon.cxx moon.hxx \
|
||||
neptune.cxx neptune.hxx \
|
||||
pluto.hxx \
|
||||
saturn.cxx saturn.hxx \
|
||||
sky.cxx sky.hxx \
|
||||
solarsystem.cxx solarsystem.hxx \
|
||||
star.cxx star.hxx \
|
||||
stars.cxx stars.hxx \
|
||||
uranus.cxx uranus.hxx \
|
||||
venus.cxx venus.hxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
|
||||
178
simgear/ephemeris/celestialBody.cxx
Normal file
178
simgear/ephemeris/celestialBody.cxx
Normal file
@@ -0,0 +1,178 @@
|
||||
/**************************************************************************
|
||||
* celestialBody.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#ifdef FG_MATH_EXCEPTION_CLASH
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
|
||||
*
|
||||
* Basically, this member function provides a general interface for
|
||||
* calculating the right ascension and declinaion. This function is
|
||||
* used for calculating the planetary positions. For the planets, an
|
||||
* overloaded member function is provided to additionally calculate the
|
||||
* planet's magnitude.
|
||||
* The sun and moon have their own overloaded updatePosition member, as their
|
||||
* position is calculated an a slightly different manner.
|
||||
*
|
||||
* arguments:
|
||||
* fgTIME t: provides the current time.
|
||||
* Star *ourSun: the sun's position is needed to convert heliocentric
|
||||
* coordinates into geocentric coordinates.
|
||||
*
|
||||
* return value: none
|
||||
*
|
||||
*************************************************************************/
|
||||
void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
double eccAnom, v, ecl, actTime,
|
||||
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
|
||||
|
||||
updateOrbElements(t);
|
||||
actTime = fgCalcActTime(t);
|
||||
|
||||
// calcualate the angle bewteen ecliptic and equatorial coordinate system
|
||||
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime);
|
||||
|
||||
eccAnom = fgCalcEccAnom(M, e); //calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
yv = a * (sqrt (1.0 - e*e) * sin(eccAnom));
|
||||
v = atan2(yv, xv); // the planet's true anomaly
|
||||
r = sqrt (xv*xv + yv*yv); // the planet's distance
|
||||
|
||||
// calculate the planet's position in 3D space
|
||||
xh = r * (cos(N) * cos(v+w) - sin(N) * sin(v+w) * cos(i));
|
||||
yh = r * (sin(N) * cos(v+w) + cos(N) * sin(v+w) * cos(i));
|
||||
zh = r * (sin(v+w) * sin(i));
|
||||
|
||||
// calculate the ecliptic longitude and latitude
|
||||
xg = xh + ourSun->getxs();
|
||||
yg = yh + ourSun->getys();
|
||||
zg = zh;
|
||||
|
||||
lonEcl = atan2(yh, xh);
|
||||
latEcl = atan2(zh, sqrt(xh*xh+yh*yh));
|
||||
|
||||
xe = xg;
|
||||
ye = yg * cos(ecl) - zg * sin(ecl);
|
||||
ze = yg * sin(ecl) + zg * cos(ecl);
|
||||
rightAscension = atan2(ye, xe);
|
||||
declination = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
FG_LOG(FG_GENERAL, FG_INFO, "Planet found at : "
|
||||
<< rightAscension << " (ra), " << declination << " (dec)" );
|
||||
|
||||
//calculate some variables specific to calculating the magnitude
|
||||
//of the planet
|
||||
R = sqrt (xg*xg + yg*yg + zg*zg);
|
||||
s = ourSun->getDistance();
|
||||
|
||||
// It is possible from these calculations for the argument to acos
|
||||
// to exceed the valid range for acos(). So we do a little extra
|
||||
// checking.
|
||||
|
||||
double tmp = (r*r + R*R - s*s) / (2*r*R);
|
||||
if ( tmp > 1.0) {
|
||||
tmp = 1.0;
|
||||
} else if ( tmp < -1.0) {
|
||||
tmp = -1.0;
|
||||
}
|
||||
|
||||
FV = RAD_TO_DEG * acos( tmp );
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* double CelestialBody::fgCalcEccAnom(double M, double e)
|
||||
* this private member calculates the eccentric anomaly of a celestial body,
|
||||
* given its mean anomaly and eccentricity.
|
||||
*
|
||||
* -Mean anomaly: the approximate angle between the perihelion and the current
|
||||
* position. this angle increases uniformly with time.
|
||||
*
|
||||
* True anomaly: the actual angle between perihelion and current position.
|
||||
*
|
||||
* Eccentric anomaly: this is an auxilary angle, used in calculating the true
|
||||
* anomaly from the mean anomaly.
|
||||
*
|
||||
* -eccentricity. Indicates the amount in which the orbit deviates from a
|
||||
* circle (0 = circle, 0-1, is ellipse, 1 = parabola, > 1 = hyperbola).
|
||||
*
|
||||
* This function is also known as solveKeplersEquation()
|
||||
*
|
||||
* arguments:
|
||||
* M: the mean anomaly
|
||||
* e: the eccentricity
|
||||
*
|
||||
* return value:
|
||||
* the eccentric anomaly
|
||||
*
|
||||
****************************************************************************/
|
||||
double CelestialBody::fgCalcEccAnom(double M, double e)
|
||||
{
|
||||
double
|
||||
eccAnom, E0, E1, diff;
|
||||
|
||||
eccAnom = M + e * sin(M) * (1.0 + e * cos (M));
|
||||
// iterate to achieve a greater precision for larger eccentricities
|
||||
if (e > 0.05)
|
||||
{
|
||||
E0 = eccAnom;
|
||||
do
|
||||
{
|
||||
E1 = E0 - (E0 - e * sin(E0) - M) / (1 - e *cos(E0));
|
||||
diff = fabs(E0 - E1);
|
||||
E0 = E1;
|
||||
}
|
||||
while (diff > (DEG_TO_RAD * 0.001));
|
||||
return E0;
|
||||
}
|
||||
return eccAnom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
196
simgear/ephemeris/celestialBody.hxx
Normal file
196
simgear/ephemeris/celestialBody.hxx
Normal file
@@ -0,0 +1,196 @@
|
||||
/**************************************************************************
|
||||
* celestialBody.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CELESTIALBODY_H_
|
||||
#define _CELESTIALBODY_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
class Star;
|
||||
|
||||
class CelestialBody
|
||||
{
|
||||
protected: // make the data protected, in order to give the inherited
|
||||
// classes direct access to the data
|
||||
double NFirst; /* longitude of the ascending node first part */
|
||||
double NSec; /* longitude of the ascending node second part */
|
||||
double iFirst; /* inclination to the ecliptic first part */
|
||||
double iSec; /* inclination to the ecliptic second part */
|
||||
double wFirst; /* first part of argument of perihelion */
|
||||
double wSec; /* second part of argument of perihelion */
|
||||
double aFirst; /* semimayor axis first part*/
|
||||
double aSec; /* semimayor axis second part */
|
||||
double eFirst; /* eccentricity first part */
|
||||
double eSec; /* eccentricity second part */
|
||||
double MFirst; /* Mean anomaly first part */
|
||||
double MSec; /* Mean anomaly second part */
|
||||
|
||||
double N, i, w, a, e, M; /* the resulting orbital elements, obtained from the former */
|
||||
|
||||
double rightAscension, declination;
|
||||
double r, R, s, FV;
|
||||
double magnitude;
|
||||
double lonEcl, latEcl;
|
||||
|
||||
double fgCalcEccAnom(double M, double e);
|
||||
double fgCalcActTime(FGTime *t);
|
||||
void updateOrbElements(FGTime *t);
|
||||
|
||||
public:
|
||||
CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, FGTime *t);
|
||||
void getPos(double *ra, double *dec);
|
||||
void getPos(double *ra, double *dec, double *magnitude);
|
||||
double getLon();
|
||||
double getLat();
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* inline CelestialBody::CelestialBody
|
||||
* public constructor for a generic celestialBody object.
|
||||
* initializes the 6 primary orbital elements. The elements are:
|
||||
* N: longitude of the ascending node
|
||||
* i: inclination to the ecliptic
|
||||
* w: argument of perihelion
|
||||
* a: semi-major axis, or mean distance from the sun
|
||||
* e: eccenticity
|
||||
* M: mean anomaly
|
||||
* Each orbital element consists of a constant part and a variable part that
|
||||
* gradually changes over time.
|
||||
*
|
||||
* Argumetns:
|
||||
* the 13 arguments to the constructor constitute the first, constant
|
||||
* ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital
|
||||
* elements. The 13th argument is the current time. Note that the inclination
|
||||
* is written with a capital (If, Is), because 'if' is a reserved word in the
|
||||
* C/C++ programming language.
|
||||
***************************************************************************/
|
||||
inline CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, FGTime *t)
|
||||
{
|
||||
NFirst = Nf; NSec = Ns;
|
||||
iFirst = If; iSec = Is;
|
||||
wFirst = wf; wSec = ws;
|
||||
aFirst = af; aSec = as;
|
||||
eFirst = ef; eSec = es;
|
||||
MFirst = Mf; MSec = Ms;
|
||||
updateOrbElements(t);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
* given the current time, this private member calculates the actual
|
||||
* orbital elements
|
||||
*
|
||||
* Arguments: FGTime *t: the current time:
|
||||
*
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
{
|
||||
double actTime = fgCalcActTime(t);
|
||||
M = DEG_TO_RAD * (MFirst + (MSec * actTime));
|
||||
w = DEG_TO_RAD * (wFirst + (wSec * actTime));
|
||||
N = DEG_TO_RAD * (NFirst + (NSec * actTime));
|
||||
i = DEG_TO_RAD * (iFirst + (iSec * actTime));
|
||||
e = eFirst + (eSec * actTime);
|
||||
a = aFirst + (aSec * actTime);
|
||||
}
|
||||
/*****************************************************************************
|
||||
* inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
* this private member function returns the offset in days from the epoch for
|
||||
* wich the orbital elements are calculated (Jan, 1st, 2000).
|
||||
*
|
||||
* Argument: the current time
|
||||
*
|
||||
* return value: the (fractional) number of days until Jan 1, 2000.
|
||||
****************************************************************************/
|
||||
inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
{
|
||||
return (t->getMjd() - 36523.5);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec)
|
||||
* gives public access to Right Ascension and declination
|
||||
*
|
||||
****************************************************************************/
|
||||
inline void CelestialBody::getPos(double* ra, double* dec)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude
|
||||
* gives public acces to the current Right ascension, declination, and
|
||||
* magnitude
|
||||
****************************************************************************/
|
||||
inline void CelestialBody::getPos(double* ra, double* dec, double* magn)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
*magn = magnitude;
|
||||
}
|
||||
|
||||
inline double CelestialBody::getLon()
|
||||
{
|
||||
return lonEcl;
|
||||
}
|
||||
|
||||
inline double CelestialBody::getLat()
|
||||
{
|
||||
return latEcl;
|
||||
}
|
||||
|
||||
#endif // _CELESTIALBODY_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
65
simgear/ephemeris/jupiter.cxx
Normal file
65
simgear/ephemeris/jupiter.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
/**************************************************************************
|
||||
* jupiter.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "jupiter.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Jupiter::Jupiter(FGTime *t)
|
||||
* Public constructor for class Jupiter
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Jupiter are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Jupiter::Jupiter(FGTime *t) :
|
||||
CelestialBody(100.4542, 2.7685400E-5,
|
||||
1.3030, -1.557E-7,
|
||||
273.8777, 1.6450500E-5,
|
||||
5.2025600, 0.000000,
|
||||
0.048498, 4.469E-9,
|
||||
19.89500, 0.08308530010, t)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Jupiter, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Jupiter specific equation
|
||||
*************************************************************************/
|
||||
void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
38
simgear/ephemeris/jupiter.hxx
Normal file
38
simgear/ephemeris/jupiter.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/**************************************************************************
|
||||
* jupiter.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _JUPITER_HXX_
|
||||
#define _JUPITER_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Jupiter : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Jupiter (FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _JUPITER_HXX_
|
||||
59
simgear/ephemeris/mars.cxx
Normal file
59
simgear/ephemeris/mars.cxx
Normal file
@@ -0,0 +1,59 @@
|
||||
/**************************************************************************
|
||||
* mars.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "mars.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mars::Mars(FGTime *t)
|
||||
* Public constructor for class Mars
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mars are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mars::Mars(FGTime *t) :
|
||||
CelestialBody(49.55740, 2.1108100E-5,
|
||||
1.8497, -1.78E-8,
|
||||
286.5016, 2.9296100E-5,
|
||||
1.5236880, 0.000000,
|
||||
0.093405, 2.516E-9,
|
||||
18.60210, 0.52402077660, t)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mars, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mars specific equation
|
||||
*************************************************************************/
|
||||
void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
|
||||
}
|
||||
38
simgear/ephemeris/mars.hxx
Normal file
38
simgear/ephemeris/mars.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/**************************************************************************
|
||||
* mars.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _MARS_HXX_
|
||||
#define _MARS_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Mars : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mars ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _MARS_HXX_
|
||||
61
simgear/ephemeris/mercury.cxx
Normal file
61
simgear/ephemeris/mercury.cxx
Normal file
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************
|
||||
* mercury.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "mercury.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mercury::Mercury(FGTime *t)
|
||||
* Public constructor for class Mercury
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mercury are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mercury::Mercury(FGTime *t) :
|
||||
CelestialBody (48.33130, 3.2458700E-5,
|
||||
7.0047, 5.00E-8,
|
||||
29.12410, 1.0144400E-5,
|
||||
0.3870980, 0.000000,
|
||||
0.205635, 5.59E-10,
|
||||
168.6562, 4.09233443680, t)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mercury, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mercury specific equation
|
||||
*************************************************************************/
|
||||
void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
|
||||
}
|
||||
|
||||
|
||||
38
simgear/ephemeris/mercury.hxx
Normal file
38
simgear/ephemeris/mercury.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/**************************************************************************
|
||||
* mercury.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _MERCURY_HXX_
|
||||
#define _MERCURY_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Mercury : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mercury ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star* ourSun);
|
||||
};
|
||||
|
||||
#endif // _MERURY_HXX_
|
||||
398
simgear/ephemeris/moon.cxx
Normal file
398
simgear/ephemeris/moon.cxx
Normal file
@@ -0,0 +1,398 @@
|
||||
/**************************************************************************
|
||||
* moon.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
|
||||
#include <Main/options.hxx>
|
||||
#include <Objects/texload.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
|
||||
#include "moon.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Moon::Moon(FGTime *t)
|
||||
* Public constructor for class Moon. Initializes the orbital elements and
|
||||
* sets up the moon texture.
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Moon are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Moon::Moon(FGTime *t) :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
60.266600, 0.000000,
|
||||
0.054900, 0.000000,
|
||||
115.3654, 13.0649929509, t)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &moon_texid);
|
||||
xglBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &moon_texid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, moon_texid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// load in the texture data
|
||||
FGPath tpath( current_options.get_fg_root() );
|
||||
tpath.append( "Textures" );
|
||||
tpath.append( "moon.rgb" );
|
||||
|
||||
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
// Try compressed
|
||||
FGPath fg_tpath = tpath;
|
||||
fg_tpath.append( ".gz" );
|
||||
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in loading moon texture " << tpath.str() );
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE,
|
||||
moon_texbuf);
|
||||
|
||||
// setup the halo texture
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &moon_halotexid);
|
||||
xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &moon_halotexid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
setHalo();
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
moon_halotexbuf);
|
||||
moonObject = gluNewQuadric();
|
||||
}
|
||||
|
||||
Moon::~Moon()
|
||||
{
|
||||
//delete moonObject;
|
||||
delete moon_texbuf;
|
||||
delete moon_halotexbuf;
|
||||
}
|
||||
|
||||
|
||||
static int texWidth = 256; /* 64x64 is plenty */
|
||||
|
||||
void Moon::setHalo()
|
||||
{
|
||||
int texSize;
|
||||
//void *textureBuf;
|
||||
GLubyte *p;
|
||||
int i,j;
|
||||
double radius;
|
||||
|
||||
texSize = texWidth*texWidth;
|
||||
|
||||
moon_halotexbuf = new GLubyte[texSize*4];
|
||||
if (!moon_halotexbuf)
|
||||
return; // Ugly!
|
||||
|
||||
p = moon_halotexbuf;
|
||||
|
||||
radius = (double)(texWidth / 2);
|
||||
|
||||
for (i=0; i < texWidth; i++) {
|
||||
for (j=0; j < texWidth; j++) {
|
||||
double x, y, d;
|
||||
|
||||
*p = 0xff;
|
||||
*(p+1) = 0xff;
|
||||
*(p+2) = 0xff;
|
||||
|
||||
x = fabs((double)(i - (texWidth / 2)));
|
||||
y = fabs((double)(j - (texWidth / 2)));
|
||||
|
||||
d = sqrt((x * x) + (y * y));
|
||||
if (d < radius) {
|
||||
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
|
||||
// inverse square looks nice
|
||||
*(p+3) = (int)((double) 0x20 * (t*t));
|
||||
} else {
|
||||
*(p+3) = 0x00;
|
||||
}
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
|
||||
// GL_LUMINANCE,
|
||||
// GL_UNSIGNED_BYTE, textureBuf);
|
||||
//free(textureBuf);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
* this member function calculates the actual topocentric position (i.e.)
|
||||
* the position of the moon as seen from the current position on the surface
|
||||
* of the moon.
|
||||
****************************************************************************/
|
||||
void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
double
|
||||
eccAnom, ecl, actTime,
|
||||
xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
|
||||
Ls, Lm, D, F, mpar, gclat, rho, HA, g,
|
||||
geoRa, geoDec;
|
||||
|
||||
fgAIRCRAFT *air;
|
||||
FGInterface *f;
|
||||
|
||||
air = ¤t_aircraft;
|
||||
f = air->fdm_state;
|
||||
|
||||
updateOrbElements(t);
|
||||
actTime = fgCalcActTime(t);
|
||||
|
||||
// calculate the angle between ecliptic and equatorial coordinate system
|
||||
// in Radians
|
||||
ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
|
||||
eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
|
||||
v = atan2(yv, xv); // the moon's true anomaly
|
||||
r = sqrt (xv*xv + yv*yv); // and its distance
|
||||
|
||||
// estimate the geocentric rectangular coordinates here
|
||||
xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i));
|
||||
yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i));
|
||||
zh = r * (sin(v+w) * sin(i));
|
||||
|
||||
// calculate the ecliptic latitude and longitude here
|
||||
lonEcl = atan2 (yh, xh);
|
||||
latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
|
||||
|
||||
/* Calculate a number of perturbatioin, i.e. disturbances caused by the
|
||||
* gravitational infuence of the sun and the other major planets.
|
||||
* The largest of these even have a name */
|
||||
Ls = ourSun->getM() + ourSun->getw();
|
||||
Lm = M + w + N;
|
||||
D = Lm - Ls;
|
||||
F = Lm - N;
|
||||
|
||||
lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
|
||||
+0.658 * sin (2*D)
|
||||
-0.186 * sin(ourSun->getM())
|
||||
-0.059 * sin(2*M - 2*D)
|
||||
-0.057 * sin(M - 2*D + ourSun->getM())
|
||||
+0.053 * sin(M + 2*D)
|
||||
+0.046 * sin(2*D - ourSun->getM())
|
||||
+0.041 * sin(M - ourSun->getM())
|
||||
-0.035 * sin(D)
|
||||
-0.031 * sin(M + ourSun->getM())
|
||||
-0.015 * sin(2*F - 2*D)
|
||||
+0.011 * sin(M - 4*D)
|
||||
);
|
||||
latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
|
||||
-0.055 * sin(M - F - 2*D)
|
||||
-0.046 * sin(M + F - 2*D)
|
||||
+0.033 * sin(F + 2*D)
|
||||
+0.017 * sin(2*M + F)
|
||||
);
|
||||
r += (-0.58 * cos(M - 2*D)
|
||||
-0.46 * cos(2*D)
|
||||
);
|
||||
FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
|
||||
xg = r * cos(lonEcl) * cos(latEcl);
|
||||
yg = r * sin(lonEcl) * cos(latEcl);
|
||||
zg = r * sin(latEcl);
|
||||
|
||||
xe = xg;
|
||||
ye = yg * cos(ecl) -zg * sin(ecl);
|
||||
ze = yg * sin(ecl) +zg * cos(ecl);
|
||||
|
||||
geoRa = atan2(ye, xe);
|
||||
geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa)
|
||||
<< "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */
|
||||
|
||||
|
||||
// Given the moon's geocentric ra and dec, calculate its
|
||||
// topocentric ra and dec. i.e. the position as seen from the
|
||||
// surface of the earth, instead of the center of the earth
|
||||
|
||||
// First calculate the moon's parrallax, that is, the apparent size of the
|
||||
// (equatorial) radius of the earth, as seen from the moon
|
||||
mpar = asin ( 1 / r);
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() );
|
||||
|
||||
gclat = f->get_Latitude() - 0.003358 *
|
||||
sin (2 * DEG_TO_RAD * f->get_Latitude() );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
|
||||
|
||||
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * f->get_Latitude());
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
|
||||
|
||||
if (geoRa < 0)
|
||||
geoRa += (2*FG_PI);
|
||||
|
||||
HA = t->getLst() - (3.8197186 * geoRa);
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
|
||||
<< " HA = " << HA ); */
|
||||
|
||||
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
|
||||
|
||||
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
|
||||
declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* void Moon::newImage()
|
||||
*
|
||||
* This function regenerates a new visual image of the moon, which is added to
|
||||
* solarSystem display list.
|
||||
*
|
||||
* Arguments: Right Ascension and declination
|
||||
*
|
||||
* return value: none
|
||||
**************************************************************************/
|
||||
void Moon::newImage()
|
||||
{
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
float moon_angle = l->moon_angle;
|
||||
|
||||
/*double x_2, x_4, x_8, x_10;
|
||||
GLfloat ambient;
|
||||
GLfloat amb[4];*/
|
||||
int moonSize = 550;
|
||||
|
||||
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
|
||||
GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
|
||||
|
||||
if( moon_angle*RAD_TO_DEG < 100 )
|
||||
{
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
|
||||
|
||||
xglPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
|
||||
xglTranslatef(0.0, 60000.0, 0.0);
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
// Draw the halo...
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
|
||||
xglEnable( GL_LIGHT0 );
|
||||
// set lighting parameters
|
||||
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
|
||||
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
|
||||
// Enable( GL_CULL_FACE );
|
||||
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
|
||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
// Draw the moon-proper
|
||||
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
gluQuadricTexture(moonObject, GL_TRUE );
|
||||
}
|
||||
gluSphere(moonObject, moonSize, 12, 12 );
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
xglPopMatrix();
|
||||
glDisable(GL_LIGHTING); // Lighting Disabled.
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
57
simgear/ephemeris/moon.hxx
Normal file
57
simgear/ephemeris/moon.hxx
Normal file
@@ -0,0 +1,57 @@
|
||||
/**************************************************************************
|
||||
* moon.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _MOON_HXX_
|
||||
#define _MOON_HXX_
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Moon : public CelestialBody
|
||||
{
|
||||
private:
|
||||
void TexInit(); // This should move to the constructor eventually.
|
||||
|
||||
GLUquadricObj *moonObject;
|
||||
GLuint Sphere;
|
||||
GLuint moon_texid;
|
||||
GLuint moon_halotexid;
|
||||
GLubyte *moon_texbuf;
|
||||
GLubyte *moon_halotexbuf;
|
||||
|
||||
void setHalo();
|
||||
public:
|
||||
Moon ( FGTime *t);
|
||||
~Moon();
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
void newImage();
|
||||
};
|
||||
|
||||
|
||||
#endif // _MOON_HXX_
|
||||
59
simgear/ephemeris/neptune.cxx
Normal file
59
simgear/ephemeris/neptune.cxx
Normal file
@@ -0,0 +1,59 @@
|
||||
/**************************************************************************
|
||||
* neptune.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "neptune.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Neptune::Neptune(FGTime *t)
|
||||
* Public constructor for class Neptune
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Neptune are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Neptune::Neptune(FGTime *t) :
|
||||
CelestialBody(131.7806, 3.0173000E-5,
|
||||
1.7700, -2.550E-7,
|
||||
272.8461, -6.027000E-6,
|
||||
30.058260, 3.313E-8,
|
||||
0.008606, 2.150E-9,
|
||||
260.2471, 0.00599514700, t)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Neptune, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Neptune specific equation
|
||||
*************************************************************************/
|
||||
void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
|
||||
}
|
||||
38
simgear/ephemeris/neptune.hxx
Normal file
38
simgear/ephemeris/neptune.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/**************************************************************************
|
||||
* neptune.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _NEPTUNE_HXX_
|
||||
#define _NEPTUNE_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Neptune : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Neptune ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _NEPTUNE_HXX_
|
||||
36
simgear/ephemeris/pluto.hxx
Normal file
36
simgear/ephemeris/pluto.hxx
Normal file
@@ -0,0 +1,36 @@
|
||||
/**************************************************************************
|
||||
* pluto.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _PLUTO_HXX_
|
||||
#define _PLUTO_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
|
||||
class Pluto : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Pluto ( FGTime t);
|
||||
};
|
||||
|
||||
#endif // _PLUTO_HXX_
|
||||
69
simgear/ephemeris/saturn.cxx
Normal file
69
simgear/ephemeris/saturn.cxx
Normal file
@@ -0,0 +1,69 @@
|
||||
/**************************************************************************
|
||||
* saturn.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "saturn.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Saturn::Saturn(FGTime *t)
|
||||
* Public constructor for class Saturn
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Saturn are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Saturn::Saturn(FGTime *t) :
|
||||
CelestialBody(113.6634, 2.3898000E-5,
|
||||
2.4886, -1.081E-7,
|
||||
339.3939, 2.9766100E-5,
|
||||
9.5547500, 0.000000,
|
||||
0.055546, -9.499E-9,
|
||||
316.9670, 0.03344422820, t)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Saturn, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Saturn specific equation
|
||||
*************************************************************************/
|
||||
void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
|
||||
double actTime = fgCalcActTime(t);
|
||||
double ir = 0.4897394;
|
||||
double Nr = 2.9585076 + 6.6672E-7*actTime;
|
||||
double B = asin (sin(declination) * cos(ir) -
|
||||
cos(declination) * sin(ir) *
|
||||
sin(rightAscension - Nr));
|
||||
double ring_magn = -2.6 * sin(fabs(B)) + 1.2 * pow(sin(B), 2);
|
||||
magnitude = -9.0 + 5*log10(r*R) + 0.044 * FV + ring_magn;
|
||||
}
|
||||
|
||||
45
simgear/ephemeris/saturn.hxx
Normal file
45
simgear/ephemeris/saturn.hxx
Normal file
@@ -0,0 +1,45 @@
|
||||
/**************************************************************************
|
||||
* saturn.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _SATURN_HXX_
|
||||
#define _SATURN_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Saturn : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Saturn ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _SATURN_HXX_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
377
simgear/ephemeris/sky.cxx
Normal file
377
simgear/ephemeris/sky.cxx
Normal file
@@ -0,0 +1,377 @@
|
||||
// sky.cxx -- model sky with an upside down "bowl"
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// 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$
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <simgear/xgl/xgl.h>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/math/fg_random.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <FDM/flight.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/event.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#include "sky.hxx"
|
||||
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# pragma global_optimizer off
|
||||
#endif
|
||||
|
||||
|
||||
// in meters of course
|
||||
#define CENTER_ELEV 25000.0
|
||||
|
||||
#define INNER_RADIUS 50000.0
|
||||
#define INNER_ELEV 20000.0
|
||||
|
||||
#define MIDDLE_RADIUS 70000.0
|
||||
#define MIDDLE_ELEV 8000.0
|
||||
|
||||
#define OUTER_RADIUS 80000.0
|
||||
#define OUTER_ELEV 0.0
|
||||
|
||||
#define BOTTOM_RADIUS 50000.0
|
||||
#define BOTTOM_ELEV -2000.0
|
||||
|
||||
|
||||
static float inner_vertex[12][3];
|
||||
static float middle_vertex[12][3];
|
||||
static float outer_vertex[12][3];
|
||||
static float bottom_vertex[12][3];
|
||||
|
||||
static GLubyte inner_color[12][4];
|
||||
static GLubyte middle_color[12][4];
|
||||
static GLubyte outer_color[12][4];
|
||||
|
||||
|
||||
// Calculate the sky structure vertices
|
||||
void fgSkyVerticesInit( void ) {
|
||||
float theta;
|
||||
int i;
|
||||
|
||||
FG_LOG(FG_ASTRO, FG_INFO, " Generating the sky dome vertices.");
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
theta = (i * 30.0) * DEG_TO_RAD;
|
||||
|
||||
inner_vertex[i][0] = cos(theta) * INNER_RADIUS;
|
||||
inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
|
||||
inner_vertex[i][2] = INNER_ELEV;
|
||||
|
||||
// printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
|
||||
// sin(theta) * INNER_RADIUS);
|
||||
|
||||
middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
|
||||
middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
|
||||
middle_vertex[i][2] = MIDDLE_ELEV;
|
||||
|
||||
outer_vertex[i][0] = cos((double)theta) * OUTER_RADIUS;
|
||||
outer_vertex[i][1] = sin((double)theta) * OUTER_RADIUS;
|
||||
outer_vertex[i][2] = OUTER_ELEV;
|
||||
|
||||
bottom_vertex[i][0] = cos((double)theta) * BOTTOM_RADIUS;
|
||||
bottom_vertex[i][1] = sin((double)theta) * BOTTOM_RADIUS;
|
||||
bottom_vertex[i][2] = BOTTOM_ELEV;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// (Re)calculate the sky colors at each vertex
|
||||
void fgSkyColorsInit( void ) {
|
||||
fgLIGHT *l;
|
||||
double sun_angle, diff;
|
||||
double outer_param[3], outer_amt[3], outer_diff[3];
|
||||
double middle_param[3], middle_amt[3], middle_diff[3];
|
||||
int i, j;
|
||||
|
||||
l = &cur_light_params;
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
" Generating the sky colors for each vertex." );
|
||||
|
||||
// setup for the possibility of sunset effects
|
||||
sun_angle = l->sun_angle * RAD_TO_DEG;
|
||||
// fgPrintf( FG_ASTRO, FG_INFO,
|
||||
// " Sun angle in degrees = %.2f\n", sun_angle);
|
||||
|
||||
if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
|
||||
// 0.0 - 0.4
|
||||
outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 20.0;
|
||||
outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
|
||||
outer_param[2] = -(10.0 - fabs(90.0 - sun_angle)) / 30.0;
|
||||
// outer_param[2] = 0.0;
|
||||
|
||||
middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
|
||||
middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 80.0;
|
||||
middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_param[0] / 6.0;
|
||||
outer_diff[1] = outer_param[1] / 6.0;
|
||||
outer_diff[2] = outer_param[2] / 6.0;
|
||||
|
||||
middle_diff[0] = middle_param[0] / 6.0;
|
||||
middle_diff[1] = middle_param[1] / 6.0;
|
||||
middle_diff[2] = middle_param[2] / 6.0;
|
||||
} else {
|
||||
outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
|
||||
middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
|
||||
middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
|
||||
}
|
||||
// printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
|
||||
// outer_red_param, outer_red_diff);
|
||||
|
||||
// calculate transition colors between sky and fog
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = outer_param[j];
|
||||
middle_amt[j] = middle_param[j];
|
||||
}
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->fog_color[j], diff);
|
||||
|
||||
inner_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.3) * 255);
|
||||
middle_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.9
|
||||
+ middle_amt[j]) * 255);
|
||||
outer_color[i][j] = (GLubyte)((l->fog_color[j] + outer_amt[j])
|
||||
* 255);
|
||||
|
||||
if ( inner_color[i][j] > 255 ) { inner_color[i][j] = 255; }
|
||||
if ( inner_color[i][j] < 25 ) { inner_color[i][j] = 25; }
|
||||
if ( middle_color[i][j] > 255 ) { middle_color[i][j] = 255; }
|
||||
if ( middle_color[i][j] < 25 ) { middle_color[i][j] = 25; }
|
||||
if ( outer_color[i][j] > 255 ) { outer_color[i][j] = 255; }
|
||||
if ( outer_color[i][j] < 25 ) { outer_color[i][j] = 25; }
|
||||
}
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
(GLubyte)(l->sky_color[3] * 255);
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] -= outer_diff[j];
|
||||
middle_amt[j] -= middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
middle_color[i][3]);
|
||||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = 0.0;
|
||||
middle_amt[j] = 0.0;
|
||||
}
|
||||
|
||||
for ( i = 6; i < 12; i++ ) {
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->fog_color[j], diff);
|
||||
|
||||
inner_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.3) * 255);
|
||||
middle_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.9
|
||||
+ middle_amt[j]) * 255);
|
||||
outer_color[i][j] = (GLubyte)((l->fog_color[j] + outer_amt[j])
|
||||
* 255);
|
||||
|
||||
if ( inner_color[i][j] > 255 ) { inner_color[i][j] = 255; }
|
||||
if ( inner_color[i][j] < 25 ) { inner_color[i][j] = 25; }
|
||||
if ( middle_color[i][j] > 255 ) { middle_color[i][j] = 255; }
|
||||
if ( middle_color[i][j] < 25 ) { middle_color[i][j] = 25; }
|
||||
if ( outer_color[i][j] > 255 ) { outer_color[i][j] = 255; }
|
||||
if ( outer_color[i][j] < 35 ) { outer_color[i][j] = 35; }
|
||||
}
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
(GLubyte)(l->sky_color[3] * 255);
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] += outer_diff[j];
|
||||
middle_amt[j] += middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
middle_color[i][3]);
|
||||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initialize the sky structure and colors
|
||||
void fgSkyInit( void ) {
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Initializing the sky" );
|
||||
|
||||
fgSkyVerticesInit();
|
||||
|
||||
// regester fgSkyColorsInit() as an event to be run periodically
|
||||
global_events.Register( "fgSkyColorsInit()", fgSkyColorsInit,
|
||||
fgEVENT::FG_EVENT_READY, 30000);
|
||||
}
|
||||
|
||||
|
||||
// Draw the Sky
|
||||
void fgSkyRender( void ) {
|
||||
FGInterface *f;
|
||||
fgLIGHT *l;
|
||||
GLubyte sky_color[4];
|
||||
GLubyte inner_color[4];
|
||||
GLubyte middle_color[4];
|
||||
GLubyte outer_color[4];
|
||||
double diff;
|
||||
int i;
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
l = &cur_light_params;
|
||||
|
||||
// printf("Rendering the sky.\n");
|
||||
|
||||
// calculate the proper colors
|
||||
for ( i = 0; i < 3; i++ ) {
|
||||
diff = l->sky_color[i] - l->adj_fog_color[i];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->adj_fog_color[j], diff);
|
||||
|
||||
inner_color[i] = (GLubyte)((l->sky_color[i] - diff * 0.3) * 255);
|
||||
middle_color[i] = (GLubyte)((l->sky_color[i] - diff * 0.9) * 255);
|
||||
outer_color[i] = (GLubyte)(l->adj_fog_color[i] * 255);
|
||||
}
|
||||
inner_color[3] = middle_color[3] = outer_color[3] =
|
||||
(GLubyte)(l->adj_fog_color[3] * 255);
|
||||
|
||||
xglPushMatrix();
|
||||
|
||||
// Translate to view position
|
||||
Point3D zero_elev = current_view.get_cur_zero_elev();
|
||||
xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() );
|
||||
// printf(" Translated to %.2f %.2f %.2f\n",
|
||||
// zero_elev.x, zero_elev.y, zero_elev.z );
|
||||
|
||||
// Rotate to proper orientation
|
||||
// printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
|
||||
// FG_Latitude * RAD_TO_DEG);
|
||||
xglRotatef( f->get_Longitude() * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||
xglRotatef( 90.0 - f->get_Latitude() * RAD_TO_DEG, 0.0, 1.0, 0.0 );
|
||||
xglRotatef( l->sun_rotation * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||
|
||||
// Draw inner/center section of sky*/
|
||||
xglBegin( GL_TRIANGLE_FAN );
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
sky_color[i] = (GLubyte)(l->sky_color[i] * 255);
|
||||
}
|
||||
xglColor4fv(l->sky_color);
|
||||
xglVertex3f(0.0, 0.0, CENTER_ELEV);
|
||||
for ( i = 11; i >= 0; i-- ) {
|
||||
xglColor4ubv( inner_color );
|
||||
xglVertex3fv( inner_vertex[i] );
|
||||
}
|
||||
xglColor4ubv( inner_color );
|
||||
xglVertex3fv( inner_vertex[11] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the middle ring
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglColor4ubv( middle_color );
|
||||
// printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
// middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
// middle_color[i][3]);
|
||||
// xglColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
xglVertex3fv( middle_vertex[i] );
|
||||
xglColor4ubv( inner_color );
|
||||
// printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
// inner_color[i][0], inner_color[i][1], inner_color[i][2],
|
||||
// inner_color[i][3]);
|
||||
// xglColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
xglVertex3fv( inner_vertex[i] );
|
||||
}
|
||||
xglColor4ubv( middle_color );
|
||||
// xglColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
xglVertex3fv( middle_vertex[0] );
|
||||
xglColor4ubv( inner_color );
|
||||
// xglColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
xglVertex3fv( inner_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the outer ring
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglColor4ubv( outer_color );
|
||||
xglVertex3fv( outer_vertex[i] );
|
||||
xglColor4ubv( middle_color );
|
||||
xglVertex3fv( middle_vertex[i] );
|
||||
}
|
||||
xglColor4ubv( outer_color );
|
||||
xglVertex3fv( outer_vertex[0] );
|
||||
xglColor4ubv( middle_color );
|
||||
xglVertex3fv( middle_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the bottom skirt
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
xglColor4ubv( outer_color );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglVertex3fv( bottom_vertex[i] );
|
||||
xglVertex3fv( outer_vertex[i] );
|
||||
}
|
||||
xglVertex3fv( bottom_vertex[0] );
|
||||
xglVertex3fv( outer_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
xglPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
53
simgear/ephemeris/sky.hxx
Normal file
53
simgear/ephemeris/sky.hxx
Normal file
@@ -0,0 +1,53 @@
|
||||
// sky.hxx -- model sky with an upside down "bowl"
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// 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$
|
||||
|
||||
|
||||
#ifndef _SKY_HXX
|
||||
#define _SKY_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include <plib/ssg.h> // plib include
|
||||
|
||||
|
||||
class fgSky : ssgLeaf
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// (Re)generate the display list
|
||||
void fgSkyInit( void );
|
||||
|
||||
// (Re)calculate the sky colors at each vertex
|
||||
void fgSkyColorsInit( void );
|
||||
|
||||
// Draw the Sky
|
||||
void fgSkyRender( void );
|
||||
|
||||
|
||||
#endif // _SKY_HXX
|
||||
|
||||
|
||||
217
simgear/ephemeris/solarsystem.cxx
Normal file
217
simgear/ephemeris/solarsystem.cxx
Normal file
@@ -0,0 +1,217 @@
|
||||
/**************************************************************************
|
||||
* solarsystem.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <simgear/xgl/xgl.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Time/sunpos.hxx>
|
||||
#include <Time/moonpos.hxx>
|
||||
#include "solarsystem.hxx"
|
||||
|
||||
/***************************************************************************
|
||||
* default constructor for class SolarSystem:
|
||||
* or course there can only be one way to create an entire solar system -:) )
|
||||
* the FGTime argument is needed to properly initialize the the current orbital
|
||||
* elements
|
||||
*************************************************************************/
|
||||
SolarSystem::SolarSystem(FGTime *t)
|
||||
{
|
||||
if (theSolarSystem)
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one solarsystem allowed" );
|
||||
exit(-1);
|
||||
}
|
||||
theSolarSystem = this;
|
||||
ourSun = new Star(t);
|
||||
earthsMoon = new Moon(t);
|
||||
mercury = new Mercury(t);
|
||||
venus = new Venus(t);
|
||||
mars = new Mars(t);
|
||||
jupiter = new Jupiter(t);
|
||||
saturn = new Saturn(t);
|
||||
uranus = new Uranus(t);
|
||||
neptune = new Neptune(t);
|
||||
|
||||
displayList = 0;
|
||||
};
|
||||
|
||||
/**************************************************************************
|
||||
* the destructor for class SolarSystem;
|
||||
**************************************************************************/
|
||||
SolarSystem::~SolarSystem()
|
||||
{
|
||||
delete ourSun;
|
||||
delete earthsMoon;
|
||||
delete mercury;
|
||||
delete venus;
|
||||
delete mars;
|
||||
delete jupiter;
|
||||
delete saturn;
|
||||
delete uranus;
|
||||
delete neptune;
|
||||
}
|
||||
/****************************************************************************
|
||||
* void SolarSystem::rebuild()
|
||||
*
|
||||
* this member function updates the positions for the sun, moon, and planets,
|
||||
* and then rebuilds the display list.
|
||||
*
|
||||
* arguments: none
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
void SolarSystem::rebuild()
|
||||
{
|
||||
//fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
//float x, y, z;
|
||||
//double sun_angle;
|
||||
double ra, dec;
|
||||
//double x_2, x_4, x_8, x_10;*/
|
||||
double magnitude;
|
||||
//GLfloat ambient;
|
||||
//GLfloat amb[4];
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// Step 1: update all the positions
|
||||
ourSun->updatePosition(t);
|
||||
earthsMoon->updatePosition(t, ourSun);
|
||||
mercury->updatePosition(t, ourSun);
|
||||
venus->updatePosition(t, ourSun);
|
||||
mars->updatePosition(t, ourSun);
|
||||
jupiter->updatePosition(t, ourSun);
|
||||
saturn->updatePosition(t, ourSun);
|
||||
uranus->updatePosition(t, ourSun);
|
||||
neptune->updatePosition(t, ourSun);
|
||||
|
||||
fgUpdateSunPos(); // get the right sun angle (especially important when
|
||||
// running for the first time).
|
||||
fgUpdateMoonPos();
|
||||
|
||||
if (displayList)
|
||||
xglDeleteLists(displayList, 1);
|
||||
|
||||
displayList = xglGenLists(1);
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Rebuilding astro display list" );
|
||||
|
||||
// Step 2: rebuild the display list
|
||||
xglNewList( displayList, GL_COMPILE);
|
||||
{
|
||||
// Step 2a: Add the moon...
|
||||
// Not that it is preferred to draw the moon first, and the sun next, in order to mime a
|
||||
// solar eclipse. This is yet untested though...
|
||||
// Euhh, actually the ecplise doesn't work...
|
||||
|
||||
earthsMoon->newImage();
|
||||
// Step 2b: Add the sun
|
||||
ourSun->newImage();
|
||||
// Step 2c: Add the planets
|
||||
xglBegin(GL_POINTS);
|
||||
mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
venus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
mars ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
jupiter->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
saturn ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
uranus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
neptune->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
xglEnd();
|
||||
xglEnable(GL_LIGHTING);
|
||||
}
|
||||
xglEndList();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* double SolarSystem::scaleMagnitude(double magn)
|
||||
* This private member function rescales the original magnitude, as used in the
|
||||
* astronomical sense of the word, into a value used by OpenGL to draw a
|
||||
* convincing Star or planet
|
||||
*
|
||||
* Argument: the astronomical magnitude
|
||||
*
|
||||
* return value: the rescaled magnitude
|
||||
****************************************************************************/
|
||||
double SolarSystem::scaleMagnitude(double magn)
|
||||
{
|
||||
double magnitude = (0.0 - magn) / 5.0 + 1.0;
|
||||
magnitude = magnitude * 0.7 + (3 * 0.1);
|
||||
if (magnitude > 1.0) magnitude = 1.0;
|
||||
if (magnitude < 0.0) magnitude = 0.0;
|
||||
return magnitude;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* void SolarSytem::addPlanetToList(double ra, double dec, double magn);
|
||||
*
|
||||
* This private member function first causes the magnitude to be properly
|
||||
* rescaled, and then adds the planet to the display list.
|
||||
*
|
||||
* arguments: Right Ascension, declination, and magnitude
|
||||
*
|
||||
* return value: none
|
||||
**************************************************************************/
|
||||
void SolarSystem::addPlanetToList(double ra, double dec, double magn)
|
||||
{
|
||||
double
|
||||
magnitude = scaleMagnitude ( magn );
|
||||
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
|
||||
if ((double) (l->sun_angle - FG_PI_2) >
|
||||
((magnitude - 1.0) * - 20 * DEG_TO_RAD))
|
||||
{
|
||||
xglColor3f (magnitude, magnitude, magnitude);
|
||||
xglVertex3f( 50000.0 * cos (ra) * cos (dec),
|
||||
50000.0 * sin (ra) * cos (dec),
|
||||
50000.0 * sin (dec));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SolarSystem* SolarSystem::theSolarSystem = 0;
|
||||
|
||||
/******************************************************************************
|
||||
* void solarSystemRebuild()
|
||||
* this a just a wrapper function, provided for use as an interface to the
|
||||
* event manager
|
||||
*****************************************************************************/
|
||||
void solarSystemRebuild()
|
||||
{
|
||||
SolarSystem::theSolarSystem->rebuild();
|
||||
}
|
||||
91
simgear/ephemeris/solarsystem.hxx
Normal file
91
simgear/ephemeris/solarsystem.hxx
Normal file
@@ -0,0 +1,91 @@
|
||||
/**************************************************************************
|
||||
* solarsystem.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _SOLARSYSTEM_H_
|
||||
#define _SOLARSYSTEM_H_
|
||||
|
||||
#include <Time/light.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
#include <Main/views.hxx>
|
||||
|
||||
#include "star.hxx"
|
||||
#include "moon.hxx"
|
||||
#include "mercury.hxx"
|
||||
#include "venus.hxx"
|
||||
#include "mars.hxx"
|
||||
#include "jupiter.hxx"
|
||||
#include "saturn.hxx"
|
||||
#include "uranus.hxx"
|
||||
#include "neptune.hxx"
|
||||
#include "pluto.hxx"
|
||||
|
||||
|
||||
class SolarSystem
|
||||
{
|
||||
private:
|
||||
Star* ourSun;
|
||||
Moon* earthsMoon;
|
||||
Mercury* mercury;
|
||||
Venus* venus;
|
||||
Mars* mars;
|
||||
Jupiter* jupiter;
|
||||
Saturn* saturn;
|
||||
Uranus* uranus;
|
||||
Neptune* neptune;
|
||||
//Pluto* pluto;
|
||||
|
||||
GLint displayList;
|
||||
double scaleMagnitude(double magn);
|
||||
void addPlanetToList(double ra, double dec, double magn);
|
||||
|
||||
|
||||
public:
|
||||
SolarSystem(FGTime *t);
|
||||
CelestialBody *getSun();
|
||||
CelestialBody *getMoon();
|
||||
~SolarSystem();
|
||||
|
||||
static SolarSystem *theSolarSystem; // thanks to Bernie Bright!
|
||||
void rebuild();
|
||||
friend void solarSystemRebuild();
|
||||
void draw();
|
||||
};
|
||||
|
||||
inline CelestialBody* SolarSystem::getSun()
|
||||
{
|
||||
return ourSun;
|
||||
}
|
||||
|
||||
inline CelestialBody* SolarSystem::getMoon()
|
||||
{
|
||||
return earthsMoon;
|
||||
}
|
||||
|
||||
inline void SolarSystem::draw()
|
||||
{
|
||||
xglCallList(displayList);
|
||||
}
|
||||
|
||||
extern void solarSystemRebuild();
|
||||
|
||||
#endif // _SOLARSYSTEM_H_
|
||||
270
simgear/ephemeris/star.cxx
Normal file
270
simgear/ephemeris/star.cxx
Normal file
@@ -0,0 +1,270 @@
|
||||
/**************************************************************************
|
||||
* star.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Time/sunpos.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <Main/options.hxx>
|
||||
|
||||
#include "star.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Star::Star(FGTime *t)
|
||||
* Public constructor for class Star
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements our sun are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
* note that the word sun is avoided, in order to prevent some compilation
|
||||
* problems on sun systems
|
||||
************************************************************************/
|
||||
Star::Star(FGTime *t) :
|
||||
CelestialBody (0.000000, 0.0000000000,
|
||||
0.0000, 0.00000,
|
||||
282.9404, 4.7093500E-5,
|
||||
1.0000000, 0.000000,
|
||||
0.016709, -1.151E-9,
|
||||
356.0470, 0.98560025850, t)
|
||||
{
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Sun Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &sun_texid);
|
||||
xglBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &sun_texid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, sun_texid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
setTexture();
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
sun_texbuf);
|
||||
|
||||
SunObject = gluNewQuadric();
|
||||
if(SunObject == NULL)
|
||||
{
|
||||
printf("gluNewQuadric(SunObject) failed !\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//SunList = 0;
|
||||
distance = 0.0;
|
||||
}
|
||||
|
||||
Star::~Star()
|
||||
{
|
||||
//delete SunObject;
|
||||
delete [] sun_texbuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int texWidth = 256; /* 64x64 is plenty */
|
||||
|
||||
void Star::setTexture()
|
||||
{
|
||||
int texSize;
|
||||
//void *textureBuf;
|
||||
GLubyte *p;
|
||||
int i,j;
|
||||
double radius;
|
||||
|
||||
texSize = texWidth*texWidth;
|
||||
|
||||
sun_texbuf = new GLubyte[texSize*4];
|
||||
if (!sun_texbuf)
|
||||
return; // Ugly!
|
||||
|
||||
p = sun_texbuf;
|
||||
|
||||
radius = (double)(texWidth / 2);
|
||||
|
||||
for (i=0; i < texWidth; i++) {
|
||||
for (j=0; j < texWidth; j++) {
|
||||
double x, y, d;
|
||||
|
||||
*p = 0xff;
|
||||
*(p+1) = 0xff;
|
||||
*(p+2) = 0xff;
|
||||
|
||||
x = fabs((double)(i - (texWidth / 2)));
|
||||
y = fabs((double)(j - (texWidth / 2)));
|
||||
|
||||
d = sqrt((x * x) + (y * y));
|
||||
if (d < radius) {
|
||||
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
|
||||
// inverse square looks nice
|
||||
*(p+3) = (int)((double) 0xff * (t*t));
|
||||
} else {
|
||||
*(p+3) = 0x00;
|
||||
}
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
|
||||
// GL_LUMINANCE,
|
||||
// GL_UNSIGNED_BYTE, textureBuf);
|
||||
//free(textureBuf);
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of our sun.
|
||||
*************************************************************************/
|
||||
void Star::updatePosition(FGTime *t)
|
||||
{
|
||||
double
|
||||
actTime, eccAnom,
|
||||
xv, yv, v, r,
|
||||
xe, ye, ze, ecl;
|
||||
|
||||
updateOrbElements(t);
|
||||
|
||||
actTime = fgCalcActTime(t);
|
||||
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
|
||||
eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation)
|
||||
|
||||
xv = cos(eccAnom) - e;
|
||||
yv = sqrt (1.0 - e*e) * sin(eccAnom);
|
||||
v = atan2 (yv, xv); // the sun's true anomaly
|
||||
distance = r = sqrt (xv*xv + yv*yv); // and its distance
|
||||
|
||||
lonEcl = v + w; // the sun's true longitude
|
||||
latEcl = 0;
|
||||
|
||||
// convert the sun's true longitude to ecliptic rectangular
|
||||
// geocentric coordinates (xs, ys)
|
||||
xs = r * cos (lonEcl);
|
||||
ys = r * sin (lonEcl);
|
||||
|
||||
// convert ecliptic coordinates to equatorial rectangular
|
||||
// geocentric coordinates
|
||||
|
||||
xe = xs;
|
||||
ye = ys * cos (ecl);
|
||||
ze = ys * sin (ecl);
|
||||
|
||||
// And finally, calculate right ascension and declination
|
||||
rightAscension = atan2 (ye, xe);
|
||||
declination = atan2 (ze, sqrt (xe*xe + ye*ye));
|
||||
}
|
||||
|
||||
void Star::newImage(void)
|
||||
{
|
||||
/*static float stars[3];
|
||||
stars[0] = 0.0;
|
||||
stars[1] = 0.0;
|
||||
stars[2] = 1.0;*/
|
||||
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
float sun_angle = l->sun_angle;
|
||||
|
||||
if( sun_angle*RAD_TO_DEG < 100 ) { // else no need to draw sun
|
||||
|
||||
|
||||
double x_2, x_4, x_8, x_10;
|
||||
GLfloat ambient;
|
||||
GLfloat amb[4];
|
||||
int sun_size = 550;
|
||||
|
||||
// daily variation sun gets larger near horizon
|
||||
/*if(sun_angle*RAD_TO_DEG > 84.0 && sun_angle*RAD_TO_DEG < 95)
|
||||
{
|
||||
double sun_grow = 9*fabs(94-sun_angle*RAD_TO_DEG);
|
||||
sun_size = (int)(sun_size + sun_size * cos(sun_grow*DEG_TO_RAD));
|
||||
}*/
|
||||
x_2 = sun_angle * sun_angle;
|
||||
x_4 = x_2 * x_2;
|
||||
x_8 = x_4 * x_4;
|
||||
x_10 = x_8 * x_2;
|
||||
ambient = (float)(0.4 * pow (1.1, - x_10 / 30.0));
|
||||
if (ambient < 0.3) ambient = 0.3;
|
||||
if (ambient > 1.0) ambient = 1.0;
|
||||
|
||||
amb[0] = ((ambient * 6.0) - 1.0); // minimum value = 0.8
|
||||
amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3
|
||||
amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0
|
||||
amb[3] = 1.00;
|
||||
|
||||
if (amb[0] > 1.0) amb[0] = 1.0;
|
||||
if (amb[1] > 1.0) amb[1] = 1.0;
|
||||
if (amb[2] > 1.0) amb[2] = 1.0;
|
||||
xglColor3fv(amb);
|
||||
glPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglTranslatef(0,60000,0);
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
xglDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_LIGHTING); // LIGHTING DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
glPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglColor4fv(amb);
|
||||
xglTranslatef(0,60000,0);
|
||||
gluSphere( SunObject, sun_size, 10, 10 );
|
||||
}
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
}
|
||||
98
simgear/ephemeris/star.hxx
Normal file
98
simgear/ephemeris/star.hxx
Normal file
@@ -0,0 +1,98 @@
|
||||
/**************************************************************************
|
||||
* star.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* 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$
|
||||
**************************************************************************/
|
||||
#ifndef _STAR_HXX_
|
||||
#define _STAR_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
|
||||
|
||||
class Star : public CelestialBody
|
||||
{
|
||||
private:
|
||||
//double longitude; // the sun's true longitude - this is depreciated by
|
||||
// CelestialBody::lonEcl
|
||||
double xs, ys; // the sun's rectangular geocentric coordinates
|
||||
double distance; // the sun's distance to the earth
|
||||
GLUquadricObj *SunObject;
|
||||
GLuint sun_texid;
|
||||
GLubyte *sun_texbuf;
|
||||
|
||||
void setTexture();
|
||||
public:
|
||||
Star (FGTime *t);
|
||||
~Star();
|
||||
void updatePosition(FGTime *t);
|
||||
double getM();
|
||||
double getw();
|
||||
//double getLon();
|
||||
double getxs();
|
||||
double getys();
|
||||
double getDistance();
|
||||
void newImage();
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline double Star::getM()
|
||||
{
|
||||
return M;
|
||||
}
|
||||
|
||||
inline double Star::getw()
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
inline double Star::getxs()
|
||||
{
|
||||
return xs;
|
||||
}
|
||||
|
||||
inline double Star::getys()
|
||||
{
|
||||
return ys;
|
||||
}
|
||||
|
||||
inline double Star::getDistance()
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
#endif // _STAR_HXX_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
268
simgear/ephemeris/stars.cxx
Normal file
268
simgear/ephemeris/stars.cxx
Normal file
@@ -0,0 +1,268 @@
|
||||
// stars.cxx -- data structures and routines for managing and rendering stars.
|
||||
//
|
||||
// Written by Curtis Olson, started August 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
|
||||
//
|
||||
// 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$
|
||||
//*************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio>
|
||||
# include <cstring>
|
||||
# include <ctime>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <simgear/xgl/xgl.h>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
#include <simgear/misc/fgstream.hxx>
|
||||
#include <simgear/misc/stopwatch.hxx>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#include "stars.hxx"
|
||||
|
||||
// FG_USING_STD(getline);
|
||||
|
||||
#define EpochStart (631065600)
|
||||
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
|
||||
#define FG_MAX_STARS 3500
|
||||
|
||||
// Define four structures, each with varying amounts of stars
|
||||
static GLint stars[FG_STAR_LEVELS];
|
||||
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void ) {
|
||||
// -dw- avoid local data > 32k error by dynamic allocation of the
|
||||
// array, problem for some compilers
|
||||
Point3D *starlist = new Point3D[FG_MAX_STARS];
|
||||
// struct CelestialCoord pltPos;
|
||||
double right_ascension, declination, magnitude;
|
||||
double min_magnitude[FG_STAR_LEVELS];
|
||||
// double ra_save, decl_save;
|
||||
// double ra_save1, decl_save1;
|
||||
int i, j, starcount, count;
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Initializing stars" );
|
||||
|
||||
if ( FG_STAR_LEVELS < 4 ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Big whups in stars.cxx" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// build the full path name to the stars data base file
|
||||
FGPath path ( current_options.get_fg_root() );
|
||||
path.append( "Astro/stars" );
|
||||
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path.str() );
|
||||
|
||||
fg_gzifstream in( path.str() );
|
||||
if ( ! in ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path.str() );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
starcount = 0;
|
||||
|
||||
StopWatch timer;
|
||||
timer.start();
|
||||
|
||||
// read in each line of the file
|
||||
while ( ! in.eof() && starcount < FG_MAX_STARS )
|
||||
{
|
||||
in >> skipcomment;
|
||||
string name;
|
||||
getline( in, name, ',' );
|
||||
in >> starlist[starcount];
|
||||
++starcount;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
"Loaded " << starcount << " stars in "
|
||||
<< timer.elapsedSeconds() << " seconds" );
|
||||
|
||||
min_magnitude[0] = 4.2;
|
||||
min_magnitude[1] = 3.6;
|
||||
min_magnitude[2] = 3.0;
|
||||
min_magnitude[3] = 2.4;
|
||||
min_magnitude[4] = 1.8;
|
||||
min_magnitude[5] = 1.2;
|
||||
min_magnitude[6] = 0.6;
|
||||
min_magnitude[7] = 0.0;
|
||||
|
||||
// build the various star display lists
|
||||
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
|
||||
|
||||
stars[i] = xglGenLists(1);
|
||||
xglNewList( stars[i], GL_COMPILE );
|
||||
xglBegin( GL_POINTS );
|
||||
|
||||
count = 0;
|
||||
|
||||
for ( j = 0; j < starcount; j++ ) {
|
||||
magnitude = starlist[j].z();
|
||||
// printf("magnitude = %.2f\n", magnitude);
|
||||
|
||||
if ( magnitude < min_magnitude[i] ) {
|
||||
right_ascension = starlist[j].x();
|
||||
declination = starlist[j].y();
|
||||
|
||||
count++;
|
||||
|
||||
// scale magnitudes to (0.0 - 1.0)
|
||||
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
|
||||
|
||||
// scale magnitudes again so they look ok
|
||||
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
||||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||
// magnitude =
|
||||
// magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
|
||||
|
||||
magnitude = magnitude * 0.9 +
|
||||
(((FG_STAR_LEVELS - 1) - i) * 0.014);
|
||||
// printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
// name, right_ascension, declination, magnitude);
|
||||
|
||||
xglColor3f( magnitude, magnitude, magnitude );
|
||||
//xglColor3f(0,0,0);*/
|
||||
xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
|
||||
50000.0*sin(right_ascension)*cos(declination),
|
||||
50000.0*sin(declination) );
|
||||
}
|
||||
} // while
|
||||
|
||||
xglEnd();
|
||||
|
||||
/*
|
||||
xglBegin(GL_LINE_LOOP);
|
||||
xglColor3f(1.0, 0.0, 0.0);
|
||||
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(decl_save-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(decl_save-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(decl_save+0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(decl_save+0.2) );
|
||||
xglEnd();
|
||||
*/
|
||||
|
||||
/*
|
||||
xglBegin(GL_LINE_LOOP);
|
||||
xglColor3f(0.0, 1.0, 0.0);
|
||||
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(decl_save1-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(decl_save1-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(decl_save1+0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(decl_save1+0.2) );
|
||||
xglEnd();
|
||||
*/
|
||||
|
||||
xglEndList();
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
" Loading " << count << " stars brighter than "
|
||||
<< min_magnitude[i] );
|
||||
}
|
||||
|
||||
return 1; // OK, we got here because initialization worked.
|
||||
}
|
||||
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void ) {
|
||||
FGInterface *f;
|
||||
fgLIGHT *l;
|
||||
FGTime *t;
|
||||
int i;
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
l = &cur_light_params;
|
||||
t = FGTime::cur_time_params;
|
||||
|
||||
// FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
|
||||
|
||||
// t->sun_angle = 3.0; // to force stars to be drawn (for testing)
|
||||
|
||||
// render the stars
|
||||
if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
|
||||
// determine which star structure to draw
|
||||
if ( l->sun_angle > (FG_PI_2 + 10.0 * DEG_TO_RAD ) ) {
|
||||
i = 0;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 8.8 * DEG_TO_RAD ) ) {
|
||||
i = 1;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 7.5 * DEG_TO_RAD ) ) {
|
||||
i = 2;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 7.0 * DEG_TO_RAD ) ) {
|
||||
i = 3;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 6.5 * DEG_TO_RAD ) ) {
|
||||
i = 4;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 6.0 * DEG_TO_RAD ) ) {
|
||||
i = 5;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 5.5 * DEG_TO_RAD ) ) {
|
||||
i = 6;
|
||||
} else {
|
||||
i = 7;
|
||||
}
|
||||
|
||||
// printf("RENDERING STARS = %d (night)\n", i);
|
||||
|
||||
xglCallList(stars[i]);
|
||||
} else {
|
||||
// printf("not RENDERING STARS (day)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
simgear/ephemeris/stars.hxx
Normal file
47
simgear/ephemeris/stars.hxx
Normal file
@@ -0,0 +1,47 @@
|
||||
// stars.hxx -- data structures and routines for managing and rendering stars.
|
||||
//
|
||||
// Written by Curtis Olson, started August 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
|
||||
//
|
||||
// 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$
|
||||
|
||||
|
||||
#ifndef _STARS_HXX
|
||||
#define _STARS_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#define FG_STAR_LEVELS 8 // how many star transitions
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void );
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void );
|
||||
|
||||
// [no longer used?] extern FGTime cur_time_params;
|
||||
|
||||
|
||||
#endif // _STARS_HXX
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user