RelativePath="..\..\simgear\math\localconsts.hxx"
>
</File>
- <File
- RelativePath="..\..\simgear\math\point3d.hxx"
- >
- </File>
- <File
- RelativePath="..\..\simgear\math\polar3d.hxx"
- >
- </File>
<File
RelativePath="..\..\simgear\math\sg_geodesy.hxx"
>
RelativePath="..\..\simgear\math\sphrintp.h"
>
</File>
- <File
- RelativePath="..\..\simgear\math\vector.cxx"
- >
- </File>
- <File
- RelativePath="..\..\simgear\math\vector.hxx"
- >
- </File>
</Filter>
<Filter
Name="Lib_sgmisc"
#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>
typedef struct {
- Point3D pt;
+ SGVec3d pt;
int depth;
int prev;
} lt_tree_seg;
~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];
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);
}
// 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) {
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;
- }
- }
-
}
#include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx>
+#include <simgear/math/SGGeometry.hxx>
#include "lowlevel.hxx"
#include "sg_binobj.hxx"
}
};
-
-// 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,
}
// 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());
}
// 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");
#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>
/** 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;
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; }
{ 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; }
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
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 \
interpolater.cxx \
leastsqs.cxx \
sg_random.c \
- vector.cxx \
SGGeod.cxx \
SGGeodesy.cxx
+++ /dev/null
-/**
- * \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
-
-
+++ /dev/null
-/**
- * \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
-
#ifndef _SG_GEODESY_HXX
#define _SG_GEODESY_HXX
-#include <simgear/math/point3d.hxx>
#include "SGMath.hxx"
// Compatibility header.
*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.
*
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.
#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;
+++ /dev/null
-// 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]);
- }
- }
-}
-
-
+++ /dev/null
-/**
- * \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
-
-
#include "texcoord.hxx"
-#include <simgear/math/point3d.hxx>
// using std::cout;
// using std::endl;
// 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 = "
// 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 ) {
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();
}
}
}
// 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
}
// 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;
}
#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 );
#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
* @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 );
#include <plib/sg.h>
-#include <simgear/math/vector.hxx>
-
#include "route.hxx"
# include <simgear_config.h>
#endif
-#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include "waypoint.hxx"
const SGPropertyNode *props)
{
// Gather the path(s) to the texture(s)
- vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
+ std::vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
for (unsigned int i = 0; i < textures.size(); i++)
{
string tname = textures[i]->getStringValue();
}
}
- vector<SGPropertyNode_ptr> texturesets = props->getChildren("texture-set");
+ std::vector<SGPropertyNode_ptr> texturesets = props->getChildren("texture-set");
for (unsigned int i = 0; i < texturesets.size(); i++)
{
_internal_state st( NULL, false, options );
- vector<SGPropertyNode_ptr> textures = texturesets[i]->getChildren("texture");
+ std::vector<SGPropertyNode_ptr> textures = texturesets[i]->getChildren("texture");
for (unsigned int j = 0; j < textures.size(); j++)
{
string tname = textures[j]->getStringValue();
if (props->hasChild("effect"))
effect = props->getStringValue("effect");
- vector<SGPropertyNode_ptr> object_group_nodes =
+ std::vector<SGPropertyNode_ptr> object_group_nodes =
((SGPropertyNode *)props)->getChildren("object-group");
for (unsigned int i = 0; i < object_group_nodes.size(); i++)
object_groups.push_back(new SGMatModelGroup(object_group_nodes[i]));
// read glyph table for taxi-/runway-signs
- vector<SGPropertyNode_ptr> glyph_nodes = props->getChildren("glyph");
+ std::vector<SGPropertyNode_ptr> glyph_nodes = props->getChildren("glyph");
for (unsigned int i = 0; i < glyph_nodes.size(); i++) {
const char *name = glyph_nodes[i]->getStringValue("name");
if (name)
}
// Note all the model paths
- vector <SGPropertyNode_ptr> path_nodes = node->getChildren("path");
+ std::vector <SGPropertyNode_ptr> path_nodes = node->getChildren("path");
for (unsigned int i = 0; i < path_nodes.size(); i++)
_paths.push_back(path_nodes[i]->getStringValue());
: _range_m(node->getDoubleValue("range-m", 2000))
{
// Load the object subnodes
- vector<SGPropertyNode_ptr> object_nodes =
+ std::vector<SGPropertyNode_ptr> object_nodes =
((SGPropertyNode *)node)->getChildren("object");
for (unsigned int i = 0; i < object_nodes.size(); i++) {
const SGPropertyNode * object_node = object_nodes[i];
#include <simgear/scene/model/model.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
-#include <simgear/math/polar3d.hxx>
#include "newcloud.hxx"
#include "cloudfield.hxx"
layer_coverage(SG_CLOUD_CLEAR),
scale(4000.0),
speed(0.0),
- direction(0.0),
- last_lon(0.0),
- last_lat(0.0)
+ direction(0.0)
{
// XXX
// Render bottoms before the rest of transparent objects (rendered
}
scale = 4000.0;
- last_lon = last_lat = -999.0f;
setTextureOffset(base);
// build the cloud layer
// now calculate update texture coordinates
- if ( last_lon < -900 ) {
- last_lon = lon;
- last_lat = lat;
+ SGGeod pos = SGGeod::fromRad(lon, lat);
+ if ( last_pos == SGGeod() ) {
+ last_pos = pos;
}
double sp_dist = speed*dt;
-
- if ( lon != last_lon || lat != last_lat || sp_dist != 0 ) {
- Point3D start( last_lon, last_lat, 0.0 );
- Point3D dest( lon, lat, 0.0 );
- double course = 0.0, dist = 0.0;
-
- calc_gc_course_dist( dest, start, &course, &dist );
- // cout << "course = " << course << ", dist = " << dist << endl;
+
+
+ if ( lon != last_pos.getLongitudeRad() || lat != last_pos.getLatitudeRad() || sp_dist != 0 ) {
+ double course = SGGeodesy::courseDeg(last_pos, pos) * SG_DEGREES_TO_RADIANS,
+ dist = SGGeodesy::distanceM(last_pos, pos);
// if start and dest are too close together,
// calc_gc_course_dist() can return a course of "nan". If
// cout << "base = " << base[0] << "," << base[1] << endl;
setTextureOffset(base);
- last_lon = lon;
- last_lat = lat;
+ last_pos = pos;
}
layer3D->reposition( p, up, lon, lat, dt, layer_asl);
// from winds, and to simulate the clouds being tied to ground
// position, not view position
// double xoff, yoff;
- double last_lon, last_lat, last_course;
+ SGGeod last_pos;
+ double last_course;
osg::Vec2 base;
#include <plib/sg.h>
#include <simgear/math/sg_random.h>
#include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
#include <algorithm>
#include <vector>
#include <simgear/misc/sg_path.hxx>
#include <simgear/structure/Singleton.hxx>
+#include <Simgear/math/SGMath.hxx>
using std::vector;
SGVec3f normals[latPoints][lonPoints];
SGVec3d rel[latPoints][lonPoints];
- point_list geod_nodes;
+ std::vector<SGGeod> geod_nodes;
osg::Vec3Array* vl;
osg::Vec3Array* nl;
}
// Calculate texture coordinates
- point_list geod_nodes(latPoints * lonPoints);
- VectorArrayAdapter<point_list> geodNodesArray(geod_nodes, lonPoints);
+ typedef std::vector<SGGeod> GeodVector;
+
+ GeodVector geod_nodes(latPoints * lonPoints);
+ VectorArrayAdapter<GeodVector> geodNodesArray(geod_nodes, lonPoints);
int_list rectangle(latPoints * lonPoints);
VectorArrayAdapter<int_list> rectArray(rectangle, lonPoints);
for (int j = 0; j < latPoints; j++) {
for (int i = 0; i < lonPoints; i++) {
- geodNodesArray(j, i) = Point3D(geod[j][i].getLongitudeDeg(),
- geod[j][i].getLatitudeDeg(),
- geod[j][i].getElevationM());
+ geodNodesArray(j, i) = geod[j][i];
rectArray(j, i) = j * 5 + i;
}
}
- point_list texs = sgCalcTexCoords( clat, geod_nodes, rectangle,
+
+ typedef std::vector<SGVec2f> Vec2Array;
+ Vec2Array texs = sgCalcTexCoords( clat, geod_nodes, rectangle,
1000.0 / tex_width );
- VectorArrayAdapter<point_list> texsArray(texs, lonPoints);
+
+
+ VectorArrayAdapter<Vec2Array> texsArray(texs, lonPoints);
for (int j = 0; j < latPoints; j++) {
for (int i = 0; i < lonPoints; ++i) {
vlArray(j, i) = toOsg(rel[j][i]);
nlArray(j, i) = toOsg(normals[j][i]);
- tlArray(j, i) = toOsg(texsArray(j, i).toSGVec2f());
+ tlArray(j, i) = toOsg(texsArray(j, i));
}
}
#include <map>
#include <simgear/bucket/newbucket.hxx>
-#include <simgear/math/point3d.hxx>
#include <simgear/scene/tgdb/TileEntry.hxx>
using std::map;
#include <string>
#include <simgear/bucket/newbucket.hxx>
-#include <simgear/math/point3d.hxx>
#include <simgear/misc/sg_path.hxx>
#include <osg/ref_ptr>
#include <strings.h>
#endif
-using std::string;
-using std::vector;
-
namespace simgear {
class ModelLoadHelper;
SGBucket tile_bucket;
std::string tileFileName;
- typedef vector < Point3D > point_list;
- typedef point_list::iterator point_list_iterator;
- typedef point_list::const_iterator const_point_list_iterator;
-
private:
// pointer to ssg range selector for this tile
if (!tile.read_bin(path))
return false;
- SGVec3d center = tile.get_gbs_center2();
+ SGVec3d center = tile.get_gbs_center();
SGGeod geodPos = SGGeod::fromCart(center);
SGQuatd hlOr = SGQuatd::fromLonLat(geodPos)*SGQuatd::fromEulerDeg(0, 0, 180);
#include <osgDB/Registry>
#include <simgear/sg_inlines.h>
-#include <simgear/math/point3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/scene/material/mat.hxx>