Compare commits
161 Commits
RELEASE_0_
...
RELEASE_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b6af2f0c2 | ||
|
|
5bdff41641 | ||
|
|
67e9d105cb | ||
|
|
f1fc99f16f | ||
|
|
f89e359d53 | ||
|
|
77ec170a50 | ||
|
|
34320f5f20 | ||
|
|
a26271e46e | ||
|
|
e2e7466250 | ||
|
|
1e24cc4643 | ||
|
|
dfc23c3528 | ||
|
|
cd11a5dc27 | ||
|
|
899734296b | ||
|
|
7a3a81c152 | ||
|
|
e62a4a05ac | ||
|
|
463ca207ce | ||
|
|
da6e1b31ea | ||
|
|
8c783b1680 | ||
|
|
efce88ff12 | ||
|
|
01608b7e18 | ||
|
|
a5f0e0395a | ||
|
|
0b723174fd | ||
|
|
5d248bf0df | ||
|
|
c039ccdeb0 | ||
|
|
d88fb32a73 | ||
|
|
37ac409586 | ||
|
|
7b24e94c66 | ||
|
|
e12cd2a50c | ||
|
|
98b2ba4fc1 | ||
|
|
2f0afdccc1 | ||
|
|
79734df554 | ||
|
|
c52657fa1a | ||
|
|
9cac8409cd | ||
|
|
18703ce02d | ||
|
|
709a166bd6 | ||
|
|
8048e6297c | ||
|
|
fb0dded103 | ||
|
|
055e969e7a | ||
|
|
f10db8a30e | ||
|
|
c19af3525e | ||
|
|
7c60ccfc35 | ||
|
|
84cba33aab | ||
|
|
a52b1ec64f | ||
|
|
f30c4720ae | ||
|
|
7fc8c02688 | ||
|
|
54a7a0d534 | ||
|
|
8d73160a75 | ||
|
|
ff10602c65 | ||
|
|
ca50fe386d | ||
|
|
39f3c6e41d | ||
|
|
ba1b96e518 | ||
|
|
ef486b2cc6 | ||
|
|
06f3cb4f8e | ||
|
|
074f5ff996 | ||
|
|
8c26f32d5f | ||
|
|
9a2ee54389 | ||
|
|
ab69c03698 | ||
|
|
fab1f4e7a0 | ||
|
|
41eed484c1 | ||
|
|
7d18f9bdde | ||
|
|
3a48c3de7a | ||
|
|
d769a9936b | ||
|
|
1697cb3b1a | ||
|
|
62aa32a417 | ||
|
|
a0d0852838 | ||
|
|
2f479cae69 | ||
|
|
4820d57fa8 | ||
|
|
04e3b0b3c1 | ||
|
|
a7f78b9f68 | ||
|
|
f3d8eb4665 | ||
|
|
090f79b951 | ||
|
|
88c0dbf661 | ||
|
|
9e3822ceaf | ||
|
|
007b0a8fe6 | ||
|
|
7f0ebf8871 | ||
|
|
5414e94a1a | ||
|
|
461dee8657 | ||
|
|
297b6193fe | ||
|
|
4b74e40a5f | ||
|
|
5a9b08dec2 | ||
|
|
5e6f9f79a2 | ||
|
|
e2f93e6ae1 | ||
|
|
93314b59fb | ||
|
|
29269c6686 | ||
|
|
3c84b6e2f6 | ||
|
|
04fb708543 | ||
|
|
df302f277c | ||
|
|
5e63e663bb | ||
|
|
ca10cb2d37 | ||
|
|
c9854153f8 | ||
|
|
129e3c6326 | ||
|
|
66996711ae | ||
|
|
8fe37cea51 | ||
|
|
de64b6f267 | ||
|
|
9a9d9c7cc1 | ||
|
|
a191e9762a | ||
|
|
a7b35c6e22 | ||
|
|
5034346b67 | ||
|
|
661f64b902 | ||
|
|
bbc83f721c | ||
|
|
01f4541331 | ||
|
|
0e4a894f62 | ||
|
|
1c135a9b5b | ||
|
|
e65c85ce73 | ||
|
|
26b58991f9 | ||
|
|
8390df37ca | ||
|
|
371fc73f24 | ||
|
|
921dae5444 | ||
|
|
9b3abbec89 | ||
|
|
6935baba5b | ||
|
|
dec1e32f96 | ||
|
|
710c2ccfcd | ||
|
|
8e66e534ae | ||
|
|
0f5f30b993 | ||
|
|
b199f733f7 | ||
|
|
0cdcf3a3e0 | ||
|
|
8e09486e82 | ||
|
|
0c24b78573 | ||
|
|
1436be9699 | ||
|
|
0489ad7c62 | ||
|
|
c553570533 | ||
|
|
bda112297f | ||
|
|
331a4e4406 | ||
|
|
a9faf8ceff | ||
|
|
2866d1ace9 | ||
|
|
11a74f7a31 | ||
|
|
634a2035ee | ||
|
|
ffada9257d | ||
|
|
e09164e5b3 | ||
|
|
de1a5f3034 | ||
|
|
86e83faef3 | ||
|
|
9f06c8df76 | ||
|
|
6e511de7db | ||
|
|
e34aae9982 | ||
|
|
675b388b8e | ||
|
|
7d239fe4ac | ||
|
|
edd92caba1 | ||
|
|
5c3b4abf42 | ||
|
|
d3a3466b14 | ||
|
|
4399383781 | ||
|
|
bb383998bb | ||
|
|
ffeb174ca1 | ||
|
|
a90d74dde8 | ||
|
|
9d7fd79e76 | ||
|
|
6f29d234eb | ||
|
|
6f5517f602 | ||
|
|
cc43c745b2 | ||
|
|
db8d961b27 | ||
|
|
a0bdec2846 | ||
|
|
5bbcd386fa | ||
|
|
7657632024 | ||
|
|
ab29063a97 | ||
|
|
c06ef23eb1 | ||
|
|
7b2f7aa827 | ||
|
|
7113c10f4b | ||
|
|
14033946e5 | ||
|
|
6e0e056ca7 | ||
|
|
7aa4f0ccdb | ||
|
|
4b04450fa6 | ||
|
|
ad81560be5 | ||
|
|
5c26faa20e |
@@ -8,3 +8,12 @@ config.log
|
||||
config.status
|
||||
configure
|
||||
do-config.sh
|
||||
.cdtproject
|
||||
.project
|
||||
config.guess
|
||||
config.sub
|
||||
depcomp
|
||||
INSTALL
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
|
||||
2
Doxyfile
2
Doxyfile
@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.3.5
|
||||
PROJECT_NUMBER = 0.3.8
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
EXTRA_DIST = \
|
||||
acinclude.m4 \
|
||||
autogen.sh \
|
||||
DoxygenMain.cxx
|
||||
DoxygenMain.cxx \
|
||||
README.MSVC \
|
||||
README.metakit \
|
||||
README.zlib \
|
||||
SimGear.dsp \
|
||||
SimGear.dsw
|
||||
@@ -11,7 +10,7 @@ EXTRA_DIST = \
|
||||
SUBDIRS = src-libs simgear
|
||||
|
||||
dist-hook:
|
||||
(cd $(top_srcdir); $(HOME)/projects/FlightGear-0.9/admin/am2dsp.pl)
|
||||
(cd $(top_srcdir); $(HOME)/Projects/FlightGear-0.9/admin/am2dsp.pl)
|
||||
|
||||
#
|
||||
# Rule to build RPM distribution package
|
||||
|
||||
50
NEWS
50
NEWS
@@ -1,3 +1,53 @@
|
||||
New in 0.3.8
|
||||
* January 18, 2005
|
||||
|
||||
* Configure script does a sanity check for the existance of openal.
|
||||
* Better pthreads detection for FreeBSD.
|
||||
* Abstract out the location of gl.h, glu.h, and glut.h so we can more
|
||||
easily support MacOS which puts these in an oddball location.
|
||||
* Added two new debug output types for instrumentation and systems.
|
||||
* Add a name parameter to the waypoint class for supporting a route
|
||||
manager in the flightgear gps module.
|
||||
* Make display list usage optional.
|
||||
* Event manager: specifying a zero delay will force event execution in
|
||||
the next frame rather than entering an infinite loop.
|
||||
* gcc-4.0 fix.
|
||||
* Fixes to property tree loading and saving.
|
||||
* Make volume inaudible at startup.
|
||||
* Solaris fixes.
|
||||
* For low density cloud coverages, blend the layer to nothing as we pass
|
||||
through instead of fully engulfing the aircraft in the cloud.
|
||||
* Add several new capabilities to the texture management code for building
|
||||
normal maps and doing some simple on-the-fly effects on textures.
|
||||
* Better error message for sound problems.
|
||||
* Add support for binding a thread to a specific CPU.
|
||||
|
||||
|
||||
New in 0.3.7
|
||||
* October 12, 2004
|
||||
|
||||
* Add support for parsing xml from an in memory buffer, not just a file.
|
||||
* Don't reduce visibility for a "clear" cloud layer.
|
||||
* Add support for audio orientation (direction and cone) for internal
|
||||
view and tower view.
|
||||
* Add support for drawing from display lists rather than in immediate mode.
|
||||
This provides a big performance improvement on many systems.
|
||||
|
||||
|
||||
New in 0.3.6
|
||||
* July 29, 2004
|
||||
|
||||
* Better MinGW support
|
||||
* A bit better handling of OpenAL under Cygwin
|
||||
* Switched audio system from plib's "sl/sm" to OpenAL.
|
||||
* Add support for scaling an object based on distance. The scaling
|
||||
factor is determined by a lookup table based on distance.
|
||||
* Add a "flash" animation type.
|
||||
* Fix cloud positioning/animation bugs.
|
||||
* Fix an off-by-one error in props_io.cxx
|
||||
* Clip audio gain (volume) to 1.0
|
||||
|
||||
|
||||
New in 0.3.5
|
||||
* March 26, 2004
|
||||
|
||||
|
||||
12
README.OpenAL
Normal file
12
README.OpenAL
Normal file
@@ -0,0 +1,12 @@
|
||||
[This file is mirrored in both the FlightGear and SimGear packages.]
|
||||
|
||||
You *must* have the development components of OpenAL installed on your system
|
||||
to build FlightGear!" You can get a copy here:
|
||||
|
||||
http://www.openal.org
|
||||
|
||||
Build notes:
|
||||
|
||||
The OpenAL developers do not make "versioned" releases so we recommend that
|
||||
you pull the latest version via anonymous CVS (follow the instructions at
|
||||
the OpenAL web site) and build/install that.
|
||||
49
SimGear.dsp
49
SimGear.dsp
@@ -1094,6 +1094,21 @@ SOURCE=.\simgear\scene\model\animation.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\scene\model\custtrans.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_sgmodel"
|
||||
|
||||
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_sgmodel"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\scene\model\location.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
@@ -1139,6 +1154,21 @@ SOURCE=.\simgear\scene\model\modellib.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\scene\model\personality.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_sgmodel"
|
||||
|
||||
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_sgmodel"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\scene\model\placement.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
@@ -2363,7 +2393,7 @@ SOURCE=.\simgear\serial\serial.cxx
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\sound\sound.cxx
|
||||
SOURCE=.\simgear\sound\sample_openal.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
@@ -2378,7 +2408,22 @@ SOURCE=.\simgear\sound\sound.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\sound\soundmgr.cxx
|
||||
SOURCE=.\simgear\sound\soundmgr_openal.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_sgsound"
|
||||
|
||||
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_sgsound"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\sound\xmlsound.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
|
||||
4
Thanks
4
Thanks
@@ -90,7 +90,7 @@ David Megginson <david@megginson.com>
|
||||
SimGear property manager/registry
|
||||
|
||||
|
||||
Curt Olson <curt@flightgear.org>
|
||||
Curt Olson http://www.flightgear.org/~curt/
|
||||
Curt is responsible for overall project and source code management.
|
||||
He has his hands in many of the areas.
|
||||
|
||||
@@ -175,7 +175,7 @@ NOTE:
|
||||
----
|
||||
|
||||
THIS DOCUMENT WAS INITIALLY WRITTEN BY
|
||||
Curt L. Olson <curt@flightgear.org>
|
||||
Curt L. Olson <http://www.flightgear.org/~curt>
|
||||
|
||||
|
||||
05 Jul 2000 Removed non-SimGear entries (CLO)
|
||||
|
||||
88
configure.ac
88
configure.ac
@@ -1,7 +1,5 @@
|
||||
dnl Process this file with autoget.sh to produce a working configure
|
||||
dnl script.
|
||||
dnl
|
||||
dnl $Id$
|
||||
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
|
||||
@@ -10,7 +8,7 @@ dnl Require at least automake 2.52
|
||||
AC_PREREQ(2.52)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.3.5)
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.3.8)
|
||||
|
||||
dnl Specify KAI C++ compiler and flags.
|
||||
dnl Borrowed with slight modification from blitz distribution.
|
||||
@@ -165,33 +163,18 @@ dnl Checks for libraries.
|
||||
|
||||
dnl Thread related checks
|
||||
AC_CHECK_HEADER(pthread.h)
|
||||
AC_CHECK_LIB(pthread, pthread_exit)
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
|
||||
if test "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
CXXFLAGS="$CXXFLAGS -D_REENTRANT"
|
||||
CFLAGS="$CFLAGS -D_REENTRANT"
|
||||
fi
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
dnl FreeBSD: System has pthread.h, but -lpthread library check
|
||||
dnl fails. See if we need -pthread instead of -lpthread and look
|
||||
dnl for the functions in libc_r.
|
||||
save_CXXFLAGS="$CXXFLAGS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
|
||||
if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
|
||||
CXXFLAGS="-pthread $CXXFLAGS"
|
||||
CFLAGS="-pthread $FLAGS"
|
||||
save_LIBS=$LIBS
|
||||
AC_CHECK_LIB(c_r, pthread_exit)
|
||||
if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
|
||||
CXXFLAGS=$save_CXXFLAGS
|
||||
CFLAGS=$save_CFLAGS
|
||||
else
|
||||
dnl This is cheating a bit. pthread_exit comes with using -pthread, not
|
||||
-lpthread
|
||||
ac_cv_lib_pthread_pthread_exit="yes"
|
||||
fi
|
||||
LIBS=$save_LIBS
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
|
||||
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
|
||||
|
||||
thread_LIBS="$LIBS"
|
||||
LIBS=""
|
||||
@@ -270,7 +253,56 @@ esac
|
||||
opengl_LIBS="$LIBS"
|
||||
LIBS="$base_LIBS"
|
||||
|
||||
dnl check for OpenAL libraries
|
||||
OPENAL_OK="no"
|
||||
case "${host}" in
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
dnl CygWin under Windoze.
|
||||
|
||||
AC_SEARCH_LIBS(alGenBuffers, openal32)
|
||||
AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
|
||||
LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
|
||||
openal_LIBS="$LIBS"
|
||||
OPENAL_OK="$ac_cv_search_alGenBuffers"
|
||||
;;
|
||||
|
||||
*-apple-darwin*)
|
||||
dnl Mac OS X
|
||||
|
||||
LIBS="$LIBS -framework IOKit -framework OpenAL"
|
||||
openal_LIBS="$LIBS"
|
||||
# not sure how to test if OpenAL exists on MacOS (does it come by default?)
|
||||
OPENAL_OK="yes"
|
||||
;;
|
||||
|
||||
*)
|
||||
dnl default unix style machines
|
||||
|
||||
save_LIBS=$LIBS
|
||||
LIBS="$LIBS $thread_LIBS"
|
||||
AC_SEARCH_LIBS(alGenBuffers, openal)
|
||||
OPENAL_OK="$ac_cv_search_alGenBuffers"
|
||||
openal_LIBS="$LIBS"
|
||||
LIBS=$save_LIBS
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
if test "$OPENAL_OK" == "no"; then
|
||||
echo
|
||||
echo "You *must* have the openal library installed on your system to build"
|
||||
echo "SimGear!"
|
||||
echo
|
||||
echo "Please see README.OpenAL for more details."
|
||||
echo
|
||||
echo "configure aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
LIBS="$base_LIBS"
|
||||
|
||||
AC_SUBST(base_LIBS)
|
||||
AC_SUBST(openal_LIBS)
|
||||
AC_SUBST(opengl_LIBS)
|
||||
AC_SUBST(thread_LIBS)
|
||||
AC_SUBST(network_LIBS)
|
||||
@@ -297,11 +329,11 @@ if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
|
||||
exit
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for plib 1.6.0 or newer])
|
||||
AC_MSG_CHECKING([for plib 1.8.4 or newer])
|
||||
AC_TRY_RUN([
|
||||
#include <plib/ul.h>
|
||||
|
||||
#define MIN_PLIB_VERSION 160
|
||||
#define MIN_PLIB_VERSION 184
|
||||
|
||||
int main() {
|
||||
int major, minor, micro;
|
||||
@@ -316,7 +348,7 @@ int main() {
|
||||
],
|
||||
AC_MSG_RESULT(yes),
|
||||
[AC_MSG_RESULT(wrong version);
|
||||
AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
|
||||
AC_MSG_ERROR([Install plib 1.8.4 or later first...])],
|
||||
AC_MSG_RESULT(yes)
|
||||
)
|
||||
|
||||
@@ -427,7 +459,7 @@ else
|
||||
echo "Without JPEG Factory support"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
if test "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
echo "Threads: pthread lib found."
|
||||
else
|
||||
echo "Threads: no threads (pthread lib not found.)"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Written by Curtis L. Olson, started February 1999.
|
||||
*
|
||||
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
* Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt/
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Written by Curtis L. Olson, started February 1999.
|
||||
*
|
||||
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
* Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -257,14 +257,16 @@ public:
|
||||
// Informational methods.
|
||||
|
||||
/**
|
||||
* @return the lon of the lower left corner of this tile.
|
||||
* @return the lon of the lower left corner of
|
||||
* the 1x1 chunk containing this tile.
|
||||
*/
|
||||
inline int get_lon() const { return lon; }
|
||||
inline int get_chunk_lon() const { return lon; }
|
||||
|
||||
/**
|
||||
* @return the lat of the lower left corner of this tile.
|
||||
* @return the lat of the lower left corner of
|
||||
* the 1x1 chunk containing this tile.
|
||||
*/
|
||||
inline int get_lat() const { return lat; }
|
||||
inline int get_chunk_lat() const { return lat; }
|
||||
|
||||
/**
|
||||
* @return the x coord within the 1x1 degree chunk this tile.
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# endif
|
||||
# elif __GNUC__ == 3
|
||||
# elif __GNUC__ >= 3
|
||||
// g++-3.0.x
|
||||
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NEED_AUTO_PTR
|
||||
@@ -149,13 +149,6 @@
|
||||
|
||||
#endif // __GNUC__
|
||||
|
||||
#if defined( __MINGW32__ )
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
# define isnan _isnan
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
/* KAI C++ */
|
||||
#if defined(__KCC)
|
||||
|
||||
@@ -343,7 +336,9 @@
|
||||
extern void *memmove(void *, const void *, size_t);
|
||||
# endif // __cplusplus
|
||||
|
||||
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
|
||||
# if !defined( __GNUC__ )
|
||||
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
|
||||
# endif
|
||||
|
||||
#endif // sun
|
||||
|
||||
@@ -371,6 +366,23 @@
|
||||
|
||||
#endif // __ICC
|
||||
|
||||
//
|
||||
// Platform dependent gl.h and glut.h definitions
|
||||
//
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define SG_GL_H <OpenGL/gl.h>
|
||||
# define SG_GLU_H <OpenGL/glu.h>
|
||||
# define SG_GLEXT_H <OpenGL/glext.h>
|
||||
# define SG_GLUT_H <GLUT/glut.h>
|
||||
#else
|
||||
# define SG_GL_H <GL/gl.h>
|
||||
# define SG_GLU_H <GL/glu.h>
|
||||
# define SG_GLEXT_H <GL/glext.h>
|
||||
# define SG_GLUT_H <GL/glut.h>
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// No user modifiable definitions beyond here.
|
||||
//
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started February 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -25,7 +25,9 @@ typedef enum {
|
||||
SG_NETWORK = 0x00004000,
|
||||
SG_ATC = 0x00008000,
|
||||
SG_NASAL = 0x00010000,
|
||||
SG_UNDEFD = 0x00020000, // For range checking
|
||||
SG_INSTR = 0x00020000,
|
||||
SG_SYSTEMS = 0x00040000,
|
||||
SG_UNDEFD = 0x00080000, // For range checking
|
||||
|
||||
SG_ALL = 0xFFFFFFFF
|
||||
} sgDebugClass;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// 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
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -48,7 +48,7 @@
|
||||
/** Ephemeris class
|
||||
*
|
||||
* Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
|
||||
* <curt@flightgear.org>
|
||||
* <http://www.flightgear.org/~curt>
|
||||
*
|
||||
* Introduction
|
||||
*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Shamelessly adapted from plib (plib.sourceforge.net) January 2001
|
||||
//
|
||||
// Original version Copyright (C) 2000 the plib team
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Shamelessly adapted from plib January 2001
|
||||
//
|
||||
// Original version Copyright (C) 2000 the plib team
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started January 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
// calculate the center of a list of points, by taking the halfway
|
||||
// point between the min and max points.
|
||||
static Point3D calc_center( point_list& wgs84_nodes ) {
|
||||
Point3D sgCalcCenter( point_list& wgs84_nodes ) {
|
||||
Point3D p, min, max;
|
||||
|
||||
if ( wgs84_nodes.size() ) {
|
||||
@@ -1145,7 +1145,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
|
||||
for ( i = start; i < end; ++i ) {
|
||||
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
|
||||
group_nodes.push_back( wgs84_nodes[ tris_v[i][j] ] );
|
||||
bs_center = calc_center( group_nodes );
|
||||
bs_center = sgCalcCenter( group_nodes );
|
||||
bs_radius = sgCalcBoundingRadius( bs_center, group_nodes );
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1196,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
|
||||
for ( i = start; i < end; ++i ) {
|
||||
for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
|
||||
group_nodes.push_back( wgs84_nodes[ strips_v[i][j] ] );
|
||||
bs_center = calc_center( group_nodes );
|
||||
bs_center = sgCalcCenter( group_nodes );
|
||||
bs_radius = sgCalcBoundingRadius( bs_center, group_nodes );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started January 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
@@ -221,6 +221,16 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \relates SGBinObject
|
||||
* Calculate the center of a list of points, by taking the halfway
|
||||
* point between the min and max points.
|
||||
* @param wgs84_nodes list of points in wgs84 coordinates
|
||||
* @return center point
|
||||
*/
|
||||
Point3D sgCalcCenter( point_list& wgs84_nodes );
|
||||
|
||||
|
||||
/**
|
||||
* \relates SGBinObject
|
||||
* Calculate the bounding sphere of a set of nodes.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
// Modified by Bernie Bright <bbright@bigpond.net.au>, May 2002.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include STL_IOSTREAM
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "sg_socket.hxx"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started November 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started July 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started July 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -9,9 +9,17 @@
|
||||
* IDSIA, Lugano, Switzerland
|
||||
* http://www.inf.ethz.ch/~schraudo/pubs/exp.pdf
|
||||
*
|
||||
* Base-2 exp, Laurent de Soras
|
||||
* http://www.musicdsp.org/archive.php?classid=5#106
|
||||
*
|
||||
* Fast log() Function, by Laurent de Soras:
|
||||
* http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-Fastlogfunction&forum=totd&id=-1
|
||||
*
|
||||
* Sin, Cos, Tan approximation
|
||||
* http://www.musicdsp.org/showArchiveComment.php?ArchiveID=115
|
||||
*
|
||||
* fast floating point power computation:
|
||||
* http://playstation2-linux.com/download/adam/power.c
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -21,6 +29,7 @@
|
||||
|
||||
|
||||
#include "fastmath.hxx"
|
||||
#define SGD_PI_2 1.57079632679489661923
|
||||
|
||||
/**
|
||||
* This function is on avarage 9 times faster than the system exp() function
|
||||
@@ -41,11 +50,76 @@ double fast_exp(double val) {
|
||||
const double a = 1048576/M_LN2;
|
||||
const double b_c = 1072632447; /* 1072693248 - 60801 */
|
||||
|
||||
_eco.n.i = a*val + b_c;
|
||||
_eco.n.i = (int)(a*val + b_c);
|
||||
|
||||
return _eco.d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linear approx. between 2 integer values of val. Uses 32-bit integers.
|
||||
* Not very efficient but faster than exp()
|
||||
*/
|
||||
double fast_exp2( const double val )
|
||||
{
|
||||
int e;
|
||||
double ret;
|
||||
|
||||
if (val >= 0) {
|
||||
e = int (val);
|
||||
ret = val - (e - 1);
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
((*((int *) &ret)) &= ~(2047 << 20)) += (e + 1023) << 20;
|
||||
#else
|
||||
((*(1 + (int *) &ret)) &= ~(2047 << 20)) += (e + 1023) << 20;
|
||||
#endif
|
||||
} else {
|
||||
e = int (val + 1023);
|
||||
ret = val - (e - 1024);
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
((*((int *) &ret)) &= ~(2047 << 20)) += e << 20;
|
||||
#else
|
||||
((*(1 + (int *) &ret)) &= ~(2047 << 20)) += e << 20;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
float _fast_log2(const float val)
|
||||
{
|
||||
float result, tmp;
|
||||
float mp = 0.346607f;
|
||||
|
||||
result = *(int*)&val;
|
||||
result *= 1.0/(1<<23);
|
||||
result = result - 127;
|
||||
|
||||
tmp = result - floor(result);
|
||||
tmp = (tmp - tmp*tmp) * mp;
|
||||
return tmp + result;
|
||||
}
|
||||
|
||||
float _fast_pow2(const float val)
|
||||
{
|
||||
float result;
|
||||
|
||||
float mp = 0.33971f;
|
||||
float tmp = val - floor(val);
|
||||
tmp = (tmp - tmp*tmp) * mp;
|
||||
|
||||
result = val + 127 - tmp;
|
||||
result *= (1<<23);
|
||||
*(int*)&result = (int)result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* While we're on the subject, someone might have use for these as well?
|
||||
@@ -63,3 +137,155 @@ void fast_BSR(float &x, register unsigned long shiftAmount) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fastpow(f,n) gives a rather *rough* estimate of a float number f to the
|
||||
* power of an integer number n (y=f^n). It is fast but result can be quite a
|
||||
* bit off, since we directly mess with the floating point exponent.
|
||||
*
|
||||
* Use it only for getting rough estimates of the values and where precision
|
||||
* is not that important.
|
||||
*/
|
||||
float fast_pow(const float f, const int n)
|
||||
{
|
||||
long *lp,l;
|
||||
lp=(long*)(&f);
|
||||
l=*lp;l-=0x3F800000l;l<<=(n-1);l+=0x3F800000l;
|
||||
*lp=l;
|
||||
return f;
|
||||
}
|
||||
|
||||
float fast_root(const float f, const int n)
|
||||
{
|
||||
long *lp,l;
|
||||
lp=(long*)(&f);
|
||||
l=*lp;l-=0x3F800000l;l>>=(n-1);l+=0x3F800000l;
|
||||
*lp=l;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Code for approximation of cos, sin, tan and inv sin, etc.
|
||||
* Surprisingly accurate and very usable.
|
||||
*
|
||||
* Domain:
|
||||
* Sin/Cos [0, pi/2]
|
||||
* Tan [0,pi/4]
|
||||
* InvSin/Cos [0, 1]
|
||||
* InvTan [-1, 1]
|
||||
*/
|
||||
|
||||
float fast_sin(const float val)
|
||||
{
|
||||
float fASqr = val*val;
|
||||
float fResult = -2.39e-08f;
|
||||
fResult *= fASqr;
|
||||
fResult += 2.7526e-06f;
|
||||
fResult *= fASqr;
|
||||
fResult -= 1.98409e-04f;
|
||||
fResult *= fASqr;
|
||||
fResult += 8.3333315e-03f;
|
||||
fResult *= fASqr;
|
||||
fResult -= 1.666666664e-01f;
|
||||
fResult *= fASqr;
|
||||
fResult += 1.0f;
|
||||
fResult *= val;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
float fast_cos(const float val)
|
||||
{
|
||||
float fASqr = val*val;
|
||||
float fResult = -2.605e-07f;
|
||||
fResult *= fASqr;
|
||||
fResult += 2.47609e-05f;
|
||||
fResult *= fASqr;
|
||||
fResult -= 1.3888397e-03f;
|
||||
fResult *= fASqr;
|
||||
fResult += 4.16666418e-02f;
|
||||
fResult *= fASqr;
|
||||
fResult -= 4.999999963e-01f;
|
||||
fResult *= fASqr;
|
||||
fResult += 1.0f;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
float fast_tan(const float val)
|
||||
{
|
||||
float fASqr = val*val;
|
||||
float fResult = 9.5168091e-03f;
|
||||
fResult *= fASqr;
|
||||
fResult += 2.900525e-03f;
|
||||
fResult *= fASqr;
|
||||
fResult += 2.45650893e-02f;
|
||||
fResult *= fASqr;
|
||||
fResult += 5.33740603e-02f;
|
||||
fResult *= fASqr;
|
||||
fResult += 1.333923995e-01f;
|
||||
fResult *= fASqr;
|
||||
fResult += 3.333314036e-01f;
|
||||
fResult *= fASqr;
|
||||
fResult += 1.0f;
|
||||
fResult *= val;
|
||||
|
||||
return fResult;
|
||||
|
||||
}
|
||||
|
||||
float fast_asin(float val)
|
||||
{
|
||||
float fRoot = sqrt(1.0f-val);
|
||||
float fResult = -0.0187293f;
|
||||
fResult *= val;
|
||||
fResult += 0.0742610f;
|
||||
fResult *= val;
|
||||
fResult -= 0.2121144f;
|
||||
fResult *= val;
|
||||
fResult += 1.5707288f;
|
||||
fResult = SGD_PI_2 - fRoot*fResult;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
float fast_acos(float val)
|
||||
{
|
||||
float fRoot = sqrt(1.0f-val);
|
||||
float fResult = -0.0187293f;
|
||||
fResult *= val;
|
||||
fResult += 0.0742610f;
|
||||
fResult *= val;
|
||||
fResult -= 0.2121144f;
|
||||
fResult *= val;
|
||||
fResult += 1.5707288f;
|
||||
fResult *= fRoot;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
float fast_atan(float val)
|
||||
{
|
||||
float fVSqr = val*val;
|
||||
float fResult = 0.0028662257f;
|
||||
fResult *= fVSqr;
|
||||
fResult -= 0.0161657367f;
|
||||
fResult *= fVSqr;
|
||||
fResult += 0.0429096138f;
|
||||
fResult *= fVSqr;
|
||||
fResult -= 0.0752896400f;
|
||||
fResult *= fVSqr;
|
||||
fResult += 0.1065626393f;
|
||||
fResult *= fVSqr;
|
||||
fResult -= 0.1420889944f;
|
||||
fResult *= fVSqr;
|
||||
fResult += 0.1999355085f;
|
||||
fResult *= fVSqr;
|
||||
fResult -= 0.3333314528f;
|
||||
fResult *= fVSqr;
|
||||
fResult += 1.0f;
|
||||
fResult *= val;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
@@ -32,24 +32,41 @@
|
||||
|
||||
|
||||
double fast_exp(double val);
|
||||
double fast_exp2(const double val);
|
||||
|
||||
float fast_pow(const float val1, const float val2);
|
||||
float fast_log2(const float cal);
|
||||
float fast_root(const float f, const int n);
|
||||
|
||||
float _fast_pow2(const float cal);
|
||||
float _fast_log2(const float val);
|
||||
|
||||
float fast_sin(const float val);
|
||||
float fast_cos(const float val);
|
||||
float fast_tan(const float val);
|
||||
float fast_asin(const float val);
|
||||
float fast_acos(const float val);
|
||||
float fast_atan(const float val);
|
||||
|
||||
void fast_BSL(float &x, register unsigned long shiftAmount);
|
||||
void fast_BSR(float &x, register unsigned long shiftAmount);
|
||||
|
||||
|
||||
inline float fast_log2 (float val)
|
||||
{
|
||||
int * const exp_ptr = reinterpret_cast <int *> (&val);
|
||||
int x = *exp_ptr;
|
||||
const int log_2 = ((x >> 23) & 255) - 128;
|
||||
x &= ~(255 << 23);
|
||||
x += 127 << 23;
|
||||
*exp_ptr = x;
|
||||
int * const exp_ptr = reinterpret_cast <int *> (&val);
|
||||
int x = *exp_ptr;
|
||||
const int log_2 = ((x >> 23) & 255) - 128;
|
||||
x &= ~(255 << 23);
|
||||
x += 127 << 23;
|
||||
*exp_ptr = x;
|
||||
|
||||
val = ((-1.0f/3) * val + 2) * val - 2.0f/3; // (1)
|
||||
val = ((-1.0f/3) * val + 2) * val - 2.0f/3; // (1)
|
||||
|
||||
return (val + log_2);
|
||||
return (val + log_2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is about 3 times faster than the system log() function
|
||||
* and has an error of about 0.01%
|
||||
@@ -65,5 +82,36 @@ inline float fast_log10 (const float &val)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is about twice as fast as the system pow(x,y) function
|
||||
*/
|
||||
inline float fast_pow(const float val1, const float val2)
|
||||
{
|
||||
return _fast_pow2(val2 * _fast_log2(val1));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Haven't seen this elsewhere, probably because it is too obvious?
|
||||
* Anyway, these functions are intended for 32-bit floating point numbers
|
||||
* only and should work a bit faster than the regular ones.
|
||||
*/
|
||||
inline float fast_abs(float f)
|
||||
{
|
||||
int i=((*(int*)&f)&0x7fffffff);
|
||||
return (*(float*)&i);
|
||||
}
|
||||
|
||||
inline float fast_neg(float f)
|
||||
{
|
||||
int i=((*(int*)&f)^0x80000000);
|
||||
return (*(float*)&i);
|
||||
}
|
||||
|
||||
inline int fast_sgn(float f)
|
||||
{
|
||||
return 1+(((*(int*)&f)>>31)<<1);
|
||||
}
|
||||
|
||||
#endif // !_SG_FMATH_HXX
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started April 1998.
|
||||
//
|
||||
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
||||
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
// Written by Curtis Olson, started April 1998.
|
||||
//
|
||||
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
||||
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started September 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started September 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started September 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Adapted from algebra3 by Jean-Francois Doue, started October 1998.
|
||||
*/
|
||||
|
||||
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
||||
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started June 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started June 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -108,7 +108,7 @@ static double seaLevelRadius(double r, double z)
|
||||
// starts making very poor guesses as to latitude. As altitude
|
||||
// approaches infinity, it should be guessing with geocentric
|
||||
// coordinates, not "local geodetic up" ones.
|
||||
void sgCartToGeod(double* xyz, double* lat, double* lon, double* alt)
|
||||
void sgCartToGeod(const double* xyz, double* lat, double* lon, double* alt)
|
||||
{
|
||||
// The error is expressed as a radian angle, and we want accuracy
|
||||
// to 1 part in 2^50 (an IEEE double has between 51 and 52
|
||||
|
||||
@@ -42,7 +42,7 @@ void sgGeodToGeoc(double lat_geod, double alt,
|
||||
* @param lon (out) Longitude, in radians
|
||||
* @param alt (out) Altitude, in meters above the WGS84 ellipsoid
|
||||
*/
|
||||
void sgCartToGeod(double* xyz, double* lat, double* lon, double* alt);
|
||||
void sgCartToGeod(const double* xyz, double* lat, double* lon, double* alt);
|
||||
|
||||
/**
|
||||
* Convert a cartesian point to a geodetic lat/lon/altitude.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started July 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started July 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// Written by Curtis L. Olson, started April 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -43,7 +43,7 @@ static const char sgDirPathSep = '/';
|
||||
static const char sgDirPathSepBad = '\\';
|
||||
#endif
|
||||
|
||||
#if defined( WIN32 )
|
||||
#if defined( WIN32 ) && !defined(__CYGWIN__)
|
||||
static const char sgSearchPathSep = ';';
|
||||
#else
|
||||
static const char sgSearchPathSep = ':';
|
||||
@@ -112,6 +112,11 @@ void SGPath::append( const string& p ) {
|
||||
fix();
|
||||
}
|
||||
|
||||
//add a new path component to the existing path string
|
||||
void SGPath::add( const string& p ) {
|
||||
append( sgSearchPathSep+p );
|
||||
}
|
||||
|
||||
|
||||
// concatenate a string to the end of the path without inserting a
|
||||
// path separator
|
||||
@@ -149,7 +154,7 @@ string SGPath::dir() const {
|
||||
// get the base part of the path (everything but the extension.)
|
||||
string SGPath::base() const {
|
||||
int index = path.rfind(".");
|
||||
if (index >= 0) {
|
||||
if ((index >= 0) && (path.find("/", index) == string::npos)) {
|
||||
return path.substr(0, index);
|
||||
} else {
|
||||
return "";
|
||||
@@ -157,9 +162,11 @@ string SGPath::base() const {
|
||||
}
|
||||
|
||||
// get the extention (everything after the final ".")
|
||||
// but make sure no "/" follows the "." character (otherwise it
|
||||
// is has to be a directory name containing a ".").
|
||||
string SGPath::extension() const {
|
||||
int index = path.rfind(".");
|
||||
if (index >= 0) {
|
||||
if ((index >= 0) && (path.find("/", index) == string::npos)) {
|
||||
return path.substr(index + 1);
|
||||
} else {
|
||||
return "";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
// Written by Curtis L. Olson, started April 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -79,6 +79,12 @@ public:
|
||||
* @param p additional path component */
|
||||
void append( const string& p );
|
||||
|
||||
/**
|
||||
* Append a new piece to the existing path. Inserts a search path
|
||||
* separator to the existing path and the new patch component.
|
||||
* @param p additional path component */
|
||||
void add( const string& p );
|
||||
|
||||
/**
|
||||
* Concatenate a string to the end of the path without inserting a
|
||||
* path separator.
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include STL_STRING
|
||||
|
||||
#include <ctype.h> // isspace()
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -561,7 +561,7 @@ public:
|
||||
* Property value types.
|
||||
*/
|
||||
enum Type {
|
||||
NONE,
|
||||
NONE = 0,
|
||||
ALIAS,
|
||||
BOOL,
|
||||
INT,
|
||||
|
||||
@@ -133,7 +133,6 @@ checkFlag (const char * flag, bool defaultState = true)
|
||||
void
|
||||
PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
||||
{
|
||||
State &st = state();
|
||||
const char * attval;
|
||||
|
||||
if (_level == 0) {
|
||||
@@ -160,6 +159,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
||||
}
|
||||
|
||||
else {
|
||||
State &st = state();
|
||||
// Get the index.
|
||||
attval = atts.getValue("n");
|
||||
int index = 0;
|
||||
@@ -322,6 +322,23 @@ readProperties (const string &file, SGPropertyNode * start_node)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read properties from an in-memory buffer.
|
||||
*
|
||||
* @param buf A character buffer containing the xml data.
|
||||
* @param size The size/length of the buffer in bytes
|
||||
* @param start_node The root node for reading properties.
|
||||
* @return true if the read succeeded, false otherwise.
|
||||
*/
|
||||
void readProperties (const char *buf, const int size,
|
||||
SGPropertyNode * start_node)
|
||||
{
|
||||
PropsVisitor visitor(start_node, "");
|
||||
readXML(buf, size, visitor);
|
||||
if (visitor.hasException())
|
||||
throw visitor.getException();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Property list writer.
|
||||
@@ -466,7 +483,7 @@ writeNode (ostream &output, const SGPropertyNode * node,
|
||||
}
|
||||
|
||||
// If there are children, write them next.
|
||||
if (nChildren > 0 || node->isAlias()) {
|
||||
if (nChildren > 0) {
|
||||
doIndent(output, indent);
|
||||
output << '<' << name;
|
||||
writeAtts(output, node);
|
||||
@@ -563,6 +580,8 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out)
|
||||
retval = false;
|
||||
break;
|
||||
default:
|
||||
if (in->isAlias())
|
||||
break;
|
||||
string message = "Unknown internal SGPropertyNode type";
|
||||
message += in->getType();
|
||||
throw sg_error(message, "SimGear Property Reader");
|
||||
|
||||
@@ -41,6 +41,13 @@ void readProperties (istream &input, SGPropertyNode * start_node,
|
||||
void readProperties (const string &file, SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Read properties from an in-memory buffer.
|
||||
*/
|
||||
void readProperties (const char *buf, const int size,
|
||||
SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML output stream.
|
||||
*/
|
||||
|
||||
@@ -29,12 +29,13 @@
|
||||
|
||||
// Constructor
|
||||
SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt,
|
||||
const modetype m, const string s ) {
|
||||
const modetype m, const string s, const string n ) {
|
||||
target_lon = lon;
|
||||
target_lat = lat;
|
||||
target_alt = alt;
|
||||
mode = m;
|
||||
id = s;
|
||||
name = n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ private:
|
||||
double distance;
|
||||
|
||||
string id;
|
||||
string name;
|
||||
|
||||
public:
|
||||
|
||||
@@ -86,10 +87,11 @@ public:
|
||||
* @param alt target altitude
|
||||
* @param mode type of coordinates/math to use
|
||||
* @param s waypoint identifier
|
||||
* @param n waypoint name
|
||||
*/
|
||||
SGWayPoint( const double lon = 0.0, const double lat = 0.0,
|
||||
const double alt = 0.0, const modetype m = WGS84,
|
||||
const string s = "" );
|
||||
const string s = "", const string n = "" );
|
||||
|
||||
/** Destructor */
|
||||
~SGWayPoint();
|
||||
@@ -153,6 +155,9 @@ public:
|
||||
/** @return waypoint id */
|
||||
inline string get_id() const { return id; }
|
||||
|
||||
/** @return waypoint name */
|
||||
inline string get_name() const { return name; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started May 1998.
|
||||
//
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
@@ -90,7 +90,7 @@ SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props
|
||||
{
|
||||
// Gather the path(s) to the texture(s)
|
||||
vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
|
||||
for (int i = 0; i < textures.size(); i++)
|
||||
for (unsigned int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
string tname = textures[i]->getStringValue();
|
||||
if (tname == "") {
|
||||
@@ -227,7 +227,7 @@ SGMaterial::build_ssg_state( bool defer_tex_load )
|
||||
{
|
||||
GLenum shade_model = GL_SMOOTH;
|
||||
|
||||
for (int i = 0; i < _status.size(); i++)
|
||||
for (unsigned int i = 0; i < _status.size(); i++)
|
||||
{
|
||||
ssgSimpleState *state = new ssgSimpleState();
|
||||
state->ref();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Written by Curtis Olson, started May 1998.
|
||||
// Overhauled by David Megginson, December 2001
|
||||
//
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
@@ -217,7 +217,7 @@ private:
|
||||
vector<_internal_state> _status;
|
||||
|
||||
// Round-robin counter
|
||||
int _current_ptr;
|
||||
unsigned int _current_ptr;
|
||||
|
||||
// texture size
|
||||
double xsize, ysize;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started May 1998.
|
||||
//
|
||||
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
||||
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
@@ -33,12 +33,12 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include <string.h>
|
||||
#include STL_STRING
|
||||
|
||||
@@ -174,56 +174,6 @@ static int gen_taxiway_dir_light_map( int r, int g, int b, int alpha ) {
|
||||
}
|
||||
|
||||
|
||||
// generate the directional vasi light environment texture map
|
||||
static int gen_vasi_light_map_old() {
|
||||
const int env_tex_res = 256;
|
||||
int half_res = env_tex_res / 2;
|
||||
|
||||
static unsigned char env_map[env_tex_res][env_tex_res][4];
|
||||
GLuint tex_name;
|
||||
|
||||
for ( int i = 0; i < env_tex_res; ++i ) {
|
||||
for ( int j = 0; j < env_tex_res; ++j ) {
|
||||
double x = (i - half_res) / (double)half_res;
|
||||
double y = (j - half_res) / (double)half_res;
|
||||
double dist = sqrt(x*x + y*y);
|
||||
if ( dist > 1.0 ) { dist = 1.0; }
|
||||
double bright = cos( dist * SGD_PI_2 );
|
||||
|
||||
// top half white, bottom half red
|
||||
env_map[i][j][0] = 255;
|
||||
if ( i > half_res ) {
|
||||
// white
|
||||
env_map[i][j][1] = 255;
|
||||
env_map[i][j][2] = 255;
|
||||
} else if ( i == half_res - 1 || i == half_res ) {
|
||||
// pink
|
||||
env_map[i][j][1] = 127;
|
||||
env_map[i][j][2] = 127;
|
||||
} else {
|
||||
// red
|
||||
env_map[i][j][1] = 0;
|
||||
env_map[i][j][2] = 0;
|
||||
}
|
||||
env_map[i][j][3] = (int)(bright * 255);
|
||||
}
|
||||
}
|
||||
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||
glGenTextures( 1, &tex_name );
|
||||
glBindTexture( GL_TEXTURE_2D, tex_name );
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, env_tex_res, env_tex_res, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, env_map);
|
||||
|
||||
return tex_name;
|
||||
}
|
||||
|
||||
|
||||
// Load a library of material properties
|
||||
bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started May 1998.
|
||||
//
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by David Megginson, started May 1998.
|
||||
//
|
||||
// Copyright (C) 1998 - 2003 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1998 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
@@ -126,6 +126,22 @@ SGMatModel::get_model_count( SGModelLib *modellib,
|
||||
return _models.size();
|
||||
}
|
||||
|
||||
static void
|
||||
setAlphaClampToBranch( ssgBranch *b, float clamp )
|
||||
{
|
||||
int nb = b->getNumKids();
|
||||
for (int i = 0; i<nb; i++) {
|
||||
ssgEntity *e = b->getKid(i);
|
||||
if (e->isAKindOf(ssgTypeLeaf())) {
|
||||
ssgSimpleState*s = (ssgSimpleState*)((ssgLeaf*)e)->getState();
|
||||
s->enable( GL_ALPHA_TEST );
|
||||
s->setAlphaClamp( clamp );
|
||||
} else if (e->isAKindOf(ssgTypeBranch())) {
|
||||
setAlphaClampToBranch( (ssgBranch*)e, clamp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
SGMatModel::load_models ( SGModelLib *modellib,
|
||||
const string &fg_root,
|
||||
@@ -147,6 +163,14 @@ SGMatModel::load_models ( SGModelLib *modellib,
|
||||
lod->ref();
|
||||
lod->setRanges(ranges, 2);
|
||||
if (_heading_type == HEADING_BILLBOARD) {
|
||||
// if the model is a billboard, it is likely :
|
||||
// 1. a branch with only leaves,
|
||||
// 2. a tree or a non rectangular shape faked by transparency
|
||||
// We add alpha clamp then
|
||||
if ( entity->isAKindOf(ssgTypeBranch()) ) {
|
||||
ssgBranch *b = (ssgBranch *)entity;
|
||||
setAlphaClampToBranch( b, 0.01f );
|
||||
}
|
||||
ssgCutout * cutout = new ssgCutout(false);
|
||||
cutout->addKid(entity);
|
||||
lod->addKid(cutout);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by David Megginson, December 2001
|
||||
//
|
||||
// Copyright (C) 1998 - 2003 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1998 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -6,16 +6,20 @@ noinst_HEADERS =
|
||||
|
||||
include_HEADERS = \
|
||||
animation.hxx \
|
||||
custtrans.hxx \
|
||||
location.hxx \
|
||||
model.hxx \
|
||||
modellib.hxx \
|
||||
personality.hxx \
|
||||
placement.hxx
|
||||
|
||||
libsgmodel_a_SOURCES = \
|
||||
animation.cxx \
|
||||
custtrans.cxx \
|
||||
location.cxx \
|
||||
model.cxx \
|
||||
modellib.cxx \
|
||||
personality.cxx \
|
||||
placement.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
@@ -14,9 +14,11 @@
|
||||
#include <simgear/math/interpolater.hxx>
|
||||
#include <simgear/props/condition.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
|
||||
#include "animation.hxx"
|
||||
|
||||
#include "custtrans.hxx"
|
||||
#include "personality.hxx"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -174,11 +176,17 @@ read_interpolation_table (SGPropertyNode_ptr props)
|
||||
|
||||
// Initialize the static data member
|
||||
double SGAnimation::sim_time_sec = 0.0;
|
||||
SGPersonalityBranch *SGAnimation::current_object = 0;
|
||||
|
||||
SGAnimation::SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch)
|
||||
: _branch(branch)
|
||||
{
|
||||
_branch->setName(props->getStringValue("name", 0));
|
||||
if ( props->getBoolValue( "enable-hot", true ) ) {
|
||||
_branch->setTraversalMaskBits( SSGTRAV_HOT );
|
||||
} else {
|
||||
_branch->clrTraversalMaskBits( SSGTRAV_HOT );
|
||||
}
|
||||
}
|
||||
|
||||
SGAnimation::~SGAnimation ()
|
||||
@@ -190,8 +198,14 @@ SGAnimation::init ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGAnimation::update()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
SGAnimation::restore()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -219,12 +233,16 @@ SGNullAnimation::~SGNullAnimation ()
|
||||
SGRangeAnimation::SGRangeAnimation (SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props)
|
||||
: SGAnimation(props, new ssgRangeSelector),
|
||||
_min(0.0), _max(0.0), _min_factor(1.0), _max_factor(1.0)
|
||||
|
||||
_min(0.0), _max(0.0), _min_factor(1.0), _max_factor(1.0),
|
||||
_condition(0)
|
||||
{
|
||||
SGPropertyNode_ptr node = props->getChild("condition");
|
||||
if (node != 0)
|
||||
_condition = sgReadCondition(prop_root, node);
|
||||
|
||||
float ranges[2];
|
||||
|
||||
SGPropertyNode_ptr node = props->getChild( "min-factor" );
|
||||
node = props->getChild( "min-factor" );
|
||||
if (node != 0) {
|
||||
_min_factor = props->getFloatValue("min-factor", 1.0);
|
||||
}
|
||||
@@ -255,26 +273,27 @@ SGRangeAnimation::~SGRangeAnimation ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGRangeAnimation::update()
|
||||
{
|
||||
float ranges[2];
|
||||
bool upd = false;
|
||||
float ranges[2];
|
||||
if ( _condition == 0 || _condition->test() ) {
|
||||
if (_min_prop != 0) {
|
||||
ranges[0] = _min_prop->getFloatValue() * _min_factor;
|
||||
upd = true;
|
||||
ranges[0] = _min_prop->getFloatValue() * _min_factor;
|
||||
} else {
|
||||
ranges[0] = _min * _min_factor;
|
||||
ranges[0] = _min * _min_factor;
|
||||
}
|
||||
if (_max_prop != 0) {
|
||||
ranges[1] = _max_prop->getFloatValue() * _max_factor;
|
||||
upd = true;
|
||||
ranges[1] = _max_prop->getFloatValue() * _max_factor;
|
||||
} else {
|
||||
ranges[1] = _max * _max_factor;
|
||||
}
|
||||
if (upd) {
|
||||
((ssgRangeSelector *)_branch)->setRanges(ranges, 2);
|
||||
ranges[1] = _max * _max_factor;
|
||||
}
|
||||
} else {
|
||||
ranges[0] = 0.f;
|
||||
ranges[1] = 1000000000.f;
|
||||
}
|
||||
((ssgRangeSelector *)_branch)->setRanges(ranges, 2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -313,13 +332,14 @@ SGSelectAnimation::~SGSelectAnimation ()
|
||||
delete _condition;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGSelectAnimation::update()
|
||||
{
|
||||
if (_condition != 0 && _condition->test())
|
||||
((ssgSelector *)_branch)->select(0xffff);
|
||||
else
|
||||
((ssgSelector *)_branch)->select(0x0000);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,8 +355,13 @@ SGSpinAnimation::SGSpinAnimation( SGPropertyNode *prop_root,
|
||||
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
||||
_factor(props->getDoubleValue("factor", 1.0)),
|
||||
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
|
||||
_last_time_sec( sim_time_sec )
|
||||
_last_time_sec( sim_time_sec ),
|
||||
_condition(0)
|
||||
{
|
||||
SGPropertyNode_ptr node = props->getChild("condition");
|
||||
if (node != 0)
|
||||
_condition = sgReadCondition(prop_root, node);
|
||||
|
||||
_center[0] = 0;
|
||||
_center[1] = 0;
|
||||
_center[2] = 0;
|
||||
@@ -372,20 +397,23 @@ SGSpinAnimation::~SGSpinAnimation ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGSpinAnimation::update()
|
||||
{
|
||||
double dt = sim_time_sec - _last_time_sec;
|
||||
_last_time_sec = sim_time_sec;
|
||||
if ( _condition == 0 || _condition->test() ) {
|
||||
double dt = sim_time_sec - _last_time_sec;
|
||||
_last_time_sec = sim_time_sec;
|
||||
|
||||
float velocity_rpms = (_prop->getDoubleValue() * _factor / 60.0);
|
||||
_position_deg += (dt * velocity_rpms * 360);
|
||||
while (_position_deg < 0)
|
||||
_position_deg += 360.0;
|
||||
while (_position_deg >= 360.0)
|
||||
_position_deg -= 360.0;
|
||||
set_rotation(_matrix, _position_deg, _center, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
float velocity_rpms = (_prop->getDoubleValue() * _factor / 60.0);
|
||||
_position_deg += (dt * velocity_rpms * 360);
|
||||
while (_position_deg < 0)
|
||||
_position_deg += 360.0;
|
||||
while (_position_deg >= 360.0)
|
||||
_position_deg -= 360.0;
|
||||
set_rotation(_matrix, _position_deg, _center, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,10 +424,28 @@ SGSpinAnimation::update()
|
||||
|
||||
SGTimedAnimation::SGTimedAnimation (SGPropertyNode_ptr props)
|
||||
: SGAnimation(props, new ssgSelector),
|
||||
_use_personality( props->getBoolValue("use-personality",false) ),
|
||||
_duration_sec(props->getDoubleValue("duration-sec", 1.0)),
|
||||
_last_time_sec(0),
|
||||
_step(-1)
|
||||
_last_time_sec( sim_time_sec ),
|
||||
_total_duration_sec( 0 ),
|
||||
_step( 0 )
|
||||
|
||||
{
|
||||
vector<SGPropertyNode_ptr> nodes = props->getChildren( "branch-duration-sec" );
|
||||
size_t nb = nodes.size();
|
||||
for ( size_t i = 0; i < nb; i++ ) {
|
||||
size_t ind = nodes[ i ]->getIndex();
|
||||
while ( ind >= _branch_duration_specs.size() ) {
|
||||
_branch_duration_specs.push_back( DurationSpec( _duration_sec ) );
|
||||
}
|
||||
SGPropertyNode_ptr rNode = nodes[ i ]->getChild("random");
|
||||
if ( rNode == 0 ) {
|
||||
_branch_duration_specs[ ind ] = DurationSpec( nodes[ i ]->getDoubleValue() );
|
||||
} else {
|
||||
_branch_duration_specs[ ind ] = DurationSpec( rNode->getDoubleValue( "min", 0.0 ),
|
||||
rNode->getDoubleValue( "max", 1.0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SGTimedAnimation::~SGTimedAnimation ()
|
||||
@@ -407,15 +453,91 @@ SGTimedAnimation::~SGTimedAnimation ()
|
||||
}
|
||||
|
||||
void
|
||||
SGTimedAnimation::init()
|
||||
{
|
||||
if ( !_use_personality ) {
|
||||
for ( int i = 0; i < getBranch()->getNumKids(); i++ ) {
|
||||
double v;
|
||||
if ( i < (int)_branch_duration_specs.size() ) {
|
||||
DurationSpec &sp = _branch_duration_specs[ i ];
|
||||
v = sp._min + sg_random() * ( sp._max - sp._min );
|
||||
} else {
|
||||
v = _duration_sec;
|
||||
}
|
||||
_branch_duration_sec.push_back( v );
|
||||
_total_duration_sec += v;
|
||||
}
|
||||
// Sanity check : total duration shouldn't equal zero
|
||||
if ( _total_duration_sec < 0.01 ) {
|
||||
_total_duration_sec = 0.01;
|
||||
}
|
||||
}
|
||||
((ssgSelector *)getBranch())->selectStep(_step);
|
||||
}
|
||||
|
||||
int
|
||||
SGTimedAnimation::update()
|
||||
{
|
||||
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
|
||||
_last_time_sec = sim_time_sec;
|
||||
_step++;
|
||||
if (_step >= getBranch()->getNumKids())
|
||||
_step = 0;
|
||||
((ssgSelector *)getBranch())->selectStep(_step);
|
||||
if ( _use_personality ) {
|
||||
SGPersonalityBranch *key = current_object;
|
||||
if ( !key->getIntValue( this, INIT ) ) {
|
||||
double total = 0;
|
||||
double offset = 1.0;
|
||||
for ( size_t i = 0; i < _branch_duration_specs.size(); i++ ) {
|
||||
DurationSpec &sp = _branch_duration_specs[ i ];
|
||||
double v = sp._min + sg_random() * ( sp._max - sp._min );
|
||||
key->setDoubleValue( v, this, BRANCH_DURATION_SEC, i );
|
||||
if ( i == 0 )
|
||||
offset = v;
|
||||
total += v;
|
||||
}
|
||||
// Sanity check : total duration shouldn't equal zero
|
||||
if ( total < 0.01 ) {
|
||||
total = 0.01;
|
||||
}
|
||||
offset *= sg_random();
|
||||
key->setDoubleValue( sim_time_sec - offset, this, LAST_TIME_SEC );
|
||||
key->setDoubleValue( total, this, TOTAL_DURATION_SEC );
|
||||
key->setIntValue( 0, this, STEP );
|
||||
key->setIntValue( 1, this, INIT );
|
||||
}
|
||||
|
||||
_step = key->getIntValue( this, STEP );
|
||||
_last_time_sec = key->getDoubleValue( this, LAST_TIME_SEC );
|
||||
_total_duration_sec = key->getDoubleValue( this, TOTAL_DURATION_SEC );
|
||||
while ( ( sim_time_sec - _last_time_sec ) >= _total_duration_sec ) {
|
||||
_last_time_sec += _total_duration_sec;
|
||||
}
|
||||
double duration = _duration_sec;
|
||||
if ( _step < (int)_branch_duration_specs.size() ) {
|
||||
duration = key->getDoubleValue( this, BRANCH_DURATION_SEC, _step );
|
||||
}
|
||||
if ( ( sim_time_sec - _last_time_sec ) >= duration ) {
|
||||
_last_time_sec += duration;
|
||||
_step += 1;
|
||||
if ( _step >= getBranch()->getNumKids() )
|
||||
_step = 0;
|
||||
}
|
||||
((ssgSelector *)getBranch())->selectStep( _step );
|
||||
key->setDoubleValue( _last_time_sec, this, LAST_TIME_SEC );
|
||||
key->setIntValue( _step, this, STEP );
|
||||
} else {
|
||||
while ( ( sim_time_sec - _last_time_sec ) >= _total_duration_sec ) {
|
||||
_last_time_sec += _total_duration_sec;
|
||||
}
|
||||
double duration = _duration_sec;
|
||||
if ( _step < (int)_branch_duration_sec.size() ) {
|
||||
duration = _branch_duration_sec[ _step ];
|
||||
}
|
||||
if ( ( sim_time_sec - _last_time_sec ) >= duration ) {
|
||||
_last_time_sec += duration;
|
||||
_step += 1;
|
||||
if ( _step >= getBranch()->getNumKids() )
|
||||
_step = 0;
|
||||
((ssgSelector *)getBranch())->selectStep( _step );
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -435,8 +557,13 @@ SGRotateAnimation::SGRotateAnimation( SGPropertyNode *prop_root,
|
||||
_min_deg(props->getDoubleValue("min-deg")),
|
||||
_has_max(props->hasValue("max-deg")),
|
||||
_max_deg(props->getDoubleValue("max-deg")),
|
||||
_position_deg(props->getDoubleValue("starting-position-deg", 0))
|
||||
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
|
||||
_condition(0)
|
||||
{
|
||||
SGPropertyNode_ptr node = props->getChild("condition");
|
||||
if (node != 0)
|
||||
_condition = sgReadCondition(prop_root, node);
|
||||
|
||||
_center[0] = 0;
|
||||
_center[1] = 0;
|
||||
_center[2] = 0;
|
||||
@@ -473,20 +600,23 @@ SGRotateAnimation::~SGRotateAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGRotateAnimation::update()
|
||||
{
|
||||
if (_table == 0) {
|
||||
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
|
||||
if (_has_min && _position_deg < _min_deg)
|
||||
_position_deg = _min_deg;
|
||||
if (_has_max && _position_deg > _max_deg)
|
||||
_position_deg = _max_deg;
|
||||
} else {
|
||||
_position_deg = _table->interpolate(_prop->getDoubleValue());
|
||||
if (_condition == 0 || _condition->test()) {
|
||||
if (_table == 0) {
|
||||
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
|
||||
if (_has_min && _position_deg < _min_deg)
|
||||
_position_deg = _min_deg;
|
||||
if (_has_max && _position_deg > _max_deg)
|
||||
_position_deg = _max_deg;
|
||||
} else {
|
||||
_position_deg = _table->interpolate(_prop->getDoubleValue());
|
||||
}
|
||||
set_rotation(_matrix, _position_deg, _center, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
}
|
||||
set_rotation(_matrix, _position_deg, _center, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -498,14 +628,14 @@ SGBlendAnimation::SGBlendAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props )
|
||||
: SGAnimation(props, new ssgTransform),
|
||||
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
||||
_table(read_interpolation_table(props)),
|
||||
_prev_value(1.0),
|
||||
_offset(props->getDoubleValue("offset", 0.0)),
|
||||
_factor(props->getDoubleValue("factor", 1.0)),
|
||||
_table(read_interpolation_table(props)),
|
||||
_has_min(props->hasValue("min")),
|
||||
_min(props->getDoubleValue("min", 0.0)),
|
||||
_has_max(props->hasValue("max")),
|
||||
_max(props->getDoubleValue("max", 1.0)),
|
||||
_prev_value(1.0)
|
||||
_max(props->getDoubleValue("max", 1.0))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -514,7 +644,7 @@ SGBlendAnimation::~SGBlendAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGBlendAnimation::update()
|
||||
{
|
||||
double _blend;
|
||||
@@ -534,6 +664,7 @@ SGBlendAnimation::update()
|
||||
_prev_value = _blend;
|
||||
change_alpha( _branch, _blend );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -553,8 +684,13 @@ SGTranslateAnimation::SGTranslateAnimation( SGPropertyNode *prop_root,
|
||||
_min_m(props->getDoubleValue("min-m")),
|
||||
_has_max(props->hasValue("max-m")),
|
||||
_max_m(props->getDoubleValue("max-m")),
|
||||
_position_m(props->getDoubleValue("starting-position-m", 0))
|
||||
_position_m(props->getDoubleValue("starting-position-m", 0)),
|
||||
_condition(0)
|
||||
{
|
||||
SGPropertyNode_ptr node = props->getChild("condition");
|
||||
if (node != 0)
|
||||
_condition = sgReadCondition(prop_root, node);
|
||||
|
||||
_axis[0] = props->getFloatValue("axis/x", 0);
|
||||
_axis[1] = props->getFloatValue("axis/y", 0);
|
||||
_axis[2] = props->getFloatValue("axis/z", 0);
|
||||
@@ -566,20 +702,23 @@ SGTranslateAnimation::~SGTranslateAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGTranslateAnimation::update()
|
||||
{
|
||||
if (_table == 0) {
|
||||
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
||||
if (_has_min && _position_m < _min_m)
|
||||
_position_m = _min_m;
|
||||
if (_has_max && _position_m > _max_m)
|
||||
_position_m = _max_m;
|
||||
} else {
|
||||
_position_m = _table->interpolate(_prop->getDoubleValue());
|
||||
if (_condition == 0 || _condition->test()) {
|
||||
if (_table == 0) {
|
||||
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
||||
if (_has_min && _position_m < _min_m)
|
||||
_position_m = _min_m;
|
||||
if (_has_max && _position_m > _max_m)
|
||||
_position_m = _max_m;
|
||||
} else {
|
||||
_position_m = _table->interpolate(_prop->getDoubleValue());
|
||||
}
|
||||
set_translation(_matrix, _position_m, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
}
|
||||
set_translation(_matrix, _position_m, _axis);
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -619,7 +758,7 @@ SGScaleAnimation::~SGScaleAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGScaleAnimation::update()
|
||||
{
|
||||
if (_table == 0) {
|
||||
@@ -654,6 +793,7 @@ SGScaleAnimation::update()
|
||||
|
||||
set_scale(_matrix, _x_scale, _y_scale, _z_scale );
|
||||
((ssgTransform *)_branch)->setTransform(_matrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -688,7 +828,7 @@ SGTexRotateAnimation::~SGTexRotateAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGTexRotateAnimation::update()
|
||||
{
|
||||
if (_table == 0) {
|
||||
@@ -702,6 +842,7 @@ SGTexRotateAnimation::update()
|
||||
}
|
||||
set_rotation(_matrix, _position_deg, _center, _axis);
|
||||
((ssgTexTrans *)_branch)->setTransform(_matrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -735,7 +876,7 @@ SGTexTranslateAnimation::~SGTexTranslateAnimation ()
|
||||
delete _table;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGTexTranslateAnimation::update()
|
||||
{
|
||||
if (_table == 0) {
|
||||
@@ -749,6 +890,7 @@ SGTexTranslateAnimation::update()
|
||||
}
|
||||
set_translation(_matrix, _position, _axis);
|
||||
((ssgTexTrans *)_branch)->setTransform(_matrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -821,11 +963,10 @@ SGTexMultipleAnimation::SGTexMultipleAnimation( SGPropertyNode *prop_root,
|
||||
|
||||
SGTexMultipleAnimation::~SGTexMultipleAnimation ()
|
||||
{
|
||||
// delete _table;
|
||||
delete _transform;
|
||||
delete [] _transform;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SGTexMultipleAnimation::update()
|
||||
{
|
||||
int i;
|
||||
@@ -866,6 +1007,7 @@ SGTexMultipleAnimation::update()
|
||||
}
|
||||
}
|
||||
((ssgTexTrans *)_branch)->setTransform(tmatrix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -904,4 +1046,135 @@ void SGAlphaTestAnimation::setAlphaClampToBranch(ssgBranch *b, float clamp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of SGFlashAnimation
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
SGFlashAnimation::SGFlashAnimation(SGPropertyNode_ptr props)
|
||||
: SGAnimation( props, new SGCustomTransform )
|
||||
{
|
||||
_axis[0] = props->getFloatValue("axis/x", 0);
|
||||
_axis[1] = props->getFloatValue("axis/y", 0);
|
||||
_axis[2] = props->getFloatValue("axis/z", 1);
|
||||
|
||||
_center[0] = props->getFloatValue("center/x-m", 0);
|
||||
_center[1] = props->getFloatValue("center/y-m", 0);
|
||||
_center[2] = props->getFloatValue("center/z-m", 0);
|
||||
|
||||
_offset = props->getFloatValue("offset", 0.0);
|
||||
_factor = props->getFloatValue("factor", 1.0);
|
||||
_power = props->getFloatValue("power", 1.0);
|
||||
_two_sides = props->getBoolValue("two-sides", false);
|
||||
|
||||
_min_v = props->getFloatValue("min", 0.0);
|
||||
_max_v = props->getFloatValue("max", 1.0);
|
||||
|
||||
((SGCustomTransform *)_branch)->setTransCallback( &SGFlashAnimation::flashCallback, this );
|
||||
}
|
||||
|
||||
SGFlashAnimation::~SGFlashAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
void SGFlashAnimation::flashCallback( sgMat4 r, sgFrustum *f, sgMat4 m, void *d )
|
||||
{
|
||||
((SGFlashAnimation *)d)->flashCallback( r, f, m );
|
||||
}
|
||||
|
||||
void SGFlashAnimation::flashCallback( sgMat4 r, sgFrustum *f, sgMat4 m )
|
||||
{
|
||||
sgVec3 transformed_axis;
|
||||
sgXformVec3( transformed_axis, _axis, m );
|
||||
sgNormalizeVec3( transformed_axis );
|
||||
|
||||
sgVec3 view;
|
||||
sgFullXformPnt3( view, _center, m );
|
||||
sgNormalizeVec3( view );
|
||||
|
||||
float cos_angle = -sgScalarProductVec3( transformed_axis, view );
|
||||
float scale_factor = 0.f;
|
||||
if ( _two_sides && cos_angle < 0 )
|
||||
scale_factor = _factor * (float)pow( -cos_angle, _power ) + _offset;
|
||||
else if ( cos_angle > 0 )
|
||||
scale_factor = _factor * (float)pow( cos_angle, _power ) + _offset;
|
||||
|
||||
if ( scale_factor < _min_v )
|
||||
scale_factor = _min_v;
|
||||
if ( scale_factor > _max_v )
|
||||
scale_factor = _max_v;
|
||||
|
||||
sgMat4 transform;
|
||||
sgMakeIdentMat4( transform );
|
||||
transform[0][0] = scale_factor;
|
||||
transform[1][1] = scale_factor;
|
||||
transform[2][2] = scale_factor;
|
||||
transform[3][0] = _center[0] * ( 1 - scale_factor );
|
||||
transform[3][1] = _center[1] * ( 1 - scale_factor );
|
||||
transform[3][2] = _center[2] * ( 1 - scale_factor );
|
||||
|
||||
sgCopyMat4( r, m );
|
||||
sgPreMultMat4( r, transform );
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of SGDistScaleAnimation
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
SGDistScaleAnimation::SGDistScaleAnimation(SGPropertyNode_ptr props)
|
||||
: SGAnimation( props, new SGCustomTransform ),
|
||||
_factor(props->getFloatValue("factor", 1.0)),
|
||||
_offset(props->getFloatValue("offset", 0.0)),
|
||||
_min_v(props->getFloatValue("min", 0.0)),
|
||||
_max_v(props->getFloatValue("max", 1.0)),
|
||||
_has_min(props->hasValue("min")),
|
||||
_has_max(props->hasValue("max")),
|
||||
_table(read_interpolation_table(props))
|
||||
{
|
||||
_center[0] = props->getFloatValue("center/x-m", 0);
|
||||
_center[1] = props->getFloatValue("center/y-m", 0);
|
||||
_center[2] = props->getFloatValue("center/z-m", 0);
|
||||
|
||||
((SGCustomTransform *)_branch)->setTransCallback( &SGDistScaleAnimation::distScaleCallback, this );
|
||||
}
|
||||
|
||||
SGDistScaleAnimation::~SGDistScaleAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
void SGDistScaleAnimation::distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m, void *d )
|
||||
{
|
||||
((SGDistScaleAnimation *)d)->distScaleCallback( r, f, m );
|
||||
}
|
||||
|
||||
void SGDistScaleAnimation::distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m )
|
||||
{
|
||||
sgVec3 view;
|
||||
sgFullXformPnt3( view, _center, m );
|
||||
|
||||
float scale_factor = sgLengthVec3( view );
|
||||
if (_table == 0) {
|
||||
scale_factor = _factor * scale_factor + _offset;
|
||||
if ( _has_min && scale_factor < _min_v )
|
||||
scale_factor = _min_v;
|
||||
if ( _has_max && scale_factor > _max_v )
|
||||
scale_factor = _max_v;
|
||||
} else {
|
||||
scale_factor = _table->interpolate( scale_factor );
|
||||
}
|
||||
|
||||
sgMat4 transform;
|
||||
sgMakeIdentMat4( transform );
|
||||
transform[0][0] = scale_factor;
|
||||
transform[1][1] = scale_factor;
|
||||
transform[2][2] = scale_factor;
|
||||
transform[3][0] = _center[0] * ( 1 - scale_factor );
|
||||
transform[3][1] = _center[1] * ( 1 - scale_factor );
|
||||
transform[3][2] = _center[2] * ( 1 - scale_factor );
|
||||
|
||||
sgCopyMat4( r, m );
|
||||
sgPreMultMat4( r, transform );
|
||||
}
|
||||
|
||||
// end of animation.cxx
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(map);
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
@@ -25,6 +27,7 @@ SG_USING_STD(vector);
|
||||
// Don't pull in the headers, since we don't need them here.
|
||||
class SGInterpTable;
|
||||
class SGCondition;
|
||||
class SGPersonalityBranch;
|
||||
|
||||
|
||||
// Has anyone done anything *really* stupid, like making min and max macros?
|
||||
@@ -65,7 +68,12 @@ public:
|
||||
/**
|
||||
* Update the animation.
|
||||
*/
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
|
||||
/**
|
||||
* Restore the state after the animation.
|
||||
*/
|
||||
virtual void restore();
|
||||
|
||||
/**
|
||||
* Set the value of sim_time_sec. This needs to be called every
|
||||
@@ -73,6 +81,12 @@ public:
|
||||
*/
|
||||
static void set_sim_time_sec( double val ) { sim_time_sec = val; }
|
||||
|
||||
/**
|
||||
* Current personality branch : enable animation to behave differently
|
||||
* for similar objects
|
||||
*/
|
||||
static SGPersonalityBranch *current_object;
|
||||
|
||||
protected:
|
||||
|
||||
static double sim_time_sec;
|
||||
@@ -102,7 +116,7 @@ public:
|
||||
SGRangeAnimation (SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props);
|
||||
virtual ~SGRangeAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _min_prop;
|
||||
SGPropertyNode_ptr _max_prop;
|
||||
@@ -110,6 +124,7 @@ private:
|
||||
float _max;
|
||||
float _min_factor;
|
||||
float _max_factor;
|
||||
SGCondition * _condition;
|
||||
};
|
||||
|
||||
|
||||
@@ -133,7 +148,7 @@ public:
|
||||
SGSelectAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGSelectAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGCondition * _condition;
|
||||
};
|
||||
@@ -151,7 +166,7 @@ public:
|
||||
SGPropertyNode_ptr props,
|
||||
double sim_time_sec );
|
||||
virtual ~SGSpinAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _factor;
|
||||
@@ -160,6 +175,7 @@ private:
|
||||
sgMat4 _matrix;
|
||||
sgVec3 _center;
|
||||
sgVec3 _axis;
|
||||
SGCondition * _condition;
|
||||
};
|
||||
|
||||
|
||||
@@ -171,11 +187,22 @@ class SGTimedAnimation : public SGAnimation
|
||||
public:
|
||||
SGTimedAnimation (SGPropertyNode_ptr props);
|
||||
virtual ~SGTimedAnimation ();
|
||||
virtual void update();
|
||||
virtual void init();
|
||||
virtual int update();
|
||||
private:
|
||||
bool _use_personality;
|
||||
enum PersonalityVar { INIT, LAST_TIME_SEC, TOTAL_DURATION_SEC, BRANCH_DURATION_SEC, STEP };
|
||||
double _duration_sec;
|
||||
double _last_time_sec;
|
||||
double _total_duration_sec;
|
||||
int _step;
|
||||
struct DurationSpec {
|
||||
DurationSpec( double m = 0.0 ) : _min(m), _max(m) {}
|
||||
DurationSpec( double m1, double m2 ) : _min(m1), _max(m2) {}
|
||||
double _min, _max;
|
||||
};
|
||||
vector<DurationSpec> _branch_duration_specs;
|
||||
vector<double> _branch_duration_sec;
|
||||
};
|
||||
|
||||
|
||||
@@ -189,7 +216,7 @@ class SGRotateAnimation : public SGAnimation
|
||||
public:
|
||||
SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
|
||||
virtual ~SGRotateAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _offset_deg;
|
||||
@@ -203,6 +230,7 @@ private:
|
||||
sgMat4 _matrix;
|
||||
sgVec3 _center;
|
||||
sgVec3 _axis;
|
||||
SGCondition * _condition;
|
||||
};
|
||||
|
||||
|
||||
@@ -215,7 +243,7 @@ public:
|
||||
SGTranslateAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGTranslateAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _offset_m;
|
||||
@@ -228,6 +256,7 @@ private:
|
||||
double _position_m;
|
||||
sgMat4 _matrix;
|
||||
sgVec3 _axis;
|
||||
SGCondition * _condition;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -239,7 +268,7 @@ public:
|
||||
SGBlendAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGBlendAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
SGInterpTable * _table;
|
||||
@@ -261,7 +290,7 @@ public:
|
||||
SGScaleAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGScaleAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _x_factor;
|
||||
@@ -299,7 +328,7 @@ class SGTexRotateAnimation : public SGAnimation
|
||||
public:
|
||||
SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
|
||||
virtual ~SGTexRotateAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _offset_deg;
|
||||
@@ -325,7 +354,7 @@ public:
|
||||
SGTexTranslateAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGTexTranslateAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
SGPropertyNode_ptr _prop;
|
||||
double _offset;
|
||||
@@ -354,7 +383,7 @@ public:
|
||||
SGTexMultipleAnimation( SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr props );
|
||||
virtual ~SGTexMultipleAnimation ();
|
||||
virtual void update();
|
||||
virtual int update();
|
||||
private:
|
||||
class TexTransform
|
||||
{
|
||||
@@ -382,7 +411,7 @@ private:
|
||||
|
||||
|
||||
/**
|
||||
* An animation to enable the alpha test
|
||||
* An "animation" to enable the alpha test
|
||||
*/
|
||||
class SGAlphaTestAnimation : public SGAnimation
|
||||
{
|
||||
@@ -396,4 +425,45 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An "animation" that compute a scale according to
|
||||
* the angle between an axis and the view direction
|
||||
*/
|
||||
class SGFlashAnimation : public SGAnimation
|
||||
{
|
||||
public:
|
||||
SGFlashAnimation(SGPropertyNode_ptr props);
|
||||
virtual ~SGFlashAnimation ();
|
||||
|
||||
static void flashCallback( sgMat4 r, sgFrustum *f, sgMat4 m, void *d );
|
||||
void flashCallback( sgMat4 r, sgFrustum *f, sgMat4 m );
|
||||
|
||||
private:
|
||||
sgVec3 _axis, _center;
|
||||
float _power, _factor, _offset, _min_v, _max_v;
|
||||
bool _two_sides;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An animation that compute a scale according to
|
||||
* the distance from a point and the viewer
|
||||
*/
|
||||
class SGDistScaleAnimation : public SGAnimation
|
||||
{
|
||||
public:
|
||||
SGDistScaleAnimation(SGPropertyNode_ptr props);
|
||||
virtual ~SGDistScaleAnimation ();
|
||||
|
||||
static void distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m, void *d );
|
||||
void distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m );
|
||||
|
||||
private:
|
||||
sgVec3 _center;
|
||||
float _factor, _offset, _min_v, _max_v;
|
||||
bool _has_min, _has_max;
|
||||
SGInterpTable * _table;
|
||||
};
|
||||
|
||||
|
||||
#endif // _SG_ANIMATION_HXX
|
||||
|
||||
61
simgear/scene/model/custtrans.cxx
Executable file
61
simgear/scene/model/custtrans.cxx
Executable file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "plib/ssg.h"
|
||||
#include "custtrans.hxx"
|
||||
void _ssgPushMatrix ( sgMat4 m );
|
||||
void _ssgPopMatrix ();
|
||||
void _ssgReadInt ( FILE *fd, int *var );
|
||||
void _ssgWriteInt ( FILE *fd, const int var );
|
||||
extern sgMat4 _ssgOpenGLAxisSwapMatrix;
|
||||
|
||||
void SGCustomTransform::copy_from( SGCustomTransform *src, int clone_flags )
|
||||
{
|
||||
ssgBranch::copy_from( src, clone_flags );
|
||||
_callback = src->_callback;
|
||||
_data = src->_data;
|
||||
}
|
||||
|
||||
ssgBase *SGCustomTransform::clone( int clone_flags )
|
||||
{
|
||||
SGCustomTransform *b = new SGCustomTransform;
|
||||
b -> copy_from( this, clone_flags );
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
SGCustomTransform::SGCustomTransform()
|
||||
: _callback(0),_data(0)
|
||||
{
|
||||
type = ssgTypeBranch();
|
||||
}
|
||||
|
||||
SGCustomTransform::~SGCustomTransform()
|
||||
{
|
||||
}
|
||||
|
||||
void SGCustomTransform::cull( sgFrustum *f, sgMat4 m, int test_needed )
|
||||
{
|
||||
if ( ! preTravTests( &test_needed, SSGTRAV_CULL ) )
|
||||
return;
|
||||
|
||||
if ( _callback ) {
|
||||
sgMat4 tmp;
|
||||
_callback( tmp, f, m, _data );
|
||||
|
||||
_ssgPushMatrix( tmp );
|
||||
glPushMatrix();
|
||||
glLoadMatrixf( (float *) tmp );
|
||||
|
||||
for ( ssgEntity *e = getKid ( 0 ); e != NULL; e = getNextKid() )
|
||||
e -> cull( f, tmp, test_needed );
|
||||
|
||||
glPopMatrix();
|
||||
_ssgPopMatrix();
|
||||
}
|
||||
postTravTests( SSGTRAV_CULL );
|
||||
}
|
||||
|
||||
|
||||
const char *SGCustomTransform::getTypeName (void) { return "SGCustomTransform"; }
|
||||
32
simgear/scene/model/custtrans.hxx
Executable file
32
simgear/scene/model/custtrans.hxx
Executable file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _SG_CUSTOM_TRANSFORM_HXX
|
||||
#define _SG_CUSTOM_TRANSFORM_HXX 1
|
||||
|
||||
class SGCustomTransform : public ssgBranch
|
||||
{
|
||||
public:
|
||||
typedef void (*TransCallback)( sgMat4 r, sgFrustum *f, sgMat4 m, void *d );
|
||||
virtual ssgBase *clone( int clone_flags = 0 );
|
||||
SGCustomTransform();
|
||||
virtual ~SGCustomTransform(void);
|
||||
|
||||
void setTransCallback( TransCallback c, void *d ) {
|
||||
_callback = c;
|
||||
_data = d;
|
||||
}
|
||||
|
||||
virtual const char *getTypeName(void);
|
||||
virtual void cull( sgFrustum *f, sgMat4 m, int test_needed );
|
||||
|
||||
protected:
|
||||
virtual void copy_from( SGCustomTransform *src, int clone_flags );
|
||||
|
||||
private:
|
||||
TransCallback _callback;
|
||||
void *_data;
|
||||
};
|
||||
|
||||
#endif // _SG_CUSTOM_TRANSFORM_HXX
|
||||
@@ -3,7 +3,7 @@
|
||||
// Written by Jim Wilson, David Megginson, started April 2002.
|
||||
// Based largely on code by Curtis Olson and Norman Vine.
|
||||
//
|
||||
// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string.h> // for strcmp()
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
@@ -26,21 +27,44 @@
|
||||
#include "model.hxx"
|
||||
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(set);
|
||||
|
||||
bool sgUseDisplayList = true;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Global state
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
static bool
|
||||
model_filter = true;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Static utility functions.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int
|
||||
model_filter_callback (ssgEntity * entity, int mask)
|
||||
{
|
||||
return model_filter ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update an animation.
|
||||
*/
|
||||
static int
|
||||
animation_callback (ssgEntity * entity, int mask)
|
||||
{
|
||||
((SGAnimation *)entity->getUserData())->update();
|
||||
return true;
|
||||
return ((SGAnimation *)entity->getUserData())->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to restore the state after an animation.
|
||||
*/
|
||||
static int
|
||||
restore_callback (ssgEntity * entity, int mask)
|
||||
{
|
||||
((SGAnimation *)entity->getUserData())->restore();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +124,10 @@ sgMakeAnimation( ssgBranch * model,
|
||||
vector<SGPropertyNode_ptr> &name_nodes,
|
||||
SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr node,
|
||||
double sim_time_sec )
|
||||
double sim_time_sec,
|
||||
set<ssgBranch *> &ignore_branches )
|
||||
{
|
||||
bool ignore = false;
|
||||
SGAnimation * animation = 0;
|
||||
const char * type = node->getStringValue("type", "none");
|
||||
if (!strcmp("none", type)) {
|
||||
@@ -130,8 +156,13 @@ sgMakeAnimation( ssgBranch * model,
|
||||
animation = new SGTexMultipleAnimation(prop_root, node);
|
||||
} else if (!strcmp("blend", type)) {
|
||||
animation = new SGBlendAnimation(prop_root, node);
|
||||
ignore = true;
|
||||
} else if (!strcmp("alpha-test", type)) {
|
||||
animation = new SGAlphaTestAnimation(node);
|
||||
} else if (!strcmp("flash", type)) {
|
||||
animation = new SGFlashAnimation(node);
|
||||
} else if (!strcmp("dist-scale", type)) {
|
||||
animation = new SGDistScaleAnimation(node);
|
||||
} else {
|
||||
animation = new SGNullAnimation(node);
|
||||
SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
|
||||
@@ -144,7 +175,7 @@ sgMakeAnimation( ssgBranch * model,
|
||||
if (name_nodes.size() > 0) {
|
||||
object = find_named_node(model, name_nodes[0]->getStringValue());
|
||||
if (object == 0) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "Object " << name_nodes[0]->getStringValue()
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Object " << name_nodes[0]->getStringValue()
|
||||
<< " not found");
|
||||
delete animation;
|
||||
animation = 0;
|
||||
@@ -163,21 +194,41 @@ sgMakeAnimation( ssgBranch * model,
|
||||
const char * name = name_nodes[i]->getStringValue();
|
||||
object = find_named_node(model, name);
|
||||
if (object == 0) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "Object " << name << " not found");
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Object " << name << " not found");
|
||||
delete animation;
|
||||
animation = 0;
|
||||
} else {
|
||||
ssgBranch * oldParent = object->getParent(0);
|
||||
branch->addKid(object);
|
||||
oldParent->removeKid(object);
|
||||
}
|
||||
ssgBranch * oldParent = object->getParent(0);
|
||||
branch->addKid(object);
|
||||
oldParent->removeKid(object);
|
||||
}
|
||||
|
||||
animation->init();
|
||||
branch->setUserData(animation);
|
||||
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
|
||||
if ( animation != 0 ) {
|
||||
animation->init();
|
||||
branch->setUserData(animation);
|
||||
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
|
||||
branch->setTravCallback(SSG_CALLBACK_POSTTRAV, restore_callback);
|
||||
if ( ignore ) {
|
||||
ignore_branches.insert( branch );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void makeDList( ssgBranch *b, const set<ssgBranch *> &ignore )
|
||||
{
|
||||
int nb = b->getNumKids();
|
||||
for (int i = 0; i<nb; i++) {
|
||||
ssgEntity *e = b->getKid(i);
|
||||
if (e->isAKindOf(ssgTypeLeaf())) {
|
||||
((ssgLeaf*)e)->makeDList();
|
||||
} else if (e->isAKindOf(ssgTypeBranch()) && ignore.find((ssgBranch *)e) == ignore.end()) {
|
||||
makeDList( (ssgBranch*)e, ignore );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -187,17 +238,17 @@ sgMakeAnimation( ssgBranch * model,
|
||||
ssgBranch *
|
||||
sgLoad3DModel( const string &fg_root, const string &path,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec )
|
||||
double sim_time_sec, ssgEntity *(*load_panel)(SGPropertyNode *) )
|
||||
{
|
||||
ssgBranch * model = 0;
|
||||
SGPropertyNode props;
|
||||
|
||||
// Load the 3D aircraft object itself
|
||||
SGPath modelpath = path;
|
||||
SGPath modelpath = path, texturepath = path;
|
||||
if ( !ulIsAbsolutePathName( path.c_str() ) ) {
|
||||
SGPath tmp = fg_root;
|
||||
tmp.append(modelpath.str());
|
||||
modelpath = tmp;
|
||||
modelpath = texturepath = tmp;
|
||||
}
|
||||
|
||||
// Check for an XML wrapper
|
||||
@@ -206,6 +257,10 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
||||
if (props.hasValue("/path")) {
|
||||
modelpath = modelpath.dir();
|
||||
modelpath.append(props.getStringValue("/path"));
|
||||
if (props.hasValue("/texture-path")) {
|
||||
texturepath = texturepath.dir();
|
||||
texturepath.append(props.getStringValue("/texture-path"));
|
||||
}
|
||||
} else {
|
||||
if (model == 0)
|
||||
model = new ssgBranch;
|
||||
@@ -215,14 +270,18 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
||||
// Assume that textures are in
|
||||
// the same location as the XML file.
|
||||
if (model == 0) {
|
||||
ssgTexturePath((char *)modelpath.dir().c_str());
|
||||
if (texturepath.extension() != "")
|
||||
texturepath = texturepath.dir();
|
||||
|
||||
ssgTexturePath((char *)texturepath.c_str());
|
||||
model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
|
||||
if (model == 0)
|
||||
throw sg_exception("Failed to load 3D model");
|
||||
}
|
||||
|
||||
// Set up the alignment node
|
||||
ssgTransform * alignmainmodel = new ssgTransform;
|
||||
if ( load_panel == 0 )
|
||||
alignmainmodel->setTravCallback( SSG_CALLBACK_PRETRAV, model_filter_callback );
|
||||
alignmainmodel->addKid(model);
|
||||
sgMat4 res_matrix;
|
||||
sgMakeOffsetsMatrix(&res_matrix,
|
||||
@@ -252,24 +311,51 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
||||
align->setTransform(res_matrix);
|
||||
|
||||
ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"),
|
||||
prop_root, sim_time_sec );
|
||||
prop_root, sim_time_sec, load_panel );
|
||||
align->addKid(kid);
|
||||
align->setName(node->getStringValue("name", ""));
|
||||
model->addKid(align);
|
||||
}
|
||||
|
||||
// Load animations
|
||||
set<ssgBranch *> ignore_branches;
|
||||
vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
|
||||
for (i = 0; i < animation_nodes.size(); i++) {
|
||||
const char * name = animation_nodes[i]->getStringValue("name", 0);
|
||||
vector<SGPropertyNode_ptr> name_nodes =
|
||||
animation_nodes[i]->getChildren("object-name");
|
||||
sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
|
||||
sim_time_sec);
|
||||
sim_time_sec, ignore_branches);
|
||||
}
|
||||
|
||||
#if PLIB_VERSION > 183
|
||||
if ( model != 0 && sgUseDisplayList ) {
|
||||
makeDList( model, ignore_branches );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( load_panel ) {
|
||||
// Load panels
|
||||
vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
|
||||
for (i = 0; i < panel_nodes.size(); i++) {
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
|
||||
ssgEntity * panel = load_panel(panel_nodes[i]);
|
||||
if (panel_nodes[i]->hasValue("name"))
|
||||
panel->setName((char *)panel_nodes[i]->getStringValue("name"));
|
||||
model->addKid(panel);
|
||||
}
|
||||
}
|
||||
|
||||
return alignmainmodel;
|
||||
}
|
||||
|
||||
bool
|
||||
sgSetModelFilter( bool filter )
|
||||
{
|
||||
bool old = model_filter;
|
||||
model_filter = filter;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
// end of model.cxx
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(set);
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
@@ -43,7 +45,8 @@ SG_USING_STD(vector);
|
||||
*/
|
||||
ssgBranch *
|
||||
sgLoad3DModel( const string& fg_root, const string &path,
|
||||
SGPropertyNode *prop_root, double sim_time_sec );
|
||||
SGPropertyNode *prop_root, double sim_time_sec,
|
||||
ssgEntity *(*load_panel)(SGPropertyNode *) = 0 );
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,7 +65,18 @@ sgMakeAnimation( ssgBranch * model,
|
||||
vector<SGPropertyNode_ptr> &name_nodes,
|
||||
SGPropertyNode *prop_root,
|
||||
SGPropertyNode_ptr node,
|
||||
double sim_time_sec );
|
||||
double sim_time_sec,
|
||||
set<ssgBranch *> &ignore_branches );
|
||||
|
||||
/**
|
||||
* Set the filter state on models
|
||||
*/
|
||||
bool
|
||||
sgSetModelFilter( bool filter );
|
||||
|
||||
/**
|
||||
* Enable or disable Display list usage
|
||||
*/
|
||||
extern bool sgUseDisplayList;
|
||||
|
||||
#endif // __MODEL_HXX
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include "model.hxx"
|
||||
#include "animation.hxx"
|
||||
#include "personality.hxx"
|
||||
|
||||
#include "modellib.hxx"
|
||||
|
||||
@@ -60,6 +62,21 @@ SGModelLib::flush1()
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
personality_pretrav_callback(ssgEntity * entity, int mask)
|
||||
{
|
||||
((SGPersonalityBranch *)entity)->_old_current = SGAnimation::current_object;
|
||||
SGAnimation::current_object = (SGPersonalityBranch *)entity;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
personality_posttrav_callback(ssgEntity * entity, int mask)
|
||||
{
|
||||
SGAnimation::current_object = ((SGPersonalityBranch *)entity)->_old_current;
|
||||
((SGPersonalityBranch *)entity)->_old_current = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssgEntity *
|
||||
SGModelLib::load_model( const string &fg_root,
|
||||
@@ -67,6 +84,10 @@ SGModelLib::load_model( const string &fg_root,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec )
|
||||
{
|
||||
ssgBranch *personality_branch = new SGPersonalityBranch;
|
||||
personality_branch->setTravCallback(SSG_CALLBACK_PRETRAV, personality_pretrav_callback);
|
||||
personality_branch->setTravCallback(SSG_CALLBACK_POSTTRAV, personality_posttrav_callback);
|
||||
|
||||
// FIXME: normalize path to
|
||||
// avoid duplicates.
|
||||
map<string, ssgBase *>::iterator it = _table.find(path);
|
||||
@@ -75,10 +96,11 @@ SGModelLib::load_model( const string &fg_root,
|
||||
sim_time_sec );
|
||||
model->ref();
|
||||
_table[path] = model; // add one reference to keep it around
|
||||
return model;
|
||||
personality_branch->addKid( model );
|
||||
} else {
|
||||
return (ssgEntity *)it->second;
|
||||
personality_branch->addKid( (ssgEntity *)it->second );
|
||||
}
|
||||
return personality_branch;
|
||||
}
|
||||
|
||||
|
||||
|
||||
37
simgear/scene/model/personality.cxx
Executable file
37
simgear/scene/model/personality.cxx
Executable file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include "personality.hxx"
|
||||
|
||||
void SGPersonalityBranch::setDoubleValue( double value, SGAnimation *anim, int var_id, int var_num )
|
||||
{
|
||||
_doubleValues[ Key( anim, var_id, var_num ) ] = value;
|
||||
}
|
||||
|
||||
void SGPersonalityBranch::setIntValue( int value, SGAnimation *anim, int var_id, int var_num )
|
||||
{
|
||||
_intValues[ Key( anim, var_id, var_num ) ] = value;
|
||||
}
|
||||
|
||||
double SGPersonalityBranch::getDoubleValue( SGAnimation *anim, int var_id, int var_num ) const
|
||||
{
|
||||
map<Key,double>::const_iterator it = _doubleValues.find( Key( anim, var_id, var_num ) );
|
||||
if ( it != _doubleValues.end() ) {
|
||||
return it->second;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int SGPersonalityBranch::getIntValue( SGAnimation *anim, int var_id, int var_num ) const
|
||||
{
|
||||
map<Key,int>::const_iterator it = _intValues.find( Key( anim, var_id, var_num ) );
|
||||
if ( it != _intValues.end() ) {
|
||||
return it->second;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
41
simgear/scene/model/personality.hxx
Executable file
41
simgear/scene/model/personality.hxx
Executable file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _SG_PERSONALITY_HXX
|
||||
#define _SG_PERSONALITY_HXX 1
|
||||
|
||||
#include <map>
|
||||
|
||||
SG_USING_STD(map);
|
||||
|
||||
#include <plib/ssg.h>
|
||||
|
||||
class SGAnimation;
|
||||
|
||||
class SGPersonalityBranch : public ssgBranch {
|
||||
public:
|
||||
void setDoubleValue( double value, SGAnimation *anim, int var_id, int var_num = 0 );
|
||||
void setIntValue( int value, SGAnimation *anim, int var_id, int var_num = 0 );
|
||||
double getDoubleValue( SGAnimation *anim, int var_id, int var_num = 0 ) const;
|
||||
int getIntValue( SGAnimation *anim, int var_id, int var_num = 0 ) const;
|
||||
|
||||
SGPersonalityBranch *_old_current;
|
||||
|
||||
private:
|
||||
struct Key {
|
||||
Key( SGAnimation *a, int i, int n = 0 ) : anim(a), var_id(i), var_num(n) {}
|
||||
SGAnimation *anim;
|
||||
int var_id;
|
||||
int var_num;
|
||||
bool operator<( const Key &r ) const {
|
||||
return anim < r.anim ||
|
||||
( anim == r.anim && ( var_id < r.var_id ||
|
||||
( var_id == r.var_id && var_num < r.var_num ) ) );
|
||||
}
|
||||
};
|
||||
map<Key,double> _doubleValues;
|
||||
map<Key,int> _intValues;
|
||||
};
|
||||
|
||||
#endif // _SG_PERSONALITY_HXX
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
|
||||
// Written by Curtis Olson, started June 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -143,6 +143,18 @@ public:
|
||||
/** get the cloud movement speed */
|
||||
inline float getSpeed() { return speed; }
|
||||
|
||||
/**
|
||||
* set the alpha component of the cloud base color. Normally this
|
||||
* should be 1.0, but you can set it anywhere in the range of 0.0
|
||||
* to 1.0 to fade a cloud layer in or out.
|
||||
* @param alpha cloud alpha value (0.0 to 1.0)
|
||||
*/
|
||||
inline void setAlpha( float alpha ) {
|
||||
if ( alpha < 0.0 ) { alpha = 0.0; }
|
||||
if ( alpha > 1.0 ) { alpha = 1.0; }
|
||||
cloud_alpha = alpha;
|
||||
}
|
||||
|
||||
/** build the cloud object */
|
||||
void rebuild();
|
||||
|
||||
@@ -167,13 +179,31 @@ public:
|
||||
double dt = 0.0 );
|
||||
|
||||
/** draw the cloud layer */
|
||||
void draw();
|
||||
void draw( bool top );
|
||||
|
||||
static bool enable_bump_mapping;
|
||||
|
||||
private:
|
||||
|
||||
struct CloudVertex {
|
||||
sgVec3 position;
|
||||
sgVec2 texCoord;
|
||||
sgVec3 tangentSpLight;
|
||||
sgVec3 sTangent;
|
||||
sgVec3 tTangent;
|
||||
sgVec3 normal;
|
||||
sgVec4 color;
|
||||
};
|
||||
|
||||
CloudVertex *vertices;
|
||||
unsigned int *indices;
|
||||
|
||||
ssgRoot *layer_root;
|
||||
ssgTransform *layer_transform;
|
||||
ssgLeaf *layer[4];
|
||||
ssgStateSelector *state_sel;
|
||||
|
||||
float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely
|
||||
|
||||
ssgColourArray *cl[4];
|
||||
ssgVertexArray *vl[4];
|
||||
|
||||
@@ -33,9 +33,12 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/glu.h>
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GLU_H
|
||||
|
||||
#include "SkyCloud.hpp"
|
||||
#include "SkyRenderableInstance.hpp"
|
||||
#include "SkyContext.hpp"
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include "SkyUtil.hpp"
|
||||
#include "SkySingleton.hpp"
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/glu.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GLU_H
|
||||
|
||||
#include "glut_shapes.h"
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include "vec4f.hpp"
|
||||
#include "SkyUtil.hpp"
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include "SkyMinMaxBox.hpp"
|
||||
#include "camutils.hpp"
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/glu.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GLU_H
|
||||
|
||||
#include "SkyUtil.hpp"
|
||||
#include "SkyCloud.hpp"
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include "SkyRenderableInstanceGroup.hpp"
|
||||
#include "SkySceneManager.hpp"
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#define __glext_h_
|
||||
#define __GLEXT_H_
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/glu.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GLU_H
|
||||
|
||||
#include "SkyTextureManager.hpp"
|
||||
#include "SkyContext.hpp"
|
||||
|
||||
@@ -48,10 +48,13 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
# include <simgear_config.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include "glut_shapes.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <GL/glu.h>
|
||||
#include SG_GLU_H
|
||||
|
||||
|
||||
/* Some <math.h> files do not define M_PI... */
|
||||
@@ -509,7 +512,7 @@ static GLfloat idata[12][3] =
|
||||
{-Z, -X, 0}
|
||||
};
|
||||
|
||||
static int index[20][3] =
|
||||
static int iindex[20][3] =
|
||||
{
|
||||
{0, 4, 1},
|
||||
{0, 9, 4},
|
||||
@@ -539,7 +542,7 @@ icosahedron(GLenum shadeType)
|
||||
int i;
|
||||
|
||||
for (i = 19; i >= 0; i--) {
|
||||
drawtriangle(i, idata, index, shadeType);
|
||||
drawtriangle(i, idata, iindex, shadeType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
// SSG-ified by Curtis Olson, February 2000.
|
||||
//
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -33,7 +33,9 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include SG_GL_H
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
// SSG-ified by Curtis Olson, February 2000.
|
||||
//
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "sphere.hxx"
|
||||
#include "oursun.hxx"
|
||||
|
||||
static double sun_exp2_punch_through;
|
||||
|
||||
// Set up sun rendering call backs
|
||||
static int sgSunOrbPreDraw( ssgEntity *e ) {
|
||||
/* cout << endl << "Sun orb pre draw" << endl << "----------------"
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
static double sun_exp2_punch_through;
|
||||
|
||||
class SGSun {
|
||||
|
||||
ssgTransform *sun_transform;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
// SSG-ified by Curtis Olson, February 2000.
|
||||
//
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -171,46 +171,48 @@ bool SGSky::reposition( SGSkyState &st, double dt )
|
||||
void SGSky::preDraw( float alt, float fog_exp2_density ) {
|
||||
ssgCullAndDraw( pre_root );
|
||||
|
||||
// FIXME: This should not be needed, but at this time (08/15/2003)
|
||||
// certain NVidia drivers don't seem to implement
|
||||
// glPushAttrib(FG_FOG_BIT) properly. The result is that
|
||||
// there is not fog when looking at the sun.
|
||||
glFogf ( GL_FOG_DENSITY, fog_exp2_density );
|
||||
|
||||
// if we are closer than this to a cloud layer, don't draw clouds
|
||||
// if we are closer than this to a cloud layer, don't draw clouds
|
||||
static const float slop = 5.0;
|
||||
int i;
|
||||
|
||||
// check where we are relative to the cloud layers
|
||||
in_cloud = -1;
|
||||
for ( i = 0; i < (int)cloud_layers.size(); ++i ) {
|
||||
float asl = cloud_layers[i]->getElevation_m();
|
||||
float thickness = cloud_layers[i]->getThickness_m();
|
||||
float asl = cloud_layers[i]->getElevation_m();
|
||||
float thickness = cloud_layers[i]->getThickness_m();
|
||||
|
||||
if ( alt < asl - slop ) {
|
||||
// below cloud layer
|
||||
} else if ( alt < asl + thickness + slop ) {
|
||||
// in cloud layer
|
||||
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
|
||||
}
|
||||
// bail now and don't draw any clouds
|
||||
in_cloud = i;
|
||||
} else {
|
||||
// above cloud layer
|
||||
}
|
||||
}
|
||||
|
||||
// determine rendering order
|
||||
cur_layer_pos = 0;
|
||||
while ( cur_layer_pos < (int)cloud_layers.size() &&
|
||||
alt > cloud_layers[cur_layer_pos]->getElevation_m())
|
||||
alt > cloud_layers[cur_layer_pos]->getElevation_m() )
|
||||
{
|
||||
++cur_layer_pos;
|
||||
++cur_layer_pos;
|
||||
}
|
||||
|
||||
// FIXME: This should not be needed, but at this time (08/15/2003)
|
||||
// certain NVidia drivers don't seem to implement
|
||||
// glPushAttrib(FG_FOG_BIT) properly. The result is that
|
||||
// there is not fog when looking at the sun.
|
||||
glFogf ( GL_FOG_DENSITY, fog_exp2_density );
|
||||
}
|
||||
|
||||
void SGSky::drawUpperClouds( ) {
|
||||
// draw the cloud layers that are above us, top to bottom
|
||||
for ( i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) {
|
||||
for ( int i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) {
|
||||
if ( i != in_cloud ) {
|
||||
cloud_layers[i]->draw();
|
||||
cloud_layers[i]->draw( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,13 +220,12 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) {
|
||||
|
||||
// draw translucent clouds ... do this after you've drawn all the
|
||||
// oapaque elements of your scene.
|
||||
void SGSky::postDraw( float alt ) {
|
||||
void SGSky::drawLowerClouds() {
|
||||
|
||||
// draw the cloud layers that are below us, bottom to top
|
||||
|
||||
for ( int i = 0; i < cur_layer_pos; ++i ) {
|
||||
if ( i != in_cloud ) {
|
||||
cloud_layers[i]->draw();
|
||||
cloud_layers[i]->draw( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,7 +266,10 @@ void SGSky::modify_vis( float alt, float time_factor ) {
|
||||
|
||||
double ratio = 1.0;
|
||||
|
||||
if ( alt < asl - transition ) {
|
||||
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
|
||||
// less than 50% coverage -- assume we're in the clear for now
|
||||
ratio = 1.0;
|
||||
} else if ( alt < asl - transition ) {
|
||||
// below cloud layer
|
||||
ratio = 1.0;
|
||||
} else if ( alt < asl ) {
|
||||
@@ -282,9 +286,35 @@ void SGSky::modify_vis( float alt, float time_factor ) {
|
||||
ratio = 1.0;
|
||||
}
|
||||
|
||||
// accumulate effects from multiple cloud layers
|
||||
effvis *= ratio;
|
||||
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
|
||||
// do nothing, clear layers aren't drawn, don't affect
|
||||
// visibility andn dont' need to be faded in or out.
|
||||
} else if ( (cloud_layers[i]->getCoverage() ==
|
||||
SGCloudLayer::SG_CLOUD_FEW)
|
||||
|| (cloud_layers[i]->getCoverage() ==
|
||||
SGCloudLayer::SG_CLOUD_SCATTERED) )
|
||||
{
|
||||
// set the alpha fade value for the cloud layer. For less
|
||||
// dense cloud layers we fade the layer to nothing as we
|
||||
// approach it because we stay clear visibility-wise as we
|
||||
// pass through it.
|
||||
float temp = ratio * 2.0;
|
||||
if ( temp > 1.0 ) { temp = 1.0; }
|
||||
cloud_layers[i]->setAlpha( temp );
|
||||
|
||||
// don't touch visibility
|
||||
} else {
|
||||
// maintain full alpha for denser cloud layer types.
|
||||
// Let's set the value explicitly in case someone changed
|
||||
// the layer type.
|
||||
cloud_layers[i]->setAlpha( 1.0 );
|
||||
|
||||
// lower visibility as we approach the cloud layer.
|
||||
// accumulate effects from multiple cloud layers
|
||||
effvis *= ratio;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ( ratio < 1.0 ) {
|
||||
if ( ! in_puff ) {
|
||||
// calc chance of entering cloud puff
|
||||
@@ -341,12 +371,14 @@ void SGSky::modify_vis( float alt, float time_factor ) {
|
||||
in_puff = false;
|
||||
}
|
||||
}
|
||||
|
||||
// never let visibility drop below 25 meters
|
||||
if ( effvis <= 25.0 ) {
|
||||
effvis = 25.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// never let visibility drop below 25 meters
|
||||
if ( effvis <= 25.0 ) {
|
||||
effvis = 25.0;
|
||||
}
|
||||
|
||||
} // for
|
||||
|
||||
effective_visibility = effvis;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
// SSG-ified by Curtis Olson, February 2000.
|
||||
//
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -143,22 +143,27 @@ typedef struct {
|
||||
|
||||
* Rendering the Sky
|
||||
|
||||
* The sky is designed to be rendered in two stages. The first stage
|
||||
* The sky is designed to be rendered in three stages. The first stage
|
||||
* renders the parts that form your back drop - the sky dome, the
|
||||
* stars and planets, the sun, and the moon. These should be rendered
|
||||
* before the rest of your scene by calling the preDraw() method. The
|
||||
* second stage renders the clouds which are likely to be translucent
|
||||
* (depending on type) and should be drawn after your scene has been
|
||||
* rendered. Use the postDraw() method to draw the second stage of
|
||||
* the sky.
|
||||
* second stage renders the clouds that are above the viewer. This stage
|
||||
* is done before translucent objects in the main scene are drawn. It
|
||||
* is seperated from the preDraw routine to enable to implement a
|
||||
* multi passes technique and is located in the drawUpperClouds() method.
|
||||
* The third stage renders the clouds that are below the viewer an which
|
||||
* are likely to be translucent (depending on type) and should be drawn
|
||||
* after your scene has been rendered. Use the drawLowerClouds() method
|
||||
* to draw the second stage of the sky.
|
||||
|
||||
* A typical application might do the following:
|
||||
|
||||
* <li> thesky->preDraw();
|
||||
* <li> thesky->preDraw( my_altitude );
|
||||
* <li> thesky->drawUpperClouds();
|
||||
* <li> ssgCullAndDraw ( myscene ) ;
|
||||
* <li> thesky->postDraw( my_altitude );
|
||||
* <li> thesky->drawLowerClouds();
|
||||
|
||||
* The current altitude in meters is passed to the postDraw() method
|
||||
* The current altitude in meters is passed to the preDraw() method
|
||||
* so the clouds layers can be rendered correction from most distant
|
||||
* to closest.
|
||||
|
||||
@@ -332,12 +337,19 @@ public:
|
||||
void preDraw( float alt, float fog_exp2_density );
|
||||
|
||||
/**
|
||||
* Draw translucent clouds ... do this after you've drawn all the
|
||||
* oapaque elements of your scene. See discussion in detailed
|
||||
* class description.
|
||||
* @param alt current altitude
|
||||
* Draw upper translucent clouds ... do this before you've drawn
|
||||
* all the translucent elements of your scene. See discussion in
|
||||
* detailed class description.
|
||||
* @param fog_exp2_density fog density of the current cloud layer
|
||||
*/
|
||||
void postDraw( float alt );
|
||||
void drawUpperClouds();
|
||||
|
||||
/**
|
||||
* Draw lower translucent clouds ... do this after you've drawn
|
||||
* all the opaque elements of your scene. See discussion in detailed
|
||||
* class description.
|
||||
*/
|
||||
void drawLowerClouds();
|
||||
|
||||
/**
|
||||
* Specify the texture path (optional, defaults to current directory)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started July 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started July 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Written by Curtis Olson, started October 1997.
|
||||
//
|
||||
// Copyright (C) 1997 - 2003 Curtis L. Olson - curt@flightgear.org
|
||||
// Copyright (C) 1997 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user