Compare commits

...

225 Commits

Author SHA1 Message Date
Frederic Bouvier
1670f88e54 MSVC fix: deambiguiate function calls 2011-01-08 14:55:22 +01:00
Torsten Dreyer
58c7edfed6 SGExpression bugfix: allow <sin> within <product> 2011-01-08 13:06:25 +01:00
Torsten Dreyer
122d7f681f Add <expression> to animations
Allow complex animation expressions

Example: translate along the y-axis following a sin
function.
<animation>
  <type>translate</type>
  <axis>
    <y>1</y>
  </axis>
  <expression>
    <sin>
      <product>
        <property>/some/position-norm</property>
        <value>6.28</value>
      </product>
    </sin>
  </expression>
</animation>
2011-01-07 22:43:46 +01:00
Frederic Bouvier
acec1ba4bf Remove the dependency to boost serialization 2011-01-05 09:54:50 +01:00
Curtis L. Olson
0040757cd3 Merge branch 'next' of gitorious.org:fg/simgear into next 2011-01-03 07:55:45 -06:00
Curtis L. Olson
49d554e9d8 Update simgear version number to keep pace with FlightGear. 2011-01-03 07:54:31 -06:00
James Turner
fa3389ed23 Better MSVC Boost serialization fix from Olaf 2011-01-03 09:48:31 +00:00
Frederic Bouvier
188a84a893 Cmake: use build postfix 2011-01-02 19:44:04 +01:00
Frederic Bouvier
ceff1622c1 Cmake: Right way to search for include files 2011-01-02 18:45:14 +01:00
Frederic Bouvier
8d15cacf92 Cmake: MSVC_3RDPARTY_DIR is a path, not an option 2011-01-02 18:01:57 +01:00
James Turner
80161bfa96 Cmake: 3RDPARTY_DIR fixes from Olaf Flebbe 2011-01-01 21:06:43 +00:00
Torsten Dreyer
c32ab1b84f handle NCD (nil clouds detected) in METAR 2010-12-31 13:31:09 +01:00
Tim Moore
73c0ce628b Merge remote branch 'gitorious/next' into next 2010-12-29 18:12:56 +01:00
Tim Moore
dc68397e48 cmake improvements for shared library build 2010-12-29 18:12:44 +01:00
Tim Moore
c934b47f2e Issue 110: fix pick animation interaction with effects
Set OVERRIDE and PROTECTED attributes on pick animation state
attributes. Set up attributes and add a colorMode uniform so that the
default shader will take color and alpha values from the
material. Also, add a DotOsg writer method for ConditionNode.
2010-12-29 18:09:23 +01:00
James Turner
07d3d6508a Uninstall support, pinched from OSG. 2010-12-28 13:38:05 +00:00
James Turner
e4a8896fdc MSVC improvements from Olaf Flebbe. 2010-12-28 13:32:54 +00:00
Tim Moore
33e1a9457a set data variance to DYNAMIC for animated effect attributes 2010-12-26 18:34:00 +01:00
James Turner
b6a20fd6e4 64-bit compatability tweak from papillion 2010-12-20 14:46:53 +00:00
James Turner
ae9757bf43 Create version.h during SimGear CMake build 2010-12-19 19:08:14 +00:00
James Turner
b9a34b1b05 Initial work on CMake support for SimGear. 2010-12-19 14:16:39 +00:00
Erik Hofman
c33f66b691 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-12-13 18:40:39 +01:00
Erik Hofman
cf8d6c2621 Remove unused files 2010-12-13 18:40:08 +01:00
Torsten Dreyer
6c789f7165 metar: add string constants for cloud coverages 2010-12-12 22:18:10 +01:00
Erik Hofman
7d77eff4f4 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-12-12 20:23:08 +01:00
Erik Hofman
f83278bd61 Update the bad-doppler test and simplify it to only test for bad platforms. 2010-12-12 14:07:44 +01:00
Csaba Halasz
9a96018cc2 Compilation fix: add missing #include to SGPagedLod.cxx, needed by OSG 2.9.11 2010-12-12 00:23:06 +01:00
Torsten Dreyer
ab3612517f Make the max. opacity of a 2d cloud settable 2010-12-09 09:06:40 +01:00
Torsten Dreyer
0909722bb5 Metar: symbolic cloudnames and phenomena exposure
- use symbolic names for scattered, broken, overcast, etc. cloud
coverages.
- better approach to expose weather phenomena to the interface
2010-12-04 12:02:38 +01:00
Torsten Dreyer
1cb8f9237c Expose weather phenomena to the SGMetar interface 2010-11-27 21:04:04 +01:00
Anders Gidenstam
4cac366468 simgear/scene/sky/sky.cxx: Include sg_inlines.h with simgear/ prefix as all other simgear includes. 2010-11-26 21:49:30 +01:00
Torsten Dreyer
a6138b3445 Make visibility within cloudlayers settable 2010-11-26 19:24:44 +01:00
Frederic Bouvier
093e4614d3 Update VS2010 projects 2010-11-20 21:42:10 +01:00
Frederic Bouvier
82efb8a784 Update VS2010 projects 2010-11-20 14:23:20 +01:00
Frederic Bouvier
be720709fe Compile PropertyObject under Windows 2010-11-20 14:20:35 +01:00
James Turner
325b13b101 Build propertyObject on MSVC2008 2010-11-20 13:08:01 +00:00
James Turner
203d1c2b45 PropertyObject ::create tests. 2010-11-20 04:25:11 -08:00
James Turner
c3c97f2956 Shrink PropertyObjectBase by a pointer, don't pull exception header into the header. 2010-11-20 03:31:42 -08:00
James Turner
ac535de2fa PropertyObject enhancements, unit-test for make check 2010-11-20 02:49:04 -08:00
Torsten Dreyer
9d4f0f5824 A sum without diff is like foo without bar
Add a <difference> aka <diff> to SGExpression to compute
differences
2010-11-20 11:05:45 +01:00
ThorstenB
b4f5eaa541 Current timestamps for forced scenery loading.
Priorities during forced model loads won't work unless using current framestamps...
2010-11-19 13:39:20 +01:00
ThorstenB
66cdbf6215 Fixed invalid character in source file.
Removed illegal character (0xc). How did this happen???
2010-11-19 13:36:50 +01:00
ThorstenB
c9e0bfb7fe Improved tile cache priority scheme.
Use priorities for loading/unloading.
Maintain an expiry time for each tile.
Replaced "cache lock" by "current view" flag.
2010-11-19 13:33:12 +01:00
James Turner
6da8ef83af Merge branch 'topics/propobj' into next 2010-11-18 20:23:40 +00:00
James Turner
f53559b8d0 Initial propertyObject work. 2010-11-18 20:21:37 +00:00
Torsten Dreyer
49f038b9d1 Purge some gcc and MSVC warnings 2010-11-18 12:08:16 +01:00
Tim Moore
ce67657e0a eliminate property node path cache
The property path cache was making very little difference in practice
and made the eventual goal of having the property tree be thread safe
for readers more difficult to attain.
2010-11-17 11:25:07 +01:00
James Turner
56c520f455 Tighten up name filters on Unix. Fixes bug 168. 2010-11-15 23:23:40 +00:00
ThorstenB
9f88b077ee remove old .cvsignore files
Hello GIT!
2010-11-14 15:09:36 +01:00
Curtis L. Olson
50315a7346 Fix setsockopt() to match previous precident of setsockopt() usage (as seen
later in the setBroadcast() function.)
2010-11-12 15:52:33 -06:00
Frederic Bouvier
6b58afe823 Fix setsockopt call 2010-11-12 22:03:11 +01:00
Curtis L. Olson
167cba9e93 Patch to avoid the problem of the socket resource not yet being available
if the program is restarted quickly after being killed.

Reference: http://www.unixguide.net/network/socketfaq/4.5.shtml
2010-11-12 13:19:57 -06:00
Frederic Bouvier
ce89a410d2 Update VS2010 projects : use Boost 1.44.0 2010-11-07 20:01:18 +01:00
Frederic Bouvier
98d0f33f8f Don't crash on exit 2010-11-07 10:31:13 +01:00
Frederic Bouvier
c305341ef4 Update VS2008 projects : use Boost 1.44.0 available in last 3rd Party archive 2010-11-06 17:02:16 +01:00
ThorstenB
0607a67a92 Fixed METAR. Make loader fully HTTP compliant.
HTTP protocol requires a "Host:" line.
The old noaa server didn't mind. Now it does...
2010-11-05 20:07:50 +01:00
James Turner
5f2f95676c Formal shutdown interface on SGSubsystem. 2010-11-05 09:19:22 +00:00
Frederic Bouvier
4bf16243fc Update Vs2010 projects 2010-11-04 22:20:08 +01:00
James Turner
607738f22e Fix ConditionNode Win32 compilation. 2010-11-04 18:54:18 +00:00
James Turner
200df49d6e Make subsystem group destruction explicit, so get_subsystem calls during destruction are safe. 2010-11-04 18:49:24 +00:00
Tim Moore
580a1b7fc2 Add ConditionNode files to VC90 project 2010-11-04 15:04:03 +01:00
Tim Moore
3372f9fc0d add SGMath.hxx header file to ConditionNode.cxx
Apparently necessary for MSVC 2008.
2010-11-04 11:04:13 +01:00
Tim Moore
4787ac64ff issue 165: fix material animation condition problem
The evaluation of the condition is moved to a ConditionNode and
separated from the animation of values via properties. Previously the
conditional application of static values was broken.
2010-11-04 10:06:13 +01:00
Tim Moore
fef625ce27 add ConditionNode scenegraph node
This class directs its scenegraph traversal by evaluating a condition
and doesn't rely on an update callback.
2010-11-04 07:01:38 +01:00
ThorstenB
0b53dd8fa7 Show compiler warnings by default. 2010-10-30 20:53:19 +02:00
James Turner
fe628e44e1 Add platform defines to SimGear, and a replacement for ulSleep functions. 2010-10-30 19:18:57 +01:00
Frederic Bouvier
d314b6a552 Fix line endings 2010-10-29 19:47:44 +02:00
Frederic Bouvier
02462d1752 Quick hack to remote trailing / on Windows. Feel free to replace by something more elegant 2010-10-29 09:30:59 +02:00
ThorstenB
5b734d8c52 Merge branch 'integration' into next 2010-10-28 19:39:55 +02:00
James Turner
81d640ed7c Fix build when OSG implict-ref-ptr conversion is disabled. 2010-10-26 10:09:55 +01:00
Frederic Bouvier
7e2ad05fae Add mipmap.* to the unix build system 2010-10-25 21:59:55 +02:00
Frederic Bouvier
bda5890f17 Add a function to debug mipmaps 2010-10-25 21:51:27 +02:00
Frederic Bouvier
c7dd293e01 Update Vs2010 projects 2010-10-24 09:30:16 +02:00
Frederic Bouvier
fbf0a20f38 Unix line endings 2010-10-24 09:25:42 +02:00
Frederic Bouvier
87ccfbab02 Restore commit 48c6d3d89a by Torsten Dreyer: Provide a little more descriptive error message if TextureBuilder fails 2010-10-24 09:25:41 +02:00
Frederic Bouvier
97f39282ef Don't compute mipmap for inexistant image color components 2010-10-24 09:25:40 +02:00
Frederic Bouvier
4fd3d49fc1 Add mipmap control in the effect file 2010-10-24 09:25:40 +02:00
Frederic Bouvier
a70c8a9cae Untabify 2010-10-24 09:25:39 +02:00
Frederic Bouvier
c0926633e8 Update Vs2010 projects 2010-10-24 09:24:13 +02:00
James Turner
1ae91097ba Build fixes for net classes in Simgear. 2010-10-24 01:22:59 +01:00
James Turner
bfd76880a9 Migrate relevant PLIB netXXX classes into SimGear. 2010-10-24 01:12:42 +01:00
ThorstenB
662578dbe7 Buffer size safety.
Do not look for '\n' beyond valid data area.
Obey buffer length (in case a METAR contained a line > 512byte).
2010-10-23 14:47:24 +02:00
Torsten Dreyer
48c6d3d89a Provide a little more descriptive error message if TextureBuilder fails 2010-10-12 16:21:38 +02:00
Frederic Bouvier
7bdb530440 Add project.* to MSVC project files 2010-10-09 08:45:52 +02:00
Tim Moore
bfe953c18d replace glu functions with equivalents from OSG 2010-10-08 23:44:38 +02:00
Torsten Dreyer
136676012f Merge branch 'next' of gitorious.org:fg/simgear into next 2010-10-07 17:43:35 +02:00
Torsten Dreyer
0994ffc195 Don't crash in strutils::trim() with empty strings 2010-10-05 22:39:41 +02:00
Frederic Bouvier
df19feac34 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-10-05 08:32:00 +02:00
Frederic Bouvier
961fa89b7a Use same transformation for generated ocean tiles than for regular tiles. Fix the normal orientation that broke the new water shader 2010-10-05 08:30:52 +02:00
James Turner
ddf9e08069 Make get_subsystem safe during destruction of the manager. 2010-10-03 16:08:34 +01:00
Tim Moore
b5f3978b8a Thorsten Renk's fix for tile manager problems
Locking tiles in cache keeps tiles from mysteriously disappearing.
2010-10-02 23:05:52 +02:00
James Turner
82dc6c32ec Don't crash when a submodel fails to load. 2010-10-02 21:01:29 +01:00
James Turner
889e2d6f06 Add another overload for sg_io_exception ctor. 2010-10-01 12:27:08 +01:00
Torsten Dreyer
9a28642a4e tolerate NDV (no directional validation) in METAR 2010-09-27 19:38:15 +02:00
Torsten Dreyer
0b953462f7 Ivan Ngeow: Fix build on FreeBSD
FreeBSD 8.0-RELEASE, only a very small patch needed
to be applied to simgear/simgear/compiler.h, to add

so that __FreeBSD_version is defined.
2010-09-23 10:27:06 +02:00
Torsten Dreyer
061eb686c6 Fix wrong movement of 2d cloud layers on N/S courses 2010-09-19 10:53:25 +02:00
Frederic Bouvier
937297561f Fix MSVC 100 project files updated by hand 2010-09-12 12:06:57 +02:00
Erik Hofman
bf70d6f087 Set the listener position to it's default value, just like the samples position 2010-09-10 15:02:37 +02:00
Frederic Bouvier
26fdfc42f4 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-09-09 20:06:27 +02:00
Frederic Bouvier
abab8c6ec8 MSVC 10 project update 2010-09-09 20:06:15 +02:00
James Turner
a7697f6095 Second attempt to fixed OpenAL tests. 2010-09-06 14:27:58 +01:00
James Turner
49270e99e5 Fix up tests for revised SGSoundSample ctor. 2010-09-06 12:30:13 +01:00
James Turner
d75ce1e12e Pass current-dir down through XMLSound
(should allow relative paths in sound XML files)
2010-09-06 09:26:46 +01:00
James Turner
289e768ca5 Add ResourceManager, and use to find sound and model paths. 2010-09-06 09:09:58 +01:00
James Turner
44c587400d Validate sound file paths in an XML file. 2010-09-05 14:15:18 +01:00
Torsten Dreyer
df467b9dba Let SGCloudLayer handle coverage strings
This is currently handled in various places in FlightGear.
2010-08-27 18:20:09 +02:00
Frederic Bouvier
510543e14b Add a convenience constructeur to SGPath 2010-08-22 09:33:56 +02:00
Frederic Bouvier
c3133f020d std::string::c_str() is const 2010-08-21 09:02:12 +02:00
James Turner
a7439aa056 Standardise path-handling in XML mode files
aircraft-dir/fg-data paths always work, and
paths relative to the location of the current XML
file always work.
2010-08-17 11:05:55 +01:00
James Turner
d7bea0c4c6 Add isAbsolute/isRelative predicates to SGPath. 2010-08-14 22:51:01 +01:00
James Turner
764a3c29e9 Allow loading of 2.5D panels to be controlled again. 2010-08-14 19:48:52 +01:00
James Turner
3c57572b89 Ralf Gerlich: fix bucket numbering at extreme latitudes
Also document existing algorithms
2010-08-14 10:18:35 +01:00
Tim Moore
fe7c6554f7 support for integer uniforms
Also, share common Uniform objects
2010-08-13 12:54:02 +02:00
Tim Moore
19bb7f5a83 force static models to have effects too 2010-08-13 12:54:02 +02:00
Torsten Dreyer
c0e20ad56b add padding function lpad and rpad to strutils 2010-08-12 13:02:16 +02:00
Torsten Dreyer
49887ff06e Fix the fix that turned a warning into a bug :-( 2010-08-12 12:16:48 +02:00
Torsten Dreyer
1f6555c9ad two warning fixes 2010-08-12 11:42:04 +02:00
Torsten Dreyer
7f8efa7cef use correct parameter types for SGText::UpdateCallback 2010-08-12 11:35:09 +02:00
James Turner
8106956be2 Merge branch 'topics/cmdcatch' into next 2010-08-11 00:20:02 +01:00
James Turner
cc435ba817 Fix Win32 build of SGPath. 2010-08-09 09:13:28 +01:00
James Turner
0c55a4d7bb Catch exceptions raised executing a command. 2010-08-09 09:12:26 +01:00
James Turner
c4b4c0ce59 Make SGPath cache stat() information, cheers Fred
* cache exists/isDir/isFile in SGPath, to avoid
  repeated calls.
2010-08-09 08:19:14 +01:00
James Turner
d31c1df639 More ignore files, for 'make check' binaries 2010-08-08 09:55:31 +01:00
James Turner
780286ea81 Ding, dong, the witch is dead. PLIB is no more, in SimGear. 2010-08-07 18:03:37 +01:00
James Turner
20a75b9c9e Change how certain constants are (re-)defined, to avoid warning when PLIB sg.h is included. 2010-08-07 16:28:39 +01:00
James Turner
2a2e2716bd Removal of PLIB/SG from SimGear 2010-08-07 13:55:33 +01:00
James Turner
6a07c22826 Catch subsystem update() exceptions in the manager, and permit a maximum number of exceptions before suspending the subsystem. 2010-08-07 10:25:20 +01:00
James Turner
7c294915c8 Ensure 'make dist' works. 2010-08-07 09:09:58 +01:00
James Turner
7788cb288e Fixes for automake correctness. 2010-08-06 21:18:04 +01:00
James Turner
c1762c709e Ralf Gerlich: add headless mode to SimGear (merging simgear-cs) 2010-08-06 19:17:14 +01:00
James Turner
8690528080 Fix compilation if OSG ref_ptr implicit conversion is not enabled. 2010-08-06 18:42:56 +01:00
Frederic Bouvier
5376294389 Merge commit 'refs/merge-requests/1' of git://gitorious.org/fg/simgear into vivian/cube 2010-08-03 08:41:27 +02:00
Frederic Bouvier
fa1b703bf8 Update MSVC10 project files 2010-08-03 08:40:10 +02:00
Vivian Meazza
72d2c7f078 Remove debugging messages
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
2010-08-02 20:27:49 +01:00
Vivian Meazza
09ecc66e53 Add support for Cube Crosses. Based on Zan's work, with some bugs removed.
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
2010-08-02 20:22:33 +01:00
Erik Hofman
879dc295a8 Actually enable looping for a sample queue 2010-08-02 11:43:53 +02:00
Erik Hofman
8a5a1d3301 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-08-02 10:11:41 +02:00
Erik Hofman
67c8067aed Initial commit for a sample queue extension. 2010-08-02 10:10:58 +02:00
Frederic Bouvier
123e32e345 MSVC 10 build 2010-08-01 18:00:39 +02:00
Frederic Bouvier
3a09d67f59 MSVC 10 build: Resolve an ambiguity between boost::bind and std::tr1::bind 2010-08-01 18:00:37 +02:00
Frederic Bouvier
ec3ed8fbcd Project file to build and install SimGear alone 2010-08-01 18:00:32 +02:00
Frederic Bouvier
18370ebd08 Update project to use VC100 OSG and Boost 1.42.0 2010-08-01 18:00:30 +02:00
Frederic Bouvier
acbc09b232 MSVC10 build fix 2010-08-01 18:00:27 +02:00
Frederic Bouvier
9d1cf253b4 Compile with MSVC10 2010-08-01 18:00:25 +02:00
Frederic Bouvier
e46304d1ce Add VS2010 project files 2010-08-01 18:00:23 +02:00
James Turner
668c62b1f4 Missed removing a build rule. 2010-07-31 15:33:25 +01:00
James Turner
49f418f146 Remove legacy direct-OpenGL code in simgear/screen (predating switch to OSG). 2010-07-31 15:17:09 +01:00
Erik Hofman
c46c735f2f fix a typo 2010-07-30 10:44:50 +02:00
Erik Hofman
82aa7fcbad use std::string 2010-07-30 10:42:44 +02:00
James Turner
2cfeeb4b13 Merge branch 'topics/remove_point3d' of git@gitorious.org:~zakalawe/fg/james-simgear into topics/remove_point3d 2010-07-30 09:00:35 +01:00
James Turner
aa859c488f Remove deprecated vector classes - finally! 2010-07-30 00:46:30 +01:00
James Turner
1b2915aa2a WIP - removing remaining users of Point3D. 2010-07-29 17:49:37 +01:00
James Turner
e99c3d4705 Collapse SGGeoCoord into SGTimeZone, and switch timezone search to cartesian math. 2010-07-29 10:12:00 +01:00
James Turner
d23491646a Use a custom 'findDataFile' method in key places, and hook this into a callback set on SGModelLib. 2010-07-29 01:05:24 +01:00
Erik Hofman
1d740a63bd C++ify some code 2010-07-27 15:57:36 +02:00
Erik Hofman
d1897fabf0 Small bugfix, the previous test always sets _property (these days) 2010-07-27 14:51:44 +02:00
Erik Hofman
d4178d6440 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-27 10:15:28 +02:00
James Turner
f4d42289d4 More ignore rules for Git. 2010-07-27 00:21:44 +01:00
Erik Hofman
d0def466da Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-25 10:29:25 +02:00
James Turner
959f44502b Fix simgear::Dir::children on Linux where dirent->d_type might be 0; always use stat() to determine file type. Thanks to Alex Romonsan for helping debugging this! 2010-07-24 10:27:50 +01:00
Erik Hofman
1840541f6d Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-23 20:05:40 +02:00
Cutis L. Olson
c5ec6927b3 Add a method to set particle wind using from heading (deg) and speed (kt) 2010-07-23 09:01:49 -05:00
James Turner
7beaf3705e Add closest-point calculation to SGRay, to replace a vector.h helper. 2010-07-23 13:04:09 +01:00
Erik Hofman
792ffa2d26 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-23 13:57:53 +02:00
James Turner
bbd61977f1 Change SGPath::exists to use stat(), fix '.' and '..' handling on Windows, add simgear::Dir version of exists(). 2010-07-23 07:54:10 +01:00
James Turner
e3d1fa2686 Merge branch 'next' of git@gitorious.org:fg/simgear into next 2010-07-23 06:30:37 +01:00
James Turner
293d3b4fb3 Fix Win32 compilation of raw_socket. 2010-07-23 06:30:02 +01:00
James Turner
e1d8155565 Linux build fixes, now netSocket.h is no longer included. 2010-07-22 22:06:02 +01:00
James Turner
c37b27a926 I greatly dislike GNU automake. 2010-07-22 21:27:11 +01:00
James Turner
6b3a05e23f Move PLIB netSocket into SimGear, as simgear::Socket, and update the wrapper classes. 2010-07-22 20:02:37 +01:00
Erik Hofman
0e92bb58b0 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-22 08:57:04 +02:00
James Turner
63cbd4deb0 On Unix, check for symlinks from readdir(), and look through them (using stat()) to discern target type. 2010-07-21 22:08:06 +01:00
Frederic Bouvier
17bcd4e2ab Add a new function alias for MSVC: strcasecmp -> stricmp 2010-07-19 22:36:01 +02:00
Frederic Bouvier
72f301c655 Merge branch 'next' of git://gitorious.org/fg/simgear into fredb/winbuild 2010-07-19 20:02:41 +02:00
Erik Hofman
a62a8518b9 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-16 20:20:28 +02:00
Torsten Dreyer
fa169d6aa2 Merge branch 'next' of gitorious.org:fg/simgear into next 2010-07-16 18:35:55 +02:00
Torsten Dreyer
d2bcb86e1e Warning fix: compare signed/unsigned 2010-07-16 18:34:39 +02:00
Torsten Dreyer
ed7361622b Warning fix: unused variable in TextureBuilder.cxx 2010-07-16 18:19:56 +02:00
James Turner
3117ec5a7d Fix simgear::Dir compilation on some Unix setups, thanks Anders. 2010-07-16 08:40:07 +01:00
James Turner
cb4716f403 Initial work on simgear::Dir, replacement for PLIB ulDir functions. 2010-07-15 09:40:46 +01:00
Erik Hofman
b48c0e968f Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-14 12:19:08 +02:00
James Turner
aa2ed5fb0c Allow tasks to be removed from the EventManager by name. 2010-07-13 13:07:35 +01:00
Erik Hofman
8b7a279c61 Merge branch 'next' of git://gitorious.org/fg/simgear into next 2010-07-09 08:53:56 +02:00
James Turner
b286e9d337 Add two more subsystem groups, to aid in fixing bug 141. 2010-07-08 23:21:25 +01:00
Erik Hofman
d671c3d9fa At some points Flightgear stops and restarts the entire sample group containing the looping background/engine noise. But it does not restart the individual (looping) samples in the group. So now the background noise dies when resetting the sim or changing aircraft location. 2010-06-29 08:28:38 +02:00
Erik Hofman
7086f2dc89 brehmt:
When a sample's state constantly is "changed" (because sth. keeps updating the
sample in each update loop), then SGSampleGroup::update never ever checked if
the sample had already stopped playing by itself.
The attached patch reorders the last two conditions. It now first checks if a
sample has already stopped playing, before checking if there's sth to update.
2010-06-28 08:12:23 +02:00
Frederic Bouvier
7e8bb9ea00 Merge branch 'next' of git://gitorious.org/fg/simgear into fredb/winbuild 2010-06-19 08:14:26 +02:00
Frederic Bouvier
4e46bb6671 Merge branch 'master' of git://gitorious.org/fg/simgear into fredb/winbuild 2010-06-19 08:14:02 +02:00
Tim Moore
de35658096 Merge remote branch 'gitorious/next' into next 2010-06-17 23:46:52 +02:00
Tim Moore
034f5db3bd use an additional shader program map keyed using the resolved shader filenames 2010-06-17 23:45:27 +02:00
James Turner
57375bfd73 Merge commit 'b846e33' into next 2010-06-17 21:40:09 +01:00
James Turner
b846e33ee3 Extend Magvar interface to use SGGeod. 2010-06-17 21:39:10 +01:00
James Turner
cc9b817f0e Extend SGSubsystemGroup, to allow running a fixed dt time, internally 2010-06-16 18:02:41 +01:00
Tim Moore
0d419aba8a Add bool and int uniform types for shaders, and vertex-program-two-sided
vertex-program-two-sided is an extra parameter written by the code
that creates effects from state sets generated by the ac3d loader. The
objective of this work is to support a workaround for broken
gl_FrontFacing on some Macintosh machines.
2010-06-15 19:05:18 +02:00
James Turner
ae22321d9c Automake changes to Hudson 'make check' runs.
Includes moving the OpenAL test programs to 'noinst' so they don't run as part of make check
2010-06-14 12:38:41 +01:00
James Turner
87169febf8 Const-ify some ephemeris accessors, so they can be tied. 2010-06-14 10:23:06 +01:00
James Turner
dd044844e5 Add radial intersection code to SGGeodesy, and test coverage for geocentric helpers. 2010-06-14 10:15:44 +01:00
James Turner
0c8c596ee5 Fix longitude sign convention of geocentric routines
(derived from the Williams aviation formulary, with W longitude +ve)
2010-06-11 18:38:43 +02:00
James Turner
b9496fef1d Merge branch 'topics/condexp' into next 2010-05-27 15:19:38 +01:00
James Turner
b4b9d3a4b7 Support constant true and false values in conditions. 2010-05-27 15:19:04 +01:00
James Turner
0128c89f8d Merge branch 'topics/condexp' into next 2010-05-26 19:29:28 +01:00
James Turner
9e77d06c72 Support <table>s in expression XML. 2010-05-26 19:28:42 +01:00
Torsten Dreyer
25bb1cc957 Cleanup some nonprinting characters make this file work 2010-05-23 21:02:19 +02:00
Torsten Dreyer
2c6f8299f0 typo in gitignore filename 2010-05-23 19:09:00 +02:00
Torsten Dreyer
6a2773c3ac ignore generated files 2010-05-23 10:54:23 +02:00
Torsten Dreyer
1eea917121 ignore generated files 2010-05-23 10:45:01 +02:00
Torsten Dreyer
ea1bbbabfa ignore generated test apps 2010-05-23 10:44:29 +02:00
Torsten Dreyer
399d2bc73c Fix a gcc warning 2010-05-22 23:40:07 +02:00
Torsten Dreyer
0759dbcdc9 Merge branch 'next' of gitorious.org:fg/simgear into next 2010-05-22 23:36:39 +02:00
Torsten Dreyer
1ae0f9c19d New pick animation capability from Alex Perry
Alex Perry: Adds a new pick animation capability which parallels the existing
"action" for a named object.  Specifying "vncaction" and a transform
from model space will enable all mouse clicks on that object to be
delivered directly to the OSG image.  Currently, the readers for VNC
and PDF files yield interactive images; more are likely to be added
over time.
2010-05-22 23:35:01 +02:00
James Turner
e8364a03bc Merge branch 'topics/condexp' into next 2010-05-20 23:57:54 +01:00
James Turner
046d88ab2d Support <expression> children in comparison conditions. Also makes ordering of child nodes match XML consistently. 2010-05-20 23:56:04 +01:00
Mathias Froehlich
f161f78a33 Add a tight and cheap method to represent a rotation.
Adapt tests for that new method.
2010-05-17 23:13:59 +02:00
Erik Hofman
1912444886 revert previous commit, this was a mistake 2010-05-11 11:32:58 +02:00
Erik Hofman
b6ef5a0a3d Before 2010-05-08 11:19:01 +02:00
Frederic Bouvier
401c88adbb Test git commit with a simple change 2010-05-08 00:19:43 +02:00
James Turner
42984d1bfb Make ALUT 1.0 builds again, hopefully in the short term - MinGW needs this. 2010-05-07 00:12:21 +01:00
James Turner
6997082b03 Add .gitignore files, ignore automake/configure artefacts. 2010-05-06 11:25:53 +01:00
James Turner
139217dc79 Configure.as updates for ALUT changes, make --with-alut-framework= work. 2010-05-06 10:27:38 +01:00
Tim Moore
2cc2a857a2 Merge branch 'jmt/ref_ptr-conv' 2010-05-06 10:43:53 +02:00
Tim Moore
7dfb463ba9 Merge branch 'ehofman/framebuffer' 2010-05-06 10:43:45 +02:00
Tim Moore
da07871bc6 Merge branch 'mathias/intersect' 2010-05-06 10:43:27 +02:00
Tim Moore
530d2309e7 Merge branch 'ehofman/sound' 2010-05-06 10:43:12 +02:00
Tim Moore
7e7a5d38f8 Merge branch 'fredb/msvc-cleanup' 2010-05-06 10:42:59 +02:00
Tim Moore
ecf949dee0 Merge branch 'ehofman/model' 2010-05-06 10:42:44 +02:00
246 changed files with 11450 additions and 12175 deletions

View File

@@ -1,19 +1,17 @@
Makefile
Makefile.in
SimGear.spec
aclocal.m4
.deps
autom4te.cache
config.cache
config.guess
config.log
config.status
configure
do-config.sh
.cdtproject
.project
config.guess
config.sub
configure
depcomp
INSTALL
install-sh
missing
mkinstalldirs
aclocal.m4
INSTALL
SimGear.spec
*.o
lib*.a

128
CMakeLists.txt Normal file
View File

@@ -0,0 +1,128 @@
cmake_minimum_required (VERSION 2.6)
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckCXXSourceCompiles)
include (CPack)
project(SimGear)
set(SIMGEAR_VERSION "2.2.0")
#packaging
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
# We have some custom .cmake scripts not in the official distribution.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
option(SIMGEAR_HEADLESS "Set to ON to build SimGear with GUI/graphics support" OFF)
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
set(MSVC_3RDPARTY_DIR NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
if (MSVC_3RDPARTY_DIR)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_DIR}")
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/lib ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/lib )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/include ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/include)
set (BOOST_ROOT ${MSVC_3RDPARTY_DIR}/boost_1_44_0)
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/lib)
endif (MSVC_3RDPARTY_DIR)
find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
if (${SIMGEAR_HEADLESS})
message(STATUS "headlesss mode")
set(NO_OPENSCENEGRAPH_INTERFACE 1)
else()
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(ALUT REQUIRED)
find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
endif()
if(JPEG_FACTORY)
message(STATUS "JPEG-factory enabled")
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
endif()
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(windows.h HAVE_WINDOWS_H)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists(ftime HAVE_FTIME)
check_function_exists(timegm HAVE_TIMEGM)
check_function_exists(rint HAVE_RINT)
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
# isnan might not be real symbol, so can't check using function_exists
check_cxx_source_compiles(
"#include <cmath>
void f() { isnan(0.0);} "
HAVE_ISNAN)
if(CMAKE_COMPILER_IS_GNUCXX)
set(WARNING_FLAGS -Wall)
endif(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
if(MSVC)
# turn off various warnings
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
# endforeach(warning)
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
endif(MSVC)
# assumed on Windows
set(HAVE_GETLOCALTIME 1)
endif(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR}/simgear)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}
${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
add_definitions(-DHAVE_CONFIG_H)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
"${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
)
install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
add_subdirectory(simgear)
#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

View File

@@ -0,0 +1,67 @@
# Locate ALUT
# This module defines
# ALUT_LIBRARY
# ALUT_FOUND, if false, do not try to link to ALUT
# ALUT_INCLUDE_DIR, where to find the headers
#
# $ALUTDIR is an environment variable that would
# correspond to the ./configure --prefix=$ALUTDIR
# used in building ALUT.
#
# Created by James Turner. This was influenced by the FindOpenAL.cmake module.
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
# Per my request, CMake should search for frameworks first in
# the following order:
# ~/Library/Frameworks/OpenAL.framework/Headers
# /Library/Frameworks/OpenAL.framework/Headers
# /System/Library/Frameworks/OpenAL.framework/Headers
#
# On OS X, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# OPENAL_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
FIND_PATH(ALUT_INCLUDE_DIR alut.h
HINTS
$ENV{ALUTDIR}
PATH_SUFFIXES include/AL include/ALUT include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt
)
FIND_LIBRARY(ALUT_LIBRARY
NAMES ALUT alut
HINTS
$ENV{ALUTDIR}
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt
)
SET(ALUT_FOUND "NO")
IF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
SET(ALUT_FOUND "YES")
ENDIF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)

View File

@@ -0,0 +1,23 @@
macro(simgear_component name includePath sources headers)
if (SIMGEAR_SHARED)
foreach(s ${sources})
set_property(GLOBAL
APPEND PROPERTY ALL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
endforeach()
foreach(h ${headers})
set_property(GLOBAL
APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
endforeach()
else()
set(libName "sg${name}")
add_library(${libName} STATIC ${sources} )
install (TARGETS ${libName} ARCHIVE DESTINATION lib${LIB_SUFFIX})
install (FILES ${headers} DESTINATION include/simgear/${includePath})
endif()
endmacro()

View File

@@ -0,0 +1,22 @@
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF()
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"${file}\"")
IF(EXISTS "${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
ENDIF()
ELSE()
MESSAGE(STATUS "File \"${file}\" does not exist.")
ENDIF()
ENDFOREACH()

View File

@@ -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 = 1.9.0
PROJECT_NUMBER = 2.2.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@@ -10,10 +10,6 @@ EXTRA_DIST = \
SUBDIRS = simgear
dist-hook:
(cd $(top_srcdir); $(HOME)/Projects/FlightGear/admin/am2dsp.pl)
rm -rf `find $(distdir)/projects -name CVS`
#
# Rule to build RPM distribution package
#

View File

@@ -8,7 +8,7 @@ dnl Require at least automake 2.52
AC_PREREQ(2.52)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 2.0.0)
AM_INIT_AUTOMAKE(SimGear, 2.2.0)
dnl Specify KAI C++ compiler and flags.
dnl Borrowed with slight modification from blitz distribution.
@@ -24,6 +24,14 @@ AC_ARG_WITH(cxx,
esac
])
AC_ARG_ENABLE(headless,
AS_HELP_STRING([--enable-headless],[Enable only packages for headless build]))
AC_MSG_CHECKING([for headless mode])
AC_MSG_RESULT([$enable_headless])
AM_CONDITIONAL(WANT_HEADLESS,[test "x$enable_headless" = "xyes"])
AC_MSG_CHECKING([CXX])
AC_MSG_RESULT([$CXX])
AC_MSG_CHECKING([CC])
@@ -84,6 +92,10 @@ AC_SUBST(AR)
AC_SUBST(ARFLAGS)
AC_SUBST(compatibility_DIR)
# Show all compiler warnings by default
CXXFLAGS="$CXXFLAGS -Wall"
CFLAGS="$CFLAGS -Wall"
if echo $includedir | egrep "simgear$" > /dev/null; then
echo "includedir is" $includedir "libdir is" $libdir
else
@@ -119,20 +131,6 @@ else
fi
AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
# specify the plib location
AC_ARG_WITH(plib, [ --with-plib=PREFIX Specify the prefix path to plib])
if test "x$with_plib" != "x" ; then
echo "plib prefix is $with_plib"
EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
fi
AC_ARG_WITH(plib_framework, [ --with-plib-framework=PREFIX Specify the prefix path to PLIB.framework ])
if test "x$with_plib_framework" != "x"; then
echo "plib framework prefix is $with_plib_framework"
fi
# specify the osg location
AC_ARG_WITH(osg, [ --with-osg=PREFIX Specify the prefix path to osg])
@@ -141,7 +139,7 @@ if test "x$with_osg" != "x" ; then
EXTRA_DIRS="${EXTRA_DIRS} $with_osg"
fi
AC_ARG_WITH(osg_framework, [ --with-osg-framework=PREFIX Specify the prefix path to OSG.framework ])
AC_ARG_WITH(osg_framework, [ --with-osg-framework=PREFIX Specify the prefix path to OSG.framework ])
if test "x$with_osg_framework" != "x"; then
echo "osg framework prefix is $with_osg_framework"
@@ -149,11 +147,11 @@ if test "x$with_osg_framework" != "x"; then
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:$with_osg_framework"
fi
dnl specifying OpenAL.framework (for user provided OpenAL.framework / ALUT)
AC_ARG_WITH(openal_framework, [ --with-openal-framework=PREFIX Speicfy the prefix path to OpenAL.framework ])
dnl specifying ALUT.framework (for user provided ALUT.framework)
AC_ARG_WITH(alut_framework, [ --with-alut-framework=PREFIX Specify the prefix path to ALUT.framework ])
if test "x$with_openal_framework" != "x"; then
echo "OpenAL framework prefix is $with_openal_framework"
if test "x$with_alut_framework" != "x"; then
echo "ALUT framework prefix is $with_alut_framework"
fi
dnl Determine an extra directories to add to include/lib search paths
@@ -288,9 +286,6 @@ case "${host}" in
esac
AC_SEARCH_LIBS(glutGetModifiers, [ glut glut32 freeglut ], have_glut=yes, have_glut=no)
AM_CONDITIONAL(HAVE_GLUT, test "x$have_glut" = "xyes")
opengl_LIBS="$LIBS"
LIBS="$base_LIBS"
@@ -313,24 +308,21 @@ case "${host}" in
*-apple-darwin*)
dnl Mac OS X
LIBS="$LIBS -framework IOKit -framework OpenAL"
LIBS="$LIBS -framework IOKit -framework OpenAL -framework ALUT"
openal_LIBS="$LIBS"
OPENAL_OK="yes"
ALUT_OK="no"
if test "x$with_openal_lib" != "x"; then
echo "libopenal is not supported on Mac OS platform."
openal_LIBS=""
fi
OPENAL_OK="yes"
# Looking for alut.h, if found assume that it is a part of
# the OpenAL package.
AC_CHECK_HEADERS([OpenAL/alut.h],[ALUT_OK="yes"])
AC_CHECK_HEADERS([OpenAL/al.h],[OPENAL_OK="yes"])
# Looking for alut.h
AC_CHECK_HEADERS([ALUT/alut.h],[ALUT_OK="yes"])
dnl Thank you Christian Bauer from SheepSaver
dnl Modified by Tatsuhiro Nishioka for accepting a given framework path
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH) ; $3 is optional
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH, $4=ACTION_IF_TRUE) ; $3 is optional
AC_DEFUN([AC_CHECK_FRAMEWORK], [
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
AC_CACHE_CHECK([whether compiler supports framework $1],
@@ -342,6 +334,7 @@ case "${host}" in
elif test "`echo $FRAMEWORKS | grep -- -F$3`" = ""; then
FRAMEWORKS="$FRAMEWORKS -F$3"
CXXFLAGS="$CXXFLAGS -F$3"
CPPFLAGS="$CPPFLAGS -F$3"
CCFLAGS="$CCFLAGS -F$3"
dnl This is needed for AC_TRY_LINK when a framework path is specified
export DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}:$3"
@@ -354,13 +347,14 @@ case "${host}" in
AS_IF([test AS_VAR_GET(ac_Framework) = yes],
[AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
)
AS_IF([test AS_VAR_GET(ac_Framework) = yes], $4)
AS_VAR_POPDEF([ac_Framework])dnl
])
dnl Check for OpenAL.framework when --with-openal-framework is specified
dnl Of cource OpenAL.framework needs to have alut.h
if test "x$with_openal_framework" != "x"; then
AC_CHECK_FRAMEWORK(OpenAL, [#include <OpenAL/alut.h>], $with_openal_framework)
dnl Check for ALUT.framework when --with-alut-framework is specified
if test "x$with_alut_framework" != "x"; then
AC_CHECK_FRAMEWORK(ALUT, [#include <ALUT/alut.h>], $with_alut_framework, [ALUT_OK="yes"])
fi
;;
@@ -380,7 +374,7 @@ case "${host}" in
esac
if test "$OPENAL_OK" == "no"; then
if test "$OPENAL_OK" == "no" -a "x$enable_headless" != "xyes"; then
echo
echo "You *must* have the openal library installed on your system to build"
echo "SimGear!"
@@ -391,7 +385,7 @@ if test "$OPENAL_OK" == "no"; then
exit
fi
if test "$ALUT_OK" == "no"; then
if test "$ALUT_OK" == "no" -a "x$enable_headless" != "xyes"; then
echo
echo "You *must* have the alut library installed on your system to build"
echo "SimGear!"
@@ -422,62 +416,6 @@ AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
CXXCPP="g++ -E"
AC_LANG_PUSH(C++)
dnl Check for "plib" without which we cannot go on
case ${host} in
*-apple-darwin*)
# Check PLIB framework availability when with-plib-framework is specified
if test "x$with_plib_framework" != "x"; then
AC_CHECK_FRAMEWORK(PLIB, [#include <plib/ul.h>], $with_plib_framework)
plib_FRAMEWORK="$FRAMEWORKS"
FRAMEWORKS=""
AC_SUBST(plib_FRAMEWORK)
fi
;;
esac
AM_CONDITIONAL(HAVE_FRAMEWORK_PLIB, test "x$ac_cv_framework_PLIB" != "x")
AC_CHECK_HEADER(plib/ul.h)
AC_CHECK_LIB(plibul,ulInit)
if test "x$ac_cv_header_plib_ul_h" != "xyes" \
-o "x$ac_cv_lib_plibul_ulInit" != "xyes" ; then
echo
echo "You *must* have the plib library installed on your system to build"
echo "SimGear!"
echo
echo " LIBS: '$LIBS'"
echo " LDFLAGS: '$LDFLAGS'"
echo " CPPFLAGS: '$CPPFLAGS'"
echo
echo "Please see README.plib for more details."
echo
echo "configure aborted."
exit
fi
AC_MSG_CHECKING([for plib 1.8.5 or newer])
AC_TRY_RUN([
#include <plib/ul.h>
#define MIN_PLIB_VERSION 185
int main() {
if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
return -1;
}
return 0;
}
],
AC_MSG_RESULT(yes),
[AC_MSG_RESULT(wrong version);
AC_MSG_ERROR([Install plib 1.8.5 or later first...])],
AC_MSG_RESULT(yes)
)
LIBS="$saved_LIBS"
# OpenSceneGraph
case "${host}" in
*-apple-darwin*)
@@ -490,7 +428,7 @@ case "${host}" in
# AC_CHECK_FRAMEWORK(osgDB, [#include <osgDB/Version>], $with_osg_framework)
# AC_CHECK_FRAMEWORK(osgSim, [#include <osgSim/Version>], $with_osg_framework)
# AC_CHECK_FRAMEWORK(osgParticle, [#include <osgParticle/Version>], $with_osg_framework)
# AC_CHECK_FRAMEWORK(osg, [#include <osg/Version>], $with_osg_framework)
AC_CHECK_FRAMEWORK(osg, [#include <osg/Version>], $with_osg_framework)
# osg_FRAMEWORKS="$FRAMEWORKS"
# FRAMEWORKS=""
# AC_SUBST(osg_FRAMEWORKS)

5
projects/VC100/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
Win32
x64
*.user
*.sdf
*.suo

View File

@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimGear-install", "SimGear-install.vcxproj", "{1781C058-4D52-43AB-9028-EA0A7730057D}"
ProjectSection(ProjectDependencies) = postProject
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED} = {22540CD3-D3CA-4C86-A773-80AEEE3ACDED}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimGear", "SimGear.vcxproj", "{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1781C058-4D52-43AB-9028-EA0A7730057D}.Debug|Win32.ActiveCfg = Debug|Win32
{1781C058-4D52-43AB-9028-EA0A7730057D}.Debug|Win32.Build.0 = Debug|Win32
{1781C058-4D52-43AB-9028-EA0A7730057D}.Debug|x64.ActiveCfg = Debug|Win32
{1781C058-4D52-43AB-9028-EA0A7730057D}.Release|Win32.ActiveCfg = Release|Win32
{1781C058-4D52-43AB-9028-EA0A7730057D}.Release|Win32.Build.0 = Release|Win32
{1781C058-4D52-43AB-9028-EA0A7730057D}.Release|x64.ActiveCfg = Release|Win32
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug|Win32.ActiveCfg = Debug|Win32
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug|Win32.Build.0 = Debug|Win32
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug|x64.ActiveCfg = Debug|x64
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug|x64.Build.0 = Debug|x64
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release|Win32.ActiveCfg = Release|Win32
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release|Win32.Build.0 = Release|Win32
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release|x64.ActiveCfg = Release|x64
{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1781C058-4D52-43AB-9028-EA0A7730057D}</ProjectGuid>
<RootNamespace>SimGearinstall</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Fichiers sources">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Fichiers d%27en-tête">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Fichiers de ressources">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,607 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}</ProjectGuid>
<RootNamespace>SimGear</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..;..\..\simgear;..\..\..;..\..\..\install\msvc100\OpenSceneGraph\include;..\..\..\3rdparty\include;..\..\..\boost_1_44_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_CONFIG_H;NDEBUG;WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<ProjectReference />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..;..\..\simgear;..\..\..;..\..\..\install\msvc100-64\OpenSceneGraph\include;..\..\..\3rdparty.x64\include;..\..\..\boost_1_44_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_CONFIG_H;NDEBUG;WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..;..\..\simgear;..\..\..;..\..\..\install\msvc100\OpenSceneGraph\include;..\..\..\3rdparty\include;..\..\..\boost_1_44_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_CONFIG_H;_DEBUG;WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..;..\..\simgear;..\..\..;..\..\..\install\msvc100-64\OpenSceneGraph\include;..\..\..\3rdparty.x64\include;..\..\..\boost_1_44_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_CONFIG_H;_DEBUG;WIN32;_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\simgear\bucket\newbucket.cxx" />
<ClCompile Include="..\..\simgear\debug\logstream.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\celestialBody.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\ephemeris.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\jupiter.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\mars.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\mercury.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\moonpos.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\neptune.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\saturn.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\star.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\stardata.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\uranus.cxx" />
<ClCompile Include="..\..\simgear\ephemeris\venus.cxx" />
<ClCompile Include="..\..\simgear\io\iochannel.cxx" />
<ClCompile Include="..\..\simgear\io\lowlevel.cxx" />
<ClCompile Include="..\..\simgear\io\raw_socket.cxx" />
<ClCompile Include="..\..\simgear\io\sg_binobj.cxx" />
<ClCompile Include="..\..\simgear\io\sg_file.cxx" />
<ClCompile Include="..\..\simgear\io\sg_netBuffer.cxx" />
<ClCompile Include="..\..\simgear\io\sg_netChannel.cxx" />
<ClCompile Include="..\..\simgear\io\sg_netChat.cxx" />
<ClCompile Include="..\..\simgear\io\sg_serial.cxx" />
<ClCompile Include="..\..\simgear\io\sg_socket.cxx" />
<ClCompile Include="..\..\simgear\io\sg_socket_udp.cxx" />
<ClCompile Include="..\..\simgear\magvar\coremag.cxx" />
<ClCompile Include="..\..\simgear\magvar\magvar.cxx" />
<ClCompile Include="..\..\simgear\math\interpolater.cxx" />
<ClCompile Include="..\..\simgear\math\leastsqs.cxx" />
<ClCompile Include="..\..\simgear\math\project.cxx" />
<ClCompile Include="..\..\simgear\math\sg_random.c" />
<ClCompile Include="..\..\simgear\math\SGGeod.cxx" />
<ClCompile Include="..\..\simgear\math\SGGeodesy.cxx" />
<ClCompile Include="..\..\simgear\misc\interpolator.cxx" />
<ClCompile Include="..\..\simgear\misc\PathOptions.cxx" />
<ClCompile Include="..\..\simgear\misc\sg_dir.cxx" />
<ClCompile Include="..\..\simgear\misc\sg_path.cxx" />
<ClCompile Include="..\..\simgear\misc\sgstream.cxx" />
<ClCompile Include="..\..\simgear\misc\sg_sleep.cxx" />
<ClCompile Include="..\..\simgear\misc\strutils.cxx" />
<ClCompile Include="..\..\simgear\misc\tabbed_values.cxx" />
<ClCompile Include="..\..\simgear\misc\texcoord.cxx" />
<ClCompile Include="..\..\simgear\misc\zfstream.cxx" />
<ClCompile Include="..\..\simgear\misc\ResourceManager.cxx" />
<ClCompile Include="..\..\simgear\props\propertyObject.cxx" />
<ClCompile Include="..\..\simgear\route\route.cxx" />
<ClCompile Include="..\..\simgear\route\waypoint.cxx" />
<ClCompile Include="..\..\simgear\scene\material\mipmap.cxx" />
<ClCompile Include="..\..\simgear\scene\model\ConditionNode.cxx" />
<ClCompile Include="..\..\simgear\screen\extensions.cxx" />
<ClCompile Include="..\..\simgear\screen\jpgfactory.cxx" />
<ClCompile Include="..\..\simgear\screen\screen-dump.cxx" />
<ClCompile Include="..\..\simgear\screen\tr.cxx" />
<ClCompile Include="..\..\simgear\serial\serial.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\cloud.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\cloudfield.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\CloudShaderGeometry.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\dome.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\moon.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\newcloud.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\oursun.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\sky.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\sphere.cxx" />
<ClCompile Include="..\..\simgear\scene\sky\stars.cxx" />
<ClCompile Include="..\..\simgear\timing\lowleveltime.cxx" />
<ClCompile Include="..\..\simgear\timing\sg_time.cxx" />
<ClCompile Include="..\..\simgear\timing\timestamp.cxx" />
<ClCompile Include="..\..\simgear\timing\timezone.cxx" />
<ClCompile Include="..\..\simgear\xml\easyxml.cxx" />
<ClCompile Include="..\..\simgear\xml\hashtable.c" />
<ClCompile Include="..\..\simgear\xml\xmlparse.c" />
<ClCompile Include="..\..\simgear\xml\xmlrole.c" />
<ClCompile Include="..\..\simgear\xml\xmltok.c" />
<ClCompile Include="..\..\simgear\props\AtomicChangeListener.cxx" />
<ClCompile Include="..\..\simgear\props\condition.cxx" />
<ClCompile Include="..\..\simgear\props\props.cxx" />
<ClCompile Include="..\..\simgear\props\props_io.cxx" />
<ClCompile Include="..\..\simgear\scene\model\animation.cxx" />
<ClCompile Include="..\..\simgear\scene\model\CheckSceneryVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\model\model.cxx" />
<ClCompile Include="..\..\simgear\scene\model\modellib.cxx" />
<ClCompile Include="..\..\simgear\scene\model\ModelRegistry.cxx" />
<ClCompile Include="..\..\simgear\scene\model\particles.cxx" />
<ClCompile Include="..\..\simgear\scene\model\persparam.cxx" />
<ClCompile Include="..\..\simgear\scene\model\placement.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGClipGroup.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGInteractionAnimation.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGMaterialAnimation.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGOffsetTransform.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGPagedLOD.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGReaderWriterXML.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGRotateTransform.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGScaleTransform.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGText.cxx" />
<ClCompile Include="..\..\simgear\scene\model\SGTranslateTransform.cxx" />
<ClCompile Include="..\..\simgear\scene\model\shadanim.cxx" />
<ClCompile Include="..\..\simgear\sound\sample_group.cxx" />
<ClCompile Include="..\..\simgear\sound\sample_openal.cxx" />
<ClCompile Include="..\..\simgear\sound\soundmgr_openal.cxx" />
<ClCompile Include="..\..\simgear\sound\xmlsound.cxx" />
<ClCompile Include="..\..\simgear\scene\material\Effect.cxx" />
<ClCompile Include="..\..\simgear\scene\material\EffectBuilder.cxx" />
<ClCompile Include="..\..\simgear\scene\material\EffectCullVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\material\EffectGeode.cxx" />
<ClCompile Include="..\..\simgear\scene\material\GLPredicate.cxx" />
<ClCompile Include="..\..\simgear\scene\material\makeEffect.cxx" />
<ClCompile Include="..\..\simgear\scene\material\mat.cxx" />
<ClCompile Include="..\..\simgear\scene\material\matlib.cxx" />
<ClCompile Include="..\..\simgear\scene\material\matmodel.cxx" />
<ClCompile Include="..\..\simgear\scene\material\Noise.cxx" />
<ClCompile Include="..\..\simgear\scene\material\Pass.cxx" />
<ClCompile Include="..\..\simgear\scene\material\Technique.cxx" />
<ClCompile Include="..\..\simgear\scene\material\TextureBuilder.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\apt_signs.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\GroundLightManager.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\obj.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\pt_lights.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\ReaderWriterSTG.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\SGOceanTile.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\SGReaderWriterBTG.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\SGVasiDrawable.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\ShaderGeometry.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\TileCache.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\TileEntry.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\TreeBin.cxx" />
<ClCompile Include="..\..\simgear\scene\tgdb\userdata.cxx" />
<ClCompile Include="..\..\simgear\structure\commands.cxx" />
<ClCompile Include="..\..\simgear\structure\event_mgr.cxx" />
<ClCompile Include="..\..\simgear\structure\exception.cxx">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename)1.obj</ObjectFileName>
</ClCompile>
<ClCompile Include="..\..\simgear\structure\SGBinding.cxx" />
<ClCompile Include="..\..\simgear\structure\SGExpression.cxx" />
<ClCompile Include="..\..\simgear\structure\SGSmplhist.cxx" />
<ClCompile Include="..\..\simgear\structure\SGSmplstat.cxx" />
<ClCompile Include="..\..\simgear\structure\subsystem_mgr.cxx" />
<ClCompile Include="..\..\simgear\nasal\bitslib.c" />
<ClCompile Include="..\..\simgear\nasal\code.c" />
<ClCompile Include="..\..\simgear\nasal\codegen.c" />
<ClCompile Include="..\..\simgear\nasal\gc.c" />
<ClCompile Include="..\..\simgear\nasal\hash.c" />
<ClCompile Include="..\..\simgear\nasal\iolib.c" />
<ClCompile Include="..\..\simgear\nasal\lex.c" />
<ClCompile Include="..\..\simgear\nasal\lib.c" />
<ClCompile Include="..\..\simgear\nasal\mathlib.c" />
<ClCompile Include="..\..\simgear\nasal\misc.c" />
<ClCompile Include="..\..\simgear\nasal\parse.c" />
<ClCompile Include="..\..\simgear\nasal\string.c">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MinSpace</Optimization>
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">OnlyExplicitInline</InlineFunctionExpansion>
</ClCompile>
<ClCompile Include="..\..\simgear\nasal\thread-win32.c" />
<ClCompile Include="..\..\simgear\nasal\threadlib.c" />
<ClCompile Include="..\..\simgear\nasal\utf8lib.c" />
<ClCompile Include="..\..\simgear\nasal\vector.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Filename)1.obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename)1.obj</ObjectFileName>
</ClCompile>
<ClCompile Include="..\..\simgear\environment\metar.cxx" />
<ClCompile Include="..\..\simgear\environment\precipitation.cxx" />
<ClCompile Include="..\..\simgear\environment\visual_enviro.cxx" />
<ClCompile Include="..\..\simgear\scene\util\CopyOp.cxx" />
<ClCompile Include="..\..\simgear\scene\util\NodeAndDrawableVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\util\PrimitiveUtils.cxx" />
<ClCompile Include="..\..\simgear\scene\util\QuadTreeBuilder.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SGEnlargeBoundingBox.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SGSceneFeatures.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SGSceneUserData.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SGStateAttributeVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SGTextureStateAttributeVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\util\SplicingVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\util\StateAttributeFactory.cxx" />
<ClCompile Include="..\..\simgear\scene\util\UpdateOnceCallback.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHGroup.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHLineGeometry.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHLineSegmentVisitor.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHMotionTransform.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHNode.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHStaticBinary.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHStaticGeometry.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHStaticLeaf.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHStaticNode.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHStaticTriangle.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHSubTreeCollector.cxx" />
<ClCompile Include="..\..\simgear\scene\bvh\BVHTransform.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\simgear\bucket\newbucket.hxx" />
<ClInclude Include="..\..\simgear\debug\debug_types.h" />
<ClInclude Include="..\..\simgear\debug\logstream.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\celestialBody.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\ephemeris.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\jupiter.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\mars.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\mercury.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\moonpos.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\neptune.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\pluto.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\saturn.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\star.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\stardata.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\uranus.hxx" />
<ClInclude Include="..\..\simgear\ephemeris\venus.hxx" />
<ClInclude Include="..\..\simgear\io\iochannel.hxx" />
<ClInclude Include="..\..\simgear\io\lowlevel.hxx" />
<ClInclude Include="..\..\simgear\io\raw_socket.hxx" />
<ClInclude Include="..\..\simgear\io\sg_binobj.hxx" />
<ClInclude Include="..\..\simgear\io\sg_file.hxx" />
<ClInclude Include="..\..\simgear\io\sg_netBuffer.hxx" />
<ClInclude Include="..\..\simgear\io\sg_netChannel.hxx" />
<ClInclude Include="..\..\simgear\io\sg_netChat.hxx" />
<ClInclude Include="..\..\simgear\io\sg_serial.hxx" />
<ClInclude Include="..\..\simgear\io\sg_socket.hxx" />
<ClInclude Include="..\..\simgear\io\sg_socket_udp.hxx" />
<ClInclude Include="..\..\simgear\magvar\coremag.hxx" />
<ClInclude Include="..\..\simgear\magvar\magvar.hxx" />
<ClInclude Include="..\..\simgear\math\beziercurve.hxx" />
<ClInclude Include="..\..\simgear\math\interpolater.hxx" />
<ClInclude Include="..\..\simgear\math\leastsqs.hxx" />
<ClInclude Include="..\..\simgear\math\linintp2.h" />
<ClInclude Include="..\..\simgear\math\localconsts.hxx" />
<ClInclude Include="..\..\simgear\math\point3d.hxx" />
<ClInclude Include="..\..\simgear\math\polar3d.hxx" />
<ClInclude Include="..\..\simgear\math\project.hxx" />
<ClInclude Include="..\..\simgear\math\sg_geodesy.hxx" />
<ClInclude Include="..\..\simgear\math\sg_random.h" />
<ClInclude Include="..\..\simgear\math\sg_types.hxx" />
<ClInclude Include="..\..\simgear\math\SGGeodesy.hxx" />
<ClInclude Include="..\..\simgear\math\sphrintp.h" />
<ClInclude Include="..\..\simgear\misc\interpolator.hxx" />
<ClInclude Include="..\..\simgear\misc\PathOptions.hxx" />
<ClInclude Include="..\..\simgear\misc\sg_dir.hxx" />
<ClInclude Include="..\..\simgear\misc\sg_path.hxx" />
<ClInclude Include="..\..\simgear\misc\sgstream.hxx" />
<ClInclude Include="..\..\simgear\misc\sg_sleep.hxx" />
<ClInclude Include="..\..\simgear\misc\stopwatch.hxx" />
<ClInclude Include="..\..\simgear\misc\strutils.hxx" />
<ClInclude Include="..\..\simgear\misc\tabbed_values.hxx" />
<ClInclude Include="..\..\simgear\misc\texcoord.hxx" />
<ClInclude Include="..\..\simgear\misc\zfstream.hxx" />
<ClInclude Include="..\..\simgear\misc\ResourceManager.hxx" />
<ClInclude Include="..\..\simgear\props\propertyObject.hxx" />
<ClInclude Include="..\..\simgear\route\route.hxx" />
<ClInclude Include="..\..\simgear\route\waypoint.hxx" />
<ClInclude Include="..\..\simgear\scene\material\mipmap.hxx" />
<ClInclude Include="..\..\simgear\scene\model\ConditionNode.hxx" />
<ClInclude Include="..\..\simgear\screen\colors.hxx" />
<ClInclude Include="..\..\simgear\screen\extensions.hxx" />
<ClInclude Include="..\..\simgear\screen\jpgfactory.hxx" />
<ClInclude Include="..\..\simgear\screen\screen-dump.hxx" />
<ClInclude Include="..\..\simgear\screen\tr.h" />
<ClInclude Include="..\..\simgear\screen\win32-printer.h" />
<ClInclude Include="..\..\simgear\serial\serial.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\cloud.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\cloudfield.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\CloudShaderGeometry.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\dome.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\moon.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\newcloud.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\oursun.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\sky.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\sphere.hxx" />
<ClInclude Include="..\..\simgear\scene\sky\stars.hxx" />
<ClInclude Include="..\..\simgear\timing\lowleveltime.h" />
<ClInclude Include="..\..\simgear\timing\sg_time.hxx" />
<ClInclude Include="..\..\simgear\timing\timestamp.hxx" />
<ClInclude Include="..\..\simgear\timing\timezone.h" />
<ClInclude Include="..\..\simgear\xml\asciitab.h" />
<ClInclude Include="..\..\simgear\xml\easyxml.hxx" />
<ClInclude Include="..\..\simgear\xml\hashtable.h" />
<ClInclude Include="..\..\simgear\xml\iasciitab.h" />
<ClInclude Include="..\..\simgear\xml\latin1tab.h" />
<ClInclude Include="..\..\simgear\xml\nametab.h" />
<ClInclude Include="..\..\simgear\xml\utf8tab.h" />
<ClInclude Include="..\..\simgear\xml\xmldef.h" />
<ClInclude Include="..\..\simgear\xml\xmlparse.h" />
<ClInclude Include="..\..\simgear\xml\xmlrole.h" />
<ClInclude Include="..\..\simgear\xml\xmltok.h" />
<ClInclude Include="..\..\simgear\xml\xmltok_impl.h" />
<ClInclude Include="..\..\simgear\props\AtomicChangeListener.hxx" />
<ClInclude Include="..\..\simgear\props\condition.hxx" />
<ClInclude Include="..\..\simgear\props\ExtendedPropertyAdapter.hxx" />
<ClInclude Include="..\..\simgear\props\props.hxx" />
<ClInclude Include="..\..\simgear\props\props_io.hxx" />
<ClInclude Include="..\..\simgear\scene\model\animation.hxx" />
<ClInclude Include="..\..\simgear\scene\model\CheckSceneryVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\model\model.hxx" />
<ClInclude Include="..\..\simgear\scene\model\modellib.hxx" />
<ClInclude Include="..\..\simgear\scene\model\ModelRegistry.hxx" />
<ClInclude Include="..\..\simgear\scene\model\particles.hxx" />
<ClInclude Include="..\..\simgear\scene\model\persparam.hxx" />
<ClInclude Include="..\..\simgear\scene\model\placement.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGClipGroup.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGInteractionAnimation.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGMaterialAnimation.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGOffsetTransform.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGPagedLOD.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGReaderWriterXML.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGReaderWriterXMLOptions.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGRotateTransform.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGScaleTransform.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGText.hxx" />
<ClInclude Include="..\..\simgear\scene\model\SGTranslateTransform.hxx" />
<ClInclude Include="..\..\simgear\sound\sample_group.hxx" />
<ClInclude Include="..\..\simgear\sound\sample_openal.hxx" />
<ClInclude Include="..\..\simgear\sound\soundmgr_openal.hxx" />
<ClInclude Include="..\..\simgear\sound\xmlsound.hxx" />
<ClInclude Include="..\..\simgear\scene\material\Effect.hxx" />
<ClInclude Include="..\..\simgear\scene\material\EffectBuilder.hxx" />
<ClInclude Include="..\..\simgear\scene\material\EffectCullVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\material\EffectGeode.hxx" />
<ClInclude Include="..\..\simgear\scene\material\GLPredicate.hxx" />
<ClInclude Include="..\..\simgear\scene\material\mat.hxx" />
<ClInclude Include="..\..\simgear\scene\material\matlib.hxx" />
<ClInclude Include="..\..\simgear\scene\material\matmodel.hxx" />
<ClInclude Include="..\..\simgear\scene\material\Noise.hxx" />
<ClInclude Include="..\..\simgear\scene\material\Pass.hxx" />
<ClInclude Include="..\..\simgear\scene\material\Technique.hxx" />
<ClInclude Include="..\..\simgear\scene\material\TextureBuilder.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\apt_signs.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\GroundLightManager.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\obj.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\pt_lights.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\SGModelBin.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\SGOceanTile.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\SGReaderWriterBTG.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\SGReaderWriterBTGOptions.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\SGVasiDrawable.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\ShaderGeometry.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\TileCache.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\TileEntry.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\TreeBin.hxx" />
<ClInclude Include="..\..\simgear\scene\tgdb\userdata.hxx" />
<ClInclude Include="..\..\simgear\threads\SGGuard.hxx" />
<ClInclude Include="..\..\simgear\threads\SGQueue.hxx" />
<ClInclude Include="..\..\simgear\structure\callback.hxx" />
<ClInclude Include="..\..\simgear\structure\commands.hxx" />
<ClInclude Include="..\..\simgear\structure\event_mgr.hxx" />
<ClInclude Include="..\..\simgear\structure\exception.hxx" />
<ClInclude Include="..\..\simgear\structure\OSGVersion.hxx" />
<ClInclude Include="..\..\simgear\structure\SGBinding.hxx" />
<ClInclude Include="..\..\simgear\structure\SGExpression.hxx" />
<ClInclude Include="..\..\simgear\structure\SGReferenced.hxx" />
<ClInclude Include="..\..\simgear\structure\SGSharedPtr.hxx" />
<ClInclude Include="..\..\simgear\structure\SGSmplhist.hxx" />
<ClInclude Include="..\..\simgear\structure\SGSmplstat.hxx" />
<ClInclude Include="..\..\simgear\structure\subsystem_mgr.hxx" />
<ClInclude Include="..\..\simgear\nasal\code.h" />
<ClInclude Include="..\..\simgear\nasal\data.h" />
<ClInclude Include="..\..\simgear\nasal\iolib.h" />
<ClInclude Include="..\..\simgear\nasal\nasal.h" />
<ClInclude Include="..\..\simgear\nasal\parse.h" />
<ClInclude Include="..\..\simgear\environment\metar.hxx" />
<ClInclude Include="..\..\simgear\environment\precipitation.hxx" />
<ClInclude Include="..\..\simgear\environment\visual_enviro.hxx" />
<ClInclude Include="..\..\simgear\scene\util\CopyOp.hxx" />
<ClInclude Include="..\..\simgear\scene\util\NodeAndDrawableVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\util\PrimitiveUtils.hxx" />
<ClInclude Include="..\..\simgear\scene\util\QuadTreeBuilder.hxx" />
<ClInclude Include="..\..\simgear\scene\util\RenderConstants.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGDebugDrawCallback.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGEnlargeBoundingBox.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGNodeMasks.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGSceneFeatures.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGSceneUserData.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGStateAttributeVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGTextureStateAttributeVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SGUpdateVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\util\SplicingVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\util\StateAttributeFactory.hxx" />
<ClInclude Include="..\..\simgear\scene\util\UpdateOnceCallback.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHBoundingBoxVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHDebugCollectVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHGroup.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHLineGeometry.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHLineSegmentVisitor.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHMotionTransform.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHNode.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticBinary.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticData.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticGeometry.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticGeometryBuilder.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticLeaf.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticNode.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHStaticTriangle.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHSubTreeCollector.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHTransform.hxx" />
<ClInclude Include="..\..\simgear\scene\bvh\BVHVisitor.hxx" />
<ClInclude Include="..\..\simgear\compiler.h" />
<ClInclude Include="..\..\simgear\version.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\simgear\math\linintp2.inl" />
<CustomBuild Include="..\..\simgear\simgear_config.h-msvc90">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generation of simgear_config.h</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) %(RootDir)%(Directory)\%(Filename).h
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\simgear\simgear_config.h;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generation of simgear_config.h</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) %(RootDir)%(Directory)\%(Filename).h
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\simgear\simgear_config.h;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Generation of simgear_config.h</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) %(RootDir)%(Directory)\%(Filename).h
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\simgear\simgear_config.h;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generation of simgear_config.h</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) %(RootDir)%(Directory)\%(Filename).h
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\simgear\simgear_config.h;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
SimGear.ncb
SimGear.suo
*.user
Win32
x64

3
projects/VC90/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.user
Win32
x64

File diff suppressed because it is too large Load Diff

View File

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

4
simgear/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
simgear_config.h
simgear_config.h.*
stamp-h1
version.h

57
simgear/CMakeLists.txt Normal file
View File

@@ -0,0 +1,57 @@
file(WRITE ${PROJECT_BINARY_DIR}/simgear/version.h "#define SIMGEAR_VERSION ${SIMGEAR_VERSION}")
foreach( mylibfolder
bucket
debug
ephemeris
io
magvar
math
misc
nasal
props
route
serial
structure
threads
timing
xml
)
add_subdirectory(${mylibfolder})
endforeach( mylibfolder )
if (NOT SIMGEAR_HEADLESS)
add_subdirectory(environment)
add_subdirectory(screen)
add_subdirectory(scene)
add_subdirectory(sound)
endif()
set(HEADERS compiler.h constants.h sg_inlines.h ${PROJECT_BINARY_DIR}/simgear/version.h)
install (FILES ${HEADERS} DESTINATION include/simgear/)
if(SIMGEAR_SHARED)
message(STATUS "building shared library")
get_property(allSources GLOBAL PROPERTY ALL_SOURCES)
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
add_library(SimGear SHARED ${allSources})
set_property(TARGET SimGear PROPERTY FRAMEWORK 1)
message(STATUS "public header: ${publicHeaders}")
set_property(TARGET SimGear PROPERTY PUBLIC_HEADER "${publicHeaders}")
set_property(TARGET SimGear PROPERTY LINKER_LANGUAGE CXX)
target_link_libraries(SimGear ${ZLIB_LIBRARY}
${OPENSCENEGRAPH_LIBRARIES}
${OPENAL_LIBRARY} ${ALUT_LIBRARY}
${OPENGL_LIBRARY})
install(TARGETS SimGear LIBRARY DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include/simgear)
endif(SIMGEAR_SHARED)

View File

@@ -1,13 +1,23 @@
# METAR_DIRS =
METAR_DIRS = environment
EXTRA_DIST = simgear_config.h.vc5 simgear_config.h-msvc71 version.h.in
include_HEADERS = \
compiler.h constants.h sg_inlines.h version.h
SUBDIRS = \
$(compatibility_DIR) \
if WANT_HEADLESS
SG_EXTRA_DIRS =
METAR_DIRS =
else
SG_EXTRA_DIRS = scene sound screen
METAR_DIRS = environment
endif
if HAVE_THREADS
SGTHREAD_DIR = threads
else
SGTHREAD_DIR =
endif
SUBDIRS_ALWAYS = \
xml \
debug \
misc \
@@ -17,15 +27,17 @@ SUBDIRS = \
io \
magvar \
math \
$(METAR_DIRS) \
nasal \
props \
route \
scene \
screen \
serial \
sound \
threads \
timing
DIST_SUBDIRS = $(SUBDIRS) compatibility
SUBDIRS = $(SUBDIRS_ALWAYS) \
$(compatibility_DIR) \
$(METAR_DIRS) \
$(SG_EXTRA_DIRS) \
$(SGTHREAD_DIR)
DIST_SUBDIRS = $(SUBDIRS_ALWAYS) compatibility scene sound screen environment threads

View File

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

View File

@@ -0,0 +1,7 @@
include (SimGearComponent)
set(HEADERS newbucket.hxx)
set(SOURCES newbucket.cxx)
simgear_component(bucket bucket "${SOURCES}" "${HEADERS}")

View File

@@ -92,6 +92,11 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
// cout << "diff = " << diff << " span = " << span << endl;
/* Calculate the greatest integral longitude less than
* or equal to the given longitude (floor(dlon)),
* but attribute coordinates near the east border
* to the next tile.
*/
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
lon = (int)dlon;
} else {
@@ -100,22 +105,48 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
// find subdivision or super lon if needed
if ( span < SG_EPSILON ) {
/* sg_bucket_span() never returns 0.0
* or anything near it, so this really
* should not occur at any time.
*/
// polar cap
lon = 0;
x = 0;
} else if ( span <= 1.0 ) {
/* We have more than one tile per degree of
* longitude, so we need an x offset.
*/
x = (int)((dlon - lon) / span);
} else {
if ( dlon >= 0 ) {
lon = (int)( (int)(lon / span) * span);
} else {
// cout << " lon = " << lon
// << " tmp = " << (int)((lon-1) / span) << endl;
lon = (int)( (int)((lon + 1) / span) * span - span);
if ( lon < -180 ) {
lon = -180;
}
}
/* We have one or more degrees per tile,
* so we need to find the base longitude
* of that tile.
*
* First we calculate the integral base longitude
* (e.g. -85.5 => -86) and then find the greatest
* multiple of span that is less than or equal to
* that longitude.
*
* That way, the Greenwich Meridian is always
* a tile border.
*
* This gets us into trouble with the polar caps,
* which have width 360 and thus either span
* the range from 0 to 360 or from -360 to 0
* degrees, depending on whether lon is positive
* or negative!
*
* We also get into trouble with the 8 degree tiles
* north of 88N and south of 88S, because the west-
* and east-most tiles in that range will cover 184W
* to 176W and 176E to 184E respectively, with their
* center at 180E/W!
*/
lon=(int)floor(floor((lon+SG_EPSILON)/span)*span);
/* Correct the polar cap issue */
if ( lon < -180 ) {
lon = -180;
}
x = 0;
}
@@ -124,11 +155,15 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
//
diff = dlat - (double)(int)dlat;
/* Again, a modified floor() function (see longitude) */
if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) {
lat = (int)dlat;
} else {
lat = (int)dlat - 1;
}
/* Latitude base and offset are easier, as
* tiles always are 1/8 degree of latitude wide.
*/
y = (int)((dlat - lat) * 8);
}
@@ -139,7 +174,7 @@ void SGBucket::set_bucket(const SGGeod& geod)
}
// Build the path name for this bucket
string SGBucket::gen_base_path() const {
std::string SGBucket::gen_base_path() const {
// long int index;
int top_lon, top_lat, main_lon, main_lat;
char hem, pole;
@@ -189,6 +224,17 @@ string SGBucket::gen_base_path() const {
// return width of the tile in degrees
double SGBucket::get_width() const {
if (lon==-180 && (lat==-89 || lat==88) ) {
/* Normally the tile at 180W in 88N and 89S
* would cover 184W to 176W and the next
* on the east side starts at 176W.
* To correct, make this a special tile
* from 180W to 176W with 4 degrees width
* instead of the normal 8 degrees at
* that latitude.
*/
return 4.0;
}
return sg_bucket_span( get_center_lat() );
}
@@ -213,7 +259,7 @@ double SGBucket::get_width_m() const {
double local_perimeter = local_radius * SGD_2PI;
double degree_width = local_perimeter / 360.0;
return sg_bucket_span( get_center_lat() ) * degree_width;
return get_width() * degree_width;
}

View File

@@ -24,6 +24,11 @@
/** \file newbucket.hxx
* A class and associated utiltity functions to manage world scenery tiling.
*
* Tile borders are aligned along circles of latitude and longitude.
* All tiles are 1/8 degree of latitude high and their width in degrees
* longitude depends on their latitude, adjusted in such a way that
* all tiles cover about the same amount of area of the earth surface.
*/
#ifndef _NEWBUCKET_HXX
@@ -211,9 +216,9 @@ public:
double span = sg_bucket_span( lat + y / 8.0 + SG_HALF_BUCKET_SPAN );
if ( span >= 1.0 ) {
return lon + span / 2.0;
return lon + get_width() / 2.0;
} else {
return lon + x * span + span / 2.0;
return lon + x * span + get_width() / 2.0;
}
}
@@ -329,7 +334,7 @@ void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
inline std::ostream&
operator<< ( std::ostream& out, const SGBucket& b )
{
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
return out << b.lon << ":" << (int)b.x << ", " << b.lat << ":" << (int)b.y;
}

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -67,6 +67,10 @@
# define vsnprintf _vsnprintf
# endif
# define copysign _copysign
# define strcasecmp stricmp
# undef min
# undef max
# pragma warning(disable: 4786) // identifier was truncated to '255' characters
# pragma warning(disable: 4244) // conversion from double to float
@@ -105,6 +109,7 @@
#if defined (__sun)
# define SG_UNIX
# include <strings.h>
# include <memory.h>
# if defined ( __cplusplus )
@@ -134,6 +139,8 @@
//
#ifdef __APPLE__
# define SG_MAC
# define SG_UNIX
# ifdef __GNUC__
# if ( __GNUC__ > 3 ) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 3 )
inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
@@ -150,6 +157,8 @@ inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
#endif
#if defined (__FreeBSD__)
# define SG_UNIX
#include <sys/param.h>
# if __FreeBSD_version < 500000
extern "C" {
inline int isnan(double r) { return !(r <= 0 || r >= 0); }
@@ -158,9 +167,19 @@ inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
#endif
#if defined (__CYGWIN__)
# define SG_WINDOWS
# define SG_UNIX
# include <ieeefp.h> // isnan
#endif
// includes both MSVC and mingw compilers
#if defined(_WIN32) || defined(__WIN32__)
# define SG_WINDOWS
#endif
#if defined(__linux__) || defined(_AIX) || defined ( sgi )
# define SG_UNIX
#endif
//
// No user modifiable definitions beyond here.

View File

@@ -34,15 +34,22 @@
#include <cmath>
#include <plib/sg.h>
// Make sure PI is defined in its various forms
// SG_PI and SGD_PI (float and double) come from plib/sg.h
#ifndef SGD_PI // remove me once FlightGear no longer uses PLIB
#ifdef M_PI
const double SGD_PI = M_PI;
const float SG_PI = M_PI;
#else
const float SG_PI = 3.1415926535f;
const double SGD_PI = 3.1415926535;
#endif
#endif // of PLIB-SG guard
/** 2 * PI */
#define SGD_2PI 6.28318530717958647692
const double SGD_2PI = SGD_PI * 2.0;
/** PI / 2 */
#ifdef M_PI_2
@@ -52,7 +59,17 @@
#endif
/** PI / 4 */
#define SGD_PI_4 0.78539816339744830961
const double SGD_PI_4 = 0.78539816339744830961;
#ifndef SGD_DEGREES_TO_RADIANS // // remove me once FlightGear no longer uses PLIB
const double SGD_DEGREES_TO_RADIANS = SGD_PI / 180.0;
const double SGD_RADIANS_TO_DEGREES = 180.0 / SGD_PI;
const float SG_DEGREES_TO_RADIANS = SG_PI / 180.0f;
const float SG_RADIANS_TO_DEGREES = 180.0f / SG_PI;
#endif // of PLIB-SG guard
/** \def SG_E "e" */
#ifdef M_E

View File

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

View File

@@ -0,0 +1,7 @@
include (SimGearComponent)
set(HEADERS debug_types.h logstream.hxx)
set(SOURCES logstream.cxx)
simgear_component(debug debug "${SOURCES}" "${HEADERS}")

View File

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

View File

@@ -0,0 +1,7 @@
include (SimGearComponent)
set(HEADERS metar.hxx visual_enviro.hxx precipitation.hxx)
set(SOURCES metar.cxx visual_enviro.cxx precipitation.cxx)
simgear_component(environment environment "${SOURCES}" "${HEADERS}")

View File

@@ -30,6 +30,7 @@
#include <string>
#include <time.h>
#include <cstring>
#include <simgear/io/sg_socket.hxx>
#include <simgear/debug/logstream.hxx>
@@ -189,11 +190,12 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port,
const int buflen = 512;
char buf[2 * buflen];
string host = proxy.empty() ? "weather.noaa.gov" : proxy;
string metar_server = "weather.noaa.gov";
string host = proxy.empty() ? metar_server : proxy;
string path = "/pub/data/observations/metar/stations/";
path += string(id) + ".TXT";
_url = "http://weather.noaa.gov" + path;
_url = "http://" + metar_server + path;
SGSocket *sock = new SGSocket(host, port.empty() ? "80" : port, "tcp");
sock->set_timeout(10000);
@@ -204,10 +206,11 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port,
string get = "GET ";
if (!proxy.empty())
get += "http://weather.noaa.gov";
get += "http://" + metar_server;
sprintf(buf, "%ld", time);
get += path + " HTTP/1.0\015\012X-Time: " + buf + "\015\012";
get += "Host: " + metar_server + "\015\012";
if (!auth.empty())
get += "Proxy-Authorization: " + auth + "\015\012";
@@ -465,11 +468,13 @@ bool SGMetar::scanVisibility()
int modifier = SGMetarVisibility::EQUALS;
// \d{4}(N|NE|E|SE|S|SW|W|NW)?
if (scanNumber(&m, &i, 4)) {
if (*m == 'E')
if( strncmp( m, "NDV",3 ) == 0 ) {
m+=3; // tolerate NDV (no directional validation)
} else if (*m == 'E') {
m++, dir = 90;
else if (*m == 'W')
} else if (*m == 'W') {
m++, dir = 270;
else if (*m == 'N') {
} else if (*m == 'N') {
m++;
if (*m == 'E')
m++, dir = 45;
@@ -485,7 +490,7 @@ bool SGMetar::scanVisibility()
m++, dir = 225;
else
dir = 180;
}
}
if (i == 0)
i = 50, modifier = SGMetarVisibility::LESS_THAN;
else if (i == 9999)
@@ -612,8 +617,8 @@ bool SGMetar::scanRwyVisRange()
static const struct Token special[] = {
{ "NSW", "no significant weather" },
{ "VCSH", "showers in the vicinity" },
{ "VCTS", "thunderstorm in the vicinity" },
/* { "VCSH", "showers in the vicinity" },
{ "VCTS", "thunderstorm in the vicinity" }, */
{ 0, 0 }
};
@@ -666,6 +671,7 @@ bool SGMetar::scanWeather()
char *m = _m;
string weather;
const struct Token *a;
if ((a = scanToken(&m, special))) {
if (!scanBoundary(&m))
return false;
@@ -675,32 +681,35 @@ bool SGMetar::scanWeather()
}
string pre, post;
int intensity = 0;
struct Weather w;
if (*m == '-')
m++, pre = "light ", intensity = 1;
m++, pre = "light ", w.intensity = LIGHT;
else if (*m == '+')
m++, pre = "heavy ", intensity = 3;
m++, pre = "heavy ", w.intensity = HEAVY;
else if (!strncmp(m, "VC", 2))
m += 2, post = "in the vicinity ";
m += 2, post = "in the vicinity ", w.vincinity=true;
else
pre = "moderate ", intensity = 2;
pre = "moderate ", w.intensity = MODERATE;
int i;
for (i = 0; i < 3; i++) {
if (!(a = scanToken(&m, description)))
break;
w.descriptions.push_back(a->id);
weather += string(a->text) + " ";
}
for (i = 0; i < 3; i++) {
if (!(a = scanToken(&m, phenomenon)))
break;
w.phenomena.push_back(a->id);
weather += string(a->text) + " ";
if (!strcmp(a->id, "RA"))
_rain = intensity;
_rain = w.intensity;
else if (!strcmp(a->id, "HA"))
_hail = intensity;
_hail = w.intensity;
else if (!strcmp(a->id, "SN"))
_snow = intensity;
_snow = w.intensity;
}
if (!weather.length())
return false;
@@ -710,6 +719,8 @@ bool SGMetar::scanWeather()
weather = pre + weather + post;
weather.erase(weather.length() - 1);
_weather.push_back(weather);
if( w.phenomena.size() > 0 )
_weather2.push_back( w );
_grpcount++;
return true;
}
@@ -738,7 +749,7 @@ static const struct Token cloud_types[] = {
{ 0, 0 }
};
#include <iostream>
// (FEW|SCT|BKN|OVC|SKC|CLR|CAVOK|VV)([0-9]{3}|///)?[:cloud_type:]?
bool SGMetar::scanSkyCondition()
{
@@ -756,6 +767,7 @@ bool SGMetar::scanSkyCondition()
if (!strncmp(m, "CLR", i = 3) // clear
|| !strncmp(m, "SKC", i = 3) // sky clear
|| !strncmp(m, "NCD", i = 3) // nil cloud detected
|| !strncmp(m, "NSC", i = 3) // no significant clouds
|| !strncmp(m, "CAVOK", i = 5)) { // ceiling and visibility OK (implies 9999)
m += i;
@@ -763,7 +775,7 @@ bool SGMetar::scanSkyCondition()
return false;
if (i == 3) {
cl._coverage = 0;
cl._coverage = SGMetarCloud::COVERAGE_CLEAR;
_clouds.push_back(cl);
} else {
_cavok = true;
@@ -775,13 +787,13 @@ bool SGMetar::scanSkyCondition()
if (!strncmp(m, "VV", i = 2)) // vertical visibility
;
else if (!strncmp(m, "FEW", i = 3))
cl._coverage = 1;
cl._coverage = SGMetarCloud::COVERAGE_FEW;
else if (!strncmp(m, "SCT", i = 3))
cl._coverage = 2;
cl._coverage = SGMetarCloud::COVERAGE_SCATTERED;
else if (!strncmp(m, "BKN", i = 3))
cl._coverage = 3;
cl._coverage = SGMetarCloud::COVERAGE_BROKEN;
else if (!strncmp(m, "OVC", i = 3))
cl._coverage = 4;
cl._coverage = SGMetarCloud::COVERAGE_OVERCAST;
else
return false;
m += i;
@@ -794,7 +806,7 @@ bool SGMetar::scanSkyCondition()
} else if (!scanNumber(&m, &i, 3))
i = -1;
if (cl._coverage == -1) {
if (cl._coverage == SGMetarCloud::COVERAGE_NIL) {
if (!scanBoundary(&m))
return false;
if (i == -1) // 'VV///'
@@ -1194,13 +1206,29 @@ const struct Token *SGMetar::scanToken(char **str, const struct Token *list)
}
void SGMetarCloud::set(double alt, int cov)
void SGMetarCloud::set(double alt, Coverage cov)
{
_altitude = alt;
if (cov != -1)
_coverage = cov;
}
SGMetarCloud::Coverage SGMetarCloud::getCoverage( const std::string & coverage )
{
if( coverage == "clear" ) return COVERAGE_CLEAR;
if( coverage == "few" ) return COVERAGE_FEW;
if( coverage == "scattered" ) return COVERAGE_SCATTERED;
if( coverage == "broken" ) return COVERAGE_BROKEN;
if( coverage == "overcast" ) return COVERAGE_OVERCAST;
return COVERAGE_NIL;
}
const char * SGMetarCloud::COVERAGE_NIL_STRING = "nil";
const char * SGMetarCloud::COVERAGE_CLEAR_STRING = "clear";
const char * SGMetarCloud::COVERAGE_FEW_STRING = "few";
const char * SGMetarCloud::COVERAGE_SCATTERED_STRING = "scattered";
const char * SGMetarCloud::COVERAGE_BROKEN_STRING = "broken";
const char * SGMetarCloud::COVERAGE_OVERCAST_STRING = "overcast";
void SGMetarVisibility::set(double dist, int dir, int mod, int tend)
{

View File

@@ -130,18 +130,35 @@ protected:
class SGMetarCloud {
friend class SGMetar;
public:
SGMetarCloud() : _coverage(-1), _altitude(NaN), _type(0), _type_long(0) {}
enum Coverage {
COVERAGE_NIL = -1,
COVERAGE_CLEAR = 0,
COVERAGE_FEW = 1,
COVERAGE_SCATTERED = 2,
COVERAGE_BROKEN = 3,
COVERAGE_OVERCAST = 4
};
void set(double alt, int cov = -1);
static const char * COVERAGE_NIL_STRING;
static const char * COVERAGE_CLEAR_STRING;
static const char * COVERAGE_FEW_STRING;
static const char * COVERAGE_SCATTERED_STRING;
static const char * COVERAGE_BROKEN_STRING;
static const char * COVERAGE_OVERCAST_STRING;
inline int getCoverage() const { return _coverage; }
SGMetarCloud() : _coverage(COVERAGE_NIL), _altitude(NaN), _type(0), _type_long(0) {}
void set(double alt, Coverage cov = COVERAGE_NIL );
inline Coverage getCoverage() const { return _coverage; }
static Coverage getCoverage( const std::string & coverage );
inline double getAltitude_m() const { return _altitude; }
inline double getAltitude_ft() const { return _altitude == NaN ? NaN : _altitude * SG_METER_TO_FEET; }
inline const char *getTypeString() const { return _type; }
inline const char *getTypeLongString() const { return _type_long; }
protected:
int _coverage; // quarters: 0 -> clear ... 4 -> overcast
Coverage _coverage; // quarters: 0 -> clear ... 4 -> overcast
double _altitude; // 1000 m
const char *_type; // CU
const char *_type_long; // cumulus
@@ -161,6 +178,21 @@ public:
RTD
};
enum Intensity {
NIL = 0,
LIGHT = 1,
MODERATE = 2,
HEAVY = 3
};
struct Weather {
Weather() { intensity = NIL; vincinity = false; }
Intensity intensity;
bool vincinity;
vector<string> descriptions;
vector<string> phenomena;
};
inline const char *getData() const { return _data; }
inline const char *getUnusedData() const { return _m; }
inline const bool getProxy() const { return _x_proxy; }
@@ -208,6 +240,7 @@ public:
inline const vector<SGMetarCloud>& getClouds() const { return _clouds; }
inline const map<string, SGMetarRunway>& getRunways() const { return _runways; }
inline const vector<string>& getWeather() const { return _weather; }
inline const vector<struct Weather> getWeather2() const { return _weather2; }
protected:
string _url;
@@ -234,6 +267,7 @@ protected:
int _hail;
int _snow;
bool _cavok;
vector<struct Weather> _weather2;
SGMetarVisibility _min_visibility;
SGMetarVisibility _max_visibility;

View File

@@ -28,8 +28,6 @@
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/sound/sample_group.hxx>
#include <simgear/scene/sky/cloudfield.hxx>
#include <simgear/scene/sky/newcloud.hxx>
@@ -42,7 +40,7 @@ using std::vector;
typedef struct {
Point3D pt;
SGVec3d pt;
int depth;
int prev;
} lt_tree_seg;
@@ -52,23 +50,23 @@ static float rainpos[MAX_RAIN_SLICE];
#define MAX_LT_TREE_SEG 400
#define DFL_MIN_LIGHT 0.35
sgVec3 SGEnviro::min_light = {DFL_MIN_LIGHT, DFL_MIN_LIGHT, DFL_MIN_LIGHT};
SGVec3f SGEnviro::min_light(DFL_MIN_LIGHT, DFL_MIN_LIGHT, DFL_MIN_LIGHT);
#define DFL_STREAK_BRIGHT_NEARMOST_LAYER 0.9
SGfloat SGEnviro::streak_bright_nearmost_layer = DFL_STREAK_BRIGHT_NEARMOST_LAYER;
float SGEnviro::streak_bright_nearmost_layer = DFL_STREAK_BRIGHT_NEARMOST_LAYER;
#define DFL_STREAK_BRIGHT_FARMOST_LAYER 0.5
SGfloat SGEnviro::streak_bright_farmost_layer = DFL_STREAK_BRIGHT_FARMOST_LAYER;
float SGEnviro::streak_bright_farmost_layer = DFL_STREAK_BRIGHT_FARMOST_LAYER;
#define DFL_STREAK_PERIOD_MAX 2.5
SGfloat SGEnviro::streak_period_max = DFL_STREAK_PERIOD_MAX;
float SGEnviro::streak_period_max = DFL_STREAK_PERIOD_MAX;
#define DFL_STREAK_PERIOD_CHANGE_PER_KT 0.005
SGfloat SGEnviro::streak_period_change_per_kt = DFL_STREAK_PERIOD_CHANGE_PER_KT;
float SGEnviro::streak_period_change_per_kt = DFL_STREAK_PERIOD_CHANGE_PER_KT;
#define DFL_STREAK_PERIOD_MIN 1.0
SGfloat SGEnviro::streak_period_min = DFL_STREAK_PERIOD_MIN;
float SGEnviro::streak_period_min = DFL_STREAK_PERIOD_MIN;
#define DFL_STREAK_LENGTH_MIN 0.03
SGfloat SGEnviro::streak_length_min = DFL_STREAK_LENGTH_MIN;
float SGEnviro::streak_length_min = DFL_STREAK_LENGTH_MIN;
#define DFL_STREAK_LENGTH_CHANGE_PER_KT 0.0005
SGfloat SGEnviro::streak_length_change_per_kt = DFL_STREAK_LENGTH_CHANGE_PER_KT;
float SGEnviro::streak_length_change_per_kt = DFL_STREAK_LENGTH_CHANGE_PER_KT;
#define DFL_STREAK_LENGTH_MAX 0.1
SGfloat SGEnviro::streak_length_max = DFL_STREAK_LENGTH_MAX;
float SGEnviro::streak_length_max = DFL_STREAK_LENGTH_MAX;
#define DFL_STREAK_COUNT_MIN 40
int SGEnviro::streak_count_min = DFL_STREAK_COUNT_MIN;
#define DFL_STREAK_COUNT_MAX 190
@@ -77,9 +75,9 @@ int SGEnviro::streak_count_min = DFL_STREAK_COUNT_MIN;
#endif
int SGEnviro::streak_count_max = DFL_STREAK_COUNT_MAX;
#define DFL_CONE_BASE_RADIUS 15.0
SGfloat SGEnviro::cone_base_radius = DFL_CONE_BASE_RADIUS;
float SGEnviro::cone_base_radius = DFL_CONE_BASE_RADIUS;
#define DFL_CONE_HEIGHT 30.0
SGfloat SGEnviro::cone_height = DFL_CONE_HEIGHT;
float SGEnviro::cone_height = DFL_CONE_HEIGHT;
void SGEnviro::config(const SGPropertyNode* n)
@@ -88,7 +86,7 @@ void SGEnviro::config(const SGPropertyNode* n)
return;
const float ml = n->getFloatValue("min-light", DFL_MIN_LIGHT);
sgSetVec3(min_light, ml, ml, ml);
min_light = SGVec3f(ml, ml, ml);
streak_bright_nearmost_layer = n->getFloatValue(
"streak-brightness-nearmost-layer",
@@ -146,7 +144,7 @@ public:
~SGLightning();
void lt_Render(void);
void lt_build(void);
void lt_build_tree_branch(int tree_nr, Point3D &start, float energy, int nbseg, float segsize);
void lt_build_tree_branch(int tree_nr, SGVec3d &start, float energy, int nbseg, float segsize);
// contains all the segments of the lightning
lt_tree_seg lt_tree[MAX_LT_TREE_SEG];
@@ -200,7 +198,7 @@ SGEnviro::~SGEnviro(void) {
lightnings.clear();
}
void SGEnviro::startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time) {
void SGEnviro::startOfFrame( SGVec3f p, SGVec3f up, double lon, double lat, double alt, double delta_time) {
// OSGFIXME
return;
view_in_cloud = false;
@@ -210,7 +208,7 @@ void SGEnviro::startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double
elapsed_time += delta_time;
min_time_before_lt -= delta_time;
dt = delta_time;
#if 0
sgMat4 T1, LON, LAT;
sgVec3 axis;
@@ -232,6 +230,7 @@ void SGEnviro::startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double
sgSetCoord( &pos, TRANSFORM );
sgMakeCoordMat4( transform, &pos );
#endif
last_lon = lon;
last_lat = lat;
last_alt = alt;
@@ -289,10 +288,10 @@ void SGEnviro::set_lightning_enable_state(bool enable) {
}
}
void SGEnviro::setLight(sgVec4 adj_fog_color) {
void SGEnviro::setLight(SGVec4f adj_fog_color) {
// OSGFIXME
return;
sgCopyVec4( fog_color, adj_fog_color );
fog_color = adj_fog_color;
if( false ) {
// ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, l->scene_diffuse() );
}
@@ -381,7 +380,7 @@ void SGEnviro::callback_cloud(float heading, float alt, float radius, int family
if(lightning_enable_state && min_time_before_lt <= 0.0 && (family == SGNewCloud::CLFamilly_cb) &&
dist < 15000.0 * 15000.0 && sg_random() > 0.9f) {
double lat, lon;
Point3D orig, dest;
SGVec3d orig, dest;
orig.setlat(last_lat * SG_DEGREES_TO_RADIANS );
orig.setlon(last_lon * SG_DEGREES_TO_RADIANS );
orig.setelev(0.0);
@@ -418,118 +417,11 @@ list_of_SGWxRadarEcho *SGEnviro::get_radar_echo(void) {
void SGEnviro::DrawCone2(float baseRadius, float height, int slices, bool down, double rain_norm, double speed) {
// OSGFIXME
return;
sgVec3 light;
sgAddVec3( light, fog_color, min_light );
float da = SG_PI * 2.0f / (float) slices;
// low number = faster
float speedf = streak_period_max - speed * streak_period_change_per_kt;
if( speedf < streak_period_min )
speedf = streak_period_min;
float lenf = streak_length_min + speed * streak_length_change_per_kt;
if( lenf > streak_length_max )
lenf = streak_length_max;
float t = fmod((float) elapsed_time, speedf) / speedf;
// t = 0.1f;
if( !down )
t = 1.0f - t;
float angle = 0.0f;
//glColor4f(1.0f, 0.7f, 0.7f, 0.9f); // XXX unneeded? overriden below
glBegin(GL_LINES);
if (slices > MAX_RAIN_SLICE)
slices = MAX_RAIN_SLICE; // should never happen
for( int i = 0 ; i < slices ; i++ ) {
float x = cos(angle) * baseRadius;
float y = sin(angle) * baseRadius;
angle += da;
sgVec3 dir = {x, -height, y};
// rain drops at 2 different speed to simulate depth
float t1 = (i & 1 ? t : t + t) + rainpos[i];
if(t1 > 1.0f) t1 -= 1.0f;
if(t1 > 1.0f) t1 -= 1.0f;
// distant raindrops are more transparent
float c = t1 * (i & 1 ?
streak_bright_farmost_layer
: streak_bright_nearmost_layer);
glColor4f(c * light[0], c * light[1], c * light[2], c);
sgVec3 p1, p2;
sgScaleVec3(p1, dir, t1);
// distant raindrops are shorter
float t2 = t1 + (i & 1 ? lenf : lenf+lenf);
sgScaleVec3(p2, dir, t2);
glVertex3f(p1[0], p1[1] + height, p1[2]);
glVertex3f(p2[0], p2[1] + height, p2[2]);
}
glEnd();
}
void SGEnviro::drawRain(double pitch, double roll, double heading, double hspeed, double rain_norm) {
// OSGFIXME
return;
#if 0
static int debug_period = 0;
if (debug_period++ == 50) {
debug_period = 0;
cout << "drawRain("
<< pitch << ", "
<< roll << ", "
<< heading << ", "
<< hspeed << ", "
<< rain_norm << ");"
//" angle = " << angle
//<< " raindrop(KTS) = " << raindrop_speed_kts
<< endl;
}
#endif
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
glDisable( GL_FOG );
glDisable(GL_LIGHTING);
int slice_count = static_cast<int>(
(streak_count_min + rain_norm*(streak_count_max-streak_count_min))
* precipitation_density / 100.0);
// www.wonderquest.com/falling-raindrops.htm says that
// Raindrop terminal velocity is 5 to 20mph
// Rather than model it accurately (temp, pressure, diameter), and make it
// smaller than terminal when closer to the precipitation cloud base,
// we interpolate in the 5-20mph range according to rain_norm.
double raindrop_speed_kts
= (5.0 + rain_norm*15.0) * SG_MPH_TO_MPS * SG_MPS_TO_KT;
float angle = atanf(hspeed / raindrop_speed_kts) * SG_RADIANS_TO_DEGREES;
glPushMatrix();
// the cone rotate with hspeed
angle = -pitch - angle;
glRotatef(roll, 0.0, 0.0, 1.0);
glRotatef(heading, 0.0, 1.0, 0.0);
glRotatef(angle, 1.0, 0.0, 0.0);
// up cone
DrawCone2(cone_base_radius, cone_height,
slice_count, true, rain_norm, hspeed);
// down cone (usually not visible)
if(angle > 0.0 || heading != 0.0)
DrawCone2(cone_base_radius, -cone_height,
slice_count, false, rain_norm, hspeed);
glPopMatrix();
glEnable(GL_LIGHTING);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glEnable( GL_FOG );
glEnable(GL_DEPTH_TEST);
}
void SGEnviro::set_sampleGroup(SGSampleGroup *sgr) {
@@ -560,169 +452,20 @@ SGLightning::~SGLightning() {
}
// lightning rendering code
void SGLightning::lt_build_tree_branch(int tree_nr, Point3D &start, float energy, int nbseg, float segsize) {
void SGLightning::lt_build_tree_branch(int tree_nr, SGVec3d &start, float energy, int nbseg, float segsize) {
// OSGFIXME
return;
sgVec3 dir, newdir;
int nseg = 0;
Point3D pt = start;
if( nbseg == 50 )
sgSetVec3( dir, 0.0, -1.0, 0.0 );
else {
sgSetVec3( dir, sg_random() - 0.5f, sg_random() - 0.5f, sg_random() - 0.5f);
sgNormaliseVec3(dir);
}
if( nb_tree >= MAX_LT_TREE_SEG )
return;
lt_tree[nb_tree].depth = tree_nr;
nseg = 0;
lt_tree[nb_tree].pt = pt;
lt_tree[nb_tree].prev = -1;
nb_tree ++;
// TODO:check agl
while(nseg < nbseg && pt.y() > 0.0) {
int prev = nb_tree - 1;
nseg++;
// add a branch
if( energy * sg_random() > 0.8f )
lt_build_tree_branch(tree_nr + 1, pt, energy * 0.9f, nbseg == 50 ? 10 : static_cast<int>(nbseg * 0.4f), segsize * 0.7f);
if( nb_tree >= MAX_LT_TREE_SEG )
return;
sgSetVec3(newdir, (sg_random() - 0.5f), (sg_random() - 0.5f) - (nbseg == 50 ? 0.5f : 0.0), (sg_random() - 0.5f));
sgNormaliseVec3(newdir);
sgAddVec3( dir, newdir);
sgNormaliseVec3(dir);
sgVec3 scaleDir;
sgScaleVec3( scaleDir, dir, segsize * energy * 0.5f );
pt[PX] += scaleDir[0];
pt[PY] += scaleDir[1];
pt[PZ] += scaleDir[2];
lt_tree[nb_tree].depth = tree_nr;
lt_tree[nb_tree].pt = pt;
lt_tree[nb_tree].prev = prev;
nb_tree ++;
}
}
void SGLightning::lt_build(void) {
// OSGFIXME
return;
Point3D top;
nb_tree = 0;
top[PX] = 0 ;
top[PY] = alt;
top[PZ] = 0;
lt_build_tree_branch(0, top, 1.0, 50, top[PY] / 8.0);
if( ! sgEnviro.sampleGroup )
return;
Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
Point3D dest( lon*SG_DEGREES_TO_RADIANS, lat*SG_DEGREES_TO_RADIANS, 0.0 );
double course = 0.0, dist = 0.0;
calc_gc_course_dist( dest, start, &course, &dist );
if( dist < 10000.0 && ! sgEnviro.snd_playing && (dist < sgEnviro.snd_dist || ! sgEnviro.snd_active) ) {
sgEnviro.snd_timer = 0.0;
sgEnviro.snd_wait = dist / 340;
sgEnviro.snd_dist = dist;
sgEnviro.snd_pos_lat = lat;
sgEnviro.snd_pos_lon = lon;
sgEnviro.snd_active = true;
sgEnviro.snd_playing = false;
}
}
void SGLightning::lt_Render(void) {
// OSGFIXME
return;
float flash = 0.5;
if( fmod(sgEnviro.elapsed_time*100.0, 100.0) > 50.0 )
flash = sg_random() * 0.75f + 0.25f;
float h = lt_tree[0].pt[PY];
sgVec4 col={0.62f, 0.83f, 1.0f, 1.0f};
sgVec4 c;
#define DRAW_SEG() \
{glColorMaterial(GL_FRONT, GL_EMISSION); \
glDisable(GL_LINE_SMOOTH); glBegin(GL_LINES); \
glColor4fv(c); \
glVertex3f(lt_tree[n].pt[PX], lt_tree[n].pt[PZ], lt_tree[n].pt[PY]); \
glVertex3f(lt_tree[lt_tree[n].prev].pt[PX], lt_tree[lt_tree[n].prev].pt[PZ], lt_tree[lt_tree[n].prev].pt[PY]); \
glEnd(); glEnable(GL_LINE_SMOOTH);}
glDepthMask( GL_FALSE );
glEnable(GL_BLEND);
glBlendFunc( GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_LIGHTING);
glDisable( GL_FOG );
glPushMatrix();
sgMat4 modelview, tmp;
// OSGFIXME
// ssgGetModelviewMatrix( modelview );
sgCopyMat4( tmp, sgEnviro.transform );
sgPostMultMat4( tmp, modelview );
// OSGFIXME
// ssgLoadModelviewMatrix( tmp );
Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
Point3D dest( lon*SG_DEGREES_TO_RADIANS, lat*SG_DEGREES_TO_RADIANS, 0.0 );
double course = 0.0, dist = 0.0;
calc_gc_course_dist( dest, start, &course, &dist );
double ax = 0.0, ay = 0.0;
ax = cos(course) * dist;
ay = sin(course) * dist;
glTranslatef( ax, ay, -sgEnviro.last_alt );
sgEnviro.radarEcho.push_back( SGWxRadarEcho ( course, 0.0, 0.0, dist, age, true, 0 ) );
for( int n = 0 ; n < nb_tree ; n++ ) {
if( lt_tree[n].prev < 0 )
continue;
float t1 = sgLerp(0.5, 1.0, lt_tree[n].pt[PY] / h);
t1 *= flash;
if( lt_tree[n].depth >= 2 ) {
glLineWidth(3);
sgScaleVec4(c, col, t1 * 0.6f);
DRAW_SEG();
} else {
if( lt_tree[n].depth == 0 ) {
glLineWidth(12);
sgScaleVec4(c, col, t1 * 0.5f);
DRAW_SEG();
glLineWidth(6);
sgScaleVec4(c, col, t1);
DRAW_SEG();
} else {
glLineWidth(6);
sgScaleVec4(c, col, t1 * 0.7f);
DRAW_SEG();
}
if( lt_tree[n].depth == 0 )
glLineWidth(3);
else
glLineWidth(2);
sgSetVec4(c, t1, t1, t1, t1);
DRAW_SEG();
}
}
glLineWidth(1);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glPopMatrix();
glDepthMask( GL_TRUE );
glEnable( GL_FOG );
glEnable(GL_LIGHTING);
}
void SGEnviro::addLightning(double lon, double lat, double alt) {
@@ -737,53 +480,6 @@ void SGEnviro::addLightning(double lon, double lat, double alt) {
void SGEnviro::drawLightning(void) {
// OSGFIXME
return;
list_of_lightning::iterator iLightning;
// play 'thunder' for lightning
if( snd_active ) {
if( !snd_playing ) {
// wait until sound has reached us
snd_timer += dt;
if( snd_timer >= snd_wait ) {
snd_playing = true;
// compute relative position of lightning
Point3D start( sgEnviro.last_lon*SG_DEGREES_TO_RADIANS, sgEnviro.last_lat*SG_DEGREES_TO_RADIANS, 0.0 );
Point3D dest( snd_pos_lon*SG_DEGREES_TO_RADIANS, snd_pos_lat*SG_DEGREES_TO_RADIANS, 0.0 );
double course = 0.0, dist = 0.0;
calc_gc_course_dist( dest, start, &course, &dist );
double ax = 0.0, ay = 0.0;
ax = cos(course) * dist;
ay = sin(course) * dist;
SGSharedPtr<SGSoundSample> snd = sampleGroup->find("thunder");
if( snd ) {
SGVec3d pos = SGVec3d(ax, ay, -sgEnviro.last_alt);
snd->set_position(pos);
snd->play_once();
}
}
} else {
if( !sampleGroup->is_playing("thunder") ) {
snd_active = false;
snd_playing = false;
}
}
}
if( ! lightning_enable_state )
return;
for( iLightning = lightnings.begin() ; iLightning != lightnings.end() ; iLightning++ ) {
if( dt )
if( sg_random() > 0.95f )
(*iLightning)->lt_build();
(*iLightning)->lt_Render();
(*iLightning)->age -= dt;
if( (*iLightning)->age < 0.0 ) {
delete (*iLightning);
lightnings.erase( iLightning );
break;
}
}
}

View File

@@ -22,14 +22,11 @@
#ifndef _VISUAL_ENVIRO_HXX
#define _VISUAL_ENVIRO_HXX
#include <plib/sg.h>
#include <simgear/compiler.h>
#include <string>
#include <vector>
using std::vector;
using std::string;
#include <simgear/math/SGMath.hxx>
class SGLightning;
class SGSampleGroup;
@@ -62,7 +59,7 @@ public:
int cloudId;
};
typedef vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
typedef std::vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
/**
* Visual environment helper class.
@@ -81,8 +78,8 @@ private:
double last_cloud_turbulence, cloud_turbulence;
bool lightning_enable_state;
double elapsed_time, dt;
sgVec4 fog_color;
sgMat4 transform;
SGVec4f fog_color;
SGMatrixf transform;
double last_lon, last_lat, last_alt;
SGSampleGroup *sampleGroup;
bool snd_active, snd_playing;
@@ -93,8 +90,8 @@ private:
/** a list of all the radar echo. */
list_of_SGWxRadarEcho radarEcho;
static sgVec3 min_light;
static SGfloat streak_bright_nearmost_layer,
static SGVec3f min_light;
static float streak_bright_nearmost_layer,
streak_bright_farmost_layer,
streak_period_max,
streak_period_change_per_kt,
@@ -103,7 +100,7 @@ private:
streak_length_change_per_kt,
streak_length_max;
static int streak_count_min, streak_count_max;
static SGfloat cone_base_radius,
static float cone_base_radius,
cone_height;
public:
@@ -121,7 +118,7 @@ public:
/**
* Forward a few states used for renderings.
*/
void startOfFrame( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double delta_time);
void startOfFrame( SGVec3f p, SGVec3f up, double lon, double lat, double alt, double delta_time);
void endOfFrame(void);
@@ -158,7 +155,7 @@ public:
* Forward the fog color used by the rain rendering.
* @param adj_fog_color color of the fog
*/
void setLight(sgVec4 adj_fog_color);
void setLight(SGVec4f adj_fog_color);
// this can be queried to add some turbulence for example
bool is_view_in_cloud(void) const;
@@ -250,7 +247,7 @@ public:
list_of_SGWxRadarEcho *get_radar_echo(void);
sgMat4 *get_transform(void) { return &transform; }
SGMatrixf *get_transform(void) { return &transform; }
};
extern SGEnviro sgEnviro;

View File

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

View File

@@ -0,0 +1,35 @@
include (SimGearComponent)
set(HEADERS
celestialBody.hxx
ephemeris.hxx
jupiter.hxx
mars.hxx
mercury.hxx
moonpos.hxx
neptune.hxx
pluto.hxx
saturn.hxx
star.hxx
stardata.hxx
uranus.hxx
venus.hxx
)
set(SOURCES
celestialBody.cxx
ephemeris.cxx
jupiter.cxx
mars.cxx
mercury.cxx
moonpos.cxx
neptune.cxx
saturn.cxx
star.cxx
stardata.cxx
uranus.cxx
venus.cxx
)
simgear_component(ephemeris ephemeris "${SOURCES}" "${HEADERS}")

View File

@@ -81,8 +81,8 @@ public:
double getRightAscension();
double getDeclination();
double getMagnitude();
double getLon();
double getLat();
double getLon() const;
double getLat() const;
void updatePosition(double mjd, Star *ourSun);
};
@@ -90,12 +90,12 @@ inline double CelestialBody::getRightAscension() { return rightAscension; }
inline double CelestialBody::getDeclination() { return declination; }
inline double CelestialBody::getMagnitude() { return magnitude; }
inline double CelestialBody::getLon()
inline double CelestialBody::getLon() const
{
return lonEcl;
}
inline double CelestialBody::getLat()
inline double CelestialBody::getLat() const
{
return latEcl;
}

View File

@@ -43,47 +43,47 @@ public:
Star ();
~Star();
void updatePosition(double mjd);
double getM();
double getw();
double getxs();
double getys();
double getye();
double getze();
double getDistance();
double getM() const;
double getw() const;
double getxs() const;
double getys() const;
double getye() const;
double getze() const;
double getDistance() const;
};
inline double Star::getM()
inline double Star::getM() const
{
return M;
}
inline double Star::getw()
inline double Star::getw() const
{
return w;
}
inline double Star::getxs()
inline double Star::getxs() const
{
return xs;
}
inline double Star::getys()
inline double Star::getys() const
{
return ys;
}
inline double Star::getye()
inline double Star::getye() const
{
return ye;
}
inline double Star::getze()
inline double Star::getze() const
{
return ze;
}
inline double Star::getDistance()
inline double Star::getDistance() const
{
return distance;
}

View File

@@ -34,6 +34,8 @@
using std::getline;
#endif
using std::string;
// Constructor
SGStarData::SGStarData( const SGPath& path )
{

View File

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

33
simgear/io/CMakeLists.txt Normal file
View File

@@ -0,0 +1,33 @@
include (SimGearComponent)
set(HEADERS
iochannel.hxx
lowlevel.hxx
raw_socket.hxx
sg_binobj.hxx
sg_file.hxx
sg_netBuffer.hxx
sg_netChannel.hxx
sg_netChat.hxx
sg_serial.hxx
sg_socket.hxx
sg_socket_udp.hxx
)
set(SOURCES
iochannel.cxx
lowlevel.cxx
raw_socket.cxx
sg_binobj.cxx
sg_file.cxx
sg_netBuffer.cxx
sg_netChannel.cxx
sg_netChat.cxx
sg_serial.cxx
sg_socket.cxx
sg_socket_udp.cxx
)
simgear_component(io io "${SOURCES}" "${HEADERS}")

View File

@@ -9,7 +9,11 @@ include_HEADERS = \
sg_file.hxx \
sg_serial.hxx \
sg_socket.hxx \
sg_socket_udp.hxx
sg_socket_udp.hxx \
raw_socket.hxx \
sg_netBuffer.hxx \
sg_netChannel.hxx \
sg_netChat.hxx
libsgio_a_SOURCES = \
iochannel.cxx \
@@ -18,7 +22,11 @@ libsgio_a_SOURCES = \
sg_file.cxx \
sg_serial.cxx \
sg_socket.cxx \
sg_socket_udp.cxx
sg_socket_udp.cxx \
raw_socket.cxx \
sg_netBuffer.cxx \
sg_netChannel.cxx \
sg_netChat.cxx
INCLUDES = -I$(top_srcdir)
@@ -26,52 +34,37 @@ noinst_PROGRAMS = decode_binobj socktest lowtest tcp_server tcp_client
tcp_server_SOURCES = tcp_server.cxx
if HAVE_FRAMEWORK_PLIB
tcp_server_LDFLAGS = $(plib_FRAMEWORK)
else
tcp_server_PLIB_LIBS = -lplibnet -lplibul
endif
tcp_server_LDADD = \
libsgio.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(tcp_server_PLIB_LIBS) -lz \
-lz \
$(network_LIBS) \
$(base_LIBS)
tcp_client_SOURCES = tcp_client.cxx
if HAVE_FRAMEWORK_PLIB
tcp_client_LDFLAGS = $(plib_FRAMEWORK)
else
tcp_client_PLIB_LIBS = -lplibnet -lplibul
endif
tcp_client_LDADD = \
libsgio.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(tcp_client_PLIB_LIBS) -lz \
-lz \
$(network_LIBS) \
$(base_LIBS)
socktest_SOURCES = socktest.cxx
if HAVE_FRAMEWORK_PLIB
socktest_LDFLAGS = $(plib_FRAMEWORK)
else
socktest_PLIB_LIBS = -lplibnet -lplibul
endif
socktest_LDADD = \
libsgio.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(socktest_PLIB_LIBS) -lz \
-lz \
$(network_LIBS) \
$(base_LIBS)
@@ -79,6 +72,7 @@ lowtest_SOURCES = lowtest.cxx
lowtest_LDADD = \
libsgio.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/bucket/libsgbucket.a \
$(top_builddir)/simgear/misc/libsgmisc.a \

View File

@@ -6,6 +6,7 @@
#include <unistd.h>
#include <iostream>
#include <cstdlib>
#include "sg_binobj.hxx"
@@ -63,7 +64,7 @@ int main( int argc, char **argv ) {
cout << "# geometry groups" << endl;
cout << endl;
string material;
std::string material;
int_list vertex_index;
int_list normal_index;
int_list tex_index;

View File

@@ -23,6 +23,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <string.h> // for memcpy()
#include "lowlevel.hxx"

View File

@@ -30,11 +30,11 @@
#include <stdio.h>
#include <zlib.h>
#include <plib/sg.h>
#include <simgear/compiler.h>
#include <simgear/misc/stdint.hxx>
#include <simgear/math/SGMath.hxx>
// Note that output is written in little endian form (and converted as
// necessary for big endian machines)
@@ -75,39 +75,39 @@ void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var ) ;
void sgReadString ( gzFile fd, char **var ) ;
void sgWriteString ( gzFile fd, const char *var ) ;
inline void sgReadVec2 ( gzFile fd, sgVec2 var ) {
sgReadFloat ( fd, 2, var ) ;
inline void sgReadVec2 ( gzFile fd, SGVec2f& var ) {
sgReadFloat ( fd, 2, var.data() ) ;
}
inline void sgWriteVec2 ( gzFile fd, const sgVec2 var ) {
sgWriteFloat ( fd, 2, var ) ;
inline void sgWriteVec2 ( gzFile fd, const SGVec2f& var ) {
sgWriteFloat ( fd, 2, var.data() ) ;
}
inline void sgReadVec3 ( gzFile fd, sgVec3 var ) {
sgReadFloat ( fd, 3, var ) ;
inline void sgReadVec3 ( gzFile fd, SGVec3f& var ) {
sgReadFloat ( fd, 3, var.data() ) ;
}
inline void sgWriteVec3 ( gzFile fd, const sgVec3 var ) {
sgWriteFloat ( fd, 3, var ) ;
inline void sgWriteVec3 ( gzFile fd, const SGVec3f& var ) {
sgWriteFloat ( fd, 3, var.data() ) ;
}
inline void sgReaddVec3 ( gzFile fd, sgdVec3 var ) {
sgReadDouble ( fd, 3, var ) ;
inline void sgReaddVec3 ( gzFile fd, SGVec3d& var ) {
sgReadDouble ( fd, 3, var.data() ) ;
}
inline void sgWritedVec3 ( gzFile fd, const sgdVec3 var ) {
sgWriteDouble ( fd, 3, var ) ;
inline void sgWritedVec3 ( gzFile fd, const SGVec3d& var ) {
sgWriteDouble ( fd, 3, var.data() ) ;
}
inline void sgReadVec4 ( gzFile fd, sgVec4 var ) {
sgReadFloat ( fd, 4, var ) ;
inline void sgReadVec4 ( gzFile fd, SGVec4f& var ) {
sgReadFloat ( fd, 4, var.data() ) ;
}
inline void sgWriteVec4 ( gzFile fd, const sgVec4 var ) {
sgWriteFloat ( fd, 4, var ) ;
inline void sgWriteVec4 ( gzFile fd, const SGVec4f& var ) {
sgWriteFloat ( fd, 4, var.data() ) ;
}
inline void sgReadMat4 ( gzFile fd, sgMat4 var ) {
sgReadFloat ( fd, 16, (float *)var ) ;
inline void sgReadMat4 ( gzFile fd, SGMatrixf& var ) {
sgReadFloat ( fd, 16, (float *)var.data() ) ;
}
inline void sgWriteMat4 ( gzFile fd, const sgMat4 var ) {
sgWriteFloat ( fd, 16, (float *)var ) ;
inline void sgWriteMat4 ( gzFile fd, const SGMatrixf& var ) {
sgWriteFloat ( fd, 16, (float *)var.data() ) ;
}
void sgClearReadError();

505
simgear/io/raw_socket.cxx Normal file
View File

@@ -0,0 +1,505 @@
/*
simgear::Socket, adapted from PLIB Socket by James Turner
Copyright (C) 2010 James Turner
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <simgear/compiler.h>
#include "sg_socket.hxx"
#if defined(_WIN32) && !defined(__CYGWIN__)
# define WINSOCK // use winsock convetions, otherwise standard POSIX
#endif
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <cstdio> // for snprintf
#if defined(WINSOCK)
# include <winsock.h>
# include <stdarg.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <sys/time.h>
# include <unistd.h>
# include <netdb.h>
# include <fcntl.h>
#endif
#if defined(_MSC_VER) && !defined(socklen_t)
#define socklen_t int
#endif
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
namespace simgear
{
IPAddress::IPAddress ( const char* host, int port )
{
set ( host, port ) ;
}
void IPAddress::set ( const char* host, int port )
{
memset(this, 0, sizeof(IPAddress));
sin_family = AF_INET ;
sin_port = htons (port);
/* Convert a string specifying a host name or one of a few symbolic
** names to a numeric IP address. This usually calls gethostbyname()
** to do the work; the names "" and "<broadcast>" are special.
*/
if (!host || host[0] == '\0') {
sin_addr = INADDR_ANY;
return;
}
if (strcmp(host, "<broadcast>") == 0) {
sin_addr = INADDR_BROADCAST;
return;
}
sin_addr = inet_addr ( host ) ;
if (sin_addr != INADDR_NONE) {
return;
}
// finally, try gethostbyname
struct hostent *hp = gethostbyname ( host ) ;
if (!hp) {
SG_LOG(SG_IO, SG_WARN, "gethostbyname failed for " << host);
sin_addr = INADDR_ANY ;
return;
}
memcpy ( (char *) &sin_addr, hp->h_addr, hp->h_length ) ;
}
/* Create a string object representing an IP address.
This is always a string of the form 'dd.dd.dd.dd' (with variable
size numbers). */
const char* IPAddress::getHost () const
{
#if 0
const char* buf = inet_ntoa ( sin_addr ) ;
#else
static char buf [32];
long x = ntohl(sin_addr);
sprintf(buf, "%d.%d.%d.%d",
(int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
(int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff );
#endif
return buf;
}
unsigned int IPAddress::getIP () const
{
return sin_addr;
}
unsigned int IPAddress::getPort() const
{
return ntohs(sin_port);
}
unsigned int IPAddress::getFamily () const
{
return sin_family;
}
const char* IPAddress::getLocalHost ()
{
//gethostbyname(gethostname())
char buf[256];
memset(buf, 0, sizeof(buf));
gethostname(buf, sizeof(buf)-1);
const hostent *hp = gethostbyname(buf);
if (hp && *hp->h_addr_list)
{
in_addr addr = *((in_addr*)*hp->h_addr_list);
const char* host = inet_ntoa(addr);
if ( host )
return host ;
}
return "127.0.0.1" ;
}
bool IPAddress::getBroadcast () const
{
return sin_addr == INADDR_BROADCAST;
}
Socket::Socket ()
{
handle = -1 ;
}
Socket::~Socket ()
{
close () ;
}
void Socket::setHandle (int _handle)
{
close () ;
handle = _handle ;
}
bool Socket::open ( bool stream )
{
close () ;
handle = ::socket ( AF_INET, (stream? SOCK_STREAM: SOCK_DGRAM), 0 ) ;
// Jan 26, 2010: Patch to avoid the problem of the socket resource not
// yet being available if the program is restarted quickly after being
// killed.
//
// Reference: http://www.unixguide.net/network/socketfaq/4.5.shtml
//
if ( stream ) {
int opt_boolean = 1;
#if defined(_WIN32) || defined(__CYGWIN__)
setsockopt( handle, SOL_SOCKET, SO_REUSEADDR, (char *)&opt_boolean,
sizeof(opt_boolean) );
#else
setsockopt( handle, SOL_SOCKET, SO_REUSEADDR, &opt_boolean,
sizeof(opt_boolean) );
#endif
}
return (handle != -1);
}
void Socket::setBlocking ( bool blocking )
{
assert ( handle != -1 ) ;
#if defined(WINSOCK)
u_long nblocking = blocking? 0: 1;
::ioctlsocket(handle, FIONBIO, &nblocking);
#else
int delay_flag = ::fcntl (handle, F_GETFL, 0);
if (blocking)
delay_flag &= (~O_NDELAY);
else
delay_flag |= O_NDELAY;
::fcntl (handle, F_SETFL, delay_flag);
#endif
}
void Socket::setBroadcast ( bool broadcast )
{
assert ( handle != -1 ) ;
int result;
if ( broadcast ) {
int one = 1;
#if defined(_WIN32) || defined(__CYGWIN__)
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, (char*)&one, sizeof(one) );
#else
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one) );
#endif
} else {
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, NULL, 0 );
}
if ( result < 0 ) {
throw sg_exception("Socket::setBroadcast failed");
}
}
int Socket::bind ( const char* host, int port )
{
assert ( handle != -1 ) ;
IPAddress addr ( host, port ) ;
return ::bind(handle,(const sockaddr*)&addr,sizeof(IPAddress));
}
int Socket::listen ( int backlog )
{
assert ( handle != -1 ) ;
return ::listen(handle,backlog);
}
int Socket::accept ( IPAddress* addr )
{
assert ( handle != -1 ) ;
if ( addr == NULL )
{
return ::accept(handle,NULL,NULL);
}
else
{
socklen_t addr_len = (socklen_t) sizeof(IPAddress) ;
return ::accept(handle,(sockaddr*)addr,&addr_len);
}
}
int Socket::connect ( const char* host, int port )
{
assert ( handle != -1 ) ;
IPAddress addr ( host, port ) ;
if ( addr.getBroadcast() ) {
setBroadcast( true );
}
return ::connect(handle,(const sockaddr*)&addr,sizeof(IPAddress));
}
int Socket::send (const void * buffer, int size, int flags)
{
assert ( handle != -1 ) ;
return ::send (handle, (const char*)buffer, size, flags);
}
int Socket::sendto ( const void * buffer, int size,
int flags, const IPAddress* to )
{
assert ( handle != -1 ) ;
return ::sendto(handle,(const char*)buffer,size,flags,
(const sockaddr*)to,sizeof(IPAddress));
}
int Socket::recv (void * buffer, int size, int flags)
{
assert ( handle != -1 ) ;
return ::recv (handle, (char*)buffer, size, flags);
}
int Socket::recvfrom ( void * buffer, int size,
int flags, IPAddress* from )
{
assert ( handle != -1 ) ;
socklen_t fromlen = (socklen_t) sizeof(IPAddress) ;
return ::recvfrom(handle,(char*)buffer,size,flags,(sockaddr*)from,&fromlen);
}
void Socket::close (void)
{
if ( handle != -1 )
{
#if defined(WINSOCK)
::closesocket( handle );
#else
::close( handle );
#endif
handle = -1 ;
}
}
bool Socket::isNonBlockingError ()
{
#if defined(WINSOCK)
int wsa_errno = WSAGetLastError();
if ( wsa_errno != 0 )
{
WSASetLastError(0);
SG_LOG(SG_IO, SG_WARN, "isNonBlockingError: WSAGetLastError():" << wsa_errno);
switch (wsa_errno) {
case WSAEWOULDBLOCK: // always == NET_EAGAIN?
case WSAEALREADY:
case WSAEINPROGRESS:
return true;
}
}
return false;
#else
switch (errno) {
case EWOULDBLOCK: // always == NET_EAGAIN?
case EALREADY:
case EINPROGRESS:
return true;
}
return false;
#endif
}
//////////////////////////////////////////////////////////////////////
//
// modified version by os
//
//////////////////////////////////////////////////////////////////////
int Socket::select ( Socket** reads, Socket** writes, int timeout )
{
fd_set r,w;
int retval;
FD_ZERO (&r);
FD_ZERO (&w);
int i, k ;
int num = 0 ;
if ( reads )
{
for ( i=0; reads[i]; i++ )
{
int fd = reads[i]->getHandle();
FD_SET (fd, &r);
num++;
}
}
if ( writes )
{
for ( i=0; writes[i]; i++ )
{
int fd = writes[i]->getHandle();
FD_SET (fd, &w);
num++;
}
}
if (!num)
return num ;
/* Set up the timeout */
struct timeval tv ;
tv.tv_sec = timeout/1000;
tv.tv_usec = (timeout%1000)*1000;
// It bothers me that select()'s first argument does not appear to
// work as advertised... [it hangs like this if called with
// anything less than FD_SETSIZE, which seems wasteful?]
// Note: we ignore the 'exception' fd_set - I have never had a
// need to use it. The name is somewhat misleading - the only
// thing I have ever seen it used for is to detect urgent data -
// which is an unportable feature anyway.
retval = ::select (FD_SETSIZE, &r, &w, 0, &tv);
//remove sockets that had no activity
num = 0 ;
if ( reads )
{
for ( k=i=0; reads[i]; i++ )
{
int fd = reads[i]->getHandle();
if ( FD_ISSET (fd, &r) )
{
reads[k++] = reads[i];
num++;
}
}
reads[k] = NULL ;
}
if ( writes )
{
for ( k=i=0; writes[i]; i++ )
{
int fd = writes[i]->getHandle();
if ( FD_ISSET (fd, &w) )
{
writes[k++] = writes[i];
num++;
}
}
writes[k] = NULL ;
}
if (retval == 0) // timeout
return (-2);
if (retval == -1)// error
return (-1);
return num ;
}
/* Init/Exit functions */
static void netExit ( void )
{
#if defined(WINSOCK)
/* Clean up windows networking */
if ( WSACleanup() == SOCKET_ERROR ) {
if ( WSAGetLastError() == WSAEINPROGRESS ) {
WSACancelBlockingCall();
WSACleanup();
}
}
#endif
}
int Socket::initSockets()
{
assert ( sizeof(sockaddr_in) == sizeof(IPAddress) ) ;
#if defined(WINSOCK)
/* Start up the windows networking */
WORD version_wanted = MAKEWORD(1,1);
WSADATA wsaData;
if ( WSAStartup(version_wanted, &wsaData) != 0 ) {
throw sg_exception("WinSock initialization failed");
}
#endif
atexit( netExit ) ;
return(0);
}
} // of namespace simgear

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

@@ -0,0 +1,110 @@
/*
simgear::Socket, adapted from PLIB netSocket by James Turner
Copyright (C) 2010 James Turner
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SG_IO_SOCKET_HXX
#define SG_IO_SOCKET_HXX
#include <errno.h>
#if defined(__APPLE__)
# include <netinet/in.h>
#endif
namespace simgear
{
/*
* Socket address, internet style.
*/
class IPAddress
{
/* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */
#ifdef __APPLE__
__uint8_t sin_len;
__uint8_t sin_family;
in_port_t sin_port;
in_addr_t sin_addr;
char sin_zero[8];
#else
short sin_family ;
unsigned short sin_port ;
unsigned int sin_addr ;
char sin_zero [ 8 ] ;
#endif
public:
IPAddress () {}
IPAddress ( const char* host, int port ) ;
void set ( const char* host, int port ) ;
const char* getHost () const ;
unsigned int getPort() const ;
unsigned int getIP () const ;
unsigned int getFamily () const ;
static const char* getLocalHost () ;
bool getBroadcast () const ;
};
/*
* Socket type
*/
class Socket
{
int handle ;
public:
Socket () ;
virtual ~Socket () ;
static int initSockets();
int getHandle () const { return handle; }
void setHandle (int handle) ;
bool open ( bool stream=true ) ;
void close ( void ) ;
int bind ( const char* host, int port ) ;
int listen ( int backlog ) ;
int accept ( IPAddress* addr ) ;
int connect ( const char* host, int port ) ;
int send ( const void * buffer, int size, int flags = 0 ) ;
int sendto ( const void * buffer, int size, int flags, const IPAddress* to ) ;
int recv ( void * buffer, int size, int flags = 0 ) ;
int recvfrom ( void * buffer, int size, int flags, IPAddress* from ) ;
void setBlocking ( bool blocking ) ;
void setBroadcast ( bool broadcast ) ;
static bool isNonBlockingError () ;
static int select ( Socket** reads, Socket** writes, int timeout ) ;
} ;
//const char* netFormat ( const char* fmt, ... ) ;
} // of namespace simgear
#endif // SG_IO_SOCKET_HXX

View File

@@ -31,6 +31,8 @@
#include <stdio.h>
#include <time.h>
#include <cstring>
#include <cstdlib> // for system()
#include <vector>
#include <string>
@@ -38,6 +40,7 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/math/SGGeometry.hxx>
#include "lowlevel.hxx"
#include "sg_binobj.hxx"
@@ -115,51 +118,6 @@ public:
}
};
// calculate the center of a list of points, by taking the halfway
// point between the min and max points.
Point3D sgCalcCenter( point_list& wgs84_nodes ) {
Point3D p, min, max;
if ( wgs84_nodes.size() ) {
min = max = wgs84_nodes[0];
} else {
min = max = Point3D( 0 );
}
for ( int i = 0; i < (int)wgs84_nodes.size(); ++i ) {
p = wgs84_nodes[i];
if ( p.x() < min.x() ) { min.setx( p.x() ); }
if ( p.y() < min.y() ) { min.sety( p.y() ); }
if ( p.z() < min.z() ) { min.setz( p.z() ); }
if ( p.x() > max.x() ) { max.setx( p.x() ); }
if ( p.y() > max.y() ) { max.sety( p.y() ); }
if ( p.z() > max.z() ) { max.setz( p.z() ); }
}
return ( min + max ) / 2.0;
}
// calculate the bounding sphere. Center is the center of the
// tile and zero elevation
double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes ) {
double dist_squared;
double radius_squared = 0;
for ( int i = 0; i < (int)wgs84_nodes.size(); ++i ) {
dist_squared = center.distance3Dsquared( wgs84_nodes[i] );
if ( dist_squared > radius_squared ) {
radius_squared = dist_squared;
}
}
return sqrt(radius_squared);
}
// read object properties
static void read_object( gzFile fp,
int obj_type,
@@ -737,9 +695,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
sgWriteUShort( fp, 1 ); // nelements
sgWriteUInt( fp, sizeof(double) * 3 + sizeof(float) ); // nbytes
sgdVec3 center;
sgdSetVec3( center, gbs_center.x(), gbs_center.y(), gbs_center.z() );
sgWritedVec3( fp, center );
sgWritedVec3( fp, gbs_center );
sgWriteFloat( fp, gbs_radius );
// dump vertex list
@@ -748,8 +704,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
sgWriteUShort( fp, 1 ); // nelements
sgWriteUInt( fp, wgs84_nodes.size() * sizeof(float) * 3 ); // nbytes
for ( i = 0; i < (int)wgs84_nodes.size(); ++i ) {
SGVec3f p = toVec3f(wgs84_nodes[i] - gbs_center);
sgWriteVec3( fp, p.data() );
sgWriteVec3( fp, toVec3f(wgs84_nodes[i] - gbs_center));
}
// dump vertex color list
@@ -758,7 +713,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
sgWriteUShort( fp, 1 ); // nelements
sgWriteUInt( fp, colors.size() * sizeof(float) * 4 ); // nbytes
for ( i = 0; i < (int)colors.size(); ++i ) {
sgWriteVec4( fp, colors[i].data() );
sgWriteVec4( fp, colors[i]);
}
// dump vertex normal list
@@ -781,7 +736,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
sgWriteUShort( fp, 1 ); // nelements
sgWriteUInt( fp, texcoords.size() * sizeof(float) * 2 ); // nbytes
for ( i = 0; i < (int)texcoords.size(); ++i ) {
sgWriteVec2( fp, texcoords[i].data() );
sgWriteVec2( fp, texcoords[i]);
}
// dump point groups if they exist
@@ -1128,19 +1083,16 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
}
// cout << "group = " << start << " to " << end - 1 << endl;
// make a list of points for the group
point_list group_nodes;
group_nodes.clear();
SGVec3d bs_center;
double bs_radius = 0;
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
group_nodes.push_back( Point3D::fromSGVec3(wgs84_nodes[ tris_v[i][j] ]) );
bs_center = sgCalcCenter( group_nodes ).toSGVec3d();
bs_radius = sgCalcBoundingRadius( Point3D::fromSGVec3(bs_center), group_nodes );
}
}
SGSphered d;
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
d.expandBy(wgs84_nodes[ tris_v[i][j] ]);
}
}
SGVec3d bs_center = d.getCenter();
double bs_radius = d.getRadius();
// write group headers
fprintf(fp, "\n");
fprintf(fp, "# usemtl %s\n", material.c_str());
@@ -1179,18 +1131,16 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
}
// cout << "group = " << start << " to " << end - 1 << endl;
// make a list of points for the group
point_list group_nodes;
group_nodes.clear();
SGVec3d bs_center;
double bs_radius = 0;
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
group_nodes.push_back( Point3D::fromSGVec3(wgs84_nodes[ strips_v[i][j] ]) );
bs_center = sgCalcCenter( group_nodes ).toSGVec3d();
bs_radius = sgCalcBoundingRadius( Point3D::fromSGVec3(bs_center), group_nodes );
}
}
SGSphered d;
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
d.expandBy(wgs84_nodes[ tris_v[i][j] ]);
}
}
SGVec3d bs_center = d.getCenter();
double bs_radius = d.getRadius();
// write group headers
fprintf(fp, "\n");

View File

@@ -28,12 +28,9 @@
#define _SG_BINOBJ_HXX
#include <plib/sg.h>
#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/math/sg_types.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/bucket/newbucket.hxx>
#include <stdio.h>
@@ -45,7 +42,7 @@
/** STL Structure used to store object information */
typedef vector < int_list > group_list;
typedef std::vector < int_list > group_list;
typedef group_list::iterator group_list_iterator;
typedef group_list::const_iterator const_group_list_iterator;
@@ -126,9 +123,7 @@ public:
inline unsigned short get_version() const { return version; }
inline Point3D get_gbs_center() const { return Point3D::fromSGVec3(gbs_center); }
inline void set_gbs_center( const Point3D& p ) { gbs_center = p.toSGVec3d(); }
inline const SGVec3d& get_gbs_center2() const { return gbs_center; }
inline const SGVec3d& get_gbs_center() const { return gbs_center; }
inline void set_gbs_center( const SGVec3d& p ) { gbs_center = p; }
inline float get_gbs_radius() const { return gbs_radius; }
@@ -138,40 +133,16 @@ public:
{ return wgs84_nodes; }
inline void set_wgs84_nodes( const std::vector<SGVec3d>& n )
{ wgs84_nodes = n; }
inline void set_wgs84_nodes( const point_list& n )
{
wgs84_nodes.resize(n.size());
for (unsigned i = 0; i < wgs84_nodes.size(); ++i)
wgs84_nodes[i] = n[i].toSGVec3d();
}
inline const std::vector<SGVec4f>& get_colors() const { return colors; }
inline void set_colors( const std::vector<SGVec4f>& c ) { colors = c; }
inline void set_colors( const point_list& c )
{
colors.resize(c.size());
for (unsigned i = 0; i < colors.size(); ++i)
colors[i] = SGVec4f(c[i].toSGVec3f(), 1);
}
inline const std::vector<SGVec3f>& get_normals() const { return normals; }
inline void set_normals( const std::vector<SGVec3f>& n ) { normals = n; }
inline void set_normals( const point_list& n )
{
normals.resize(n.size());
for (unsigned i = 0; i < normals.size(); ++i)
normals[i] = n[i].toSGVec3f();
}
inline const std::vector<SGVec2f>& get_texcoords() const { return texcoords; }
inline void set_texcoords( const std::vector<SGVec2f>& t ) { texcoords = t; }
inline void set_texcoords( const point_list& t )
{
texcoords.resize(t.size());
for (unsigned i = 0; i < texcoords.size(); ++i)
texcoords[i] = t[i].toSGVec2f();
}
inline const group_list& get_pts_v() const { return pts_v; }
inline void set_pts_v( const group_list& g ) { pts_v = g; }
inline const group_list& get_pts_n() const { return pts_n; }
@@ -223,7 +194,7 @@ public:
* @param file input file name
* @return result of read
*/
bool read_bin( const string& file );
bool read_bin( const std::string& file );
/**
* Write out the structures to a binary file. We assume that the
@@ -234,7 +205,7 @@ public:
* @param b bucket for object location
* @return result of write
*/
bool write_bin( const string& base, const string& name, const SGBucket& b );
bool write_bin( const std::string& base, const std::string& name, const SGBucket& b );
/**
* Write out the structures to an ASCII file. We assume that the
@@ -245,30 +216,8 @@ public:
* @param b bucket for object location
* @return result of write
*/
bool write_ascii( const string& base, const string& name,
bool write_ascii( const std::string& base, const std::string& name,
const SGBucket& b );
};
/**
* \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.
* Center is the center of the tile and zero elevation.
* @param center center of our bounding radius
* @param wgs84_nodes list of points in wgs84 coordinates
* @return radius
*/
double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes );
#endif // _SG_BINOBJ_HXX

159
simgear/io/sg_netBuffer.cxx Normal file
View File

@@ -0,0 +1,159 @@
/*
Copied from PLIB into SimGear
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: netBuffer.cxx 1568 2002-09-02 06:05:49Z sjbaker $
*/
#include "sg_netBuffer.hxx"
#include <cassert>
#include <cstring>
#include <simgear/debug/logstream.hxx>
namespace simgear {
NetBuffer::NetBuffer( int _max_length )
{
length = 0 ;
max_length = _max_length ;
data = new char [ max_length+1 ] ; //for null terminator
}
NetBuffer::~NetBuffer ()
{
delete[] data ;
}
void NetBuffer::remove ()
{
length = 0 ;
}
void NetBuffer::remove (int pos, int n)
{
assert (pos>=0 && pos<length && (pos+n)<=length) ;
//if (pos>=0 && pos<length && (pos+n)<=length)
{
memmove(&data[pos],&data[pos+n],length-(pos+n)) ;
length -= n ;
}
}
bool NetBuffer::append (const char* s, int n)
{
if ((length+n)<=max_length)
{
memcpy(&data[length],s,n) ;
length += n ;
return true ;
}
return false ;
}
bool NetBuffer::append (int n)
{
if ((length+n)<=max_length)
{
length += n ;
return true ;
}
return false ;
}
NetBufferChannel::NetBufferChannel (int in_buffer_size, int out_buffer_size) :
in_buffer (in_buffer_size),
out_buffer (out_buffer_size),
should_close (0)
{ /* empty */
}
void NetBufferChannel::handleClose ( void )
{
in_buffer.remove () ;
out_buffer.remove () ;
should_close = 0 ;
NetChannel::handleClose () ;
}
bool NetBufferChannel::bufferSend (const char* msg, int msg_len)
{
if ( out_buffer.append(msg,msg_len) )
return true ;
SG_LOG(SG_IO, SG_WARN, "NetBufferChannel: output buffer overflow!" ) ;
return false ;
}
void NetBufferChannel::handleBufferRead (NetBuffer& buffer)
{
/* do something here */
buffer.remove();
}
void
NetBufferChannel::handleRead (void)
{
int max_read = in_buffer.getMaxLength() - in_buffer.getLength() ;
if (max_read)
{
char* data = in_buffer.getData() + in_buffer.getLength() ;
int num_read = recv (data, max_read) ;
if (num_read > 0)
{
in_buffer.append (num_read) ;
//ulSetError ( UL_DEBUG, "netBufferChannel: %d read", num_read ) ;
}
}
if (in_buffer.getLength())
{
handleBufferRead (in_buffer);
}
}
void
NetBufferChannel::handleWrite (void)
{
if (out_buffer.getLength())
{
if (isConnected())
{
int length = out_buffer.getLength() ;
if (length>512)
length=512;
int num_sent = NetChannel::send (
out_buffer.getData(), length);
if (num_sent > 0)
{
out_buffer.remove (0, num_sent);
//ulSetError ( UL_DEBUG, "netBufferChannel: %d sent", num_sent ) ;
}
}
}
else if (should_close)
{
close();
}
}
} // of namespace simgear

155
simgear/io/sg_netBuffer.hxx Normal file
View File

@@ -0,0 +1,155 @@
/*
Copied from PLIB into SimGear
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: netBuffer.h 1901 2004-03-21 18:19:11Z sjbaker $
*/
/****
* NAME
* netBuffer - network buffer class
*
* DESCRIPTION
* Clients and servers built on top of netBufferChannel
* automatically support pipelining.
*
* Pipelining refers to a protocol capability. Normally,
* a conversation with a server has a back-and-forth
* quality to it. The client sends a command, and
* waits for the response. If a client needs to send
* many commands over a high-latency connection,
* waiting for each response can take a long time.
*
* For example, when sending a mail message to many recipients
* with SMTP, the client will send a series of RCPT commands, one
* for each recipient. For each of these commands, the server will
* send back a reply indicating whether the mailbox specified is
* valid. If you want to send a message to several hundred recipients,
* this can be rather tedious if the round-trip time for each command
* is long. You'd like to be able to send a bunch of RCPT commands
* in one batch, and then count off the responses to them as they come.
*
* I have a favorite visual when explaining the advantages of
* pipelining. Imagine each request to the server is a boxcar on a train.
* The client is in Los Angeles, and the server is in New York.
* Pipelining lets you hook all your cars in one long chain; send
* them to New York, where they are filled and sent back to you.
* Without pipelining you have to send one car at a time.
*
* Not all protocols allow pipelining. Not all servers support it;
* Sendmail, for example, does not support pipelining because it tends
* to fork unpredictably, leaving buffered data in a questionable state.
* A recent extension to the SMTP protocol allows a server to specify
* whether it supports pipelining. HTTP/1.1 explicitly requires that
* a server support pipelining.
*
* NOTES
* When a user passes in a buffer object, it belongs to
* the user. When the library gives a buffer to the user,
* the user should copy it.
*
* AUTHORS
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
*
* CREATION DATE
* Dec-2000
*
****/
#ifndef SG_NET_BUFFER_H
#define SG_NET_BUFFER_H
#include <simgear/io/sg_netChannel.hxx>
namespace simgear
{
// ===========================================================================
// NetBuffer
// ===========================================================================
class NetBuffer
{
protected:
int length ;
int max_length ;
char* data ;
public:
NetBuffer( int _max_length );
~NetBuffer ();
int getLength() const { return length ; }
int getMaxLength() const { return max_length ; }
/*
** getData() returns a pointer to the data
** Note: a zero (0) byte is appended for convenience
** but the data may have internal zero (0) bytes already
*/
char* getData() { data [length] = 0 ; return data ; }
const char* getData() const { ((char*)data) [length] = 0 ; return data ; }
void remove ();
void remove (int pos, int n);
bool append (const char* s, int n);
bool append (int n);
};
// ===========================================================================
// NetBufferChannel
// ===========================================================================
class NetBufferChannel : public NetChannel
{
NetBuffer in_buffer;
NetBuffer out_buffer;
int should_close ;
virtual bool readable (void)
{
return (NetChannel::readable() &&
(in_buffer.getLength() < in_buffer.getMaxLength()));
}
virtual void handleRead (void) ;
virtual bool writable (void)
{
return (out_buffer.getLength() || should_close);
}
virtual void handleWrite (void) ;
public:
NetBufferChannel (int in_buffer_size = 4096, int out_buffer_size = 16384);
virtual void handleClose ( void );
void closeWhenDone (void) { should_close = 1 ; }
virtual bool bufferSend (const char* msg, int msg_len);
virtual void handleBufferRead (NetBuffer& buffer);
};
} // namespace simgear
#endif // SG_NET_BUFFER_H

View File

@@ -0,0 +1,307 @@
/*
Copied from PLIB into SimGear
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: netChannel.cxx 1906 2004-03-22 19:44:50Z sjbaker $
*/
// TODO:
// have all socket-related functions assert that the socket has not
// been closed. [a read event may close it, and a write event may try
// to write or something...]
// Maybe assert valid handle, too?
#include "sg_netChannel.hxx"
#include <memory>
#include <cassert>
#include <cstring>
#include <simgear/debug/logstream.hxx>
namespace simgear {
static NetChannel* channels = 0 ;
NetChannel::NetChannel ()
{
closed = true ;
connected = false ;
accepting = false ;
write_blocked = false ;
should_delete = false ;
next_channel = channels ;
channels = this ;
}
NetChannel::~NetChannel ()
{
close();
NetChannel* prev = NULL ;
for ( NetChannel* ch = channels; ch != NULL;
ch = ch -> next_channel )
{
if (ch == this)
{
ch = ch -> next_channel ;
if ( prev != NULL )
prev -> next_channel = ch ;
else
channels = ch ;
next_channel = 0 ;
break;
}
prev = ch ;
}
}
void
NetChannel::setHandle (int handle, bool is_connected)
{
close () ;
Socket::setHandle ( handle ) ;
connected = is_connected ;
//if ( connected ) this->handleConnect();
closed = false ;
}
bool
NetChannel::open (void)
{
close();
if (Socket::open(true)) {
closed = false ;
setBlocking ( false ) ;
return true ;
}
return false ;
}
int
NetChannel::listen ( int backlog )
{
accepting = true ;
return Socket::listen ( backlog ) ;
}
int
NetChannel::connect ( const char* host, int port )
{
int result = Socket::connect ( host, port ) ;
if (result == 0) {
connected = true ;
//this->handleConnect();
return 0;
} else if (isNonBlockingError ()) {
return 0;
} else {
// some other error condition
this->handleError (result);
close();
return -1;
}
}
int
NetChannel::send (const void * buffer, int size, int flags)
{
int result = Socket::send (buffer, size, flags);
if (result == (int)size) {
// everything was sent
write_blocked = false ;
return result;
} else if (result >= 0) {
// not all of it was sent, but no error
write_blocked = true ;
return result;
} else if (isNonBlockingError ()) {
write_blocked = true ;
return 0;
} else {
this->handleError (result);
close();
return -1;
}
}
int
NetChannel::recv (void * buffer, int size, int flags)
{
int result = Socket::recv (buffer, size, flags);
if (result > 0) {
return result;
} else if (result == 0) {
close();
return 0;
} else if (isNonBlockingError ()) {
return 0;
} else {
this->handleError (result);
close();
return -1;
}
}
void
NetChannel::close (void)
{
if ( !closed )
{
this->handleClose();
closed = true ;
connected = false ;
accepting = false ;
write_blocked = false ;
}
Socket::close () ;
}
void
NetChannel::handleReadEvent (void)
{
if (accepting) {
if (!connected) {
connected = true ;
//this->handleConnect();
}
this->handleAccept();
} else if (!connected) {
connected = true ;
//this->handleConnect();
this->handleRead();
} else {
this->handleRead();
}
}
void
NetChannel::handleWriteEvent (void)
{
if (!connected) {
connected = true ;
//this->handleConnect();
}
write_blocked = false ;
this->handleWrite();
}
bool
NetChannel::poll (unsigned int timeout)
{
if (!channels)
return false ;
enum { MAX_SOCKETS = 256 } ;
Socket* reads [ MAX_SOCKETS+1 ] ;
Socket* writes [ MAX_SOCKETS+1 ] ;
Socket* deletes [ MAX_SOCKETS+1 ] ;
int nreads = 0 ;
int nwrites = 0 ;
int ndeletes = 0 ;
int nopen = 0 ;
NetChannel* ch;
for ( ch = channels; ch != NULL; ch = ch -> next_channel )
{
if ( ch -> should_delete )
{
assert(ndeletes<MAX_SOCKETS);
deletes[ndeletes++] = ch ;
}
else if ( ! ch -> closed )
{
nopen++ ;
if (ch -> readable()) {
assert(nreads<MAX_SOCKETS);
reads[nreads++] = ch ;
}
if (ch -> writable()) {
assert(nwrites<MAX_SOCKETS);
writes[nwrites++] = ch ;
}
}
}
reads[nreads] = NULL ;
writes[nwrites] = NULL ;
deletes[ndeletes] = NULL ;
int i ;
for ( i=0; deletes[i]; i++ )
{
ch = (NetChannel*)deletes[i];
delete ch ;
}
if (!nopen)
return false ;
if (!nreads && !nwrites)
return true ; //hmmm- should we shutdown?
Socket::select (reads, writes, timeout) ;
for ( i=0; reads[i]; i++ )
{
ch = (NetChannel*)reads[i];
if ( ! ch -> closed )
ch -> handleReadEvent();
}
for ( i=0; writes[i]; i++ )
{
ch = (NetChannel*)writes[i];
if ( ! ch -> closed )
ch -> handleWriteEvent();
}
return true ;
}
void
NetChannel::loop (unsigned int timeout)
{
while ( poll (timeout) ) ;
}
void NetChannel::handleRead (void) {
SG_LOG(SG_IO, SG_WARN, "Network:" << getHandle() << ": unhandled read");
}
void NetChannel::handleWrite (void) {
SG_LOG(SG_IO, SG_WARN, "Network:" << getHandle() << ": unhandled write");
}
void NetChannel::handleAccept (void) {
SG_LOG(SG_IO, SG_WARN, "Network:" << getHandle() << ": unhandled accept");
}
void NetChannel::handleError (int error) {
SG_LOG(SG_IO, SG_WARN,"Network:" << getHandle() << ": errno: " << strerror(errno) <<"(" << errno << ")");
}
} // of namespace simgear

View File

@@ -0,0 +1,115 @@
/*
NetChannel - copied from PLIB
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: netChannel.h 1899 2004-03-21 17:41:07Z sjbaker $
*/
/****
* NAME
* netChannel - network channel class
*
* DESCRIPTION
* netChannel is adds event-handling to the low-level
* netSocket class. Otherwise, it can be treated as
* a normal non-blocking socket object.
*
* The direct interface between the netPoll() loop and
* the channel object are the handleReadEvent and
* handleWriteEvent methods. These are called
* whenever a channel object 'fires' that event.
*
* The firing of these low-level events can tell us whether
* certain higher-level events have taken place, depending on
* the timing and state of the connection.
*
* AUTHORS
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
*
* CREATION DATE
* Dec-2000
*
****/
#ifndef SG_NET_CHANNEL_H
#define SG_NET_CHANNEL_H
#include <simgear/io/raw_socket.hxx>
namespace simgear
{
class NetChannel : public Socket
{
bool closed, connected, accepting, write_blocked, should_delete ;
NetChannel* next_channel ;
friend bool netPoll (unsigned int timeout);
public:
NetChannel () ;
virtual ~NetChannel () ;
void setHandle (int s, bool is_connected = true);
bool isConnected () const { return connected; }
bool isClosed () const { return closed; }
void shouldDelete () { should_delete = true ; }
// --------------------------------------------------
// socket methods
// --------------------------------------------------
bool open ( void ) ;
void close ( void ) ;
int listen ( int backlog ) ;
int connect ( const char* host, int port ) ;
int send ( const void * buf, int size, int flags = 0 ) ;
int recv ( void * buf, int size, int flags = 0 ) ;
// poll() eligibility predicates
virtual bool readable (void) { return (connected || accepting); }
virtual bool writable (void) { return (!connected || write_blocked); }
// --------------------------------------------------
// event handlers
// --------------------------------------------------
void handleReadEvent (void);
void handleWriteEvent (void);
// These are meant to be overridden.
virtual void handleClose (void) {
}
virtual void handleRead (void);
virtual void handleWrite (void);
virtual void handleAccept (void);
virtual void handleError (int error);
static bool poll (unsigned int timeout = 0 ) ;
static void loop (unsigned int timeout = 0 ) ;
};
} // of namespace simgear
#endif // SG_NET_CHANNEL_H

138
simgear/io/sg_netChat.cxx Normal file
View File

@@ -0,0 +1,138 @@
/*
Copied from PLIB into SimGear
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: NetChat.cxx 2117 2007-09-13 23:21:09Z fayjf $
*/
#include <simgear/io/sg_netChat.hxx>
#include <cstring> // for strdup
namespace simgear {
void
NetChat::setTerminator (const char* t)
{
if (terminator) delete[] terminator;
terminator = strdup(t);
}
const char*
NetChat::getTerminator (void)
{
return terminator;
}
// return the size of the largest prefix of needle at the end
// of haystack
#define MAX(a,b) (((a)>(b))?(a):(b))
static int
find_prefix_at_end (const NetBuffer& haystack, const char* needle)
{
const char* hd = haystack.getData();
int hl = haystack.getLength();
int nl = strlen(needle);
for (int i = MAX (nl-hl, 0); i < nl; i++) {
//if (haystack.compare (needle, hl-(nl-i), nl-i) == 0) {
if (memcmp(needle, &hd[hl-(nl-i)], nl-i) == 0) {
return (nl-i);
}
}
return 0;
}
static int
find_terminator (const NetBuffer& haystack, const char* needle)
{
if (needle && *needle)
{
const char* data = haystack.getData();
const char* ptr = strstr(data,needle);
if (ptr != NULL)
return(ptr-data);
}
return -1;
}
bool NetChat::push (const char* s)
{
return bufferSend ( s, strlen(s) ) ;
}
void
NetChat::handleBufferRead (NetBuffer& in_buffer)
{
// Continue to search for terminator in in_buffer,
// while calling collect_incoming_data. The while loop is
// necessary because we might read several data+terminator combos
// with a single recv().
while (in_buffer.getLength()) {
// special case where we're not using a terminator
if (terminator == 0 || *terminator == 0) {
collectIncomingData (in_buffer.getData(),in_buffer.getLength());
in_buffer.remove ();
return;
}
int terminator_len = strlen(terminator);
int index = find_terminator ( in_buffer, terminator ) ;
// 3 cases:
// 1) end of buffer matches terminator exactly:
// collect data, transition
// 2) end of buffer matches some prefix:
// collect data to the prefix
// 3) end of buffer does not match any prefix:
// collect data
if (index != -1) {
// we found the terminator
collectIncomingData ( in_buffer.getData(), index ) ;
in_buffer.remove (0, index + terminator_len);
foundTerminator();
} else {
// check for a prefix of the terminator
int num = find_prefix_at_end (in_buffer, terminator);
if (num) {
int bl = in_buffer.getLength();
// we found a prefix, collect up to the prefix
collectIncomingData ( in_buffer.getData(), bl - num ) ;
in_buffer.remove (0, bl - num);
break;
} else {
// no prefix, collect it all
collectIncomingData (in_buffer.getData(), in_buffer.getLength());
in_buffer.remove();
}
}
}
}
} // of namespace simgear

90
simgear/io/sg_netChat.hxx Normal file
View File

@@ -0,0 +1,90 @@
/*
Copied from PLIB into SimGear
PLIB - A Suite of Portable Game Libraries
Copyright (C) 1998,2002 Steve Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: netChat.h 1568 2002-09-02 06:05:49Z sjbaker $
*/
/****
* NAME
* netChat - network chat class
*
* DESCRIPTION
* This class adds support for 'chat' style protocols -
* where one side sends a 'command', and the other sends
* a response (examples would be the common internet
* protocols - smtp, nntp, ftp, etc..).
*
* The handle_buffer_read() method looks at the input
* stream for the current 'terminator' (usually '\r\n'
* for single-line responses, '\r\n.\r\n' for multi-line
* output), calling found_terminator() on its receipt.
*
* EXAMPLE
* Say you build an nntp client using this class.
* At the start of the connection, you'll have
* terminator set to '\r\n', in order to process
* the single-line greeting. Just before issuing a
* 'LIST' command you'll set it to '\r\n.\r\n'.
* The output of the LIST command will be accumulated
* (using your own 'collect_incoming_data' method)
* up to the terminator, and then control will be
* returned to you - by calling your found_terminator()
*
* AUTHORS
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
*
* CREATION DATE
* Dec-2000
*
****/
#ifndef SG_NET_CHAT_H
#define SG_NET_CHAT_H
#include <simgear/io/sg_netBuffer.hxx>
namespace simgear
{
class NetChat : public NetBufferChannel
{
char* terminator;
virtual void handleBufferRead (NetBuffer& buffer) ;
public:
NetChat () : terminator (0) {}
void setTerminator (const char* t);
const char* getTerminator (void);
bool push (const char* s);
virtual void collectIncomingData (const char* s, int n) {}
virtual void foundTerminator (void) {}
};
} // of namespace simgear
#endif // SG_NET_CHAT_H

View File

@@ -27,11 +27,9 @@
#include <simgear/compiler.h>
#if defined( sgi )
#include <strings.h>
#endif
#include <iostream>
#include <cstring>
#include <cstdlib> // for atoi
#include <simgear/debug/logstream.hxx>
@@ -52,8 +50,8 @@ SGSocket::SGSocket( const string& host, const string& port_,
{
if (!init)
{
netInit(NULL, NULL); // plib-1.4.2 compatible
init = true;
simgear::Socket::initSockets();
init = true;
}
if ( style == "tcp" )
@@ -298,7 +296,7 @@ SGSocket::readline( char *buf, int length )
int i;
for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i )
;
if ( save_buf[i] == '\n' ) {
if (( i < save_len ) && ( save_buf[i] == '\n' )) {
result = i + 1;
} else {
// no end of line yet
@@ -307,9 +305,16 @@ SGSocket::readline( char *buf, int length )
// we found an end of line
// check buffer size
int copy_length = result;
if (copy_length >= length) {
SG_LOG( SG_IO, SG_ALERT,
"Alert: readline() has line exceeding the buffer size." );
copy_length = length-1;
}
// copy to external buffer
strncpy( buf, save_buf, result );
buf[result] = '\0';
strncpy( buf, save_buf, copy_length );
buf[copy_length] = '\0';
// shift save buffer
//memmove( save_buf+, save_buf+, ? );
@@ -326,7 +331,7 @@ SGSocket::readline( char *buf, int length )
int
SGSocket::write( const char *buf, const int length )
{
netSocket* s = client == 0 ? &sock : client;
simgear::Socket* s = client == 0 ? &sock : client;
if (s->getHandle() == -1)
{
return 0;
@@ -384,24 +389,24 @@ SGSocket::nonblock()
int
SGSocket::poll()
{
netSocket* readers[2];
simgear::Socket* readers[2];
readers[0] = client != 0 ? client : &sock;
readers[1] = 0;
netSocket* writers[1];
simgear::Socket* writers[1];
writers[0] = 0;
int result = netSocket::select( readers, writers, timeout );
int result = simgear::Socket::select( readers, writers, timeout );
if (result > 0 && is_server && client == 0)
{
// Accept a new client connection
netAddress addr;
simgear::IPAddress addr;
int new_fd = sock.accept( &addr );
SG_LOG( SG_IO, SG_INFO, "Accepted connection from "
<< addr.getHost() << ":" << addr.getPort() );
client = new netSocket();
client = new simgear::Socket();
client->setHandle( new_fd );
return 0;
}

View File

@@ -27,21 +27,13 @@
#ifndef _SG_SOCKET_HXX
#define _SG_SOCKET_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <string>
#include <simgear/math/sg_types.hxx>
#include <simgear/io/iochannel.hxx>
#include <plib/netSocket.h>
using std::string;
#include <simgear/io/raw_socket.hxx>
#define SG_MAX_SOCKET_QUEUE 32
@@ -52,14 +44,14 @@ using std::string;
class SGSocket : public SGIOChannel {
public:
private:
string hostname;
string port_str;
std::string hostname;
std::string port_str;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
netSocket sock;
netSocket* client;
simgear::Socket sock;
simgear::Socket* client;
unsigned short port;
bool is_tcp;
bool is_server;
@@ -126,7 +118,7 @@ public:
* @param port port number if we care to choose one.
* @param style specify "udp" or "tcp"
*/
SGSocket( const string& host, const string& port, const string& style );
SGSocket( const std::string& host, const std::string& port, const std::string& style );
/** Destructor */
~SGSocket();
@@ -161,10 +153,10 @@ public:
inline void set_timeout(int i) { timeout = i; }
/** @return the remote host name */
inline string get_hostname() const { return hostname; }
inline std::string get_hostname() const { return hostname; }
/** @return the port number (in string form) */
inline string get_port_str() const { return port_str; }
inline std::string get_port_str() const { return port_str; }
};

View File

@@ -26,14 +26,12 @@
#include <simgear/compiler.h>
#if defined( sgi )
#include <strings.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "sg_socket_udp.hxx"
#include <cstring>
#include <cstdlib> // for atoi
SGSocketUDP::SGSocketUDP( const string& host, const string& port ) :
hostname(host),

View File

@@ -28,20 +28,13 @@
#define _SG_SOCKET_UDP_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <plib/netSocket.h>
#include <simgear/compiler.h>
#include <string>
#include <simgear/math/sg_types.hxx>
#include <simgear/io/iochannel.hxx>
using std::string;
#include <simgear/io/raw_socket.hxx>
/**
* A UDP socket I/O class based on SGIOChannel and plib/net.
@@ -50,10 +43,10 @@ class SGSocketUDP : public SGIOChannel {
private:
netSocket sock;
simgear::Socket sock;
string hostname;
string port_str;
std::string hostname;
std::string port_str;
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
int save_len;
@@ -128,10 +121,10 @@ public:
bool setBlocking( bool value );
/** @return the remote host name */
inline string get_hostname() const { return hostname; }
inline std::string get_hostname() const { return hostname; }
/** @return the port number (in string form) */
inline string get_port_str() const { return port_str; }
inline std::string get_port_str() const { return port_str; }
};

View File

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

2
simgear/magvar/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
testmagvar

View File

@@ -0,0 +1,7 @@
include (SimGearComponent)
set(HEADERS magvar.hxx coremag.hxx)
set(SOURCES magvar.cxx coremag.cxx)
simgear_component(magvar magvar "${SOURCES}" "${HEADERS}")

View File

@@ -21,6 +21,11 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <math.h>
#include <simgear/magvar/magvar.hxx>
@@ -50,7 +55,7 @@ void SGMagVar::update( double lon, double lat, double alt_m, double jd ) {
void SGMagVar::update( const SGGeod& geod, double jd ) {
update(geod.getLongitudeDeg(), geod.getLatitudeDeg(),
update(geod.getLongitudeRad(), geod.getLatitudeRad(),
geod.getElevationM(), jd);
}
@@ -62,3 +67,10 @@ double sgGetMagVar( double lon, double lat, double alt_m, double jd ) {
double field[6];
return calc_magvar( lat, lon, alt_m / 1000.0, (long)jd, field );
}
double sgGetMagVar( const SGGeod& pos, double jd )
{
return sgGetMagVar(pos.getLongitudeRad(), pos.getLatitudeRad(),
pos.getElevationM(), jd);
}

View File

@@ -103,5 +103,9 @@ public:
*/
double sgGetMagVar( double lon, double lat, double alt_m, double jd );
/**
* overload version of the above to take a SGGeod
*/
double sgGetMagVar( const SGGeod& pos, double jd );
#endif // _MAGVAR_HXX

View File

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

3
simgear/math/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
SGMathTest
SGGeometryTest

View File

@@ -0,0 +1,47 @@
include (SimGearComponent)
set(HEADERS
Math.hxx
SGBox.hxx
SGCMath.hxx
SGGeoc.hxx
SGGeod.hxx
SGGeodesy.hxx
SGGeometry.hxx
SGGeometryFwd.hxx
SGIntersect.hxx
SGLimits.hxx
SGLineSegment.hxx
SGMath.hxx
SGMathFwd.hxx
SGMatrix.hxx
SGMisc.hxx
SGPlane.hxx
SGQuat.hxx
SGRay.hxx
SGSphere.hxx
SGTriangle.hxx
SGVec2.hxx
SGVec3.hxx
SGVec4.hxx
beziercurve.hxx
interpolater.hxx
leastsqs.hxx
project.hxx
sg_geodesy.hxx
sg_types.hxx
sg_random.h
)
set(SOURCES
SGGeod.cxx
SGGeodesy.cxx
interpolater.cxx
leastsqs.cxx
project.cxx
sg_random.c
)
simgear_component(math math "${SOURCES}" "${HEADERS}")

View File

@@ -4,22 +4,29 @@ check_PROGRAMS = SGMathTest SGGeometryTest
TESTS = $(check_PROGRAMS)
SGMathTest_SOURCES = SGMathTest.cxx
SGMathTest_LDADD = libsgmath.a -lsgstructure $(base_LIBS)
SGMathTest_LDADD = \
libsgmath.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(base_LIBS)
SGGeometryTest_SOURCES = SGGeometryTest.cxx
SGGeometryTest_LDADD = libsgmath.a -lsgstructure $(base_LIBS)
SGGeometryTest_LDADD = \
libsgmath.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(base_LIBS)
lib_LIBRARIES = libsgmath.a
include_HEADERS = \
interpolater.hxx \
leastsqs.hxx \
point3d.hxx \
polar3d.hxx \
sg_geodesy.hxx \
sg_random.h \
sg_types.hxx \
vector.hxx \
Math.hxx \
SGBox.hxx \
SGCMath.hxx \
@@ -43,14 +50,15 @@ include_HEADERS = \
SGVec2.hxx \
SGVec3.hxx \
SGVec4.hxx \
beziercurve.hxx
beziercurve.hxx \
project.hxx
libsgmath_a_SOURCES = \
interpolater.cxx \
leastsqs.cxx \
sg_random.c \
vector.cxx \
SGGeod.cxx \
SGGeodesy.cxx
SGGeodesy.cxx \
project.cxx
INCLUDES = -I$(top_srcdir)

View File

@@ -22,6 +22,8 @@
#include <cmath>
#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include "SGMath.hxx"
// These are hard numbers from the WGS84 standard. DON'T MODIFY
@@ -509,15 +511,16 @@ SGGeodesy::advanceRadM(const SGGeoc& geoc, double course, double distance,
result.setLongitudeRad(geoc.getLongitudeRad());
} else {
double tmp = SGMiscd::clip(sin(course) * sinDistance / cosLat, -1, 1);
double lon = SGMiscd::normalizeAngle(geoc.getLongitudeRad() - asin( tmp ));
result.setLongitudeRad(lon);
double lon = SGMiscd::normalizeAngle(-geoc.getLongitudeRad() - asin( tmp ));
result.setLongitudeRad(-lon);
}
}
double
SGGeodesy::courseRad(const SGGeoc& from, const SGGeoc& to)
{
double diffLon = to.getLongitudeRad() - from.getLongitudeRad();
//double diffLon = to.getLongitudeRad() - from.getLongitudeRad();
double diffLon = from.getLongitudeRad() - to.getLongitudeRad();
double sinLatFrom = sin(from.getLatitudeRad());
double cosLatFrom = cos(from.getLatitudeRad());
@@ -559,3 +562,76 @@ SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to)
{
return distanceRad(from, to) * SG_RAD_TO_NM * SG_NM_TO_METER;
}
bool
SGGeodesy::radialIntersection(const SGGeoc& a, double r1,
const SGGeoc& b, double r2, SGGeoc& result)
{
// implementation of
// http://williams.best.vwh.net/avform.htm#Intersection
double crs13 = r1 * SG_DEGREES_TO_RADIANS;
double crs23 = r2 * SG_DEGREES_TO_RADIANS;
double dst12 = SGGeodesy::distanceRad(a, b);
//IF sin(lon2-lon1)<0
// crs12=acos((sin(lat2)-sin(lat1)*cos(dst12))/(sin(dst12)*cos(lat1)))
// crs21=2.*pi-acos((sin(lat1)-sin(lat2)*cos(dst12))/(sin(dst12)*cos(lat2)))
// ELSE
// crs12=2.*pi-acos((sin(lat2)-sin(lat1)*cos(dst12))/(sin(dst12)*cos(lat1)))
// crs21=acos((sin(lat1)-sin(lat2)*cos(dst12))/(sin(dst12)*cos(lat2)))
// ENDIF
double crs12 = SGGeodesy::courseRad(a, b),
crs21 = SGGeodesy::courseRad(b, a);
double sinLat1 = sin(a.getLatitudeRad());
double cosLat1 = cos(a.getLatitudeRad());
double sinDst12 = sin(dst12);
double cosDst12 = cos(dst12);
double ang1 = SGMiscd::normalizeAngle2(crs13-crs12);
double ang2 = SGMiscd::normalizeAngle2(crs21-crs23);
if ((sin(ang1) == 0.0) && (sin(ang2) == 0.0)) {
SG_LOG(SG_GENERAL, SG_WARN, "SGGeodesy::radialIntersection: infinity of intersections");
return false;
}
if ((sin(ang1)*sin(ang2))<0.0) {
SG_LOG(SG_GENERAL, SG_WARN, "SGGeodesy::radialIntersection: intersection ambiguous");
return false;
}
ang1 = fabs(ang1);
ang2 = fabs(ang2);
//ang3=acos(-cos(ang1)*cos(ang2)+sin(ang1)*sin(ang2)*cos(dst12))
//dst13=atan2(sin(dst12)*sin(ang1)*sin(ang2),cos(ang2)+cos(ang1)*cos(ang3))
//lat3=asin(sin(lat1)*cos(dst13)+cos(lat1)*sin(dst13)*cos(crs13))
//lon3=mod(lon1-dlon+pi,2*pi)-pi
double ang3 = acos(-cos(ang1) * cos(ang2) + sin(ang1) * sin(ang2) * cosDst12);
double dst13 = atan2(sinDst12 * sin(ang1) * sin(ang2), cos(ang2) + cos(ang1)*cos(ang3));
double lat3 = asin(sinLat1 * cos(dst13) + cosLat1 * sin(dst13) * cos(crs13));
//dlon=atan2(sin(crs13)*sin(dst13)*cos(lat1),cos(dst13)-sin(lat1)*sin(lat3))
double dlon = atan2(sin(crs13)*sin(dst13)*cosLat1, cos(dst13)- (sinLat1 * sin(lat3)));
double lon3 = SGMiscd::normalizeAngle(-a.getLongitudeRad()-dlon);
result = SGGeoc::fromRadM(-lon3, lat3, a.getRadiusM());
return true;
}
bool
SGGeodesy::radialIntersection(const SGGeod& a, double aRadial,
const SGGeod& b, double bRadial, SGGeod& result)
{
SGGeoc r;
bool ok = radialIntersection(SGGeoc::fromGeod(a), aRadial,
SGGeoc::fromGeod(b), bRadial, r);
if (!ok) {
return false;
}
result = SGGeod::fromGeoc(r);
return true;
}

View File

@@ -63,6 +63,16 @@ public:
static double courseRad(const SGGeoc& from, const SGGeoc& to);
static double distanceRad(const SGGeoc& from, const SGGeoc& to);
static double distanceM(const SGGeoc& from, const SGGeoc& to);
/**
* compute the intersection of two (true) radials (in degrees), or return false
* if no intersection culd be computed.
*/
static bool radialIntersection(const SGGeoc& a, double aRadial,
const SGGeoc& b, double bRadial, SGGeoc& result);
static bool radialIntersection(const SGGeod& a, double aRadial,
const SGGeod& b, double bRadial, SGGeod& result);
};
#endif

View File

@@ -79,6 +79,22 @@ Vec3Test(void)
return true;
}
template<typename T>
bool
isSameRotation(const SGQuat<T>& q1, const SGQuat<T>& q2)
{
const SGVec3<T> e1(1, 0, 0);
const SGVec3<T> e2(0, 1, 0);
const SGVec3<T> e3(0, 0, 1);
if (!equivalent(q1.transform(e1), q2.transform(e1)))
return false;
if (!equivalent(q1.transform(e2), q2.transform(e2)))
return false;
if (!equivalent(q1.transform(e3), q2.transform(e3)))
return false;
return true;
}
template<typename T>
bool
QuatTest(void)
@@ -94,7 +110,7 @@ QuatTest(void)
v2 = SGVec3<T>(1, -2, -3);
if (!equivalent(q1.transform(v1), v2))
return false;
// Check a rotation around the x axis
q1 = SGQuat<T>::fromAngleAxis(0.5*SGMisc<T>::pi(), e1);
v2 = SGVec3<T>(1, 3, -2);
@@ -106,7 +122,7 @@ QuatTest(void)
v2 = SGVec3<T>(-1, 2, -3);
if (!equivalent(q1.transform(v1), v2))
return false;
// Check a rotation around the y axis
q1 = SGQuat<T>::fromAngleAxis(0.5*SGMisc<T>::pi(), e2);
v2 = SGVec3<T>(-3, 2, 1);
@@ -153,15 +169,32 @@ QuatTest(void)
SGVec3<T> angleAxis;
q1.getAngleAxis(angleAxis);
q4 = SGQuat<T>::fromAngleAxis(angleAxis);
if (!equivalent(q1, q4))
if (!isSameRotation(q1, q4))
return false;
q2.getAngleAxis(angleAxis);
q4 = SGQuat<T>::fromAngleAxis(angleAxis);
if (!equivalent(q2, q4))
if (!isSameRotation(q2, q4))
return false;
q3.getAngleAxis(angleAxis);
q4 = SGQuat<T>::fromAngleAxis(angleAxis);
if (!equivalent(q3, q4))
if (!isSameRotation(q3, q4))
return false;
/// Test angle axis forward and back transform
q1 = SGQuat<T>::fromAngleAxis(0.2*SGMisc<T>::pi(), e1);
q2 = SGQuat<T>::fromAngleAxis(1.7*SGMisc<T>::pi(), e2);
q3 = q1*q2;
SGVec3<T> positiveAngleAxis = q1.getPositiveRealImag();
q4 = SGQuat<T>::fromPositiveRealImag(positiveAngleAxis);
if (!isSameRotation(q1, q4))
return false;
positiveAngleAxis = q2.getPositiveRealImag();
q4 = SGQuat<T>::fromPositiveRealImag(positiveAngleAxis);
if (!isSameRotation(q2, q4))
return false;
positiveAngleAxis = q3.getPositiveRealImag();
q4 = SGQuat<T>::fromPositiveRealImag(positiveAngleAxis);
if (!isSameRotation(q3, q4))
return false;
return true;
@@ -204,7 +237,7 @@ MatrixTest(void)
return false;
if (!equivalent(m3*m0, SGMatrix<T>::unit()))
return false;
return true;
}
@@ -238,104 +271,28 @@ GeodesyTest(void)
if (!equivalent(cart0, cart1))
return false;
return true;
}
bool
sgInterfaceTest(void)
{
SGVec3f v3f = SGVec3f::e2();
SGVec4f v4f = SGVec4f::e2();
SGQuatf qf = SGQuatf::fromEulerRad(1.2, 1.3, -0.4);
SGMatrixf mf;
mf.postMultTranslate(v3f);
mf.postMultRotate(qf);
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGVec3f tv3f;
sgVec3 sv3f;
sgCopyVec3(sv3f, v3f.sg());
sgCopyVec3(tv3f.sg(), sv3f);
if (tv3f != v3f)
return false;
// test course / advance routines
// uses examples from Williams aviation formulary
SGGeoc lax = SGGeoc::fromRadM(-2.066470, 0.592539, 10.0);
SGGeoc jfk = SGGeoc::fromRadM(-1.287762, 0.709186, 10.0);
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGVec4f tv4f;
sgVec4 sv4f;
sgCopyVec4(sv4f, v4f.sg());
sgCopyVec4(tv4f.sg(), sv4f);
if (tv4f != v4f)
return false;
double distNm = SGGeodesy::distanceRad(lax, jfk) * SG_RAD_TO_NM;
std::cout << "distance is " << distNm << std::endl;
if (0.5 < fabs(distNm - 2144)) // 2144 nm
return false;
double crsDeg = SGGeodesy::courseRad(lax, jfk) * SG_RADIANS_TO_DEGREES;
std::cout << "course is " << crsDeg << std::endl;
if (0.5 < fabs(crsDeg - 66)) // 66 degrees
return false;
SGGeoc adv;
SGGeodesy::advanceRadM(lax, crsDeg * SG_DEGREES_TO_RADIANS, 100 * SG_NM_TO_METER, adv);
std::cout << "lon:" << adv.getLongitudeRad() << ", lat:" << adv.getLatitudeRad() << std::endl;
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGQuatf tqf;
sgQuat sqf;
sgCopyQuat(sqf, qf.sg());
sgCopyQuat(tqf.sg(), sqf);
if (tqf != qf)
return false;
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGMatrixf tmf;
sgMat4 smf;
sgCopyMat4(smf, mf.sg());
sgCopyMat4(tmf.sg(), smf);
if (tmf != mf)
return false;
return true;
}
bool
sgdInterfaceTest(void)
{
SGVec3d v3d = SGVec3d::e2();
SGVec4d v4d = SGVec4d::e2();
SGQuatd qd = SGQuatd::fromEulerRad(1.2, 1.3, -0.4);
SGMatrixd md;
md.postMultTranslate(v3d);
md.postMultRotate(qd);
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGVec3d tv3d;
sgdVec3 sv3d;
sgdCopyVec3(sv3d, v3d.sg());
sgdCopyVec3(tv3d.sg(), sv3d);
if (tv3d != v3d)
return false;
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGVec4d tv4d;
sgdVec4 sv4d;
sgdCopyVec4(sv4d, v4d.sg());
sgdCopyVec4(tv4d.sg(), sv4d);
if (tv4d != v4d)
return false;
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGQuatd tqd;
sgdQuat sqd;
sgdCopyQuat(sqd, qd.sg());
sgdCopyQuat(tqd.sg(), sqd);
if (tqd != qd)
return false;
// Copy to and from plibs types check if result is equal,
// test for exact equality
SGMatrixd tmd;
sgdMat4 smd;
sgdCopyMat4(smd, md.sg());
sgdCopyMat4(tmd.sg(), smd);
if (tmd != md)
return false;
if (0.01 < fabs(adv.getLongitudeRad() - (-2.034206)) ||
0.01 < fabs(adv.getLatitudeRad() - 0.604180))
return false;
return true;
}
@@ -365,12 +322,6 @@ main(void)
if (!GeodesyTest())
return EXIT_FAILURE;
// Check interaction with sg*/sgd*
if (!sgInterfaceTest())
return EXIT_FAILURE;
if (!sgdInterfaceTest())
return EXIT_FAILURE;
std::cout << "Successfully passed all tests!" << std::endl;
return EXIT_SUCCESS;
}

View File

@@ -150,6 +150,17 @@ public:
return fromRealImag(cos(angle2), T(sin(angle2)/nAxis)*axis);
}
/// Create a normalized quaternion just from the imaginary part.
/// The imaginary part should point into that axis direction that results in
/// a quaternion with a positive real part.
/// This is the smallest numerically stable representation of an orientation
/// in space. See getPositiveRealImag()
static SGQuat fromPositiveRealImag(const SGVec3<T>& imag)
{
T r = sqrt(SGMisc<T>::max(T(0), T(1) - dot(imag, imag)));
return fromRealImag(r, imag);
}
/// Return a quaternion that rotates the from vector onto the to vector.
static SGQuat fromRotateTo(const SGVec3<T>& from, const SGVec3<T>& to)
{
@@ -326,6 +337,19 @@ public:
axis *= angle;
}
/// Get the imaginary part of the quaternion.
/// The imaginary part should point into that axis direction that results in
/// a quaternion with a positive real part.
/// This is the smallest numerically stable representation of an orientation
/// in space. See fromPositiveRealImag()
SGVec3<T> getPositiveRealImag() const
{
if (real(*this) < T(0))
return (T(-1)/norm(*this))*imag(*this);
else
return (T(1)/norm(*this))*imag(*this);
}
/// Access by index, the index is unchecked
const T& operator()(unsigned i) const
{ return data()[i]; }

View File

@@ -47,6 +47,12 @@ public:
SGVec3<T> getNormalizedDirection() const
{ return normalize(getDirection()); }
SGVec3<T> getClosestPointTo(const SGVec3<T>& point)
{
SGVec3<T> u(getNormalizedDirection()),
v(point - _origin);
return (dot(u, v) * u) + _origin;
}
private:
SGVec3<T> _origin;
SGVec3<T> _direction;

View File

@@ -1,438 +0,0 @@
/**
* \file point3d.hxx
* A 3d point class (depricated). This class is depricated and we are
* in the process of removing all usage of it in favor of plib's "sg"
* library of point, vector, and math routines. Plib's sg lib is less
* object oriented, but integrates more seamlessly with opengl.
*
* Adapted from algebra3 by Jean-Francois Doue, started October 1998.
*/
// 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _POINT3D_HXX
#define _POINT3D_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <ostream>
#include <istream>
#include <cassert>
#include <cmath>
#include "SGMath.hxx"
const double fgPoint3_Epsilon = 0.0000001;
enum {PX, PY, PZ}; // axes
// Kludge for msvc++ 6.0 - requires forward decls of friend functions.
class Point3D;
std::istream& operator>> ( std::istream&, Point3D& );
std::ostream& operator<< ( std::ostream&, const Point3D& );
Point3D operator- (const Point3D& p); // -p1
bool operator== (const Point3D& a, const Point3D& b); // p1 == p2?
/**
* 3D Point class.
*/
class Point3D {
protected:
double n[3];
public:
/** Default constructor */
Point3D();
Point3D(const double x, const double y, const double z);
explicit Point3D(const double d);
Point3D(const Point3D &p);
static Point3D fromSGGeod(const SGGeod& geod);
static Point3D fromSGGeoc(const SGGeoc& geoc);
static Point3D fromSGVec3(const SGVec3<double>& cart);
static Point3D fromSGVec3(const SGVec3<float>& cart);
static Point3D fromSGVec2(const SGVec2<double>& cart);
// Assignment operators
Point3D& operator = ( const Point3D& p ); // assignment of a Point3D
Point3D& operator += ( const Point3D& p ); // incrementation by a Point3D
Point3D& operator -= ( const Point3D& p ); // decrementation by a Point3D
Point3D& operator *= ( const double d ); // multiplication by a constant
Point3D& operator /= ( const double d ); // division by a constant
void setx(const double x);
void sety(const double y);
void setz(const double z);
void setlon(const double x);
void setlat(const double y);
void setradius(const double z);
void setelev(const double z);
// Queries
double& operator [] ( int i); // indexing
double operator[] (int i) const; // read-only indexing
inline const double *get_n() const { return n; };
double x() const; // cartesian x
double y() const; // cartesian y
double z() const; // cartesian z
double lon() const; // polar longitude
double lat() const; // polar latitude
double radius() const; // polar radius
double elev() const; // geodetic elevation (if specifying a surface point)
SGGeod toSGGeod(void) const;
SGGeoc toSGGeoc(void) const;
SGVec3d toSGVec3d(void) const;
SGVec3f toSGVec3f(void) const;
SGVec2f toSGVec2f(void) const;
// friends
friend Point3D operator - (const Point3D& p); // -p1
friend bool operator == (const Point3D& a, const Point3D& b); // p1 == p2?
friend std::istream& operator>> ( std::istream&, Point3D& );
friend std::ostream& operator<< ( std::ostream&, const Point3D& );
// Special functions
double distance3D(const Point3D& a) const; // distance between
double distance3Dsquared(const Point3D& a) const; // distance between ^ 2
};
// input from stream
inline std::istream&
operator >> ( std::istream& in, Point3D& p)
{
char c;
in >> p.n[PX];
// read past optional comma
while ( in.get(c) ) {
if ( (c != ' ') && (c != ',') ) {
// push back on the stream
in.putback(c);
break;
}
}
in >> p.n[PY];
// read past optional comma
while ( in.get(c) ) {
if ( (c != ' ') && (c != ',') ) {
// push back on the stream
in.putback(c);
break;
}
}
in >> p.n[PZ];
return in;
}
inline std::ostream&
operator<< ( std::ostream& out, const Point3D& p )
{
return out << p.n[PX] << ", " << p.n[PY] << ", " << p.n[PZ];
}
///////////////////////////
//
// Point3D Member functions
//
///////////////////////////
// CONSTRUCTORS
inline Point3D::Point3D()
{
n[PX] = n[PY] = 0.0;
n[PZ] = -9999.0;
}
inline Point3D::Point3D(const double x, const double y, const double z)
{
n[PX] = x; n[PY] = y; n[PZ] = z;
}
inline Point3D::Point3D(const double d)
{
n[PX] = n[PY] = n[PZ] = d;
}
inline Point3D::Point3D(const Point3D& p)
{
n[PX] = p.n[PX]; n[PY] = p.n[PY]; n[PZ] = p.n[PZ];
}
inline Point3D Point3D::fromSGGeod(const SGGeod& geod)
{
Point3D pt;
pt.setlon(geod.getLongitudeRad());
pt.setlat(geod.getLatitudeRad());
pt.setelev(geod.getElevationM());
return pt;
}
inline Point3D Point3D::fromSGGeoc(const SGGeoc& geoc)
{
Point3D pt;
pt.setlon(geoc.getLongitudeRad());
pt.setlat(geoc.getLatitudeRad());
pt.setradius(geoc.getRadiusM());
return pt;
}
inline Point3D Point3D::fromSGVec3(const SGVec3<double>& cart)
{
Point3D pt;
pt.setx(cart.x());
pt.sety(cart.y());
pt.setz(cart.z());
return pt;
}
inline Point3D Point3D::fromSGVec3(const SGVec3<float>& cart)
{
Point3D pt;
pt.setx(cart.x());
pt.sety(cart.y());
pt.setz(cart.z());
return pt;
}
inline Point3D Point3D::fromSGVec2(const SGVec2<double>& cart)
{
Point3D pt;
pt.setx(cart.x());
pt.sety(cart.y());
pt.setz(0);
return pt;
}
// ASSIGNMENT OPERATORS
inline Point3D& Point3D::operator = (const Point3D& p)
{
n[PX] = p.n[PX]; n[PY] = p.n[PY]; n[PZ] = p.n[PZ]; return *this;
}
inline Point3D& Point3D::operator += ( const Point3D& p )
{
n[PX] += p.n[PX]; n[PY] += p.n[PY]; n[PZ] += p.n[PZ]; return *this;
}
inline Point3D& Point3D::operator -= ( const Point3D& p )
{
n[PX] -= p.n[PX]; n[PY] -= p.n[PY]; n[PZ] -= p.n[PZ]; return *this;
}
inline Point3D& Point3D::operator *= ( const double d )
{
n[PX] *= d; n[PY] *= d; n[PZ] *= d; return *this;
}
inline Point3D& Point3D::operator /= ( const double d )
{
double d_inv = 1./d; n[PX] *= d_inv; n[PY] *= d_inv; n[PZ] *= d_inv;
return *this;
}
inline void Point3D::setx(const double x) {
n[PX] = x;
}
inline void Point3D::sety(const double y) {
n[PY] = y;
}
inline void Point3D::setz(const double z) {
n[PZ] = z;
}
inline void Point3D::setlon(const double x) {
n[PX] = x;
}
inline void Point3D::setlat(const double y) {
n[PY] = y;
}
inline void Point3D::setradius(const double z) {
n[PZ] = z;
}
inline void Point3D::setelev(const double z) {
n[PZ] = z;
}
// QUERIES
inline double& Point3D::operator [] ( int i)
{
assert(! (i < PX || i > PZ));
return n[i];
}
inline double Point3D::operator [] ( int i) const {
assert(! (i < PX || i > PZ));
return n[i];
}
inline double Point3D::x() const { return n[PX]; }
inline double Point3D::y() const { return n[PY]; }
inline double Point3D::z() const { return n[PZ]; }
inline double Point3D::lon() const { return n[PX]; }
inline double Point3D::lat() const { return n[PY]; }
inline double Point3D::radius() const { return n[PZ]; }
inline double Point3D::elev() const { return n[PZ]; }
inline SGGeod Point3D::toSGGeod(void) const
{
SGGeod geod;
geod.setLongitudeRad(lon());
geod.setLatitudeRad(lat());
geod.setElevationM(elev());
return geod;
}
inline SGGeoc Point3D::toSGGeoc(void) const
{
SGGeoc geoc;
geoc.setLongitudeRad(lon());
geoc.setLatitudeRad(lat());
geoc.setRadiusM(radius());
return geoc;
}
inline SGVec3d Point3D::toSGVec3d(void) const
{
return SGVec3d(x(), y(), z());
}
inline SGVec3f Point3D::toSGVec3f(void) const
{
return SGVec3f(x(), y(), z());
}
inline SGVec2f Point3D::toSGVec2f(void) const
{
return SGVec2f(x(), y());
}
// FRIENDS
inline Point3D operator - (const Point3D& a)
{
return Point3D(-a.n[PX],-a.n[PY],-a.n[PZ]);
}
inline Point3D operator + (const Point3D& a, const Point3D& b)
{
return Point3D(a) += b;
}
inline Point3D operator - (const Point3D& a, const Point3D& b)
{
return Point3D(a) -= b;
}
inline Point3D operator * (const Point3D& a, const double d)
{
return Point3D(a) *= d;
}
inline Point3D operator * (const double d, const Point3D& a)
{
return a*d;
}
inline Point3D operator / (const Point3D& a, const double d)
{
return Point3D(a) *= (1.0 / d );
}
inline bool operator == (const Point3D& a, const Point3D& b)
{
return
fabs(a.n[PX] - b.n[PX]) < fgPoint3_Epsilon &&
fabs(a.n[PY] - b.n[PY]) < fgPoint3_Epsilon &&
fabs(a.n[PZ] - b.n[PZ]) < fgPoint3_Epsilon;
}
inline bool operator != (const Point3D& a, const Point3D& b)
{
return !(a == b);
}
// Special functions
inline double
Point3D::distance3D(const Point3D& a ) const
{
double x, y, z;
x = n[PX] - a.n[PX];
y = n[PY] - a.n[PY];
z = n[PZ] - a.n[PZ];
return sqrt(x*x + y*y + z*z);
}
inline double
Point3D::distance3Dsquared(const Point3D& a ) const
{
double x, y, z;
x = n[PX] - a.n[PX];
y = n[PY] - a.n[PY];
z = n[PZ] - a.n[PZ];
return(x*x + y*y + z*z);
}
#endif // _POINT3D_HXX

View File

@@ -1,69 +0,0 @@
/**
* \file polar3d.hxx
* Routines to deal with polar math and transformations.
*/
// Written by Curtis Olson, started June 1997.
//
// 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _POLAR3D_HXX
#define _POLAR3D_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/math/point3d.hxx>
#include "SGMath.hxx"
/**
* Calculate new lon/lat given starting lon/lat, and offset radial, and
* distance. NOTE: starting point is specifed in radians, distance is
* specified in meters (and converted internally to radians)
* ... assumes a spherical world.
* @param orig specified in polar coordinates
* @param course offset radial
* @param dist offset distance
* @return destination point in polar coordinates
*/
inline Point3D calc_gc_lon_lat(const Point3D& orig, double course, double dist)
{ return Point3D::fromSGGeoc(orig.toSGGeoc().advanceRadM(course, dist)); }
/**
* Calculate course/dist given two spherical points.
* @param start starting point
* @param dest ending point
* @param course resulting course
* @param dist resulting distance
*/
inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
double *course, double *dist )
{
SGGeoc gs = start.toSGGeoc();
SGGeoc gd = dest.toSGGeoc();
*course = SGGeoc::courseRad(gs, gd);
*dist = SGGeoc::distanceM(gs, gd);
}
#endif // _POLAR3D_HXX

43
simgear/math/project.cxx Normal file
View File

@@ -0,0 +1,43 @@
// Copyright (C) 2010 Tim Moore moore@bricoworks.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "project.hxx"
#include <osg/Math>
#include <osg/Matrixd>
namespace simgear
{
GLint project(GLdouble objX, GLdouble objY, GLdouble objZ,
const GLdouble *model, const GLdouble *proj, const GLint *view,
GLdouble* winX, GLdouble* winY, GLdouble* winZ)
{
using namespace osg;
Vec4d obj(objX, objY, objZ, 1.0);
Matrixd Mmodel(model), Mproj(proj);
Matrixd Mwin = (Matrixd::translate(1.0, 1.0, 1.0)
* Matrixd::scale(0.5 * view[2], 0.5 * view[3], 0.5)
* Matrixd::translate(view[0], view[1], 0.0));
Vec4d result = obj * Mmodel * Mproj * Mwin;
if (equivalent(result.w(), 0.0))
return GL_FALSE;
result = result / result.w();
*winX = result.x(); *winY = result.y(); *winZ = result.z();
return GL_TRUE;
}
}

29
simgear/math/project.hxx Normal file
View File

@@ -0,0 +1,29 @@
// Copyright (C) 2010 Tim Moore moore@bricoworks.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef SIMGEAR_PROJECT_HXX
#define SIMGEAR_PROJECT_HXX 1
#include <osg/GL>
namespace simgear
{
// Replacement for gluProject. OSG doesn't link in GLU anymore.
extern GLint project(GLdouble objX, GLdouble objY, GLdouble objZ,
const GLdouble *model, const GLdouble *proj,
const GLint *view,
GLdouble* winX, GLdouble* winY, GLdouble* winZ);
}
#endif

View File

@@ -1,7 +1,6 @@
#ifndef _SG_GEODESY_HXX
#define _SG_GEODESY_HXX
#include <simgear/math/point3d.hxx>
#include "SGMath.hxx"
// Compatibility header.
@@ -52,21 +51,6 @@ inline void sgCartToGeod(const double* xyz, double* lat, double* lon, double* al
*alt = geod.getElevationM();
}
/**
* Convert a cartesian point to a geodetic lat/lon/altitude.
* Alternate form using Point3D objects.
*
* @param cartesian point
* @return geodetic point
*/
inline Point3D sgCartToGeod(const Point3D& p)
{
SGGeod geod;
SGGeodesy::SGCartToGeod(SGVec3<double>(p.x(), p.y(), p.z()), geod);
return Point3D::fromSGGeod(geod);
}
/**
* Convert a geodetic lat/lon/altitude to a cartesian point.
*
@@ -84,20 +68,6 @@ inline void sgGeodToCart(double lat, double lon, double alt, double* xyz)
xyz[2] = cart(2);
}
/**
* Convert a geodetic lat/lon/altitude to a cartesian point.
* Alternate form using Point3D objects.
*
* @param geodetic point
* @return cartesian point
*/
inline Point3D sgGeodToCart(const Point3D& geod)
{
SGVec3<double> cart;
SGGeodesy::SGGeodToCart(SGGeod::fromRadM(geod.lon(), geod.lat(), geod.elev()), cart);
return Point3D::fromSGVec3(cart);
}
/**
* Given a starting position and an offset radial and distance,
* calculate an ending positon on a wgs84 ellipsoid.

View File

@@ -38,28 +38,18 @@
#include <string>
#include <vector>
class Point3D;
using std::vector;
using std::string;
/** STL vector list of ints */
typedef vector < int > int_list;
typedef std::vector < int > int_list;
typedef int_list::iterator int_list_iterator;
typedef int_list::const_iterator const_int_list_iterator;
/** STL vector list of doubles */
typedef vector < double > double_list;
typedef std::vector < double > double_list;
typedef double_list::iterator double_list_iterator;
typedef double_list::const_iterator const_double_list_iterator;
/** STL vector list of Point3D */
typedef vector < Point3D > point_list;
typedef point_list::iterator point_list_iterator;
typedef point_list::const_iterator const_point_list_iterator;
/** STL vector list of strings */
typedef vector < string > string_list;
typedef std::vector < std::string > string_list;
typedef string_list::iterator string_list_iterator;
typedef string_list::const_iterator const_string_list_iterator;

View File

@@ -1,138 +0,0 @@
// vector.cxx -- additional vector routines
//
// Written by Curtis Olson, started December 1997.
//
// 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <math.h>
#include <stdio.h>
// #include <Include/fg_types.h>
#include "vector.hxx"
// calculate the projection, p, of u along the direction of d.
void sgProjection(sgVec3 p, const sgVec3 u, const sgVec3 d){
double denom = sgScalarProductVec3(d,d);
if (denom == 0.) sgCopyVec3(p, u);
else sgScaleVec3(p, d, sgScalarProductVec3(u,d) / denom);
}
// Same thing, except using double precision
void sgProjection(sgdVec3 p, const sgdVec3 u, const sgdVec3 d){
double denom = sgdScalarProductVec3(d,d);
if (denom == 0.) sgdCopyVec3(p, u);
else sgdScaleVec3(p, d, sgdScalarProductVec3(u,d) / denom);
}
// Given a point p, and a line through p0 with direction vector d,
// find the closest point (p1) on the line
void sgClosestPointToLine( sgVec3 p1, const sgVec3 p, const sgVec3 p0,
const sgVec3 d ) {
sgVec3 u, u1;
// u = p - p0
sgSubVec3(u, p, p0);
// calculate the projection, u1, of u along d.
sgProjection(u1, u, d);
// calculate the point p1 along the line that is closest to p
// p0 = p1 + u1
sgAddVec3(p1, p0, u1);
}
// Given a point p, and a line through p0 with direction vector d,
// find the closest point (p1) on the line
void sgdClosestPointToLine( sgdVec3 p1, const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d ) {
sgdVec3 u, u1;
// u = p - p0
sgdSubVec3(u, p, p0);
// calculate the projection, u1, of u along d.
sgProjection(u1, u, d);
// calculate the point p1 along the line that is closest to p
// p0 = p1 + u1
sgdAddVec3(p1, p0, u1);
}
// Given a point p, and a line through p0 with direction vector d,
// find the shortest distance (squared) from the point to the line
double sgClosestPointToLineDistSquared( const sgVec3 p, const sgVec3 p0,
const sgVec3 d ) {
sgVec3 u, u1, v;
// u = p - p0
sgSubVec3(u, p, p0);
// calculate the projection, u1, of u along d.
sgProjection(u1, u, d);
// v = u - u1 = vector from closest point on line, p1, to the
// original point, p.
sgSubVec3(v, u, u1);
return ( sgScalarProductVec3(v, v) );
}
// Given a point p, and a line through p0 with direction vector d,
// find the shortest distance (squared) from the point to the line
double sgdClosestPointToLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d ) {
sgdVec3 u, u1, v;
// u = p - p0
sgdSubVec3(u, p, p0);
// calculate the projection, u1, of u along d.
sgProjection(u1, u, d);
// v = u - u1 = vector from closest point on line, p1, to the
// original point, p.
sgdSubVec3(v, u, u1);
return ( sgdScalarProductVec3(v, v) );
}
// This is a quicker form of
// sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
// sgPostMultMat4( sgMat, sgTRANS );
void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans )
{
for( int i=0; i<4; i++) {
for( int j=0; j<3; j++ ) {
src[i][j] += (src[i][3] * trans[j]);
}
}
}

View File

@@ -1,175 +0,0 @@
/**
* \file vector.hxx
* Additional vector routines.
*/
// Written by Curtis Olson, started December 1997.
//
// 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _VECTOR_HXX
#define _VECTOR_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <plib/sg.h>
/**
* calculate the projection, p, of u along the direction of d.
* @param p (out) the projection
* @param u (in) the vector to be projected
* @param d (in) the direction onto which we project
*/
void sgProjection(sgVec3 p, const sgVec3 u, const sgVec3 d);
void sgProjection(sgdVec3 p, const sgdVec3 u, const sgdVec3 d);
/**
* Map i.e. project a vector onto a plane.
* @param normal (in) normal vector for the plane
* @param v0 (in) a point on the plane
* @param vec (in) the vector to map onto the plane
* @param result (out) the result vector
*/
inline void sgmap_vec_onto_cur_surface_plane( sgVec3 normal,
sgVec3 v0,
sgVec3 vec,
sgVec3 result )
{
sgVec3 u1, v, tmp;
// calculate a vector "u1" representing the shortest distance from
// the plane specified by normal and v0 to a point specified by
// "vec". "u1" represents both the direction and magnitude of
// this desired distance.
// u1 = ( (normal <dot> vec) / (normal <dot> normal) ) * normal
sgScaleVec3( u1,
normal,
( sgScalarProductVec3(normal, vec) /
sgScalarProductVec3(normal, normal)
)
);
// printf(" vec = %.2f, %.2f, %.2f\n", vec[0], vec[1], vec[2]);
// printf(" v0 = %.2f, %.2f, %.2f\n", v0[0], v0[1], v0[2]);
// printf(" u1 = %.2f, %.2f, %.2f\n", u1[0], u1[1], u1[2]);
// calculate the vector "v" which is the vector "vec" mapped onto
// the plane specified by "normal" and "v0".
// v = v0 + vec - u1
sgAddVec3(tmp, v0, vec);
sgSubVec3(v, tmp, u1);
// printf(" v = %.2f, %.2f, %.2f\n", v[0], v[1], v[2]);
// Calculate the vector "result" which is "v" - "v0" which is a
// directional vector pointing from v0 towards v
// result = v - v0
sgSubVec3(result, v, v0);
// printf(" result = %.2f, %.2f, %.2f\n",
// result[0], result[1], result[2]);
}
/**
* Copy and negate a vector.
* @param dst (out) result vector
* @param src (in) input vector
*/
inline void sgCopyNegateVec4( sgVec4 dst, sgVec4 src )
{
dst [ 0 ] = -src [ 0 ] ;
dst [ 1 ] = -src [ 1 ] ;
dst [ 2 ] = -src [ 2 ] ;
dst [ 3 ] = -src [ 3 ] ;
}
/**
* Given a point p, and a line through p0 with direction vector d,
* find the closest point (p1) on the line (float version).
* @param p1 (out) closest point to p on the line
* @param p (in) original point
* @param p0 (in) point on the line
* @param d (in) vector defining line direction
*/
void sgClosestPointToLine( sgVec3 p1, const sgVec3 p, const sgVec3 p0,
const sgVec3 d );
/**
* Given a point p, and a line through p0 with direction vector d,
* find the closest point (p1) on the line (double version).
* @param p1 (out) closest point to p on the line
* @param p (in) original point
* @param p0 (in) point on the line
* @param d (in) vector defining line direction
*/
void sgdClosestPointToLine( sgdVec3 p1, const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d );
/**
* Given a point p, and a line through p0 with direction vector d,
* find the shortest distance (squared) from the point to the line (float
* version.)
* @param p (in) original point
* @param p0 (in) point on the line
* @param d (in) vector defining line direction
* @return shortest distance (squared) from p to line
*/
double sgClosestPointToLineDistSquared( const sgVec3 p, const sgVec3 p0,
const sgVec3 d );
/**
* Given a point p, and a line through p0 with direction vector d,
* find the shortest distance (squared) from the point to the line (double
* version.)
* @param p (in) original point
* @param p0 (in) point on the line
* @param d (in) vector defining line direction
* @return shortest distance (squared) from p to line
*/
double sgdClosestPointToLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d );
/**
* This is same as:
*
* <li> sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
* <li> sgPostMultMat4( sgMat4 src, sgTRANS );
*
* @param src starting sgMat4 matrix
* @param trans translation vector
*/
void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans );
#endif // _VECTOR_HXX

View File

@@ -1,6 +0,0 @@
.deps
Makefile
Makefile.in
props_test
tabbed_value_test
swap_test

View File

@@ -0,0 +1,35 @@
include (SimGearComponent)
set(HEADERS
PathOptions.hxx
ResourceManager.hxx
interpolator.hxx
sg_dir.hxx
sg_path.hxx
sg_sleep.hxx
sgstream.hxx
stdint.hxx
stopwatch.hxx
strutils.hxx
tabbed_values.hxx
texcoord.hxx
zfstream.hxx
)
set(SOURCES
PathOptions.cxx
ResourceManager.cxx
interpolator.cxx
sg_dir.cxx
sg_path.cxx
sg_sleep.cxx
sgstream.cxx
strutils.cxx
tabbed_values.cxx
texcoord.cxx
zfstream.cxx
)
simgear_component(misc misc "${SOURCES}" "${HEADERS}")

View File

@@ -12,7 +12,10 @@ include_HEADERS = \
zfstream.hxx \
interpolator.hxx \
stdint.hxx \
PathOptions.hxx
PathOptions.hxx \
sg_dir.hxx \
ResourceManager.hxx \
sg_sleep.hxx
libsgmisc_a_SOURCES = \
sg_path.cxx \
@@ -22,7 +25,10 @@ libsgmisc_a_SOURCES = \
texcoord.cxx \
zfstream.cxx \
interpolator.cxx \
PathOptions.cxx
PathOptions.cxx \
sg_dir.cxx \
ResourceManager.cxx \
sg_sleep.cxx
#noinst_PROGRAMS = tabbed_value_test swap_test

View File

@@ -0,0 +1,104 @@
// ResourceManager.cxx -- manage finding resources by names/paths
// Copyright (C) 2010 James Turner
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <simgear_config.h>
#include <simgear/misc/ResourceManager.hxx>
namespace simgear
{
static ResourceManager* static_manager = NULL;
ResourceManager::ResourceManager()
{
}
ResourceManager* ResourceManager::instance()
{
if (!static_manager) {
static_manager = new ResourceManager();
}
return static_manager;
}
/**
* trivial provider using a fixed base path
*/
class BasePathProvider : public ResourceProvider
{
public:
BasePathProvider(const SGPath& aBase, int aPriority) :
ResourceProvider(aPriority),
_base(aBase)
{
}
virtual SGPath resolve(const std::string& aResource, SGPath&) const
{
SGPath p(_base, aResource);
return p.exists() ? p : SGPath();
}
private:
SGPath _base;
};
void ResourceManager::addBasePath(const SGPath& aPath, Priority aPriority)
{
addProvider(new BasePathProvider(aPath, aPriority));
}
void ResourceManager::addProvider(ResourceProvider* aProvider)
{
ProviderVec::iterator it = _providers.begin();
for (; it != _providers.end(); ++it) {
if (aProvider->priority() > (*it)->priority()) {
_providers.insert(it, aProvider);
return;
}
}
// fell out of the iteration, goes to the end of the vec
_providers.push_back(aProvider);
}
SGPath ResourceManager::findPath(const std::string& aResource, SGPath aContext)
{
if (!aContext.isNull()) {
SGPath r(aContext, aResource);
if (r.exists()) {
return r;
}
}
ProviderVec::iterator it = _providers.begin();
for (; it != _providers.end(); ++it) {
SGPath path = (*it)->resolve(aResource, aContext);
if (!path.isNull()) {
return path;
}
}
return SGPath();
}
} // of namespace simgear

View File

@@ -0,0 +1,93 @@
// ResourceManager.hxx -- manage finding resources by names/paths
// Copyright (C) 2010 James Turner
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef SG_RESOURCE_MANAGER_HXX
#define SG_RESOURCE_MANAGER_HXX
#include <vector>
#include <simgear/misc/sg_path.hxx>
namespace simgear
{
class ResourceProvider;
/**
* singleton management of resources
*/
class ResourceManager
{
public:
typedef enum {
PRIORITY_DEFAULT = 0,
PRIORITY_FALLBACK = -100,
PRIORITY_NORMAL = 100,
PRIORITY_HIGH = 1000
} Priority;
static ResourceManager* instance();
/**
* add a simple fixed resource location, to resolve against
*/
void addBasePath(const SGPath& aPath, Priority aPriority = PRIORITY_DEFAULT);
/**
*
*/
void addProvider(ResourceProvider* aProvider);
/**
* given a resource name (or path), find the appropriate real resource
* path.
* @param aContext an optional current location to resolve relative names
* against (e.g a current directory)
*/
SGPath findPath(const std::string& aResource, SGPath aContext = SGPath());
private:
ResourceManager();
typedef std::vector<ResourceProvider*> ProviderVec;
ProviderVec _providers;
};
class ResourceProvider
{
public:
virtual SGPath resolve(const std::string& aResource, SGPath& aContext) const = 0;
virtual int priority() const
{
return _priority;
}
protected:
ResourceProvider(int aPriority) :
_priority(aPriority)
{}
int _priority;
};
} // of simgear namespace
#endif // of header guard

181
simgear/misc/sg_dir.cxx Normal file
View File

@@ -0,0 +1,181 @@
// Written by James Turner, started July 2010.
//
// Copyright (C) 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <simgear/misc/sg_dir.hxx>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#else
# include <sys/types.h>
# include <dirent.h>
#endif
#include <simgear/debug/logstream.hxx>
#include <cstring>
#include <iostream>
namespace simgear
{
Dir::Dir(const SGPath& path) :
_path(path)
{
}
Dir::Dir(const Dir& rel, const SGPath& relPath) :
_path(rel.file(relPath.str()))
{
}
PathList Dir::children(int types, const std::string& nameFilter) const
{
PathList result;
if (types == 0) {
types = TYPE_FILE | TYPE_DIR | NO_DOT_OR_DOTDOT;
}
#ifdef _WIN32
std::string search(_path.str());
if (nameFilter.empty()) {
search += "\\*"; // everything
} else {
search += "\\*" + nameFilter;
}
WIN32_FIND_DATA fData;
HANDLE find = FindFirstFile(search.c_str(), &fData);
if (find == INVALID_HANDLE_VALUE) {
SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << _path.str());
return result;
}
bool done = false;
for (bool done = false; !done; done = (FindNextFile(find, &fData) == 0)) {
if (fData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) {
if (!(types & INCLUDE_HIDDEN)) {
continue;
}
}
if (fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (types & NO_DOT_OR_DOTDOT) {
if (!strcmp(fData.cFileName,".") || !strcmp(fData.cFileName,"..")) {
continue;
}
}
if (!(types & TYPE_DIR)) {
continue;
}
} else if ((fData.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) ||
(fData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
{
continue; // always ignore device files
} else if (!(types & TYPE_FILE)) {
continue;
}
result.push_back(file(fData.cFileName));
}
FindClose(find);
#else
DIR* dp = opendir(_path.c_str());
if (!dp) {
SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: opendir failed:" << _path.str());
return result;
}
int filterLen = nameFilter.size();
while (true) {
struct dirent* entry = readdir(dp);
if (!entry) {
break; // done iteration
}
// skip hidden files (names beginning with '.') unless requested
if (!(types & INCLUDE_HIDDEN) && (entry->d_name[0] == '.')) {
continue;
}
SGPath f = file(entry->d_name);
if (!f.exists()) {
continue; // stat() failed
}
if (f.isDir()) {
// directory handling
if (!(types & TYPE_DIR)) {
continue;
}
if (types & NO_DOT_OR_DOTDOT) {
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
}
} else if (f.isFile()) {
// regular file handling
if (!(types & TYPE_FILE)) {
continue;
}
} else {
// block device /fifo/char file, ignore
continue;
}
if (!nameFilter.empty()) {
int nameLen = strlen(entry->d_name);
if (nameLen < filterLen) {
continue; // name is shorter than the filter
}
char* nameSuffix = entry->d_name + (nameLen - filterLen);
if (strcmp(nameSuffix, nameFilter.c_str())) {
continue;
}
}
// passed all criteria, add to our result vector
result.push_back(file(entry->d_name));
}
closedir(dp);
#endif
return result;
}
bool Dir::exists() const
{
return _path.isDir();
}
SGPath Dir::file(const std::string& name) const
{
SGPath childPath = _path;
childPath.append(name);
return childPath;
}
} // of namespace simgear

67
simgear/misc/sg_dir.hxx Normal file
View File

@@ -0,0 +1,67 @@
// Written by James Turner, started July 2010.
//
// Copyright (C) 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _SG_DIR_HXX
#define _SG_DIR_HXX
#include <sys/types.h>
#include <simgear/compiler.h>
#include <string>
#include <simgear/math/sg_types.hxx>
#include <simgear/misc/sg_path.hxx>
namespace simgear
{
typedef std::vector<SGPath> PathList;
class Dir
{
public:
Dir(const SGPath& path);
Dir(const Dir& rel, const SGPath& relPath);
enum FileTypes
{
TYPE_FILE = 1,
TYPE_DIR = 2,
NO_DOT_OR_DOTDOT = 1 << 12,
INCLUDE_HIDDEN = 1 << 13
};
PathList children(int types = 0, const std::string& nameGlob = "") const;
SGPath file(const std::string& name) const;
/**
* Check that the directory at the path exists (and is a directory!)
*/
bool exists() const;
private:
mutable SGPath _path;
};
} // of namespace simgear
#endif // _SG_DIR_HXX

View File

@@ -28,12 +28,13 @@
#include <simgear/debug/logstream.hxx>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
#endif
#include "sg_path.hxx"
using std::string;
/**
* define directory path separators
@@ -49,9 +50,7 @@ static const char sgSearchPathSep = ':';
#endif
// If Unix, replace all ":" with "/". If MacOS, replace all "/" with
// ":" it should go without saying that neither of these characters
// should be used in file or directory names. In windoze, allow the
// If Unix, replace all ":" with "/". In windoze, allow the
// second character to be a ":" for things like c:\foo\bar
void
@@ -73,18 +72,47 @@ SGPath::fix()
// default constructor
SGPath::SGPath()
: path("")
: path(""),
_cached(false)
{
}
// create a path based on "path"
SGPath::SGPath( const std::string& p )
: path(p)
: path(p),
_cached(false)
{
fix();
}
// create a path based on "path" and a "subpath"
SGPath::SGPath( const SGPath& p, const std::string& r )
: path(p.path),
_cached(false)
{
append(r);
fix();
}
SGPath::SGPath(const SGPath& p) :
path(p.path),
_cached(p._cached),
_exists(p._exists),
_isDir(p._isDir),
_isFile(p._isFile)
{
}
SGPath& SGPath::operator=(const SGPath& p)
{
path = p.path;
_cached = p._cached;
_exists = p._exists;
_isDir = p._isDir;
_isFile = p._isFile;
return *this;
}
// destructor
SGPath::~SGPath() {
@@ -95,6 +123,7 @@ SGPath::~SGPath() {
void SGPath::set( const string& p ) {
path = p;
fix();
_cached = false;
}
@@ -109,6 +138,7 @@ void SGPath::append( const string& p ) {
path += p;
}
fix();
_cached = false;
}
//add a new path component to the existing path string
@@ -126,6 +156,7 @@ void SGPath::concat( const string& p ) {
path += p;
}
fix();
_cached = false;
}
@@ -172,13 +203,57 @@ string SGPath::extension() const {
}
}
bool SGPath::exists() const {
FILE* fp = fopen( path.c_str(), "r");
if (fp == 0) {
return false;
}
fclose(fp);
return true;
void SGPath::validate() const
{
if (_cached) {
return;
}
#ifdef _WIN32
struct _stat buf ;
bool remove_trailing = false;
if ( path.length() > 1 && path[path.length()-1] == '/' )
remove_trailing=true;
if (_stat (path.substr(0,remove_trailing?path.length()-1:path.length()).c_str(), &buf ) < 0) {
_exists = false;
} else {
_exists = true;
_isFile = ((S_IFREG & buf.st_mode ) !=0);
_isDir = ((S_IFDIR & buf.st_mode ) !=0);
}
#else
struct stat buf ;
if (stat(path.c_str(), &buf ) < 0) {
_exists = false;
} else {
_exists = true;
_isFile = ((S_ISREG(buf.st_mode )) != 0);
_isDir = ((S_ISDIR(buf.st_mode )) != 0);
}
#endif
_cached = true;
}
bool SGPath::exists() const
{
validate();
return _exists;
}
bool SGPath::isDir() const
{
validate();
return _exists && _isDir;
}
bool SGPath::isFile() const
{
validate();
return _exists && _isFile;
}
#ifdef _WIN32
@@ -268,3 +343,26 @@ string_list sgPathSplit( const string &search_path ) {
return result;
}
bool SGPath::isAbsolute() const
{
if (path.empty()) {
return false;
}
#ifdef _WIN32
// detect '[A-Za-z]:/'
if (path.size() > 2) {
if (isalpha(path[0]) && (path[1] == ':') && (path[2] == sgDirPathSep)) {
return true;
}
}
#endif
return (path[0] == sgDirPathSep);
}
bool SGPath::isNull() const
{
return path.empty() || (path == "");
}

View File

@@ -35,8 +35,6 @@
#include <simgear/math/sg_types.hxx>
using std::string;
#ifdef _MSC_VER
typedef int mode_t;
#endif
@@ -53,18 +51,30 @@ class SGPath {
private:
string path;
std::string path;
public:
/** Default constructor */
SGPath();
/** Copy contructor */
SGPath(const SGPath& p);
SGPath& operator=(const SGPath& p);
/**
* Construct a path based on the starting path provided.
* @param p initial path
*/
SGPath( const string& p );
SGPath( const std::string& p );
/**
* Construct a path based on the starting path provided and a relative subpath
* @param p initial path
* @param r relative subpath
*/
SGPath( const SGPath& p, const std::string& r );
/** Destructor */
~SGPath();
@@ -73,63 +83,63 @@ public:
* Set path to a new value
* @param p new path
*/
void set( const string& p );
void set( const std::string& p );
SGPath& operator= ( const char* p ) { this->set(p); return *this; }
/**
* Append another piece to the existing path. Inserts a path
* separator between the existing component and the new component.
* @param p additional path component */
void append( const string& p );
void append( const std::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 );
void add( const std::string& p );
/**
* Concatenate a string to the end of the path without inserting a
* path separator.
* @param p additional path suffix
*/
void concat( const string& p );
void concat( const std::string& p );
/**
* Get the file part of the path (everything after the last path sep)
* @return file string
*/
string file() const;
std::string file() const;
/**
* Get the directory part of the path.
* @return directory string
*/
string dir() const;
std::string dir() const;
/**
* Get the base part of the path (everything but the extension.)
* @return the base string
*/
string base() const;
std::string base() const;
/**
* Get the extension part of the path (everything after the final ".")
* @return the extension string
*/
string extension() const;
std::string extension() const;
/**
* Get the path string
* @return path string
*/
string str() const { return path; }
std::string str() const { return path; }
/**
* Get the path string
* @return path in "C" string (ptr to char array) form.
*/
const char* c_str() { return path.c_str(); }
const char* c_str() const { return path.c_str(); }
/**
* Determine if file exists by attempting to fopen it.
@@ -143,22 +153,46 @@ public:
*/
int create_dir(mode_t mode);
bool isFile() const;
bool isDir() const;
/**
* Opposite sense to isAbsolute
*/
bool isRelative() const { return !isAbsolute(); }
/**
* Is this an absolute path?
* I.e starts with a directory seperator, or a single character + colon
*/
bool isAbsolute() const;
/**
* check for default constructed path
*/
bool isNull() const;
private:
void fix();
void validate() const;
mutable bool _cached;
mutable bool _exists;
mutable bool _isDir;
mutable bool _isFile;
};
/**
* Split a directory string into a list of it's parent directories.
*/
string_list sgPathBranchSplit( const string &path );
string_list sgPathBranchSplit( const std::string &path );
/**
* Split a directory search path into a vector of individual paths
*/
string_list sgPathSplit( const string &search_path );
string_list sgPathSplit( const std::string &search_path );
#endif // _SG_PATH_HXX

60
simgear/misc/sg_sleep.cxx Normal file
View File

@@ -0,0 +1,60 @@
// Written by James Turner, started July 2010.
//
// Copyright (C) 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <simgear/misc/sg_sleep.hxx>
#ifdef SG_WINDOWS
# include <windows.h>
#else
# include <unistd.h>
#endif
namespace simgear
{
#ifdef SG_WINDOWS
void sleepForSeconds(int seconds)
{
Sleep(1000 * seconds);
}
void sleepForMSec(int msec)
{
Sleep(msec);
}
#else
void sleepForSeconds(int seconds)
{
::sleep(seconds);
}
void sleepForMSec(int msec)
{
::usleep(msec * 1000);
}
#endif
} // of namespace simhear

41
simgear/misc/sg_sleep.hxx Normal file
View File

@@ -0,0 +1,41 @@
// Written by James Turner, started July 2010.
//
// Copyright (C) 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _SG_SLEEP_HXX
#define _SG_SLEEP_HXX
#include <simgear/compiler.h>
namespace simgear
{
void sleepForSeconds(int seconds);
void sleepForMSec(int msec);
} // of namespace simgear
#endif // _SG_SLEEP_HXX

View File

@@ -131,10 +131,9 @@ namespace simgear {
static string
do_strip( const string& s, int striptype )
{
// if (s.empty())
// return s;
string::size_type len = s.length();
if( len == 0 ) // empty string is trivial
return s;
string::size_type i = 0;
if (striptype != RIGHTSTRIP)
{
@@ -183,5 +182,23 @@ namespace simgear {
return do_strip( s, BOTHSTRIP );
}
string
rpad( const string & s, string::size_type length, char c )
{
string::size_type l = s.length();
if( l >= length ) return s;
string reply = s;
return reply.append( length-l, c );
}
string
lpad( const string & s, size_t length, char c )
{
string::size_type l = s.length();
if( l >= length ) return s;
string reply = s;
return reply.insert( 0, length-l, c );
}
} // end namespace strutils
} // end namespace simgear

View File

@@ -64,6 +64,24 @@ namespace simgear {
std::string rstrip( const std::string& s );
std::string strip( const std::string& s );
/**
* Right-padding of a string to a given length
* @param s String to pad
* @param length The total length of the resulting string
* @param c The character to pad with
* @return The padded string
*/
std::string rpad( const std::string & s, size_t length, char c );
/**
* Left-padding of a string to a given length
* @param s String to pad
* @param length The total length of the resulting string
* @param c The character to pad with
* @return The padded string
*/
std::string lpad( const std::string & s, size_t length, char c );
/**
* Split a string into a words using 'sep' as the delimiter string.
* Produces a result similar to the perl and python functions of the

View File

@@ -149,7 +149,6 @@ enter this in the official comments in case I forget again. :-)
#include "texcoord.hxx"
#include <simgear/math/point3d.hxx>
// using std::cout;
// using std::endl;
@@ -160,28 +159,28 @@ enter this in the official comments in case I forget again. :-)
// return the basic unshifted/unmoded texture coordinate for a lat/lon
static inline Point3D basic_tex_coord( const Point3D& p,
static inline SGVec2f basic_tex_coord( const SGGeod& p,
double degree_width,
double degree_height,
double scale )
{
return Point3D( p.x() * ( degree_width * scale /
return SGVec2f( p.getLongitudeDeg() * ( degree_width * scale /
FG_STANDARD_TEXTURE_DIMENSION ),
p.y() * ( degree_height * scale /
FG_STANDARD_TEXTURE_DIMENSION ),
0.0 );
p.getLatitudeDeg() * ( degree_height * scale /
FG_STANDARD_TEXTURE_DIMENSION )
);
}
// traverse the specified fan/strip/list of vertices and attempt to
// calculate "none stretching" texture coordinates
point_list sgCalcTexCoords( const SGBucket& b, const point_list& geod_nodes,
std::vector<SGVec2f> sgCalcTexCoords( const SGBucket& b, const std::vector<SGGeod>& geod_nodes,
const int_list& fan, double scale )
{
return sgCalcTexCoords(b.get_center_lat(), geod_nodes, fan, scale);
}
point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
std::vector<SGVec2f> sgCalcTexCoords( double centerLat, const std::vector<SGGeod>& geod_nodes,
const int_list& fan, double scale )
{
// cout << "calculating texture coordinates for a specific fan of size = "
@@ -214,16 +213,16 @@ point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
// cout << "degree_height = " << degree_height << endl;
// find min/max of fan
Point3D tmin, tmax, p, t;
SGVec2f tmin, tmax;
bool first = true;
int i;
for ( i = 0; i < (int)fan.size(); ++i ) {
p = geod_nodes[ fan[i] ];
SGGeod p = geod_nodes[ fan[i] ];
// cout << "point p = " << p << endl;
t = basic_tex_coord( p, degree_width, degree_height, scale );
SGVec2f t = basic_tex_coord( p, degree_width, degree_height, scale );
// cout << "basic_tex_coord = " << t << endl;
if ( first ) {
@@ -231,16 +230,16 @@ point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
first = false;
} else {
if ( t.x() < tmin.x() ) {
tmin.setx( t.x() );
tmin.x() = t.x();
}
if ( t.y() < tmin.y() ) {
tmin.sety( t.y() );
tmin.y() = t.y();
}
if ( t.x() > tmax.x() ) {
tmax.setx( t.x() );
tmax.x() = t.x();
}
if ( t.y() > tmax.y() ) {
tmax.sety( t.y() );
tmax.y() = t.y();
}
}
}
@@ -256,30 +255,31 @@ point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
// but is the best we can do.
// cout << "SHIFTING" << endl;
if ( tmin.x() < 0 ) {
tmin.setx( (double)( (int)tmin.x() - 1 ) );
tmin.x() = (double)( (int)tmin.x() - 1 ) ;
} else {
tmin.setx( (int)tmin.x() );
tmin.x() = (int)tmin.x();
}
if ( tmin.y() < 0 ) {
tmin.sety( (double)( (int)tmin.y() - 1 ) );
tmin.y() = (double)( (int)tmin.y() - 1 );
} else {
tmin.sety( (int)tmin.y() );
tmin.y() = (int)tmin.y();
}
// cout << "found tmin = " << tmin << endl;
} else {
if ( tmin.x() < 0 ) {
tmin.setx( ( (int)(tmin.x() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD );
tmin.x() = ( (int)(tmin.x() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD ;
} else {
tmin.setx( ( (int)(tmin.x() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD );
tmin.x() = ( (int)(tmin.x() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD ;
}
if ( tmin.y() < 0 ) {
tmin.sety( ( (int)(tmin.y() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD );
tmin.y() = ( (int)(tmin.y() / HALF_MAX_TEX_COORD) - 1 )
* HALF_MAX_TEX_COORD ;
} else {
tmin.sety( ( (int)(tmin.y() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD );
tmin.y() = ( (int)(tmin.y() / HALF_MAX_TEX_COORD) )
* HALF_MAX_TEX_COORD ;
}
#if 0
// structure is small enough ... we can mod it so we can
@@ -319,12 +319,12 @@ point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
}
// generate tex_list
Point3D adjusted_t;
point_list tex;
SGVec2f adjusted_t;
std::vector<SGVec2f> tex;
tex.clear();
for ( i = 0; i < (int)fan.size(); ++i ) {
p = geod_nodes[ fan[i] ];
t = basic_tex_coord( p, degree_width, degree_height, scale );
SGGeod p = geod_nodes[ fan[i] ];
SGVec2f t = basic_tex_coord( p, degree_width, degree_height, scale );
// cout << "second t = " << t << endl;
adjusted_t = t - tmin;
@@ -342,12 +342,12 @@ point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
}
#endif
if ( adjusted_t.x() < SG_EPSILON ) {
adjusted_t.setx( 0.0 );
adjusted_t.x() = 0.0;
}
if ( adjusted_t.y() < SG_EPSILON ) {
adjusted_t.sety( 0.0 );
adjusted_t.y() = 0.0;
}
adjusted_t.setz( 0.0 );
// cout << "adjusted_t = " << adjusted_t << endl;
tex.push_back( adjusted_t );

View File

@@ -36,6 +36,9 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/math/sg_types.hxx>
#include <simgear/math/SGMathFwd.hxx>
#include <simgear/math/SGGeod.hxx>
#include <simgear/math/SGVec2.hxx>
/**
* Traverse the specified fan/strip/list of vertices and attempt to
@@ -46,10 +49,10 @@
* @param scale (default = 1.0) scaling factor
* @return list of texture coordinates
*/
point_list sgCalcTexCoords( const SGBucket& b, const point_list& geod_nodes,
std::vector<SGVec2f> sgCalcTexCoords( const SGBucket& b, const std::vector<SGGeod>& geod_nodes,
const int_list& fan, double scale = 1.0 );
point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
std::vector<SGVec2f> sgCalcTexCoords( double centerLat, const std::vector<SGGeod>& geod_nodes,
const int_list& fan, double scale = 1.0 );

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