# 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
# pragma warning(disable: 4305) //
#include <cmath>
-#include <plib/sg.h>
+// Make sure PI is defined in its various forms
+#ifdef M_PI
+#define SGD_PI M_PI
+#define SG_PI M_PI
+#else
+#define SG_PI 3.1415926535f
+#define SGD_PI 3.1415926535
+#endif
-// Make sure PI is defined in its various forms
-// SG_PI and SGD_PI (float and double) come from plib/sg.h
/** 2 * PI */
-#define SGD_2PI 6.28318530717958647692
+#define SGD_2PI SGD_PI * 2.0
/** PI / 2 */
#ifdef M_PI_2
/** PI / 4 */
#define SGD_PI_4 0.78539816339744830961
+
+#define SGD_DEGREES_TO_RADIANS (SGD_PI/180.0)
+#define SGD_RADIANS_TO_DEGREES (180.0/SGD_PI)
+
+#define SG_DEGREES_TO_RADIANS SGD_DEGREES_TO_RADIANS
+#define SG_RADIANS_TO_DEGREES SGD_RADIANS_TO_DEGREES
+
/** \def SG_E "e" */
#ifdef M_E
# define SG_E M_E
#include <string>
#include <time.h>
+#include <cstring>
#include <simgear/io/sg_socket.hxx>
#include <simgear/debug/logstream.hxx>
#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
#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)
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",
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;
elapsed_time += delta_time;
min_time_before_lt -= delta_time;
dt = delta_time;
-
+#if 0
sgMat4 T1, LON, LAT;
sgVec3 axis;
sgSetCoord( &pos, TRANSFORM );
sgMakeCoordMat4( transform, &pos );
+ #endif
last_lon = lon;
last_lat = lat;
last_alt = alt;
}
}
-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() );
}
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) {
void SGLightning::lt_build(void) {
// OSGFIXME
return;
-
}
#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;
int cloudId;
};
-typedef vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
+typedef std::vector<SGWxRadarEcho> list_of_SGWxRadarEcho;
/**
* Visual environment helper class.
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;
/** 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,
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:
/**
* 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);
* 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;
list_of_SGWxRadarEcho *get_radar_echo(void);
- sgMat4 *get_transform(void) { return &transform; }
+ SGMatrixf *get_transform(void) { return &transform; }
};
extern SGEnviro sgEnviro;
#include <unistd.h>
#include <iostream>
+#include <cstdlib>
#include "sg_binobj.hxx"
#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)
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();
#include <stdio.h>
#include <time.h>
+#include <cstring>
+#include <cstdlib> // for system()
#include <vector>
#include <string>
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
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
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
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
#define _SG_BINOBJ_HXX
-#include <plib/sg.h>
-
#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/math/sg_types.hxx>
# include <simgear_config.h>
#endif
-#include <plib/sg.h>
-
#include "route.hxx"
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
#include "BVHMotionTransform.hxx"
#include "BVHVisitor.hxx"
// But anyway, almost all transforms in a scenegraph will
// have them equal to 1 ...
double r = norm(_toWorldReference.xformVec(SGVec3d(1, 0, 0)));
- r = std::max(r, norm(_toWorldReference.xformVec(SGVec3d(0, 1, 0))));
- r = std::max(r, norm(_toWorldReference.xformVec(SGVec3d(0, 0, 1))));
+ r = SGMiscd::max(r, norm(_toWorldReference.xformVec(SGVec3d(0, 1, 0))));
+ r = SGMiscd::max(r, norm(_toWorldReference.xformVec(SGVec3d(0, 0, 1))));
_toWorldAmplification = r;
r = norm(_toLocalReference.xformVec(SGVec3d(1, 0, 0)));
- r = std::max(r, norm(_toLocalReference.xformVec(SGVec3d(0, 1, 0))));
- r = std::max(r, norm(_toLocalReference.xformVec(SGVec3d(0, 0, 1))));
+ r = SGMiscd::max(r, norm(_toLocalReference.xformVec(SGVec3d(0, 1, 0))));
+ r = SGMiscd::max(r, norm(_toLocalReference.xformVec(SGVec3d(0, 0, 1))));
_toLocalAmplification = r;
}
#include "BVHSubTreeCollector.hxx"
#include <simgear/math/SGGeometry.hxx>
+#include <cassert>
#include "BVHNode.hxx"
#include "BVHGroup.hxx"
#include <algorithm>
//yuck
#include <cstring>
+#include <cassert>
#include <boost/bind.hpp>
#include <simgear/compiler.h>
-#include <plib/sg.h>
#include <simgear/math/sg_random.h>
#include <simgear/math/sg_geodesy.hxx>
float SGCloudField::fieldSize = 50000.0f;
double SGCloudField::timer_dt = 0.0;
float SGCloudField::view_distance = 20000.0f;
-sgVec3 SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y;
+SGVec3f SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y;
// reposition the cloud layer at the specified origin and orientation
bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon, double lat,
#ifndef _CLOUDFIELD_HXX
#define _CLOUDFIELD_HXX
-#include <plib/sg.h>
#include <simgear/compiler.h>
#include <vector>
class Cloud {
public:
SGNewCloud *aCloud;
- sgVec3 pos;
+ SGVec3f pos;
bool visible;
};
static const int QUADTREE_SIZE = 32;
// this is a relative position only, with that we can move all clouds at once
- sgVec3 relative_position;
+ SGVec3f relative_position;
// double lon, lat;
osg::ref_ptr<osg::Group> field_root;
double deltax, deltay, alt;
double last_course;
- sgSphere field_sphere;
float last_coverage;
float coverage;
SGGeoc cld_pos;
// visibility distance for clouds in meters
static float CloudVis;
- static sgVec3 view_vec, view_X, view_Y;
+ static SGVec3f view_vec, view_X, view_Y;
static float view_distance;
static double timer_dt;
#include <simgear/compiler.h>
-#include <plib/sg.h>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/PathOptions.hxx>
#ifndef _NEWCLOUD_HXX
#define _NEWCLOUD_HXX
-#include <plib/sg.h>
#include <simgear/compiler.h>
#include <string>
#include <vector>
#include <simgear/debug/logstream.hxx>
#include <iostream>
+#include <cstdlib>
#include <osg/Node>
#include <osg/Geometry>
#endif
#include <stdlib.h> // rand()
+#include <cstring>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
#endif
#include <string>
+#include <cstdlib>
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/math/SGMath.hxx>
-
/**
* manages everything we need to know for an individual audio sample
*/
# include <simgear_config.h>
#endif
-#include <stdlib.h> // rand()
+#include <cstdlib> // rand()
+#include <cstring>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
#include <iostream>
#include <algorithm>
+#include <cstring>
#include "soundmgr_openal.hxx"
#include <string>
#include <sstream>
#include <boost/bind.hpp>
+#include <cstring> // for strcmp
#include <simgear/props/props.hxx>
#include <cstdio>
#include <cstdlib>
#include <ctime>
+#include <cstring>
#include <string>
#include <errno.h>
#include <string.h>
#include <stdio.h>
+#include <cstdlib>
#include <simgear/structure/exception.hxx>