Compare commits

..

59 Commits

Author SHA1 Message Date
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
curt
a1c59071a1 Changes by David Megginson. 2000-05-16 16:21:08 +00:00
curt
13af443057 cygwin32 fix for gdbm 2000-04-27 01:28:22 +00:00
curt
b8e2b0d0f9 Fixes for cygwin32 builds. 2000-04-27 01:26:36 +00:00
curt
53cd776bf6 Tweaks. 2000-03-30 00:48:38 +00:00
113 changed files with 8247 additions and 1419 deletions

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!

View File

@@ -2,6 +2,94 @@ EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h
SUBDIRS = simgear
#
# Additional all, clean, and distclean rules for additional packages.
# We can't just include the additional package dirs in SUBDIRS (which
# would be nice because there are then problems with make dist
#
all:
@list='@subdirs@'; \
target=`echo $@`; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done
install:
@list='@subdirs@'; \
target=`echo $@`; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done
clean:
@list='@subdirs@'; \
target=`echo $@`; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done
distclean:
@list='@subdirs@'; \
target=`echo $@`; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done
#
# distclean the associated packages and include them in the dist
#
dist-hook:
tar cf - simgear/metar | (cd $(distdir); tar xvf -)
@list='@subdirs@'; \
target=distclean; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) echo "distclean error ignored...";; *k*) fail=yes;; *) echo "distclean error ignored...";; esac; \
done
tar cf - simgear/metakit | (cd $(distdir); tar xvf -)
#
# Rule to build RPM distribution package
#
@@ -9,6 +97,3 @@ 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 -)

17
NEWS
View File

@@ -1,3 +1,20 @@
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

3
README
View File

@@ -0,0 +1,3 @@
MSVC5 users:
Copy simgear/config.h.vc5 to simgear/config.h before building.

243
README.metakit Normal file
View File

@@ -0,0 +1,243 @@
With the author's permission, SimGear now bundles MetaKit. MetaKit is
explained
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>

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

@@ -182,7 +182,7 @@
#undef HAVE_WAIT3
/* Define if you have gdbm installed system wide. */
#undef HAVE_GDBM
/* #undef HAVE_GDBM */
/* Define if you have zlib installed system wide. */
#undef HAVE_ZLIB

View File

@@ -6,7 +6,7 @@ dnl $Id$
AC_INIT(simgear/bucket/newbucket.cxx)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.0.7)
AM_INIT_AUTOMAKE(SimGear, 0.0.12)
dnl Checks for programs.
AC_PROG_MAKE_SET
@@ -24,11 +24,6 @@ else
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)])
@@ -200,14 +195,26 @@ if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
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."
# 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 metakit
AC_CHECK_HEADER(mk4.h)
if test "x$ac_cv_header_mk4_h" != "xyes"; then
echo "no metakit found, configuring and building."
# Run configure in the metakit subdir
AC_CONFIG_SUBDIRS( simgear/metakit/unix )
fi
AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
AM_CONDITIONAL(HAVE_METAKIT, test "x$ac_cv_header_mk4_h" = "xyes" )
dnl Specify if we want logging (testing build) or not (release build)
dnl Check for system installed zlib
AC_CHECK_HEADER(zlib.h)
@@ -245,17 +252,24 @@ AC_OUTPUT( \
simgear/version.h \
simgear/bucket/Makefile \
simgear/debug/Makefile \
simgear/gdbm/Makefile \
simgear/ephemeris/Makefile \
simgear/io/Makefile \
simgear/magvar/Makefile \
simgear/math/Makefile \
simgear/misc/Makefile \
simgear/screen/Makefile \
simgear/serial/Makefile \
simgear/sky/Makefile \
simgear/timing/Makefile \
simgear/xgl/Makefile \
simgear/zlib/Makefile \
)
# AC_OUTPUT_COMMANDS([./mksymlinks.sh])
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"
@@ -275,8 +289,12 @@ else
echo "Electric fence: no"
fi
if test "x$ac_cv_header_gdbm_h" != "xyes"; then
echo "Building gdbm"
# if test "x$ac_cv_header_gdbm_h" != "xyes"; then
# echo "Building gdbm"
# fi
if test "x$ac_cv_header_mk4_h" != "xyes"; then
echo "Building metakit"
fi
if test "x$ac_cv_header_zlib_h" != "xyes"; then

View File

@@ -4,11 +4,11 @@ else
SERIAL_DIRS =
endif
if HAVE_GDBM
GDBM_DIRS =
else
GDBM_DIRS = gdbm
endif
# if HAVE_GDBM
# GDBM_DIRS =
# else
# GDBM_DIRS = gdbm
# endif
if HAVE_ZLIB
ZLIB_DIRS =
@@ -21,18 +21,22 @@ METAR_DIRS =
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 fg_traits.hxx fg_zlib.h inlines.h version.h
SUBDIRS = \
bucket \
debug \
$(GDBM_DIRS) \
ephemeris \
io \
magvar \
math \
$(METAR_DIRS) \
misc \
screen \
$(SERIAL_DIRS) \
sky \
timing \
xgl \
$(ZLIB_DIRS)

View File

@@ -5,19 +5,20 @@
*
* 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$
**************************************************************************/

View File

@@ -5,19 +5,20 @@
*
* 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$
**************************************************************************/
@@ -73,7 +74,7 @@ private:
int y; // y subdivision (0 to 7)
public:
// default constructor
FGBucket();
@@ -90,6 +91,10 @@ public:
// Set the bucket params for the specified lat and lon
void set_bucket( double dlon, double dlat );
void set_bucket( double *lonlat ) {
set_bucket( lonlat[0], lonlat[1] );
}
void make_bad ( void );
// Generate the unique scenery tile index for this bucket
@@ -227,7 +232,7 @@ inline FGBucket::FGBucket(const bool 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) {
@@ -236,11 +241,11 @@ inline FGBucket::FGBucket(const long int bindex) {
lon = index >> 14;
index -= lon << 14;
lon -= 180;
lat = index >> 6;
index -= lat << 6;
lat -= 90;
y = index >> 3;
index -= y << 3;
@@ -310,9 +315,9 @@ inline double FGBucket::get_height() const {
// create an impossible bucket
inline void FGBucket::make_bad( void ) {
set_bucket(0.0, 0.0);
lon = -1000;
lon = -1000;
}
// offset a bucket struct by the specified tile units in the X & Y
// direction
@@ -323,12 +328,6 @@ FGBucket fgBucketOffset( double dlon, double dlat, int x, int y );
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);
*/
inline ostream&
operator<< ( ostream& out, const FGBucket& b )
{

View File

@@ -1,19 +1,20 @@
/**************************************************************************
* 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$
**************************************************************************/
@@ -127,7 +128,10 @@
// Microsoft compilers.
//
#ifdef _MSC_VER
# if _MSC_VER == 1200 // msvc++ 6.0
# 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 FG_NAMESPACES
# define FG_HAVE_STD
# define FG_HAVE_STD_INCLUDES
@@ -147,7 +151,25 @@
# pragma warning(disable: 4305) //
# elif _MSC_VER == 1100 // msvc++ 5.0
# error MSVC++ 5.0 still to be supported...
# define NEEDNAMESPACESTD
# define FG_NAMESPACES
# define FG_HAVE_STD
# define FG_HAVE_STD_INCLUDES
# define FG_HAVE_STREAMBUF
# define STL_ALGORITHM <algorithm>
# define STL_FUNCTIONAL <functional>
# define STL_IOMANIP <iomanip>
# define STL_IOSTREAM <iostream>
# define STL_FSTREAM <fstream>
# define STL_STDEXCEPT <stdexcept>
# define STL_STRING <string>
# define STL_STRSTREAM <strstream>
# pragma warning(disable: 4786) // identifier was truncated to '255' characters
# pragma warning(disable: 4244) // conversion from double to float
# pragma warning(disable: 4305) //
# else
# error What version of MSVC++ is this?
# endif

View File

@@ -47,9 +47,6 @@
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define if you have gdbm installed system wide. */
#undef HAVE_GDBM
/* Define if you have zlib installed system wide. */
#undef HAVE_ZLIB

View File

@@ -1,58 +1,19 @@
/* simgear/config.h. Generated automatically by configure. */
/* simgear/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Include/config.h. Generated for MSCV++ 5.0 */
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
#define X_DISPLAY_MISSING 1
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to eliminate all trace of debugging messages such as for a
release build */
/* #undef FG_NDEBUG */
/* Define to enable 3dfx/glide render in a window hack under unix.
This probably won't work under windows. */
/* #undef XMESA */
/* #undef FX */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define if you have gdbm installed system wide. */
#define HAVE_GDBM 1
/* Define if you have zlib installed system wide. */
#define HAVE_ZLIB 1
/* Define to package name */
#define PACKAGE "FlightGear"
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
@@ -64,37 +25,31 @@
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* #undef TIME_WITH_SYS_TIME */
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* #define TM_IN_SYS_TIME 1 */
/* Define to version number */
#define VERSION "0.0.8"
/* Define if compiling on a Winbloze (95, NT, etc.) platform */
/* #undef WIN32 */
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
#define WIN32 1
/* Define if you have the GetLocalTime function. */
/* #undef HAVE_GETLOCALTIME */
/* Define if you have the bcopy function. */
#define HAVE_BCOPY 1
#define HAVE_GETLOCALTIME 1
/* Define if you have the ftime function. */
#define HAVE_FTIME 1
/* #define HAVE_FTIME 1 */
/* Define if you have the getitimer function. */
#define HAVE_GETITIMER 1
/* #define HAVE_GETITIMER 1 */
/* Define if you have the getrusage function. */
#define HAVE_GETRUSAGE 1
/* #define HAVE_GETRUSAGE 1 */
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* #define HAVE_GETTIMEOFDAY 1 */
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
@@ -106,10 +61,10 @@
#define HAVE_RANDOM 1
/* Define if you have the rint function. */
#define HAVE_RINT 1
/* #define HAVE_RINT 1 */
/* Define if you have the setitimer function. */
#define HAVE_SETITIMER 1
/* #define HAVE_SETITIMER 1 */
/* Define if you have the signal function. */
#define HAVE_SIGNAL 1
@@ -117,83 +72,71 @@
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the timegm function. */
#define HAVE_TIMEGM 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* #define HAVE_GETOPT_H 1 */
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* #define HAVE_SYS_TIME_H 1 */
/* Define if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* #define HAVE_UNISTD_H 1 */
/* Define if you have the <values.h> header file. */
#define HAVE_VALUES_H 1
/* #define HAVE_VALUES_H 1 */
/* Define if you have the <winbase.h> header file. */
/* #undef HAVE_WINBASE_H */
#define HAVE_WINBASE_H 1
/* Define if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
#define HAVE_WINDOWS_H 1
/* Define if you have the GL library (-lGL). */
#define HAVE_LIBGL 1
/* Define if you have the GLU library (-lGLU). */
/* #undef HAVE_LIBGLU */
#define HAVE_LIBGLU 1
/* Define if you have the GLcore library (-lGLcore). */
/* #undef HAVE_LIBGLCORE */
/* Define if you have the ICE library (-lICE). */
#define HAVE_LIBICE 1
/* #define HAVE_LIBICE 1 */
/* Define if you have the MesaGL library (-lMesaGL). */
/* #undef HAVE_LIBMESAGL */
/* Define if you have the MesaGLU library (-lMesaGLU). */
#define HAVE_LIBMESAGLU 1
/* #undef HAVE_LIBMESAGLU */
/* Define if you have the SM library (-lSM). */
#define HAVE_LIBSM 1
/* #define HAVE_LIBSM 1 */
/* Define if you have the X11 library (-lX11). */
#define HAVE_LIBX11 1
/* #define HAVE_LIBX11 1 */
/* Define if you have the Xext library (-lXext). */
#define HAVE_LIBXEXT 1
/* #define HAVE_LIBXEXT 1 */
/* Define if you have the Xi library (-lXi). */
#define HAVE_LIBXI 1
/* #define HAVE_LIBXI 1 */
/* Define if you have the Xmu library (-lXmu). */
#define HAVE_LIBXMU 1
/* #define HAVE_LIBXMU 1 */
/* Define if you have the Xt library (-lXt). */
#define HAVE_LIBXT 1
/* #define HAVE_LIBXT 1 */
/* Define if you have the glut library (-lglut). */
#define HAVE_LIBGLUT 1
@@ -204,9 +147,8 @@
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Name of package */
#define PACKAGE "SimGear"
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Version number of package */
#define VERSION "0.0.7"
#define HAVE_MEMCPY 1

View File

@@ -4,25 +4,26 @@
//
// 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
#ifndef _SG_CONSTANTS_H
#define _SG_CONSTANTS_H
#ifdef HAVE_CONFIG_H
@@ -140,4 +141,4 @@
#define FG_EPSILON 0.0000001
#endif // _SUPPORTGEAR_CONSTANTS_H
#endif // _SG_CONSTANTS_H

View File

@@ -4,19 +4,20 @@
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// 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$

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 \
moon.hxx \
neptune.hxx \
saturn.hxx \
star.hxx \
stars.hxx \
uranus.hxx \
venus.hxx
libsgephem_a_SOURCES = \
celestialBody.cxx \
ephemeris.cxx \
jupiter.cxx \
mars.cxx \
mercury.cxx \
moon.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 \
stars.cxx \
uranus.cxx \
venus.cxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
INCLUDES += -I$(top_builddir)

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$
**************************************************************************/
@@ -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);
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
@@ -110,7 +111,7 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
};
/****************************************************************************
* 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;

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,7 +84,7 @@ public:
double getMagnitude();
double getLon();
double getLat();
void updatePosition(FGTime *t, Star *ourSun);
void updatePosition(double mjd, Star *ourSun);
};
/*****************************************************************************
@@ -113,7 +112,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
double wf, double ws,
double af, double as,
double ef, double es,
double Mf, double Ms, FGTime *t)
double Mf, double Ms, double mjd)
{
NFirst = Nf; NSec = Ns;
iFirst = If; iSec = Is;
@@ -121,7 +120,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
aFirst = af; aSec = as;
eFirst = ef; eSec = es;
MFirst = Mf; MSec = Ms;
updateOrbElements(t);
updateOrbElements(mjd);
};
inline CelestialBody::CelestialBody(double Nf, double Ns,
@@ -140,17 +139,17 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
};
/****************************************************************************
* inline void CelestialBody::updateOrbElements(FGTime *t)
* inline void CelestialBody::updateOrbElements(double mjd)
* given the current time, this private member calculates the actual
* orbital elements
*
* Arguments: FGTime *t: the current time:
* Arguments: double mjd: the current modified julian date:
*
* return value: none
***************************************************************************/
inline void CelestialBody::updateOrbElements(FGTime *t)
inline void CelestialBody::updateOrbElements(double mjd)
{
double actTime = fgCalcActTime(t);
double actTime = sgCalcActTime(mjd);
M = DEG_TO_RAD * (MFirst + (MSec * actTime));
w = DEG_TO_RAD * (wFirst + (wSec * actTime));
N = DEG_TO_RAD * (NFirst + (NSec * actTime));
@@ -159,7 +158,7 @@ inline void CelestialBody::updateOrbElements(FGTime *t)
a = aFirst + (aSec * actTime);
}
/*****************************************************************************
* inline double CelestialBody::fgCalcActTime(FGTime *t)
* 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).
*
@@ -167,9 +166,9 @@ inline void CelestialBody::updateOrbElements(FGTime *t)
*
* return value: the (fractional) number of days until Jan 1, 2000.
****************************************************************************/
inline double CelestialBody::fgCalcActTime(FGTime *t)
inline double CelestialBody::sgCalcActTime(double mjd)
{
return (t->getMjd() - 36523.5);
return (mjd - 36523.5);
}
/*****************************************************************************

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,7 +27,7 @@
// Constructor
FGEphemeris::FGEphemeris( const string &path ) {
SGEphemeris::SGEphemeris( const string &path ) {
our_sun = new Star;
moon = new Moon;
mercury = new Mercury;
@@ -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( FGPath(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,27 @@
// ephemeris.hxx -- Top level class for calculating current positions of
// astronomical objects
//
// Written by Curtis Olson, started March 2000.
// Top level interface 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,9 +30,11 @@
#define _EPHEMERIS_HXX
#include <plib/sg.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Time/fg_time.hxx>
#include <plib/sg.h>
#include "star.hxx"
#include "moon.hxx"
@@ -42,7 +48,7 @@
#include "stars.hxx"
class FGEphemeris {
class SGEphemeris {
Star *our_sun;
Moon *moon;
@@ -61,19 +67,19 @@ class FGEphemeris {
int nplanets;
sgdVec3 planets[7];
FGStars *stars;
SGStarData *stars;
public:
// Constructor
FGEphemeris( const string &path );
SGEphemeris( const string &path );
// Destructor
~FGEphemeris( void );
~SGEphemeris( void );
// Update (recalculate) the positions of all objects for the
// specified time
void update(FGTime *t, double lat);
void update(double mjd, double lst, double lat);
// sun
inline Star *get_sun() const { return our_sun; }

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"
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"
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"
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

@@ -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$
**************************************************************************/
@@ -28,106 +29,32 @@
#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"
/*************************************************************************
* Moon::Moon(FGTime *t)
* Moon::Moon(double mjd)
* Public constructor for class Moon. Initializes the orbital elements and
* sets up the moon texture.
* Argument: The current time.
* the hard coded orbital elements for Moon are passed to
* CelestialBody::CelestialBody();
************************************************************************/
Moon::Moon(FGTime *t) :
Moon::Moon(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)
{
#if 0
int width, height;
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &moon_texid);
xglBindTexture(GL_TEXTURE_2D, moon_texid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &moon_texid);
xglBindTextureEXT(GL_TEXTURE_2D, moon_texid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// load in the texture data
FGPath tpath( current_options.get_fg_root() );
tpath.append( "Textures" );
tpath.append( "moon.rgb" );
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
== NULL )
{
// Try compressed
FGPath fg_tpath = tpath;
fg_tpath.append( ".gz" );
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
== NULL )
{
FG_LOG( FG_GENERAL, FG_ALERT,
"Error in loading moon texture " << tpath.str() );
exit(-1);
}
}
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGB,
256, 256,
0,
GL_RGB, GL_UNSIGNED_BYTE,
moon_texbuf);
// setup the halo texture
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &moon_halotexid);
xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &moon_halotexid);
xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
setHalo();
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
256, 256,
0,
GL_RGBA, GL_UNSIGNED_BYTE,
moon_halotexbuf);
moonObject = gluNewQuadric();
#endif
}
Moon::Moon() :
@@ -143,70 +70,16 @@ Moon::Moon() :
Moon::~Moon()
{
//delete moonObject;
// delete moon_texbuf;
// delete moon_halotexbuf;
}
#if 0
static int texWidth = 256; /* 64x64 is plenty */
void Moon::setHalo()
{
int texSize;
//void *textureBuf;
GLubyte *p;
int i,j;
double radius;
texSize = texWidth*texWidth;
moon_halotexbuf = new GLubyte[texSize*4];
if (!moon_halotexbuf)
return; // Ugly!
p = moon_halotexbuf;
radius = (double)(texWidth / 2);
for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) {
double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius) {
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*(p+3) = (int)((double) 0x20 * (t*t));
} else {
*(p+3) = 0x00;
}
p += 4;
}
}
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
// GL_LUMINANCE,
// GL_UNSIGNED_BYTE, textureBuf);
//free(textureBuf);
}
#endif
/*****************************************************************************
* void Moon::updatePosition(FGTime *t, Star *ourSun)
* void Moon::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 Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
{
double
eccAnom, ecl, actTime,
@@ -214,19 +87,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
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
@@ -308,7 +175,7 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
if (geoRa < 0)
geoRa += (2*FG_PI);
HA = t->getLst() - (3.8197186 * geoRa);
HA = lst - (3.8197186 * geoRa);
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
<< " HA = " << HA ); */
@@ -322,95 +189,3 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
}
#if 0
/************************************************************************
* void Moon::newImage()
*
* This function regenerates a new visual image of the moon, which is added to
* solarSystem display list.
*
* Arguments: Right Ascension and declination
*
* return value: none
**************************************************************************/
void Moon::newImage()
{
fgLIGHT *l = &cur_light_params;
float moon_angle = l->moon_angle;
/*double x_2, x_4, x_8, x_10;
GLfloat ambient;
GLfloat amb[4];*/
int moonSize = 550;
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
if( moon_angle*RAD_TO_DEG < 100 )
{
FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
xglPushMatrix();
{
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
xglTranslatef(0.0, 60000.0, 0.0);
glEnable(GL_BLEND); // BLEND ENABLED
// Draw the halo...
if (current_options.get_textures())
{
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
glEnd();
}
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
xglEnable( GL_LIGHT0 );
// set lighting parameters
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
// Enable( GL_CULL_FACE );
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
//glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_ONE, GL_ONE);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// Draw the moon-proper
if (current_options.get_textures())
{
glBindTexture(GL_TEXTURE_2D, moon_texid);
gluQuadricTexture(moonObject, GL_TRUE );
}
gluSphere(moonObject, moonSize, 12, 12 );
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
xglPopMatrix();
glDisable(GL_LIGHTING); // Lighting Disabled.
}
else
{
}
}
#endif

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$
**************************************************************************/
@@ -27,10 +28,6 @@
#include <simgear/constants.h>
#include <Aircraft/aircraft.hxx>
#include <Main/views.hxx>
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
#include "star.hxx"
@@ -52,10 +49,10 @@ private:
public:
Moon( FGTime *t);
Moon(double mjd);
Moon();
~Moon();
void updatePosition(FGTime *t, double lat, Star *ourSun);
void updatePosition(double mjd, double lst, double lat, Star *ourSun);
// void newImage();
};

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"
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"
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);
actTime = sgCalcActTime(mjd);
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)
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,7 +26,6 @@
#define _STAR_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx"
@@ -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

@@ -4,19 +4,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,27 +27,30 @@
#include "stars.hxx"
#ifdef _MSC_VER
FG_USING_STD(getline);
#endif
// Constructor
FGStars::FGStars() {
SGStarData::SGStarData() {
}
FGStars::FGStars( FGPath path ) {
SGStarData::SGStarData( FGPath path ) {
data_path = FGPath( 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" );
@@ -66,7 +70,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, ',' );

View File

@@ -4,25 +4,26 @@
//
// 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 _STARS_HXX
#define _STARS_HXX
#ifndef _SG_STARDATA_HXX
#define _SG_STARDATA_HXX
#include <plib/sg.h>
@@ -30,10 +31,10 @@
#include <simgear/misc/fgpath.hxx>
#define FG_MAX_STARS 850
#define SG_MAX_STARS 850
class FGStars {
class SGStarData {
int nstars;
sgdVec3 *stars;
@@ -43,11 +44,11 @@ class FGStars {
public:
// Constructor
FGStars();
FGStars( FGPath path );
SGStarData();
SGStarData( FGPath path );
// Destructor
~FGStars();
~SGStarData();
// load the stars database
bool load();
@@ -58,4 +59,4 @@ public:
};
#endif // _STARS_HXX
#endif // _SG_STARDATA_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"
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"
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

@@ -6,19 +6,20 @@
*
* 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 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$
**************************************************************************/

62
simgear/inlines.h Normal file
View File

@@ -0,0 +1,62 @@
// inlines.h -- various inline template definitions
//
// Written by Norman Vine, started June 2000.
//
// Copyright (C) 2000 Norman Vine - nhv@cape.com
//
// 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_INLINES_H
#define _SG_INLINES_H
template <class T>
inline const int SG_SIGN(const T x) {
return x < T(0) ? -1 : 1;
}
template <class T>
inline const T SG_MIN(const T a, const T b) {
return a < b ? a : b;
}
// return the minimum of three values
template <class T>
inline const T SG_MIN3( const T a, const T b, const T c) {
return (a < b ? SG_MIN (a, c) : SG_MIN (b, c));
}
template <class T>
inline const T SG_MAX(const T a, const T b) {
return a > b ? a : b;
}
// return the maximum of three values
template <class T>
inline const T SG_MAX3 (const T a, const T b, const T c) {
return (a > b ? SG_MAX (a, c) : SG_MAX (b, c));
}
//
template <class T>
inline void SG_SWAP( T &a, T &b) {
T c = a; a = b; b = c;
}
#endif // _SG_INLINES_H

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

@@ -0,0 +1,17 @@
includedir = @includedir@/io
lib_LIBRARIES = libsgio.a
include_HEADERS = \
iochannel.hxx \
sg_file.hxx \
sg_serial.hxx \
sg_socket.hxx
libsgio_a_SOURCES = \
iochannel.cxx \
sg_file.cxx \
sg_serial.cxx \
sg_socket.cxx
INCLUDES += -I$(top_builddir)

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

@@ -0,0 +1,74 @@
// 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"
// #include "garmin.hxx"
// #include "nmea.hxx"
// constructor
SGIOChannel::SGIOChannel()
{
}
// destructor
SGIOChannel::~SGIOChannel()
{
}
// dummy configure routine
bool SGIOChannel::open( SGProtocolDir dir ) {
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( char *buf, int length ) {
return false;
}
// dummy process routine
int SGIOChannel::writestring( char *str ) {
return false;
}
// dummy close routine
bool SGIOChannel::close() {
return false;
}

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

@@ -0,0 +1,78 @@
// iochannel.hxx -- 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$
#ifndef _IOCHANNEL_HXX
#define _IOCHANNEL_HXX
#include <simgear/compiler.h>
// #include "protocol.hxx"
#include STL_STRING
#include <vector>
FG_USING_STD(vector);
FG_USING_STD(string);
#define SG_IO_MAX_MSG_SIZE 16384
enum SGProtocolDir {
SG_IO_NONE = 0,
SG_IO_IN = 1,
SG_IO_OUT = 2,
SG_IO_BI = 3
};
enum SGChannelType {
sgFileType = 0,
sgSerialType = 1,
sgSocketType = 2
};
class SGIOChannel {
SGChannelType type;
public:
SGIOChannel();
virtual ~SGIOChannel();
virtual bool open( SGProtocolDir dir );
virtual int read( char *buf, int length );
virtual int readline( char *buf, int length );
virtual int write( char *buf, int length );
virtual int writestring( char *str );
virtual bool close();
virtual void set_type( SGChannelType t ) { type = t; }
virtual SGChannelType get_type() const { return type; }
};
#endif // _IOCHANNEL_HXX

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

@@ -0,0 +1,156 @@
// 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
#ifdef _MSC_VER
# include <io.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_file.hxx"
FG_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( SGProtocolDir dir ) {
if ( dir == SG_IO_OUT ) {
#ifdef _MSC_VER
fp = _open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
00666 );
#else
fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
S_IROTH | S_IWOTH );
#endif
} else if ( dir == SG_IO_IN ) {
#ifdef _MSC_VER
fp = _open( file_name.c_str(), O_RDONLY );
#else
fp = std::open( file_name.c_str(), O_RDONLY );
#endif
} else {
FG_LOG( FG_IO, FG_ALERT,
"Error: bidirection mode not available for files." );
return false;
}
if ( fp == -1 ) {
FG_LOG( FG_IO, FG_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
#ifdef _MSC_VER
int result = _read( fp, buf, length );
#else
int result = std::read( fp, buf, length );
#endif
return result;
}
// 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
#ifdef _MSC_VER
int result = _read( fp, buf, length );
#else
int result = std::read( fp, buf, length );
#endif
// 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( char *buf, int length ) {
#ifdef _MSC_VER
int result = _write( fp, buf, length );
#else
int result = std::write( fp, buf, length );
#endif
if ( result != length ) {
FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
}
return result;
}
// write null terminated string to a file
int SGFile::writestring( char *str ) {
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGFile::close() {
#ifdef _MSC_VER
if ( _close( fp ) == -1 ) {
#else
if ( std::close( fp ) == -1 ) {
#endif
return false;
}
return true;
}

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

@@ -0,0 +1,82 @@
// 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"
FG_USING_STD(string);
class SGFile : public SGIOChannel {
string file_name;
int fp;
public:
SGFile( const string& file );
~SGFile();
// open the file based on specified direction
bool open( 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( char *buf, int length );
// write null terminated string to a file
int writestring( char *str );
// close file
bool close();
inline string get_file_name() const { return file_name; }
};
#endif // _SG_FILE_HXX

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

@@ -0,0 +1,155 @@
// 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"
FG_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( SGProtocolDir dir ) {
if ( ! port.open_port( device ) ) {
FG_LOG( FG_IO, FG_ALERT, "Error opening device: " << device );
return false;
}
// cout << "fd = " << port.fd << endl;
if ( ! port.set_baud( atoi( baud.c_str() ) ) ) {
FG_LOG( FG_IO, FG_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';
FG_LOG( FG_IO, FG_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( char *buf, int length ) {
int result = port.write_port( buf, length );
if ( result != length ) {
FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << device );
}
return result;
}
// write null terminated string to port
int SGSerial::writestring( char *str ) {
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGSerial::close() {
if ( ! port.close_port() ) {
return false;
}
return true;
}

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

@@ -0,0 +1,88 @@
// 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 FG_HAVE_STD_INCLUDES
// # include <ctime>
// #else
// # include <time.h>
// #endif
#include <simgear/serial/serial.hxx>
#include "iochannel.hxx"
FG_USING_STD(string);
class SGSerial : public SGIOChannel {
string device;
string baud;
FGSerialPort port;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
public:
SGSerial( const string& device_name, const string& baud_rate );
~SGSerial();
// open the serial port based on specified direction
bool open( 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 port
int write( char *buf, int length );
// write null terminated string to port
int writestring( char *str );
// close port
bool close();
inline string get_device() const { return device; }
inline string get_baud() const { return baud; }
};
#endif // _SG_SERIAL_HXX

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

@@ -0,0 +1,415 @@
// 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( _MSC_VER )
# include <sys/time.h> // select()
# include <sys/types.h> // socket(), bind(), select(), accept()
# include <sys/socket.h> // socket(), bind(), listen(), accept()
# include <netinet/in.h> // struct sockaddr_in
# include <netdb.h> // gethostbyname()
# include <unistd.h> // select(), fsync()/fdatasync(), fcntl()
# include <fcntl.h> // fcntl()
#else
# include <sys/timeb.h> // select()
# include <winsock2.h> // socket(), bind(), listen(), accept(),
// struct sockaddr_in, gethostbyname()
# include <windows.h>
# include <io.h>
#endif
#if defined( sgi )
#include <strings.h>
#endif
#include STL_STRING
#include <simgear/debug/logstream.hxx>
#include "sg_socket.hxx"
FG_USING_STD(string);
SGSocket::SGSocket( const string& host, const string& port,
const string& style ) :
save_len(0)
{
hostname = host;
port_str = port;
if ( style == "udp" ) {
sock_style = SOCK_DGRAM;
} else if ( style == "tcp" ) {
sock_style = SOCK_STREAM;
} else {
sock_style = SOCK_DGRAM;
FG_LOG( FG_IO, FG_ALERT,
"Error: SGSocket() unknown style = " << style );
}
set_type( sgSocketType );
}
SGSocket::~SGSocket() {
}
int SGSocket::make_server_socket () {
struct sockaddr_in name;
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER )
int length;
#else
socklen_t length;
#endif
// Create the socket.
sock = socket (PF_INET, sock_style, 0);
if (sock < 0) {
FG_LOG( FG_IO, FG_ALERT,
"Error: socket() failed in make_server_socket()" );
return -1;
}
// Give the socket a name.
name.sin_family = AF_INET;
name.sin_addr.s_addr = INADDR_ANY;
name.sin_port = htons(port); // set port to zero to let system pick
name.sin_addr.s_addr = htonl (INADDR_ANY);
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
FG_LOG( FG_IO, FG_ALERT,
"Error: bind() failed in make_server_socket()" );
return -1;
}
// Find the assigned port number
length = sizeof(struct sockaddr_in);
if ( getsockname(sock, (struct sockaddr *) &name, &length) ) {
FG_LOG( FG_IO, FG_ALERT,
"Error: getsockname() failed in make_server_socket()" );
return -1;
}
port = ntohs(name.sin_port);
return sock;
}
int SGSocket::make_client_socket () {
struct sockaddr_in name;
struct hostent *hp;
FG_LOG( FG_IO, FG_INFO, "Make client socket()" );
// Create the socket.
sock = socket (PF_INET, sock_style, 0);
if (sock < 0) {
FG_LOG( FG_IO, FG_ALERT,
"Error: socket() failed in make_client_socket()" );
return -1;
}
// specify address family
name.sin_family = AF_INET;
// get the hosts official name/info
hp = gethostbyname( hostname.c_str() );
// Connect this socket to the host and the port specified on the
// command line
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
bcopy(hp->h_addr, (char *)(&(name.sin_addr.s_addr)), hp->h_length);
#else
bcopy(hp->h_addr, &(name.sin_addr.s_addr), hp->h_length);
#endif
name.sin_port = htons(port);
if ( connect(sock, (struct sockaddr *) &name,
sizeof(struct sockaddr_in)) < 0 )
{
#ifdef _MSC_VER
_close(sock);
#else
std::close(sock);
#endif
FG_LOG( FG_IO, FG_ALERT,
"Error: connect() failed in make_client_socket()" );
return -1;
}
return sock;
}
// 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 dir ) {
if ( port_str == "" || port_str == "any" ) {
port = 0;
} else {
port = atoi( port_str.c_str() );
}
// client_connections.clear();
if ( dir == 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.
sock = make_server_socket();
FG_LOG( FG_IO, FG_INFO, "socket is connected to port = " << port );
if ( sock_style == SOCK_DGRAM ) {
// Non-blocking UDP
fcntl( sock, F_SETFL, O_NONBLOCK );
} else {
// Blocking TCP
// Specify the maximum length of the connection queue
listen( sock, SG_MAX_SOCKET_QUEUE );
}
} else if ( dir == SG_IO_OUT ) {
// this means client for now
sock = make_client_socket();
if ( sock_style == SOCK_DGRAM ) {
// Non-blocking UDP
fcntl( sock, F_SETFL, O_NONBLOCK );
}
} else {
FG_LOG( FG_IO, FG_ALERT,
"Error: bidirection mode not available yet for sockets." );
return false;
}
if ( sock < 0 ) {
FG_LOG( FG_IO, FG_ALERT, "Error opening socket: " << hostname
<< ":" << port );
return false;
}
return true;
}
// read data from socket (server)
// read a block of data of specified size
int SGSocket::read( char *buf, int length ) {
int result = 0;
// check for potential input
fd_set ready;
FD_ZERO(&ready);
FD_SET(sock, &ready);
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
// test for any input available on sock (returning immediately, even if
// nothing)
select(32, &ready, 0, 0, &tv);
if ( FD_ISSET(sock, &ready) ) {
#ifdef _MSC_VER
result = _read( sock, buf, length );
#else
result = std::read( sock, buf, length );
#endif
if ( result != length ) {
FG_LOG( FG_IO, FG_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 ) {
int result = 0;
// check for potential input
fd_set ready;
FD_ZERO(&ready);
FD_SET(sock, &ready);
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
// test for any input read on sock (returning immediately, even if
// nothing)
select(32, &ready, 0, 0, &tv);
if ( FD_ISSET(sock, &ready) ) {
// read a chunk, keep in the save buffer until we have the
// requested amount read
char *buf_ptr = save_buf + save_len;
#ifdef _MSC_VER
result = _read( sock, buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
#else
result = std::read( sock, buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
#endif
save_len += result;
// cout << "current read = " << buf_ptr << endl;
// cout << "current save_buf = " << save_buf << endl;
// cout << "save_len = " << save_len << endl;
}
// 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 SGSocket::write( char *buf, int length ) {
bool error_condition = false;
#ifdef _MSC_VER
if ( _write(sock, buf, length) < 0 ) {
#else
if ( std::write(sock, buf, length) < 0 ) {
#endif
FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
error_condition = true;
}
#if 0
// check for any new client connection requests
fd_set ready;
FD_ZERO(&ready);
FD_SET(sock, &ready);
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
// test for any input on sock (returning immediately, even if
// nothing)
select(32, &ready, 0, 0, &tv);
// any new connections?
if ( FD_ISSET(sock, &ready) ) {
int msgsock = accept(sock, 0, 0);
if ( msgsock < 0 ) {
FG_LOG( FG_IO, FG_ALERT,
"Error: accept() failed in write()" );
return 0;
} else {
client_connections.push_back( msgsock );
}
}
FG_LOG( FG_IO, FG_INFO, "Client connections = " <<
client_connections.size() );
for ( int i = 0; i < (int)client_connections.size(); ++i ) {
int msgsock = client_connections[i];
// read and junk any possible incoming messages.
// char junk[ SG_IO_MAX_MSG_SIZE ];
// std::read( msgsock, junk, SG_IO_MAX_MSG_SIZE );
// write the interesting data to the socket
#ifdef _MSC_VER
if ( _write(msgsock, buf, length) < 0 ) {
#else
if ( std::write(msgsock, buf, length) < 0 ) {
#endif
FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
error_condition = true;
} else {
#ifdef _POSIX_SYNCHRONIZED_IO
// fdatasync(msgsock);
#else
// fsync(msgsock);
#endif
}
}
#endif
if ( error_condition ) {
return 0;
}
return length;
}
// write null terminated string to socket (server)
int SGSocket::writestring( char *str ) {
int length = strlen( str );
return write( str, length );
}
// close the port
bool SGSocket::close() {
#if 0
for ( int i = 0; i < (int)client_connections.size(); ++i ) {
int msgsock = client_connections[i];
#ifdef _MSC_VER
_close( msgsock );
#else
std::close( msgsock );
#endif
}
#endif
#ifdef _MSC_VER
_close( sock );
#else
std::close( sock );
#endif
return true;
}

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

@@ -0,0 +1,98 @@
// 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 <string>
#include <simgear/math/fg_types.hxx>
#include "iochannel.hxx"
FG_USING_STD(string);
#define SG_MAX_SOCKET_QUEUE 32
class SGSocket : public SGIOChannel {
string hostname;
string port_str;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
int sock;
short unsigned int port;
int sock_style; // SOCK_STREAM or SOCK_DGRAM
// make a server (master listening) socket
int make_server_socket();
// make a client socket
int make_client_socket();
// int_list client_connections;
public:
SGSocket( const string& host, const string& port, const string& style );
~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( SGProtocolDir dir );
// 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( char *buf, int length );
// write null terminated string to a socket
int writestring( char *str );
// close file
bool close();
inline string get_hostname() const { return hostname; }
inline string get_port_str() const { return port_str; }
};
#endif // _SG_SOCKET_HXX

View File

@@ -47,19 +47,20 @@
//
// 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$

View File

@@ -16,19 +16,20 @@
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
//
// 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$

View File

@@ -56,8 +56,11 @@ void fgGeocToGeod( double lat_geoc, double radius, double
*sea_level_r = EQUATORIAL_RADIUS_M*E;
*alt = radius - *sea_level_r;
} else {
// cout << " lat_geoc = " << lat_geoc << endl;
t_lat = tan(lat_geoc);
// cout << " tan(t_lat) = " << t_lat << endl;
x_alpha = E*EQUATORIAL_RADIUS_M/sqrt(t_lat*t_lat + E*E);
// cout << " x_alpha = " << x_alpha << endl;
double tmp = RESQ_M - x_alpha * x_alpha;
if ( tmp < 0.0 ) { tmp = 0.0; }
mu_alpha = atan2(sqrt(tmp),E*x_alpha);

View File

@@ -1,18 +1,19 @@
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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$

View File

@@ -6,19 +6,20 @@
//
// 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 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$

View File

@@ -6,19 +6,20 @@
//
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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 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,
// 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.
// 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 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$
//

View File

@@ -4,19 +4,20 @@
//
// 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 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,
// 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.
// 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 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$
///

View File

@@ -4,19 +4,20 @@
//
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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 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$

View File

@@ -4,19 +4,20 @@
//
// 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 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,6 +31,8 @@
#endif
#include <math.h>
#include <simgear/constants.h>
#include <simgear/math/point3d.hxx>
@@ -66,7 +69,8 @@ inline Point3D fgCartToPolar3d(const Point3D& cp) {
// distance. NOTE: starting point is specifed in radians, distance is
// specified in meters (and converted internally to radians)
// ... assumes a spherical world
inline Point3D calc_lon_lat( const Point3D& orig, double course, double dist ) {
inline Point3D calc_gc_lon_lat( const Point3D& orig, double course,
double dist ) {
Point3D result;
// lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
@@ -96,6 +100,60 @@ inline Point3D calc_lon_lat( const Point3D& orig, double course, double dist ) {
}
// calc course/dist
inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
double *course, double *dist ) {
// d = 2*asin(sqrt((sin((lat1-lat2)/2))^2 +
// cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
double tmp1 = sin( (start.y() - dest.y()) / 2 );
double tmp2 = sin( (start.x() - dest.x()) / 2 );
double d = 2.0 * asin( sqrt( tmp1 * tmp1 +
cos(start.y()) * cos(dest.y()) * tmp2 * tmp2));
// We obtain the initial course, tc1, (at point 1) from point 1 to
// point 2 by the following. The formula fails if the initial
// point is a pole. We can special case this with:
//
// IF (cos(lat1) < EPS) // EPS a small number ~ machine precision
// IF (lat1 > 0)
// tc1= pi // starting from N pole
// ELSE
// tc1= 0 // starting from S pole
// ENDIF
// ENDIF
//
// For starting points other than the poles:
//
// IF sin(lon2-lon1)<0
// tc1=acos((sin(lat2)-sin(lat1)*cos(d))/(sin(d)*cos(lat1)))
// ELSE
// tc1=2*pi-acos((sin(lat2)-sin(lat1)*cos(d))/(sin(d)*cos(lat1)))
// ENDIF
double tc1;
if ( cos(start.y()) < FG_EPSILON ) {
// EPS a small number ~ machine precision
if ( start.y() > 0 ) {
tc1 = FG_PI; // starting from N pole
} else {
tc1 = 0; // starting from S pole
}
}
// For starting points other than the poles:
double tmp3 = sin(d)*cos(start.y());
double tmp4 = sin(dest.y())-sin(start.y())*cos(d);
double tmp5 = acos(tmp4/tmp3);
if ( sin( dest.x() - start.x() ) < 0 ) {
tc1 = tmp5;
} else {
tc1 = 2 * FG_PI - tmp5;
}
*course = tc1;
*dist = d * RAD_TO_NM * NM_TO_METER;
}
#endif // _POLAR_HXX

View File

@@ -4,19 +4,20 @@
//
// 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 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$
@@ -35,18 +36,13 @@ double sgPointLineDistSquared( const sgVec3 p, const sgVec3 p0,
const sgVec3 d ) {
sgVec3 u, u1, v;
double ud, dd, tmp;
// u = p - p0
sgSubVec3(u, p, p0);
// calculate the projection, u1, of u along d.
// u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d;
ud = sgScalarProductVec3(u, d);
dd = sgScalarProductVec3(d, d);
tmp = ud / dd;
sgScaleVec3(u1, d, tmp);;
sgScaleVec3( u1, d, sgScalarProductVec3(u,d) / sgScalarProductVec3(d,d) );
// v = u - u1 = vector from closest point on line, p1, to the
// original point, p.
@@ -81,3 +77,18 @@ double sgdPointLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
return ( sgdScalarProductVec3(v, v) );
}
// This is a quicker form of
// sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
// sgPostMultMat4( sgMat, sgTRANS );
void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans )
{
for( int i=0; i<4; i++) {
for( int j=0; j<3; j++ ) {
src[i][j] += (src[i][3] * trans[j]);
}
}
}

View File

@@ -4,19 +4,20 @@
//
// 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 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$
@@ -83,6 +84,14 @@ inline void sgmap_vec_onto_cur_surface_plane( sgVec3 normal,
}
inline void sgCopyNegateVec4( sgVec4 dst, sgVec4 src )
{
dst [ 0 ] = -src [ 0 ] ;
dst [ 1 ] = -src [ 1 ] ;
dst [ 2 ] = -src [ 2 ] ;
dst [ 3 ] = -src [ 3 ] ;
}
// Given a point p, and a line through p0 with direction vector d,
// find the shortest distance (squared) from the point to the line
double sgPointLineDistSquared( const sgVec3 p, const sgVec3 p0,
@@ -93,6 +102,10 @@ double sgPointLineDistSquared( const sgVec3 p, const sgVec3 p0,
double sgdPointLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d );
// This is same as
// sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
// sgPostMultMat4( sgMat, sgTRANS );
void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans );
#endif // _VECTOR_HXX

View File

@@ -11,6 +11,7 @@ lib_LIBRARIES = libsgmisc.a
include_HEADERS = \
fgpath.hxx \
fgstream.hxx \
props.hxx \
stopwatch.hxx \
strutils.hxx \
texcoord.hxx \
@@ -19,6 +20,7 @@ include_HEADERS = \
libsgmisc_a_SOURCES = \
fgpath.cxx \
fgstream.cxx \
props.cxx \
strutils.cxx \
texcoord.cxx \
zfstream.cxx

View File

@@ -6,19 +6,20 @@
//
// 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$

View File

@@ -6,19 +6,20 @@
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// 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$

1200
simgear/misc/props.cxx Normal file

File diff suppressed because it is too large Load Diff

355
simgear/misc/props.hxx Normal file
View File

@@ -0,0 +1,355 @@
// props.hxx -- declaration of SimGear Property Manager.
//
// Written by David Megginson - david@megginson.com
//
// This module is in the PUBLIC DOMAIN.
//
// 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 props.html for documentation [replace with URL when available].
//
// $Id$
#ifndef __PROPS_HXX
#define __PROPS_HXX
#include <stdio.h>
#include <string>
#include <map>
using std::string;
using std::map;
////////////////////////////////////////////////////////////////////////
// Values.
////////////////////////////////////////////////////////////////////////
/**
* Abstract representation of a FlightGear value.
*
* This value is designed to be fairly robust -- it can exist without
* a specified value, it can be any of several types, and it can
* be tied to an external variable without disrupting any existing
* pointers or references to the value. Some basic type conversions
* are also handled automatically.
*
* Values also have attributes that control whether they can be read
* from, written to, or archived (i.e. saved to disk).
*/
class SGValue
{
public:
// External getters
typedef bool (*bool_getter)();
typedef int (*int_getter)();
typedef float (*float_getter)();
typedef double (*double_getter)();
typedef const string &(*string_getter)();
// External setters
typedef void (*bool_setter)(bool);
typedef void (*int_setter)(int);
typedef void (*float_setter)(float);
typedef void (*double_setter)(double);
typedef void (*string_setter)(const string &);
enum Type {
UNKNOWN, // no value assigned yet
BOOL, // boolean
INT, // integer
FLOAT, // floating point
DOUBLE, // double precision
STRING // text
};
SGValue ();
virtual ~SGValue ();
// Meta information.
virtual Type getType () const { return _type; }
virtual bool isTied () const { return _tied; }
// Accessors.
virtual bool getBoolValue () const;
virtual int getIntValue () const;
virtual float getFloatValue () const;
virtual double getDoubleValue () const;
virtual const string &getStringValue () const;
// Setters.
virtual bool setBoolValue (bool value);
virtual bool setIntValue (int value);
virtual bool setFloatValue (float value);
virtual bool setDoubleValue (double value);
virtual bool setStringValue (const string &value);
virtual bool setUnknownValue (const string &value);
// Tie to external variables.
virtual bool tieBool (bool_getter getter,
bool_setter setter = 0,
bool useDefault = true);
virtual bool tieInt (int_getter getter,
int_setter setter = 0,
bool useDefault = true);
virtual bool tieFloat (float_getter getter,
float_setter setter = 0,
bool useDefault = true);
virtual bool tieDouble (double_getter getter,
double_setter setter = 0,
bool useDefault = true);
virtual bool tieString (string_getter getter,
string_setter setter = 0,
bool useDefault = true);
// Untie from external variables.
virtual bool untie ();
protected:
bool getRawBool () const;
int getRawInt () const;
float getRawFloat () const;
double getRawDouble () const;
const string &getRawString () const;
bool setRawBool (bool value);
bool setRawInt (int value);
bool setRawFloat (float value);
bool setRawDouble (double value);
bool setRawString (const string & value);
private:
Type _type;
bool _tied;
mutable string string_val;
// The value is one of the following...
union {
bool bool_val;
int int_val;
float float_val;
double double_val;
struct {
bool_setter setter;
bool_getter getter;
} bool_func;
struct {
int_setter setter;
int_getter getter;
} int_func;
struct {
void * obj;
float_setter setter;
float_getter getter;
} float_func;
struct {
void * obj;
double_setter setter;
double_getter getter;
} double_func;
struct {
string_setter setter;
string_getter getter;
} string_func;
} _value;
};
////////////////////////////////////////////////////////////////////////
// Top-level manager.
////////////////////////////////////////////////////////////////////////
/**
* A list of FlightGear properties.
*
* This list associates names (conventional written as paths,
* i.e. "/foo/bar/hack") with SGValue classes. Once an SGValue
* object is associated with the name, the association is
* permanent -- it is safe to keep a pointer or reference.
* however, that the type of a value may change if it is tied
* to a variable.
*
* When iterating through the list, the value type is
*
* pair<string,SGValue>
*
* To get the name from a const_iterator, use
*
* it->first
*
* and to get the value from a const_iterator, use
*
* it->second
*/
class SGPropertyList
{
public:
typedef map<string, SGValue> value_map;
typedef SGValue::bool_getter bool_getter;
typedef SGValue::int_getter int_getter;
typedef SGValue::float_getter float_getter;
typedef SGValue::double_getter double_getter;
typedef SGValue::string_getter string_getter;
typedef SGValue::bool_setter bool_setter;
typedef SGValue::int_setter int_setter;
typedef SGValue::float_setter float_setter;
typedef SGValue::double_setter double_setter;
typedef SGValue::string_setter string_setter;
typedef value_map::value_type value_type;
typedef value_map::size_type size_type;
typedef value_map::const_iterator const_iterator;
SGPropertyList ();
virtual ~SGPropertyList ();
virtual size_type size () const { return _props.size(); }
virtual const_iterator begin () const { return _props.begin(); }
virtual const_iterator end () const { return _props.end(); }
virtual SGValue * getValue (const string &name, bool create = false);
virtual const SGValue * getValue (const string &name) const;
virtual bool getBoolValue (const string &name) const;
virtual int getIntValue (const string &name) const;
virtual float getFloatValue (const string &name) const;
virtual double getDoubleValue (const string &name) const;
virtual const string &getStringValue (const string &name) const;
virtual bool setBoolValue (const string &name, bool value);
virtual bool setIntValue (const string &name, int value);
virtual bool setFloatValue (const string &name, float value);
virtual bool setDoubleValue (const string &name, double value);
virtual bool setStringValue (const string &name, const string &value);
virtual bool setUnknownValue (const string &name, const string &value);
virtual bool tieBool (const string &name,
bool_getter getter,
bool_setter setter = 0,
bool useDefault = true);
virtual bool tieInt (const string &name,
int_getter getter,
int_setter setter = 0,
bool useDefault = true);
virtual bool tieFloat (const string &name,
float_getter getter,
float_setter setter = 0,
bool useDefault = true);
virtual bool tieDouble (const string &name,
double_getter getter,
double_setter setter = 0,
bool useDefault = true);
virtual bool tieString (const string &name,
string_getter getter,
string_setter setter = 0,
bool useDefault = true);
virtual bool untie (const string &name);
private:
value_map _props;
};
////////////////////////////////////////////////////////////////////////
// Tree/node/directory view.
////////////////////////////////////////////////////////////////////////
/**
* Tree view of a property list.
*
* This class provides a virtual tree view of a property list, without
* actually constructing a tree -- the view always stays in sync with
* the property list itself.
*
* This class is designed to be used for setup and configuration; it is
* optimized for ease of use rather than performance, and shouldn't be
* used inside a tight loop.
*
* Every node is actually just a path together with a pointer to
* the real property list and a few convenient operations; to the
* user, however, it looks like a node in a tree or a file system,
* with the regular operations such as getChild and getParent.
*
* Note that a node may be both a branch and a leaf -- that is, it
* may have a value itself and it may have children. Here is a simple
* example that prints the names of all of the different nodes inside
* "/controls":
*
* SGPropertyNode controls("/controls", current_property_list);
* SGPropertyNode child;
* int size = controls.size();
* for (int i = 0; i < size; i++) {
* if (controls.getChild(child, i))
* cout << child.getName() << endl;
* else
* cerr << "Failed to read child " << i << endl;
* }
*/
class SGPropertyNode
{
public:
// Constructor and destructor
SGPropertyNode (const string &path = "", SGPropertyList * props = 0);
virtual ~SGPropertyNode ();
// Accessor and setter for the internal
// path.
virtual const string &getPath () const { return _path; }
virtual void setPath (const string &path);
// Accessor and setter for the real
// property list.
virtual SGPropertyList * getPropertyList () { return _props; }
virtual void setPropertyList (SGPropertyList * props) {
_props = props;
}
// Accessors for derived information.
virtual int size () const;
virtual const string &getName () const;
virtual SGValue * getValue ();
virtual bool getParent (SGPropertyNode &parent) const;
virtual bool getChild (SGPropertyNode &child, int n) const;
private:
string _path;
mutable string _name; // for pointer persistence only
SGPropertyList * _props;
};
////////////////////////////////////////////////////////////////////////
// Global property manager.
////////////////////////////////////////////////////////////////////////
extern SGPropertyList current_properties;
#endif __PROPS_HXX
// end of props.hxx

View File

@@ -7,15 +7,20 @@
*
* Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
*
* 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,
* 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.
* 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.
*
* Suggestions: blitz-suggest@cybervision.com
* Bugs: blitz-bugs@cybervision.com

View File

@@ -4,19 +4,20 @@
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// 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$
@@ -113,17 +114,40 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
// cout << "dx = " << dx << " dy = " << dy << endl;
bool do_shift = false;
Point3D mod_shift;
// Point3D mod_shift;
if ( (dx > HALF_MAX_TEX_COORD) || (dy > HALF_MAX_TEX_COORD) ) {
// structure is too big, we'll just have to shift it so that
// tmin = (0,0). This messes up subsequent texture scaling,
// but is the best we can do.
// cout << "SHIFTING" << endl;
do_shift = true;
tmin.setx( (double)( (int)tmin.x() + 1 ) );
tmin.sety( (double)( (int)tmin.y() + 1 ) );
if ( tmin.x() < 0 ) {
tmin.setx( (double)( (int)tmin.x() - 1 ) );
} else {
tmin.setx( (int)tmin.x() );
}
if ( tmin.y() < 0 ) {
tmin.sety( (double)( (int)tmin.y() - 1 ) );
} else {
tmin.sety( (int)tmin.y() );
}
// cout << "found tmin = " << tmin << endl;
} else {
if ( tmin.x() < 0 ) {
tmin.setx( ( (int)(tmin.x() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD );
} else {
tmin.setx( ( (int)(tmin.x() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD );
}
if ( tmin.y() < 0 ) {
tmin.sety( ( (int)(tmin.y() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD );
} else {
tmin.sety( ( (int)(tmin.y() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD );
}
#if 0
// structure is small enough ... we can mod it so we can
// properly scale the texture coordinates later.
// cout << "MODDING" << endl;
@@ -142,7 +166,7 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
// At this point we know that the object is < 16 wide in
// texture coordinate space. If the modulo of the tmin is >
// the mod of the tmax at this point, then we know that the
// starting tex coordinate for the tmin > 16 so we can shift
// starting tex coordinate for the tmax > 16 so we can shift
// everything down by 16 and get it within the 0-32 range.
if ( x1 > x2 ) {
@@ -156,7 +180,7 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
} else {
mod_shift.sety( 0.0 );
}
#endif
// cout << "mod_shift = " << mod_shift << endl;
}
@@ -169,8 +193,9 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
t = basic_tex_coord( p, degree_width, degree_height, scale );
// cout << "second t = " << t << endl;
if ( do_shift ) {
adjusted_t = t - tmin;
// if ( do_shift ) {
adjusted_t = t - tmin;
#if 0
} else {
adjusted_t.setx( fmod(t.x() + mod_shift.x(), MAX_TEX_COORD) );
while ( adjusted_t.x() < 0 ) {
@@ -182,7 +207,7 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
}
// cout << "adjusted_t " << adjusted_t << endl;
}
#endif
if ( adjusted_t.x() < FG_EPSILON ) {
adjusted_t.setx( 0.0 );
}

View File

@@ -4,19 +4,20 @@
//
// 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$
@@ -41,5 +42,3 @@ point_list calc_tex_coords( const FGBucket& b, const point_list& geod_nodes,
#endif // _TEXCOORD_HXX

View File

@@ -5,19 +5,20 @@
//
// 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$

View File

@@ -5,19 +5,20 @@
//
// 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$

View File

@@ -2,19 +2,20 @@
//
// Contributed by Richard Kaszeta <bofh@me.umn.edu>, started October 1999.
//
// 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$

View File

@@ -2,19 +2,20 @@
//
// Contributed by Richard Kaszeta <bofh@me.umn.edu>, started October 1999.
//
// 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$

View File

@@ -4,19 +4,20 @@
//
// Copyright (C) 1998 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$

View File

@@ -4,19 +4,20 @@
//
// Copyright (C) 1998 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$

View File

@@ -1,11 +1,23 @@
noinst_LIBRARIES = libSky.a
includedir = @includedir@/sky
libSky_a_SOURCES = \
dome.cxx dome.hxx \
moon.cxx moon.hxx \
oursun.cxx oursun.hxx \
sky.cxx sky.hxx \
sphere.cxx sphere.hxx \
stars.cxx stars.hxx
lib_LIBRARIES = libsgsky.a
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
include_HEADERS = \
cloud.hxx \
dome.hxx \
moon.hxx \
oursun.hxx \
sky.hxx \
sphere.hxx \
stars.hxx
libsgsky_a_SOURCES = \
cloud.cxx \
dome.cxx \
moon.cxx \
oursun.cxx \
sky.cxx \
sphere.cxx \
stars.cxx
INCLUDES += -I$(top_builddir)

258
simgear/sky/cloud.cxx Normal file
View File

@@ -0,0 +1,258 @@
// cloud.cxx -- model a single cloud layer
//
// Written by Curtis Olson, started June 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// 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 <iostream>
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include "cloud.hxx"
// Constructor
SGCloudLayer::SGCloudLayer( void ) {
}
// Destructor
SGCloudLayer::~SGCloudLayer( void ) {
}
// build the moon object
void SGCloudLayer::build( double s, double asl, double thickness,
double transition, ssgSimpleState *state )
{
scale = 4000.0;
layer_asl = asl;
layer_thickness = thickness;
layer_transition = transition;
size = s;
last_lon = last_lat = -999.0f;
layer_state = state;
cl = new ssgColourArray( 4 );
vl = new ssgVertexArray( 4 );
tl = new ssgTexCoordArray( 4 );
// build the cloud layer
sgVec4 color;
sgVec3 vertex;
sgVec2 tc;
sgSetVec4( color, 1.0f, 1.0f, 1.0f, 1.0f );
sgSetVec3( vertex, -size, -size, 0.0f );
sgVec2 base;
sgSetVec2( base, fg_random(), fg_random() );
sgSetVec2( tc, base[0], base[1] );
cl->add( color );
vl->add( vertex );
tl->add( tc );
sgSetVec3( vertex, size, -size, 0.0f );
sgSetVec2( tc, base[0] + size / scale, base[1] );
cl->add( color );
vl->add( vertex );
tl->add( tc );
sgSetVec3( vertex, -size, size, 0.0f );
sgSetVec2( tc, base[0], base[1] + size / scale );
cl->add( color );
vl->add( vertex );
tl->add( tc );
sgSetVec3( vertex, size, size, 0.0f );
sgSetVec2( tc, base[0] + size / scale, base[1] + size / scale );
cl->add( color );
vl->add( vertex );
tl->add( tc );
ssgLeaf *layer =
new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, NULL, tl, cl );
layer->setState( layer_state );
// force a repaint of the moon colors with arbitrary defaults
repaint( color );
// build the ssg scene graph sub tree for the sky and connected
// into the provide scene graph branch
layer_transform = new ssgTransform;
// moon_transform->addKid( halo );
layer_transform->addKid( layer );
layer_root = new ssgRoot;
layer_root->addKid( layer_transform );
}
// repaint the cloud layer colors
bool SGCloudLayer::repaint( sgVec3 fog_color ) {
float *color;
for ( int i = 0; i < 4; ++i ) {
color = cl->get( i );
sgCopyVec4( color, fog_color );
}
return true;
}
// reposition the cloud layer at the specified origin and orientation
// lon specifies a rotation about the Z axis
// lat specifies a rotation about the new Y axis
// spin specifies a rotation about the new Z axis (and orients the
// sunrise/set effects
bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat,
double alt )
{
sgMat4 T1, LON, LAT;
sgVec3 axis;
// combine p and asl (meters) to get translation offset
sgVec3 asl_offset;
sgCopyVec3( asl_offset, up );
sgNormalizeVec3( asl_offset );
if ( alt <= layer_asl ) {
sgScaleVec3( asl_offset, layer_asl );
} else {
sgScaleVec3( asl_offset, layer_asl + layer_thickness );
}
// cout << "asl_offset = " << asl_offset[0] << "," << asl_offset[1]
// << "," << asl_offset[2] << endl;
sgAddVec3( asl_offset, p );
// cout << " asl_offset = " << asl_offset[0] << "," << asl_offset[1]
// << "," << asl_offset[2] << endl;
// Translate to zero elevation
// Point3D zero_elev = current_view.get_cur_zero_elev();
// xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() );
sgMakeTransMat4( T1, asl_offset );
// printf(" Translated to %.2f %.2f %.2f\n",
// zero_elev.x, zero_elev.y, zero_elev.z );
// Rotate to proper orientation
// printf(" lon = %.2f lat = %.2f\n",
// lon * SGD_RADIANS_TO_DEGREES,
// lat * SGD_RADIANS_TO_DEGREES);
// xglRotatef( lon * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0 );
sgSetVec3( axis, 0.0, 0.0, 1.0 );
sgMakeRotMat4( LON, lon * SGD_RADIANS_TO_DEGREES, axis );
// xglRotatef( 90.0 - f->get_Latitude() * SGD_RADIANS_TO_DEGREES,
// 0.0, 1.0, 0.0 );
sgSetVec3( axis, 0.0, 1.0, 0.0 );
sgMakeRotMat4( LAT, 90.0 - lat * SGD_RADIANS_TO_DEGREES, axis );
sgMat4 TRANSFORM;
sgCopyMat4( TRANSFORM, T1 );
sgPreMultMat4( TRANSFORM, LON );
sgPreMultMat4( TRANSFORM, LAT );
sgCoord layerpos;
sgSetCoord( &layerpos, TRANSFORM );
layer_transform->setTransform( &layerpos );
// now calculate update texture coordinates
if ( last_lon < -900 ) {
last_lon = lon;
last_lat = lat;
}
if ( lon != last_lon || lat != last_lat ) {
Point3D start( last_lon, last_lat, 0.0 );
Point3D dest( lon, lat, 0.0 );
double course, dist;
calc_gc_course_dist( dest, start, &course, &dist );
// cout << "course = " << course << ", dist = " << dist << endl;
double xoff = cos( course ) * dist / (2 * scale);
double yoff = sin( course ) * dist / (2 * scale);
// cout << "xoff = " << xoff << ", yoff = " << yoff << endl;
float *base, *tc;
base = tl->get( 0 );
base[0] += xoff;
while ( base[0] > 1.0 ) { base[0] -= 1.0; }
while ( base[0] < 0.0 ) { base[0] += 1.0; }
base[1] += yoff;
while ( base[1] > 1.0 ) { base[1] -= 1.0; }
while ( base[1] < 0.0 ) { base[1] += 1.0; }
// cout << "base = " << base[0] << "," << base[1] << endl;
tc = tl->get( 1 );
sgSetVec2( tc, base[0] + size / scale, base[1] );
tc = tl->get( 2 );
sgSetVec2( tc, base[0], base[1] + size / scale );
tc = tl->get( 3 );
sgSetVec2( tc, base[0] + size / scale, base[1] + size / scale );
last_lon = lon;
last_lat = lat;
}
return true;
}
void SGCloudLayer::draw() {
ssgCullAndDraw( layer_root );
}
// make an ssgSimpleState for a cloud layer given the named texture
ssgSimpleState *SGCloudMakeState( const string &path ) {
ssgSimpleState *state = new ssgSimpleState();
state->setTexture( (char *)path.c_str() );
state->setShadeModel( GL_SMOOTH );
state->disable( GL_LIGHTING );
state->disable( GL_CULL_FACE );
state->enable( GL_TEXTURE_2D );
state->enable( GL_COLOR_MATERIAL );
state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
state->enable( GL_BLEND );
state->enable( GL_ALPHA_TEST );
state->setAlphaClamp( 0.01 );
return state;
}

118
simgear/sky/cloud.hxx Normal file
View File

@@ -0,0 +1,118 @@
// cloud.hxx -- model a single cloud layer
//
// Written by Curtis Olson, started June 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_CLOUD_HXX_
#define _SG_CLOUD_HXX_
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include <plib/ssg.h>
#include STL_STRING
FG_USING_STD(string);
#define SG_MAX_CLOUD_TYPES 4 // change this if we add/remove cloud
// types en the enum below
enum SGCloudType {
SG_CLOUD_OVERCAST = 0,
SG_CLOUD_MOSTLY_CLOUDY = 1,
SG_CLOUD_MOSTLY_SUNNY = 2,
SG_CLOUD_CIRRUS = 3,
};
class SGCloudLayer {
private:
ssgRoot *layer_root;
ssgTransform *layer_transform;
ssgSimpleState *layer_state;
ssgColourArray *cl;
ssgVertexArray *vl;
ssgTexCoordArray *tl;
// height above sea level (meters)
float layer_asl;
float layer_thickness;
float layer_transition;
float size;
float scale;
// for handling texture coordinates to simulate cloud movement
// from winds, and to simulate the clouds being tied to ground
// position, not view position
// double xoff, yoff;
double last_lon, last_lat;
public:
// Constructor
SGCloudLayer( void );
// Destructor
~SGCloudLayer( void );
// build the cloud object
void build( double size, double asl, double thickness,
double transition, ssgSimpleState *state );
// repaint the cloud colors based on current value of sun_angle,
// sky, and fog colors. This updates the color arrays for
// ssgVtxTable.
// sun angle in degrees relative to verticle
// 0 degrees = high noon
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool repaint( sgVec3 fog_color );
// reposition the cloud layer at the specified origin and
// orientation
// lon specifies a rotation about the Z axis
// lat specifies a rotation about the new Y axis
// spin specifies a rotation about the new Z axis (and orients the
// sunrise/set effects
bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
// draw the cloud layer
void draw();
inline float get_asl() const { return layer_asl; }
inline float get_thickness() const { return layer_thickness; }
inline float get_transition() const { return layer_transition; }
};
// make an ssgSimpleState for a cloud layer given the named texture
ssgSimpleState *SGCloudMakeState( const string &path );
#endif // _SG_CLOUD_HXX_

View File

@@ -5,19 +5,20 @@
//
// Copyright (C) 1997-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$
@@ -35,7 +36,8 @@
#include <GL/glut.h>
#include <simgear/xgl/xgl.h>
#include <simgear/constants.h>
#include <plib/sg.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
@@ -108,6 +110,8 @@ ssgBranch * SGSkyDome::build( ) {
dome_state->disable( GL_TEXTURE_2D );
dome_state->enable( GL_COLOR_MATERIAL );
dome_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
dome_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
dome_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
dome_state->disable( GL_BLEND );
dome_state->disable( GL_ALPHA_TEST );
@@ -137,7 +141,7 @@ ssgBranch * SGSkyDome::build( ) {
sgSetVec3( center_vertex, 0.0, 0.0, CENTER_ELEV );
for ( i = 0; i < 12; i++ ) {
theta = (i * 30.0) * DEG_TO_RAD;
theta = (i * 30.0) * SGD_DEGREES_TO_RADIANS;
sgSetVec3( upper_vertex[i],
cos(theta) * UPPER_RADIUS,
@@ -215,7 +219,7 @@ ssgBranch * SGSkyDome::build( ) {
// force a repaint of the sky colors with ugly defaults
sgVec3 fog_color;
sgSetVec3( fog_color, 1.0, 1.0, 1.0 );
repaint( color, fog_color, 0.0 );
repaint( color, fog_color, 0.0, 5000.0 );
// build the ssg scene graph sub tree for the sky and connected
// into the provide scene graph branch
@@ -268,7 +272,8 @@ ssgBranch * SGSkyDome::build( ) {
// 0 degrees = high noon
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle )
bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle,
double vis )
{
double diff;
sgVec3 outer_param, outer_amt, outer_diff;
@@ -309,11 +314,28 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle )
// First, recalulate the basic colors
//
sgVec4 center_color;
sgVec4 upper_color[12];
sgVec4 middle_color[12];
sgVec4 lower_color[12];
sgVec4 bottom_color[12];
double vis_factor;
if ( vis < 3000.0 ) {
vis_factor = (vis - 1000.0) / 2000.0;
if ( vis_factor < 0.0 ) {
vis_factor = 0.0;
}
} else {
vis_factor = 1.0;
}
for ( j = 0; j < 3; j++ ) {
diff = sky_color[j] - fog_color[j];
center_color[j] = sky_color[j] - diff * ( 1.0 - vis_factor );
}
for ( i = 0; i < 6; i++ ) {
for ( j = 0; j < 3; j++ ) {
diff = sky_color[j] - fog_color[j];
@@ -321,8 +343,9 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle )
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
// l->sky_color[j], l->fog_color[j], diff);
upper_color[i][j] = sky_color[j] - diff * 0.3;
middle_color[i][j] = sky_color[j] - diff * 0.9 + middle_amt[j];
upper_color[i][j] = sky_color[j] - diff * ( 1.0 - vis_factor * 0.7);
middle_color[i][j] = sky_color[j] - diff * ( 1.0 - vis_factor * 0.1)
+ middle_amt[j];
lower_color[i][j] = fog_color[j] + outer_amt[j];
if ( upper_color[i][j] > 1.0 ) { upper_color[i][j] = 1.0; }
@@ -361,8 +384,9 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle )
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
// sky_color[j], fog_color[j], diff);
upper_color[i][j] = sky_color[j] - diff * 0.3;
middle_color[i][j] = sky_color[j] - diff * 0.9 + middle_amt[j];
upper_color[i][j] = sky_color[j] - diff * ( 1.0 - vis_factor * 0.7);
middle_color[i][j] = sky_color[j] - diff * ( 1.0 - vis_factor * 0.1)
+ middle_amt[j];
lower_color[i][j] = fog_color[j] + outer_amt[j];
if ( upper_color[i][j] > 1.0 ) { upper_color[i][j] = 1.0; }
@@ -407,7 +431,7 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle )
slot = center_disk_cl->get( counter++ );
// sgVec4 red;
// sgSetVec4( red, 1.0, 0.0, 0.0, 1.0 );
sgCopyVec4( slot, sky_color );
sgCopyVec4( slot, center_color );
for ( i = 11; i >= 0; i-- ) {
slot = center_disk_cl->get( counter++ );
sgCopyVec4( slot, upper_color[i] );
@@ -482,19 +506,21 @@ bool SGSkyDome::reposition( sgVec3 p, double lon, double lat, double spin ) {
// zero_elev.x, zero_elev.y, zero_elev.z );
// Rotate to proper orientation
// printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
// FG_Latitude * RAD_TO_DEG);
// xglRotatef( f->get_Longitude() * RAD_TO_DEG, 0.0, 0.0, 1.0 );
// printf(" lon = %.2f lat = %.2f\n",
// lon * SGD_RADIANS_TO_DEGREES,
// lat * SGD_RADIANS_TO_DEGREES);
// xglRotatef( lon * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0 );
sgSetVec3( axis, 0.0, 0.0, 1.0 );
sgMakeRotMat4( LON, lon * RAD_TO_DEG, axis );
sgMakeRotMat4( LON, lon * SGD_RADIANS_TO_DEGREES, axis );
// xglRotatef( 90.0 - f->get_Latitude() * RAD_TO_DEG, 0.0, 1.0, 0.0 );
// xglRotatef( 90.0 - f->get_Latitude() * SGD_RADIANS_TO_DEGREES,
// 0.0, 1.0, 0.0 );
sgSetVec3( axis, 0.0, 1.0, 0.0 );
sgMakeRotMat4( LAT, 90.0 - lat * RAD_TO_DEG, axis );
sgMakeRotMat4( LAT, 90.0 - lat * SGD_RADIANS_TO_DEGREES, axis );
// xglRotatef( l->sun_rotation * RAD_TO_DEG, 0.0, 0.0, 1.0 );
// xglRotatef( l->sun_rotation * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0 );
sgSetVec3( axis, 0.0, 0.0, 1.0 );
sgMakeRotMat4( SPIN, spin * RAD_TO_DEG, axis );
sgMakeRotMat4( SPIN, spin * SGD_RADIANS_TO_DEGREES, axis );
sgMat4 TRANSFORM;

View File

@@ -5,19 +5,20 @@
//
// Copyright (C) 1997-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$
@@ -69,7 +70,8 @@ public:
// 0 degrees = high noon
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool repaint( sgVec3 sky_color, sgVec3 fog_color, double sun_angle );
bool repaint( sgVec3 sky_color, sgVec3 fog_color, double sun_angle,
double vis );
// reposition the sky at the specified origin and orientation
// lon specifies a rotation about the Z axis

View File

@@ -7,26 +7,32 @@
//
// Separated out rendering pieces and converted to ssg by Curt Olson,
// March 2000
// 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>
#endif
#include <stdio.h>
#include <iostream>
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/constants.h>
@@ -42,9 +48,6 @@ static int sgMoonOrbPreDraw( ssgEntity *e ) {
glDisable( GL_DEPTH_TEST );
glDisable( GL_FOG );
glBlendFunc ( GL_SRC_ALPHA, GL_ONE ) ;
// sgVec4 color;
// sgSetVec4( color, 0.0, 0.0, 0.0, 1.0 );
// glMaterialfv ( GL_FRONT_AND_BACK, GL_AMBIENT, color ) ;
return true;
}
@@ -56,6 +59,14 @@ static int sgMoonOrbPostDraw( ssgEntity *e ) {
glEnable( GL_FOG );
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
/* test
glDisable( GL_LIGHTING );
glDisable( GL_CULL_FACE );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glEnable( GL_CULL_FACE );
glEnable( GL_LIGHTING ); */
return true;
}
@@ -103,8 +114,9 @@ ssgBranch * SGMoon::build( FGPath path, double moon_size ) {
orb_state->enable( GL_TEXTURE_2D );
orb_state->enable( GL_COLOR_MATERIAL );
orb_state->setColourMaterial( GL_DIFFUSE );
orb_state->setMaterial( GL_AMBIENT, 0.0, 0.0, 0.0, 1.0 );
orb_state->setMaterial( GL_SPECULAR, 0.0, 0.0, 0.0, 1.0 );
orb_state->setMaterial( GL_AMBIENT, 0, 0, 0, 1.0 );
orb_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
orb_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
orb_state->enable( GL_BLEND );
orb_state->enable( GL_ALPHA_TEST );
orb_state->setAlphaClamp( 0.01 );
@@ -138,8 +150,8 @@ ssgBranch * SGMoon::build( FGPath path, double moon_size ) {
halo_state->disable( GL_COLOR_MATERIAL );
halo_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
halo_state->setMaterial ( GL_AMBIENT_AND_DIFFUSE, 1, 1, 1, 1 ) ;
halo_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
halo_state -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
halo_state->setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
halo_state->setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
// halo_state -> setShininess ( 0 ) ;
halo_state->enable( GL_ALPHA_TEST );
halo_state->setAlphaClamp(0.01);
@@ -192,7 +204,7 @@ ssgBranch * SGMoon::build( FGPath path, double moon_size ) {
// 90 degrees = moon rise/set
// 180 degrees = darkest midnight
bool SGMoon::repaint( double moon_angle ) {
if ( moon_angle * RAD_TO_DEG < 100 ) {
if ( moon_angle * SGD_RADIANS_TO_DEGREES < 100 ) {
// else moon is well below horizon (so no point in repainting it)
// x_10 = moon_angle^10
@@ -210,7 +222,10 @@ bool SGMoon::repaint( double moon_angle ) {
(ambient * 11.0) - 3.0, // minimum value = 0.3
(ambient * 12.0) - 3.6, // minimum value = 0.0
0.5 );
// temp test, forces the color to always be white
// sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
if (color[0] > 1.0) color[0] = 1.0;
if (color[1] > 1.0) color[1] = 1.0;
if (color[2] > 1.0) color[2] = 1.0;
@@ -244,16 +259,17 @@ bool SGMoon::reposition( sgVec3 p, double angle,
sgSetVec3( axis, 0.0, 0.0, -1.0 );
sgMakeRotMat4( GST, angle, axis );
// xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
// xglRotatef( ((SGD_RADIANS_TO_DEGREES * rightAscension)- 90.0),
// 0.0, 0.0, 1.0);
sgSetVec3( axis, 0.0, 0.0, 1.0 );
sgMakeRotMat4( RA, (rightAscension * RAD_TO_DEG) - 90.0, axis );
sgMakeRotMat4( RA, (rightAscension * SGD_RADIANS_TO_DEGREES) - 90.0, axis );
// xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
// xglRotatef((SGD_RADIANS_TO_DEGREES * declination), 1.0, 0.0, 0.0);
sgSetVec3( axis, 1.0, 0.0, 0.0 );
sgMakeRotMat4( DEC, declination * RAD_TO_DEG, axis );
sgMakeRotMat4( DEC, declination * SGD_RADIANS_TO_DEGREES, axis );
// xglTranslatef(0,60000,0);
sgSetVec3( v, 0.0, 60000.0, 0.0 );
// xglTranslatef(0,moon_dist);
sgSetVec3( v, 0.0, moon_dist, 0.0 );
sgMakeTransMat4( T2, v );
sgMat4 TRANSFORM;
@@ -270,3 +286,4 @@ bool SGMoon::reposition( sgVec3 p, double angle,
return true;
}

View File

@@ -8,19 +8,20 @@
// Separated out rendering pieces and converted to ssg by Curt Olson,
// March 2000
//
// 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$

View File

@@ -7,30 +7,34 @@
//
// Separated out rendering pieces and converted to ssg by Curt Olson,
// March 2000
// 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>
#endif
#include <stdio.h>
#include <iostream>
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/constants.h>
#include "sphere.hxx"
#include "oursun.hxx"
@@ -200,10 +204,13 @@ ssgBranch * SGSun::build( FGPath path, double sun_size ) {
orb_state = new ssgSimpleState();
orb_state->setShadeModel( GL_SMOOTH );
orb_state->disable( GL_LIGHTING );
// orb_state->enable( GL_LIGHTING );
orb_state->disable( GL_CULL_FACE );
orb_state->disable( GL_TEXTURE_2D );
orb_state->enable( GL_COLOR_MATERIAL );
orb_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
orb_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
orb_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
orb_state->disable( GL_BLEND );
orb_state->disable( GL_ALPHA_TEST );
@@ -227,13 +234,15 @@ ssgBranch * SGSun::build( FGPath path, double sun_size ) {
path.append( "halo.rgba" );
halo_state = new ssgSimpleState();
halo_state->setTexture( (char *)path.c_str() );
// halo_state->setTexture( sun_texid );
halo_state->enable( GL_TEXTURE_2D );
halo_state->disable( GL_LIGHTING );
// halo_state->enable( GL_LIGHTING );
halo_state->setShadeModel( GL_SMOOTH );
halo_state->disable( GL_CULL_FACE );
halo_state->enable( GL_COLOR_MATERIAL );
halo_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
halo_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
halo_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
halo_state->enable( GL_ALPHA_TEST );
halo_state->setAlphaClamp(0.01);
halo_state->enable ( GL_BLEND ) ;
@@ -270,9 +279,9 @@ ssgBranch * SGSun::build( FGPath path, double sun_size ) {
// into the provide scene graph branch
sun_transform = new ssgTransform;
sun_transform->addKid( halo );
halo->setCallback( SSG_CALLBACK_PREDRAW, sgSunHaloPreDraw );
halo->setCallback( SSG_CALLBACK_POSTDRAW, sgSunHaloPostDraw );
sun_transform->addKid( halo );
sun_transform->addKid( orb );
return sun_transform;
@@ -285,7 +294,7 @@ ssgBranch * SGSun::build( FGPath path, double sun_size ) {
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool SGSun::repaint( double sun_angle ) {
if ( sun_angle * RAD_TO_DEG < 100 ) {
if ( sun_angle * SGD_RADIANS_TO_DEGREES < 100 ) {
// else sun is well below horizon (so no point in repainting it)
// x_10 = sun_angle^10
@@ -303,6 +312,9 @@ bool SGSun::repaint( double sun_angle ) {
(ambient * 12.0) - 3.6, // minimum value = 0.0
1.0 );
// temp test, forces the color to always be white
// sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
if (color[0] > 1.0) color[0] = 1.0;
if (color[1] > 1.0) color[1] = 1.0;
if (color[2] > 1.0) color[2] = 1.0;
@@ -336,16 +348,17 @@ bool SGSun::reposition( sgVec3 p, double angle,
sgSetVec3( axis, 0.0, 0.0, -1.0 );
sgMakeRotMat4( GST, angle, axis );
// xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
// xglRotatef( ((SGD_RADIANS_TO_DEGREES * rightAscension)- 90.0),
// 0.0, 0.0, 1.0);
sgSetVec3( axis, 0.0, 0.0, 1.0 );
sgMakeRotMat4( RA, (rightAscension * RAD_TO_DEG) - 90.0, axis );
sgMakeRotMat4( RA, (rightAscension * SGD_RADIANS_TO_DEGREES) - 90.0, axis );
// xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
// xglRotatef((SGD_RADIANS_TO_DEGREES * declination), 1.0, 0.0, 0.0);
sgSetVec3( axis, 1.0, 0.0, 0.0 );
sgMakeRotMat4( DEC, declination * RAD_TO_DEG, axis );
sgMakeRotMat4( DEC, declination * SGD_RADIANS_TO_DEGREES, axis );
// xglTranslatef(0,60000,0);
sgSetVec3( v, 0.0, 60000.0, 0.0 );
// xglTranslatef(0,sun_dist);
sgSetVec3( v, 0.0, sun_dist, 0.0 );
sgMakeTransMat4( T2, v );
sgMat4 TRANSFORM;

View File

@@ -8,19 +8,20 @@
// Separated out rendering pieces and converted to ssg by Curt Olson,
// March 2000
//
// 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$

View File

@@ -5,30 +5,48 @@
//
// Copyright (C) 1997-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 <plib/ssg.h> // plib include
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/math/fg_random.h>
#include "sky.hxx"
// Constructor
SGSky::SGSky( void ) {
effective_visibility = visibility = 10000.0;
// near cloud visibility state variables
in_puff = false;
puff_length = 0;
puff_progression = 0;
ramp_up = 0.15;
ramp_down = 0.15;
// ramp_up = 4.0;
// ramp_down = 4.0;
}
@@ -39,35 +57,64 @@ SGSky::~SGSky( void ) {
// initialize the sky and connect the components to the scene graph at
// the provided branch
ssgBranch * SGSky::build( double sun_size, double moon_size,
int nplanets, sgdVec3 *planet_data,
double planet_dist,
int nstars, sgdVec3 *star_data, double star_dist )
void SGSky::build( double sun_size, double moon_size,
int nplanets, sgdVec3 *planet_data,
double planet_dist,
int nstars, sgdVec3 *star_data, double star_dist )
{
sky_selector = new ssgSelector;
sky_transform = new ssgTransform;
pre_root = new ssgRoot;
post_root = new ssgRoot;
pre_selector = new ssgSelector;
post_selector = new ssgSelector;
pre_transform = new ssgTransform;
post_transform = new ssgTransform;
dome = new SGSkyDome;
sky_transform -> addKid( dome->build() );
pre_transform -> addKid( dome->build() );
planets = new SGStars;
sky_transform -> addKid( planets->build(nplanets, planet_data,
pre_transform -> addKid( planets->build(nplanets, planet_data,
planet_dist)
);
stars = new SGStars;
sky_transform -> addKid( stars->build(nstars, star_data, star_dist) );
pre_transform -> addKid( stars->build(nstars, star_data, star_dist) );
moon = new SGMoon;
sky_transform -> addKid( moon->build(tex_path, moon_size) );
pre_transform -> addKid( moon->build(tex_path, moon_size) );
oursun = new SGSun;
sky_transform -> addKid( oursun->build(tex_path, sun_size) );
pre_transform -> addKid( oursun->build(tex_path, sun_size) );
sky_selector->addKid( sky_transform );
sky_selector->clrTraversalMaskBits( SSGTRAV_HOT );
pre_selector->addKid( pre_transform );
pre_selector->clrTraversalMaskBits( SSGTRAV_HOT );
return sky_selector;
post_selector->addKid( post_transform );
post_selector->clrTraversalMaskBits( SSGTRAV_HOT );
pre_root->addKid( pre_selector );
post_root->addKid( post_selector );
// add the cloud ssgStates to the material lib
FGPath cloud_path;
cloud_path.set( tex_path.str() );
cloud_path.append( "overcast.rgb" );
cloud_mats[SG_CLOUD_OVERCAST] = SGCloudMakeState( cloud_path.str() );
cloud_path.set( tex_path.str() );
cloud_path.append( "mostlycloudy.rgba" );
cloud_mats[SG_CLOUD_MOSTLY_CLOUDY] = SGCloudMakeState( cloud_path.str() );
cloud_path.set( tex_path.str() );
cloud_path.append( "mostlysunny.rgba" );
cloud_mats[SG_CLOUD_MOSTLY_SUNNY] = SGCloudMakeState( cloud_path.str() );
cloud_path.set( tex_path.str() );
cloud_path.append( "cirrus.rgba" );
cloud_mats[SG_CLOUD_CIRRUS] = SGCloudMakeState( cloud_path.str() );
}
@@ -83,11 +130,21 @@ bool SGSky::repaint( sgVec4 sky_color, sgVec4 fog_color,
int nplanets, sgdVec3 *planet_data,
int nstars, sgdVec3 *star_data )
{
dome->repaint( sky_color, fog_color, sun_angle );
oursun->repaint( sun_angle );
moon->repaint( moon_angle );
planets->repaint( sun_angle, nplanets, planet_data );
stars->repaint( sun_angle, nstars, star_data );
if ( effective_visibility > 1000.0 ) {
enable();
dome->repaint( sky_color, fog_color, sun_angle, effective_visibility );
oursun->repaint( sun_angle );
moon->repaint( moon_angle );
planets->repaint( sun_angle, nplanets, planet_data );
stars->repaint( sun_angle, nstars, star_data );
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
cloud_layers[i]->repaint( fog_color );
}
} else {
// turn off sky
disable();
}
return true;
}
@@ -100,8 +157,8 @@ bool SGSky::repaint( sgVec4 sky_color, sgVec4 fog_color,
// spin specifies a rotation about the new Z axis (this allows
// additional orientation for the sunrise/set effects and is used by
// the skydome and perhaps clouds.
bool SGSky::reposition( sgVec3 view_pos, sgVec3 zero_elev,
double lon, double lat, double spin,
bool SGSky::reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
double lon, double lat, double alt, double spin,
double gst,
double sun_ra, double sun_dec, double sun_dist,
double moon_ra, double moon_dec, double moon_dist )
@@ -113,5 +170,223 @@ bool SGSky::reposition( sgVec3 view_pos, sgVec3 zero_elev,
planets->reposition( view_pos, angle );
stars->reposition( view_pos, angle );
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
cloud_layers[i]->reposition( zero_elev, view_up, lon, lat, alt );
}
return true;
}
// draw background portions of the sky ... do this before you draw the
// rest of your scene.
void SGSky::preDraw() {
ssgCullAndDraw( pre_root );
}
// draw translucent clouds ... do this after you've drawn all the
// oapaque elements of your scene.
void SGSky::postDraw( float alt ) {
float slop = 5.0; // if we are closer than this to a cloud layer,
// don't draw clouds
int in_cloud = -1; // cloud we are in
// check where we are relative to the cloud layers
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
float asl = cloud_layers[i]->get_asl();
float thickness = cloud_layers[i]->get_thickness();
if ( alt < asl - slop ) {
// below cloud layer
} else if ( alt < asl + thickness + slop ) {
// in cloud layer
// bail now and don't draw any clouds
in_cloud = i;
} else {
// above cloud layer
}
}
// determine rendering order
int pos = 0;
while ( pos < (int)cloud_layers.size() &&
alt > cloud_layers[pos]->get_asl())
{
++pos;
}
if ( pos == 0 ) {
// we are below all the cloud layers, draw top to bottom
for ( int i = cloud_layers.size() - 1; i >= 0; --i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
}
}
} else if ( pos >= (int)cloud_layers.size() ) {
// we are above all the cloud layers, draw bottom to top
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
}
}
} else {
// we are between cloud layers, draw lower layers bottom to
// top and upper layers top to bottom
for ( int i = 0; i < pos; ++i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
}
}
for ( int i = cloud_layers.size() - 1; i >= pos; --i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
}
}
}
}
void SGSky::add_cloud_layer( double asl, double thickness,
double transition, double span,
ssgSimpleState *state ) {
SGCloudLayer *layer = new SGCloudLayer;
layer->build( span, asl, thickness, transition, state );
layer_list_iterator current = cloud_layers.begin();
layer_list_iterator last = cloud_layers.end();
while ( current != last && (*current)->get_asl() < asl ) {
++current;
}
if ( current != last ) {
cloud_layers.insert( current, layer );
} else {
cloud_layers.push_back( layer );
}
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
cout << "layer " << i << " = " << cloud_layers[i]->get_asl() << endl;
}
cout << endl;
}
void SGSky::add_cloud_layer( double asl, double thickness,
double transition, double span,
const string &tex_path ) {
ssgSimpleState *state = SGCloudMakeState( tex_path );
add_cloud_layer( asl, thickness, transition, span, state );
}
void SGSky::add_cloud_layer( double asl, double thickness,
double transition, double span,
SGCloudType type ) {
if ( type > 0 && type < SG_MAX_CLOUD_TYPES ) {
add_cloud_layer( asl, thickness, transition, span, cloud_mats[type] );
}
}
// modify the current visibility based on cloud layers, thickness,
// transition range, and simulated "puffs".
void SGSky::modify_vis( float alt, float time_factor ) {
float effvis = visibility;
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
float asl = cloud_layers[i]->get_asl();
float thickness = cloud_layers[i]->get_thickness();
float transition = cloud_layers[i]->get_transition();
double ratio = 1.0;
if ( alt < asl - transition ) {
// below cloud layer
ratio = 1.0;
} else if ( alt < asl ) {
// in lower transition
ratio = (asl - alt) / transition;
} else if ( alt < asl + thickness ) {
// in cloud layer
ratio = 0.0;
} else if ( alt < asl + thickness + transition ) {
// in upper transition
ratio = (alt - (asl + thickness)) / transition;
} else {
// above cloud layer
ratio = 1.0;
}
// accumulate effects from multiple cloud layers
effvis *= ratio;
if ( ratio < 1.0 ) {
if ( ! in_puff ) {
// calc chance of entering cloud puff
double rnd = fg_random();
double chance = rnd * rnd * rnd;
if ( chance > 0.95 /* * (diff - 25) / 50.0 */ ) {
in_puff = true;
puff_length = fg_random() * 2.0; // up to 2 seconds
puff_progression = 0.0;
}
}
if ( in_puff ) {
// modify actual_visibility based on puff envelope
if ( puff_progression <= ramp_up ) {
double x = 0.5 * SGD_PI * puff_progression / ramp_up;
double factor = 1.0 - sin( x );
// cout << "ramp up = " << puff_progression
// << " factor = " << factor << endl;
effvis = effvis * factor;
} else if ( puff_progression >= ramp_up + puff_length ) {
double x = 0.5 * SGD_PI *
(puff_progression - (ramp_up + puff_length)) /
ramp_down;
double factor = sin( x );
// cout << "ramp down = "
// << puff_progression - (ramp_up + puff_length)
// << " factor = " << factor << endl;
effvis = effvis * factor;
} else {
effvis = 0.0;
}
/* cout << "len = " << puff_length
<< " x = " << x
<< " factor = " << factor
<< " actual_visibility = " << actual_visibility
<< endl; */
// time_factor = ( global_multi_loop *
// current_options.get_speed_up() ) /
// (double)current_options.get_model_hz();
puff_progression += time_factor;
// cout << "time factor = " << time_factor << endl;
/* cout << "gml = " << global_multi_loop
<< " speed up = " << current_options.get_speed_up()
<< " hz = " << current_options.get_model_hz() << endl;
*/
if ( puff_progression > puff_length + ramp_up + ramp_down) {
in_puff = false;
}
}
// never let visibility drop below 25 meters
if ( effvis <= 25.0 ) {
effvis = 25.0;
}
}
} // for
effective_visibility = effvis;
}

View File

@@ -5,19 +5,20 @@
//
// Copyright (C) 1997-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$
@@ -33,28 +34,56 @@
#include <plib/ssg.h> // plib include
#include <simgear/compiler.h>
#include <simgear/misc/fgpath.hxx>
#include <vector>
#include "cloud.hxx"
#include "dome.hxx"
#include "moon.hxx"
#include "oursun.hxx"
#include "stars.hxx"
FG_USING_STD(vector);
typedef vector < SGCloudLayer* > layer_list_type;
typedef layer_list_type::iterator layer_list_iterator;
typedef layer_list_type::const_iterator layer_list_const_iterator;
class SGSky {
private:
// components of the sky
SGSkyDome *dome;
SGSun *oursun;
SGMoon *moon;
SGStars *planets;
SGStars *stars;
ssgSimpleState *cloud_mats[SG_MAX_CLOUD_TYPES];
layer_list_type cloud_layers;
ssgSelector *sky_selector;
ssgTransform *sky_transform;
ssgRoot *pre_root, *post_root;
ssgSelector *pre_selector, *post_selector;
ssgTransform *pre_transform, *post_transform;
FGPath tex_path;
// visibility
float visibility;
float effective_visibility;
// near cloud visibility state variables
bool in_puff;
double puff_length; // in seconds
double puff_progression; // in seconds
double ramp_up; // in seconds
double ramp_down; // in seconds
public:
// Constructor
@@ -65,9 +94,9 @@ public:
// initialize the sky and connect the components to the scene
// graph at the provided branch
ssgBranch *build( double sun_size, double moon_size,
int nplanets, sgdVec3 *planet_data, double planet_dist,
int nstars, sgdVec3 *star_data, double star_dist );
void build( double sun_size, double moon_size,
int nplanets, sgdVec3 *planet_data, double planet_dist,
int nstars, sgdVec3 *star_data, double star_dist );
// repaint the sky components based on current value of sun_angle,
// sky, and fog colors.
@@ -76,7 +105,7 @@ public:
// 0 degrees = high noon
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool repaint( sgVec4 sky_color, sgVec4 fog_color,
bool repaint( sgVec4 sky_color, sgVec4 fog_color,
double sun_angle, double moon_angle,
int nplanets, sgdVec3 *planet_data,
int nstars, sgdVec3 *star_data );
@@ -88,23 +117,62 @@ public:
// spin specifies a rotation about the new Z axis (this allows
// additional orientation for the sunrise/set effects and is used
// by the skydome and perhaps clouds.
bool reposition( sgVec3 view_pos, sgVec3 zero_elev,
double lon, double lat, double spin,
bool reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
double lon, double lat, double alt, double spin,
double gst,
double sun_ra, double sun_dec, double sun_dist,
double moon_ra, double moon_dec, double moon_dist );
// modify the given visibility based on cloud layers, thickness,
// transition range, and simulated "puffs".
void modify_vis( float alt, float time_factor );
// draw background portions of the sky ... do this before you draw
// the rest of your scene.
void preDraw();
// draw translucent clouds ... do this after you've drawn all the
// oapaque elements of your scene.
void postDraw( float alt );
// specify the texture path (optional, defaults to current directory)
inline void texture_path( const string& path ) {
tex_path = FGPath( path );
}
// enable the sky in the scene graph (default)
inline void enable() { sky_selector->select( 1 ); }
// enable the sky
inline void enable() {
pre_selector->select( 1 );
post_selector->select( 1 );
}
// disable the sky in the scene graph. The leaf node is still
// there, how ever it won't be traversed on by ssgCullandRender()
inline void disable() { sky_selector->select( 0 ); }
inline void disable() {
pre_selector->select( 0 );
post_selector->select( 0 );
}
// add a cloud layer (above sea level in meters)
void add_cloud_layer( double asl, double thickness,
double transition, double span,
SGCloudType type );
void add_cloud_layer( double asl, double thickness,
double transition, double span,
const string &tex_path );
void add_cloud_layer( double asl, double thickness,
double transition, double span,
ssgSimpleState *state );
inline int get_num_layers() const { return cloud_layers.size(); }
inline SGCloudLayer *get_cloud_layer( int i ) const {
return cloud_layers[i];
}
inline float get_visibility() const { return effective_visibility; }
inline void set_visibility( float v ) {
effective_visibility = visibility = v;
}
};

View File

@@ -5,23 +5,33 @@
// Original gluSphere code is Copyright (C) 1999-2000 Brian Paul and
// licensed under the GPL
//
// 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>
#endif
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
@@ -39,26 +49,8 @@ ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl,
sgVec2 vec2;
sgVec3 vec3;
// handle cl whether it is preinitialized or not
if ( cl == NULL ) {
// create a new array if needed
cl = new ssgColourArray( 1 );
}
sgVec4 color;
sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
if ( cl->getNum() > 1 ) {
cl->removeAll();
cl->add( color );
} else if ( cl->getNum() == 0 ) {
cl->add( color );
} else {
// accept value as given to us in
}
drho = M_PI / (float) stacks;
dtheta = 2.0 * M_PI / (float) slices;
drho = SG_PI / (float) stacks;
dtheta = 2.0 * SG_PI / (float) slices;
/* texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y
axis t goes from -1.0/+1.0 at z = -radius/+radius (linear along
@@ -119,6 +111,15 @@ ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl,
ssgLeaf *slice =
new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, nl, tl, cl );
if ( vl->getNum() != nl->getNum() ) {
cout << "bad sphere1\n";
exit(-1);
}
if ( vl->getNum() != tl->getNum() ) {
cout << "bad sphere2\n";
exit(-1);
}
slice->setState( state );
slice->setCallback( SSG_CALLBACK_PREDRAW, predraw );
slice->setCallback( SSG_CALLBACK_POSTDRAW, postdraw );

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