Compare commits

..

468 Commits

Author SHA1 Message Date
curt
16bd8cef38 Updated for 0.3.1 2002-12-04 19:47:57 +00:00
curt
f2567f9af4 Fixes for 0.3.1 release. 2002-12-04 19:46:12 +00:00
curt
c363758449 Updated for 0.3.0 release. 2002-12-03 18:27:04 +00:00
curt
dfdeb8be9b Updated version number 2002-12-03 18:19:41 +00:00
curt
d1c8f60ca9 #include <simgear_config.h> as necessary. 2002-12-03 13:13:16 +00:00
curt
2fb961c922 NOMINMAX fix ... 2002-12-02 22:12:22 +00:00
david
2e17b28994 Includes patch from Erik Hofman. 2002-11-17 11:07:40 +00:00
david
c3f558b034 Cygwin patch from Patrick Staehlin:
To compile the development CVS version of FlightGear(0.9.0) i had to
apply some small changes to SimGear and FlightGear.

The changes need probably some additional ifdefs for other platforms but
since my linux-hd crashed i can't verify that.
2002-11-17 00:42:17 +00:00
david
65ce1a04b2 MS patch from Norm Vine to fix min/max macro defs. 2002-11-17 00:34:40 +00:00
david
3af4a19f76 Allow 'include' attribute on root PropertyList element. 2002-11-11 14:40:16 +00:00
david
5178f69f18 Simplified the command-manager interface. 2002-10-26 01:18:03 +00:00
curt
52e2005b3e Erik Hofman: fix an Irix build problem. 2002-10-24 13:59:33 +00:00
david
94fa51e3f7 Change int to GLenum for portability. 2002-10-18 20:25:21 +00:00
curt
590547e12d John W:
Attached is the new, improved SkyCloud.cpp. Tested on west coast @ KSFO and
east @ KJFK. Don't have any southern hemisphere or other airports to test
against, but you might give it a go and see what happens

Probably a good idea to add some user options to set cloud altitude, startup
position, etc, but for now this should suffice.
2002-10-04 16:44:23 +00:00
curt
c6832d2513 Fixes from Mark Harris. 2002-10-03 19:00:01 +00:00
curt
1fd63c30e9 Fix a texture state problem that caused clouds to occasionally flash all white. 2002-10-03 18:44:34 +00:00
curt
f08ae9f2ea John Wojnaroski:
Attached are the new files to transform the cloud field for local lat/lon.
2002-10-03 02:52:55 +00:00
curt
5c61e97358 ref() the cloud states before use so that if we are dyanmically creating and
deleting cloud layers we don't inadvertantly delete a cloud state.
2002-10-02 16:03:25 +00:00
curt
87e38e2617 Fix a tyop. 2002-09-22 03:42:26 +00:00
curt
92e1856caa Did I forget to commit John's loader patch?
Ran dos2unix on extgl.*
Include <simgear_config.h> from extgl.h so it properly picks up the WIN32
symbol.
2002-09-20 18:10:28 +00:00
curt
20c099b7ef Added extgl.c and extgl.h 2002-09-19 02:30:52 +00:00
curt
7eb74c7e2a Tweaks to build system following removal of interpreter subdir. 2002-09-18 20:38:40 +00:00
david
8d63c300e2 Removed simgear/interpreter directory; most likely we will use the new
PSL interpreted language in plib.
2002-09-18 20:27:17 +00:00
curt
01ccdd3ae1 Erik Hofman:
This patch fixes and STL problem, and adds (compile time) support for
architextures that don't support multitexturing.
2002-09-18 19:41:52 +00:00
curt
ab074726df Removed unnecessary files. 2002-09-18 18:47:47 +00:00
curt
ed26458a24 Norman's most recent 3d clouds code tweaks. 2002-09-18 14:24:19 +00:00
curt
fcf1d34e55 Latest changes from John. 2002-09-17 16:08:00 +00:00
curt
19f99ea273 Build with other simgear header files from source tree, not those that are
installed.
2002-09-17 01:16:18 +00:00
curt
fe5bb76def Latest changes from John Wojnaroski. 2002-09-16 14:55:31 +00:00
david
7ecf508453 Rolled Norm's change back out; update needs to be called earlier. 2002-09-16 13:13:49 +00:00
david
83e6e44eab Patches from Norm Vine to get clouds working (and add some debugging
information).
2002-09-16 02:26:20 +00:00
david
69a93342c0 Ignore generated files. 2002-09-15 10:42:54 +00:00
curt
e17338622a Change the header install directory.
Clean up a couple warnings.
2002-09-15 04:32:28 +00:00
david
a67fd7ea99 Added autom4te.cache. 2002-09-14 16:06:22 +00:00
david
cf2b8afbe9 Added stamp-h1. 2002-09-14 16:05:58 +00:00
david
a1e7761384 Removed /usr/local/include (as with plib). 2002-09-14 16:05:41 +00:00
david
d068915b42 Added newlines and did other clean-ups to eliminate errors and
minimize warnings compiling with g++ 3.2.
2002-09-14 16:03:39 +00:00
curt
adeb0d48fc Upgrade the version number. 2002-09-13 23:19:14 +00:00
curt
55c89ea865 Added simgear/sky/clouds3d to the build system. 2002-09-13 22:51:40 +00:00
curt
8bd07e358f Tweak lib name. 2002-09-13 20:36:19 +00:00
curt
01113e82f3 Initial revision. 2002-09-13 20:29:04 +00:00
curt
6d79582890 Initial revision 2002-09-07 02:58:19 +00:00
curt
2ae3c89406 For version 0.2.0 2002-09-07 01:45:46 +00:00
curt
1818102ffe Updated ... 2002-09-07 01:33:17 +00:00
curt
406d6dd6fc Getting ready for 0.2.0 stable release. 2002-09-07 01:25:02 +00:00
curt
c8ef854f01 Fixes to allow MingW compilation. 2002-09-06 20:05:40 +00:00
curt
87dcaf5a00 Fixes to better support the native irix compilers. 2002-09-06 15:30:11 +00:00
curt
c3bdd0e537 Automake version check is only done in autogen.sh and not in configure. 2002-09-03 21:44:44 +00:00
curt
c23fd6e66f Fix a typo in acinclude.m4 2002-09-03 02:52:39 +00:00
curt
e809eee896 Additional configure changes. 2002-09-02 22:18:31 +00:00
curt
c44ef2126c Tweaks for next prerelease. 2002-09-02 04:08:01 +00:00
curt
e2bfb5633b Minor tweaks. 2002-09-02 03:43:05 +00:00
curt
064ee8ba8f Make sure interpreters/ gets included with "make dist" 2002-09-02 03:41:39 +00:00
curt
a5c130446e Preparation for next pre-release. 2002-08-31 18:39:07 +00:00
curt
4162817c0b More clean ups. 2002-08-31 13:18:49 +00:00
curt
81cab6e089 Additional build system tweaks, regenerated the .dsp/.dsw's. 2002-08-30 15:03:30 +00:00
curt
d78204d147 Several fixes and tweaks. 2002-08-29 14:00:35 +00:00
curt
d8b523d067 Attempting more fixes to our autoconf/make scripts. 2002-08-28 14:08:12 +00:00
curt
c4cfad6069 Additional tweaks that got lost somehow. 2002-08-27 21:48:51 +00:00
curt
5bddb88ce2 Ooops, minor typo fixed. 2002-08-27 21:45:48 +00:00
curt
8c4ee69aeb Modernize the autoconf scripts a bit. 2002-08-27 21:44:39 +00:00
curt
b3a533f8ce Add #ifdef'd out support for plibs cheesy lens flare object. 2002-08-27 21:43:35 +00:00
curt
a885314a39 Tidy up the autoconf/automake configuration a bit.
- Removed some old cruft.

- Removed some support for older versions of automake which technically was
  correct, but caused the newer automakes to squawk warnings during an
  initial sanity check (which isn't done very intelligently.)

  NOTE: this fix is technically not correct for older version of automake.
  These older version use the variable "INCLUDES" internally and could have
  them already set to an important value.  That is why we were appending
  our values to them.  However, newer versions of automake don't set this
  value themselves so it is an error to append to a non-existant variable.
  We seem to "get away" with overwriting the value on older versions of
  automake, but if you have problems, consider upgrading to at least
  automake-1.5.
2002-08-25 17:31:47 +00:00
curt
0567a76445 It probably is better not to hide warning messages. Removed spaces from
AC_DEFINE( SYMBOL ) -> AC_DEFINE(SYMBOL)
2002-08-24 18:21:49 +00:00
curt
d6dc2d6eab Brandon Bergren:
2. I changed Simgear's autogen.sh so it is quieter, and errors out if
autoheader or autoconf fails.  It puts all error output in autogen.err, and
deletes it if nothing errored out.  The patch is in (sg.autogen.sh.patch.gz)
This patch applies to flightgear, too.  If someone doesn't like what I did
here, please speak up!  I really believe that this patch will help cause
less confusion among people new to compiling flightgear.
2002-08-24 03:54:45 +00:00
curt
b75a694682 Bernie Bright:
Here are some changes that gave me a significant frame rate increase of about 10 fps with random objects disabled.  The interesting thing is that these changes aren't in the main loop but are in tile loader.  My guess is that I've reduced the memory footprint just enough to reduce CPU cache misses, though I have no hard evidence of this.

Initially I modified all SGBinObject member functions to pass/return by reference instead of by-value.  This gives little or no speed up but allows for some optimizations in fgBinObjLoad().  It is these changes that reduce the number of memory allocations.  Needless copying of vectors, and vectors of vectors, can be very memory intensive, especially if they are large.

Anyway I would be interested to see if you get similar results.  I would emphasize that the frame rate increase only occurs with random objects disabled.  I lose about 10-15 fps on my GF2MX 32MB with random objects, probably a fill-rate limitation or texture memory thing.
2002-08-23 17:52:10 +00:00
david
2e7e9b73a0 Change from Norman Vine to add new random-number algorithm. 2002-08-05 18:43:28 +00:00
david
7a11523692 Random-number seed patch from Erik Hofman. 2002-07-31 17:14:29 +00:00
curt
f85a9866fe Remove efence support in favor of valgrind. 2002-07-30 14:10:08 +00:00
david
9b05c27938 Remove ECMAScript interpreter from the default build for now. It can
still be built from inside the directory.
2002-07-30 11:58:34 +00:00
david
fd96729362 Patch from Cameron Moore:
* Fixed (un)signed comparison
2002-07-18 20:30:18 +00:00
david
c57cc096f8 Patch from Cameron Moore:
* Rearranged member initializers to shut gcc -Wall up
2002-07-18 20:30:02 +00:00
david
c8efd0a465 Added JavaScript interpreter, repackaged by Tony Peden. It's not tied
into anything yet, but it builds OK inside SimGear.
2002-07-18 20:27:46 +00:00
david
db60139845 Downgrade cloud-base alert to a debug warning. 2002-07-18 20:23:30 +00:00
david
cadefd323a Quick fix for bug reported by Julian Foad, where the simplify flag was
not honoured after the first call.  This isn't all that efficient, and
the return type probably should change to string eventually, but this
fix avoids changing the headers for now.
2002-07-18 20:04:50 +00:00
david
baab88f42a Fix deletes in destructor. 2002-07-06 15:00:37 +00:00
david
767b74dd35 Added new getDisplayName method that gets the name with its index.
Suggested by Julian Foad.
2002-07-06 14:58:38 +00:00
david
90e8287f43 Made SGPropertyNode::getPath extremely efficient: it now caches its
result, so after the first call for any node, it simply tests and
returns a pointer.  This also fixes the problem of buffer conflicts
with make_string.

Added SGPropertyNode::hasChild(const char * name, int index = 0) to
provide a syntactically-cleaner way to test for the existence of a
child node, i.e.

  for (int i = 0; i < 9; i++) {
    if (node->hasChild("foo", i))
      foo[i] = node->getChild("foo", i)->getDoubleValue();
  }
2002-07-06 13:19:02 +00:00
david
d8b7e5b8fd Added simgear_config.h.in 2002-07-06 12:06:40 +00:00
curt
7769447283 Fixed a couple minor compiler warnings. 2002-07-03 17:35:49 +00:00
david
d6a790cf13 MSVC++ bug work-around from Frederic Bouvier. 2002-07-03 02:06:23 +00:00
curt
033c66363d Fixes for IA-64 with Intel compiler. 2002-07-02 18:44:20 +00:00
david
3ff1789963 Fixed an MSVC compilation problem reported by Frederic Bouvier. 2002-06-28 17:02:42 +00:00
david
9737c0c4dd Fixed bug reported by Julian Foad:
While investigating, I found that SGPropertyNode::getPath returns a
(char *) pointer to the character data of a string on its stack,
i.e. to undefined memory after it returns.  I remember someone was
changing strings to char* for efficiency.  Perhaps this bug was
introduced then.  I'll include a patch for it with my eventual patch
for the above, unless someone beats me to it.  I don't think it
affects any existing callers: they all want a string anyway.
2002-06-28 16:56:14 +00:00
david
b201383a80 Patch from Julian Foad:
Initialise a "possibly uninitialised" variable (which was already
functionally correct).

[Note from DPM: this patch will be blown away if we ever update to a
newer version of Expat.]
2002-06-28 15:55:11 +00:00
david
2253b82304 Patch from Julian Foad:
Remove a hack that originally worked around a buffer overflow
elsewhere in the file.  The buffer overflow was fixed long ago, but
the hack was not removed.
2002-06-28 15:54:34 +00:00
david
2581446d85 Patch from Julian Foad:
Remove trailing comma (unportable).
2002-06-28 15:54:15 +00:00
david
a6291b286c Patch from Julian Foad:
Remove unused static function (warning because it cannot possibly be used).
2002-06-28 15:53:58 +00:00
david
96a396bfcb Patch from Julian Foad:
This file should be removed from CVS because it is generated by
autogen.sh.
2002-06-28 15:53:31 +00:00
david
0833a11686 Significant improvements to the change-listener support. There are
now three different change events, and the listener base class removes
itself from the parent in the destructor.
2002-06-18 21:17:42 +00:00
david
9c7f7f3d32 Added a ptr() method to SGPropertyNode_ptr to get the raw pointer.
Added the SGPropertyChangeListener interface and addChangeListener and
firePropertyChange methods.
2002-06-18 01:26:09 +00:00
david
7847fe8074 Patch from Melchior Franz:
layer_span used uninitialized in SGCloudLayer::rebuild (line 162, 170, etc.)
2002-06-07 17:39:38 +00:00
david
c57d25ac51 Be more conservative and reuse SSG objects. 2002-06-05 19:12:50 +00:00
david
1341b5b9f8 Try to avoid some memory leaks. 2002-06-05 15:43:04 +00:00
curt
fb54e9e103 Include the autogen.sh script in the distribution. 2002-05-23 13:46:19 +00:00
david
3a835dde7d Skip drawing clear cloud layers. 2002-05-17 16:53:19 +00:00
curt
128a4a36ca Bernie Bright:
I've defined snprintf as _snprintf in compiler.h for MSVC and MINGW
targets and removed duplicate definitions from FG sources.
2002-05-17 14:38:03 +00:00
david
255bb6dd07 Preparation for making dynamic cloud layers -- moved cloud state out
of sky.[ch]xx and into cloud.[ch]xx, and added setters for modifying
the state of an existing layer.
2002-05-16 23:16:39 +00:00
curt
786b1e3a30 Removed SG_STATIC_CONST define. 2002-05-16 02:44:35 +00:00
curt
d5f38a558e Minor tweaks. 2002-05-16 02:30:06 +00:00
curt
ce5d4b7db8 Erik Hofman:
Some small patches to make the code Irix/Muli platform compatible and
one small fix to make it plib-1.4.2 compatible also.
2002-05-15 19:21:54 +00:00
curt
8c0b36fe9e Added SG_COMPILER macro. This is a string that identifies the build
compiler and version.  It might be useful to display it during program
startup.
2002-05-14 18:59:03 +00:00
david
c7e6459c64 Modified to work with the new SGPropertyNode_ptr class. 2002-05-10 22:58:03 +00:00
david
86e31e696d Patch from Frederic Bouvier:
I have modified the SGPropertyNode interface to support node removal
and address the issues you mention yesterday.

I added the SGPropertyNode_ptr class that is a smart pointer that
increment and decrement a counter in SGPropertyNode. The _children
vector is changed to a vector<SGPropertyNode_ptr> in order for the
node to hold a reference to its children. I also added a
_removedChildren vector of the same type. When removeChild is called
with the keep parameter set to true, the reference is removed from
_children and inserted in _removedChildren, and the attribute REMOVED
is set. When getChild is called with create set to true, the _children
vector is searched, then the _removedChildren and then a new node is
created. If a resurrected node is returned, the REMOVED bit is cleared.
The static const int LAST_USED_ATTRIBUTE is also added.

The footprint of this patch is light. SGPropertyNode is one int
longer in size, SGPropertyNode_ptr is one pointer large without
virtual functions. Some functions can be inlined if your current
policy change.

The FlightGear patch is to take account the change in the getChildren
function that now returns a vector<SGPropertyNode_ptr>. If the
removeChild functionnality is to be added in FlightGear, all those
SGPropertyNode * floating around should be changed to
SGPropertyNode_ptr.
2002-05-10 22:57:36 +00:00
david
be0b1bb994 Mac OS X fixes from Jonathan Polley. 2002-05-10 21:33:12 +00:00
david
03e74bfeb4 Ignore binaries. 2002-05-10 21:31:55 +00:00
david
972223cd50 Eliminate an unsigned-int comparison warning. 2002-05-10 21:31:15 +00:00
curt
761b7b9354 Bernie Bright:
Here's a first cut at SGSocket reimplemented using plib.net.  I've
maintained the same TCP server behaviour, that is only one client
connection at a time.  I don't think it is possible within the current
framework to handle simultaneous clients.

I've also added two simple test programs, tcp_client and tcp_server.
2002-05-10 13:53:22 +00:00
curt
6a3d1895d9 Bernie Bright:
Here is a total rewrite of the strutils package.  I've reimplemented the
trimleft(), trimright() and trim() functions as lstrip(), rstrip() and
strip() respectively.  Additionally I've added a split() function that
behaves like its perl/python equivalent.  Just the thing for splitting
comma separated option strings or space separated telnet commands and
arguments.  I've also enclosed the whole thing in a namespace
simgear::strutils.  Since I seem to be the only one who uses these
functions, SimGear and FlightGear compile without change.

PS It is no coincidence that the new function names bear an uncanny
resemblance to the python functions of the same name.
2002-05-10 13:32:44 +00:00
curt
d1178a26ce Updated MSVC project files. 2002-05-10 13:31:44 +00:00
curt
8ffdfa3cb1 Make the skydome interface a little more flexible so we can scale the dome
for other applications.
2002-04-27 03:19:45 +00:00
david
384e56b9b4 Patches from Erik Hoffman:
Tbis is a first patch in a series to clean up SimGear by removing
warning messages. Most of them are straight forwared, but in pops.hxx
the compile complaints about "type qualifier is meaningless on return
type". I think it's up to you to decide if you want that part applied.
2002-04-25 15:09:10 +00:00
david
d198e962b0 Patch from Melchior Franz:
From the cosmetics department ...
2002-04-25 14:56:03 +00:00
david
0136fdadbb Patch from Melchior Franz:
magvar and magdip are used before their initialization
2002-04-25 14:55:40 +00:00
curt
c616568830 Make sure README.MSVC goes in the distribution. 2002-04-23 01:56:51 +00:00
curt
995d2c1ede Make sure zlib.dsp goes in the distribution. 2002-04-23 01:55:48 +00:00
curt
051a5e9a38 Updated am2dsp.cfg file for creating MSVC project files.
New README.MSVC.
New src-libs/zlib.dsp for building zlib.
2002-04-22 20:37:31 +00:00
curt
60d89097de Bump up version number, remove boost from src-libs/Makefile.am 2002-04-20 22:03:35 +00:00
curt
6c35255549 Updated for 0.0.18. 2002-04-20 21:06:05 +00:00
curt
c985d8846d tweak. 2002-04-20 20:53:54 +00:00
curt
9a8ab26381 Removed boost dependency. Maybe we'll try again later. 2002-04-12 01:35:09 +00:00
david
711622fd5b Patch from Frederic Bouvier:
A const char * is not supposed to change and cannot be deleted. So
here is a patch that remove unnecessary const from props.hxx and
props.cxx. There also is the addition of a friend directive because
nested classes do not receive special privileges and cannot access
private members of the outer class.
2002-04-07 21:28:43 +00:00
david
96474823b5 Implemented a very simple hash-table cache for property lookup using
relative paths.
2002-04-06 21:47:22 +00:00
curt
bbf4b54613 Initial revision. 2002-04-03 21:22:52 +00:00
curt
9795c5dd6b Added src-libs subdirectory for keeping source code to extra libs. These
are things that are needed, but that many systems already have packages
available to install, and many users may have versions of these already
installed to support other projects.  So rather than build and install by
default with the main SimGear build/install, these are kept separate so that
those users that don't have them already installed can build and install
them separately.
2002-04-03 21:21:29 +00:00
curt
addcace80d Added a very crude/simple initial README.Install. 2002-04-03 21:18:13 +00:00
curt
77e43a5fa8 - Added src-libs/boost.tar.gz and README.boost. This is in anticipation
of actually using them in the flightgear event manager.
- Now that we have several add on libs we are bundling with simgear (but
  not automatically built as part of the simgear build) I have moved them
  to their own subdirectory (src-libs).
2002-04-03 21:05:51 +00:00
curt
b751188e56 string == "" -> string.empty() conversion. 2002-04-03 02:34:20 +00:00
curt
1ad9a15864 Updated to the latest metakit release. This fixes a few bugs that could
possibly affect some users.  For details, see the metakit changelog at
the metakit home page: ttp://www.equi4.com/metakit/
2002-03-28 02:21:00 +00:00
david
d0d7878e0a Patch from Melchior Franz:
This module works mostly with char* and allocates memory with
strdup ... delete doesn't go well with malloc(). The transition
to string only would be nice, but some class interfaces return
char*, so it was more natural to just drop the deletes.
2002-03-27 11:42:09 +00:00
david
be5d365348 Patch from Melchior Franz:
Here is a patch that fixes a little problem in dome.cxx: The fog_color
is created in a sgVec3 (227) but then handed over to ::repaint(), which
expects a sgVec4 (282). Then (343) center_color (although defined as
sgVec4) is only initialized with 3 values, but later (441) assigned to
'slot' via sgCopyVec4.
2002-03-25 19:56:48 +00:00
david
a8e0002a64 Patch from Melchior Franz:
at several places material was copied to "buffer" using strncpy
without adding a closing '\0'. This again lead to access to non
initialized memory and potentially (and actually at least in one
case) to feeding garbage to atof(). In case the following garbage
happened to start with digits, we would get funny time
values.  :-)
   I just added the obligatory "buffer[n] = 0", which doesn't
really look professional now. Maybe we should use the string
class or define a helper function that strncopies =and= adds
a trailing zero?
   The last hunk fixes another buglet, that wasn't dangerous
at all, but caused an error message. The loop that should cut
the string at hash marks ('#') did neither stop at such, nor at
string ends. It always scanned the whole 256 character long
buffer and accessed uninitialized memory. valgrind doesn't
like that. I dropped the 256 counter, because fgets =does=
add the closing zero. It is safe to scan until we either
get the zero or the hash mark.
2002-03-25 19:50:32 +00:00
david
bf75cf7225 Removed an unnecessary string allocation during copying. 2002-03-22 15:02:50 +00:00
david
c024b680bc Removed commented-out dead code. 2002-03-22 13:18:49 +00:00
david
c896475765 More rearrangement of headers. Replaced delete with delete[] where
appropriate.
2002-03-22 12:45:11 +00:00
david
101fdb3598 Moved up #include <algorithm> 2002-03-22 12:38:34 +00:00
david
b13505afdf Fix segfault when deleting a node with a string value. 2002-03-21 15:19:26 +00:00
david
9d96b171a0 Patch from Frederic Bouvier:
deletion of a const char * is not allowed with MSVC 6. I had to cast to char
*
to avoid compile errors.
2002-03-20 21:44:38 +00:00
david
8b5a0cde69 Patch from Tony Peden to remove unused variable and eliminate compiler
warning.
2002-03-20 21:31:53 +00:00
david
bed7593cdd Moved includes higher to make sure that std::sort is known. 2002-03-20 13:43:23 +00:00
david
9fed946567 Include <algorithm> and <stdio.hxx> to fix compilation errors on some
platforms (I should have done this anyway).
2002-03-19 18:17:36 +00:00
david
4d0bc0ae39 Major property-manager rewrite, using const char * throughout
interface instead of string.  This will result in a lot more
efficiency later, once I add in a simple hash table for caching
lookups, since it will avoid creating a lot of temporary string
objects.  The major considerations for users will be that they cannot
use

  node->getName() == "foo";

any more, and will have to use c_str() when setting a string value
from a C++ string.
2002-03-19 16:07:47 +00:00
david
f9824aa7de Removed SGRawValueInternal class (it's now handled directly by
SGPropertyNode) and updated some out-of-date documentation comments.
2002-03-18 14:55:59 +00:00
david
4d2522964a Some code fixes to keep untying clean with new optimizations. 2002-03-18 14:55:15 +00:00
david
dbe4a59b8e Code cleanup and minor speed improvements. For the record, accessing
an internally-managed property is nearly twice as fast as accessing
one tied to methods.
2002-03-18 03:21:18 +00:00
david
918f8a3ed4 Patches from Tony Peden to separate property XML I/O operations into a
separate header file.  This change will help integrate properties into
JSBSim.
2002-03-15 23:16:46 +00:00
curt
f645596606 Fixed an 'elstupido' bug.
Cleaned out some old #ifdef'd out code.
2002-03-13 05:01:51 +00:00
curt
d778dd081d Added some increased functionality in support of the binary file format
additions.
2002-03-13 05:00:55 +00:00
curt
f6ed02c3fb zlib-1.1.3 had a potential security flaw which is fixed by zlib-1.1.4:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Zlib Advisory 2002-03-11
zlib Compression Library Corrupts malloc Data Structures via Double Free

   Original release date: March 11, 2002
   Last revised: March 11, 2002
   Source: This advisory is based on a CERT advisory written
           by Jeffrey P. Lanza  http://www.kb.cert.org/vuls/id/368819

Systems Affected

     * Any software that is linked against zlib 1.1.3 or earlier
     * Any data compression library derived from zlib 1.1.3 or earlier

Overview

   There is a vulnerability in the zlib shared library that may introduce
   vulnerabilities   into   any   program   that   includes   zlib.  This
   vulnerability has been assigned a CVE name of CAN-2002-0059
   http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0059

I. Description

   There  is  a  vulnerability in the decompression algorithm used by the
   popular  zlib  compression  library.  If an attacker is able to pass a
   specially-crafted  block of invalid compressed data to a program  that
   includes zlib,  the program's  attempt to decompress  the crafted data
   can cause the  zlib  routines to corrupt the internal data  structures
   maintained by malloc.

   The  vulnerability  results  from  a  programming  error  that  causes
   segments of dynamically allocated memory to be released more than once
   (aka.   "double-freed").  Specifically,  when  inftrees.c:huft_build()
   encounters  the  crafted data, it returns an unexpected Z_MEM_ERROR to
   inftrees.c:inflate_trees_dynamic().  When a subsequent call is made to
   infblock.c:inflate_blocks(), the inflate_blocks function tries to free
   an internal data structure a second time.

   Because  this  vulnerability interferes with the proper allocation and
   de-allocation of dynamic memory, it may be possible for an attacker to
   influence  the  operation  of  programs  that  include  zlib.  In most
   circumstances,  this influence will be limited to denial of service or
   information  leakage, but it is theoretically possible for an attacker
   to  insert  arbitrary  code into a running program. This code would be
   executed with the permissions of the vulnerable program.

II. Impact

   This vulnerability may introduce vulnerabilities into any program that
   includes  the  affected library. Depending upon how and where the zlib
   routines   are   called   from   the   given  program,  the  resulting
   vulnerability may have one or more of the following impacts: denial of
   service, information leakage, or execution of arbitrary code.

III. Solution

Upgrade your version of zlib

   The  maintainers  of  zlib have released version 1.1.4 to address this
   vulnerability.  Any software that is linked against or derived from an
   earlier  version  of  zlib  should be upgraded immediately. The latest
   version of zlib is available at http://www.zlib.org

   The md5 sums of the source archives are:
       abc405d0bdd3ee22782d7aa20e440f08  zlib-1.1.4.tar.gz
       ea16358be41384870acbdc372f9db152  zlib-1.1.4.tar.bz2

IV. Acknowledgments

Thanks to Owen Taylor and Mark Cox of Redhat, Inc. for the
reporting and research of this vulnerability.


This document is available from
http://www.gzip.org/zlib/advisory-2002-03-11.txt

The public PGP key of zlib author Jean-loup Gailly is available from
http://www.gzip.org/zlib/jloup.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8jSR02aJ9JQGWcacRAuDEAKCWdrRkWeJV9lYU5z8NN56s3m8eKACglR4m
42KDUGHuftBkwACTMCnZLEo=
=3yLS
-----END PGP SIGNATURE-----
2002-03-11 23:03:19 +00:00
curt
7fa5dd7a35 Added a warning message if the file is not found. 2002-03-11 21:47:09 +00:00
curt
a3186af099 Additions to the binary file format to make it *much* more flexible.
For each major primative type: points, triangles, fans, and strips, you
can specify an index list of vertices, normals, colors, and texture
coordinates.  You can skip any of these you like to save on space.

Note that the work for this has only been done in the file format reader
and writer.  The FlightGear loader for instance still needs to have
support for this built in.

This is is one more small step towards runway lighting.
2002-03-10 22:49:01 +00:00
david
a2d95ac742 Patch from Martin Dressler to ensure that values as well as children
get written with write-all.
2002-03-09 11:14:29 +00:00
david
10715bbea7 Modified to add an optional parameter to writeProperties to allow
*all* properties to be written, rather than just the ones flagged as
archivable.  Tony Peden requested this feature to make it easier for
people to document properties.
2002-03-03 21:22:24 +00:00
david
89fcb12556 Cleanups from Petru Paler:
It's basically a couple unused variables, an explicit cast, some unused
functions removed or commented out, and a whole bunch of pragmas
removed.
2002-03-02 23:37:04 +00:00
david
cc3d7ddee5 Minor changes to path caching. 2002-02-28 14:37:00 +00:00
curt
cc01f99acb Added support for points objects. 2002-02-27 23:08:45 +00:00
curt
62b75190bb Might as well bump up the version number. 2002-02-26 23:55:54 +00:00
curt
520124c1be Add initial support for per vertex or per object colors. 2002-02-26 20:05:20 +00:00
curt
e251bfcbaf Extended .btg format to support a 'points' primitive. 2002-02-26 19:47:06 +00:00
david
aef809348f IMPORTANT: backwards-incompatible change to properties.
The useDefault argument for the SGPropertyNode::tie(...) methods will
invoke the setter only when there is already a property value defined;
previously, the setter was always invoked, with a default value if
necessary.
2002-02-19 15:20:02 +00:00
curt
2d4a8774b8 Updated version number. 2002-02-15 17:27:50 +00:00
curt
b55c8fd828 Removed duplicate message. 2002-02-15 17:22:53 +00:00
curt
dfff091b5f Updated ... 2002-02-15 17:13:12 +00:00
curt
47eb7efafa Added README's to distribution. 2002-02-14 21:35:32 +00:00
curt
b2a7fff26e Explicitely reset the glBlendFunc() after drawing the moon for the Voodoo2
linux driver since it seems to have a bug in glPopAttrib().
2002-02-14 14:21:48 +00:00
curt
5f70123723 0.7.9pre2 changes. 2002-02-13 15:10:06 +00:00
david
dd629da8d3 Replaced some cout's with SG_LOG (fixes namespace problem with
ANSI-conformant compilers).
2002-02-13 12:14:01 +00:00
curt
74f7d52d95 Fixed a problem that could lead to a 'near infinite' loop if bogus input
values are provided.
2002-02-12 15:21:14 +00:00
curt
7a65a990ba Decouple sg_time code from the current time(NULL), i.e. you can run the
time calculations for an alternate calendar time (i.e. if the application
is being driven from an external source of data.)

Fix a bug in sg_binobj.cxx which disrupted the 'broken down time' globally
for the entire application.
2002-02-11 22:27:27 +00:00
curt
fe0076e291 Updated with 0.0.17 changes. 2002-02-10 04:10:00 +00:00
curt
1a8bc06cc6 FreeBSD fix: strnstr() is already defined. 2002-02-10 03:28:57 +00:00
curt
8c41081a5c This code had been written to assume current clock time. Added options
to allow specifying an alternate clock time.
2002-02-10 03:16:03 +00:00
curt
5b40eed554 Fixes a config problem that could lead to a bogus build for people with
voodoo cards.
2002-02-07 22:37:09 +00:00
curt
b1c4d34eef Fix for FreeBSD. 2002-02-06 01:04:38 +00:00
curt
0152b607f8 Tweaks ... 2002-02-05 21:36:09 +00:00
curt
ab6e72047b oops, minor tweaks. 2002-02-04 22:48:30 +00:00
curt
15399bfe95 Various mingwin patches contributed by Norman Vine. 2002-02-04 22:38:23 +00:00
curt
0ff748987b Pass strings by const reference instead of by value,
Made fix_path() a private member function, SGPath::fix(),
Added bool SGPath::exists(),
Added an assignment operator that acts like SGPath::append().
2002-02-04 20:23:41 +00:00
curt
58e0e7736b Removed some depricated irix support that is now handled elsewhere. 2002-02-01 20:18:47 +00:00
david
2d1b2ca938 Minor fixes from Cameron Moore. 2002-01-30 15:09:56 +00:00
curt
9a4152eb2d Fixes to make telnet interface work more than 1x. 2002-01-28 21:48:00 +00:00
curt
6ab443545f Further autogen.sh fixes to handle more cases. 2002-01-19 13:45:06 +00:00
curt
98a9b4a10c Minor clean ups. 2002-01-19 13:37:22 +00:00
david
a6251606dd Added some new functionality to the property manager:
1. Nodes cache previous relative paths so that they do not have to
parse the paths each time.

2. There are new getNode() methods that include indices, so that users
do not have to sprintf to a buffer to iterate through indexed nodes.
2002-01-19 03:06:22 +00:00
curt
c3b21e143c Fixed typos ... 2002-01-17 16:58:18 +00:00
curt
b496593883 Updated to automatically handle newer versions of automake.
Does some IRIX specific fixups.
2002-01-17 15:21:49 +00:00
curt
4ef4b019ca Added conditional support for Norman's jpegfactory code (requires libjpeg
to be already installed.)
2002-01-16 21:13:27 +00:00
curt
a8021531ab Initial revision of jpegfactory code for generating jpeg format screen dumps. 2002-01-16 21:11:00 +00:00
david
93fd948978 Added aclocal.m4 2002-01-16 00:04:16 +00:00
curt
a1b3740dc6 A few changes from Norman Vine to support mingwin. 2002-01-15 22:28:21 +00:00
curt
40920457cb Initial revision. 2001-12-29 03:35:31 +00:00
curt
5039c84fd0 Removed metakit and zlib from the configure/build process. The
developer will need to build and install these separately if they
don't have packages already installed by their system.  See
README.metakit and README.zlib for more details.

As a convenience, pristine tarballs of the metakit and zlib source
code trees are included with the simgear distribution (and cvs.)
2001-12-29 00:38:04 +00:00
curt
220a43bf46 Removed metakit and zlib from the configure/build process. The
developer will need to build and install these separately if they don't
have packages already installed by their system.  See README.metakit and
README.zlib for more details.

As a convenience, pristine tarballs of the metakit and zlib source code
trees are included with the simgear distribution (and cvs.)
2001-12-29 00:35:34 +00:00
curt
45d3e19c38 Small tweaks to class initialization. 2001-12-28 23:37:34 +00:00
curt
5bab565cfe Updates to build system to better support automake-1.5
- automake-1.4 sets default values for INCLUDES which we can't
  overwrite.
- automake-1.5 renames this to DEFAULT_INCLUDES and leaves INCLUDES
  open for the developer to use.

Thus for automake-1.4 we are forced to 'append' to INCLUDES and in
automake-1.5 we can just set the value to whatever we like.
Unfortunately, the behaviors of the two versions are mutually
incompatible.

The solution I am committing now works for both versions but
automake-1.5 generates a lot of spurious warning messages that are
annoying, but not fatal.
2001-12-28 21:27:19 +00:00
curt
319a4282c8 Test commit. 2001-12-17 16:52:20 +00:00
david
c6aa8bc8e9 Fixed Makefile.am to install easyxml.hxx in the simgear/xml rather
than simgear/.
2001-12-16 20:59:16 +00:00
david
6f1bfa202e -Added .cvsignore files to clean up CVS messages 2001-12-12 02:44:37 +00:00
david
6fa9f86d1c Added trace attributes to properties:
TRACE_READ - log a message whenever the property is read.

TRACE_WRITE - log a message whenever the property is written.

The second one works only when the property value is changed through
the property manager; tied variables and accessors are not polled for
value changes because of the performance hit.

These methods end up invoking private methods
SGPropertyNode::trace_read and SGPropertyNode::trace_write.  By
setting breakpoints on these methods inside a debugger, it is possible
to debug property access and find what parts of a program are reading
or writing specific property values by doing a backtrace.

In the XML property files, users can use the attributes 'trace-read'
and 'trace-write' to control tracing; the value should be 'y' to
enable tracing or 'n' to disable it (the default).
2001-12-12 02:28:28 +00:00
david
019a9527d2 Added Curt to empty Authors file as CVS test. 2001-12-11 22:23:25 +00:00
curt
d100ca485f Doh! fixed a typo ... 2001-12-10 00:24:51 +00:00
curt
35ab6900ee [Hopefully] fix a line ending problem that surfaces in MSVC. 2001-12-09 03:54:46 +00:00
curt
c8570302f5 Removed this autogenerated file from CVS. 2001-12-06 22:53:29 +00:00
curt
74f10486bc In certain degenerate situations on the FlightGear side when the flight
model math blows up, the lat/lon could be nan.  Thus updateLocal() could
potentially called with nan arguments if FlightGear is reiniting from a
blown up state.  This is a bug in FlightGear, but I've added a simple
check to catch this so updateLocal() is robust if called under these
circumstances.
2001-12-05 22:31:03 +00:00
curt
2b12425a62 Christian M. says it's bad to chain one constructor call from another.
I can't find anything that addresses this in Stroustrup, but I also don't
see them doing this in any of their examples.  So I have rewritten this
instance to use default arguments to accomplish the same thing.  I imagine
there are other instances of this same sort of thing in other classes to
be fixed at a later date.
2001-11-27 03:17:43 +00:00
curt
c600aad7a7 Bernie Bright: support for Intel C++ under Linux. 2001-11-21 21:31:40 +00:00
curt
67b2f0a977 - changed getAttribute to avoid MSVC compiler warning 2001-11-20 20:57:07 +00:00
curt
70c6b48a07 - implemented set/get_log_classes and set/get_log_priority 2001-11-20 20:56:53 +00:00
curt
76084f8538 Oops, typo ... 2001-11-12 18:20:32 +00:00
curt
64c408d2b7 Updated RPM make rule as per Ross Golder. 2001-11-12 17:37:24 +00:00
curt
73b050ae34 Mixed a makefile typo. 2001-11-12 15:27:32 +00:00
curt
59991393ca plib/net based udp client/server sockets. 2001-11-12 04:47:58 +00:00
curt
69b2717b62 One more tiny Irix tweak. 2001-10-24 20:01:15 +00:00
curt
f2a323e048 Misc Irix tweaks. 2001-10-24 19:59:05 +00:00
curt
7d07e6ea51 Misc MSVC tweaks. 2001-10-24 19:05:16 +00:00
curt
7c846972bf Macintosh OSX changes. 2001-10-23 20:22:12 +00:00
curt
4f76c258af MSVC tweaks. 2001-08-13 17:14:21 +00:00
curt
eca2afb982 Various changes for MingWin32 support. 2001-08-02 22:56:33 +00:00
curt
9ff6934c83 Various MSVC fixes. 2001-07-30 20:34:20 +00:00
curt
e04839765d Updates for irix to disable various warnings and define
__STL_FUNCTION_TMPL_PARTIAL_ORDER
2001-07-30 20:05:27 +00:00
curt
d0c655109f Oops, missing a trainling backslash after exception.hxx 2001-07-28 04:00:10 +00:00
curt
b28b55abb1 - removed declaration of sg_xml_exception (use sg_io_exception) 2001-07-24 21:41:33 +00:00
curt
c3a0db1aba - make sure file is closed when an exception passes through 2001-07-24 21:41:19 +00:00
curt
5e929d7d01 - remove dependencies on sg_throwable::clone 2001-07-24 21:41:06 +00:00
curt
17f113f8cd - remove clone methods for exceptions (SGI/Irix compiler bugs)
- added declaration for sg_throwable::getFormattedMessage
- added declaration for sg_io_exception::getFormattedMessage
- added #ifdef wrapper
2001-07-24 21:40:57 +00:00
curt
445cd4ccda - remove clone method declarations (SGI/Irix compiler bugs)
- added default implementation for sg_throwable::getFormattedMessage
  (returns sg_throwable::getMessage by default)
- removed unneeded newline in sg_location::asString
2001-07-24 21:40:46 +00:00
curt
55845bbbb9 Added exceptions.[ch]xx 2001-07-19 02:34:43 +00:00
curt
1976481ba2 - added sg_xml_exception class
- changed return type of readXML from bool to void (uses an exception
  to report problems now)
- removed XMLVisitor::error callback
- declared new readXML function that uses a path rather than a stream
- modified existing readXML function to take an optional path parameter
2001-07-19 02:34:18 +00:00
curt
5f17edbc72 - implemented sg_xml_exception class
- implemented new readXML function with path instead of stream
- modified existing readXML function to use optional path parameter
- modified readXML to throw exceptions rather than returning a bool
  value on error
2001-07-19 02:33:58 +00:00
curt
6f7fe4b481 - modified both readProperties functions to return void, and modified
file-name variant to invoke new readXML function
- readProperties and writeProperties will now throw exceptions if there
  are file I/O problems
- replace error messages with exceptions
- tunnel sg_io_exception through from nested property read, since
  the C-based Expat code cannot handle exceptions
2001-07-19 02:33:38 +00:00
curt
66ebe6e690 - changed return type of both readProperties functions to void
- changed return type of both writeProperties functions to void
2001-07-19 02:33:18 +00:00
curt
a9cd67e0ce - new file: implementation of SimGear general exception classes 2001-07-19 02:33:00 +00:00
curt
994a470fbf Prepairing for 0.0.17 2001-07-13 14:58:14 +00:00
curt
0ce0684dae Added a missing include for memcpy() 2001-07-13 03:36:50 +00:00
curt
377eb4782a Updated for 0.0.16 2001-07-13 03:36:29 +00:00
curt
f1a79e6b9f - changed default value of "archive" attribute from "y" to "n"
- modified to write out non-archivable parents if they have an
  archivable descendant (i.e. archive="n" no longer kills a whole
  subbranch); this makes sense now that archive defaults to "n".
- don't save the flags -- let the program handle them itself
- produce slightly less verbose output; omit n="0" in elements
2001-07-12 21:09:12 +00:00
curt
007a1e4659 - changed the default value of the archive flag to false; it must now
be set explicitly for a value to be saved
2001-07-12 21:08:58 +00:00
curt
fcb873b6dd - added virtual destructor to XMLVisitor to make sure derived classes
get a virtual destructor automatically.
2001-07-11 16:02:26 +00:00
curt
a66d1ad855 Check for valid hostname lookup in sg_socket.cxx. 2001-07-10 14:13:51 +00:00
curt
76a5950f19 Add a separate function to just return modified julian date. 2001-07-03 14:39:05 +00:00
curt
b7a91bdb03 Various tweaks for Irix. 2001-07-02 20:51:32 +00:00
curt
e4bbc5c50b Fix a potential array under/over run bug. 2001-06-30 02:01:22 +00:00
curt
b481ccd749 Tweaks to track changes in property manager. 2001-06-28 21:54:02 +00:00
curt
e7b9e55599 - removed all reference to SGValue
- renamed UNKNOWN to UNSPECIED and setUnknownValue to
  setUnspecifiedValue
- modified routines to use 'read', 'write', and 'archive' attribute
  for access-mode attributes (only if non-default; they all default to
  'y')
- modified write routine to honour ARCHIVE attribute (won't write
  subtree if ARCHIVE is not set)
2001-06-28 21:53:46 +00:00
curt
05eaa7135f - made getValue methods protected, so that they won't be invoked outside
the class
- renamed UNKNOWN to UNSPECIED and setUnknownValue to
  setUnspecifiedValue
- added access-mode attributes
- added methods for setting and querying access-mode attributes
2001-06-28 21:53:34 +00:00
curt
d063b319e8 - attempting to tie an aliased node now fails; the node must be
unaliased first
- renamed UNKNOWN to UNSPECIED and setUnknownValue to
  setUnspecifiedValue
- modified get*Value and set*Value methods to respect READ and WRITE
  attributes
2001-06-28 21:53:24 +00:00
curt
be4fd56660 - added SGCommandState class so that commands can compile and save
copies of their arguments
- modified prototype for command functions -- they now take a pointer
  to a pointer of an SGCommandState object (which they will normally
  subclass) so that they can cache state between invocations
- commented out convenience execute methods until they're actually
  needed
2001-06-28 21:53:10 +00:00
curt
a406a3c00b - added implementation of SGCommandState
- removed commented-out convenience execute methods
2001-06-28 21:53:01 +00:00
curt
c7295da5eb Fixed a type conversion bug that could trip up some of the pickier compilers
out there.
2001-06-27 02:48:01 +00:00
curt
505f561e1c Added tr.cxx / tr.h, Brian Paul's LGPL'd tiled rendering support libs for
rendering ultra high res "tiled" screen shots.
2001-06-26 15:19:39 +00:00
curt
7bd8477fa1 Tweaks. 2001-06-20 18:35:42 +00:00
curt
36ef15940e Changes for 0.7.8 2001-06-20 18:12:18 +00:00
curt
f2ba7aefa6 Need to include <simgear_config.h> to pick up the WIN32 definition. 2001-06-19 14:24:16 +00:00
curt
73b58b0e87 Updated for the 0.0.15 release. 2001-06-19 00:50:33 +00:00
curt
6ce4f096b2 #endif // __COMMANDS_HXX 2001-06-13 18:59:07 +00:00
curt
3e7ece7f5f #include <simgear/compiler.h> and adjust to fit the standard coding conventions
of this project.
2001-06-13 18:10:16 +00:00
curt
48a219473e Norman Vine optimizations. 2001-06-12 21:44:03 +00:00
curt
887ffd102f David patches. 2001-06-12 02:52:07 +00:00
curt
b1a719dd4c - added SGPropertyNode::Type
- changed return type of SGPropertyNode::getType methods from
  SGValue::Type to SGPropertyNode::Type
- made SGPropertyNode::getValue and SGPropertyNode::hasValue private
  so that applications cannot get at SGValue instances (SGValue is
  slated for removal)
2001-06-12 02:49:32 +00:00
curt
b4efe8f374 - added missing return statement for getAliasTarget
- changed SGValue::Type to SGPropertyNode::Type for all of
  SGPropertyNode
2001-06-12 02:48:24 +00:00
curt
03f844d4be - added missing return statements for execute methods 2001-06-12 02:44:40 +00:00
curt
a212589865 Fixed a problem that could cause a divide by zero error during initialization.
Contributed by Durk Talsma.
2001-06-10 15:12:09 +00:00
curt
29dfc5bd3c Resolve a #define clash with the template argument LOCK. 2001-06-06 23:12:03 +00:00
curt
a6ac06c47a Display a warning message for Irix users. 2001-06-06 21:27:38 +00:00
curt
4d914db1db - fixed XML syntax error with missing '"' for some attribute values
that was preventing fgfs save/restore from working
- ensured that aliases always appear standalone
2001-06-06 14:57:58 +00:00
curt
68572f106d Added support for #include STL_ITERATOR 2001-06-05 17:47:02 +00:00
curt
c5ca4db94e Fixed a bug in star repainting optimization. 2001-06-02 04:21:04 +00:00
curt
3980f08cc5 Initial revsion of new command manager (contributed by David Megginson)
Fix to configure.in.
2001-06-01 15:28:49 +00:00
curt
f93fa4b613 Detect Irix/CC compiler and substitute AR="CC -ar". 2001-06-01 15:13:04 +00:00
curt
06f2dba92c Norman Vine contributed an optimization to eliminate unnecessary color
recalculations.
2001-05-29 13:45:06 +00:00
curt
30a14741c9 gcc-3.0.x fixes. 2001-05-23 19:25:27 +00:00
curt
2f39b688f4 Added #include <config.h> 2001-05-18 19:06:26 +00:00
curt
724a2ef83b MSVC changes contributed by Geoff McLane. 2001-05-17 19:54:18 +00:00
curt
f7e0e46143 Tweak link libs for decode_binobj. 2001-05-17 16:19:29 +00:00
curt
83acb47295 renamed config.h to simgear_config.h 2001-05-16 00:19:24 +00:00
curt
e5282caea5 MSVC++ tweaks. 2001-05-15 22:17:58 +00:00
curt
6a481eed36 We have to add a few more libs to a couple link lines in order to make
irix happy because it tries to resolve dependencies even if they are
eventually never used.
2001-05-15 21:31:35 +00:00
curt
e145f903de STL-ified the interpolation table so it is not size limited. 2001-05-15 21:07:41 +00:00
curt
2afd1c8663 Updates ... 2001-05-15 20:34:20 +00:00
curt
948d02055d Tweaks. 2001-05-15 20:26:47 +00:00
curt
e2b4c0787a Attempt to resolve ambiguity between #include <config.h> for simgear vs.
flightgear, especially when this occurs in a simgear .hxx file.  This is
now expressly forbidden, and will cause problems anyways because we now
changed the name to <simgear_config.h> which isn't installed, so you can't
include it in an installed header file.
2001-05-15 19:26:22 +00:00
curt
2d21e59b54 MSVC++ doesn't have long long, but does have __int64. 2001-05-15 15:52:10 +00:00
curt
00ccafb90d Update build order to work around dependencies. 2001-05-04 02:10:46 +00:00
curt
b82e02b5ed Tweaks. 2001-05-03 01:58:50 +00:00
curt
096550f163 Initial revision. 2001-05-03 01:58:12 +00:00
curt
81e5963a5d Timezone fixes for cygwin. 2001-04-26 16:15:01 +00:00
curt
14569e4fae Tweaked efence configure. 2001-04-24 21:34:07 +00:00
curt
6cc32a56b9 Added some convenience functions to point3d. 2001-04-24 20:01:52 +00:00
curt
ebdb86c460 Screen shot tweaks from Cameron Moore. 2001-04-22 20:02:49 +00:00
curt
400c9d6a2d Fix various compiler warnings contributed by Norman Princeton. 2001-04-22 14:57:08 +00:00
curt
e9a1b06746 Updated for cygwin build note. 2001-04-18 11:59:47 +00:00
curt
4f3aaa1ede iAdded new classes to simgear/threads. SGGuard is a wrapper around a
mutex that unlocks the mutex when the SGGuard object goes out of scope.
The SGxxxQueue<T> template family factor out the common behaviour we
need for passing data between threads.
2001-04-16 17:26:13 +00:00
curt
187258cc3a -a needed instead of -o 2001-04-13 13:45:15 +00:00
curt
dfbcb1566b Irix tweaks. 2001-04-11 21:14:24 +00:00
curt
e3b0a70eb9 Fixed a typo. 2001-04-11 18:03:30 +00:00
curt
790a40ec99 Tweak... 2001-04-09 18:02:22 +00:00
curt
a824bec9e1 Configure check for pthreads. 2001-04-09 17:58:20 +00:00
curt
10db0c3c66 Swab after sgReadBytes() if necessary. 2001-04-07 23:07:44 +00:00
curt
12620b6152 Tweaks to endianess support. 2001-04-06 21:26:34 +00:00
curt
2294283506 Tweaks to lowlevel.[ch]xx from Norman. 2001-04-06 18:08:07 +00:00
curt
cebcf6a4fc Expanded doxygen comments and added the SGThread::set_cancel() function. 2001-04-06 14:30:42 +00:00
curt
a79a78b6e6 Ooops, commit Makefile.am not .in. 2001-04-05 23:01:04 +00:00
curt
c6ad744ce2 Added support for byte swapping based on endianess. Note the assumption is
that files are stored in little endian order so if reads or writes are done
from a big endian machine, the contents must be byte swapped.
2001-04-05 21:51:32 +00:00
curt
b430b3c8df Added simgear/threads contributed by Bernie Bright. 2001-04-05 15:58:41 +00:00
curt
0b316a8c5e Initial revision. 2001-04-05 15:58:22 +00:00
curt
b8e93e6099 Fixes for native Irix compilers. 2001-04-02 00:23:46 +00:00
curt
a84a88bf09 - started adding doc comments to simgear/misc/props.hxx
- fixed some minor bugs in simgear/misc/props-io.cxx relating to the
new LONG type
2001-03-29 01:35:00 +00:00
curt
02d54dd187 Doxygen. 2001-03-26 19:04:52 +00:00
curt
fb054c7f8d Doxygen ... 2001-03-26 02:41:40 +00:00
curt
77da29b4f7 Doxygen ... 2001-03-25 21:39:03 +00:00
curt
828a9a8c51 Doxygen ... 2001-03-25 13:27:50 +00:00
curt
c680947db5 Doxygen. 2001-03-25 13:16:05 +00:00
curt
5348f4eafe Doxygen. 2001-03-25 12:45:13 +00:00
curt
7781498181 renamed to sgstream.[ch]xx 2001-03-25 12:07:55 +00:00
curt
b8ce139b8a FG_ to SG_ namespace changes.
Doxygenifing.
2001-03-25 12:06:09 +00:00
curt
75911b6c64 doxygen ... 2001-03-25 01:42:40 +00:00
curt
bf0d95145d Doxygen ... 2001-03-24 14:21:06 +00:00
curt
4326d560e9 name space tweaks.
dogygen.
2001-03-24 13:56:53 +00:00
curt
65fa6f2f00 fg_traits.hxx -> sg_traits.hxx
fg_zlib.hxx -> sg_zlib.hxx
2001-03-24 13:12:26 +00:00
curt
124629e1d9 Added some doxygen comments. 2001-03-24 05:27:23 +00:00
curt
557fade4a7 SG-ified logstream. 2001-03-24 05:02:14 +00:00
curt
98a65b5d1d Doxygen ... 2001-03-24 04:21:37 +00:00
curt
caaa35e5a7 SG_ namespace. 2001-03-24 03:55:18 +00:00
curt
a7459489ff Use plib rad/degrees conversion constants. 2001-03-24 03:20:47 +00:00
curt
87e59ff876 SG_ namespace fixes. 2001-03-24 03:02:31 +00:00
curt
9d87c913e7 Initial revision. 2001-03-24 02:43:29 +00:00
curt
0e8c010645 Trying to sort out name space confusing with SG_PI and SGD_PI and varients. 2001-03-23 23:39:25 +00:00
curt
470d01a508 FG_ to SG_ namespace changes. 2001-03-23 23:18:08 +00:00
curt
c16b9ed25b FG_ to SG_ namespace changes. 2001-03-23 21:59:44 +00:00
curt
d498199e8a FG_ to SG_ name changes. 2001-03-23 21:42:18 +00:00
curt
013687dccd Name space changes. 2001-03-23 21:09:56 +00:00
curt
baf25ca7a7 Name space tweaks. 2001-03-23 20:59:25 +00:00
curt
6c28bd884b Added doxygen comments. 2001-03-23 20:50:10 +00:00
curt
510091f082 From David Megginson:
1. Fixed a bug reported by Curt for one of the getChild methods.

2. Cleaned up some of the error reporting, and require PropertyList as
the root element name.  Also uncluttered the XML output a little
(removed type="unknown").

3. Added a new Long type (i.e. setLongValue, getLongValue, etc.), as
requested by Curt aeons ago.

4. Added aliases, so that a property's value can directly reflect the
value of another property.

5. Added a generalized inclusion facility, with parameters (panel
writers should love this one).
2001-03-21 04:57:13 +00:00
curt
7db44c113c Patch to property tree to allow repeating tag names. The property manager
simply assigns ordinality as it finds multiple instances.
2001-03-18 21:22:28 +00:00
curt
6cbf4306e7 Here are four small changes to simgear/misc/props.hxx for Red Hat 6.2.
I've also compiled with Mandrake 7.2 and MSVC with no problems.
2001-03-18 20:52:27 +00:00
curt
777386ea67 Tweaks to interpolator code. 2001-03-14 06:24:52 +00:00
curt
95e5e90791 More Irix Mips tweaks. 2001-03-07 23:56:11 +00:00
curt
a86868526e Patch to tweak traits so they work on Irix too. 2001-03-06 21:14:32 +00:00
curt
f1ab6e2533 Tweaks to follow flightgear STL standard coding procedure. 2001-03-06 19:57:56 +00:00
curt
9f516a8ccc Patches from Norman Vine <nhv@cape.com> to catch and properly report "errno"
conditions.
2001-03-06 16:33:39 +00:00
curt
e07af68018 Changes for the native Irix CC compiler contributed by Erik Hofman. 2001-03-02 22:52:04 +00:00
curt
a37d9a2d8e Reduced the verbocity level of the property loader. 2001-01-31 15:35:43 +00:00
curt
57811b5371 Tweaks to errno checking and perror. 2001-01-27 01:53:11 +00:00
curt
7ff9ba4fe6 Close a binary file before we return (if it turns out not to be a binary file) 2001-01-24 20:07:13 +00:00
curt
fad34bdbc3 Attempt to further isolate domain error problem. 2001-01-24 04:11:36 +00:00
curt
22b41d892a Tweaks from David Megginson. 2001-01-19 21:56:02 +00:00
curt
7a97c7575d Fixed a bug in how zlib.h was included. 2001-01-19 21:55:49 +00:00
curt
b0e175ad3d Tweaks to get us back within the ANSI C++ spec.
Cleaned up some debugging output.
2001-01-12 21:55:44 +00:00
curt
0de60aa6aa Minor MSVC tweaks by Christian Mayer. 2001-01-11 03:33:09 +00:00
curt
933e10d8a0 Initial revision. 2001-01-09 15:46:32 +00:00
curt
2efac3d949 made read/write functions into members of SGBinObject. 2001-01-06 04:31:11 +00:00
curt
c33841329d Simplified calling interface to read/write obj functions. 2001-01-06 04:07:45 +00:00
curt
f37800560f Need to properly interpret gzread() and gzwrite() return result for error
detection.
2001-01-05 21:26:59 +00:00
curt
60e61a0627 1. Patched simgear/magvar/magvar.[ch]xx to allow retrieval of the
magnetic variation for a specific location and date without running an
update cycle (I use this for setting up VOR default offsets in some
FlightGear patches).

2. [CRITICAL] Fixed some null-pointer bugs in simgear/misc/props.cxx.
2001-01-05 16:04:21 +00:00
curt
260dbeb3d2 Additional bug fixes after testing. 2001-01-05 00:04:20 +00:00
curt
70f495b4e1 Move binary file reading and writing to simgear. 2001-01-04 20:16:11 +00:00
curt
663db8f978 Fix a build order problem. 2000-12-20 15:06:04 +00:00
curt
c412739040 Updates for 0.0.15 2000-12-20 04:57:54 +00:00
curt
8b13d71fcf Rewrite of the property manager my David Megginson. 2000-12-19 21:53:37 +00:00
curt
1b129b289c Ready for 0.0.14 release. 2000-12-14 21:21:13 +00:00
curt
a89ceb96b9 Tweak ... 2000-12-14 15:10:56 +00:00
curt
9af5f9f094 MacOS tweaks contributed by Darrell Walisser. 2000-12-13 21:12:15 +00:00
curt
6776c2e536 oops again, fixed. 2000-12-13 19:35:32 +00:00
curt
4c3b4219fe Oops, fixed ... :-) 2000-12-13 19:30:57 +00:00
curt
a09806bb98 Tweaks to newbucket organization. 2000-12-13 19:18:29 +00:00
curt
e175c8cc4d Tweaks to property manager write routine to return true as it should when
the write succeeds.
2000-12-08 15:22:09 +00:00
curt
a53faf4565 Updated random interface so we can optionally specify our own seed value. 2000-12-06 19:01:57 +00:00
curt
dc653ac46c Removed some previously added debugging output. 2000-12-04 22:24:08 +00:00
curt
c544777d37 Minor fix to make the dome always match the fog / horizon color at the
horizon, so we don't see the extreme far tile edges when it is really dark.
2000-12-04 21:31:58 +00:00
curt
93a37df90a Renamed fg_random -> sg_random. 2000-12-04 04:12:33 +00:00
curt
1da02cca4c Added methods to return tile dimension in meters. 2000-12-04 04:11:03 +00:00
curt
4b1d777ad4 Updated some "const" stuff. 2000-12-03 19:32:42 +00:00
curt
fb0916be0f Added an explanation of what this code does. 2000-12-01 22:13:41 +00:00
curt
806083cb25 Initial revision. 2000-11-30 17:38:23 +00:00
curt
5ba74e30b8 Reduced debugging output. 2000-10-23 15:10:45 +00:00
curt
c39e08cb2a Added a distance off route routine (works best with 2d cartesian coordinates.) 2000-10-23 14:57:29 +00:00
curt
e4653be9a1 MSVC++ fixes. 2000-10-19 22:27:27 +00:00
curt
cd5765be1e Tweaks to waypoints and routing. Added distance_to field for each waypoint. 2000-10-13 21:32:51 +00:00
curt
c481b06451 Added route.[ch]xx which maintains a list of waypoints (i.e. a route)
Added an elevation field to each waypoint.  This can be used by the calling
program however it wishes.
2000-10-11 23:04:09 +00:00
curt
91ba4618e7 Initial revision. 2000-10-10 23:41:25 +00:00
curt
fdc5521389 First working revision. 2000-10-10 22:15:11 +00:00
curt
e88c915206 A bit of file renaming to avoid problems with MSVC++ 2000-10-10 17:19:17 +00:00
curt
1e60698053 Initial revision. 2000-10-04 21:55:11 +00:00
curt
5702bd7ee8 io changes and tweaks. Working on adding SOCK_STREAM (tcp) support. Still
needs some work, but is basically there.
2000-10-04 20:14:26 +00:00
curt
8eef3eb582 MSVC++ tweaks. 2000-10-02 18:55:26 +00:00
curt
31db353173 Changes from Bernie Bright:
Added '--with-cxx=COMPILER[:flags]' to ./configure in order to set the
compiler and flags.  If this option is omitted then the default compiler
is assumed (ie the current behaviour).  This duplicates the effect of
passing CC, CFLAGS, CXX and CXXFLAGS on the command line to configure
and make.

SimGear/simgear/compiler.h
Initial support for KAI C++ on linux.

SimGear/simgear/ephemeris/celestialBody.[ch]xx
Removed extraneous semicolons.

SimGear/simgear/io/sg_file.cxx
MSVC tidy up.
2000-10-02 18:52:32 +00:00
curt
2c4a0dd998 Updates from David Megginson:
These patches also eliminate the spurious warning messages about not being
able to set values for joystick buttons.
2000-09-30 01:34:46 +00:00
curt
7d7e41dacc Cleaned up a few poluting #defines.
Did some fg -> sg name space updating (lots more to do but we'll get there
  eventually)
2000-09-27 18:00:04 +00:00
curt
453a53b372 Oops! fixed a typo ... 2000-09-26 21:28:46 +00:00
curt
ef68d18f64 Renames fg_types.hxx -> sg_types.hxx 2000-09-26 21:03:31 +00:00
curt
ded1d2343f Renamed fg_types.hxx -> sg_types.hxx 2000-09-26 21:01:46 +00:00
curt
e6241a2f73 Renamed fg_types.hxx -> sg_types.hxx 2000-09-26 20:52:01 +00:00
curt
467254ec66 MSVC socket support added by Bernie Bright. 2000-09-25 17:32:44 +00:00
curt
135e137921 Initial revision. 2000-09-22 19:24:41 +00:00
curt
e13a5b57d4 Oops, references to built libs need to be relative to $(top_builddir) 2000-09-20 21:21:13 +00:00
curt
f1c00cdd18 #includes based off of srcdir rather than builddir. 2000-09-20 21:14:42 +00:00
curt
8c3de351b0 Use time_t rather than long int as return type for mktime(). 2000-09-18 17:00:16 +00:00
curt
0bcdb7eb70 Ready for 0.0.13 release. 2000-09-14 16:56:13 +00:00
curt
a92b71fffc MSVC changes ... 2000-09-13 20:21:39 +00:00
curt
89960ab715 MacOS portability tweaks from Darrell Walisser. 2000-09-13 19:29:01 +00:00
curt
2a369803ae MACOS -> macintosh 2000-09-09 20:53:44 +00:00
curt
b0134a377e Added a touch of error checking to the screen dump routine, i.e. don't
die if you can't open the output file.
2000-09-09 13:31:45 +00:00
curt
502c650cd9 Sep. 8, 2000 updates from David Megginson. 2000-09-08 18:34:45 +00:00
curt
a1bf8d2229 9/05/2000 updates from David Megginson relating to the property manager and
easyxml support.  This is a bit of simgear side support to facilitate a
configurable instrument panel in flightgear.
2000-09-05 21:38:00 +00:00
curt
25b743bdec Preserve initial "state" by careful use of glPushAttrib() and glPopAttrib()
being careful to manually call getState()->apply() before the glPushAttrib()
so that the ssg state handling mechanism doesn't get derailed accidentally.
2000-08-22 02:40:13 +00:00
curt
dbf7db02a2 Tiny bug fix/tweak. 2000-08-08 14:54:09 +00:00
curt
8c998659c6 Missed some files needed in make dist. 2000-08-08 03:21:26 +00:00
curt
4e23b3dff5 Clean up constructor a bit. 2000-08-08 03:20:02 +00:00
curt
159d3c4c6c Restructured the magvar code a bit to make it more usable. 2000-08-07 18:26:35 +00:00
curt
612b5ae0bc Added simgear/xml. 2000-07-27 02:55:47 +00:00
curt
60cbe9c1d4 Initial revision. 2000-07-26 19:17:43 +00:00
curt
4dadd29727 Updates for 0.0.13 2000-07-22 21:34:58 +00:00
curt
e4610b9baa Ready for 0.0.12 release. 2000-07-20 02:04:47 +00:00
curt
926a0f2437 Renamed FG* to SG* to conform with SimGear naming prefix scheme. 2000-07-14 21:26:45 +00:00
curt
9325ec681e Tweaking api. 2000-07-14 19:15:41 +00:00
curt
af383e6c39 Tweaks to SGSocket. 2000-07-13 22:51:16 +00:00
curt
b000691ab9 Added iochannel stuff to simgear. 2000-07-11 18:38:10 +00:00
curt
22812a0aae Moved to SimGear. 2000-07-11 18:37:49 +00:00
curt
dda7ebfe0d Minor spelling changes in comments. 2000-07-10 13:18:10 +00:00
curt
9a211af659 Sg-ifying names. 2000-07-08 21:30:23 +00:00
curt
82459a2802 Converted to the LGPL licencing terms. 2000-07-08 19:16:10 +00:00
curt
1774fb2d02 Starting conversion to LGPL (from GPL). 2000-07-08 18:44:26 +00:00
curt
f0081c7697 Collapsed the init() method into the constructor. 2000-07-08 13:54:06 +00:00
curt
1e53bedca5 Minor tidying up of interface. 2000-07-08 03:06:45 +00:00
curt
cf1c7e7378 Updated Durk's entry. 2000-07-07 22:03:45 +00:00
curt
5c3b569e97 What do you know, more tidying. 2000-07-07 21:56:25 +00:00
curt
cb29dcc238 clean ups ... 2000-07-07 19:51:42 +00:00
curt
d48b3f1e9a More SGTime tidying. 2000-07-07 18:28:36 +00:00
curt
a4d60e7bd6 Still tweaking output messages. 2000-07-07 15:26:54 +00:00
curt
1a6e2509c7 More SGTime clean ups. 2000-07-07 14:59:04 +00:00
curt
8159b749f4 fg_time.* becomes sg_time.*, FGTime becomes SGTime ... 2000-07-06 20:10:41 +00:00
curt
bec11c2939 ... 2000-07-06 12:46:18 +00:00
curt
8a189b6778 ... 2000-07-06 12:31:18 +00:00
curt
93c6845a6d David Megginson: Added an interface for tree-based navigation (like
navigating a file system.)
2000-07-05 18:50:34 +00:00
curt
b659c805fc Initial revision. 2000-07-05 18:43:44 +00:00
curt
15eaf8dc84 Updates from David Megginson. 2000-07-05 18:36:52 +00:00
curt
cafe89047c Additional updates. 2000-07-05 14:42:58 +00:00
curt
b5705ff47a Pulling in code from the flight gear project relating to timing and ephemeral
calculations.
2000-07-05 00:26:03 +00:00
curt
1b07b25ad2 Migrating timing support routines over to SimGear. 2000-07-05 00:25:30 +00:00
curt
a46163bcd7 Migrated this source over to SimGear. 2000-07-05 00:20:08 +00:00
curt
6531b1ebbc More tweaks ... 2000-07-04 15:44:49 +00:00
curt
dc7bbdce11 Updates to control span (or lateral size of cloud layer square) 2000-07-04 03:32:02 +00:00
curt
a29cbc1112 Updates ... 2000-07-03 21:42:56 +00:00
curt
afc2099865 Updated news. 2000-07-03 17:50:03 +00:00
curt
7d251444e6 Tweaks for 0.0.11 release. 2000-07-03 17:45:30 +00:00
curt
1c2289dacd Initial revision. 2000-07-03 15:07:33 +00:00
curt
044ac5d5d3 Just a few more visibility tweaks and clean ups. 2000-06-30 22:16:41 +00:00
curt
38167ed273 Oops, a couple more sky tweaks. 2000-06-30 21:51:12 +00:00
curt
e15ffbc856 Updates to remove unneeded dependencies on FlightGear and SimGear. 2000-06-30 19:45:24 +00:00
curt
6cf2716615 Updates to cloud code to add different basic cloud types. This isn't the
final list of cloud types, but servers as an example / template for someone
who wants to tweak this out and do it right.
2000-06-23 02:55:57 +00:00
curt
0468b315d4 A couple more cloud tweaks. 2000-06-20 21:44:04 +00:00
curt
de66c74a91 Updating cloud code. 2000-06-20 20:31:48 +00:00
curt
7db73cd215 Cloud texcoord fixes to tie apparent cloud position to earth even though
the whole cloud structure is actual tied to ownship movement.
2000-06-20 02:49:03 +00:00
curt
242eceb1c6 Added a spherical course & dist given two points routine. 2000-06-20 02:46:42 +00:00
curt
c2b84db5a2 Moving cloud functionality to sky section. 2000-06-20 00:30:30 +00:00
curt
487bee35ab Initial revision. 2000-06-20 00:27:53 +00:00
curt
9fabeb77bc Metakit seems to really want to #define bool int, #define true 1,
#define false 0, so I massaged the header files to make this impossible.
2000-06-19 17:06:35 +00:00
curt
bfea2dec4d Initial revision. 2000-06-19 17:05:41 +00:00
curt
2ed07850c6 Math/bucket/tiling updates contributed by Norman Vine.
Texture coordinate calculation updates by Curt.
2000-06-16 00:28:19 +00:00
curt
b72d36d96f Minor fiddling with material properties *trying* to chase down a visual bug
where the scene get's brighter or dimmer depending on whether or not the sun
or moon is in the field of view.
2000-06-01 19:14:06 +00:00
curt
e3ff048ff6 First quick hack at panel shading. 2000-05-27 04:40:55 +00:00
curt
ceef43681d First stab at replacing gdbm with metakit. 2000-05-27 03:43:44 +00:00
curt
3ec00676e4 Initial revision. 2000-05-25 16:45:19 +00:00
curt
e6575fb1db MSVC5 portability changes contributed by Bruce Finney. 2000-05-24 04:10:01 +00:00
curt
fa98d733d6 Updated for version 0.0.9 2000-05-24 01:30:42 +00:00
curt
2981a10e62 Updated for MSVC5. 2000-05-24 01:30:18 +00:00
curt
551c06f885 Updates for MSVC5 2000-05-24 01:29:13 +00:00
326 changed files with 57715 additions and 5325 deletions

9
.cvsignore Normal file
View File

@@ -0,0 +1,9 @@
Makefile
Makefile.in
SimGear.spec
aclocal.m4
autom4te.cache
config.cache
config.log
config.status
configure

View File

@@ -0,0 +1 @@
Curtis Olsen and others.

481
COPYING Normal file
View File

@@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

806
Doxyfile Normal file
View File

@@ -0,0 +1,806 @@
# Doxyfile 1.2.6
# This file describes the settings to be used by doxygen for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = SimGear
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.3.1
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = ../doxy
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese,
# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian,
# Polish, Portuguese and Slovene.
OUTPUT_LANGUAGE = English
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = NO
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
STRIP_FROM_PATH =
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a class diagram (in Html and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off.
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower case letters. If set to YES upper case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are adviced to set this option to NO.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like the Qt-style comments (thus requiring an
# explict @brief command for a brief description.
JAVADOC_AUTOBRIEF = YES
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
INHERIT_DOCS = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 8
# The ENABLE_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text.
WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = \
simgear/bucket \
simgear/compiler.h \
simgear/constants.h \
simgear/debug \
simgear/ephemeris \
simgear/io \
simgear/magvar \
simgear/math \
simgear/misc \
simgear/route \
simgear/screen \
simgear/serial \
simgear/sg_inlines.h \
simgear/sg_traits.hxx \
simgear/sg_zlib.h \
simgear/sky \
simgear/threads \
simgear/timing \
simgear/xml
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
FILE_PATTERNS = *.h *.hxx *.c *.cxx *.cpp
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = simgear/metakit simgear/zlib
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
INPUT_FILTER =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
TOC_EXPAND = NO
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Netscape 4.0+
# or Internet explorer 4.0+).
GENERATE_TREEVIEW = NO
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = YES
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimised for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = YES
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using a WORD or other.
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assigments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = YES
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tagfiles.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to
# YES then doxygen will generate a graph for each documented file showing
# the direct and indirect include dependencies of the file with other
# documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to
# YES then doxygen will generate a graph for each documented header file showing
# the documented files that directly or indirectly include this file
INCLUDED_BY_GRAPH = YES
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
DOT_PATH =
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_WIDTH = 1024
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_HEIGHT = 1024
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
CGI_NAME = search.cgi
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
CGI_URL =
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
DOC_URL =
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
DOC_ABSPATH =
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
BIN_ABSPATH = /usr/local/bin/
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
EXT_DOC_PATHS =

View File

@@ -1,14 +1,20 @@
EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h
EXTRA_DIST = \
acinclude.m4 \
autogen.sh \
README.MSVC \
README.metakit \
README.zlib \
SimGear.dsp \
SimGear.dsw
SUBDIRS = simgear
SUBDIRS = src-libs simgear
dist-hook:
(cd $(top_srcdir); $(HOME)/projects/FlightGear-0.7/admin/am2dsp.pl)
#
# Rule to build RPM distribution package
#
rpm: dist
cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/packages/SOURCES
rpm -ba @PACKAGE@.spec
dist-hook:
tar cf - simgear/metar | (cd $(distdir); tar xvf -)
rpm -ta $(PACKAGE)-$(VERSION).tar.gz

212
NEWS
View File

@@ -1,3 +1,211 @@
New in 0.3.1
* December 4, 2002
* Fix a major packaging blunder with several missing files.
New in 0.3.0
* December 3, 2002
* removed interpreter subdir
* NOMINAX fix for Cygwin/gcc-3.2
* Added some prototype 3d clouds based on Mark Harris's demos.
* Simplified the command manager interface
* Allow an "include" attribute on root PropertyList element.
New in 0.2.0
* September 6, 2002
* Modernized the autoconf/make scripts, plus lots of tweaks and enhancements.
* Removed efence support (in favor of valgrind.)
* Added a javascript interpreter.
* SGSocket reimplimented on top of plib/net libs.
* Added a new random number generation algorithm.
* Total rewrite of the strutils package.
* Patch for the random number seed.
* IA-64 w/ Intel compiler fixes.
* MSVC/MINGW fixes.
* Mac OS X fixes.
* Irix fixes.
* Code clean ups to remove warning messages.
* Optimizations in sg_binobj to reduce the amout of memory copying
needed when loading a binobj format file.
* Fixed a couple places where variables could be used before they were
initialized.
* Various property manager fixes and improvements.
* Fixes to cloud layer management code.
* Made the sky dome more flexible to facilitate use in other applications.
New in 0.0.18
* April 20, 2002
* Created a src/libs subdirectory for several packages that need to be
installed by the user but are used by many other packages and may already
be installed. So we just bundle the source separately as a convenience
if the user needs to build and install these.
* Upgrade to zlib-1.1.4 (security fix)
* Upgrade to metakit-2.4.2-32.tar.gz (latest upstream release)
* Added support for point objects in the scenery file format.
* Additions to the binary file format to make it *much* more flexible.
For each major primative type: points, triangles, fans, and strips, you
can specify an index list of vertices, normals, colors, and texture
coordinates. You can skip any of these you like to save on space.
* Added support for new file features in the binary -> ascii scenery file
decoder.
* Various code clean ups.
* Separate XML I/O operations into a separate header file.
* Major property manager rewrite, then lots of followup cleaning and
improvements.
New in 0.0.17 (final)
* February 16, 2002
* Explicitely reset the glBlendFunc() after drawing the moon for the
Voodoo2 linux driver since it seems to have a bug in glPopAttrib().
New in 0.0.17pre2
* February 13, 2002
* Replaced some cout's with SG_LOG's
New in 0.0.17pre1
* February 12, 2002
* Removed metakit and zlib from build process. Tarballs are still included
for those who's systems don't provide these packages.
* MSVC fixes.
* IRIX fixes.
* Mingwin fixes.
* Mac OS X fixes.
* FreeBSD fixes.
* Added support for Intel's C++ compiler under Linux.
* Attempt to build in support for various non-compatible automake/autoconf
versions.
* Fix for a problem that could lead to a bogus build for people with voodoo
cards.
* Added Norman's jpegfactory code which can create jpeg format screen shots
of a live running application.
* implemented set/get_log_classes and set/get_log_priority.
* Socket library improvements.
* Added a C++ exception abstraction.
* Property manager fixes and improvements including node path caching
and debug tracing of property reads/writes.
* Updates/fixes to xml handling.
New in 0.0.16
* July 12, 2001
* Various changes to the property manager implimentation to better support
dumping out the desired portions of the property tree to file.
* Don't compile the metakit demos by default (causes problems for Irix)'
* Other various tweaks for Irix.
* Added a virtual destructor to XMLVisitor to fix a warning message.
* Check for valid hostname lookup in sg_socket.cxx
* Add a function to return modified julian date without creating an
entire SGTime class. This avoids an extraneous warning about not
being able to find a timezone.
* Created a mailing list for cvs commit messages.
* Fixed a potential array under/over run bug in interpolator.cxx
* Removed all references to SGValue from the property manager. Added
support for an "archive" bit in the property manager to control
which values get written out.
* Added SGCommandState class so that commands can compile and save
copies of their arguments for efficiency if they are called multiple
times.
* Added Brian Baul's "tr" tiled rendering low level support library.
This along with some higher level code in flightgear allows us to do
ultra-hires tiled screen dumps suitable for large format printers.
(Norman Vine)
New in 0.0.15
* June 20, 2001
* Various bug fixes, tweaks, and optimizations.
* Added a command manager (analogous to the property manager)
* Better Irix Mips support.
* Various gcc-3.0 fixes.
* Various MSVC fixes.
* Added MSVC project files (automatically generated from the unix
automake configuration files.)
* Removed total size limitation on interpolation table module.
* Various Cygwin fixes.
* Added some convenience functions to point3d.
* Various compiler warning fixes.
* Added a thread wrapper class (currently only supports pthreads)
* Added IO routines for a lowlevel, native simgear binary 3d file
format optimized for TerraGear terrain.
* Better endianness checking and support for the binary file
read/write routines.
* Added doxygen comments for all public interface code. Documentation
can be accessed via the SimGear web page.
* Many FG -> SG name space changes for better consistancy throughout
this package.
* Added property aliases, repeated name tags, and a general xml
inclusion facilities. Many other property manager clean ups
following a complete rewrite.
* Fixed some critical null pointer bugs in property manager.
* Magnetic variation can now be fetched for any arbitrary location.
New in 0.0.14
* December 14, 2000
* Added a module to manage waypoints and routes, calculate bearing and
distance to next waypoint, lateral distance off route, etc.
* Moved some of the basic time management code over from flightgear.
* Bucket dimensions can be returned in meters
* Added SOCK_STREAM (TCP) socket support to the networking code.
* Updated random number generator interface so application can provide
it's own seed value as well as use the default time seed.
* Added a routine to calculate the distance between a point and a line segment.
* Updates to the property manager and the property list loader/saver.
* Added an explanation of the rational behind our terrain texture coordinate
generation code.
* Fixed sky dome so that the color at the horizon will always match
the specified fog color.
* Did a fair amount of fg -> sg name space updating (lots left to do.)
* Added support for KAI C++ on linux.
* MSVC tweaks.
* MacOS tweaks.
* FreeBSD tweaks.
New in 0.0.13
* September 14, 2000
* Added support for reading and writing xml files (easyxml)
* Then updates to property manager and xml code.
* Update magnetic variation code.
* Sky code now uses glPushAttrib and glPopAttrib so it plays better with
other ssg based apps.
* MacOS tweaks.
* MSVC tweaks.
New in 0.0.12
* July 19, 2000
* Converted project license from GPL to LGPL.
* Moved low level IO (socket, file, serial) code over to SimGear.
* Moved ephemeral code into simgear
* Moved basic world time code into simgear
* Added a property manager (registry)
* Some documentation added.
New in 0.0.11
* July 3, 2000
* Replaced gdbm with metakit
* Added drop in sky (depends on plib)
* Added spherical course and dist given two points calculations
* MSVC5 fixes
* Math/bucket/tiling tweaks from Norman Vine
New in 0.0.7
* March 29, 2000
* Added support for RedHat package building contributed by Habibie
@@ -10,18 +218,22 @@ New in 0.0.7
* Optimizations and bullet proofing of magnetic variation code by Norman
Vine and Ed Williams
New in 0.0.6
* March 27, 2000
* Added Nima World Magnetic Model 2000 contributed by Ed Williams
* Fixes for MSVC++
New in 0.0.5
* March 17, 2000
* Restructured directory layout to facilitate windows/mac IDE builds.
New in 0.0.4
* Removed mat3.h and friends (we now use plib's sg lib for these sorts of
things.)
New in 0.0.3
* Release that conincides with FlightGear-0.7.2

1
README
View File

@@ -0,0 +1 @@
[ Nothing here at this time. ]

24
README.MSVC Normal file
View File

@@ -0,0 +1,24 @@
This document describes how to build SimGear using the supplied workspace and
project files.
Unpack the SimGear source file into your work directory. This creates a new
subdirectory called SimGear-X.Y.Z. Rename this to SimGear. Before we can
build SimGear you must unpack and build the third party libraries metakit and
zlib. Sources for these are included in the SimGear/src-libs directory.
Unpack these into the top level SimGear directory. At this point your
directory structure should look something like this:
<work_dir>/
SimGear/
metakit-x.y.z/
simgear/
src-libs/
zlib-x.y.z/
Now open the SimGear workspace. This workspace file contains projects for
building metakit(mklib), SimGear and zlib. Select each project as the active
project and build all. Order is unimportant since there are no dependencies
between the projects.
The workspace and project files are generated by a perl script with extra
input from the am2dsp.cfg file.

285
README.metakit Normal file
View File

@@ -0,0 +1,285 @@
For your convenience (and with the author's permission) a copy of the
MetaKit source is bundled with SimGear in $(top_srcdir)/src-libs/.
You must have metakit installed before you can build SimGear.
- Most linux distributions have a metakit package. For linux
developers, we recommend ysou install your distributions package
rather than building from source.
- For developers on most other platforms, you will have to build
metakit from source and install it yourself. For your convenience a
tar ball of the metakit source is included with the simgear source
distribution. Untar the metakit source, and follow the included
build and installation instructions.
Once metakit is installed you can return to configuring and building
Simgear.
=============================================================================
Potentially important build note:
Later on when you are linking programs with -lmk4 (i.e. FlightGear or one
of it's associated programs) if you come across an error similar to the
following:
c++ -Wall -O2 -L/usr/local/lib -o gensimple gensimple.o libAirports.a
-lsgdebug -lsgmisc -lmk4 -lz -lm
/usr/local/lib/libmk4.a(view.o)(.text+0x1c8):view.cpp: multiple definition
of `c4_View::~c4_View(void)'
libAirports.a(simple.o)(.text$_$_7c4_View+0x0):simple.cxx: first defined
here
collect2: ld returned 1 exit status
make[2]: *** [gensimple] Error 1
make[2]: Leaving directory `/home/curt/FlightGear-0.7.7/src/Airports'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/curt/FlightGear-0.7.7/src'
make: *** [all-recursive] Error 1
Then you need to come back and rebuild Metakit with the -DNDEBUG flag.
For unix/cygwin systems, modify the unix/Makefile file and add -DNDEBUG
to the CFLAGS line.
Now we return you to the official metakit readme ... :-)
The MetaKit Library 2.01 March 2000
==============================================================================
WHAT IT IS - MetaKit is an embeddable database which runs on Unix, Windows,
Macintosh, and other platforms. It lets you build applications which
store their data efficiently, in a portable way, and which will not need a
complex runtime installation. In terms of the data model, MetaKit takes
the middle ground between RDBMS, OODBMS, and flat-file databases - yet it
is quite different from each of them.
WHAT IT ISN'T - MetaKit is not: 1) multi-user/-threading, 2) scalable to
gigabytes, 3) proprietary software, 4) full of bugs, 5) just a toy.
TECHNOLOGY - Everything is stored variable-sized yet with efficient positional
row access. Changing an existing datafile structure is as simple as re-
opening it with that new structure. All changes are transacted. You can
mix and match software written in C++, Python, and Tcl. Things can't get
much more flexible...
CORE - The Metakit core library is written in C++. It has a code footprint of
just over 100 Kb on Windows. It can be used as DLL, or linked statically.
Debug builds include extensive assertion checks to catch problems early.
PYTHON - The binding for Python is called "Mk4py". It uses SCXX by Gordon
McMillan as C++ glue interface. The source is in directory "python/".
TCL/TK - The MK extension for Tcl is called "Mk4tcl". It is being used in a
number of commercial projects, for in-house use as well as in commercially
distributed products. The source is in directory "tcl/".
LICENSE AND SUPPORT - MetaKit 2.01 is distributed as open source software (the
X/MIT-style license is at the end of this document). Commercial support
is available through an Enterprise License, see the URL mentioned below.
DOCUMENTATION - All documentation uses HTML. The main page is "MetaKit.html",
which leads to the rest of the documentation in the "doc/" directory.
WEBSITE URLS - The main pages on the world wide web, for news and downloads:
Homepage: http://www.equi4.com/metakit/
Python news: http://www.equi4.com/metakit/python.html
Tcl/Tk news: http://www.equi4.com/metakit/tcl.html
License info: http://www.equi4.com/metakit/license.html
Contact info: http://www.equi4.com/contact.html
INSTALLATION
============
Starting with this release, all platform builds and language bindings are now
designed to work from a single common "builds/" directory. It turns out to
be impossible to keep build side-effects limited to *just* this directory
(CodeWarrior can't be told where to place its temp data, and Visual C++ still
alters a few files next to the project ".dsw" file, to name two offenders).
UNIX
It is no longer advised to build the Unix code in the "unix/" directory.
Instead, you should perform the following steps:
% cd builds
% ../unix/configure
% make
% make test
And optionally (this only installs the core lib, not script extensions):
% make install
By switching to the "builds/" directory, you will keep the distribution
directory tree 100% unaltered. All changes are made in this subdir, and
all final build results are left behind in this same subdir.
Nastiness: if you build Mk4tcl, please do a "make Mk4tcl.so" as well.
And if you intend to create the Python extension, do a "make Mk4py.so".
The "libmk4tcl.so.0.0.0" and "libMk4py.so.0.0.0" targets are bogus ones.
You will probably have to make changes in the makefile to locate the
proper includes and libs for Python (Tcl has been fixed, see "--with-tcl).
You probably only need to adjust "CXX_SWITCHES_PY" to find the headers.
To build with STL containers and strings, you can do the following:
make CXXFLAGS='-Dq4_STD' test # add -O3 etc, as needed
This passes the test suite on Linux RedHat 5.2 with gcc 2.95-2.
See below for some platform-specific build notes.
WINDOWS
There is a "win/" directory which contains subdirectories for a number of
compiler systems. MetaKit has been built with many different compilers
in the past (Microsoft, Borland, Watcom, Symantec, Metrowerks, Optima),
but to preserve my sanity (there are 12 configurations for MSVC6 alone!),
I am limiting myself to MSVC6, MWCW5, Borland C++ Builder 4, and Cygwin.
The MS Visual C++ 6.0 project is "win/msvc60/mksrc.dsw", with subprojects
for the C++ demo (mkdemo), building dll's (mkdll), static libs (mklib),
regression tests (mktest), as well as Tcl (mktcl) and Python (mkpython).
It has been set up to place all intermediate files and final results in
the "builds/" subdirectory, even though you'll launch it from "win/".
To build with STL containers and strings under MSVC, define "q4_STD".
To build with MFC containers and strings under MSVC, define "q4_MFC".
The Metrowerks Codewarrior project is in the "mac/" directory, and can be
used to build both Mac and Windows versions (on either Mac *or* Windows).
The core libraries are built with "mac/cw5.mcp", demos / tests are built
with "cw5apps.mcp", Tcl is "cw5tcl.mcp", and Python is "cw5python.mcp".
The Borland C++ Builder projects have not yet been incorporated in this
release, but the "KitViewer" application is an example of how to use BCB.
The Cygwin build (B20.1 / gcc 2.95.2) is different, because it uses the
unix autoconf system, and must be launched as described above for UNIX.
I have upgraded to the latest development of libtool to be able to build
DLL's with Cygwin. You can build the "-mno-cygwin" version by editing
the Makefile by hand and adding that option to CXXFLAGS.
Rob Bloodgood adds that the following GCC options are for maximum code
efficiency on x86 hardware: "-O2 -m486 -malign-loops=2 -malign-jumps=2".
I have not yet tried this myself, but am passing on the tip.
MACINTOSH
The Mac version requires Metrowerks CodeWarrior 5. See the info above
in the Windows section (MWCW is multi-platform). The projects are all
located in the "mac/" folder, which is also where MWCW will place its own
"... Data" folders with intermediate results. As with all other setups,
final results are made to end up in the "builds/" directory.
Static 68K builds appear to work fine, the 68K CFM variants will need
some more work (I couldn't get the libraries to export their symbols).
PLATFORM-SPECIFIC NOTES
=======================
* Linux RH 5.2 / gcc 2.95.2
Builds with gcc 2.95.2 work out of the box. The Tcl extension ends up as
".libs/libmk4tcl.so.0.0.0" (to please libtool), and should be renamed to
"Mk4tcl.so". Similarly, ".libs/libMk4py.so.0.0.0" is in fact the Python
extension, and *must* be renamed to "Mk4py.so" to call it from Python.
The core MK libs end up as ".libs/libmk4.a" and ".libs/libmk4.so.0.0.0".
* Solaris 2.6 / gcc 2.8.1
The Solaris builds are nasty for several reasons:
- I do not own such a machine, and often have to make arrangements
(or fight limited space on one of the machines I can telnet to).
- The gcc 2.8.1 optimizer appears to be buggy, I have had to turn off
the default "-O3" flag to prevent compiler crashes (several files).
This problems appears to be resolved with gcc 2.95.
- Locking on Solaris (especially w.r.t NFS) remains a mystery to me.
The Tcl and Python extensions both use locking (the core not yet).
See tcl/Mk4tcl.cpp around line 520, and python/PyStorage.cpp around
line 80 for details. It's all pretty messy, and not 100% correct.
Despite this, I'm doing my best to resolve these issues. Having a solid
build of the core *and* of Tcl / Python extensions is quite important.
* Other Unix systems
No further notes, though many systems will build fine out of the box.
* Windows
MSVC 6 builds MK as static lib and as DLL (universal config, I have not
yet created build versions with MFC or STL, mainly because MK can now be
used in all contexts regardless of how it was built). The Python and Tcl
extensions build as dynamic extensions (a static build is easy to add).
MWCW 5 builds MK as static lib and as DLL (interestingly enough, the DLL
is slightly smaller than MSVC 6 - 102 vs 108 Kb - when their runtimes are
linked in dynamically as well). I have not added Win builds for Tcl or
Python, since MSVC 6 has those already.
Cygwin B20.1, with gcc 2.95.2 ugrade, also builds MK as static lib and as
DLL. Both "pure" Cygwin (i.e. requiring cygwin1.dll) and mingw32 (using
the -mno-cygwin flag) build, but there are some hairy include issues when
it comes to choosing the right locking model for Tcl and Python. These
issues have not been resolved fully.
* Macintosh
MWCW 5 builds PPC shared libs, PPC static libs, and 68K static libraries.
Building 68K CFM libraries leads to a "MetaKit 68K.shlb" which comes out
of the linker without errors, but the result does not seem to have any
export symbols defined (despite the fact that the library is over 200 K).
Because of that, I've been unable to build apps or Mk4tcl/Mk4py so far.
The other three configurations build, but for some reason MK's regression
test stops at L03 (everything up to that point looks ok, i.e. over 90%).
The Mk4tcl PPC extension appears to work (quick manual test), and so does
the Python extension, "Mk4py.PPC.slb". I have not yet given these two
a serious workout, hoping to have a basic test harness in place soon.
* VMS, BeOS, ...
No news yet, please report your findings with any other platform builds.
WHAT'S MISSING HERE
===================
- a section on basic concepts (or maybe it doesn't belong here?)
- a section on getting started (C++, Python, Tcl all differ - point to
the respective intro pages)
- maybe a small sample for each of C++ / Tcl / Python, to give an idea
- mention TclKit, scripted docs (WiKit/Tequila?), VFS?
- I forgot... please tell me :)
LICENSE AND COPYRIGHT STATEMENT
===============================
Copyright (c) 1996-2000 Jean-Claude Wippler
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
==============================================================================
-- Jean-Claude Wippler <jcw@equi4.com>

16
README.plib Normal file
View File

@@ -0,0 +1,16 @@
[This file is mirrored in both the FlightGear and SimGear packages.]
You *must* have plib version 1.6.0 or later installed on your system
to build FlightGear!" Flight Gear is no longer compatible with the
earlier versions of the library.
You can get the latest version of plib from:
http://plib.sourceforge.net
Build notes:
You should be able to just run "./configure" to configure the package
and use all of plib's defaults. Then run "make" followed by "make
install". By default, plib installs itself into /usr so if you don't
like this, be sure to specify an alternate prefix such as --prefix=/usr/local

173
README.zlib Normal file
View File

@@ -0,0 +1,173 @@
For your convenience and allowed by zlib's license terms:
http://www.gzip.org/zlib/zlib_license.html a copy of the zlib source
is bundled with SimGear in $(top_srcdir)/src-libs/. You must have
zlib installed before you can build SimGear.
- Most linux distributions have a zlib package. For linux
developers, we recommend ysou install your distributions package
rather than building from source.
- Cygwin installs zlib automatically.
- For developers on most other platforms, you will have to build
zlib from source and install it yourself. For your convenience a
tar ball of the zlib source is included with the simgear source
distribution. Untar the zlib source, and follow the included
build and installation instructions.
Once zlib is installed you can return to configuring and building
Simgear.
We now send you to the official zlib README ...
=============================================================================
zlib 1.1.4 is a general purpose data compression library. All the code
is thread safe. The data format used by the zlib library
is described by RFCs (Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
format) and rfc1952.txt (gzip format). These documents are also available in
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact jloup@gzip.org). A usage
example of the library is given in the file example.c which also tests that
the library is working correctly. Another example is given in the file
minigzip.c. The compression library itself is composed of all source files
except example.c and minigzip.c.
To compile all files and run the test program, follow the instructions
given at the top of Makefile. In short "make test; make install"
should work for most machines. For Unix: "./configure; make test; make install"
For MSDOS, use one of the special makefiles such as Makefile.msc.
For VMS, use Make_vms.com or descrip.mms.
Questions about zlib should be sent to <zlib@gzip.org>, or to
Gilles Vollant <info@winimage.com> for the Windows DLL version.
The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/
Before reporting a problem, please check this site to verify that
you have the latest version of zlib; otherwise get the latest version and
check whether the problem still exists or not.
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html
before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.1.4 are documented in the file ChangeLog.
The only changes made since 1.1.3 are bug corrections:
- ZFREE was repeated on same allocation on some error conditions.
This creates a security problem described in
http://www.zlib.org/advisory-2002-03-11.txt
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
- Avoid accesses before window for invalid distances with inflate window
less than 32K.
- force windowBits > 8 to avoid a bug in the encoder for a window size
of 256 bytes. (A complete fix will be available in 1.1.5).
The beta version 1.1.5beta includes many more changes. A new official
version 1.1.5 will be released as soon as extensive testing has been
completed on it.
Unsupported third party contributions are provided in directory "contrib".
A Java implementation of zlib is available in the Java Development Kit
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
See the zlib home page http://www.zlib.org for details.
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
is in the CPAN (Comprehensive Perl Archive Network) sites
http://www.cpan.org/modules/by-module/Compress/
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
is available in Python 1.5 and later versions, see
http://www.python.org/doc/lib/module-zlib.html
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
An experimental package to read and write files in .zip format,
written on top of zlib by Gilles Vollant <info@winimage.com>, is
available at http://www.winimage.com/zLibDll/unzip.html
and also in the contrib/minizip directory of zlib.
Notes for some targets:
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
The zlib DLL support was initially done by Alessandro Iacopetti and is
now maintained by Gilles Vollant <info@winimage.com>. Check the zlib DLL
home page at http://www.winimage.com/zLibDll
From Visual Basic, you can call the DLL functions which do not take
a structure as argument: compress, uncompress and all gz* functions.
See contrib/visual-basic.txt for more information, or get
http://www.tcfb.com/dowseware/cmp-z-it.zip
- For 64-bit Irix, deflate.c must be compiled without any optimization.
With -O, one libpng test fails. The test works in 32 bit mode (with
the -n32 compiler flag). The compiler bug has been reported to SGI.
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
it works when compiled with cc.
- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
is necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
with other compilers. Use "make test" to check your compiler.
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For Turbo C the small model is supported only with reduced performance to
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
Per Harald Myrvang <perm@stud.cs.uit.no>
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib;
they are too numerous to cite here.
Copyright notice:
(C) 1995-2002 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not*
receiving lengthy legal documents to sign. The sources are provided
for free but without warranty of any kind. The library has been
entirely written by Jean-loup Gailly and Mark Adler; it does not
include third-party code.
If you redistribute modified sources, we would appreciate that you include
in the file ChangeLog history information documenting your changes.

2381
SimGear.dsp Normal file

File diff suppressed because it is too large Load Diff

53
SimGear.dsw Normal file
View File

@@ -0,0 +1,53 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "SimGear"=".\SimGear.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "mklib"=".\SimGear\metakit-2.4.3\win\msvc60\mklib.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "zlib"=".\SimGear\zlib.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

1
TODO Normal file
View File

@@ -0,0 +1 @@
03/25/2001 - Resolve location of Sky dome implimentation documentation.

184
Thanks Normal file
View File

@@ -0,0 +1,184 @@
A very special thanks is due to the following people and groups.
Note: as hard as we've tried, it is impossible to perfectly maintain
this file. If you are aware of someone who you think should be
included here, PLEASE let me know. Projects like this are made
possible only by the help and hard work of others. I want to properly
credit everyone who has contributed to this project.
Raul Alonzo <amil@las.es>
Mr. Alonzo is the author of Ssystem and provided his kind permission
for using the moon texture. I also used parts of his code as a template
when adding the texture. Ssystem Homepage can be found at:
http://www1.las.es/~amil/ssystem
Paul Bleisch <pbleisch@acm.org>
Paul redid the "debug" system so that it would be much more flexible,
so it could be easily disabled for production system, and so that
messages for certain subsystems could be selectively enabled.
Also contributed a first stab at a config file/command line parsing
system.
Bernie Bright <bbright@c031.aone.net.au>
Many C++ style, usage, and implementation improvements.
STL portability, tons o' stuff. :-)
Currently trying to get a BeOS port together but life keeps getting
in the way!
Gene Buckle <geneb@deltasoft.com>
Gene has done a lot of work getting FG to compile with the MSVC++
compiler. Also, he has pushed, proded, and bugged me endlessly to
do my stuff right. (I mean that in a good way, because sometimes
when the little nudge in the right direction isn't working, I need
a good hard shove.) :-)
John Check <j4strngs@rockfish.net>
Cloud textures
Jean-Francois Doue
Vector 2D, 3D, 4D and Matrix 3D and 4D inlined C++ classes. (Based on
Graphics Gems IV ed. Paul S. Heckbert)
http://www.animats.com/simpleppp/ftp/public_html/topics/developers.html
Bruce Finney <bfinney@gte.net>
MSVC5 compatibility.
Jean-loup Gailly and Mark Adler <zlib@gzip.org>
Authors of the zlib library. Used for on-the-fly compression and
decompression routines.
http://www.cdrom.com/pub/infozip/zlib/
Thomas Gellekum <tg@ihf.rwth-aachen.de>
Changes and updates for compiling on FreeBSD
Habibie <habibie@MailandNews.com>
RedHat package building changes for SimGear.
Bruce Jackson of NASA <e.b.jackson@larc.nasa.gov>
Developed the LaRCsim code under funding by NASA which we use to provide
the flight model. Bruce has patiently answered my many, many questions.
http://dcb.larc.nasa.gov/www/DCBStaff/ebj/ebj.html
Richard Kaszeta <bofh@me.umn.edu>
Contributed screen buffer to ppm screen shot routine.
Rich has also helped in the early development of the Flight Gear "altitude
hold autopilot module" by teaching Curt Olson the basics of Control Theory
and helping him code and debug early versions. Curt's "Boss" Bob Hain
also contributed <bob@me.umn.edu>. Further details available at:
http://www.menet.umn.edu/~curt/fgfs/Docs/Autopilot/AltitudeHold/AltitudeHold.html
Rich's Homepage: http://www.menet.umn.edu/~kaszeta
Tom Knienieder <tom@knienieder.com>
Ported Steve's Audio library first to OpenBSD and IRIX and
after that also to Win32
David Megginson <david@megginson.com>
SimGear property manager/registry
Curt Olson <curt@flightgear.org>
Curt is responsible for overall project and source code management.
He has his hands in many of the areas.
Petter Reinholdtsen <pere@games.no>
Incorporated the Gnu automake/autoconf system (with libtool).
This should streamline and standardize the build process for all
Unix-like platforms. It should have little effect on IDE type
environments since the don't use the Unix make system.
Paul Schlyter <pausch@saaf.se>
Mr. Schlyter provided Durk Talsma with all the information
he needed to write the astro code. Mr. S. is also willing
to answer astro-related questions whenever one needs to.
http://welcome.to/pausch
Durk Talsma <d.talsma@chello.nl>
Accurate Sun, Moon, and Planets.
Sun changes color based on position in sky.
Moon has correct phase and blends well into the sky.
Planets are correctly positioned and have proper magnitude.
Added time zone support in the SGTime class.
Help with time functions, gui, and other misc stuff.
http://people.a2000.nl/dtals
Mark Vallevand <Mark.Vallevand@UNISYS.com>
Contributed some METAR parsing code.
Contributed some win32 screen printing routines.
Gary R. Van Sickle <tiberius@braemarinc.com>
Contributed some initial GameGLUT support and other fixes.
Has done some interesting preliminary work on a binary file format
http://www.woodsoup.org/projs/ORKiD/fgfs.htm
Has set up a 'Cygwin Tips' site that has been very helpful to many
people in getting a Cygwin Unix-on-Windows build environment set up
so they can build FG effectively.
http://www.woodsoup.org/projs/ORKiD/cygwin.htm
Norman Vine <nhv@yahoo.com>
Provided more than uncountable URL's to the "FlightGear Community".
Many performance optimizations throughout the code.
Lots of windoze related contributions.
Contributed wgs84 distance and course routines.
Contributed a great circle route autopilot mode based on wgs84 routines.
Ed Williams <Ed_Williams@compuserve.com>
Contributed magnetic variation code (impliments Nima WMM 2000)
We've also borrowed from Ed's wonderful aviation formulary at various
times as well.
http://www.best.com/~williams/index.html
Jean-Claude Wippler <jcw@equi4.com>
Author of MetaKit - a portable, embeddible database with a portable
data file format. This software is not GPL'd but the author is kindly
allowing us to bundle MetaKit with our code. MetaKit has a liberal
X/MIT-style license. Please see the following URL for more info:
http://www.equi4.com/metakit
WoodSoup Project http://www.woodsoup.org
Provided computing resources and services so that the Flight Gear
project could have real home. This includes, web services,
ftp services, shell accounts, email lists, dns services, etc.
Robert Allan Zeh <raz@cmg.FCNBD.COM>
Helped me tremendously in figuring out the Cygnus win32 compiler and
how to link with .dll's. With out him the first runable win32
version of FG would have been impossible.
NOTE:
----
THIS DOCUMENT WAS INITIALLY WRITTEN BY
Curt L. Olson <curt@flightgear.org>
05 Jul 2000 Removed non-SimGear entries (CLO)
08 Mar 2000 CONTENTS RESEARCHED AND UPDATED by
Oliver Delise <delise@mail.isis.de>

View File

@@ -1,330 +0,0 @@
/* 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 if you have gdbm installed system wide. */
#undef HAVE_GDBM
/* Define if you have zlib installed system wide. */
#undef HAVE_ZLIB
/* 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). */

View File

@@ -102,7 +102,7 @@ for exdir in $exdirs ; do
mylibdir="${exdir}/lib${subexdir}"
wi_EXTRA_LDIR($mylibdir)
progdir="${exdir}/bin${subexdirr}"
progdir="${exdir}/bin${subexdir}"
wi_EXTRA_PDIR($progdir)
fi
done
@@ -392,3 +392,24 @@ if test "$have_timezone" = no; then
AC_MSG_RESULT(no))
fi
])dnl
## AC_BZ_SET_COMPILER: Addition by Theodore Papadopoulo
## Patch by Jim McKelvey: change sed -e 's/ /@/g' to sed -e 's/ /@/'
AC_DEFUN(AC_SG_SET_COMPILER,
[cxxwith=`echo $1 | sed -e 's/ /@/'`
case "$cxxwith" in
*:*@*) # Full initialization syntax
CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)@.*/\1/p'`
CXXFLAGS=`echo "$cxxwith" | sed -n -e 's/.*:.*@\(.*\)/\1/p'`
;;
*:*) # Simple initialization syntax
CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)/\1/p'`
CXXFLAGS=$3
;;
*) # Default values
CXX=$2
CXXFLAGS=$3
CC="$2 --c"
## CFLAGS=
;;
esac])

140
aclocal.m4 vendored
View File

@@ -1,140 +0,0 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file 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([AC_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", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
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])])
#
# 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([,]))])

39
am2dsp.cfg Normal file
View File

@@ -0,0 +1,39 @@
type = StaticLibrary,Multithreaded,
exclude_dir = threads
include_path = .
include_path = ..
include_path = .\SimGear
include_path = .\SimGear\metakit-2.4.3\include
include_path = ..\SimGear\zlib-1.1.4
define = HAVE_CONFIG_H
add_project = .\SimGear\metakit-2.4.3\win\msvc60\mklib.dsp,mklib
add_project = .\SimGear\zlib.dsp,zlib
# Rule to create simgear_config.h
add_source_file = SOURCE=.\simgear\simgear_config.h.vc5\
\
!IF "$(CFG)" == "SimGear - Win32 Release"\
\
# Begin Custom Build - Creating config.h\
InputPath=.\simgear\simgear_config.h.vc5\
\
".\simgear\simgear_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
\
# End Custom Build\
\
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\
\
# Begin Custom Build - Creating config.h\
InputPath=.\simgear\simgear_config.h.vc5\
\
".\simgear\simgear_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
\
# End Custom Build\
\
!ENDIF\

52
autogen.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/sh
OSTYPE=`uname -s`
MACHINE=`uname -m`
AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\.\([0-9]*\).*/\1/'`
if test $AUTO_MAKE_VERSION -lt 15; then
echo ""
echo "You need to upgrade to automake version 1.5 or greater."
echo "Most distributions have packages available to install or you can"
echo "find the source for the most recent version at"
echo "ftp://ftp.gnu.org/gnu/automake"
exit 1
fi
echo "Host info: $OSTYPE $MACHINE"
echo -n " automake: `automake --version | head -1 | awk '{print $4}'`"
echo " ($AUTO_MAKE_VERSION)"
echo ""
echo "Running aclocal"
aclocal
echo "Running autoheader"
autoheader
if [ ! -e simgear/simgear_config.h.in ]; then
echo "ERROR: autoheader didn't create simgear/simgear_config.h.in!"
exit 1
fi
echo "Running automake --add-missing"
automake --add-missing
echo "Running autoconf"
autoconf
if [ ! -e configure ]; then
echo "ERROR: configure was not created!"
exit 1
fi
echo ""
echo "======================================"
if [ -f config.cache ]; then
echo "config.cache exists. Removing the config.cache file will force"
echo "the ./configure script to rerun all it's tests rather than using"
echo "the previously cached values."
echo ""
fi
echo "Now you are ready to run './configure'"
echo "======================================"

410
configure.ac Normal file
View File

@@ -0,0 +1,410 @@
dnl Process this file with aclocal ; automake -a ; autoconf to produce a
dnl working configure script.
dnl
dnl $Id$
AC_INIT
AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
# Require at least automake 2.52
AC_PREREQ(2.52)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.3.1)
dnl Specify KAI C++ compiler and flags.
dnl Borrowed with slight modification from blitz distribution.
AC_ARG_WITH(cxx,
[ --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
[case "$withval" in
KCC*) # KAI C++ http://www.kai.com/
echo "Configuring for KAI C++"
AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
CXX_OPTIMIZE_FLAGS=="+K3 -O3"
CXX_DEBUG_FLAGS="-g +K0"
;;
esac
])
echo CXX = $CXX
echo CC = $CC
dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
# Used on the Irix platform
AR="ar"
ARFLAGS="cru"
OS=`uname -s`
if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
if test "$CXX" = "CC"; then
AR="CC -ar"
ARFLAGS="-o"
fi
fi
AC_SUBST(AR)
AC_SUBST(ARFLAGS)
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
# 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], 1, [Define for no logging output])
fi
# Specify if we want to build with Norman's jpeg image server support.
# This requires libjpeg to be installed and available.
# Default to with_jpeg_server=no
JPEGLIB=''
AC_ARG_WITH(jpeg_factory, [ --with-jpeg-factory Include Norman's jpeg image factory support code])
if test "x$with_jpeg_factory" = "xyes" ; then
echo "Building with Norman's jpeg image factory support"
AC_CHECK_LIB(jpeg, jpeg_start_compress)
if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
echo
echo "In order to build the jpeg factory code you need libjpeg installed."
echo "otherwise please configure with the --with-jpeg-sever=no option"
echo
echo "libjpeg is available at :"
echo " ftp://ftp.uu.net in the directory graphics/jpeg"
exit 1
fi
else
echo "Building without Norman's jpeg image server support"
fi
AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
dnl Check for MS Windows environment
AC_CHECK_HEADER(windows.h)
AC_EGREP_CPP(yes,
[#ifdef __MINGW32__
yes
#endif
],is_mingw=yes, is_mingw=no)
echo "IS_MINGW = $is_mingw"
AM_CONDITIONAL(IS_MINGW, test "x$is_mingw" = "xyes")
AC_EGREP_CPP(yes,
[#ifdef __CYGWIN__
yes
#endif
],is_cygwin=yes, is_cygwin=no)
echo "IS_CYGWIN = $is_cygwin"
AM_CONDITIONAL(IS_CYGWIN, test "x$is_cygwin" = "xyes")
if test "x$HOSTTYPE" != "xmacintosh" -a "x$is_mingw" != "xyes"; then
dnl extra library and include directories
EXTRA_DIRS="/usr/X11R6"
if test -d /opt/X11R6 ; then
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
fi
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 X11 might be installed on Mac OS X, don't want to use it if it is.
if test "x$HOSTTYPE" != "xmacintosh" ; then
dnl Check for X11 (fancy)
AC_PATH_XTRA
fi
dnl Checks for libraries.
null_LIBS="$LIBS"
AC_CHECK_LIB(m, cos)
base_LIBS="$LIBS"
dnl Thread related checks
AC_CHECK_LIB(pthread, pthread_exit)
AC_CHECK_HEADER(pthread.h)
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
CXXFLAGS="$CXXFLAGS -D_REENTRANT"
CFLAGS="$CFLAGS -D_REENTRANT"
fi
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
AC_CHECK_LIB(socket, socket)
dnl X11 might be installed, but we don't want to use it for OSX -dw-
if test "x$HOSTTYPE" != "xmacintosh" ; then
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)
fi
dnl check for OpenGL related libraries
AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
if test "x$HOSTTYPE" = "xmacintosh" ; then
dnl Macintosh OSX
LIBS="$LIBS -framework OpenGL -framework GLUT"
elif test "x$ac_cv_header_windows_h" != "xyes" ; then
dnl Reasonable stuff for X-Windows based machines
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/fxmesa.h)
if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
AC_DEFINE([XMESA], 1, [Define for fxmesa])
AC_DEFINE([FX], 1, [Define for fxmesa])
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 libs
echo Win32 specific hacks...
AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
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"
if test "x$is_mingw" = "xyes" ; then
EXTRA_DIRS="${EXTRA_DIRS}"
fi
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 install the latest version of glut. If your"
echo "distribution doesn't provide a newer version, you can get the source"
echo "code 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" )
# The following are C++ items that need to be tested for with the c++
# compiler
AC_LANG_PUSH(C++)
dnl Check for "plib" without which we cannot go on
AC_CHECK_HEADER(plib/ul.h)
if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
echo
echo "You *must* have the plib library installed on your system to build"
echo "SimGear!"
echo
echo "Please see README.plib for more details."
echo
echo "configure aborted."
exit
fi
AC_MSG_CHECKING([for plib 1.6.0 or newer])
AC_TRY_RUN([
#include <plib/ul.h>
#define MIN_PLIB_VERSION 160
int main() {
int major, minor, micro;
if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
return -1;
}
return 0;
}
],
AC_MSG_RESULT(yes),
[AC_MSG_RESULT(wrong version);
AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
AC_MSG_RESULT(yes)
)
dnl Check for system installed metakit
AC_CHECK_HEADER(mk4.h)
if test "x$ac_cv_header_mk4_h" != "xyes"; then
echo
echo "Metakit not found, you will need to install this first."
echo "Please read the README.metakit for more information."
exit
fi
AC_LANG_POP
dnl Specify if we want logging (testing build) or not (release build)
dnl Check for system installed zlib
AC_CHECK_HEADER(zlib.h)
if test "x$ac_cv_header_zlib_h" != "xyes"; then
echo
echo "zlib not found, you will need to install this first."
echo "Please read the README.zlib for more information."
exit
fi
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS( \
fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
sys/stat.h sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
if test "x$ac_cv_header_stdint_h" = "xyes"; then
AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
fi
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 drand48 setitimer getitimer signal GetLocalTime rint getrusage )
AM_CONFIG_HEADER(simgear/simgear_config.h)
AC_CONFIG_FILES([ \
Makefile \
SimGear.spec \
src-libs/Makefile \
simgear/Makefile \
simgear/version.h \
simgear/bucket/Makefile \
simgear/debug/Makefile \
simgear/ephemeris/Makefile \
simgear/io/Makefile \
simgear/magvar/Makefile \
simgear/math/Makefile \
simgear/metar/Makefile \
simgear/misc/Makefile \
simgear/route/Makefile \
simgear/screen/Makefile \
simgear/serial/Makefile \
simgear/sky/Makefile \
simgear/sky/clouds3d/Makefile \
simgear/threads/Makefile \
simgear/timing/Makefile \
simgear/xgl/Makefile \
simgear/xml/Makefile \
])
AC_OUTPUT
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
echo -n "Automake version: ($AUTO_MAKE_VERSION) "
automake --version | head -1
if test "x$with_jpeg_factory" = "xyes"; then
echo "With JPEG Factory support"
else
echo "Without JPEG Factory support"
fi
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
echo "Threads: pthread lib found."
else
echo "Threads: no threads (pthread lib not found.)"
fi

View File

@@ -1,288 +0,0 @@
dnl Process this file with aclocal ; automake -a ; autoconf to produce a
dnl working configure script.
dnl
dnl $Id$
AC_INIT(simgear/bucket/newbucket.cxx)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.0.8)
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 Run configure in the gdbm subdir
dnl AC_CONFIG_SUBDIRS( simgear/gdbm )
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 gdbm
AC_CHECK_HEADER(gdbm.h)
if test "x$ac_cv_header_gdbm_h" = "xyes"; then
AC_DEFINE( HAVE_GDBM )
else
echo "no gdbm found, configuring and building."
fi
AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
dnl Check for system installed zlib
AC_CHECK_HEADER(zlib.h)
if test "x$ac_cv_header_zlib_h" = "xyes"; then
AC_DEFINE( HAVE_ZLIB )
else
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(simgear/config.h)
AC_OUTPUT( \
Makefile \
SimGear.spec \
simgear/Makefile \
simgear/version.h \
simgear/bucket/Makefile \
simgear/debug/Makefile \
simgear/gdbm/Makefile \
simgear/magvar/Makefile \
simgear/math/Makefile \
simgear/misc/Makefile \
simgear/screen/Makefile \
simgear/serial/Makefile \
simgear/xgl/Makefile \
simgear/zlib/Makefile \
)
AC_OUTPUT_COMMANDS([
if test "x$ac_cv_header_windows_h" = "xyes" ; then
cp simgear/gdbm/autoconf.h.cygwin32 simgear/gdbm/autoconf.h
fi
])
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
if test "x$ac_cv_header_gdbm_h" != "xyes"; then
echo "Building gdbm"
fi
if test "x$ac_cv_header_zlib_h" != "xyes"; then
echo "Building zlib"
fi

View File

@@ -1,42 +0,0 @@
#! /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 ../include/version.h src/simgear/version.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/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
ln -s ../../zlib/zlib.h src/simgear/zlib/zlib.h
ln -s ../../zlib/zconf.h src/simgear/zlib/zconf.h

8
simgear/.cvsignore Normal file
View File

@@ -0,0 +1,8 @@
Makefile
Makefile.in
simgear_config.h
simgear_config.h.in
stamp-h
stamp-h.in
stamp-h1
version.h

View File

@@ -1,38 +1,33 @@
if ENABLE_UNIX_SERIAL
SERIAL_DIRS = serial
if HAVE_THREADS
SGTHREAD_DIR = threads
else
SERIAL_DIRS =
SGTHREAD_DIR =
endif
if HAVE_GDBM
GDBM_DIRS =
else
GDBM_DIRS = gdbm
endif
# METAR_DIRS =
METAR_DIRS = metar
if HAVE_ZLIB
ZLIB_DIRS =
else
ZLIB_DIRS = zlib
endif
EXTRA_DIST = simgear_config.h.vc5 version.h.in
METAR_DIRS =
# METAR_DIRS = metar
EXTRA_DIST = version.h.in
include_HEADERS = compiler.h constants.h fg_traits.hxx fg_zlib.h version.h
include_HEADERS = \
compiler.h constants.h sg_inlines.h sg_traits.hxx sg_zlib.h version.h
SUBDIRS = \
bucket \
xml \
debug \
$(GDBM_DIRS) \
misc \
bucket \
ephemeris \
io \
magvar \
math \
$(METAR_DIRS) \
misc \
route \
screen \
$(SERIAL_DIRS) \
xgl \
$(ZLIB_DIRS)
serial \
sky \
$(SGTHREAD_DIR) \
timing \
xgl
DIST_SUBDIRS = $(SUBDIRS)

View File

@@ -0,0 +1,3 @@
.deps
Makefile
Makefile.in

View File

@@ -14,4 +14,4 @@ libsgbucket_a_SOURCES = newbucket.cxx
# $(top_builddir)/bucket/libsgbucket.a \
# $(top_builddir)/misc/libsgmisc.a
INCLUDES += -I$(top_builddir)
INCLUDES = -I$(top_srcdir)

View File

@@ -5,38 +5,139 @@
*
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <simgear_config.h>
#endif
#include <math.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
#include "newbucket.hxx"
// default constructor
SGBucket::SGBucket() {
}
// constructor for specified location
SGBucket::SGBucket(const double dlon, const double dlat) {
set_bucket(dlon, dlat);
}
// create an impossible bucket if false
SGBucket::SGBucket(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
SGBucket::SGBucket(const long int bindex) {
long int index = bindex;
lon = index >> 14;
index -= lon << 14;
lon -= 180;
lat = index >> 6;
index -= lat << 6;
lat -= 90;
y = index >> 3;
index -= y << 3;
x = index;
}
// default destructor
SGBucket::~SGBucket() {
}
// Set the bucket params for the specified lat and lon
void SGBucket::set_bucket( double *lonlat ) {
set_bucket( lonlat[0], lonlat[1] );
}
// Set the bucket params for the specified lat and lon
void SGBucket::set_bucket( double dlon, double dlat ) {
//
// latitude first
//
double span = sg_bucket_span( dlat );
double diff = dlon - (double)(int)dlon;
// cout << "diff = " << diff << " span = " << span << endl;
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
lon = (int)dlon;
} else {
lon = (int)dlon - 1;
}
// find subdivision or super lon if needed
if ( span < SG_EPSILON ) {
// polar cap
lon = 0;
x = 0;
} else if ( span <= 1.0 ) {
x = (int)((dlon - lon) / span);
} else {
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
lon = (int)( (int)(lon / span) * span);
} else {
// cout << " lon = " << lon
// << " tmp = " << (int)((lon-1) / span) << endl;
lon = (int)( (int)((lon + 1) / span) * span - span);
if ( lon < -180 ) {
lon = -180;
}
}
x = 0;
}
//
// then latitude
//
diff = dlat - (double)(int)dlat;
if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) {
lat = (int)dlat;
} else {
lat = (int)dlat - 1;
}
y = (int)((dlat - lat) * 8);
}
// Build the path name for this bucket
string FGBucket::gen_base_path() const {
string SGBucket::gen_base_path() const {
// long int index;
int top_lon, top_lat, main_lon, main_lat;
char hem, pole;
@@ -78,25 +179,64 @@ string FGBucket::gen_base_path() const {
hem, top_lon, pole, top_lat,
hem, main_lon, pole, main_lat);
FGPath path( raw_path );
SGPath path( raw_path );
return path.str();
}
// return width of the tile in degrees
double SGBucket::get_width() const {
return sg_bucket_span( get_center_lat() );
}
// return height of the tile in degrees
double SGBucket::get_height() const {
return SG_BUCKET_SPAN;
}
// return width of the tile in meters
double SGBucket::get_width_m() const {
double clat = (int)get_center_lat();
if ( clat > 0 ) {
clat = (int)clat + 0.5;
} else {
clat = (int)clat - 0.5;
}
double clat_rad = clat * SGD_DEGREES_TO_RADIANS;
double cos_lat = cos( clat_rad );
double local_radius = cos_lat * SG_EQUATORIAL_RADIUS_M;
double local_perimeter = 2.0 * local_radius * SGD_PI;
double degree_width = local_perimeter / 360.0;
return sg_bucket_span( get_center_lat() ) * degree_width;
}
// return height of the tile in meters
double SGBucket::get_height_m() const {
double perimeter = 2.0 * SG_EQUATORIAL_RADIUS_M * SGD_PI;
double degree_height = perimeter / 360.0;
return SG_BUCKET_SPAN * degree_height;
}
// find the bucket which is offset by the specified tile units in the
// X & Y direction. We need the current lon and lat to resolve
// ambiguities when going from a wider tile to a narrower one above or
// below. This assumes that we are feeding in
FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
FGBucket result( dlon, dlat );
double clat = result.get_center_lat() + dy * FG_BUCKET_SPAN;
SGBucket sgBucketOffset( double dlon, double dlat, int dx, int dy ) {
SGBucket result( dlon, dlat );
double clat = result.get_center_lat() + dy * SG_BUCKET_SPAN;
// walk dy units in the lat direction
result.set_bucket( dlon, clat );
// find the lon span for the new latitude
double span = bucket_span( clat );
double span = sg_bucket_span( clat );
// walk dx units in the lon direction
double tmp = dlon + dx * span;
@@ -113,7 +253,7 @@ FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
// calculate the offset between two buckets
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ) {
// Latitude difference
double c1_lat = b1.get_center_lat();
@@ -121,12 +261,12 @@ void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
double diff_lat = c2_lat - c1_lat;
#ifdef HAVE_RINT
*dy = (int)rint( diff_lat / FG_BUCKET_SPAN );
*dy = (int)rint( diff_lat / SG_BUCKET_SPAN );
#else
if ( diff_lat > 0 ) {
*dy = (int)( diff_lat / FG_BUCKET_SPAN + 0.5 );
*dy = (int)( diff_lat / SG_BUCKET_SPAN + 0.5 );
} else {
*dy = (int)( diff_lat / FG_BUCKET_SPAN - 0.5 );
*dy = (int)( diff_lat / SG_BUCKET_SPAN - 0.5 );
}
#endif
@@ -135,10 +275,10 @@ void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
double c2_lon = b2.get_center_lon();
double diff_lon = c2_lon - c1_lon;
double span;
if ( bucket_span(c1_lat) <= bucket_span(c2_lat) ) {
span = bucket_span(c1_lat);
if ( sg_bucket_span(c1_lat) <= sg_bucket_span(c2_lat) ) {
span = sg_bucket_span(c1_lat);
} else {
span = bucket_span(c2_lat);
span = sg_bucket_span(c2_lat);
}
#ifdef HAVE_RINT

View File

@@ -5,23 +5,27 @@
*
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
/** \file newbucket.hxx
* A class and associated utiltity functions to manage world scenery tiling.
*/
#ifndef _NEWBUCKET_HXX
#define _NEWBUCKET_HXX
@@ -29,102 +33,46 @@
#include <simgear/compiler.h>
#include <simgear/constants.h>
#ifdef FG_HAVE_STD_INCLUDES
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
# include <cstdio> // sprintf()
# include <iostream>
#else
# include <math.h>
# include <stdio.h> // sprintf()
# include <iostream.h>
#endif
#include STL_IOSTREAM
// I don't understand ... <math.h> or <cmath> should be included
// already depending on how you defined FG_HAVE_STD_INCLUDES, but I
// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
// can go ahead and add this -- CLO
#ifdef __MWERKS__
# include <math.h> // needed fabs()
SG_USING_STD(sprintf);
SG_USING_STD(fabs);
#endif
#include STL_STRING
FG_USING_STD(string);
SG_USING_STD(string);
#if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
FG_USING_STD(ostream);
#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
SG_USING_STD(ostream);
#endif
/**
* standard size of a bucket in degrees (1/8 of a degree)
*/
#define SG_BUCKET_SPAN 0.125
#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 {
private:
double cx, cy; // centerpoint (lon, lat) in degrees of bucket
int lon; // longitude index (-180 to 179)
int lat; // latitude index (-90 to 89)
int x; // x subdivision (0 to 7)
int y; // y subdivision (0 to 7)
public:
// default constructor
FGBucket();
// create a bucket which would contain the specified lon/lat
FGBucket(const double lon, const double lat);
// 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() 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& );
};
/**
* half of a standard SG_BUCKET_SPAN
*/
#define SG_HALF_BUCKET_SPAN ( 0.5 * SG_BUCKET_SPAN )
// return the horizontal tile span factor based on latitude
inline double bucket_span( double l ) {
static double sg_bucket_span( double l ) {
if ( l >= 89.0 ) {
return 360.0;
} else if ( l >= 88.0 ) {
@@ -159,185 +107,229 @@ inline double bucket_span( double l ) {
}
// Set the bucket params for the specified lat and lon
inline void FGBucket::set_bucket( double dlon, double dlat ) {
//
// latitude first
//
double span = bucket_span( dlat );
double diff = dlon - (double)(int)dlon;
/**
* A class to manage world scenery tiling.
* This class encapsulates the world tiling scheme. It provides ways
* to calculate a unique tile index from a lat/lon, and it can provide
* information such as the dimensions of a given tile.
*/
// cout << "diff = " << diff << " span = " << span << endl;
class SGBucket {
if ( (dlon >= 0) || (fabs(diff) < FG_EPSILON) ) {
lon = (int)dlon;
} else {
lon = (int)dlon - 1;
private:
double cx, cy; // centerpoint (lon, lat) in degrees of bucket
int lon; // longitude index (-180 to 179)
int lat; // latitude index (-90 to 89)
int x; // x subdivision (0 to 7)
int y; // y subdivision (0 to 7)
public:
/**
* Default constructor.
*/
SGBucket();
/**
* Construct a bucket given a specific location.
* @param dlon longitude specified in degrees
* @param dlat latitude specified in degrees
*/
SGBucket(const double dlon, const double dlat);
/** Construct a bucket.
* @param is_good if false, create an invalid bucket. This is
* useful * if you are comparing cur_bucket to last_bucket and
* you want to * make sure last_bucket starts out as something
* impossible.
*/
SGBucket(const bool is_good);
/** Construct a bucket given a unique bucket index number.
* @param bindex unique bucket index
*/
SGBucket(const long int bindex);
/**
* Default destructor.
*/
~SGBucket();
/**
* Reset a bucket to represent a new lat and lon
* @param dlon longitude specified in degrees
* @param dlat latitude specified in degrees
*/
void set_bucket( double dlon, double dlat );
/**
* Reset a bucket to represent a new lat and lon
* @param lonlat an array of double[2] holding lon and lat
* (specified) in degrees
*/
void set_bucket( double *lonlat );
/**
* Create an impossible bucket.
* This is useful if you are comparing cur_bucket to last_bucket
* and you want to make sure last_bucket starts out as something
* impossible.
*/
inline void make_bad() {
set_bucket(0.0, 0.0);
lon = -1000;
}
// find subdivision or super lon if needed
if ( span < FG_EPSILON ) {
// polar cap
lon = 0;
x = 0;
} else if ( span <= 1.0 ) {
x = (int)((dlon - lon) / span);
} else {
if ( (dlon >= 0) || (fabs(diff) < FG_EPSILON) ) {
lon = (int)( (int)(lon / span) * span);
/**
* Generate the unique scenery tile index for this bucket
*
* 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)
* @return tile index
*/
inline long int gen_index() const {
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x;
}
/**
* Generate the unique scenery tile index for this bucket in ascii
* string form.
* @return tile index in string form
*/
inline string gen_index_str() const {
char tmp[20];
sprintf(tmp, "%ld",
(((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
return (string)tmp;
}
/**
* Build the base path name for this bucket.
* @return base path in string form
*/
string gen_base_path() const;
/**
* @return the center lon of a tile.
*/
inline double get_center_lon() const {
double span = sg_bucket_span( lat + y / 8.0 + SG_HALF_BUCKET_SPAN );
if ( span >= 1.0 ) {
return lon + span / 2.0;
} else {
// cout << " lon = " << lon
// << " tmp = " << (int)((lon-1) / span) << endl;
lon = (int)( (int)((lon + 1) / span) * span - span);
if ( lon < -180 ) {
lon = -180;
}
return lon + x * span + span / 2.0;
}
x = 0;
}
//
// then latitude
//
diff = dlat - (double)(int)dlat;
if ( (dlat >= 0) || (fabs(diff) < FG_EPSILON) ) {
lat = (int)dlat;
} else {
lat = (int)dlat - 1;
/**
* @return the center lat of a tile.
*/
inline double get_center_lat() const {
return lat + y / 8.0 + SG_HALF_BUCKET_SPAN;
}
y = (int)((dlat - lat) * 8);
}
/**
* @return the width of the tile in degrees.
*/
double get_width() const;
/**
* @return the height of the tile in degrees.
*/
double get_height() const;
/**
* @return the width of the tile in meters.
*/
double get_width_m() const;
/**
* @return the height of the tile in meters.
*/
double get_height_m() const;
// Informational methods.
/**
* @return the lon of the lower left corner of this tile.
*/
inline int get_lon() const { return lon; }
/**
* @return the lat of the lower left corner of this tile.
*/
inline int get_lat() const { return lat; }
/**
* @return the x coord within the 1x1 degree chunk this tile.
*/
inline int get_x() const { return x; }
/**
* @return the y coord within the 1x1 degree chunk this tile.
*/
inline int get_y() const { return y; }
// friends
friend ostream& operator<< ( ostream&, const SGBucket& );
friend bool operator== ( const SGBucket&, const SGBucket& );
};
// default constructor
inline FGBucket::FGBucket() {}
/**
* \relates SGBucket
* Return the bucket which is offset from the specified dlon, dlat by
* the specified tile units in the X & Y direction.
* @param dlon starting lon in degrees
* @param dlat starting lat in degrees
* @param x number of bucket units to offset in x (lon) direction
* @param y number of bucket units to offset in y (lat) direction
* @return offset bucket
*/
SGBucket sgBucketOffset( double dlon, double dlat, int x, int y );
// constructor for specified location
inline FGBucket::FGBucket(const double dlon, const double dlat) {
set_bucket(dlon, 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;
lon = index >> 14;
index -= lon << 14;
lon -= 180;
lat = index >> 6;
index -= lat << 6;
lat -= 90;
y = index >> 3;
index -= y << 3;
x = index;
}
// default destructor
inline FGBucket::~FGBucket() {}
// Generate the unique scenery tile index for this bucket
//
// 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)
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 {
double span = bucket_span( lat + y / 8.0 + FG_HALF_BUCKET_SPAN );
if ( span >= 1.0 ) {
return lon + span / 2.0;
} else {
return lon + x * span + span / 2.0;
}
}
// return the center lat of a tile
inline double FGBucket::get_center_lat() const {
return lat + y / 8.0 + FG_HALF_BUCKET_SPAN;
}
// 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 );
// calculate the offset between two buckets
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy );
/*
// Given a lat/lon, fill in the local tile index array
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
*/
/**
* \relates SGBucket
* Calculate the offset between two buckets (in quantity of buckets).
* @param b1 bucket 1
* @param b2 bucket 2
* @param dx offset distance (lon) in tile units
* @param dy offset distance (lat) in tile units
*/
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
/**
* Write the bucket lon, lat, x, and y to the output stream.
* @param out output stream
* @param b bucket
*/
inline ostream&
operator<< ( ostream& out, const FGBucket& b )
operator<< ( ostream& out, const SGBucket& b )
{
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
}
/**
* Compare two bucket structures for equality.
* @param b1 bucket 1
* @param b2 bucket 2
* @return comparison result
*/
inline bool
operator== ( const FGBucket& b1, const FGBucket& b2 )
operator== ( const SGBucket& b1, const SGBucket& b2 )
{
return ( b1.lon == b2.lon &&
b1.lat == b2.lat &&

View File

@@ -1,52 +1,83 @@
/**************************************************************************
* compiler.h -- C++ Compiler Portability Macros
*
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
*
**************************************************************************/
#ifndef _COMPILER_H
#define _COMPILER_H
/** \file compiler.h
* A set of defines to encapsulate compiler and platform differences.
* Please refer to the source code for full documentation on this file.
*
* Here is a summary of what this file does.
*
* (1) Defines macros for some STL includes which may be affected
* by file name length limitations.
*
* (2) Defines macros for some features not supported by all C++ compilers.
*
* (3) Defines 'explicit' as a null macro if the compiler doesn't support
* the explicit keyword.
*
* (4) Defines 'typename' as a null macro if the compiler doesn't support
* the typename keyword.
*
* (5) Defines bool, true and false if the compiler doesn't do so.
*
* (6) Defines SG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
* supports calling a function template by providing its template
* arguments explicitly.
*
* (7) Defines SG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
*
* (8) Defines SG_NO_ARROW_OPERATOR if the compiler is unable
* to support operator->() for iterators.
*
* (9) Defines SG_USE_EXCEPTIONS if the compiler supports exceptions.
* Note: no FlightGear code uses exceptions.
*
* (10) Define SG_NAMESPACES if the compiler supports namespaces.
*
* (11) SG_MATH_FN_IN_NAMESPACE_STD -- not used??
*
* (12) Define SG_HAVE_STD if std namespace is supported.
*
* (13) Defines SG_CLASS_PARTIAL_SPECIALIZATION if the compiler
* supports partial specialization of class templates.
*
* (14) Defines SG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
*
* (15) Defines SG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
*
* (16) Define SG_MATH_EXCEPTION_CLASH if math.h defines an exception class
* that clashes with the one defined in <stdexcept>.
*/
// What this file does.
// (1) Defines macros for some STL includes which may be affected
// by file name length limitations.
// (2) Defines macros for some features not supported by all C++ compilers.
// (3) Defines 'explicit' as a null macro if the compiler doesn't support
// the explicit keyword.
// (4) Defines 'typename' as a null macro if the compiler doesn't support
// the typename keyword.
// (5) Defines bool, true and false if the compiler doesn't do so.
// (6) Defines FG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
// supports calling a function template by providing its template
// arguments explicitly.
// (7) Defines FG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
// (8) Defines FG_NO_ARROW_OPERATOR if the compiler is unable
// to support operator->() for iterators.
// (9) Defines FG_USE_EXCEPTIONS if the compiler supports exceptions.
// Note: no FlightGear code uses exceptions.
// (10) Define FG_NAMESPACES if the compiler supports namespaces.
// (11) FG_MATH_FN_IN_NAMESPACE_STD -- not used??
// (12) Define FG_HAVE_STD if std namespace is supported.
// (13) Defines FG_CLASS_PARTIAL_SPECIALIZATION if the compiler
// supports partial specialization of class templates.
// (14) Defines FG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
// (15) Defines FG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
// (16) Define FG_MATH_EXCEPTION_CLASH if math.h defines an exception class
// that clashes with the one defined in <stdexcept>.
#ifndef _SG_COMPILER_H
#define _SG_COMPILER_H
/*
* Helper macro SG_STRINGIZE:
* Converts the parameter X to a string after macro replacement
* on X has been performed.
*/
#define SG_STRINGIZE(X) SG_DO_STRINGIZE(X)
#define SG_DO_STRINGIZE(X) #X
#ifdef __GNUC__
# if __GNUC__ == 2
@@ -57,42 +88,96 @@
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip.h>
# define STL_IOSTREAM <iostream.h>
# define STL_ITERATOR <iterator.h>
# define STL_FSTREAM <fstream.h>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream.h>
# define FG_NEED_AUTO_PTR
# define FG_NO_DEFAULT_TEMPLATE_ARGS
# define FG_INCOMPLETE_FUNCTIONAL
# define FG_NO_ARROW_OPERATOR
# define SG_NEED_AUTO_PTR
# define SG_NO_DEFAULT_TEMPLATE_ARGS
# define SG_INCOMPLETE_FUNCTIONAL
# define SG_NO_ARROW_OPERATOR
# elif __GNUC_MINOR__ >= 8
// g++-2.8.x and egcs-1.x
# define FG_EXPLICIT_FUNCTION_TMPL_ARGS
# define FG_NEED_AUTO_PTR
# define FG_MEMBER_TEMPLATES
# define FG_NAMESPACES
# define FG_HAVE_STD
# define FG_HAVE_STREAMBUF
# define FG_CLASS_PARTIAL_SPECIALIZATION
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
# define SG_NEED_AUTO_PTR
# define SG_MEMBER_TEMPLATES
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_HAVE_STREAMBUF
# define SG_CLASS_PARTIAL_SPECIALIZATION
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# endif
# elif __GNUC__ == 3
// g++-3.0.x
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
# define SG_NEED_AUTO_PTR
# define SG_MEMBER_TEMPLATES
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_HAVE_STREAMBUF
# define SG_CLASS_PARTIAL_SPECIALIZATION
# define SG_HAVE_STD_INCLUDES
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# else
# error Time to upgrade. GNU compilers < 2.7 not supported
# endif
# define SG_COMPILER_STR "GNU C++ version " SG_STRINGIZE(__GNUC__) "." SG_STRINGIZE(__GNUC_MINOR__)
#endif // __GNUC__
#if defined( __MINGW32__ )
# define bcopy(from, to, n) memcpy(to, from, n)
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
# define snprintf _snprintf
#endif
/* KAI C++ */
#if defined(__KCC)
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_HAVE_STREAMBUF
# define SG_HAVE_TRAITS
# define SG_HAVE_STD_INCLUDES
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# define SG_COMPILER_STR "Kai C++ version " SG_STRINGIZE(__KCC_VERSION)
#endif // __KCC
//
// Metrowerks
//
@@ -100,15 +185,16 @@
/*
CodeWarrior compiler from Metrowerks, Inc.
*/
# define FG_HAVE_TRAITS
# define FG_HAVE_STD_INCLUDES
# define FG_HAVE_STD
# define FG_NAMESPACES
# define SG_HAVE_TRAITS
# define SG_HAVE_STD_INCLUDES
# define SG_HAVE_STD
# define SG_NAMESPACES
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
@@ -117,41 +203,51 @@
# define bcopy(from, to, n) memcpy(to, from, n)
// -rp- please use FG_MEM_COPY everywhere !
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
// #define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
// -dw- currently used glut has no game mode stuff
# define GLUT_WRONG_VERSION
#endif
# define SG_COMPILER_STR "Metrowerks CodeWarrior C++ version " SG_STRINGIZE(__MWERKS__)
#endif // __MWERKS__
//
// Microsoft compilers.
//
#ifdef _MSC_VER
# if _MSC_VER == 1200 // msvc++ 6.0
# define FG_NAMESPACES
# define FG_HAVE_STD
# define FG_HAVE_STD_INCLUDES
# define FG_HAVE_STREAMBUF
# define bcopy(from, to, n) memcpy(to, from, n)
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
# if _MSC_VER == 1200 // msvc++ 6.0
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_HAVE_STD_INCLUDES
# define SG_HAVE_STREAMBUF
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# define snprintf _snprintf
# pragma warning(disable: 4786) // identifier was truncated to '255' characters
# pragma warning(disable: 4244) // conversion from double to float
# pragma warning(disable: 4305) //
# elif _MSC_VER == 1100 // msvc++ 5.0
# error MSVC++ 5.0 still to be supported...
# else
# error What version of MSVC++ is this?
# endif
#endif
# define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
#endif // _MSC_VER
#ifdef __BORLANDC__
# if defined(HAVE_SGI_STL_PORT)
@@ -161,7 +257,7 @@
# define STL_ALGORITHM "algorithm"
# define STL_FUNCTIONAL "functional"
# define FG_MATH_EXCEPTION_CLASH
# define SG_MATH_EXCEPTION_CLASH
# else
@@ -171,16 +267,19 @@
# define STL_STDEXCEPT <stdexcept>
# define STL_STRSTREAM <strstream>
# define FG_INCOMPLETE_FUNCTIONAL
# define SG_INCOMPLETE_FUNCTIONAL
# endif // HAVE_SGI_STL_PORT
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STRING <string>
# define FG_NO_DEFAULT_TEMPLATE_ARGS
# define FG_NAMESPACES
// # define FG_HAVE_STD
# define SG_NO_DEFAULT_TEMPLATE_ARGS
# define SG_NAMESPACES
// # define SG_HAVE_STD
# define SG_COMPILER_STR "Borland C++ version " SG_STRINGIZE(__BORLANDC__)
#endif // __BORLANDC__
@@ -189,23 +288,40 @@
//
#if defined ( sgi ) && !defined( __GNUC__ )
# define FG_HAVE_NATIVE_SGI_COMPILERS
# define SG_HAVE_NATIVE_SGI_COMPILERS
# define FG_EXPLICIT_FUNCTION_TMPL_ARGS
# define FG_NEED_AUTO_PTR
# define FG_MEMBER_TEMPLATES
# define FG_NAMESPACES
# define FG_HAVE_STD
# define FG_CLASS_PARTIAL_SPECIALIZATION
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
# define SG_NEED_AUTO_PTR
# define SG_MEMBER_TEMPLATES
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_CLASS_PARTIAL_SPECIALIZATION
# define SG_HAVE_TRAITS
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip.h>
# define STL_IOSTREAM <iostream.h>
# define STL_ITERATOR <iterator.h>
# define STL_FSTREAM <fstream.h>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# define STL_STRSTREAM <strstream.h>
// # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
// typedef void PFNGLPOINTPARAMETERFEXTPROC
#define glPointParameterfEXT glPointParameterfSGIS
#define glPointParameterfvEXT glPointParameterfvSGIS
#pragma set woff 1001,1012,1014,1116,1155,1172,1174
#pragma set woff 1401,1460,1551,1552,1681
#ifdef __cplusplus
#pragma set woff 1682,3303
#endif
# define SG_COMPILER_STR "SGI Irix compiler version " SG_STRINGIZE(_COMPILER_VERSION)
#endif // Native SGI compilers
@@ -221,65 +337,95 @@
# else
extern void *memmove(void *, const void *, size_t);
# endif // __cplusplus
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
#endif // sun
//
// Intel C++ Compiler
//
#if defined(__ICC) || defined (__ECC)
# define SG_NAMESPACES
# define SG_HAVE_STD
# define SG_HAVE_STREAMBUF
# define SG_HAVE_TRAITS
# define SG_HAVE_STD_INCLUDES
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_ITERATOR <iterator>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# define SG_COMPILER_STR "Intel C++ version " SG_STRINGIZE(__ICC)
#endif // __ICC
//
// No user modifiable definitions beyond here.
//
#ifdef FG_NEED_EXPLICIT
#ifdef SG_NEED_EXPLICIT
# define explicit
#endif
#ifdef FG_NEED_TYPENAME
#ifdef SG_NEED_TYPENAME
# define typename
#endif
#ifdef FG_NEED_MUTABLE
#ifdef SG_NEED_MUTABLE
# define mutable
#endif
#ifdef FG_NEED_BOOL
#ifdef SG_NEED_BOOL
typedef int bool;
# define true 1
# define false 0
#endif
#ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
# define FG_NULL_TMPL_ARGS <>
#ifdef SG_EXPLICIT_FUNCTION_TMPL_ARGS
# define SG_NULL_TMPL_ARGS <>
#else
# define FG_NULL_TMPL_ARGS
# define SG_NULL_TMPL_ARGS
#endif
#ifdef FG_CLASS_PARTIAL_SPECIALIZATION
# define FG_TEMPLATE_NULL template<>
#ifdef SG_CLASS_PARTIAL_SPECIALIZATION
# define SG_TEMPLATE_NULL template<>
#else
# define FG_TEMPLATE_NULL
# define SG_TEMPLATE_NULL
#endif
// FG_NO_NAMESPACES is a hook so that users can disable namespaces
// SG_NO_NAMESPACES is a hook so that users can disable namespaces
// without having to edit library headers.
#if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
# define FG_NAMESPACE(X) namespace X {
# define FG_NAMESPACE_END }
# define FG_USING_NAMESPACE(X) using namespace X
#if defined(SG_NAMESPACES) && !defined(SG_NO_NAMESPACES)
# define SG_NAMESPACE(X) namespace X {
# define SG_NAMESPACE_END }
# define SG_USING_NAMESPACE(X) using namespace X
# else
# define FG_NAMESPACE(X)
# define FG_NAMESPACE_END
# define FG_USING_NAMESPACE(X)
# define SG_NAMESPACE(X)
# define SG_NAMESPACE_END
# define SG_USING_NAMESPACE(X)
#endif
# ifdef FG_HAVE_STD
# define FG_USING_STD(X) using std::X
/** \def SG_USING_STD(x)
* Expands to using std::x if SG_HAVE_STD is defined
*/
# ifdef SG_HAVE_STD
# define SG_USING_STD(X) using std::X
# define STD std
# else
# define FG_USING_STD(X)
# define SG_USING_STD(X)
# define STD
# endif
// Additional <functional> implementation from SGI STL 3.11
// Adapter function objects: pointers to member functions
#ifdef FG_INCOMPLETE_FUNCTIONAL
#ifdef SG_INCOMPLETE_FUNCTIONAL
template <class _Ret, class _Tp>
class const_mem_fun_ref_t
@@ -298,6 +444,6 @@ template <class _Ret, class _Tp>
inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
{ return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
#endif // FG_INCOMPLETE_FUNCTIONAL
#endif // SG_INCOMPLETE_FUNCTIONAL
#endif // _COMPILER_H
#endif // _SG_COMPILER_H

View File

@@ -4,140 +4,129 @@
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#ifndef _SUPPORTGEAR_CONSTANTS_H
#define _SUPPORTGEAR_CONSTANTS_H
/** \file constants.h
* Various constant definitions.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef _SG_CONSTANTS_H
#define _SG_CONSTANTS_H
#include <simgear/compiler.h>
#ifdef FG_HAVE_STD_INCLUDES
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
#else
# ifdef FG_MATH_EXCEPTION_CLASH
# ifdef SG_MATH_EXCEPTION_CLASH
# define exception C_exception
# endif
# include <math.h>
#endif
#include <plib/sg.h>
// Make sure PI is defined in its various forms
// PI, only PI, and nothing but PI
#ifdef M_PI
# define FG_PI M_PI
#else
# define FG_PI 3.14159265358979323846
#endif
// SG_PI and SGD_PI (float and double) come from plib/sg.h
// 2 * PI
#define FG_2PI 6.28318530717958647692
/** 2 * PI */
#define SGD_2PI 6.28318530717958647692
// PI / 2
/** PI / 2 */
#ifdef M_PI_2
# define FG_PI_2 M_PI_2
# define SGD_PI_2 M_PI_2
#else
# define FG_PI_2 1.57079632679489661923
# define SGD_PI_2 1.57079632679489661923
#endif
// PI / 4
#define FG_PI_4 0.78539816339744830961
/** PI / 4 */
#define SGD_PI_4 0.78539816339744830961
#ifndef M_E
# define M_E 2.7182818284590452354
/** \def SG_E "e" */
#ifdef M_E
# define SG_E M_E
#else
# define SG_E 2.7182818284590452354
#endif
// ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator
#define ONE_SECOND 4.848136811E-6
/** pi/180/60/60, or about 100 feet at earths' equator */
#define SG_ONE_SECOND 4.848136811E-6
// Radius of Earth in kilometers at the equator. Another source had
// 6378.165 but this is probably close enough
#define EARTH_RAD 6378.155
/** Radius of Earth in kilometers at the equator. Another source had
* 6378.165 but this is probably close enough */
#define SG_EARTH_RAD 6378.155
// Earth parameters for WGS 84, taken from LaRCsim/ls_constants.h
// Value of earth radius from [8]
#define EQUATORIAL_RADIUS_FT 20925650. // ft
#define EQUATORIAL_RADIUS_M 6378138.12 // meter
// Radius squared
#define RESQ_FT 437882827922500. // ft
#define RESQ_M 40680645877797.1344 // meter
/** Value of earth radius from LaRCsim (ft) */
#define SG_EQUATORIAL_RADIUS_FT 20925650.
// Value of earth flattening parameter from ref [8]
//
// Note: FP = f
// E = 1-f
// EPS = sqrt(1-(1-f)^2)
//
#define FP 0.003352813178
#define E 0.996647186
#define EPS 0.081819221
#define INVG 0.031080997
/** Value of earth radius from LaRCsim (meter) */
#define SG_EQUATORIAL_RADIUS_M 6378138.12
// Time Related Parameters
#define MJD0 2415020.0
#define J2000 (2451545.0 - MJD0)
#define SIDRATE .9972695677
/** Radius squared (ft) */
#define SG_EQ_RAD_SQUARE_FT 437882827922500.
/** Radius squared (meter) */
#define SG_EQ_RAD_SQUARE_M 40680645877797.1344
// Conversions
// Degrees to Radians
#define DEG_TO_RAD 0.017453292 // deg*pi/180 = rad
/** Arc seconds to radians. (arcsec*pi)/(3600*180) = rad */
#define SG_ARCSEC_TO_RAD 4.84813681109535993589e-06
// Radians to Degrees
#define RAD_TO_DEG 57.29577951 // rad*180/pi = deg
/** Radians to arc seconds. (rad*3600*180)/pi = arcsec */
#define SG_RAD_TO_ARCSEC 206264.806247096355156
// Arc seconds to radians // (arcsec*pi)/(3600*180) = rad
#define ARCSEC_TO_RAD 4.84813681109535993589e-06
/** Feet to Meters */
#define SG_FEET_TO_METER 0.3048
// Radians to arc seconds // (rad*3600*180)/pi = arcsec
#define RAD_TO_ARCSEC 206264.806247096355156
/** Meters to Feet */
#define SG_METER_TO_FEET 3.28083989501312335958
// Feet to Meters
#define FEET_TO_METER 0.3048
/** Meters to Nautical Miles. 1 nm = 6076.11549 feet */
#define SG_METER_TO_NM 0.00053995680
// Meters to Feet
#define METER_TO_FEET 3.28083989501312335958
/** Nautical Miles to Meters */
#define SG_NM_TO_METER 1852.0000
// Meters to Nautical Miles, 1 nm = 6076.11549 feet
#define METER_TO_NM 0.00053995680
/** Radians to Nautical Miles. 1 nm = 1/60 of a degree */
#define SG_NM_TO_RAD 0.00029088820866572159
// Nautical Miles to Meters
#define NM_TO_METER 1852.0000
/** Nautical Miles to Radians */
#define SG_RAD_TO_NM 3437.7467707849392526
// Radians to Nautical Miles, 1 nm = 1/60 of a degree
#define NM_TO_RAD 0.00029088820866572159
// Nautical Miles to Radians
#define RAD_TO_NM 3437.7467707849392526
// For divide by zero avoidance, this will be close enough to zero
#define FG_EPSILON 0.0000001
/** For divide by zero avoidance, this will be close enough to zero */
#define SG_EPSILON 0.0000001
#endif // _SUPPORTGEAR_CONSTANTS_H
/** Highest binobj format version we know how to read/write. This starts at
* 0 and can go up to 65535 */
#define SG_BINOBJ_VERSION 6
/** for backwards compatibility */
#define SG_SCENERY_FILE_FORMAT "0.4"
#endif // _SG_CONSTANTS_H

3
simgear/debug/.cvsignore Normal file
View File

@@ -0,0 +1,3 @@
.deps
Makefile
Makefile.in

View File

@@ -8,4 +8,4 @@ include_HEADERS = debug_types.h logstream.hxx
libsgdebug_a_SOURCES = logstream.cxx
INCLUDES += -I$(top_builddir)
INCLUDES = -I$(top_srcdir)

View File

@@ -1,38 +1,43 @@
// NB: To add a dbg_class, add it here, and add it to the structure in
// fg_debug.c
/** \file debug_types.h
* Define the various logging classes and prioritiess
*/
/**
* Define the possible classes/categories of logging messages
*/
typedef enum {
FG_NONE = 0x00000000,
SG_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_IO = 0x00001000,
FG_CLIPPER = 0x00002000,
FG_NETWORK = 0x00004000,
FG_UNDEFD = 0x00008000, // For range checking
SG_TERRAIN = 0x00000001,
SG_ASTRO = 0x00000002,
SG_FLIGHT = 0x00000004,
SG_INPUT = 0x00000008,
SG_GL = 0x00000010,
SG_VIEW = 0x00000020,
SG_COCKPIT = 0x00000040,
SG_GENERAL = 0x00000080,
SG_MATH = 0x00000100,
SG_EVENT = 0x00000200,
SG_AIRCRAFT = 0x00000400,
SG_AUTOPILOT = 0x00000800,
SG_IO = 0x00001000,
SG_CLIPPER = 0x00002000,
SG_NETWORK = 0x00004000,
SG_UNDEFD = 0x00008000, // For range checking
FG_ALL = 0xFFFFFFFF
} fgDebugClass;
SG_ALL = 0xFFFFFFFF
} sgDebugClass;
// NB: To add a priority, add it here.
/**
* Define the possible logging priorities (and their order).
*/
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;
SG_BULK, // For frequent messages
SG_DEBUG, // Less frequent debug type messages
SG_INFO, // Informatory messages
SG_WARN, // Possible impending problem
SG_ALERT // Very possible impending problem
// SG_EXIT, // Problem (no core)
// SG_ABORT // Abandon ship (core)
} sgDebugPriority;

View File

@@ -4,27 +4,30 @@
//
// 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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#include "logstream.hxx"
logstream *global_logstream = NULL;
bool logbuf::logging_enabled = true;
fgDebugClass logbuf::logClass = FG_NONE;
fgDebugPriority logbuf::logPriority = FG_INFO;
sgDebugClass logbuf::logClass = SG_NONE;
sgDebugPriority logbuf::logPriority = SG_INFO;
streambuf* logbuf::sbuf = NULL;
logbuf::logbuf()
@@ -49,14 +52,38 @@ logbuf::set_sb( streambuf* sb )
}
void
logbuf::set_log_level( fgDebugClass c, fgDebugPriority p )
logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
{
logClass = c;
logPriority = p;
}
void
logstream::setLogLevels( fgDebugClass c, fgDebugPriority p )
logbuf::set_log_classes (sgDebugClass c)
{
logClass = c;
}
sgDebugClass
logbuf::get_log_classes ()
{
return logClass;
}
void
logbuf::set_log_priority (sgDebugPriority p)
{
logPriority = p;
}
sgDebugPriority
logbuf::get_log_priority ()
{
return logPriority;
}
void
logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
{
logbuf::set_log_level( c, p );
}

View File

@@ -1,56 +1,59 @@
// Stream based logging mechanism.
//
/** \file logstream.hxx
* Stream based logging mechanism.
*/
// Written by Bernie Bright, 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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#ifndef _LOGSTREAM_H
#define _LOGSTREAM_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#ifdef FG_HAVE_STD_INCLUDES
// At least Irix needs this
#ifdef SG_HAVE_NATIVE_SGI_COMPILERS
#include <char_traits.h>
#endif
#ifdef SG_HAVE_STD_INCLUDES
# include <streambuf>
# include <iostream>
#else
# include <iostream.h>
# include <simgear/fg_traits.hxx>
# include <simgear/sg_traits.hxx>
#endif
#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);
#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
SG_USING_STD(streambuf);
SG_USING_STD(ostream);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#else
SG_USING_STD(char_traits);
#endif
#ifdef __MWERKS__
# define cerr std::cerr
# define endl std::endl
FG_USING_STD(iostream);
SG_USING_STD(iostream);
#endif
//
@@ -61,43 +64,90 @@ FG_USING_STD(iostream);
// 3. Read environment for default debugClass and debugPriority.
//
//-----------------------------------------------------------------------------
//
// logbuf is an output-only streambuf with the ability to disable sets of
// messages at runtime. Only messages with priority >= logbuf::logPriority
// and debugClass == logbuf::logClass are output.
//
/**
* logbuf is an output-only streambuf with the ability to disable sets of
* messages at runtime. Only messages with priority >= logbuf::logPriority
* and debugClass == logbuf::logClass are output.
*/
class logbuf : public streambuf
{
public:
#ifndef FG_HAVE_STD_INCLUDES
#ifndef SG_HAVE_STD_INCLUDES
typedef char_traits<char> traits_type;
typedef char_traits<char>::int_type int_type;
typedef char_traits<char>::pos_type pos_type;
typedef char_traits<char>::off_type off_type;
// typedef char_traits<char>::pos_type pos_type;
// typedef char_traits<char>::off_type off_type;
#endif
// logbuf( streambuf* sb ) : sbuf(sb) {}
// logbuf( streambuf* sb ) : sbuf(sb) {}
/** Constructor */
logbuf();
/** Destructor */
~logbuf();
// Is logging enabled?
/**
* Is logging enabled?
* @return true or false*/
bool enabled() { return logging_enabled; }
// Set the logging level of subsequent messages.
void set_log_state( fgDebugClass c, fgDebugPriority p );
/**
* Set the logging level of subsequent messages.
* @param c debug class
* @param p priority
*/
void set_log_state( sgDebugClass c, sgDebugPriority p );
// Set the global logging level.
static void set_log_level( fgDebugClass c, fgDebugPriority p );
/**
* Set the global logging level.
* @param c debug class
* @param p priority
*/
static void set_log_level( sgDebugClass c, sgDebugPriority p );
//
/**
* Set the allowed logging classes.
* @param c All enabled logging classes anded together.
*/
static void set_log_classes (sgDebugClass c);
/**
* Get the logging classes currently enabled.
* @return All enabled debug logging anded together.
*/
static sgDebugClass get_log_classes ();
/**
* Set the logging priority.
* @param c The priority cutoff for logging messages.
*/
static void set_log_priority (sgDebugPriority p);
/**
* Get the current logging priority.
* @return The priority cutoff for logging messages.
*/
static sgDebugPriority get_log_priority ();
/**
* Set the stream buffer
* @param sb stream buffer
*/
void set_sb( streambuf* sb );
protected:
/** sync/flush */
inline virtual int sync();
/** overflow */
int_type overflow( int ch );
// int xsputn( const char* s, istreamsize n );
// int xsputn( const char* s, istreamsize n );
private:
@@ -105,8 +155,8 @@ private:
static streambuf* sbuf;
static bool logging_enabled;
static fgDebugClass logClass;
static fgDebugPriority logPriority;
static sgDebugClass logClass;
static sgDebugPriority logPriority;
private:
@@ -118,7 +168,7 @@ private:
inline int
logbuf::sync()
{
#ifdef FG_HAVE_STD_INCLUDES
#ifdef SG_HAVE_STD_INCLUDES
return sbuf->pubsync();
#else
return sbuf->sync();
@@ -126,7 +176,7 @@ logbuf::sync()
}
inline void
logbuf::set_log_state( fgDebugClass c, fgDebugPriority p )
logbuf::set_log_state( sgDebugClass c, sgDebugPriority p )
{
logging_enabled = ((c & logClass) != 0 && p >= logPriority);
}
@@ -137,54 +187,65 @@ logbuf::overflow( int c )
return logging_enabled ? sbuf->sputc(c) : (EOF == 0 ? 1: 0);
}
//-----------------------------------------------------------------------------
//
// logstream manipulator for setting the log level of a message.
//
/**
* logstream manipulator for setting the log level of a message.
*/
struct loglevel
{
loglevel( fgDebugClass c, fgDebugPriority p )
loglevel( sgDebugClass c, sgDebugPriority p )
: logClass(c), logPriority(p) {}
fgDebugClass logClass;
fgDebugPriority logPriority;
sgDebugClass logClass;
sgDebugPriority logPriority;
};
//-----------------------------------------------------------------------------
//
// A helper class that ensures a streambuf and ostream are constructed and
// destroyed in the correct order. The streambuf must be created before the
// ostream but bases are constructed before members. Thus, making this class
// a private base of logstream, declared to the left of ostream, we ensure the
// correct order of construction and destruction.
//
/**
* A helper class that ensures a streambuf and ostream are constructed and
* destroyed in the correct order. The streambuf must be created before the
* ostream but bases are constructed before members. Thus, making this class
* a private base of logstream, declared to the left of ostream, we ensure the
* correct order of construction and destruction.
*/
struct logstream_base
{
// logstream_base( streambuf* sb ) : lbuf(sb) {}
// logstream_base( streambuf* sb ) : lbuf(sb) {}
logstream_base() {}
logbuf lbuf;
};
//-----------------------------------------------------------------------------
//
//
//
/**
* Class to manage the debug logging stream.
*/
class logstream : private logstream_base, public ostream
{
public:
// The default is to send messages to cerr.
/**
* The default is to send messages to cerr.
* @param out output stream
*/
logstream( ostream& out )
// : logstream_base(out.rdbuf()),
// : logstream_base(out.rdbuf()),
: logstream_base(),
ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
/**
* Set the output stream
* @param out output stream
*/
void set_output( ostream& out ) { lbuf.set_sb( out.rdbuf() ); }
// Set the global log class and priority level.
void setLogLevels( fgDebugClass c, fgDebugPriority p );
/**
* Set the global log class and priority level.
* @param c debug class
* @param p priority
*/
void setLogLevels( sgDebugClass c, sgDebugPriority p );
// Output operator to capture the debug level and priority of a message.
/**
* Output operator to capture the debug level and priority of a message.
* @param l log level
*/
inline ostream& operator<< ( const loglevel& l );
};
@@ -195,26 +256,51 @@ logstream::operator<< ( const loglevel& l )
return *this;
}
//-----------------------------------------------------------------------------
//
// Return the one and only logstream instance.
// We use a function instead of a global object so we are assured that cerr
// has been initialised.
//
extern logstream *global_logstream;
/**
* \relates logstream
* Return the one and only logstream instance.
* We use a function instead of a global object so we are assured that cerr
* has been initialised.
* @return current logstream
*/
inline logstream&
fglog()
sglog()
{
static logstream logstrm( cerr );
return logstrm;
if (global_logstream == NULL) {
#ifdef __APPLE__
/**
* There appears to be a bug in the C++ runtime in Mac OS X that
* will crash if certain funtions are called (in this case
* cerr.rdbuf()) during static initialization of a class. This
* print statement is hack to kick the library in the pants so it
* won't crash when cerr.rdbuf() is first called -DW
**/
cout << "Using Mac OS X hack for initializing C++ stdio..." << endl;
#endif
global_logstream = new logstream (cerr);
}
return *global_logstream;
}
/** \def SG_LOG(C,P,M)
* Log a message.
* @param C debug class
* @param P priority
* @param M message
*/
#ifdef FG_NDEBUG
# define FG_LOG(C,P,M)
# define SG_LOG(C,P,M)
#elif defined( __MWERKS__ )
# define FG_LOG(C,P,M) ::fglog() << ::loglevel(C,P) << M << std::endl
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
#else
# define FG_LOG(C,P,M) fglog() << loglevel(C,P) << M << endl
# define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl
#endif
#endif // _LOGSTREAM_H

View File

@@ -1,23 +1,39 @@
#include <string>
#include "Debug/logstream.hxx"
class Test {
public:
Test() {
//cout << "Cout seems to work" << endl;
//cerr << "Cerr seems to work" << endl;
sglog().setLogLevels( SG_ALL, SG_INFO );
SG_LOG(SG_EVENT, SG_INFO, "Test::Test" << "foo");
}
};
Test test;
int
main( int argc, char* argv[] )
{
fglog().setLogLevels( FG_ALL, FG_INFO );
sglog().setLogLevels( SG_ALL, SG_INFO );
FG_LOG( FG_TERRAIN, FG_BULK, "terrain::bulk" ); // shouldnt appear
FG_LOG( FG_TERRAIN, FG_DEBUG, "terrain::debug" ); // shouldnt appear
FG_LOG( FG_TERRAIN, FG_INFO, "terrain::info" );
FG_LOG( FG_TERRAIN, FG_WARN, "terrain::warn" );
FG_LOG( FG_TERRAIN, FG_ALERT, "terrain::alert" );
//SG_LOG( FG_TERRAIN, FG_BULK, "terrain::bulk" ); // shouldnt appear
//SG_LOG( FG_TERRAIN, SG_DEBUG, "terrain::debug" ); // shouldnt appear
//SG_LOG( FG_TERRAIN, SG_INFO, "terrain::info" );
//SG_LOG( FG_TERRAIN, FG_WARN, "terrain::warn" );
//SG_LOG( FG_TERRAIN, SG_ALERT, "terrain::alert" );
int i = 12345;
long l = 54321L;
double d = 3.14159;
string s = "Hello world!";
FG_LOG( FG_EVENT, FG_INFO, "event::info "
SG_LOG( SG_EVENT, SG_INFO, "event::info "
<< "i=" << i
<< ", l=" << l
<< ", d=" << d
@@ -25,7 +41,7 @@ main( int argc, char* argv[] )
<< ", s=\"" << s << "\"" );
// This shouldn't appear in log output:
FG_LOG( FG_EVENT, FG_DEBUG, "event::debug "
SG_LOG( SG_EVENT, SG_DEBUG, "event::debug "
<< "- this should be seen - "
<< "d=" << d
<< ", s=\"" << s << "\"" );

View File

@@ -0,0 +1,3 @@
.deps
Makefile
Makefile.in

View File

@@ -1,18 +1,34 @@
noinst_LIBRARIES = libEphemeris.a
includedir = @includedir@/ephemeris
libEphemeris_a_SOURCES = \
celestialBody.cxx celestialBody.hxx \
ephemeris.cxx ephemeris.hxx \
jupiter.cxx jupiter.hxx \
mars.cxx mars.hxx \
mercury.cxx mercury.hxx \
moon.cxx moon.hxx \
neptune.cxx neptune.hxx \
lib_LIBRARIES = libsgephem.a
include_HEADERS = \
celestialBody.hxx \
ephemeris.hxx \
jupiter.hxx \
mars.hxx \
mercury.hxx \
moonpos.hxx \
neptune.hxx \
saturn.hxx \
star.hxx \
stardata.hxx \
uranus.hxx \
venus.hxx
libsgephem_a_SOURCES = \
celestialBody.cxx \
ephemeris.cxx \
jupiter.cxx \
mars.cxx \
mercury.cxx \
moonpos.cxx \
neptune.cxx \
pluto.hxx \
saturn.cxx saturn.hxx \
star.cxx star.hxx \
stars.cxx stars.hxx \
uranus.cxx uranus.hxx \
venus.cxx venus.hxx
saturn.cxx \
star.cxx \
stardata.cxx \
uranus.cxx \
venus.cxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
INCLUDES = -I$(top_srcdir)

View File

@@ -5,26 +5,27 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#include <simgear/debug/logstream.hxx>
#ifdef FG_MATH_EXCEPTION_CLASH
#ifdef SG_MATH_EXCEPTION_CLASH
# define exception c_exception
#endif
#include <math.h>
@@ -34,7 +35,7 @@
/**************************************************************************
* void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
* void CelestialBody::updatePosition(double mjd, Star *ourSun)
*
* Basically, this member function provides a general interface for
* calculating the right ascension and declinaion. This function is
@@ -45,25 +46,25 @@
* position is calculated an a slightly different manner.
*
* arguments:
* fgTIME t: provides the current time.
* double mjd: provides the modified julian date.
* 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)
void CelestialBody::updatePosition(double mjd, Star *ourSun)
{
double eccAnom, v, ecl, actTime,
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
updateOrbElements(t);
actTime = fgCalcActTime(t);
updateOrbElements(mjd);
actTime = sgCalcActTime(mjd);
// calcualate the angle bewteen ecliptic and equatorial coordinate system
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime);
ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 *actTime);
eccAnom = fgCalcEccAnom(M, e); //calculate the eccentric anomaly
eccAnom = sgCalcEccAnom(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
@@ -87,7 +88,7 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
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 : "
/* SG_LOG(SG_GENERAL, SG_INFO, "Planet found at : "
<< rightAscension << " (ra), " << declination << " (dec)" ); */
//calculate some variables specific to calculating the magnitude
@@ -106,11 +107,11 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
tmp = -1.0;
}
FV = RAD_TO_DEG * acos( tmp );
};
FV = SGD_RADIANS_TO_DEGREES * acos( tmp );
}
/****************************************************************************
* double CelestialBody::fgCalcEccAnom(double M, double e)
* double CelestialBody::sgCalcEccAnom(double M, double e)
* this private member calculates the eccentric anomaly of a celestial body,
* given its mean anomaly and eccentricity.
*
@@ -135,7 +136,7 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
* the eccentric anomaly
*
****************************************************************************/
double CelestialBody::fgCalcEccAnom(double M, double e)
double CelestialBody::sgCalcEccAnom(double M, double e)
{
double
eccAnom, E0, E1, diff;
@@ -151,28 +152,118 @@ double CelestialBody::fgCalcEccAnom(double M, double e)
diff = fabs(E0 - E1);
E0 = E1;
}
while (diff > (DEG_TO_RAD * 0.001));
while (diff > (SGD_DEGREES_TO_RADIANS * 0.001));
return E0;
}
return eccAnom;
}
/*****************************************************************************
* 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.
***************************************************************************/
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, double mjd)
{
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(mjd);
}
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)
{
NFirst = Nf; NSec = Ns;
iFirst = If; iSec = Is;
wFirst = wf; wSec = ws;
aFirst = af; aSec = as;
eFirst = ef; eSec = es;
MFirst = Mf; MSec = Ms;
}
/****************************************************************************
* inline void CelestialBody::updateOrbElements(double mjd)
* given the current time, this private member calculates the actual
* orbital elements
*
* Arguments: double mjd: the current modified julian date:
*
* return value: none
***************************************************************************/
void CelestialBody::updateOrbElements(double mjd)
{
double actTime = sgCalcActTime(mjd);
M = SGD_DEGREES_TO_RADIANS * (MFirst + (MSec * actTime));
w = SGD_DEGREES_TO_RADIANS * (wFirst + (wSec * actTime));
N = SGD_DEGREES_TO_RADIANS * (NFirst + (NSec * actTime));
i = SGD_DEGREES_TO_RADIANS * (iFirst + (iSec * actTime));
e = eFirst + (eSec * actTime);
a = aFirst + (aSec * actTime);
}
/*****************************************************************************
* inline double CelestialBody::sgCalcActTime(double mjd)
* 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.
****************************************************************************/
double CelestialBody::sgCalcActTime(double mjd)
{
return (mjd - 36523.5);
}
/*****************************************************************************
* inline void CelestialBody::getPos(double* ra, double* dec)
* gives public access to Right Ascension and declination
*
****************************************************************************/
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
****************************************************************************/
void CelestialBody::getPos(double* ra, double* dec, double* magn)
{
*ra = rightAscension;
*dec = declination;
*magn = magnitude;
}

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -33,8 +34,6 @@
#include <simgear/constants.h>
#include <Time/fg_time.hxx>
class Star;
class CelestialBody
@@ -61,9 +60,9 @@ protected: // make the data protected, in order to give the
double magnitude;
double lonEcl, latEcl;
double fgCalcEccAnom(double M, double e);
double fgCalcActTime(FGTime *t);
void updateOrbElements(FGTime *t);
double sgCalcEccAnom(double M, double e);
double sgCalcActTime(double mjd);
void updateOrbElements(double mjd);
public:
CelestialBody(double Nf, double Ns,
@@ -71,7 +70,7 @@ public:
double wf, double ws,
double af, double as,
double ef, double es,
double Mf, double Ms, FGTime *t);
double Mf, double Ms, double mjd);
CelestialBody(double Nf, double Ns,
double If, double Is,
double wf, double ws,
@@ -85,116 +84,9 @@ public:
double getMagnitude();
double getLon();
double getLat();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, 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 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)
{
NFirst = Nf; NSec = Ns;
iFirst = If; iSec = Is;
wFirst = wf; wSec = ws;
aFirst = af; aSec = as;
eFirst = ef; eSec = es;
MFirst = Mf; MSec = Ms;
};
/****************************************************************************
* 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::getRightAscension() { return rightAscension; }
inline double CelestialBody::getDeclination() { return declination; }
inline double CelestialBody::getMagnitude() { return magnitude; }
@@ -211,14 +103,3 @@ inline double CelestialBody::getLat()
#endif // _CELESTIALBODY_H_

View File

@@ -5,19 +5,20 @@
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
@@ -26,9 +27,9 @@
// Constructor
FGEphemeris::FGEphemeris( const string &path ) {
SGEphemeris::SGEphemeris( const string &path ) {
our_sun = new Star;
moon = new Moon;
moon = new MoonPos;
mercury = new Mercury;
venus = new Venus;
mars = new Mars;
@@ -36,12 +37,12 @@ FGEphemeris::FGEphemeris( const string &path ) {
saturn = new Saturn;
uranus = new Uranus;
neptune = new Neptune;
stars = new FGStars( FGPath(path) );
stars = new SGStarData( SGPath(path) );
}
// Destructor
FGEphemeris::~FGEphemeris( void ) {
SGEphemeris::~SGEphemeris( void ) {
delete our_sun;
delete moon;
delete mercury;
@@ -57,17 +58,17 @@ FGEphemeris::~FGEphemeris( void ) {
// Update (recalculate) the positions of all objects for the specified
// time
void FGEphemeris::update( FGTime *t, double lat ) {
void SGEphemeris::update( double mjd, double lst, double lat ) {
// update object positions
our_sun->updatePosition( t );
moon->updatePosition( t, lat, our_sun );
mercury->updatePosition( t, our_sun );
venus->updatePosition( t, our_sun );
mars->updatePosition( t, our_sun );
jupiter->updatePosition( t, our_sun );
saturn->updatePosition( t, our_sun );
uranus->updatePosition( t, our_sun );
neptune->updatePosition( t, our_sun );
our_sun->updatePosition( mjd );
moon->updatePosition( mjd, lst, lat, our_sun );
mercury->updatePosition( mjd, our_sun );
venus->updatePosition( mjd, our_sun );
mars->updatePosition( mjd, our_sun );
jupiter->updatePosition( mjd, our_sun );
saturn->updatePosition( mjd, our_sun );
uranus->updatePosition( mjd, our_sun );
neptune->updatePosition( mjd, our_sun );
// update planets list
nplanets = 7;

View File

@@ -1,23 +1,28 @@
// ephemeris.hxx -- Top level class for calculating current positions of
// astronomical objects
/** \file ephemeris.hxx
* Top level class for calculating current positions of astronomical objects.
*/
// Top level interface written by Curtis Olson, started March 2000.
//
// Written by Curtis Olson, started March 2000.
// All the core code underneath this is written by Durk Talsma. See
// the headers of all the other individual files for details.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
@@ -26,30 +31,46 @@
#define _EPHEMERIS_HXX
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <plib/sg.h>
#include <Time/fg_time.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 "stars.hxx"
#include <simgear/ephemeris/star.hxx>
#include <simgear/ephemeris/moonpos.hxx>
#include <simgear/ephemeris/mercury.hxx>
#include <simgear/ephemeris/venus.hxx>
#include <simgear/ephemeris/mars.hxx>
#include <simgear/ephemeris/jupiter.hxx>
#include <simgear/ephemeris/saturn.hxx>
#include <simgear/ephemeris/uranus.hxx>
#include <simgear/ephemeris/neptune.hxx>
#include <simgear/ephemeris/stardata.hxx>
class FGEphemeris {
/** Ephemeris class
*
* Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
* <curt@flightgear.org>
*
* Introduction
*
* The SGEphemeris class computes and stores the positions of the Sun,
* the Moon, the planets, and the brightest stars. These positions
* can then be used to accurately render the dominant visible items in
* the Earth's sky. Note, this class isn't intended for use in an
* interplanetary/interstellar/intergalactic type application. It is
* calculates everything relative to the Earth and is therefore best
* suited for Earth centric applications.
*
* The positions of the various astronomical objects are time
* dependent, so to maintain accuracy, you will need to periodically
* call the update() method. The SGTime class conveniently provides
* the two time related values you need to pass to the update()
* method.
*/
class SGEphemeris {
Star *our_sun;
Moon *moon;
MoonPos *moon;
Mercury *mercury;
Venus *venus;
Mars *mars;
@@ -65,44 +86,88 @@ class FGEphemeris {
int nplanets;
sgdVec3 planets[7];
FGStars *stars;
SGStarData *stars;
public:
// Constructor
FGEphemeris( const string &path );
/**
* Constructor.
* This creates an instance of the SGEphemeris object. When
* calling the constructor you need to provide a path pointing to
* your star database file.
* @param path path to your star database */
SGEphemeris( const string &path );
// Destructor
~FGEphemeris( void );
/** Destructor */
~SGEphemeris( void );
// Update (recalculate) the positions of all objects for the
// specified time
void update(FGTime *t, double lat);
/**
* Update (recalculate) the positions of all objects for the
* specified time. The update() method requires you to pass in
* the current modified Julian date, the current local sidereal
* time, and the current latitude. The update() method is designed
* to be called by the host application before every frame.
* @param mjd modified julian date
* @param lst current local sidereal time
* @param lat current latitude
*/
void update(double mjd, double lst, double lat);
// sun
/**
* @return a pointer to a Star class containing all the positional
* information for Earth's Sun.
*/
inline Star *get_sun() const { return our_sun; }
/** @return the right ascension of the Sun. */
inline double getSunRightAscension() const {
return our_sun->getRightAscension();
}
/** @return the declination of the Sun. */
inline double getSunDeclination() const {
return our_sun->getDeclination();
}
// moon
inline Moon *get_moon() const { return moon; }
/**
* @return a pointer to a Moon class containing all the positional
* information for Earth's Moon.
*/
inline MoonPos *get_moon() const { return moon; }
/** @return the right ascension of the Moon. */
inline double getMoonRightAscension() const {
return moon->getRightAscension();
}
/** @return the declination of the Moon. */
inline double getMoonDeclination() const {
return moon->getDeclination();
}
// planets
/** @return the numbers of defined planets. */
inline int getNumPlanets() const { return nplanets; }
/**
* Returns a pointer to an array of planet data in sgdVec3
* format. (See plib.sourceforge.net for information on plib and
* the ``sg'' package.) An sgdVec3 is a 3 element double
* array. The first element is the right ascension of the planet,
* the second is the declination, and the third is the magnitude.
* @return planets array
*/
inline sgdVec3 *getPlanets() { return planets; }
// planets
/** @return the numbers of defined stars. */
inline int getNumStars() const { return stars->getNumStars(); }
/**
* Returns a pointer to an array of star data in sgdVec3
* format. An The first element of the sgdVec3 is the right
* ascension of the planet, the second is the declination, and the
* third is the magnitude.
* @returns star array
*/
inline sgdVec3 *getStars() { return stars->getStars(); }
};

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -31,19 +32,19 @@
#include "jupiter.hxx"
/*************************************************************************
* Jupiter::Jupiter(FGTime *t)
* Jupiter::Jupiter(double mjd)
* 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) :
Jupiter::Jupiter(double mjd) :
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)
19.89500, 0.08308530010, mjd)
{
}
@@ -58,15 +59,15 @@ Jupiter::Jupiter() :
}
/*************************************************************************
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
* void Jupiter::updatePosition(double mjd, 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)
void Jupiter::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _JUPITER_HXX_
#define _JUPITER_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Jupiter : public CelestialBody
{
public:
Jupiter (FGTime *t);
Jupiter (double mjd);
Jupiter ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _JUPITER_HXX_

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "mars.hxx"
/*************************************************************************
* Mars::Mars(FGTime *t)
* Mars::Mars(double mjd)
* 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) :
Mars::Mars(double mjd) :
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)
18.60210, 0.52402077660, mjd)
{
}
Mars::Mars() :
@@ -55,14 +56,14 @@ Mars::Mars() :
{
}
/*************************************************************************
* void Mars::updatePosition(FGTime *t, Star *ourSun)
* void Mars::updatePosition(double mjd, 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)
void Mars::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _MARS_HXX_
#define _MARS_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Mars : public CelestialBody
{
public:
Mars ( FGTime *t);
Mars ( double mjd );
Mars ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _MARS_HXX_

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "mercury.hxx"
/*************************************************************************
* Mercury::Mercury(FGTime *t)
* Mercury::Mercury(double mjd)
* 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) :
Mercury::Mercury(double mjd) :
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)
168.6562, 4.09233443680, mjd)
{
}
Mercury::Mercury() :
@@ -55,15 +56,15 @@ Mercury::Mercury() :
{
}
/*************************************************************************
* void Mercury::updatePosition(FGTime *t, Star *ourSun)
* void Mercury::updatePosition(double mjd, 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)
void Mercury::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _MERCURY_HXX_
#define _MERCURY_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Mercury : public CelestialBody
{
public:
Mercury ( FGTime *t);
Mercury (double mjd);
Mercury ();
void updatePosition(FGTime *t, Star* ourSun);
void updatePosition(double mjd, Star* ourSun);
};
#endif // _MERURY_HXX_

View File

@@ -1,63 +0,0 @@
/**************************************************************************
* 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();
~Moon();
void updatePosition(FGTime *t, double lat, Star *ourSun);
// void newImage();
};
#endif // _MOON_HXX_

View File

@@ -1,23 +1,24 @@
/**************************************************************************
* moon.cxx
* moonpos.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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -26,40 +27,36 @@
#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 <FDM/flight.hxx>
#include "moon.hxx"
#include "moonpos.hxx"
/*************************************************************************
* Moon::Moon(FGTime *t)
* Public constructor for class Moon. Initializes the orbital elements and
* MoonPos::MoonPos(double mjd)
* Public constructor for class MoonPos. Initializes the orbital elements and
* sets up the moon texture.
* Argument: The current time.
* the hard coded orbital elements for Moon are passed to
* the hard coded orbital elements for MoonPos are passed to
* CelestialBody::CelestialBody();
************************************************************************/
Moon::Moon(FGTime *t) :
MoonPos::MoonPos(double mjd) :
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)
115.3654, 13.0649929509, mjd)
{
}
Moon::Moon() :
MoonPos::MoonPos() :
CelestialBody(125.1228, -0.0529538083,
5.1454, 0.00000,
318.0634, 0.1643573223,
@@ -70,18 +67,18 @@ Moon::Moon() :
}
Moon::~Moon()
MoonPos::~MoonPos()
{
}
/*****************************************************************************
* void Moon::updatePosition(FGTime *t, Star *ourSun)
* void MoonPos::updatePosition(double mjd, 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, double lat, Star *ourSun)
void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun)
{
double
eccAnom, ecl, actTime,
@@ -89,19 +86,13 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
Ls, Lm, D, F, mpar, gclat, rho, HA, g,
geoRa, geoDec;
fgAIRCRAFT *air;
FGInterface *f;
air = &current_aircraft;
f = air->fdm_state;
updateOrbElements(t);
actTime = fgCalcActTime(t);
updateOrbElements(mjd);
actTime = sgCalcActTime(mjd);
// 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
ecl = ((SGD_DEGREES_TO_RADIANS * 23.4393) - (SGD_DEGREES_TO_RADIANS * 3.563E-7) * actTime);
eccAnom = sgCalcEccAnom(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
@@ -124,7 +115,7 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
D = Lm - Ls;
F = Lm - N;
lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
lonEcl += SGD_DEGREES_TO_RADIANS * (-1.274 * sin (M - 2*D)
+0.658 * sin (2*D)
-0.186 * sin(ourSun->getM())
-0.059 * sin(2*M - 2*D)
@@ -137,7 +128,7 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
-0.015 * sin(2*F - 2*D)
+0.011 * sin(M - 4*D)
);
latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
latEcl += SGD_DEGREES_TO_RADIANS * (-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)
@@ -146,7 +137,7 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
r += (-0.58 * cos(M - 2*D)
-0.46 * cos(2*D)
);
// FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
// SG_LOG(SG_GENERAL, SG_INFO, "Running moon update");
xg = r * cos(lonEcl) * cos(latEcl);
yg = r * sin(lonEcl) * cos(latEcl);
zg = r * sin(latEcl);
@@ -158,9 +149,9 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
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) << ")" ); */
/* SG_LOG( SG_GENERAL, SG_INFO,
"(geocentric) geoRa = (" << (SGD_RADIANS_TO_DEGREES * geoRa)
<< "), geoDec= (" << (SGD_RADIANS_TO_DEGREES * geoDec) << ")" ); */
// Given the moon's geocentric ra and dec, calculate its
@@ -170,30 +161,40 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
// 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() );
// SG_LOG( SG_GENERAL, SG_INFO, "r = " << r << " mpar = " << mpar );
// SG_LOG( SG_GENERAL, SG_INFO, "lat = " << f->get_Latitude() );
gclat = lat - 0.003358 *
sin (2 * DEG_TO_RAD * lat );
// FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
sin (2 * SGD_DEGREES_TO_RADIANS * lat );
// SG_LOG( SG_GENERAL, SG_INFO, "gclat = " << gclat );
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat);
// FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
rho = 0.99883 + 0.00167 * cos(2 * SGD_DEGREES_TO_RADIANS * lat);
// SG_LOG( SG_GENERAL, SG_INFO, "rho = " << rho );
if (geoRa < 0)
geoRa += (2*FG_PI);
geoRa += (2*SGD_PI);
HA = t->getLst() - (3.8197186 * geoRa);
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
HA = lst - (3.8197186 * geoRa);
/* SG_LOG( SG_GENERAL, SG_INFO, "t->getLst() = " << t->getLst()
<< " HA = " << HA ); */
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
// FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
// SG_LOG( SG_GENERAL, SG_INFO, "g = " << g );
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
if (fabs(lat) > 0) {
declination
= geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
} else {
declination = geoDec;
// cerr << "Geocentric vs. Topocentric position" << endl;
// cerr << "RA (difference) : "
// << SGD_RADIANS_TO_DEGREES * (geoRa - rightAscension) << endl;
// cerr << "Dec (difference) : "
// << SGD_RADIANS_TO_DEGREES * (geoDec - declination) << endl;
}
/* FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
/* SG_LOG( SG_GENERAL, SG_INFO,
"Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension)
<< "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */
}

View File

@@ -0,0 +1,61 @@
/**************************************************************************
* moonpos.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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _MOONPOS_HXX_
#define _MOONPOS_HXX_
#include <simgear/constants.h>
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class MoonPos : 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:
MoonPos(double mjd);
MoonPos();
~MoonPos();
void updatePosition(double mjd, double lst, double lat, Star *ourSun);
// void newImage();
};
#endif // _MOONPOS_HXX_

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "neptune.hxx"
/*************************************************************************
* Neptune::Neptune(FGTime *t)
* Neptune::Neptune(double mjd)
* 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) :
Neptune::Neptune(double mjd) :
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)
260.2471, 0.00599514700, mjd)
{
}
Neptune::Neptune() :
@@ -55,14 +56,14 @@ Neptune::Neptune() :
{
}
/*************************************************************************
* void Neptune::updatePosition(FGTime *t, Star *ourSun)
* void Neptune::updatePosition(double mjd, 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)
void Neptune::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _NEPTUNE_HXX_
#define _NEPTUNE_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Neptune : public CelestialBody
{
public:
Neptune ( FGTime *t);
Neptune (double mjd);
Neptune ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _NEPTUNE_HXX_

View File

@@ -5,32 +5,32 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _PLUTO_HXX_
#define _PLUTO_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
class Pluto : public CelestialBody
{
public:
Pluto ( FGTime *t);
Pluto (double mjd);
Pluto ();
};

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "saturn.hxx"
/*************************************************************************
* Saturn::Saturn(FGTime *t)
* Saturn::Saturn(double mjd)
* 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) :
Saturn::Saturn(double mjd) :
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)
316.9670, 0.03344422820, mjd)
{
}
Saturn::Saturn() :
@@ -56,17 +57,17 @@ Saturn::Saturn() :
}
/*************************************************************************
* void Saturn::updatePosition(FGTime *t, Star *ourSun)
* void Saturn::updatePosition(double mjd, 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)
void Saturn::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
double actTime = fgCalcActTime(t);
double actTime = sgCalcActTime(mjd);
double ir = 0.4897394;
double Nr = 2.9585076 + 6.6672E-7*actTime;
double B = asin (sin(declination) * cos(ir) -

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _SATURN_HXX_
#define _SATURN_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Saturn : public CelestialBody
{
public:
Saturn ( FGTime *t);
Saturn (double mjd);
Saturn ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _SATURN_HXX_

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,15 +31,11 @@
#include <simgear/debug/logstream.hxx>
#include <Time/sunpos.hxx>
#include <Time/light.hxx>
#include <Main/options.hxx>
#include "star.hxx"
/*************************************************************************
* Star::Star(FGTime *t)
* Star::Star(double mjd)
* Public constructor for class Star
* Argument: The current time.
* the hard coded orbital elements our sun are passed to
@@ -46,13 +43,13 @@
* note that the word sun is avoided, in order to prevent some compilation
* problems on sun systems
************************************************************************/
Star::Star(FGTime *t) :
Star::Star(double mjd) :
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)
356.0470, 0.98560025850, mjd)
{
distance = 0.0;
}
@@ -74,22 +71,22 @@ Star::~Star()
/*************************************************************************
* void Star::updatePosition(FGTime *t, Star *ourSun)
* void Star::updatePosition(double mjd, Star *ourSun)
*
* calculates the current position of our sun.
*************************************************************************/
void Star::updatePosition(FGTime *t)
void Star::updatePosition(double mjd)
{
double
actTime, eccAnom,
xv, yv, v, r,
xe, ye, ze, ecl;
updateOrbElements(t);
updateOrbElements(mjd);
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)
actTime = sgCalcActTime(mjd);
ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
eccAnom = sgCalcEccAnom(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);

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -25,8 +26,7 @@
#define _STAR_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
class Star : public CelestialBody
@@ -39,10 +39,10 @@ private:
public:
Star (FGTime *t);
Star (double mjd);
Star ();
~Star();
void updatePosition(FGTime *t);
void updatePosition(double mjd);
double getM();
double getw();
double getxs();

View File

@@ -1,60 +1,68 @@
// stars.cxx -- manage star data
// stardata.cxx -- manage star data
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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 library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library 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
// This library 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.
// Library 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.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/sgstream.hxx>
#include "stars.hxx"
#include "stardata.hxx"
#if defined (_MSC_VER) || defined (SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(getline);
#endif
// Constructor
FGStars::FGStars() {
SGStarData::SGStarData() :
nstars(0)
{
}
FGStars::FGStars( FGPath path ) {
data_path = FGPath( path );
SGStarData::SGStarData( SGPath path ) :
nstars(0)
{
data_path = SGPath( path );
load();
}
// Destructor
FGStars::~FGStars() {
SGStarData::~SGStarData() {
}
bool FGStars::load() {
bool SGStarData::load() {
// -dw- avoid local data > 32k error by dynamic allocation of the
// array, problem for some compilers
stars = new sgdVec3[FG_MAX_STARS];
stars = new sgdVec3[SG_MAX_STARS];
// build the full path name to the stars data base file
data_path.append( "stars" );
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << data_path.str() );
SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() );
fg_gzifstream in( data_path.str() );
sg_gzifstream in( data_path.str() );
if ( ! in.is_open() ) {
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: "
SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: "
<< data_path.str() );
exit(-1);
}
@@ -66,7 +74,7 @@ bool FGStars::load() {
nstars = 0;
// read in each line of the file
while ( ! in.eof() && nstars < FG_MAX_STARS ) {
while ( ! in.eof() && nstars < SG_MAX_STARS ) {
in >> skipcomment;
getline( in, name, ',' );
@@ -112,7 +120,7 @@ bool FGStars::load() {
++nstars;
}
FG_LOG( FG_ASTRO, FG_INFO, " Loaded " << nstars << " stars" );
SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << nstars << " stars" );
return true;
}

View File

@@ -0,0 +1,62 @@
// stardata.hxx -- manage star data
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#ifndef _SG_STARDATA_HXX
#define _SG_STARDATA_HXX
#include <plib/sg.h>
#include <simgear/misc/sg_path.hxx>
#define SG_MAX_STARS 850
class SGStarData {
int nstars;
sgdVec3 *stars;
SGPath data_path;
public:
// Constructor
SGStarData();
SGStarData( SGPath path );
// Destructor
~SGStarData();
// load the stars database
bool load();
// stars
inline int getNumStars() const { return nstars; }
inline sgdVec3 *getStars() { return stars; }
};
#endif // _SG_STARDATA_HXX

View File

@@ -1,61 +0,0 @@
// stars.hxx -- manage star data
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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$
#ifndef _STARS_HXX
#define _STARS_HXX
#include <plib/sg.h>
#include <simgear/misc/fgpath.hxx>
#define FG_MAX_STARS 850
class FGStars {
int nstars;
sgdVec3 *stars;
FGPath data_path;
public:
// Constructor
FGStars();
FGStars( FGPath path );
// Destructor
~FGStars();
// load the stars database
bool load();
// stars
inline int getNumStars() const { return nstars; }
inline sgdVec3 *getStars() { return stars; }
};
#endif // _STARS_HXX

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "uranus.hxx"
/*************************************************************************
* Uranus::Uranus(FGTime *t)
* Uranus::Uranus(double mjd)
* Public constructor for class Uranus
* Argument: The current time.
* the hard coded orbital elements for Uranus are passed to
* CelestialBody::CelestialBody();
************************************************************************/
Uranus::Uranus(FGTime *t) :
Uranus::Uranus(double mjd) :
CelestialBody(74.00050, 1.3978000E-5,
0.7733, 1.900E-8,
96.66120, 3.0565000E-5,
19.181710, -1.55E-8,
0.047318, 7.450E-9,
142.5905, 0.01172580600, t)
142.5905, 0.01172580600, mjd)
{
}
Uranus::Uranus() :
@@ -56,14 +57,14 @@ Uranus::Uranus() :
}
/*************************************************************************
* void Uranus::updatePosition(FGTime *t, Star *ourSun)
* void Uranus::updatePosition(double mjd, Star *ourSun)
*
* calculates the current position of Uranus, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using
* a Uranus specific equation
*************************************************************************/
void Uranus::updatePosition(FGTime *t, Star *ourSun)
void Uranus::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _URANUS_HXX_
#define _URANUS_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Uranus : public CelestialBody
{
public:
Uranus ( FGTime *t);
Uranus (double mjd);
Uranus ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _URANUS_HXX_

View File

@@ -5,19 +5,20 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
@@ -30,19 +31,19 @@
#include "venus.hxx"
/*************************************************************************
* Venus::Venus(FGTime *t)
* Venus::Venus(double mjd)
* Public constructor for class Venus
* Argument: The current time.
* the hard coded orbital elements for Venus are passed to
* CelestialBody::CelestialBody();
************************************************************************/
Venus::Venus(FGTime *t) :
Venus::Venus(double mjd) :
CelestialBody(76.67990, 2.4659000E-5,
3.3946, 2.75E-8,
54.89100, 1.3837400E-5,
0.7233300, 0.000000,
0.006773, -1.302E-9,
48.00520, 1.60213022440, t)
48.00520, 1.60213022440, mjd)
{
}
Venus::Venus() :
@@ -56,14 +57,14 @@ Venus::Venus() :
}
/*************************************************************************
* void Venus::updatePosition(FGTime *t, Star *ourSun)
* void Venus::updatePosition(double mjd, Star *ourSun)
*
* calculates the current position of Venus, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using
* a Venus specific equation
*************************************************************************/
void Venus::updatePosition(FGTime *t, Star *ourSun)
void Venus::updatePosition(double mjd, Star *ourSun)
{
CelestialBody::updatePosition(t, ourSun);
CelestialBody::updatePosition(mjd, ourSun);
magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
}

View File

@@ -5,35 +5,35 @@
* 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* This library 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.
* Library 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.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* $Id$
**************************************************************************/
#ifndef _VENUS_HXX_
#define _VENUS_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
#include <simgear/ephemeris/celestialBody.hxx>
#include <simgear/ephemeris/star.hxx>
class Venus : public CelestialBody
{
public:
Venus ( FGTime *t);
Venus (double mjd);
Venus ();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
#endif // _VENUS_HXX_

View File

@@ -1,86 +0,0 @@
/**************************************************************************
* fg_zlib.h -- a zlib wrapper to replace zlib calls with normal uncompressed
* calls for systems that have problems building zlib.
*
* Written by Curtis Olson, started April 1998.
*
* Copyright (C) 1998 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 _FG_ZLIB_H
#define _FG_ZLIB_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef AVOID_USING_ZLIB
#include <stdio.h>
#define fgFile FILE *
/* fgFile fgopen(char *filename, const char *flags) */
#define fgopen(P, F) (fopen((P), (F)))
/* int fgseek(fgFile *file, long offset, int whence) */
#define fgseek(F, O, W) (fseek((F), (O), (W)))
/* fgread(fgFile file, void *buf, int size); */
#define fgread(F, B, S) (fread((B), (S), 1, (F)))
/* int fggets(fgFile fd, char *buffer, int len) */
#define fggets(F, B, L) (fgets((B), (L), (F)))
/* int fgclose(fgFile fd) */
#define fgclose(F) (fclose((F)))
#else
#ifdef HAVE_ZLIB
#include <zlib.h>
#else
#include <simgear/zlib/zlib.h>
#endif
#define fgFile gzFile
/* fgFile fgopen(char *filename, const char *flags) */
#define fgopen(P, F) (gzopen((P), (F)))
/* int fgseek(fgFile *file, long offset, int whence) */
#define fgseek(F, O, W) (gzseek((F), (O), (W)))
/* fgread(fgFile file, void *buf, int size); */
#define fgread(F, B, S) (gzread((F), (B), (S)))
/* int fggets(fgFile fd, char *buffer, int len) */
#define fggets(F, B, L) (gzgets((F), (B), (L)))
/* int fgclose(fgFile fd) */
#define fgclose(F) (gzclose((F)))
#endif /* #ifdef AVOID_USING_ZLIB #else #endif */
#endif /* _FG_ZLIB_H */

8
simgear/io/.cvsignore Normal file
View File

@@ -0,0 +1,8 @@
.deps
Makefile
Makefile.in
decode_binobj
lowtest
socktest
tcp_client
tcp_server

76
simgear/io/Makefile.am Normal file
View File

@@ -0,0 +1,76 @@
includedir = @includedir@/io
lib_LIBRARIES = libsgio.a
include_HEADERS = \
iochannel.hxx \
lowlevel.hxx \
sg_binobj.hxx \
sg_file.hxx \
sg_serial.hxx \
sg_socket.hxx \
sg_socket_udp.hxx
libsgio_a_SOURCES = \
iochannel.cxx \
lowlevel.cxx \
sg_binobj.cxx \
sg_file.cxx \
sg_serial.cxx \
sg_socket.cxx \
sg_socket_udp.cxx
INCLUDES = -I$(top_srcdir)
if IS_MINGW
NETWORK_LIB = -lwsock32
else
NETWORK_LIB =
endif
noinst_PROGRAMS = decode_binobj socktest lowtest tcp_server tcp_client
tcp_server_SOURCES = tcp_server.cxx
tcp_server_LDADD = \
$(top_builddir)/simgear/io/libsgio.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(top_builddir)/simgear/xml/libsgxml.a \
-lplibnet -lplibul -lz $(NETWORK_LIB)
tcp_client_SOURCES = tcp_client.cxx
tcp_client_LDADD = \
$(top_builddir)/simgear/io/libsgio.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(top_builddir)/simgear/xml/libsgxml.a \
-lplibnet -lplibul -lz $(NETWORK_LIB)
socktest_SOURCES = socktest.cxx
socktest_LDADD = \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/io/libsgio.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(top_builddir)/simgear/xml/libsgxml.a \
-lplibnet -lplibul -lz $(NETWORK_LIB)
lowtest_SOURCES = lowtest.cxx
lowtest_LDADD = \
$(top_builddir)/simgear/io/libsgio.a
decode_binobj_SOURCES = decode_binobj.cxx
decode_binobj_LDADD = \
$(top_builddir)/simgear/io/libsgio.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/xml/libsgxml.a \
-lz

View File

@@ -0,0 +1,151 @@
#include <simgear/compiler.h>
#include <unistd.h>
#include STL_IOSTREAM
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(cout);
SG_USING_STD(endl);
#endif
#include "sg_binobj.hxx"
int main( int argc, char **argv ) {
int i, j;
// check usage
if ( argc != 2 ) {
cout << "Usage: " << argv[0] << " binary_obj_file" << endl;
}
SGBinObject obj;
bool result = obj.read_bin( argv[1] );
if ( !result ) {
cout << "error loading: " << argv[1] << endl;
exit(-1);
}
cout << "# FGFS Scenery" << endl;
cout << "# Version " << obj.get_version() << endl;
cout << endl;
printf("# gbs %.5f %.5f %.5f %.2f\n", obj.get_gbs_center().x(),
obj.get_gbs_center().y(), obj.get_gbs_center().z(),
obj.get_gbs_radius());
cout << endl;
point_list nodes = obj.get_wgs84_nodes();
cout << "# vertex list" << endl;
for ( i = 0; i < (int)nodes.size(); ++i ) {
printf("v %.5f %.5f %.5f\n", nodes[i].x(), nodes[i].y(), nodes[i].z() );
}
cout << endl;
point_list normals = obj.get_normals();
cout << "# vertex normal list" << endl;
for ( i = 0; i < (int)normals.size(); ++i ) {
printf("vn %.5f %.5f %.5f\n",
normals[i].x(), normals[i].y(), normals[i].z() );
}
cout << endl;
point_list texcoords = obj.get_texcoords();
cout << "# texture coordinate list" << endl;
for ( i = 0; i < (int)texcoords.size(); ++i ) {
printf("vt %.5f %.5f\n",
texcoords[i].x(), texcoords[i].y() );
}
cout << endl;
cout << "# geometry groups" << endl;
cout << endl;
string material;
int_list vertex_index;
int_list normal_index;
int_list tex_index;
// generate points
string_list pt_materials = obj.get_pt_materials();
group_list pts_v = obj.get_pts_v();
group_list pts_n = obj.get_pts_n();
for ( i = 0; i < (int)pts_v.size(); ++i ) {
material = pt_materials[i];
vertex_index = pts_v[i];
normal_index = pts_n[i];
cout << "# usemtl " << material << endl;
cout << "pt ";
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
cout << vertex_index[j] << "/" << normal_index[j] << " ";
}
cout << endl;
}
// generate triangles
string_list tri_materials = obj.get_tri_materials();
group_list tris_v = obj.get_tris_v();
group_list tris_n = obj.get_tris_n();
group_list tris_tc = obj.get_tris_tc();
for ( i = 0; i < (int)tris_v.size(); ++i ) {
material = tri_materials[i];
vertex_index = tris_v[i];
normal_index = tris_n[i];
tex_index = tris_tc[i];
cout << "# usemtl " << material << endl;
cout << "f ";
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
cout << vertex_index[j];
if ( normal_index.size() ) {
cout << "/" << normal_index[j];
}
cout << "/" << tex_index[j];
cout << " ";
}
cout << endl;
}
// generate strips
string_list strip_materials = obj.get_strip_materials();
group_list strips_v = obj.get_strips_v();
group_list strips_n = obj.get_strips_n();
group_list strips_tc = obj.get_strips_tc();
for ( i = 0; i < (int)strips_v.size(); ++i ) {
material = strip_materials[i];
vertex_index = strips_v[i];
normal_index = strips_n[i];
tex_index = strips_tc[i];
cout << "# usemtl " << material << endl;
cout << "ts ";
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
cout << vertex_index[j];
if ( normal_index.size() ) {
cout << "/" << normal_index[j];
}
cout << "/" << tex_index[j] << " ";
}
cout << endl;
}
// generate fans
string_list fan_materials = obj.get_fan_materials();
group_list fans_v = obj.get_fans_v();
group_list fans_n = obj.get_fans_n();
group_list fans_tc = obj.get_fans_tc();
for ( i = 0; i < (int)fans_v.size(); ++i ) {
material = fan_materials[i];
vertex_index = fans_v[i];
normal_index = fans_n[i];
tex_index = fans_tc[i];
cout << "# usemtl " << material << endl;
cout << "tf ";
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
cout << vertex_index[j];
if ( normal_index.size() ) {
cout << "/" << normal_index[j];
}
cout << "/" << tex_index[j] << " ";
}
cout << endl;
}
}

72
simgear/io/iochannel.cxx Normal file
View File

@@ -0,0 +1,72 @@
// iochannel.cxx -- High level IO channel class
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#include "iochannel.hxx"
// constructor
SGIOChannel::SGIOChannel()
{
}
// destructor
SGIOChannel::~SGIOChannel()
{
}
// dummy configure routine
bool SGIOChannel::open( const SGProtocolDir d ) {
return false;
}
// dummy process routine
int SGIOChannel::read( char *buf, int length ) {
return 0;
}
// dummy process routine
int SGIOChannel::readline( char *buf, int length ) {
return 0;
}
// dummy process routine
int SGIOChannel::write( const char *buf, const int length ) {
return false;
}
// dummy process routine
int SGIOChannel::writestring( const char *str ) {
return false;
}
// dummy close routine
bool SGIOChannel::close() {
return false;
}

167
simgear/io/iochannel.hxx Normal file
View File

@@ -0,0 +1,167 @@
/**
* \file iochannel.hxx
* High level IO channel base class.
*/
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#ifndef _IOCHANNEL_HXX
#define _IOCHANNEL_HXX
#include <simgear/compiler.h>
// #include "protocol.hxx"
#include STL_STRING
#include <vector>
SG_USING_STD(vector);
SG_USING_STD(string);
#define SG_IO_MAX_MSG_SIZE 16384
/**
* Specify if this is a read (IN), write (OUT), or r/w (BI) directional
* channel
*/
enum SGProtocolDir {
SG_IO_NONE = 0,
SG_IO_IN = 1,
SG_IO_OUT = 2,
SG_IO_BI = 3
};
/**
* Specify the channel type
*/
enum SGChannelType {
sgFileType = 0,
sgSerialType = 1,
sgSocketType = 2
};
/**
* The SGIOChannel base class provides a consistent method for
* applications to communication through various mediums. By providing
* a base class with multiple derived classes, and application such as
* FlightGear can implement a way to speak any protocol via any kind
* of I/O channel.
*
* All of the SGIOChannel derived classes have exactly the same usage
* interface once an instance has been created.
*
*/
class SGIOChannel {
SGChannelType type;
SGProtocolDir dir;
bool valid;
public:
/** Constructor */
SGIOChannel();
/** Destructor */
virtual ~SGIOChannel();
/** Open a channel.
* @param d channel communication "direction"
* Direction can be one of:
* - SG_IO_IN - data will be flowing into this object to the application.
* - SG_IO_OUT - data will be flowing out of this object from the
* application.
* - SG_IO_BI - data will be flowing in both directions.
* - SG_IO_NONE - data will not be flowing in either direction.
* This is here for the sake of completeness.
* @return result of open
*/
virtual bool open( const SGProtocolDir d );
/**
* The read() method is modeled after the read() Unix system
* call. You must provide a pointer to a character buffer that has
* enough allocated space for your potential read. You can also
* specify the maximum number of bytes allowed for this particular
* read. The actual number of bytes read is returned. You are
* responsible to ensure that the size of buf is large enough to
* accomodate your input message
* @param buf a char pointer to your input buffer
* @param length max number of bytes to read
* @return number of bytes read
*/
virtual int read( char *buf, int length );
/**
* The readline() method is similar to read() except that it will
* stop at the first end of line encountered in the input buffer.
* @param buf a char pointer to your input buffer
* @param length max number of bytes to read
* @return number of bytes read
*/
virtual int readline( char *buf, int length );
/**
* The write() method is modeled after the write() Unix system
* call and is analogous to the read() method. You provide a
* pointer to a buffer of data, and then length of that data to be
* written out. The number of bytes written is returned.
* @param buf a char pointer to your output buffer
* @param length number of bytes to write
* @return number of bytes written
*/
virtual int write( const char *buf, const int length );
/**
* The writestring() method is a simple wrapper that will
* calculate the length of a null terminated character array and
* write it to the output channel.
* @param buf a char pointer to your output buffer
* @return number of bytes written
*/
virtual int writestring( const char *str );
/**
* The close() method is modeled after the close() Unix system
* call and will close an open device. You should call this method
* when you are done using your IO class, before it is destructed.
* @return result of close
*/
virtual bool close();
inline void set_type( SGChannelType t ) { type = t; }
inline SGChannelType get_type() const { return type; }
inline void set_dir( const SGProtocolDir d ) { dir = d; }
inline SGProtocolDir get_dir() const { return dir; }
inline bool isvalid() const { return valid; }
inline void set_valid( const bool v ) { valid = v; }
};
#endif // _IOCHANNEL_HXX

497
simgear/io/lowlevel.cxx Normal file
View File

@@ -0,0 +1,497 @@
// lowlevel.cxx -- routines to handle lowlevel compressed binary IO of
// various datatypes
//
// Shamelessly adapted from plib (plib.sourceforge.net) January 2001
//
// Original version Copyright (C) 2000 the plib team
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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$
#include <string.h> // for memcpy()
#include "lowlevel.hxx"
static int read_error = false ;
static int write_error = false ;
void sgClearReadError() { read_error = false; }
void sgClearWriteError() { write_error = false; }
int sgReadError() { return read_error ; }
int sgWriteError() { return write_error ; }
void sgReadChar ( gzFile fd, char *var )
{
if ( gzread ( fd, var, sizeof(char) ) != sizeof(char) ) {
read_error = true ;
}
}
void sgWriteChar ( gzFile fd, const char var )
{
if ( gzwrite ( fd, (void *)(&var), sizeof(char) ) != sizeof(char) ) {
write_error = true ;
}
}
void sgReadFloat ( gzFile fd, float *var )
{
if ( gzread ( fd, var, sizeof(float) ) != sizeof(float) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)var);
}
}
void sgWriteFloat ( gzFile fd, const float var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(float) ) != sizeof(float) ) {
write_error = true ;
}
}
void sgReadDouble ( gzFile fd, double *var )
{
if ( gzread ( fd, var, sizeof(double) ) != sizeof(double) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (uint64*)var);
}
}
void sgWriteDouble ( gzFile fd, const double var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (uint64*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(double) ) != sizeof(double) ) {
write_error = true ;
}
}
void sgReadUInt ( gzFile fd, unsigned int *var )
{
if ( gzread ( fd, var, sizeof(unsigned int) ) != sizeof(unsigned int) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)var);
}
}
void sgWriteUInt ( gzFile fd, const unsigned int var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(unsigned int) )
!= sizeof(unsigned int) )
{
write_error = true ;
}
}
void sgReadInt ( gzFile fd, int *var )
{
if ( gzread ( fd, var, sizeof(int) ) != sizeof(int) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)var);
}
}
void sgWriteInt ( gzFile fd, const int var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(int) ) != sizeof(int) ) {
write_error = true ;
}
}
void sgReadLong ( gzFile fd, long int *var )
{
if ( gzread ( fd, var, sizeof(long int) ) != sizeof(long int) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)var);
}
}
void sgWriteLong ( gzFile fd, const long int var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(long int) )
!= sizeof(long int) )
{
write_error = true ;
}
}
void sgReadLongLong ( gzFile fd, int64 *var )
{
if ( gzread ( fd, var, sizeof(int64) ) != sizeof(int64) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (uint64*)var);
}
}
void sgWriteLongLong ( gzFile fd, const int64 var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (uint64*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(int64) )
!= sizeof(int64) )
{
write_error = true ;
}
}
void sgReadUShort ( gzFile fd, unsigned short *var )
{
if ( gzread ( fd, var, sizeof(unsigned short) ) != sizeof(unsigned short) ){
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned short int*)var);
}
}
void sgWriteUShort ( gzFile fd, const unsigned short var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned short*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(unsigned short) )
!= sizeof(unsigned short) )
{
write_error = true ;
}
}
void sgReadShort ( gzFile fd, short *var )
{
if ( gzread ( fd, var, sizeof(short) ) != sizeof(short) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned short int*)var);
}
}
void sgWriteShort ( gzFile fd, const short var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned short*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(short) ) != sizeof(short) ) {
write_error = true ;
}
}
void sgReadFloat ( gzFile fd, const unsigned int n, float *var )
{
if ( gzread ( fd, var, sizeof(float) * n ) != (int)(sizeof(float) * n) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)var++);
}
}
}
void sgWriteFloat ( gzFile fd, const unsigned int n, const float *var )
{
if ( sgIsBigEndian() ) {
float *swab = new float[n];
float *ptr = swab;
memcpy( swab, var, sizeof(float) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(float) * n )
!= (int)(sizeof(float) * n) )
{
write_error = true ;
}
}
void sgReadDouble ( gzFile fd, const unsigned int n, double *var )
{
if ( gzread ( fd, var, sizeof(double) * n ) != (int)(sizeof(double) * n) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (uint64*)var++);
}
}
}
void sgWriteDouble ( gzFile fd, const unsigned int n, const double *var )
{
if ( sgIsBigEndian() ) {
double *swab = new double[n];
double *ptr = swab;
memcpy( swab, var, sizeof(double) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (uint64*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(double) * n )
!= (int)(sizeof(double) * n) )
{
write_error = true ;
}
}
void sgReadBytes ( gzFile fd, const unsigned int n, void *var )
{
if ( n == 0) return;
if ( gzread ( fd, var, n ) != (int)n ) {
read_error = true ;
}
}
void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var )
{
if ( n == 0) return;
if ( gzwrite ( fd, (void *)var, n ) != (int)n ) {
write_error = true ;
}
}
void sgReadUShort ( gzFile fd, const unsigned int n, unsigned short *var )
{
if ( gzread ( fd, var, sizeof(unsigned short) * n )
!= (int)(sizeof(unsigned short) * n) )
{
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned short int*)var++);
}
}
}
void sgWriteUShort ( gzFile fd, const unsigned int n, const unsigned short *var )
{
if ( sgIsBigEndian() ) {
unsigned short *swab = new unsigned short[n];
unsigned short *ptr = swab;
memcpy( swab, var, sizeof(unsigned short) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned short*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(unsigned short) * n )
!= (int)(sizeof(unsigned short) * n) )
{
write_error = true ;
}
}
void sgReadShort ( gzFile fd, const unsigned int n, short *var )
{
if ( gzread ( fd, var, sizeof(short) * n )
!= (int)(sizeof(short) * n) )
{
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned short int*)var++);
}
}
}
void sgWriteShort ( gzFile fd, const unsigned int n, const short *var )
{
if ( sgIsBigEndian() ) {
short *swab = new short[n];
short *ptr = swab;
memcpy( swab, var, sizeof(short) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned short*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(short) * n )
!= (int)(sizeof(short) * n) )
{
write_error = true ;
}
}
void sgReadUInt ( gzFile fd, const unsigned int n, unsigned int *var )
{
if ( gzread ( fd, var, sizeof(unsigned int) * n )
!= (int)(sizeof(unsigned int) * n) )
{
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)var++);
}
}
}
void sgWriteUInt ( gzFile fd, const unsigned int n, const unsigned int *var )
{
if ( sgIsBigEndian() ) {
unsigned int *swab = new unsigned int[n];
unsigned int *ptr = swab;
memcpy( swab, var, sizeof(unsigned int) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(unsigned int) * n )
!= (int)(sizeof(unsigned int) * n) )
{
write_error = true ;
}
}
void sgReadInt ( gzFile fd, const unsigned int n, int *var )
{
if ( gzread ( fd, var, sizeof(int) * n )
!= (int)(sizeof(int) * n) )
{
read_error = true ;
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)var++);
}
}
}
void sgWriteInt ( gzFile fd, const unsigned int n, const int *var )
{
if ( sgIsBigEndian() ) {
int *swab = new int[n];
int *ptr = swab;
memcpy( swab, var, sizeof(int) * n );
for ( unsigned int i = 0; i < n; ++i ) {
sgEndianSwap( (unsigned int*)ptr++);
}
var = swab;
}
if ( gzwrite ( fd, (void *)var, sizeof(int) * n )
!= (int)(sizeof(int) * n) )
{
write_error = true ;
}
}
#define MAX_ENTITY_NAME_LENGTH 1024
void sgReadString ( gzFile fd, char **var )
{
int i ;
char s [ MAX_ENTITY_NAME_LENGTH ] ;
for ( i = 0 ; i < MAX_ENTITY_NAME_LENGTH ; i++ ) {
int c = gzgetc ( fd ) ;
s [ i ] = c ;
if ( c == '\0' )
break ;
}
if ( i >= MAX_ENTITY_NAME_LENGTH-1 )
s [ MAX_ENTITY_NAME_LENGTH-1 ] = '\0' ;
if ( s[0] == '\0' )
*var = NULL ;
else {
*var = new char [ strlen(s)+1 ] ;
strcpy ( *var, s ) ;
}
}
void sgWriteString ( gzFile fd, const char *var )
{
if ( var != NULL ) {
if ( gzwrite ( fd, (void *)var, strlen(var) + 1 ) ==
(int)(strlen(var) + 1) )
return ;
} else {
gzputc( fd, 0 );
}
}

172
simgear/io/lowlevel.hxx Normal file
View File

@@ -0,0 +1,172 @@
// lowlevel.hxx -- routines to handle lowlevel compressed binary IO of
// various datatypes
//
// Shamelessly adapted from plib January 2001
//
// Original version Copyright (C) 2000 the plib team
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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$
//
#ifndef _SG_LOWLEVEL_HXX
#define _SG_LOWLEVEL_HXX
#include <stdio.h>
#include <zlib.h>
#include <plib/sg.h>
#ifdef _MSC_VER
typedef __int64 int64;
typedef __int64 uint64;
#else
typedef long long int64;
typedef unsigned long long uint64;
#endif
// Note that output is written in little endian form (and converted as
// necessary for big endian machines)
void sgReadChar ( gzFile fd, char *var ) ;
void sgWriteChar ( gzFile fd, const char var ) ;
void sgReadFloat ( gzFile fd, float *var ) ;
void sgWriteFloat ( gzFile fd, const float var ) ;
void sgReadDouble ( gzFile fd, double *var ) ;
void sgWriteDouble ( gzFile fd, const double var ) ;
void sgReadUInt ( gzFile fd, unsigned int *var ) ;
void sgWriteUInt ( gzFile fd, const unsigned int var ) ;
void sgReadInt ( gzFile fd, int *var ) ;
void sgWriteInt ( gzFile fd, const int var ) ;
void sgReadLong ( gzFile fd, long int *var ) ;
void sgWriteLong ( gzFile fd, const long int var ) ;
void sgReadLongLong ( gzFile fd, int64 *var ) ;
void sgWriteLongLong ( gzFile fd, const int64 var ) ;
void sgReadUShort ( gzFile fd, unsigned short *var ) ;
void sgWriteUShort ( gzFile fd, const unsigned short var ) ;
void sgReadShort ( gzFile fd, short *var ) ;
void sgWriteShort ( gzFile fd, const short var ) ;
void sgReadFloat ( gzFile fd, const unsigned int n, float *var ) ;
void sgWriteFloat ( gzFile fd, const unsigned int n, const float *var ) ;
void sgReadDouble ( gzFile fd, const unsigned int n, double *var ) ;
void sgWriteDouble ( gzFile fd, const unsigned int n, const double *var ) ;
void sgReadUInt ( gzFile fd, const unsigned int n, unsigned int *var ) ;
void sgWriteUInt ( gzFile fd, const unsigned int n, const unsigned int *var ) ;
void sgReadInt ( gzFile fd, const unsigned int n, int *var ) ;
void sgWriteInt ( gzFile fd, const unsigned int n, const int *var ) ;
void sgReadUShort ( gzFile fd, const unsigned int n, unsigned short *var ) ;
void sgWriteUShort ( gzFile fd, const unsigned int n, const unsigned short *var ) ;
void sgReadShort ( gzFile fd, const unsigned int n, short *var ) ;
void sgWriteShort ( gzFile fd, const unsigned int n, const short *var ) ;
void sgReadBytes ( gzFile fd, const unsigned int n, void *var ) ;
void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var ) ;
void sgReadString ( gzFile fd, char **var ) ;
void sgWriteString ( gzFile fd, const char *var ) ;
inline void sgReadVec2 ( gzFile fd, sgVec2 var ) {
sgReadFloat ( fd, 2, var ) ;
}
inline void sgWriteVec2 ( gzFile fd, const sgVec2 var ) {
sgWriteFloat ( fd, 2, var ) ;
}
inline void sgReadVec3 ( gzFile fd, sgVec3 var ) {
sgReadFloat ( fd, 3, var ) ;
}
inline void sgWriteVec3 ( gzFile fd, const sgVec3 var ) {
sgWriteFloat ( fd, 3, var ) ;
}
inline void sgReaddVec3 ( gzFile fd, sgdVec3 var ) {
sgReadDouble ( fd, 3, var ) ;
}
inline void sgWritedVec3 ( gzFile fd, const sgdVec3 var ) {
sgWriteDouble ( fd, 3, var ) ;
}
inline void sgReadVec4 ( gzFile fd, sgVec4 var ) {
sgReadFloat ( fd, 4, var ) ;
}
inline void sgWriteVec4 ( gzFile fd, const sgVec4 var ) {
sgWriteFloat ( fd, 4, var ) ;
}
inline void sgReadMat4 ( gzFile fd, sgMat4 var ) {
sgReadFloat ( fd, 16, (float *)var ) ;
}
inline void sgWriteMat4 ( gzFile fd, const sgMat4 var ) {
sgWriteFloat ( fd, 16, (float *)var ) ;
}
void sgClearReadError();
void sgClearWriteError();
int sgReadError();
int sgWriteError();
inline bool sgIsLittleEndian() {
static const int sgEndianTest = 1;
return (*((char *) &sgEndianTest ) != 0);
}
inline bool sgIsBigEndian() {
static const int sgEndianTest = 1;
return (*((char *) &sgEndianTest ) == 0);
}
inline void sgEndianSwap(unsigned short *x) {
*x =
(( *x >> 8 ) & 0x00FF ) |
(( *x << 8 ) & 0xFF00 ) ;
}
inline void sgEndianSwap(unsigned int *x) {
*x =
(( *x >> 24 ) & 0x000000FF ) |
(( *x >> 8 ) & 0x0000FF00 ) |
(( *x << 8 ) & 0x00FF0000 ) |
(( *x << 24 ) & 0xFF000000 ) ;
}
inline void sgEndianSwap(uint64 *x) {
#ifndef _MSC_VER
*x =
(( *x >> 56 ) & 0x00000000000000FFULL ) |
(( *x >> 40 ) & 0x000000000000FF00ULL ) |
(( *x >> 24 ) & 0x0000000000FF0000ULL ) |
(( *x >> 8 ) & 0x00000000FF000000ULL ) |
(( *x << 8 ) & 0x000000FF00000000ULL ) |
(( *x << 24 ) & 0x0000FF0000000000ULL ) |
(( *x << 40 ) & 0x00FF000000000000ULL ) |
(( *x << 56 ) & 0xFF00000000000000ULL ) ;
#else
*x =
(( *x >> 56 ) & 0x00000000000000FF ) |
(( *x >> 40 ) & 0x000000000000FF00 ) |
(( *x >> 24 ) & 0x0000000000FF0000 ) |
(( *x >> 8 ) & 0x00000000FF000000 ) |
(( *x << 8 ) & 0x000000FF00000000 ) |
(( *x << 24 ) & 0x0000FF0000000000 ) |
(( *x << 40 ) & 0x00FF000000000000 ) |
(( *x << 56 ) & 0xFF00000000000000 ) ;
#endif
}
#endif // _SG_LOWLEVEL_HXX

48
simgear/io/lowtest.cxx Normal file
View File

@@ -0,0 +1,48 @@
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include "lowlevel.hxx"
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(cout);
SG_USING_STD(endl);
#endif
static const int sgEndianTest = 1;
#define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
#define sgIsBigEndian (*((char *) &sgEndianTest ) == 0)
int main() {
cout << "This machine is ";
if ( sgIsLittleEndian ) {
cout << "little ";
} else {
cout << "big ";
}
cout << "endian" << endl;
cout << "sizeof(short) = " << sizeof(short) << endl;
short s = 1111;
cout << "short s = " << s << endl;
sgEndianSwap((unsigned short *)&s);
cout << "short s = " << s << endl;
sgEndianSwap((unsigned short *)&s);
cout << "short s = " << s << endl;
int i = 1111111;
cout << "int i = " << i << endl;
sgEndianSwap((unsigned int *)&i);
cout << "int i = " << i << endl;
sgEndianSwap((unsigned int *)&i);
cout << "int i = " << i << endl;
double x = 1111111111;
cout << "double x = " << x << endl;
sgEndianSwap((unsigned long long *)&x);
cout << "double x = " << x << endl;
sgEndianSwap((unsigned long long *)&x);
cout << "double x = " << x << endl;
}

1235
simgear/io/sg_binobj.cxx Normal file

File diff suppressed because it is too large Load Diff

235
simgear/io/sg_binobj.hxx Normal file
View File

@@ -0,0 +1,235 @@
/**
* \file sg_binobj.hxx
* Routines to read and write the low level (binary) simgear 3d object format.
*/
// Written by Curtis Olson, started January 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.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$
#ifndef _SG_BINOBJ_HXX
#define _SG_BINOBJ_HXX
#include <plib/sg.h>
#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/math/sg_types.hxx>
#include <simgear/bucket/newbucket.hxx>
#include <stdio.h>
#include <time.h>
#include <list>
#include STL_STRING
/** STL Structure used to store object information */
typedef vector < int_list > group_list;
typedef group_list::iterator group_list_iterator;
typedef group_list::const_iterator const_group_list_iterator;
/** Magic Number for our file format */
#define SG_FILE_MAGIC_NUMBER ( ('S'<<24) + ('G'<<16) + SG_BINOBJ_VERSION )
/**
* A class to manipulate the simgear 3d object format.
* This class provides functionality to both read and write the binary format.
*
* Here is a really quick overview of the file syntax:
*
* - scenery-file: magic, nobjects, object+
*
* - magic: "TG" + version
*
* - object: obj_typecode, nproperties, nelements, property+, element+
*
* - element: nbytes, BYTE+
*
* - property: prop_typecode, nbytes, BYTE+
*
* - obj_typecode: bounding sphere | vertices | normals | texcoords |
* points | triangles | fans | strips
*
* - prop_typecode: material_name | ???
*
* - nelements: SHORT (Gives us 65536 which ought to be enough, right?)
*
* - nproperties: SHORT
*
* - *_typecode: CHAR
*
* - nbytes: INTEGER (If we used short here that would mean 65536 bytes = 16384
* floats = 5461 vertices which is not enough for future
* growth)
*
* - vertex: FLOAT, FLOAT, FLOAT
*/
class SGBinObject {
unsigned short version;
Point3D gbs_center;
float gbs_radius;
point_list wgs84_nodes; // vertex list
point_list colors; // color list
point_list normals; // normal list
point_list texcoords; // texture coordinate list
group_list pts_v; // points vertex index
group_list pts_n; // points normal index
group_list pts_c; // points color index
group_list pts_tc; // points texture coordinate index
string_list pt_materials; // points materials
group_list tris_v; // triangles vertex index
group_list tris_n; // triangles normal index
group_list tris_c; // triangles color index
group_list tris_tc; // triangles texture coordinate index
string_list tri_materials; // triangles materials
group_list strips_v; // tristrips vertex index
group_list strips_n; // tristrips normal index
group_list strips_c; // tristrips color index
group_list strips_tc; // tristrips texture coordinate index
string_list strip_materials;// tristrips materials
group_list fans_v; // fans vertex index
group_list fans_n; // fans normal index
group_list fans_c; // fans color index
group_list fans_tc; // fans texture coordinate index
string_list fan_materials; // fans materials
public:
inline unsigned short get_version() const { return version; }
inline const Point3D& get_gbs_center() const { return gbs_center; }
inline void set_gbs_center( const Point3D& p ) { gbs_center = p; }
inline float get_gbs_radius() const { return gbs_radius; }
inline void set_gbs_radius( float r ) { gbs_radius = r; }
inline const point_list& get_wgs84_nodes() const { return wgs84_nodes; }
inline void set_wgs84_nodes( const point_list& n ) { wgs84_nodes = n; }
inline const point_list& get_colors() const { return colors; }
inline void set_colors( const point_list& c ) { colors = c; }
inline const point_list& get_normals() const { return normals; }
inline void set_normals( const point_list& n ) { normals = n; }
inline const point_list& get_texcoords() const { return texcoords; }
inline void set_texcoords( const point_list& t ) { texcoords = t; }
inline const group_list& get_pts_v() const { return pts_v; }
inline void set_pts_v( const group_list& g ) { pts_v = g; }
inline const group_list& get_pts_n() const { return pts_n; }
inline void set_pts_n( const group_list& g ) { pts_n = g; }
inline const group_list& get_pts_c() const { return pts_c; }
inline void set_pts_c( const group_list& g ) { pts_c = g; }
inline const group_list& get_pts_tc() const { return pts_tc; }
inline void set_pts_tc( const group_list& g ) { pts_tc = g; }
inline const string_list& get_pt_materials() const { return pt_materials; }
inline void set_pt_materials( const string_list& s ) { pt_materials = s; }
inline const group_list& get_tris_v() const { return tris_v; }
inline void set_tris_v( const group_list& g ) { tris_v = g; }
inline const group_list& get_tris_n() const { return tris_n; }
inline void set_tris_n( const group_list& g ) { tris_n = g; }
inline const group_list& get_tris_c() const { return tris_c; }
inline void set_tris_c( const group_list& g ) { tris_c = g; }
inline const group_list& get_tris_tc() const { return tris_tc; }
inline void set_tris_tc( const group_list& g ) { tris_tc = g; }
inline const string_list& get_tri_materials() const { return tri_materials; }
inline void set_tri_materials( const string_list& s ) { tri_materials = s; }
inline const group_list& get_strips_v() const { return strips_v; }
inline void set_strips_v( const group_list& g ) { strips_v = g; }
inline const group_list& get_strips_n() const { return strips_n; }
inline void set_strips_n( const group_list& g ) { strips_n = g; }
inline const group_list& get_strips_c() const { return strips_c; }
inline void set_strips_c( const group_list& g ) { strips_c = g; }
inline const group_list& get_strips_tc() const { return strips_tc; }
inline void set_strips_tc( const group_list& g ) { strips_tc = g; }
inline const string_list& get_strip_materials() const { return strip_materials; }
inline void set_strip_materials( const string_list& s ) { strip_materials = s; }
inline const group_list& get_fans_v() const { return fans_v; }
inline void set_fans_v( const group_list& g ) { fans_v = g; }
inline const group_list& get_fans_n() const { return fans_n; }
inline void set_fans_n( const group_list& g ) { fans_n = g; }
inline const group_list& get_fans_c() const { return fans_c; }
inline void set_fans_c( const group_list& g ) { fans_c = g; }
inline const group_list& get_fans_tc() const { return fans_tc; }
inline void set_fans_tc( const group_list& g ) { fans_tc = g; }
inline const string_list& get_fan_materials() const { return fan_materials; }
inline void set_fan_materials( const string_list& s ) { fan_materials = s; }
/**
* Read a binary file object and populate the provided structures.
* @param file input file name
* @return result of read
*/
bool read_bin( const string& file );
/**
* Write out the structures to a binary file. We assume that the
* groups come to us sorted by material property. If not, things
* don't break, but the result won't be as optimal.
* @param base name of output path
* @param name name of output file
* @param b bucket for object location
* @return result of write
*/
bool write_bin( const string& base, const string& name, const SGBucket& b );
/**
* Write out the structures to an ASCII file. We assume that the
* groups come to us sorted by material property. If not, things
* don't break, but the result won't be as optimal.
* @param base name of output path
* @param name name of output file
* @param b bucket for object location
* @return result of write
*/
bool write_ascii( const string& base, const string& name,
const SGBucket& b );
};
/**
* \relates SGBinObject
* Calculate the bounding sphere of a set of nodes.
* Center is the center of the tile and zero elevation.
* @param center center of our bounding radius
* @param wgs84_nodes list of points in wgs84 coordinates
* @return radius
*/
double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes );
#endif // _SG_BINOBJ_HXX

134
simgear/io/sg_file.cxx Normal file
View File

@@ -0,0 +1,134 @@
// sg_file.cxx -- File I/O routines
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#include <simgear/compiler.h>
#include STL_STRING
#if defined(_MSC_VER) || defined(__MINGW32__)
# include <io.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_file.hxx"
SG_USING_STD(string);
SGFile::SGFile( const string &file) {
set_type( sgFileType );
file_name = file;
}
SGFile::~SGFile() {
}
// open the file based on specified direction
bool SGFile::open( const SGProtocolDir d ) {
set_dir( d );
if ( get_dir() == SG_IO_OUT ) {
#if defined(_MSC_VER) || defined(__MINGW32__)
int mode = 00666;
#else
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
#endif
fp = ::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC, mode );
} else if ( get_dir() == SG_IO_IN ) {
fp = ::open( file_name.c_str(), O_RDONLY );
} else {
SG_LOG( SG_IO, SG_ALERT,
"Error: bidirection mode not available for files." );
return false;
}
if ( fp == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "Error opening file: " << file_name );
return false;
}
return true;
}
// read a block of data of specified size
int SGFile::read( char *buf, int length ) {
// read a chunk
return ::read( fp, buf, length );
}
// read a line of data, length is max size of input buffer
int SGFile::readline( char *buf, int length ) {
// save our current position
int pos = lseek( fp, 0, SEEK_CUR );
// read a chunk
int result = ::read( fp, buf, length );
// find the end of line and reset position
int i;
for ( i = 0; i < result && buf[i] != '\n'; ++i );
if ( buf[i] == '\n' ) {
result = i + 1;
} else {
result = i;
}
lseek( fp, pos + result, SEEK_SET );
// just in case ...
buf[ result ] = '\0';
return result;
}
// write data to a file
int SGFile::write( const char *buf, const int length ) {
int result = ::write( fp, buf, length );
if ( result != length ) {
SG_LOG( SG_IO, SG_ALERT, "Error writing data: " << file_name );
}
return result;
}
// write null terminated string to a file
int SGFile::writestring( const char *str ) {
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGFile::close() {
if ( ::close( fp ) == -1 ) {
return false;
}
return true;
}

97
simgear/io/sg_file.hxx Normal file
View File

@@ -0,0 +1,97 @@
/** \file sg_file.hxx
* File I/O routines.
*/
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#ifndef _SG_FILE_HXX
#define _SG_FILE_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <string>
#include <sys/types.h> // for open(), read(), write(), close()
#include <sys/stat.h> // for open(), read(), write(), close()
#include <fcntl.h> // for open(), read(), write(), close()
#if !defined( _MSC_VER )
# include <unistd.h> // for open(), read(), write(), close()
#endif
#include "iochannel.hxx"
SG_USING_STD(string);
/**
* A file I/O class based on SGIOChannel.
*/
class SGFile : public SGIOChannel {
string file_name;
int fp;
public:
/**
* Create an instance of SGFile.
* When calling the constructor you need to provide a file
* name. This file is not opened immediately, but instead will be
* opened when the open() method is called.
* @param file name of file to open
*/
SGFile( const string& file );
/** Destructor */
~SGFile();
// open the file based on specified direction
bool open( const SGProtocolDir dir );
// read a block of data of specified size
int read( char *buf, int length );
// read a line of data, length is max size of input buffer
int readline( char *buf, int length );
// write data to a file
int write( const char *buf, const int length );
// write null terminated string to a file
int writestring( const char *str );
// close file
bool close();
/** @return the name of the file being manipulated. */
inline string get_file_name() const { return file_name; }
};
#endif // _SG_FILE_HXX

157
simgear/io/sg_serial.cxx Normal file
View File

@@ -0,0 +1,157 @@
// sg_serial.cxx -- Serial I/O routines
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#include <simgear/compiler.h>
#include STL_STRING
#include <simgear/debug/logstream.hxx>
#include <simgear/serial/serial.hxx>
#include "sg_serial.hxx"
SG_USING_STD(string);
SGSerial::SGSerial( const string& device_name, const string& baud_rate ) :
save_len(0)
{
set_type( sgSerialType );
device = device_name;
baud = baud_rate;
}
SGSerial::~SGSerial() {
}
// open the serial port based on specified direction
bool SGSerial::open( const SGProtocolDir d ) {
set_dir( d );
if ( ! port.open_port( device ) ) {
SG_LOG( SG_IO, SG_ALERT, "Error opening device: " << device );
return false;
}
// cout << "fd = " << port.fd << endl;
if ( ! port.set_baud( atoi( baud.c_str() ) ) ) {
SG_LOG( SG_IO, SG_ALERT, "Error setting baud: " << baud );
return false;
}
return true;
}
// Read data from port. If we don't get enough data, save what we did
// get in the save buffer and return 0. The save buffer will be
// prepended to subsequent reads until we get as much as is requested.
int SGSerial::read( char *buf, int length ) {
int result;
// read a chunk, keep in the save buffer until we have the
// requested amount read
char *buf_ptr = save_buf + save_len;
result = port.read_port( buf_ptr, length - save_len );
if ( result + save_len == length ) {
strncpy( buf, save_buf, length );
save_len = 0;
return length;
}
return 0;
}
// read data from port
int SGSerial::readline( char *buf, int length ) {
int result;
// read a chunk, keep in the save buffer until we have the
// requested amount read
char *buf_ptr = save_buf + save_len;
result = port.read_port( buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
save_len += result;
// look for the end of line in save_buf
int i;
for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i );
if ( save_buf[i] == '\n' ) {
result = i + 1;
} else {
// no end of line yet
return 0;
}
// we found an end of line
// copy to external buffer
strncpy( buf, save_buf, result );
buf[result] = '\0';
SG_LOG( SG_IO, SG_INFO, "fg_serial line = " << buf );
// shift save buffer
for ( i = result; i < save_len; ++i ) {
save_buf[ i - result ] = save_buf[i];
}
save_len -= result;
return result;
}
// write data to port
int SGSerial::write( const char *buf, const int length ) {
int result = port.write_port( buf, length );
if ( result != length ) {
SG_LOG( SG_IO, SG_ALERT, "Error writing data: " << device );
}
return result;
}
// write null terminated string to port
int SGSerial::writestring( const char *str ) {
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGSerial::close() {
if ( ! port.close_port() ) {
return false;
}
return true;
}

110
simgear/io/sg_serial.hxx Normal file
View File

@@ -0,0 +1,110 @@
/**
* \file sg_serial.hxx
* Serial I/O routines
*/
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#ifndef _SG_SERIAL_HXX
#define _SG_SERIAL_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <string>
// #ifdef SG_HAVE_STD_INCLUDES
// # include <ctime>
// #else
// # include <time.h>
// #endif
#include <simgear/serial/serial.hxx>
#include "iochannel.hxx"
SG_USING_STD(string);
/**
* A serial I/O class based on SGIOChannel.
*/
class SGSerial : public SGIOChannel {
string device;
string baud;
FGSerialPort port;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
public:
/**
* Create an instance of SGSerial.
* This creates an instance of the SGSerial class. You need to
* provide the serial device name and desired baud rate. For Unix
* style systems, device names will be similar to
* ``/dev/ttyS0''. For DOS style systems you may want to use
* something similar to ``COM1:''. As with the SGFile class,
* device is not opened immediately, but instead will be opened
* when the open() method is called.
* @param device_name name of serial device
* @param baud_rate speed of communication
*/
SGSerial( const string& device_name, const string& baud_rate );
/** Destructor */
~SGSerial();
// open the serial port based on specified direction
bool open( const SGProtocolDir d );
// read a block of data of specified size
int read( char *buf, int length );
// read a line of data, length is max size of input buffer
int readline( char *buf, int length );
// write data to port
int write( const char *buf, const int length );
// write null terminated string to port
int writestring( const char *str );
// close port
bool close();
/** @return the serial port device name */
inline string get_device() const { return device; }
/** @return the baud rate */
inline string get_baud() const { return baud; }
};
#endif // _SG_SERIAL_HXX

397
simgear/io/sg_socket.cxx Normal file
View File

@@ -0,0 +1,397 @@
// sg_socket.cxx -- Socket I/O routines
//
// Written by Curtis Olson, started November 1999.
// Modified by Bernie Bright <bbright@bigpond.net.au>, May 2002.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#include <simgear/compiler.h>
#if defined( sgi )
#include <strings.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_socket.hxx"
bool SGSocket::init = false;
SGSocket::SGSocket( const string& host, const string& port_,
const string& style ) :
hostname(host),
port_str(port_),
save_len(0),
client(0),
is_tcp(false),
is_server(false),
first_read(false)
{
if (!init)
{
netInit(NULL, NULL); // plib-1.4.2 compatible
init = true;
}
if ( style == "tcp" )
{
is_tcp = true;
}
else if ( style != (string)"udp" )
{
SG_LOG( SG_IO, SG_ALERT,
"Error: SGSocket() unknown style = " << style );
}
set_type( sgSocketType );
}
SGSocket::~SGSocket()
{
this->close();
}
bool
SGSocket::make_server_socket()
{
if (!sock.open( is_tcp ))
{
SG_LOG( SG_IO, SG_ALERT,
"Error: socket() failed in make_server_socket()" );
return false;
}
if (sock.bind( "", port ) < 0)
{
SG_LOG( SG_IO, SG_ALERT,
"Error: bind() failed in make_server_socket()" );
sock.close();
return false;
}
return true;
}
bool
SGSocket::make_client_socket()
{
if (!sock.open( is_tcp ))
{
SG_LOG( SG_IO, SG_ALERT,
"Error: socket() failed in make_client_socket()" );
return false;
}
if (sock.connect( hostname.c_str(), port ) < 0)
{
SG_LOG( SG_IO, SG_ALERT,
"Error: connect() failed in make_client_socket()" );
sock.close();
return false;
}
return true;
}
// If specified as a server (in direction for now) open the master
// listening socket. If specified as a client (out direction), open a
// connection to a server.
bool
SGSocket::open( SGProtocolDir direction )
{
set_dir( direction );
is_server = is_tcp &&
(direction == SG_IO_IN || direction == SG_IO_BI);
if ( port_str == "" || port_str == "any" ) {
port = 0;
} else {
port = atoi( port_str.c_str() );
}
if (direction == SG_IO_IN)
{
// this means server for now
// Setup socket to listen on. Set "port" before making this
// call. A port of "0" indicates that we want to let the os
// pick any available port.
if (!make_server_socket())
{
SG_LOG( SG_IO, SG_ALERT, "SG_IO_IN socket creation failed" );
return false;
}
if ( !is_tcp )
{
// Non-blocking UDP
nonblock();
}
else
{
// Blocking TCP
// Specify the maximum length of the connection queue
sock.listen( SG_MAX_SOCKET_QUEUE );
}
}
else if (direction == SG_IO_OUT)
{
// this means client for now
if (!make_client_socket())
{
SG_LOG( SG_IO, SG_ALERT, "SG_IO_OUT socket creation failed" );
return false;
}
if ( !is_tcp )
{
// Non-blocking UDP
nonblock();
}
}
else if (direction == SG_IO_BI && is_tcp)
{
// this means server for TCP sockets
// Setup socket to listen on. Set "port" before making this
// call. A port of "0" indicates that we want to let the os
// pick any available port.
if (!make_server_socket())
{
SG_LOG( SG_IO, SG_ALERT, "SG_IO_BI socket creation failed" );
return false;
}
// Blocking TCP
// Specify the maximum length of the connection queue
sock.listen( SG_MAX_SOCKET_QUEUE );
}
else
{
SG_LOG( SG_IO, SG_ALERT,
"Error: bidirection mode not available for UDP sockets." );
return false;
}
first_read = false;
return true;
}
// read data from socket (server)
// read a block of data of specified size
int
SGSocket::read( char *buf, int length )
{
if (sock.getHandle() == -1 &&
(client == 0 || client->getHandle() == -1))
{
return 0;
}
// test for any input available on sock (returning immediately, even if
// nothing)
int result = poll();
if (result > 0)
{
result = sock.recv( buf, length );
if ( result != length )
{
SG_LOG( SG_IO, SG_INFO,
"Warning: read() not enough bytes." );
}
}
return result;
}
// read a line of data, length is max size of input buffer
int
SGSocket::readline( char *buf, int length )
{
if (sock.getHandle() == -1 &&
(client == 0 || client->getHandle() == -1))
{
return 0;
}
// test for any input read on sock (returning immediately, even if
// nothing)
int result = this->poll();
if (result > 0)
{
// read a chunk, keep in the save buffer until we have the
// requested amount read
if (is_tcp)
{
char *buf_ptr = save_buf + save_len;
result = client->recv( buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
if ( result > 0 )
{
first_read = true;
}
save_len += result;
// Try and detect that the remote end died. This
// could cause problems so if you see connections
// dropping for unexplained reasons, LOOK HERE!
if (result == 0 && save_len == 0 && first_read == true)
{
SG_LOG( SG_IO, SG_ALERT,
"Connection closed by foreign host." );
delete client;
client = 0;
}
}
else
{
char *buf_ptr = save_buf + save_len;
result = sock.recv( buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
save_len += result;
}
}
// look for the end of line in save_buf
int i;
for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i )
;
if ( save_buf[i] == '\n' ) {
result = i + 1;
} else {
// no end of line yet
return 0;
}
// we found an end of line
// copy to external buffer
strncpy( buf, save_buf, result );
buf[result] = '\0';
// shift save buffer
//memmove( save_buf+, save_buf+, ? );
for ( i = result; i < save_len; ++i ) {
save_buf[ i - result ] = save_buf[i];
}
save_len -= result;
return result;
}
// write data to socket (client)
int
SGSocket::write( const char *buf, const int length )
{
netSocket* s = client == 0 ? &sock : client;
if (s->getHandle() == -1)
{
return 0;
}
bool error_condition = false;
if ( s->send( buf, length ) < 0 )
{
SG_LOG( SG_IO, SG_ALERT, "Error writing to socket: " << port );
error_condition = true;
}
if ( error_condition ) {
return 0;
}
return length;
}
// write null terminated string to socket (server)
int
SGSocket::writestring( const char *str )
{
int length = strlen( str );
return this->write( str, length );
}
// close the port
bool
SGSocket::close()
{
delete client;
client = 0;
sock.close();
return true;
}
// configure the socket as non-blocking
bool
SGSocket::nonblock()
{
if (sock.getHandle() == -1) {
return false;
}
sock.setBlocking( false );
return true;
}
int
SGSocket::poll()
{
netSocket* readers[2];
readers[0] = client != 0 ? client : &sock;
readers[1] = 0;
netSocket* writers[1];
writers[0] = 0;
int result = netSocket::select( readers, writers, 0 );
if (result > 0 && is_server && client == 0)
{
// Accept a new client connection
netAddress addr;
int new_fd = sock.accept( &addr );
SG_LOG( SG_IO, SG_INFO, "Accepted connection from "
<< addr.getHost() << ":" << addr.getPort() );
client = new netSocket();
client->setHandle( new_fd );
return 0;
}
return result;
}

167
simgear/io/sg_socket.hxx Normal file
View File

@@ -0,0 +1,167 @@
/**
* \file sg_socket.hxx
* Socket I/O routines.
*/
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#ifndef _SG_SOCKET_HXX
#define _SG_SOCKET_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include STL_STRING
#include <simgear/math/sg_types.hxx>
#include <simgear/io/iochannel.hxx>
#include <plib/netSocket.h>
SG_USING_STD(string);
#define SG_MAX_SOCKET_QUEUE 32
/**
* A socket I/O class based on SGIOChannel.
*/
class SGSocket : public SGIOChannel {
public:
private:
string hostname;
string port_str;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
netSocket sock;
netSocket* client;
unsigned short port;
bool is_tcp;
bool is_server;
bool first_read;
static bool init;
// make a server (master listening) socket
bool make_server_socket();
// make a client socket
bool make_client_socket();
// Poll for new connections or data to read.
int poll();
public:
/**
* Create an instance of SGSocket.
*
* When calling the constructor you need to provide a host name, a
* port number, and a socket style. The convention used by the
* SGSocket class is that the server side listens and the client
* side sends. For a server socket, the host name should be
* empty. For a server, the port number is optional, if you do not
* specify a port, the system will assign one. For a client
* socket, you need to specify both a destination host and
* destination port. For both client and server sockets you must
* specify the socket type. Type must be either udp or tcp. Here's
* a quick breakdown of the major differences between UDP and TCP
* type sockets.
*
* TCP sockets are the type where you establish a connection and
* then can read and write to the socket from both ends. If one
* end of TCP socket connect quits, the other end will likely
* segfault if it doesn't take special precautions. But, the nice
* thing about TCP connections is that the underlying protocol
* guarantees that your message will get through. This imposes a
* certain performance overhead though on the communication
* because the protocol must resend failed messages. TCP sockets
* are good for sending periodic command/response type messages
* where performance isn't a big issues, but reliability is.
*
* UDP sockets on the other hand are a lower level protocol and
* don't have the same sort of connection as TCP sockets. With UDP
* sockets, the server end just sits and listens for incoming
* packets from anywhere. The client end sends it's message and
* forgets about it. It doesn't care if there isn't even a server
* out there listening and all the packets are getting
* lost. Although systems/networks usually do a pretty good job
* (statistically) of getting your UDP packets to their
* destination, there is no guarantee that any particular packet
* will make it. But, because of this low level implementation and
* lack of error checking, UDP packets are much faster and
* efficient. UDP packets are good for sending positional
* information to synchronize two applications. In this case, you
* want the information to arrive as quickly as possible, and if
* you lose a packet, you'd rather get new updated information
* rather than have the system waste time resending a packet that
* is becoming older and older with every retry.
* @param host name of host if direction is SG_IO_OUT or SG_IO_BI
* @param port port number if we care to choose one.
* @param style specify "udp" or "tcp"
*/
SGSocket( const string& host, const string& port, const string& style );
/** Destructor */
~SGSocket();
// If specified as a server (in direction for now) open the master
// listening socket. If specified as a client (out direction),
// open a connection to a server.
bool open( const SGProtocolDir d );
// read data from socket
int read( char *buf, int length );
// read data from socket
int readline( char *buf, int length );
// write data to a socket
int write( const char *buf, const int length );
// write null terminated string to a socket
int writestring( const char *str );
// close file
bool close();
/**
* Enable non-blocking mode.
* @return success/failure
*/
bool nonblock();
/** @return the remote host name */
inline string get_hostname() const { return hostname; }
/** @return the port number (in string form) */
inline string get_port_str() const { return port_str; }
};
#endif // _SG_SOCKET_HXX

View File

@@ -0,0 +1,202 @@
// sg_socket.cxx -- Socket I/O routines
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.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$
#include <simgear/compiler.h>
#if defined( sgi )
#include <strings.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_socket_udp.hxx"
SGSocketUDP::SGSocketUDP( const string& host, const string& port ) :
hostname(host),
port_str(port),
save_len(0)
{
set_valid( false );
}
SGSocketUDP::~SGSocketUDP() {
}
// If specified as a server (in direction for now) open the master
// listening socket. If specified as a client (out direction), open a
// connection to a server.
bool SGSocketUDP::open( const SGProtocolDir d ) {
set_dir( d );
if ( ! sock.open( false ) ) { // open a UDP socket
SG_LOG( SG_IO, SG_ALERT, "error opening socket" );
return false;
}
if ( port_str == "" || port_str == "any" ) {
port = 0;
} else {
port = atoi( port_str.c_str() );
}
// client_connections.clear();
if ( get_dir() == SG_IO_IN ) {
// this means server
// bind ...
if ( sock.bind( hostname.c_str(), port ) == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "error binding to port" << port_str );
return false;
}
} else if ( get_dir() == SG_IO_OUT ) {
// this means client
// connect ...
if ( sock.connect( hostname.c_str(), port ) == -1 ) {
SG_LOG( SG_IO, SG_ALERT,
"error connecting to " << hostname << port_str );
return false;
}
} else {
SG_LOG( SG_IO, SG_ALERT,
"Error: bidirection mode not available for UDP sockets." );
return false;
}
set_valid( true );
return true;
}
// read data from socket (server)
// read a block of data of specified size
int SGSocketUDP::read( char *buf, int length ) {
if ( ! isvalid() ) {
return 0;
}
int result;
if ( (result = sock.recv(buf, SG_IO_MAX_MSG_SIZE, 0)) >= 0 ) {
buf[result] = '\0';
// printf("msg received = %s\n", buf);
}
return result;
}
// read a line of data, length is max size of input buffer
int SGSocketUDP::readline( char *buf, int length ) {
if ( ! isvalid() ) {
return 0;
}
// cout << "sock = " << sock << endl;
char *buf_ptr = save_buf + save_len;
int result = sock.recv(buf_ptr, SG_IO_MAX_MSG_SIZE, 0);
// printf("msg received = %s\n", buf);
save_len += result;
// look for the end of line in save_buf
int i;
for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i );
if ( save_buf[i] == '\n' ) {
result = i + 1;
} else {
// no end of line yet
// cout << "no eol found" << endl;
return 0;
}
// cout << "line length = " << result << endl;
// we found an end of line
// copy to external buffer
strncpy( buf, save_buf, result );
buf[result] = '\0';
// cout << "sg_socket line = " << buf << endl;
// shift save buffer
for ( i = result; i < save_len; ++i ) {
save_buf[ i - result ] = save_buf[i];
}
save_len -= result;
return result;
}
// write data to socket (client)
int SGSocketUDP::write( const char *buf, const int length ) {
if ( ! isvalid() ) {
return 0;
}
bool error_condition = false;
if ( sock.send( buf, length, 0 ) < 0 ) {
SG_LOG( SG_IO, SG_ALERT, "Error writing to socket: " << port );
error_condition = true;
return 0;
}
return length;
}
// write null terminated string to socket (server)
int SGSocketUDP::writestring( const char *str ) {
if ( !isvalid() ) {
return 0;
}
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGSocketUDP::close() {
if ( !isvalid() ) {
return 0;
}
sock.close();
return true;
}
// configure the socket as non-blocking
bool SGSocketUDP::setBlocking( bool value ) {
sock.setBlocking( value );
return true;
}

View File

@@ -0,0 +1,138 @@
/**
* \file sg_socket_udp.hxx
* UDP Socket I/O routines.
*/
// Written by Curtis Olson, started November 2001.
//
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.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$
#ifndef _SG_SOCKET_UDP_HXX
#define _SG_SOCKET_UDP_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <plib/netSocket.h>
#include <simgear/compiler.h>
#include STL_STRING
#include <simgear/math/sg_types.hxx>
#include <simgear/io/iochannel.hxx>
SG_USING_STD(string);
/**
* A UDP socket I/O class based on SGIOChannel and plib/net.
*/
class SGSocketUDP : public SGIOChannel {
private:
netSocket sock;
string hostname;
string port_str;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
short unsigned int port;
public:
/**
* Create an instance of SGSocketUDP.
*
* When calling the constructor you need to provide a host name, and a
* port number. The convention used by the
* SGSocketUDP class is that the server side listens and the client
* side sends. For a server socket, the host name should be
* empty. For a server, the port number is optional, if you do not
* specify a port, the system will assign one. For a client
* socket, you need to specify both a destination host and
* destination port.
*
* UDP sockets are a lower level protocol than TCP sockets and are
* "connectionless" in the sense that either client or server can
* exist, or not exist, startup, quit, etc. in any order and
* whenever both ends are alive, the communication succeeds. With
* UDP sockets, the server end just sits and listens for incoming
* packets from anywhere. The client end sends it's message and
* forgets about it. It doesn't care if there isn't even a server
* out there listening and all the packets are getting
* lost. Although systems/networks usually do a pretty good job
* (statistically) of getting your UDP packets to their
* destination, there is no guarantee that any particular packet
* will make it. But, because of this low level implementation and
* lack of error checking, UDP packets are much faster and
* efficient. UDP packets are good for sending positional
* information to synchronize two applications. In this case, you
* want the information to arrive as quickly as possible, and if
* you lose a packet, you'd rather get new updated information
* rather than have the system waste time resending a packet that
* is becoming older and older with every retry.
* @param host name of host if direction is SG_IO_OUT or SG_IO_BI
* @param port port number if we care to choose one.
* @param style specify "udp" or "tcp" */
SGSocketUDP( const string& host, const string& port );
/** Destructor */
~SGSocketUDP();
// If specified as a server (in direction for now) open the master
// listening socket. If specified as a client (out direction),
// open a connection to a server.
bool open( const SGProtocolDir d );
// read data from socket
int read( char *buf, int length );
// read data from socket
int readline( char *buf, int length );
// write data to a socket
int write( const char *buf, const int length );
// write null terminated string to a socket
int writestring( const char *str );
// close file
bool close();
/**
* Set blocking true or false
* @return success/failure
*/
bool setBlocking( bool value );
/** @return the remote host name */
inline string get_hostname() const { return hostname; }
/** @return the port number (in string form) */
inline string get_port_str() const { return port_str; }
};
#endif // _SG_SOCKET_UDP_HXX

50
simgear/io/socktest.cxx Normal file
View File

@@ -0,0 +1,50 @@
#include <simgear/compiler.h>
#include <unistd.h>
#include STL_IOSTREAM
#include "sg_socket.hxx"
#include "lowlevel.hxx"
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(cout);
SG_USING_STD(endl);
#endif
static const int sgEndianTest = 1;
#define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
#define sgIsBigEndian (*((char *) &sgEndianTest ) == 0)
int main() {
if ( sgIsLittleEndian ) {
cout << "this machine is little endian\n";
}
if ( sgIsBigEndian ) {
cout << "this machine is big endian\n";
}
cout << "short = " << sizeof(unsigned short) << endl;
cout << "int = " << sizeof(unsigned int) << endl;
cout << "long long = " << sizeof(long long) << endl;
SGSocket s( "", "5500", "tcp" );
if ( !s.open( SG_IO_BI ) ) {
cout << "error can't open socket\n";
}
char buf[256];
while ( true ) {
if ( s.readline( buf, 256 ) > 0 ) {
cout << "result = " << buf;
}
#ifdef __MINGW32__
Sleep(100);
#else
sleep(1);
#endif
}
}

89
simgear/io/tcp_client.cxx Normal file
View File

@@ -0,0 +1,89 @@
#include <simgear/compiler.h>
#include STL_IOSTREAM
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_socket.hxx"
#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
using std::cout;
#endif
class TcpClient
{
public:
TcpClient( const char* host, const char* port );
~TcpClient();
bool open();
bool process();
bool close();
private:
SGIOChannel* channel;
};
TcpClient::TcpClient( const char* host, const char* port )
{
channel = new SGSocket( host, port, "tcp" );
}
TcpClient::~TcpClient()
{
delete channel;
}
bool
TcpClient::open()
{
return channel->open( SG_IO_OUT );
}
bool
TcpClient::process()
{
char wbuf[1024];
sprintf( wbuf, "hello world\n" );
int length = channel->writestring( wbuf );
cout << "writestring returned " << length << "\n";
return true;
}
bool
TcpClient::close()
{
return channel->close();
}
int
main()
{
sglog().setLogLevels( SG_ALL, SG_INFO );
TcpClient client( "localhost", "5500" );
if (!client.open())
{
cout << "client open failed\n";
return 0;
}
for (int i = 0; i < 3; ++i)
{
client.process();
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
//client.close();
return 0;
}

72
simgear/io/tcp_server.cxx Normal file
View File

@@ -0,0 +1,72 @@
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include STL_STRING
#include STL_IOSTREAM
#include "sg_socket.hxx"
using std::string;
#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
using std::cout;
#endif
class TcpServer
{
public:
TcpServer();
bool open();
bool process();
bool close();
private:
SGIOChannel* channel;
};
TcpServer::TcpServer()
{
channel = new SGSocket( "", "5500", "tcp" );
}
bool
TcpServer::open()
{
channel->open( SG_IO_BI );
return true;
}
bool
TcpServer::process()
{
char buf[1024];
int len;
while ((len = channel->readline( buf, sizeof(buf) )) > 0)
{
cout << len << ": " << buf;
}
return true;
}
bool
TcpServer::close()
{
return channel->close();
}
int
main()
{
sglog().setLogLevels( SG_ALL, SG_INFO );
TcpServer server;
server.open();
SG_LOG( SG_IO, SG_INFO, "Created TCP server" );
while (1)
{
server.process();
}
server.close();
return 0;
}

View File

@@ -0,0 +1,4 @@
.deps
Makefile
Makefile.in
testmagvar

View File

@@ -4,7 +4,9 @@ lib_LIBRARIES = libsgmagvar.a
include_HEADERS = magvar.hxx
libsgmagvar_a_SOURCES = magvar.cxx
libsgmagvar_a_SOURCES = \
coremag.hxx coremag.cxx \
magvar.cxx
noinst_PROGRAMS = testmagvar
@@ -12,4 +14,4 @@ testmagvar_SOURCES = testmagvar.cxx
testmagvar_LDADD = $(top_builddir)/simgear/magvar/libsgmagvar.a
INCLUDES += -I$(top_builddir)
INCLUDES = -I$(top_srcdir)

452
simgear/magvar/coremag.cxx Normal file
View File

@@ -0,0 +1,452 @@
// coremag.cxx -- compute local magnetic variation given position,
// altitude, and date
//
// This is an implementation of the NIMA (formerly DMA) WMM2000
//
// http://www.nima.mil/GandG/ngdc-wmm2000.html
//
// Copyright (C) 2000 Edward A Williams <Ed_Williams@compuserve.com>
//
// Adapted from Excel 3.0 version 3/27/94 EAW
// Recoded in C++ by Starry Chan
// WMM95 added and rearranged in ANSI-C EAW 7/9/95
// Put shell around program and made Borland & GCC compatible EAW 11/22/95
// IGRF95 added 2/96 EAW
// WMM2000 IGR2000 added 2/00 EAW
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
//
// Removed all pow() calls and made static roots[][] arrays to
// save many sqrt() calls on subsequent invocations
// left old code as SGMagVarOrig() for testing purposes
// 3/28/2000 Norman Vine -- nhv@yahoo.com
//
// Put in some bullet-proofing to handle magnetic and geographic poles.
// 3/28/2000 EAW
// The routine uses a spherical harmonic expansion of the magnetic
// potential up to twelfth order, together with its time variation, as
// described in Chapter 4 of "Geomagnetism, Vol 1, Ed. J.A.Jacobs,
// Academic Press (London 1987)". The program first converts geodetic
// coordinates (lat/long on elliptic earth and altitude) to spherical
// geocentric (spherical lat/long and radius) coordinates. Using this,
// the spherical (B_r, B_theta, B_phi) magnetic field components are
// computed from the model. These are finally referred to surface (X, Y,
// Z) coordinates.
//
// Fields are accurate to better than 200nT, variation and dip to
// better than 0.5 degrees, with the exception of the declination near
// the magnetic poles (where it is ill-defined) where the error may reach
// 4 degrees or more.
//
// Variation is undefined at both the geographic and
// magnetic poles, even though the field itself is well-behaved. To
// avoid the routine blowing up, latitude entries corresponding to
// the geographic poles are slightly offset. At the magnetic poles,
// the routine returns zero variation.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <simgear/constants.h>
#include <simgear/sg_inlines.h>
#include "coremag.hxx"
static const double pi = 3.14159265358979;
static const double a = 6378.16; /* major radius (km) IAU66 ellipsoid */
static const double f = 1.0 / 298.25; /* inverse flattening IAU66 ellipsoid */
static const double b = 6378.16 * (1.0 -1.0 / 298.25 );
/* minor radius b=a*(1-f) */
static const double r_0 = 6371.2; /* "mean radius" for spherical harmonic expansion */
static double gnm_wmm2000[13][13] =
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-29616.0, -1722.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-2266.7, 3070.2, 1677.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1322.4, -2291.5, 1255.9, 724.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{932.1, 786.3, 250.6, -401.5, 106.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-211.9, 351.6, 220.8, -134.5, -168.8, -13.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{73.8, 68.2, 74.1, -163.5, -3.8, 17.1, -85.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{77.4, -73.9, 2.2, 35.7, 7.3, 5.2, 8.4, -1.5, 0.0, 0.0, 0.0, 0.0, 0.0},
{23.3, 7.3, -8.5, -6.6, -16.9, 8.6, 4.9, -7.8, -7.6, 0.0, 0.0, 0.0, 0.0},
{5.7, 8.5, 2.0, -9.8, 7.6, -7.0, -2.0, 9.2, -2.2, -6.6, 0.0, 0.0, 0.0},
{-2.2, -5.7, 1.6, -3.7, -0.6, 4.1, 2.2, 2.2, 4.6, 2.3, 0.1, 0.0, 0.0},
{3.3, -1.1, -2.4, 2.6, -1.3, -1.7, -0.6, 0.4, 0.7, -0.3, 2.3, 4.2, 0.0},
{-1.5, -0.2, -0.3, 0.5, 0.2, 0.9, -1.4, 0.6, -0.6, -1.0, -0.3, 0.3, 0.4},
};
static double hnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 5194.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -2484.8, -467.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -224.7, 293.0, -486.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 273.3, -227.9, 120.9, -302.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 42.0, 173.8, -135.0, -38.6, 105.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -17.4, 61.2, 63.2, -62.9, 0.2, 43.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -62.3, -24.5, 8.9, 23.4, 15.0, -27.6, -7.8, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 12.4, -20.8, 8.4, -21.2, 15.5, 9.1, -15.5, -5.4, 0.0, 0.0, 0.0, 0.0},
{0.0, -20.4, 13.9, 12.0, -6.2, -8.6, 9.4, 5.0, -8.4, 3.2, 0.0, 0.0, 0.0},
{0.0, 0.9, -0.7, 3.9, 4.8, -5.3, -1.0, -2.4, 1.3, -2.3, -6.4, 0.0, 0.0},
{0.0, -1.5, 0.7, -1.1, -2.3, 1.3, -0.6, -2.8, -1.6, -0.1, -1.9, 1.4, 0.0},
{0.0, -1.0, 0.7, 2.2, -2.5, -0.2, 0.0, -0.2, 0.0, 0.2, -0.9, -0.2, 1.0},
};
static double gtnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{14.7, 11.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-13.6, -0.7, -1.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.3, -4.3, 0.9, -8.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-1.6, 0.9, -7.6, 2.2, -3.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.9, -0.2, -2.5, -2.7, -0.9, 1.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.2, 0.2, 1.7, 1.6, -0.1, -0.3, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.4, -0.8, -0.2, 1.1, 0.4, 0.0, -0.2, -0.2, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.3, 0.6, -0.8, 0.3, -0.2, 0.5, 0.0, -0.6, 0.1, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
};
static double htnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -20.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -21.5, -9.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 6.4, -1.3, -13.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 2.3, 0.7, 3.7, -0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 2.1, 2.3, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -0.3, -1.7, -0.9, -1.0, -0.1, 1.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.4, 0.2, 0.7, 0.4, -0.3, -0.8, -0.1, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -0.5, 0.1, -0.2, 0.0, 0.1, -0.1, 0.3, 0.2, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
};
static const int nmax = 12;
static double P[13][13];
static double DP[13][13];
static double gnm[13][13];
static double hnm[13][13];
static double sm[13];
static double cm[13];
static double root[13];
static double roots[13][13][2];
/* Convert date to Julian day 1950-2049 */
unsigned long int yymmdd_to_julian_days( int yy, int mm, int dd )
{
unsigned long jd;
yy = (yy < 50) ? (2000 + yy) : (1900 + yy);
jd = dd - 32075L + 1461L * (yy + 4800L + (mm - 14) / 12 ) / 4;
jd = jd + 367L * (mm - 2 - (mm - 14) / 12*12) / 12;
jd = jd - 3 * ((yy + 4900L + (mm - 14) / 12) / 100) / 4;
/* printf("julian date = %d\n", jd ); */
return jd;
}
/*
* return variation (in radians) given geodetic latitude (radians),
* longitude(radians), height (km) and (Julian) date
* N and E lat and long are positive, S and W negative
*/
double calc_magvar( double lat, double lon, double h, long dat, double* field )
{
/* output field B_r,B_th,B_phi,B_x,B_y,B_z */
int n,m;
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double yearfrac,sr,r,theta,c,s,psi,fn,fn_0,B_r,B_theta,B_phi,X,Y,Z;
double sinpsi, cospsi, inv_s;
static int been_here = 0;
double sinlat = sin(lat);
double coslat = cos(lat);
/* convert to geocentric coords: */
// sr = sqrt(pow(a*coslat,2.0)+pow(b*sinlat,2.0));
sr = sqrt(a*a*coslat*coslat + b*b*sinlat*sinlat);
/* sr is effective radius */
theta = atan2(coslat * (h*sr + a*a),
sinlat * (h*sr + b*b));
/* theta is geocentric co-latitude */
r = h*h + 2.0*h * sr +
(a*a*a*a - ( a*a*a*a - b*b*b*b ) * sinlat*sinlat ) /
(a*a - (a*a - b*b) * sinlat*sinlat );
r = sqrt(r);
/* r is geocentric radial distance */
c = cos(theta);
s = sin(theta);
/* protect against zero divide at geographic poles */
inv_s = 1.0 / (s + (s == 0.)*1.0e-8);
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
DP[n][m] = 0;
}
}
/* diagonal elements */
P[0][0] = 1;
P[1][1] = s;
DP[0][0] = 0;
DP[1][1] = c;
P[1][0] = c ;
DP[1][0] = -s;
// these values will not change for subsequent function calls
if( !been_here ) {
for ( n = 2; n <= nmax; n++ ) {
root[n] = sqrt((2.0*n-1) / (2.0*n));
}
for ( m = 0; m <= nmax; m++ ) {
double mm = m*m;
for ( n = SG_MAX2(m + 1, 2); n <= nmax; n++ ) {
roots[m][n][0] = sqrt((n-1)*(n-1) - mm);
roots[m][n][1] = 1.0 / sqrt( n*n - mm);
}
}
been_here = 1;
}
for ( n=2; n <= nmax; n++ ) {
// double root = sqrt((2.0*n-1) / (2.0*n));
P[n][n] = P[n-1][n-1] * s * root[n];
DP[n][n] = (DP[n-1][n-1] * s + P[n-1][n-1] * c) *
root[n];
}
/* lower triangle */
for ( m = 0; m <= nmax; m++ ) {
// double mm = m*m;
for ( n = SG_MAX2(m + 1, 2); n <= nmax; n++ ) {
// double root1 = sqrt((n-1)*(n-1) - mm);
// double root2 = 1.0 / sqrt( n*n - mm);
P[n][m] = (P[n-1][m] * c * (2.0*n-1) -
P[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
DP[n][m] = ((DP[n-1][m] * c - P[n-1][m] * s) *
(2.0*n-1) - DP[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
}
}
/* compute gnm, hnm at dat */
/* WMM2000 */
yearfrac = (dat - date0_wmm2000) / 365.25;
for ( n = 1; n <= nmax; n++ ) {
for ( m = 0; m <= nmax; m++ ) {
gnm[n][m] = gnm_wmm2000[n][m] + yearfrac * gtnm_wmm2000[n][m];
hnm[n][m] = hnm_wmm2000[n][m] + yearfrac * htnm_wmm2000[n][m];
}
}
/* compute sm (sin(m lon) and cm (cos(m lon)) */
for ( m = 0; m <= nmax; m++ ) {
sm[m] = sin(m * lon);
cm[m] = cos(m * lon);
}
/* compute B fields */
B_r = 0.0;
B_theta = 0.0;
B_phi = 0.0;
fn_0 = r_0/r;
fn = fn_0 * fn_0;
for ( n = 1; n <= nmax; n++ ) {
double c1_n=0;
double c2_n=0;
double c3_n=0;
for ( m = 0; m <= n; m++ ) {
double tmp = (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]);
c1_n=c1_n + tmp * P[n][m];
c2_n=c2_n + tmp * DP[n][m];
c3_n=c3_n + m * (gnm[n][m] * sm[m] - hnm[n][m] * cm[m]) * P[n][m];
}
// fn=pow(r_0/r,n+2.0);
fn *= fn_0;
B_r = B_r + (n + 1) * c1_n * fn;
B_theta = B_theta - c2_n * fn;
B_phi = B_phi + c3_n * fn * inv_s;
}
/* Find geodetic field components: */
psi = theta - ((pi / 2.0) - lat);
sinpsi = sin(psi);
cospsi = cos(psi);
X = -B_theta * cospsi - B_r * sinpsi;
Y = B_phi;
Z = B_theta * sinpsi - B_r * cospsi;
field[0]=B_r;
field[1]=B_theta;
field[2]=B_phi;
field[3]=X;
field[4]=Y;
field[5]=Z; /* output fields */
/* find variation in radians */
/* return zero variation at magnetic pole X=Y=0. */
/* E is positive */
return (X != 0. || Y != 0.) ? atan2(Y, X) : (double) 0.;
}
#ifdef TEST_NHV_HACKS
double SGMagVarOrig( double lat, double lon, double h, long dat, double* field )
{
/* output field B_r,B_th,B_phi,B_x,B_y,B_z */
int n,m;
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double yearfrac,sr,r,theta,c,s,psi,fn,B_r,B_theta,B_phi,X,Y,Z;
/* convert to geocentric coords: */
sr = sqrt(pow(a*cos(lat),2.0)+pow(b*sin(lat),2.0));
/* sr is effective radius */
theta = atan2(cos(lat) * (h * sr + a * a),
sin(lat) * (h * sr + b * b));
/* theta is geocentric co-latitude */
r = h * h + 2.0*h * sr +
(pow(a,4.0) - (pow(a,4.0) - pow(b,4.0)) * pow(sin(lat),2.0)) /
(a * a - (a * a - b * b) * pow(sin(lat),2.0));
r = sqrt(r);
/* r is geocentric radial distance */
c = cos(theta);
s = sin(theta);
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
DP[n][m] = 0;
}
}
/* diagonal elements */
P[0][0] = 1;
P[1][1] = s;
DP[0][0] = 0;
DP[1][1] = c;
P[1][0] = c ;
DP[1][0] = -s;
for ( n = 2; n <= nmax; n++ ) {
P[n][n] = P[n-1][n-1] * s * sqrt((2.0*n-1) / (2.0*n));
DP[n][n] = (DP[n-1][n-1] * s + P[n-1][n-1] * c) *
sqrt((2.0*n-1) / (2.0*n));
}
/* lower triangle */
for ( m = 0; m <= nmax; m++ ) {
for ( n = SG_MAX2(m + 1, 2); n <= nmax; n++ ) {
P[n][m] = (P[n-1][m] * c * (2.0*n-1) - P[n-2][m] *
sqrt(1.0*(n-1)*(n-1) - m * m)) /
sqrt(1.0* n * n - m * m);
DP[n][m] = ((DP[n-1][m] * c - P[n-1][m] * s) *
(2.0*n-1) - DP[n-2][m] *
sqrt(1.0*(n-1) * (n-1) - m * m)) /
sqrt(1.0* n * n - m * m);
}
}
/* compute gnm, hnm at dat */
/* WMM2000 */
yearfrac = (dat - date0_wmm2000) / 365.25;
for ( n = 1; n <= nmax; n++ ) {
for ( m = 0; m <= nmax; m++ ) {
gnm[n][m] = gnm_wmm2000[n][m] + yearfrac * gtnm_wmm2000[n][m];
hnm[n][m] = hnm_wmm2000[n][m] + yearfrac * htnm_wmm2000[n][m];
}
}
/* compute sm (sin(m lon) and cm (cos(m lon)) */
for ( m = 0; m <= nmax; m++ ) {
sm[m] = sin(m * lon);
cm[m] = cos(m * lon);
}
/* compute B fields */
B_r = 0.0;
B_theta = 0.0;
B_phi = 0.0;
for ( n = 1; n <= nmax; n++ ) {
double c1_n=0;
double c2_n=0;
double c3_n=0;
for ( m = 0; m <= n; m++ ) {
c1_n=c1_n + (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]) * P[n][m];
c2_n=c2_n + (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]) * DP[n][m];
c3_n=c3_n + m * (gnm[n][m] * sm[m] - hnm[n][m] * cm[m]) * P[n][m];
}
fn=pow(r_0/r,n+2.0);
B_r = B_r + (n + 1) * c1_n * fn;
B_theta = B_theta - c2_n * fn;
B_phi = B_phi + c3_n * fn / s;
}
/* Find geodetic field components: */
psi = theta - (pi / 2.0 - lat);
X = -B_theta * cos(psi) - B_r * sin(psi);
Y = B_phi;
Z = B_theta * sin(psi) - B_r * cos(psi);
field[0]=B_r;
field[1]=B_theta;
field[2]=B_phi;
field[3]=X;
field[4]=Y;
field[5]=Z; /* output fields */
/* find variation, leave in radians! */
return atan2(Y, X); /* E is positive */
}
#endif // TEST_NHV_HACKS

View File

@@ -0,0 +1,51 @@
// coremag.hxx -- compute local magnetic variation given position,
// altitude, and date
//
// This is an implimentation of the NIMA WMM 2000
//
// http://www.nima.mil/GandG/ngdc-wmm2000.html
//
// Copyright (C) 2000 Edward A Williams <Ed_Williams@compuserve.com>
//
// Adapted from Excel 3.0 version 3/27/94 EAW
// Recoded in C++ by Starry Chan
// WMM95 added and rearranged in ANSI-C EAW 7/9/95
// Put shell around program and made Borland & GCC compatible EAW 11/22/95
// IGRF95 added 2/96 EAW
// WMM2000 IGR2000 added 2/00 EAW
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#ifndef SG_MAGVAR_HXX
#define SG_MAGVAR_HXX
/* Convert date to Julian day 1950-2049 */
unsigned long int yymmdd_to_julian_days( int yy, int mm, int dd );
/* return variation (in degrees) given geodetic latitude (radians), longitude
(radians) ,height (km) and (Julian) date
N and E lat and long are positive, S and W negative
*/
double calc_magvar( double lat, double lon, double h, long dat, double* field );
#endif // SG_MAGVAR_HXX

View File

@@ -1,51 +1,8 @@
// magvar.cxx -- compute local magnetic variation given position,
// altitude, and date
// magvar.cxx -- magnetic variation wrapper class
//
// This is an implementation of the NIMA (formerly DMA) WMM2000
// Written by Curtis Olson, started July 2000.
//
// http://www.nima.mil/GandG/ngdc-wmm2000.html
//
// Copyright (C) 2000 Edward A Williams <Ed_Williams@compuserve.com>
//
// Adapted from Excel 3.0 version 3/27/94 EAW
// Recoded in C++ by Starry Chan
// WMM95 added and rearranged in ANSI-C EAW 7/9/95
// Put shell around program and made Borland & GCC compatible EAW 11/22/95
// IGRF95 added 2/96 EAW
// WMM2000 IGR2000 added 2/00 EAW
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
//
// Removed all pow() calls and made static roots[][] arrays to
// save many sqrt() calls on subsequent invocations
// left old code as SGMagVarOrig() for testing purposes
// 3/28/2000 Norman Vine -- nhv@yahoo.com
//
// Put in some bullet-proofing to handle magnetic and geographic poles.
// 3/28/2000 EAW
// The routine uses a spherical harmonic expansion of the magnetic
// potential up to twelfth order, together with its time variation, as
// described in Chapter 4 of "Geomagnetism, Vol 1, Ed. J.A.Jacobs,
// Academic Press (London 1987)". The program first converts geodetic
// coordinates (lat/long on elliptic earth and altitude) to spherical
// geocentric (spherical lat/long and radius) coordinates. Using this,
// the spherical (B_r, B_theta, B_phi) magnetic field components are
// computed from the model. These are finally referred to surface (X, Y,
// Z) coordinates.
//
// Fields are accurate to better than 200nT, variation and dip to
// better than 0.5 degrees, with the exception of the declination near
// the magnetic poles (where it is ill-defined) where the error may reach
// 4 degrees or more.
//
// Variation is undefined at both the geographic and
// magnetic poles, even though the field itself is well-behaved. To
// avoid the routine blowing up, latitude entries corresponding to
// the geographic poles are slightly offset. At the magnetic poles,
// the routine returns zero variation.
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -64,401 +21,37 @@
// $Id$
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <simgear/magvar/magvar.hxx>
#include "coremag.hxx"
#include "magvar.hxx"
#define max(a,b) (((a) > (b)) ? (a) : (b))
static const double pi = 3.14159265358979;
static const double a = 6378.16; /* major radius (km) IAU66 ellipsoid */
static const double f = 1.0 / 298.25; /* inverse flattening IAU66 ellipsoid */
static const double b = 6378.16 * (1.0 -1.0 / 298.25 );
/* minor radius b=a*(1-f) */
static const double r_0 = 6371.2; /* "mean radius" for spherical harmonic expansion */
static double gnm_wmm2000[13][13] =
SGMagVar::SGMagVar()
: magvar(0.0),
magdip(0.0)
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-29616.0, -1722.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-2266.7, 3070.2, 1677.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1322.4, -2291.5, 1255.9, 724.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{932.1, 786.3, 250.6, -401.5, 106.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-211.9, 351.6, 220.8, -134.5, -168.8, -13.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{73.8, 68.2, 74.1, -163.5, -3.8, 17.1, -85.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{77.4, -73.9, 2.2, 35.7, 7.3, 5.2, 8.4, -1.5, 0.0, 0.0, 0.0, 0.0, 0.0},
{23.3, 7.3, -8.5, -6.6, -16.9, 8.6, 4.9, -7.8, -7.6, 0.0, 0.0, 0.0, 0.0},
{5.7, 8.5, 2.0, -9.8, 7.6, -7.0, -2.0, 9.2, -2.2, -6.6, 0.0, 0.0, 0.0},
{-2.2, -5.7, 1.6, -3.7, -0.6, 4.1, 2.2, 2.2, 4.6, 2.3, 0.1, 0.0, 0.0},
{3.3, -1.1, -2.4, 2.6, -1.3, -1.7, -0.6, 0.4, 0.7, -0.3, 2.3, 4.2, 0.0},
{-1.5, -0.2, -0.3, 0.5, 0.2, 0.9, -1.4, 0.6, -0.6, -1.0, -0.3, 0.3, 0.4},
};
}
static double hnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 5194.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -2484.8, -467.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -224.7, 293.0, -486.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 273.3, -227.9, 120.9, -302.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 42.0, 173.8, -135.0, -38.6, 105.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -17.4, 61.2, 63.2, -62.9, 0.2, 43.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -62.3, -24.5, 8.9, 23.4, 15.0, -27.6, -7.8, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 12.4, -20.8, 8.4, -21.2, 15.5, 9.1, -15.5, -5.4, 0.0, 0.0, 0.0, 0.0},
{0.0, -20.4, 13.9, 12.0, -6.2, -8.6, 9.4, 5.0, -8.4, 3.2, 0.0, 0.0, 0.0},
{0.0, 0.9, -0.7, 3.9, 4.8, -5.3, -1.0, -2.4, 1.3, -2.3, -6.4, 0.0, 0.0},
{0.0, -1.5, 0.7, -1.1, -2.3, 1.3, -0.6, -2.8, -1.6, -0.1, -1.9, 1.4, 0.0},
{0.0, -1.0, 0.7, 2.2, -2.5, -0.2, 0.0, -0.2, 0.0, 0.2, -0.9, -0.2, 1.0},
};
static double gtnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{14.7, 11.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-13.6, -0.7, -1.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.3, -4.3, 0.9, -8.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-1.6, 0.9, -7.6, 2.2, -3.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.9, -0.2, -2.5, -2.7, -0.9, 1.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.2, 0.2, 1.7, 1.6, -0.1, -0.3, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.4, -0.8, -0.2, 1.1, 0.4, 0.0, -0.2, -0.2, 0.0, 0.0, 0.0, 0.0, 0.0},
{-0.3, 0.6, -0.8, 0.3, -0.2, 0.5, 0.0, -0.6, 0.1, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
};
static double htnm_wmm2000[13][13]=
{
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -20.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -21.5, -9.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 6.4, -1.3, -13.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 2.3, 0.7, 3.7, -0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 2.1, 2.3, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -0.3, -1.7, -0.9, -1.0, -0.1, 1.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.4, 0.2, 0.7, 0.4, -0.3, -0.8, -0.1, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, -0.5, 0.1, -0.2, 0.0, 0.1, -0.1, 0.3, 0.2, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
};
static const int nmax = 12;
static double P[13][13];
static double DP[13][13];
static double gnm[13][13];
static double hnm[13][13];
static double sm[13];
static double cm[13];
static double root[13];
static double roots[13][13][2];
/* Convert date to Julian day 1950-2049 */
unsigned long int yymmdd_to_julian_days( int yy, int mm, int dd )
{
unsigned long jd;
yy = (yy < 50) ? (2000 + yy) : (1900 + yy);
jd = dd - 32075L + 1461L * (yy + 4800L + (mm - 14) / 12 ) / 4;
jd = jd + 367L * (mm - 2 - (mm - 14) / 12*12) / 12;
jd = jd - 3 * ((yy + 4900L + (mm - 14) / 12) / 100) / 4;
/* printf("julian date = %d\n", jd ); */
return jd;
}
/* Convert degrees to radians */
double deg_to_rad( double deg )
{
return deg*pi/180.;
SGMagVar::~SGMagVar() {
}
/* Convert radians to degrees */
double rad_to_deg( double rad )
{
return rad*180./pi;
}
/*
* return variation (in radians) given geodetic latitude (radians),
* longitude(radians), height (km) and (Julian) date
* N and E lat and long are positive, S and W negative
*/
double SGMagVar( double lat, double lon, double h, long dat, double* field )
{
/* output field B_r,B_th,B_phi,B_x,B_y,B_z */
int n,m;
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double yearfrac,sr,r,theta,c,s,psi,fn,fn_0,B_r,B_theta,B_phi,X,Y,Z;
double sinpsi, cospsi, inv_s;
static int been_here = 0;
double sinlat = sin(lat);
double coslat = cos(lat);
/* convert to geocentric coords: */
// sr = sqrt(pow(a*coslat,2.0)+pow(b*sinlat,2.0));
sr = sqrt(a*a*coslat*coslat + b*b*sinlat*sinlat);
/* sr is effective radius */
theta = atan2(coslat * (h*sr + a*a),
sinlat * (h*sr + b*b));
/* theta is geocentric co-latitude */
r = h*h + 2.0*h * sr +
(a*a*a*a - ( a*a*a*a - b*b*b*b ) * sinlat*sinlat ) /
(a*a - (a*a - b*b) * sinlat*sinlat );
r = sqrt(r);
/* r is geocentric radial distance */
c = cos(theta);
s = sin(theta);
/* protect against zero divide at geographic poles */
inv_s = 1.0 / (s + (s == 0.)*1.0e-8);
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
DP[n][m] = 0;
}
}
/* diagonal elements */
P[0][0] = 1;
P[1][1] = s;
DP[0][0] = 0;
DP[1][1] = c;
P[1][0] = c ;
DP[1][0] = -s;
// these values will not change for subsequent function calls
if( !been_here ) {
for ( n = 2; n <= nmax; n++ ) {
root[n] = sqrt((2.0*n-1) / (2.0*n));
}
for ( m = 0; m <= nmax; m++ ) {
double mm = m*m;
for ( n = max(m + 1, 2); n <= nmax; n++ ) {
roots[m][n][0] = sqrt((n-1)*(n-1) - mm);
roots[m][n][1] = 1.0 / sqrt( n*n - mm);
}
}
been_here = 1;
}
for ( n=2; n <= nmax; n++ ) {
// double root = sqrt((2.0*n-1) / (2.0*n));
P[n][n] = P[n-1][n-1] * s * root[n];
DP[n][n] = (DP[n-1][n-1] * s + P[n-1][n-1] * c) *
root[n];
}
/* lower triangle */
for ( m = 0; m <= nmax; m++ ) {
// double mm = m*m;
for ( n = max(m + 1, 2); n <= nmax; n++ ) {
// double root1 = sqrt((n-1)*(n-1) - mm);
// double root2 = 1.0 / sqrt( n*n - mm);
P[n][m] = (P[n-1][m] * c * (2.0*n-1) -
P[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
DP[n][m] = ((DP[n-1][m] * c - P[n-1][m] * s) *
(2.0*n-1) - DP[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
}
}
/* compute gnm, hnm at dat */
/* WMM2000 */
yearfrac = (dat - date0_wmm2000) / 365.25;
for ( n = 1; n <= nmax; n++ ) {
for ( m = 0; m <= nmax; m++ ) {
gnm[n][m] = gnm_wmm2000[n][m] + yearfrac * gtnm_wmm2000[n][m];
hnm[n][m] = hnm_wmm2000[n][m] + yearfrac * htnm_wmm2000[n][m];
}
}
/* compute sm (sin(m lon) and cm (cos(m lon)) */
for ( m = 0; m <= nmax; m++ ) {
sm[m] = sin(m * lon);
cm[m] = cos(m * lon);
}
/* compute B fields */
B_r = 0.0;
B_theta = 0.0;
B_phi = 0.0;
fn_0 = r_0/r;
fn = fn_0 * fn_0;
for ( n = 1; n <= nmax; n++ ) {
double c1_n=0;
double c2_n=0;
double c3_n=0;
for ( m = 0; m <= n; m++ ) {
double tmp = (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]);
c1_n=c1_n + tmp * P[n][m];
c2_n=c2_n + tmp * DP[n][m];
c3_n=c3_n + m * (gnm[n][m] * sm[m] - hnm[n][m] * cm[m]) * P[n][m];
}
// fn=pow(r_0/r,n+2.0);
fn *= fn_0;
B_r = B_r + (n + 1) * c1_n * fn;
B_theta = B_theta - c2_n * fn;
B_phi = B_phi + c3_n * fn * inv_s;
}
/* Find geodetic field components: */
psi = theta - ((pi / 2.0) - lat);
sinpsi = sin(psi);
cospsi = cos(psi);
X = -B_theta * cospsi - B_r * sinpsi;
Y = B_phi;
Z = B_theta * sinpsi - B_r * cospsi;
field[0]=B_r;
field[1]=B_theta;
field[2]=B_phi;
field[3]=X;
field[4]=Y;
field[5]=Z; /* output fields */
/* find variation in radians */
/* return zero variation at magnetic pole X=Y=0. */
/* E is positive */
return (X != 0. || Y != 0.) ? atan2(Y, X) : (double) 0.;
void SGMagVar::update( double lon, double lat, double alt_m, double jd ) {
// Calculate local magnetic variation
double field[6];
// cout << "alt_m = " << alt_m << endl;
magvar = calc_magvar( lat, lon, alt_m / 1000.0, (long)jd, field );
magdip = atan(field[5]/sqrt(field[3]*field[3]+field[4]*field[4]));
}
#ifdef TEST_NHV_HACKS
double SGMagVarOrig( double lat, double lon, double h, long dat, double* field )
{
/* output field B_r,B_th,B_phi,B_x,B_y,B_z */
int n,m;
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double sgGetMagVar( double lon, double lat, double alt_m, double jd ) {
// cout << "lat = " << lat << " lon = " << lon << " elev = " << alt_m
// << " JD = " << jd << endl;
double yearfrac,sr,r,theta,c,s,psi,fn,B_r,B_theta,B_phi,X,Y,Z;
/* convert to geocentric coords: */
sr = sqrt(pow(a*cos(lat),2.0)+pow(b*sin(lat),2.0));
/* sr is effective radius */
theta = atan2(cos(lat) * (h * sr + a * a),
sin(lat) * (h * sr + b * b));
/* theta is geocentric co-latitude */
r = h * h + 2.0*h * sr +
(pow(a,4.0) - (pow(a,4.0) - pow(b,4.0)) * pow(sin(lat),2.0)) /
(a * a - (a * a - b * b) * pow(sin(lat),2.0));
r = sqrt(r);
/* r is geocentric radial distance */
c = cos(theta);
s = sin(theta);
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
DP[n][m] = 0;
}
}
/* diagonal elements */
P[0][0] = 1;
P[1][1] = s;
DP[0][0] = 0;
DP[1][1] = c;
P[1][0] = c ;
DP[1][0] = -s;
for ( n = 2; n <= nmax; n++ ) {
P[n][n] = P[n-1][n-1] * s * sqrt((2.0*n-1) / (2.0*n));
DP[n][n] = (DP[n-1][n-1] * s + P[n-1][n-1] * c) *
sqrt((2.0*n-1) / (2.0*n));
}
/* lower triangle */
for ( m = 0; m <= nmax; m++ ) {
for ( n = max(m + 1, 2); n <= nmax; n++ ) {
P[n][m] = (P[n-1][m] * c * (2.0*n-1) - P[n-2][m] *
sqrt(1.0*(n-1)*(n-1) - m * m)) /
sqrt(1.0* n * n - m * m);
DP[n][m] = ((DP[n-1][m] * c - P[n-1][m] * s) *
(2.0*n-1) - DP[n-2][m] *
sqrt(1.0*(n-1) * (n-1) - m * m)) /
sqrt(1.0* n * n - m * m);
}
}
/* compute gnm, hnm at dat */
/* WMM2000 */
yearfrac = (dat - date0_wmm2000) / 365.25;
for ( n = 1; n <= nmax; n++ ) {
for ( m = 0; m <= nmax; m++ ) {
gnm[n][m] = gnm_wmm2000[n][m] + yearfrac * gtnm_wmm2000[n][m];
hnm[n][m] = hnm_wmm2000[n][m] + yearfrac * htnm_wmm2000[n][m];
}
}
/* compute sm (sin(m lon) and cm (cos(m lon)) */
for ( m = 0; m <= nmax; m++ ) {
sm[m] = sin(m * lon);
cm[m] = cos(m * lon);
}
/* compute B fields */
B_r = 0.0;
B_theta = 0.0;
B_phi = 0.0;
for ( n = 1; n <= nmax; n++ ) {
double c1_n=0;
double c2_n=0;
double c3_n=0;
for ( m = 0; m <= n; m++ ) {
c1_n=c1_n + (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]) * P[n][m];
c2_n=c2_n + (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]) * DP[n][m];
c3_n=c3_n + m * (gnm[n][m] * sm[m] - hnm[n][m] * cm[m]) * P[n][m];
}
fn=pow(r_0/r,n+2.0);
B_r = B_r + (n + 1) * c1_n * fn;
B_theta = B_theta - c2_n * fn;
B_phi = B_phi + c3_n * fn / s;
}
/* Find geodetic field components: */
psi = theta - (pi / 2.0 - lat);
X = -B_theta * cos(psi) - B_r * sin(psi);
Y = B_phi;
Z = B_theta * sin(psi) - B_r * cos(psi);
field[0]=B_r;
field[1]=B_theta;
field[2]=B_phi;
field[3]=X;
field[4]=Y;
field[5]=Z; /* output fields */
/* find variation, leave in radians! */
return atan2(Y, X); /* E is positive */
double field[6];
return calc_magvar( lat, lon, alt_m / 1000.0, (long)jd, field );
}
#endif // TEST_NHV_HACKS

View File

@@ -1,20 +1,11 @@
// magvar.hxx -- compute local magnetic variation given position,
// altitude, and date
/**
* \file magvar.hxx
* Magnetic variation wrapper class.
*/
// Written by Curtis Olson, started July 2000.
//
// This is an implimentation of the NIMA WMM 2000
//
// http://www.nima.mil/GandG/ngdc-wmm2000.html
//
// Copyright (C) 2000 Edward A Williams <Ed_Williams@compuserve.com>
//
// Adapted from Excel 3.0 version 3/27/94 EAW
// Recoded in C++ by Starry Chan
// WMM95 added and rearranged in ANSI-C EAW 7/9/95
// Put shell around program and made Borland & GCC compatible EAW 11/22/95
// IGRF95 added 2/96 EAW
// WMM2000 IGR2000 added 2/00 EAW
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,24 +24,76 @@
// $Id$
#ifndef SG_MAGVAR_HXX
#define SG_MAGVAR_HXX
#ifndef _MAGVAR_HXX
#define _MAGVAR_HXX
/* Convert date to Julian day 1950-2049 */
unsigned long int yymmdd_to_julian_days( int yy, int mm, int dd );
/* Convert degrees to radians */
double deg_to_rad( double deg );
/* Convert radians to degrees */
double rad_to_deg( double rad );
/* return variation (in degrees) given geodetic latitude (radians), longitude
(radians) ,height (km) and (Julian) date
N and E lat and long are positive, S and W negative
*/
double SGMagVar( double lat, double lon, double h, long dat, double* field );
#ifndef __cplusplus
# error This library requires C++
#endif
#endif // SG_MAGVAR_HXX
/**
* Magnetic variation wrapper class.
*
* The SGMagVar class calculates the magnetic variation and dip for
* any position, altitude, and time. It is a complete
* re-implimentation of the NIMA WMM 2000 (not derived from their demo
* code.)
*
* The SGMagVar class is really a simple wrapper around the core Ed
* Williams code which does all the hard work. This class allows you
* to crunch the math once and then do multiple polls of the
* data. However, if your position, altitude, or time has changed
* significantly, you should call the update() method to recrunch new
* numbers.
*/
class SGMagVar {
private:
double magvar;
double magdip;
public:
/**
* This creates an instance of the SGMagVar object.
* You must call the update() method before any queries will be valid.
*/
SGMagVar();
/** Destructor */
~SGMagVar();
/** Recalculate the magnetic offset and dip.
* The update() method requires you to pass in your position and
* the julian date. Lon and lat are specified in radians, altitude
* is specified in meters. Julian date can be conveniently
* calculated by using an instance of the SGTime class.
* @param lon longitude in radians
* @param lat latitude in radians
* @param alt_m altitude above sea level in meters
* @param jd julian date
*/
void update( double lon, double lat, double alt_m, double jd );
/** @return the current magnetic variation in radians. */
double get_magvar() const { return magvar; }
/** @return the current magnetic dip in radians. */
double get_magdip() const { return magdip; }
};
/**
* \relates SGMagVar
* Lookup the magvar for any arbitrary location (This function doesn't
* save state like the SGMagVar class. This function triggers a fair
* amount of CPU work, so use it cautiously.
* @return the magvar in radians
*/
double sgGetMagVar( double lon, double lat, double alt_m, double jd );
#endif // _MAGVAR_HXX

View File

@@ -4,7 +4,9 @@
#include <stdlib.h>
#include <math.h>
#include "magvar.hxx"
#include <simgear/constants.h>
#include "coremag.hxx"
int main(int argc, char *argv[])
@@ -40,15 +42,15 @@ if (argc == 8){
}
var = SGMagVar( deg_to_rad(lat_deg), deg_to_rad(lon_deg), h,
yymmdd_to_julian_days(yy,mm,dd), field );
var = calc_magvar( SGD_DEGREES_TO_RADIANS * lat_deg, SGD_DEGREES_TO_RADIANS * lon_deg, h,
yymmdd_to_julian_days(yy,mm,dd), field );
fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[0], field[1], field[2] );
fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[3], field[4], field[5] );
fprintf(stdout,"%6.0lf %6.0lf %6.0lf %4.2lf %4.2lf \n",
fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[0], field[1], field[2] );
fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[3], field[4], field[5] );
fprintf(stdout,"%6.0f %6.0f %6.0f %4.2f %4.2f \n",
field[3],field[4],field[5],
rad_to_deg(atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
rad_to_deg(var));
SGD_RADIANS_TO_DEGREES * (atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
SGD_RADIANS_TO_DEGREES * var);
exit(0);
}

3
simgear/math/.cvsignore Normal file
View File

@@ -0,0 +1,3 @@
.deps
Makefile
Makefile.in

View File

@@ -1,32 +1,27 @@
includedir = @includedir@/math
if HAVE_ZLIB
ZLIB_INCL =
else
ZLIB_INCL = -I$(top_builddir)/src/zlib
endif
lib_LIBRARIES = libsgmath.a
include_HEADERS = \
fg_geodesy.hxx \
fg_memory.h \
fg_random.h \
fg_types.hxx \
interpolater.hxx \
leastsqs.hxx \
localconsts.hxx \
point3d.hxx \
polar3d.hxx \
sg_geodesy.hxx \
sg_memory.h \
sg_random.h \
sg_types.hxx \
vector.hxx
EXTRA_DIST = linintp2.h linintp2.inl sphrintp.h sphrintp.inl
libsgmath_a_SOURCES = \
fg_geodesy.cxx \
fg_random.c \
interpolater.cxx \
leastsqs.cxx \
polar3d.cxx \
sg_geodesy.cxx \
sg_random.c \
vector.cxx
INCLUDES += -I$(top_builddir) $(ZLIB_INCL)
INCLUDES = -I$(top_srcdir)

View File

@@ -1,59 +0,0 @@
// fg_memory.h -- memcpy/bcopy portability declarations
//
// 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 _FG_MEMORY_H
#define _FG_MEMORY_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_MEMCPY
# ifdef HAVE_MEMORY_H
# include <memory.h>
# endif
# define fgmemcmp memcmp
# define fgmemcpy memcpy
# define fgmemzero(dest,len) memset(dest,0,len)
#elif defined(HAVE_BCOPY)
# define fgmemcmp bcmp
# define fgmemcpy(dest,src,n) bcopy(src,dest,n)
# define fgmemzero bzero
#else
/*
* Neither memcpy() or bcopy() available.
* Use substitutes provided be zlib.
*/
# include <zutil.h>
# define fgmemcmp zmemcmp
# define fgmemcpy zmemcpy
# define fgmemzero zmemzero
#endif
#endif // _FG_MEMORY_H

View File

@@ -1,71 +0,0 @@
// fg_random.c -- routines to handle random number generation
//
// Written by Curtis Olson, started July 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
#include <stdio.h>
#include <stdlib.h> // for random(), srandom()
#include <time.h> // for time() to seed srandom()
#include "fg_random.h"
#ifndef HAVE_RAND
# ifdef sgi
# undef RAND_MAX
# define RAND_MAX 2147483647
# endif
#endif
#ifdef __SUNPRO_CC
extern "C" {
long int random(void);
void srandom(unsigned int seed);
}
#endif
// Seed the random number generater with time() so we don't see the
// same sequence every time
void fg_srandom(void) {
// fgPrintf( FG_MATH, FG_INFO, "Seeding random number generater\n");
#ifdef HAVE_RAND
srand(time(NULL));
#else
srandom(time(NULL));
#endif
}
// return a random number between [0.0, 1.0)
double fg_random(void) {
#ifdef HAVE_RAND
return(rand() / (double)RAND_MAX);
#else
return(random() / (double)RAND_MAX);
#endif
}

View File

@@ -1,48 +0,0 @@
// fg_random.h -- routines to handle random number generation
//
// Written by Curtis Olson, started July 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 _FG_RANDOM_H
#define _FG_RANDOM_H
#ifdef __cplusplus
extern "C" {
#endif
// Seed the random number generater with time() so we don't see the
// same sequence every time
void fg_srandom(void);
// return a random number between [0.0, 1.0)
double fg_random(void);
#ifdef __cplusplus
}
#endif
#endif // _FG_RANDOM_H

Some files were not shown because too many files have changed in this diff Show More