| SGGeoc.hxx | | SGGeoc.hxx | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| | | | |
| #include <simgear/constants.h> | | #include <simgear/constants.h> | |
| | | | |
| // #define SG_GEOC_NATIVE_DEGREE | | // #define SG_GEOC_NATIVE_DEGREE | |
| | | | |
| /// Class representing a geocentric location | | /// Class representing a geocentric location | |
| class SGGeoc { | | class SGGeoc { | |
| public: | | public: | |
| /// Default constructor, initializes the instance to lat = lon = lat = 0 | | /// Default constructor, initializes the instance to lat = lon = lat = 0 | |
| SGGeoc(void); | | SGGeoc(void); | |
|
| /// Initialize from a cartesian vector assumed to be in meters | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGGeoc(const SGVec3<double>& cart); | | | |
| /// Initialize from a geodetic position | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGGeoc(const SGGeod& geod); | | | |
| | | | |
| /// Factory from angular values in radians and radius in ft | | /// Factory from angular values in radians and radius in ft | |
| static SGGeoc fromRadFt(double lon, double lat, double radius); | | static SGGeoc fromRadFt(double lon, double lat, double radius); | |
| /// Factory from angular values in degrees and radius in ft | | /// Factory from angular values in degrees and radius in ft | |
| static SGGeoc fromDegFt(double lon, double lat, double radius); | | static SGGeoc fromDegFt(double lon, double lat, double radius); | |
| /// Factory from angular values in radians and radius in m | | /// Factory from angular values in radians and radius in m | |
| static SGGeoc fromRadM(double lon, double lat, double radius); | | static SGGeoc fromRadM(double lon, double lat, double radius); | |
| /// Factory from angular values in degrees and radius in m | | /// Factory from angular values in degrees and radius in m | |
| static SGGeoc fromDegM(double lon, double lat, double radius); | | static SGGeoc fromDegM(double lon, double lat, double radius); | |
|
| | | /// Factory to convert position from a cartesian position assumed to be | |
| | | /// in wgs84 measured in meters | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGGeoc fromCart(const SGVec3<double>& cart); | |
| | | /// Factory to convert position from a geodetic position | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGGeoc fromGeod(const SGGeod& geod); | |
| | | | |
| /// Return the geocentric longitude in radians | | /// Return the geocentric longitude in radians | |
| double getLongitudeRad(void) const; | | double getLongitudeRad(void) const; | |
| /// Set the geocentric longitude from the argument given in radians | | /// Set the geocentric longitude from the argument given in radians | |
| void setLongitudeRad(double lon); | | void setLongitudeRad(double lon); | |
| | | | |
| /// Return the geocentric longitude in degrees | | /// Return the geocentric longitude in degrees | |
| double getLongitudeDeg(void) const; | | double getLongitudeDeg(void) const; | |
| /// Set the geocentric longitude from the argument given in degrees | | /// Set the geocentric longitude from the argument given in degrees | |
| void setLongitudeDeg(double lon); | | void setLongitudeDeg(double lon); | |
| | | | |
| skipping to change at line 107 | | skipping to change at line 108 | |
| { | | { | |
| } | | } | |
| | | | |
| inline | | inline | |
| SGGeoc::SGGeoc(double lon, double lat, double radius) : | | SGGeoc::SGGeoc(double lon, double lat, double radius) : | |
| _lon(lon), _lat(lat), _radius(radius) | | _lon(lon), _lat(lat), _radius(radius) | |
| { | | { | |
| } | | } | |
| | | | |
| inline | | inline | |
|
| SGGeoc::SGGeoc(const SGVec3<double>& cart) | | | |
| { | | | |
| SGGeodesy::SGCartToGeoc(cart, *this); | | | |
| } | | | |
| | | | |
| inline | | | |
| SGGeoc::SGGeoc(const SGGeod& geod) | | | |
| { | | | |
| SGVec3<double> cart; | | | |
| SGGeodesy::SGGeodToCart(geod, cart); | | | |
| SGGeodesy::SGCartToGeoc(cart, *this); | | | |
| } | | | |
| | | | |
| inline | | | |
| SGGeoc | | SGGeoc | |
| SGGeoc::fromRadFt(double lon, double lat, double radius) | | SGGeoc::fromRadFt(double lon, double lat, double radius) | |
| { | | { | |
| #ifdef SG_GEOC_NATIVE_DEGREE | | #ifdef SG_GEOC_NATIVE_DEGREE | |
| return SGGeoc(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES, | | return SGGeoc(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES, | |
| radius*SG_FEET_TO_METER); | | radius*SG_FEET_TO_METER); | |
| #else | | #else | |
| return SGGeoc(lon, lat, radius*SG_FEET_TO_METER); | | return SGGeoc(lon, lat, radius*SG_FEET_TO_METER); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| skipping to change at line 169 | | skipping to change at line 156 | |
| { | | { | |
| #ifdef SG_GEOC_NATIVE_DEGREE | | #ifdef SG_GEOC_NATIVE_DEGREE | |
| return SGGeoc(lon, lat, radius); | | return SGGeoc(lon, lat, radius); | |
| #else | | #else | |
| return SGGeoc(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, | | return SGGeoc(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, | |
| radius); | | radius); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| inline | | inline | |
|
| | | SGGeoc | |
| | | SGGeoc::fromCart(const SGVec3<double>& cart) | |
| | | { | |
| | | SGGeoc geoc; | |
| | | SGGeodesy::SGCartToGeoc(cart, geoc); | |
| | | return geoc; | |
| | | } | |
| | | | |
| | | inline | |
| | | SGGeoc | |
| | | SGGeoc::fromGeod(const SGGeod& geod) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeodToCart(geod, cart); | |
| | | SGGeoc geoc; | |
| | | SGGeodesy::SGCartToGeoc(cart, geoc); | |
| | | return geoc; | |
| | | } | |
| | | | |
| | | inline | |
| double | | double | |
| SGGeoc::getLongitudeRad(void) const | | SGGeoc::getLongitudeRad(void) const | |
| { | | { | |
| #ifdef SG_GEOC_NATIVE_DEGREE | | #ifdef SG_GEOC_NATIVE_DEGREE | |
| return _lon*SGD_DEGREES_TO_RADIANS; | | return _lon*SGD_DEGREES_TO_RADIANS; | |
| #else | | #else | |
| return _lon; | | return _lon; | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| | | | |
End of changes. 4 change blocks. |
| 20 lines changed or deleted | | 27 lines changed or added | |
|
| SGGeod.hxx | | SGGeod.hxx | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| | | | |
| #include <simgear/constants.h> | | #include <simgear/constants.h> | |
| | | | |
| // #define SG_GEOD_NATIVE_DEGREE | | // #define SG_GEOD_NATIVE_DEGREE | |
| | | | |
| /// Class representing a geodetic location | | /// Class representing a geodetic location | |
| class SGGeod { | | class SGGeod { | |
| public: | | public: | |
| /// Default constructor, initializes the instance to lat = lon = elev = 0 | | /// Default constructor, initializes the instance to lat = lon = elev = 0 | |
| SGGeod(void); | | SGGeod(void); | |
|
| /// Initialize from a cartesian vector assumed to be in meters | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGGeod(const SGVec3<double>& cart); | | | |
| /// Initialize from a geocentric position | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGGeod(const SGGeoc& geoc); | | | |
| | | | |
| /// Factory from angular values in radians and elevation is 0 | | /// Factory from angular values in radians and elevation is 0 | |
| static SGGeod fromRad(double lon, double lat); | | static SGGeod fromRad(double lon, double lat); | |
| /// Factory from angular values in degrees and elevation is 0 | | /// Factory from angular values in degrees and elevation is 0 | |
| static SGGeod fromDeg(double lon, double lat); | | static SGGeod fromDeg(double lon, double lat); | |
| /// Factory from angular values in radians and elevation in ft | | /// Factory from angular values in radians and elevation in ft | |
| static SGGeod fromRadFt(double lon, double lat, double elevation); | | static SGGeod fromRadFt(double lon, double lat, double elevation); | |
| /// Factory from angular values in degrees and elevation in ft | | /// Factory from angular values in degrees and elevation in ft | |
| static SGGeod fromDegFt(double lon, double lat, double elevation); | | static SGGeod fromDegFt(double lon, double lat, double elevation); | |
| /// Factory from angular values in radians and elevation in m | | /// Factory from angular values in radians and elevation in m | |
| static SGGeod fromRadM(double lon, double lat, double elevation); | | static SGGeod fromRadM(double lon, double lat, double elevation); | |
| /// Factory from angular values in degrees and elevation in m | | /// Factory from angular values in degrees and elevation in m | |
| static SGGeod fromDegM(double lon, double lat, double elevation); | | static SGGeod fromDegM(double lon, double lat, double elevation); | |
|
| | | /// Factory to convert position from a cartesian position assumed to be | |
| | | /// in wgs84 measured in meters | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGGeod fromCart(const SGVec3<double>& cart); | |
| | | /// Factory to convert position from a geocentric position | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGGeod fromGeoc(const SGGeoc& geoc); | |
| | | | |
| /// Return the geodetic longitude in radians | | /// Return the geodetic longitude in radians | |
| double getLongitudeRad(void) const; | | double getLongitudeRad(void) const; | |
| /// Set the geodetic longitude from the argument given in radians | | /// Set the geodetic longitude from the argument given in radians | |
| void setLongitudeRad(double lon); | | void setLongitudeRad(double lon); | |
| | | | |
| /// Return the geodetic longitude in degrees | | /// Return the geodetic longitude in degrees | |
| double getLongitudeDeg(void) const; | | double getLongitudeDeg(void) const; | |
| /// Set the geodetic longitude from the argument given in degrees | | /// Set the geodetic longitude from the argument given in degrees | |
| void setLongitudeDeg(double lon); | | void setLongitudeDeg(double lon); | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 112 | |
| { | | { | |
| } | | } | |
| | | | |
| inline | | inline | |
| SGGeod::SGGeod(double lon, double lat, double elevation) : | | SGGeod::SGGeod(double lon, double lat, double elevation) : | |
| _lon(lon), _lat(lat), _elevation(elevation) | | _lon(lon), _lat(lat), _elevation(elevation) | |
| { | | { | |
| } | | } | |
| | | | |
| inline | | inline | |
|
| SGGeod::SGGeod(const SGVec3<double>& cart) | | | |
| { | | | |
| SGGeodesy::SGCartToGeod(cart, *this); | | | |
| } | | | |
| | | | |
| inline | | | |
| SGGeod::SGGeod(const SGGeoc& geoc) | | | |
| { | | | |
| SGVec3<double> cart; | | | |
| SGGeodesy::SGGeocToCart(geoc, cart); | | | |
| SGGeodesy::SGCartToGeod(cart, *this); | | | |
| } | | | |
| | | | |
| inline | | | |
| SGGeod | | SGGeod | |
| SGGeod::fromRad(double lon, double lat) | | SGGeod::fromRad(double lon, double lat) | |
| { | | { | |
| #ifdef SG_GEOD_NATIVE_DEGREE | | #ifdef SG_GEOD_NATIVE_DEGREE | |
| return SGGeod(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES, 0); | | return SGGeod(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES, 0); | |
| #else | | #else | |
| return SGGeod(lon, lat, 0); | | return SGGeod(lon, lat, 0); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 195 | | skipping to change at line 182 | |
| { | | { | |
| #ifdef SG_GEOD_NATIVE_DEGREE | | #ifdef SG_GEOD_NATIVE_DEGREE | |
| return SGGeod(lon, lat, elevation); | | return SGGeod(lon, lat, elevation); | |
| #else | | #else | |
| return SGGeod(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, | | return SGGeod(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, | |
| elevation); | | elevation); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| inline | | inline | |
|
| | | SGGeod | |
| | | SGGeod::fromCart(const SGVec3<double>& cart) | |
| | | { | |
| | | SGGeod geod; | |
| | | SGGeodesy::SGCartToGeod(cart, geod); | |
| | | return geod; | |
| | | } | |
| | | | |
| | | inline | |
| | | SGGeod | |
| | | SGGeod::fromGeoc(const SGGeoc& geoc) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeocToCart(geoc, cart); | |
| | | SGGeod geod; | |
| | | SGGeodesy::SGCartToGeod(cart, geod); | |
| | | return geod; | |
| | | } | |
| | | | |
| | | inline | |
| double | | double | |
| SGGeod::getLongitudeRad(void) const | | SGGeod::getLongitudeRad(void) const | |
| { | | { | |
| #ifdef SG_GEOD_NATIVE_DEGREE | | #ifdef SG_GEOD_NATIVE_DEGREE | |
| return _lon*SGD_DEGREES_TO_RADIANS; | | return _lon*SGD_DEGREES_TO_RADIANS; | |
| #else | | #else | |
| return _lon; | | return _lon; | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| | | | |
End of changes. 4 change blocks. |
| 20 lines changed or deleted | | 27 lines changed or added | |
|
| SGMatrix.hxx | | SGMatrix.hxx | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
| | | | |
| #ifndef SGMatrix_H | | #ifndef SGMatrix_H | |
| #define SGMatrix_H | | #define SGMatrix_H | |
| | | | |
| /// Expression templates for poor programmers ... :) | | /// Expression templates for poor programmers ... :) | |
| template<typename T> | | template<typename T> | |
| struct TransNegRef; | | struct TransNegRef; | |
| | | | |
|
| template<typename T> | | | |
| class SGMatrix; | | | |
| | | | |
| /// 3D Matrix Class | | /// 3D Matrix Class | |
| template<typename T> | | template<typename T> | |
| class SGMatrix { | | class SGMatrix { | |
| public: | | public: | |
| enum { nCols = 4, nRows = 4, nEnts = 16 }; | | enum { nCols = 4, nRows = 4, nEnts = 16 }; | |
| typedef T value_type; | | typedef T value_type; | |
| | | | |
| /// Default constructor. Does not initialize at all. | | /// Default constructor. Does not initialize at all. | |
| /// If you need them zero initialized, use SGMatrix::zeros() | | /// If you need them zero initialized, use SGMatrix::zeros() | |
| SGMatrix(void) | | SGMatrix(void) | |
| | | | |
| skipping to change at line 574 | | skipping to change at line 571 | |
| std::basic_ostream<char_type, traits_type>& | | std::basic_ostream<char_type, traits_type>& | |
| operator<<(std::basic_ostream<char_type, traits_type>& s, const SGMatrix<T>
& m) | | operator<<(std::basic_ostream<char_type, traits_type>& s, const SGMatrix<T>
& m) | |
| { | | { | |
| s << "[ " << m(0,0) << ", " << m(0,1) << ", " << m(0,2) << ", " << m(0,3)
<< "\n"; | | s << "[ " << m(0,0) << ", " << m(0,1) << ", " << m(0,2) << ", " << m(0,3)
<< "\n"; | |
| s << " " << m(1,0) << ", " << m(1,1) << ", " << m(1,2) << ", " << m(1,3)
<< "\n"; | | s << " " << m(1,0) << ", " << m(1,1) << ", " << m(1,2) << ", " << m(1,3)
<< "\n"; | |
| s << " " << m(2,0) << ", " << m(2,1) << ", " << m(2,2) << ", " << m(2,3)
<< "\n"; | | s << " " << m(2,0) << ", " << m(2,1) << ", " << m(2,2) << ", " << m(2,3)
<< "\n"; | |
| s << " " << m(3,0) << ", " << m(3,1) << ", " << m(3,2) << ", " << m(3,3)
<< " ]"; | | s << " " << m(3,0) << ", " << m(3,1) << ", " << m(3,2) << ", " << m(3,3)
<< " ]"; | |
| return s; | | return s; | |
| } | | } | |
| | | | |
|
| /// Two classes doing actually the same on different types | | | |
| typedef SGMatrix<float> SGMatrixf; | | | |
| typedef SGMatrix<double> SGMatrixd; | | | |
| | | | |
| inline | | inline | |
| SGMatrixf | | SGMatrixf | |
| toMatrixf(const SGMatrixd& m) | | toMatrixf(const SGMatrixd& m) | |
| { | | { | |
| return SGMatrixf((float)m(0,0), (float)m(0,1), (float)m(0,2), (float)m(0,
3), | | return SGMatrixf((float)m(0,0), (float)m(0,1), (float)m(0,2), (float)m(0,
3), | |
| (float)m(1,0), (float)m(1,1), (float)m(1,2), (float)m(1,
3), | | (float)m(1,0), (float)m(1,1), (float)m(1,2), (float)m(1,
3), | |
| (float)m(3,0), (float)m(2,1), (float)m(2,2), (float)m(2,
3), | | (float)m(3,0), (float)m(2,1), (float)m(2,2), (float)m(2,
3), | |
| (float)m(4,0), (float)m(4,1), (float)m(4,2), (float)m(4,
3)); | | (float)m(4,0), (float)m(4,1), (float)m(4,2), (float)m(4,
3)); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 7 lines changed or deleted | | 0 lines changed or added | |
|
| SGQuat.hxx | | SGQuat.hxx | |
| | | | |
| skipping to change at line 21 | | skipping to change at line 21 | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
| | | | |
| #ifndef SGQuat_H | | #ifndef SGQuat_H | |
| #define SGQuat_H | | #define SGQuat_H | |
| | | | |
|
| | | #ifdef min | |
| | | #undef min | |
| | | #endif | |
| | | | |
| | | #ifdef max | |
| | | #undef max | |
| | | #endif | |
| | | | |
| /// 3D Vector Class | | /// 3D Vector Class | |
| template<typename T> | | template<typename T> | |
| class SGQuat { | | class SGQuat { | |
| public: | | public: | |
| typedef T value_type; | | typedef T value_type; | |
| | | | |
| /// Default constructor. Does not initialize at all. | | /// Default constructor. Does not initialize at all. | |
| /// If you need them zero initialized, SGQuat::zeros() | | /// If you need them zero initialized, SGQuat::zeros() | |
| SGQuat(void) | | SGQuat(void) | |
| { | | { | |
| | | | |
| skipping to change at line 113 | | skipping to change at line 121 | |
| q.y() = Czd2*Syd2; | | q.y() = Czd2*Syd2; | |
| q.z() = Szd2*Cyd2; | | q.z() = Szd2*Cyd2; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| /// Return a quaternion rotation the the horizontal local frame from give
n | | /// Return a quaternion rotation the the horizontal local frame from give
n | |
| /// longitude and latitude | | /// longitude and latitude | |
| static SGQuat fromLonLatDeg(T lon, T lat) | | static SGQuat fromLonLatDeg(T lon, T lat) | |
| { return fromLonLatRad(SGMisc<T>::deg2rad(lon), SGMisc<T>::deg2rad(lat));
} | | { return fromLonLatRad(SGMisc<T>::deg2rad(lon), SGMisc<T>::deg2rad(lat));
} | |
| | | | |
|
| | | /// Return a quaternion rotation the the horizontal local frame from give | |
| | | n | |
| | | /// longitude and latitude | |
| | | static SGQuat fromLonLat(const SGGeod& geod) | |
| | | { return fromLonLatRad(geod.getLongitudeRad(), geod.getLatitudeRad()); } | |
| | | | |
| /// Create a quaternion from the angle axis representation | | /// Create a quaternion from the angle axis representation | |
| static SGQuat fromAngleAxis(T angle, const SGVec3<T>& axis) | | static SGQuat fromAngleAxis(T angle, const SGVec3<T>& axis) | |
| { | | { | |
| T angle2 = 0.5*angle; | | T angle2 = 0.5*angle; | |
| return fromRealImag(cos(angle2), T(sin(angle2))*axis); | | return fromRealImag(cos(angle2), T(sin(angle2))*axis); | |
| } | | } | |
| | | | |
| /// Create a quaternion from the angle axis representation | | /// Create a quaternion from the angle axis representation | |
| static SGQuat fromAngleAxisDeg(T angle, const SGVec3<T>& axis) | | static SGQuat fromAngleAxisDeg(T angle, const SGVec3<T>& axis) | |
| { return fromAngleAxis(SGMisc<T>::deg2rad(angle), axis); } | | { return fromAngleAxis(SGMisc<T>::deg2rad(angle), axis); } | |
| | | | |
| skipping to change at line 555 | | skipping to change at line 568 | |
| return scale0*src + signCosPhi*scale1*dst; | | return scale0*src + signCosPhi*scale1*dst; | |
| } | | } | |
| | | | |
| /// Output to an ostream | | /// Output to an ostream | |
| template<typename char_type, typename traits_type, typename T> | | template<typename char_type, typename traits_type, typename T> | |
| inline | | inline | |
| std::basic_ostream<char_type, traits_type>& | | std::basic_ostream<char_type, traits_type>& | |
| operator<<(std::basic_ostream<char_type, traits_type>& s, const SGQuat<T>&
v) | | operator<<(std::basic_ostream<char_type, traits_type>& s, const SGQuat<T>&
v) | |
| { return s << "[ " << v(0) << ", " << v(1) << ", " << v(2) << ", " << v(3)
<< " ]"; } | | { return s << "[ " << v(0) << ", " << v(1) << ", " << v(2) << ", " << v(3)
<< " ]"; } | |
| | | | |
|
| /// Two classes doing actually the same on different types | | | |
| typedef SGQuat<float> SGQuatf; | | | |
| typedef SGQuat<double> SGQuatd; | | | |
| | | | |
| inline | | inline | |
| SGQuatf | | SGQuatf | |
| toQuatf(const SGQuatd& v) | | toQuatf(const SGQuatd& v) | |
| { return SGQuatf((float)v(0), (float)v(1), (float)v(2), (float)v(3)); } | | { return SGQuatf((float)v(0), (float)v(1), (float)v(2), (float)v(3)); } | |
| | | | |
| inline | | inline | |
| SGQuatd | | SGQuatd | |
| toQuatd(const SGQuatf& v) | | toQuatd(const SGQuatf& v) | |
| { return SGQuatd(v(0), v(1), v(2), v(3)); } | | { return SGQuatd(v(0), v(1), v(2), v(3)); } | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 4 lines changed or deleted | | 14 lines changed or added | |
|
| SGVec3.hxx | | SGVec3.hxx | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 46 | |
| _data[i] = SGLimits<T>::quiet_NaN(); | | _data[i] = SGLimits<T>::quiet_NaN(); | |
| #endif | | #endif | |
| } | | } | |
| /// Constructor. Initialize by the given values | | /// Constructor. Initialize by the given values | |
| SGVec3(T x, T y, T z) | | SGVec3(T x, T y, T z) | |
| { _data[0] = x; _data[1] = y; _data[2] = z; } | | { _data[0] = x; _data[1] = y; _data[2] = z; } | |
| /// Constructor. Initialize by the content of a plain array, | | /// Constructor. Initialize by the content of a plain array, | |
| /// make sure it has at least 3 elements | | /// make sure it has at least 3 elements | |
| explicit SGVec3(const T* data) | | explicit SGVec3(const T* data) | |
| { _data[0] = data[0]; _data[1] = data[1]; _data[2] = data[2]; } | | { _data[0] = data[0]; _data[1] = data[1]; _data[2] = data[2]; } | |
|
| /// Constructor. Initialize by a geodetic coordinate | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGVec3(const SGGeod& geod) | | | |
| { SGGeodesy::SGGeodToCart(geod, *this); } | | | |
| /// Constructor. Initialize by a geocentric coordinate | | | |
| /// Note that this conversion is relatively expensive to compute | | | |
| SGVec3(const SGGeoc& geoc) | | | |
| { SGGeodesy::SGGeocToCart(geoc, *this); } | | | |
| | | | |
| /// Access by index, the index is unchecked | | /// Access by index, the index is unchecked | |
| const T& operator()(unsigned i) const | | const T& operator()(unsigned i) const | |
| { return _data[i]; } | | { return _data[i]; } | |
| /// Access by index, the index is unchecked | | /// Access by index, the index is unchecked | |
| T& operator()(unsigned i) | | T& operator()(unsigned i) | |
| { return _data[i]; } | | { return _data[i]; } | |
| | | | |
| /// Access raw data by index, the index is unchecked | | /// Access raw data by index, the index is unchecked | |
| const T& operator[](unsigned i) const | | const T& operator[](unsigned i) const | |
| | | | |
| skipping to change at line 128 | | skipping to change at line 120 | |
| static SGVec3 zeros(void) | | static SGVec3 zeros(void) | |
| { return SGVec3(0, 0, 0); } | | { return SGVec3(0, 0, 0); } | |
| /// Return unit vectors | | /// Return unit vectors | |
| static SGVec3 e1(void) | | static SGVec3 e1(void) | |
| { return SGVec3(1, 0, 0); } | | { return SGVec3(1, 0, 0); } | |
| static SGVec3 e2(void) | | static SGVec3 e2(void) | |
| { return SGVec3(0, 1, 0); } | | { return SGVec3(0, 1, 0); } | |
| static SGVec3 e3(void) | | static SGVec3 e3(void) | |
| { return SGVec3(0, 0, 1); } | | { return SGVec3(0, 0, 1); } | |
| | | | |
|
| | | /// Constructor. Initialize by a geodetic coordinate | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGVec3 fromGeod(const SGGeod& geod); | |
| | | /// Constructor. Initialize by a geocentric coordinate | |
| | | /// Note that this conversion is relatively expensive to compute | |
| | | static SGVec3 fromGeoc(const SGGeoc& geoc); | |
| | | | |
| private: | | private: | |
| /// The actual data | | /// The actual data | |
| T _data[3]; | | T _data[3]; | |
| }; | | }; | |
| | | | |
|
| | | template<> | |
| | | inline | |
| | | SGVec3<double> | |
| | | SGVec3<double>::fromGeod(const SGGeod& geod) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeodToCart(geod, cart); | |
| | | return cart; | |
| | | } | |
| | | | |
| | | template<> | |
| | | inline | |
| | | SGVec3<float> | |
| | | SGVec3<float>::fromGeod(const SGGeod& geod) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeodToCart(geod, cart); | |
| | | return SGVec3<float>(cart(0), cart(1), cart(2)); | |
| | | } | |
| | | | |
| | | template<> | |
| | | inline | |
| | | SGVec3<double> | |
| | | SGVec3<double>::fromGeoc(const SGGeoc& geoc) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeocToCart(geoc, cart); | |
| | | return cart; | |
| | | } | |
| | | | |
| | | template<> | |
| | | inline | |
| | | SGVec3<float> | |
| | | SGVec3<float>::fromGeoc(const SGGeoc& geoc) | |
| | | { | |
| | | SGVec3<double> cart; | |
| | | SGGeodesy::SGGeocToCart(geoc, cart); | |
| | | return SGVec3<float>(cart(0), cart(1), cart(2)); | |
| | | } | |
| | | | |
| /// Unary +, do nothing ... | | /// Unary +, do nothing ... | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| const SGVec3<T>& | | const SGVec3<T>& | |
| operator+(const SGVec3<T>& v) | | operator+(const SGVec3<T>& v) | |
| { return v; } | | { return v; } | |
| | | | |
| /// Unary -, do nearly nothing | | /// Unary -, do nearly nothing | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| | | | |
| skipping to change at line 260 | | skipping to change at line 299 | |
| /// Return true if about equal to roundoff of the underlying type | | /// Return true if about equal to roundoff of the underlying type | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| bool | | bool | |
| equivalent(const SGVec3<T>& v1, const SGVec3<T>& v2) | | equivalent(const SGVec3<T>& v1, const SGVec3<T>& v2) | |
| { | | { | |
| T tol = 100*SGLimits<T>::epsilon(); | | T tol = 100*SGLimits<T>::epsilon(); | |
| return equivalent(v1, v2, tol, tol); | | return equivalent(v1, v2, tol, tol); | |
| } | | } | |
| | | | |
|
| | | /// The euclidean distance of the two vectors | |
| | | template<typename T> | |
| | | inline | |
| | | T | |
| | | dist(const SGVec3<T>& v1, const SGVec3<T>& v2) | |
| | | { return norm(v1 - v2); } | |
| | | | |
| | | /// The squared euclidean distance of the two vectors | |
| | | template<typename T> | |
| | | inline | |
| | | T | |
| | | distSqr(const SGVec3<T>& v1, const SGVec3<T>& v2) | |
| | | { SGVec3<T> tmp = v1 - v2; return dot(tmp, tmp); } | |
| | | | |
| #ifndef NDEBUG | | #ifndef NDEBUG | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| bool | | bool | |
| isNaN(const SGVec3<T>& v) | | isNaN(const SGVec3<T>& v) | |
| { | | { | |
| return SGMisc<T>::isNaN(v(0)) || | | return SGMisc<T>::isNaN(v(0)) || | |
| SGMisc<T>::isNaN(v(1)) || SGMisc<T>::isNaN(v(2)); | | SGMisc<T>::isNaN(v(1)) || SGMisc<T>::isNaN(v(2)); | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /// Output to an ostream | | /// Output to an ostream | |
| template<typename char_type, typename traits_type, typename T> | | template<typename char_type, typename traits_type, typename T> | |
| inline | | inline | |
| std::basic_ostream<char_type, traits_type>& | | std::basic_ostream<char_type, traits_type>& | |
| operator<<(std::basic_ostream<char_type, traits_type>& s, const SGVec3<T>&
v) | | operator<<(std::basic_ostream<char_type, traits_type>& s, const SGVec3<T>&
v) | |
| { return s << "[ " << v(0) << ", " << v(1) << ", " << v(2) << " ]"; } | | { return s << "[ " << v(0) << ", " << v(1) << ", " << v(2) << " ]"; } | |
| | | | |
|
| /// Two classes doing actually the same on different types | | | |
| typedef SGVec3<float> SGVec3f; | | | |
| typedef SGVec3<double> SGVec3d; | | | |
| | | | |
| inline | | inline | |
| SGVec3f | | SGVec3f | |
| toVec3f(const SGVec3d& v) | | toVec3f(const SGVec3d& v) | |
| { return SGVec3f((float)v(0), (float)v(1), (float)v(2)); } | | { return SGVec3f((float)v(0), (float)v(1), (float)v(2)); } | |
| | | | |
| inline | | inline | |
| SGVec3d | | SGVec3d | |
| toVec3d(const SGVec3f& v) | | toVec3d(const SGVec3f& v) | |
| { return SGVec3d(v(0), v(1), v(2)); } | | { return SGVec3d(v(0), v(1), v(2)); } | |
| | | | |
| | | | |
End of changes. 5 change blocks. |
| 12 lines changed or deleted | | 61 lines changed or added | |
|
| animation.hxx | | animation.hxx | |
| | | | |
| skipping to change at line 17 | | skipping to change at line 17 | |
| #ifndef _SG_ANIMATION_HXX | | #ifndef _SG_ANIMATION_HXX | |
| #define _SG_ANIMATION_HXX 1 | | #define _SG_ANIMATION_HXX 1 | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <map> | | #include <map> | |
| | | | |
|
| SG_USING_STD(vector); | | | |
| SG_USING_STD(map); | | | |
| | | | |
| #include <plib/sg.h> | | #include <plib/sg.h> | |
| #include <plib/ssg.h> | | #include <plib/ssg.h> | |
| | | | |
| #include <simgear/math/point3d.hxx> | | #include <simgear/math/point3d.hxx> | |
| #include <simgear/props/props.hxx> | | #include <simgear/props/props.hxx> | |
| #include <simgear/misc/sg_path.hxx> | | #include <simgear/misc/sg_path.hxx> | |
|
| | | #include <simgear/structure/ssgSharedPtr.hxx> | |
| | | | |
| | | #include <simgear/scene/model/persparam.hxx> | |
| | | | |
| | | SG_USING_STD(vector); | |
| | | SG_USING_STD(map); | |
| | | | |
| // Don't pull in the headers, since we don't need them here. | | // Don't pull in the headers, since we don't need them here. | |
| class SGInterpTable; | | class SGInterpTable; | |
| class SGCondition; | | class SGCondition; | |
| class SGPersonalityBranch; | | class SGPersonalityBranch; | |
| | | | |
| // Has anyone done anything *really* stupid, like making min and max macros
? | | // Has anyone done anything *really* stupid, like making min and max macros
? | |
| #ifdef min | | #ifdef min | |
| #undef min | | #undef min | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 53 | |
| // Animation classes | | // Animation classes | |
| ////////////////////////////////////////////////////////////////////// | | ////////////////////////////////////////////////////////////////////// | |
| | | | |
| /** | | /** | |
| * Abstract base class for all animations. | | * Abstract base class for all animations. | |
| */ | | */ | |
| class SGAnimation : public ssgBase | | class SGAnimation : public ssgBase | |
| { | | { | |
| public: | | public: | |
| enum PersonalityVar { INIT_SPIN, LAST_TIME_SEC_SPIN, FACTOR_SPIN, | | enum PersonalityVar { INIT_SPIN, LAST_TIME_SEC_SPIN, FACTOR_SPIN, | |
|
| POSITION_DEG_SPIN, INIT_TIMED, LAST_TIME_SEC_TIMED, | | POSITION_DEG_SPIN, | |
| TOTAL_DURATION_SEC_TIMED, BRANCH_DURATION_SEC_TIMED | | INIT_TIMED, LAST_TIME_SEC_TIMED, TOTAL_DURATION_SEC | |
| , | | _TIMED, | |
| STEP_TIMED }; | | BRANCH_DURATION_SEC_TIMED, STEP_TIMED, | |
| | | INIT_TRANSLATE, FACTOR_TRANSLATE, OFFSET_TRANSLATE, | |
| | | INIT_BLEND, FACTOR_BLEND, OFFSET_BLEND, | |
| | | INIT_SCALE, X_FACTOR_SCALE, Y_FACTOR_SCALE, Z_FACTO | |
| | | R_SCALE, | |
| | | X_OFFSET_SCALE, Y_OFFSET_SCALE, Z_OFFSET_SCALE | |
| | | }; | |
| | | | |
| SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch); | | SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch); | |
| | | | |
| virtual ~SGAnimation (); | | virtual ~SGAnimation (); | |
| | | | |
| /** | | /** | |
| * Get the SSG branch holding the animation. | | * Get the SSG branch holding the animation. | |
| */ | | */ | |
| virtual ssgBranch * getBranch () { return _branch; } | | virtual ssgBranch * getBranch () { return _branch; } | |
| | | | |
| | | | |
| skipping to change at line 171 | | skipping to change at line 178 | |
| { | | { | |
| public: | | public: | |
| SGSpinAnimation( SGPropertyNode *prop_root, | | SGSpinAnimation( SGPropertyNode *prop_root, | |
| SGPropertyNode_ptr props, | | SGPropertyNode_ptr props, | |
| double sim_time_sec ); | | double sim_time_sec ); | |
| virtual ~SGSpinAnimation (); | | virtual ~SGSpinAnimation (); | |
| virtual int update(); | | virtual int update(); | |
| private: | | private: | |
| bool _use_personality; | | bool _use_personality; | |
| SGPropertyNode_ptr _prop; | | SGPropertyNode_ptr _prop; | |
|
| double _factor; | | SGPersonalityParameter<double> _factor; | |
| double _factor_min; | | SGPersonalityParameter<double> _position_deg; | |
| double _factor_max; | | | |
| double _position_deg; | | | |
| double _position_deg_min; | | | |
| double _position_deg_max; | | | |
| double _last_time_sec; | | double _last_time_sec; | |
| sgMat4 _matrix; | | sgMat4 _matrix; | |
| sgVec3 _center; | | sgVec3 _center; | |
| sgVec3 _axis; | | sgVec3 _axis; | |
| SGCondition * _condition; | | SGCondition * _condition; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Animation to draw objects for a specific amount of time each. | | * Animation to draw objects for a specific amount of time each. | |
| */ | | */ | |
| | | | |
| skipping to change at line 247 | | skipping to change at line 250 | |
| * Animation to slide along an axis. | | * Animation to slide along an axis. | |
| */ | | */ | |
| class SGTranslateAnimation : public SGAnimation | | class SGTranslateAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGTranslateAnimation( SGPropertyNode *prop_root, | | SGTranslateAnimation( SGPropertyNode *prop_root, | |
| SGPropertyNode_ptr props ); | | SGPropertyNode_ptr props ); | |
| virtual ~SGTranslateAnimation (); | | virtual ~SGTranslateAnimation (); | |
| virtual int update(); | | virtual int update(); | |
| private: | | private: | |
|
| | | bool _use_personality; | |
| SGPropertyNode_ptr _prop; | | SGPropertyNode_ptr _prop; | |
|
| double _offset_m; | | SGPersonalityParameter<double> _offset_m; | |
| double _factor; | | SGPersonalityParameter<double> _factor; | |
| SGInterpTable * _table; | | SGInterpTable * _table; | |
| bool _has_min; | | bool _has_min; | |
| double _min_m; | | double _min_m; | |
| bool _has_max; | | bool _has_max; | |
| double _max_m; | | double _max_m; | |
| double _position_m; | | double _position_m; | |
| sgMat4 _matrix; | | sgMat4 _matrix; | |
| sgVec3 _axis; | | sgVec3 _axis; | |
| SGCondition * _condition; | | SGCondition * _condition; | |
| }; | | }; | |
| | | | |
| skipping to change at line 272 | | skipping to change at line 276 | |
| * Animation to blend an object. | | * Animation to blend an object. | |
| */ | | */ | |
| class SGBlendAnimation : public SGAnimation | | class SGBlendAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGBlendAnimation( SGPropertyNode *prop_root, | | SGBlendAnimation( SGPropertyNode *prop_root, | |
| SGPropertyNode_ptr props ); | | SGPropertyNode_ptr props ); | |
| virtual ~SGBlendAnimation (); | | virtual ~SGBlendAnimation (); | |
| virtual int update(); | | virtual int update(); | |
| private: | | private: | |
|
| | | bool _use_personality; | |
| SGPropertyNode_ptr _prop; | | SGPropertyNode_ptr _prop; | |
| SGInterpTable * _table; | | SGInterpTable * _table; | |
| double _prev_value; | | double _prev_value; | |
|
| double _offset; | | SGPersonalityParameter<double> _offset; | |
| double _factor; | | SGPersonalityParameter<double> _factor; | |
| bool _has_min; | | bool _has_min; | |
| double _min; | | double _min; | |
| bool _has_max; | | bool _has_max; | |
| double _max; | | double _max; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Animation to scale an object. | | * Animation to scale an object. | |
| */ | | */ | |
| class SGScaleAnimation : public SGAnimation | | class SGScaleAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGScaleAnimation( SGPropertyNode *prop_root, | | SGScaleAnimation( SGPropertyNode *prop_root, | |
| SGPropertyNode_ptr props ); | | SGPropertyNode_ptr props ); | |
| virtual ~SGScaleAnimation (); | | virtual ~SGScaleAnimation (); | |
| virtual int update(); | | virtual int update(); | |
| private: | | private: | |
|
| | | bool _use_personality; | |
| SGPropertyNode_ptr _prop; | | SGPropertyNode_ptr _prop; | |
|
| double _x_factor; | | SGPersonalityParameter<double> _x_factor; | |
| double _y_factor; | | SGPersonalityParameter<double> _y_factor; | |
| double _z_factor; | | SGPersonalityParameter<double> _z_factor; | |
| double _x_offset; | | SGPersonalityParameter<double> _x_offset; | |
| double _y_offset; | | SGPersonalityParameter<double> _y_offset; | |
| double _z_offset; | | SGPersonalityParameter<double> _z_offset; | |
| SGInterpTable * _table; | | SGInterpTable * _table; | |
| bool _has_min_x; | | bool _has_min_x; | |
| bool _has_min_y; | | bool _has_min_y; | |
| bool _has_min_z; | | bool _has_min_z; | |
| double _min_x; | | double _min_x; | |
| double _min_y; | | double _min_y; | |
| double _min_z; | | double _min_z; | |
| bool _has_max_x; | | bool _has_max_x; | |
| bool _has_max_y; | | bool _has_max_y; | |
| bool _has_max_z; | | bool _has_max_z; | |
| | | | |
| skipping to change at line 344 | | skipping to change at line 350 | |
| double _factor; | | double _factor; | |
| SGInterpTable * _table; | | SGInterpTable * _table; | |
| bool _has_min; | | bool _has_min; | |
| double _min_deg; | | double _min_deg; | |
| bool _has_max; | | bool _has_max; | |
| double _max_deg; | | double _max_deg; | |
| double _position_deg; | | double _position_deg; | |
| sgMat4 _matrix; | | sgMat4 _matrix; | |
| sgVec3 _center; | | sgVec3 _center; | |
| sgVec3 _axis; | | sgVec3 _axis; | |
|
| | | SGCondition * _condition; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Animation to slide texture mappings along an axis. | | * Animation to slide texture mappings along an axis. | |
| */ | | */ | |
| class SGTexTranslateAnimation : public SGAnimation | | class SGTexTranslateAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGTexTranslateAnimation( SGPropertyNode *prop_root, | | SGTexTranslateAnimation( SGPropertyNode *prop_root, | |
| SGPropertyNode_ptr props ); | | SGPropertyNode_ptr props ); | |
| | | | |
| skipping to change at line 370 | | skipping to change at line 377 | |
| double _step; | | double _step; | |
| double _scroll; | | double _scroll; | |
| SGInterpTable * _table; | | SGInterpTable * _table; | |
| bool _has_min; | | bool _has_min; | |
| double _min; | | double _min; | |
| bool _has_max; | | bool _has_max; | |
| double _max; | | double _max; | |
| double _position; | | double _position; | |
| sgMat4 _matrix; | | sgMat4 _matrix; | |
| sgVec3 _axis; | | sgVec3 _axis; | |
|
| | | SGCondition * _condition; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Classes for handling multiple types of Texture translations on one objec
t | | * Classes for handling multiple types of Texture translations on one objec
t | |
| */ | | */ | |
| | | | |
| class SGTexMultipleAnimation : public SGAnimation | | class SGTexMultipleAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGTexMultipleAnimation( SGPropertyNode *prop_root, | | SGTexMultipleAnimation( SGPropertyNode *prop_root, | |
| | | | |
| skipping to change at line 430 | | skipping to change at line 438 | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An "animation" to modify material properties | | * An "animation" to modify material properties | |
| */ | | */ | |
| class SGMaterialAnimation : public SGAnimation | | class SGMaterialAnimation : public SGAnimation | |
| { | | { | |
| public: | | public: | |
| SGMaterialAnimation(SGPropertyNode *prop_root, SGPropertyNode_ptr props
, | | SGMaterialAnimation(SGPropertyNode *prop_root, SGPropertyNode_ptr props
, | |
| const SGPath &texpath); | | const SGPath &texpath); | |
|
| virtual ~SGMaterialAnimation() {} | | virtual ~SGMaterialAnimation(); | |
| virtual void init(); | | virtual void init(); | |
| virtual int update(); | | virtual int update(); | |
| private: | | private: | |
| enum { | | enum { | |
| DIFFUSE = 1, | | DIFFUSE = 1, | |
| AMBIENT = 2, | | AMBIENT = 2, | |
| SPECULAR = 4, | | SPECULAR = 4, | |
| EMISSION = 8, | | EMISSION = 8, | |
| SHININESS = 16, | | SHININESS = 16, | |
| TRANSPARENCY = 32, | | TRANSPARENCY = 32, | |
| | | | |
| skipping to change at line 493 | | skipping to change at line 501 | |
| SGPropertyNode_ptr factor_prop; | | SGPropertyNode_ptr factor_prop; | |
| SGPropertyNode_ptr offset_prop; | | SGPropertyNode_ptr offset_prop; | |
| inline bool dirty() { return value >= 0.0; } | | inline bool dirty() { return value >= 0.0; } | |
| inline bool live() { return value_prop || factor_prop || offset_pro
p; } | | inline bool live() { return value_prop || factor_prop || offset_pro
p; } | |
| inline bool operator!=(PropSpec& a) { | | inline bool operator!=(PropSpec& a) { | |
| return value != a.value || factor != a.factor || offset != a.of
fset; | | return value != a.value || factor != a.factor || offset != a.of
fset; | |
| } | | } | |
| }; | | }; | |
| SGCondition *_condition; | | SGCondition *_condition; | |
| bool _last_condition; | | bool _last_condition; | |
|
| SGPropertyNode *_prop_root; | | SGPropertyNode_ptr _prop_root; | |
| string _prop_base; | | string _prop_base; | |
| SGPath _texture_base; | | SGPath _texture_base; | |
| SGPath _texture; | | SGPath _texture; | |
| string _texture_str; | | string _texture_str; | |
| ssgSimpleState* _cached_material; | | ssgSimpleState* _cached_material; | |
| ssgSimpleState* _cloned_material; | | ssgSimpleState* _cloned_material; | |
| unsigned _read; | | unsigned _read; | |
| unsigned _update; | | unsigned _update; | |
| unsigned _static_update; | | unsigned _static_update; | |
| bool _global; | | bool _global; | |
| | | | |
| skipping to change at line 608 | | skipping to change at line 616 | |
| bool _condition_value; | | bool _condition_value; | |
| int _shader_type; | | int _shader_type; | |
| float _param_1; | | float _param_1; | |
| sgVec4 _param_color; | | sgVec4 _param_color; | |
| public: | | public: | |
| bool _depth_test; | | bool _depth_test; | |
| float _factor; | | float _factor; | |
| SGPropertyNode_ptr _factor_prop; | | SGPropertyNode_ptr _factor_prop; | |
| float _speed; | | float _speed; | |
| SGPropertyNode_ptr _speed_prop; | | SGPropertyNode_ptr _speed_prop; | |
|
| ssgTexture *_effectTexture; | | ssgSharedPtr<ssgTexture> _effectTexture; | |
| unsigned char *_textureData; | | unsigned char *_textureData; | |
| GLint _texWidth, _texHeight; | | GLint _texWidth, _texHeight; | |
| sgVec4 _envColor; | | sgVec4 _envColor; | |
| }; | | }; | |
| | | | |
| #endif // _SG_ANIMATION_HXX | | #endif // _SG_ANIMATION_HXX | |
| | | | |
End of changes. 15 change blocks. |
| 26 lines changed or deleted | | 36 lines changed or added | |
|
| cloud.hxx | | cloud.hxx | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| // | | // | |
| // This library is distributed in the hope that it will be useful, | | // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: cloud.hxx,v 1.16 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: cloud.hxx,v 1.17.2.2 2007-12-12 17:38:19 timoore Exp $ | |
| | | | |
| #ifndef _SG_CLOUD_HXX_ | | #ifndef _SG_CLOUD_HXX_ | |
| #define _SG_CLOUD_HXX_ | | #define _SG_CLOUD_HXX_ | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
|
| | | #include <simgear/misc/sg_path.hxx> | |
| | | | |
| #include <plib/ssg.h> | | #include <plib/ssg.h> | |
| | | | |
| #include STL_STRING | | #include STL_STRING | |
| SG_USING_STD(string); | | SG_USING_STD(string); | |
| | | | |
| // #include <iostream> | | // #include <iostream> | |
| // SG_USING_STD(cout); | | // SG_USING_STD(cout); | |
| // SG_USING_STD(endl); | | // SG_USING_STD(endl); | |
| | | | |
| | | | |
| skipping to change at line 181 | | skipping to change at line 182 | |
| * @param lon specifies a rotation about the Z axis | | * @param lon specifies a rotation about the Z axis | |
| * @param lat specifies a rotation about the new Y axis | | * @param lat specifies a rotation about the new Y axis | |
| * @param spin specifies a rotation about the new Z axis | | * @param spin specifies a rotation about the new Z axis | |
| * (and orients the sunrise/set effects) | | * (and orients the sunrise/set effects) | |
| * @param dt the time elapsed since the last call | | * @param dt the time elapsed since the last call | |
| */ | | */ | |
| bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double al
t, | | bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double al
t, | |
| double dt = 0.0 ); | | double dt = 0.0 ); | |
| | | | |
| /** draw the cloud layer */ | | /** draw the cloud layer */ | |
|
| void draw( bool top ); | | void draw( bool top, float *sun_color ); | |
| | | | |
| static bool enable_bump_mapping; | | static bool enable_bump_mapping; | |
| | | | |
| /** return the 3D layer cloud associated with this 2D layer */ | | /** return the 3D layer cloud associated with this 2D layer */ | |
| SGCloudField *get_layer3D(void) { return layer3D; } | | SGCloudField *get_layer3D(void) { return layer3D; } | |
| | | | |
| private: | | private: | |
| | | | |
| struct CloudVertex { | | struct CloudVertex { | |
| sgVec3 position; | | sgVec3 position; | |
| | | | |
| skipping to change at line 231 | | skipping to change at line 232 | |
| float scale; | | float scale; | |
| float speed; | | float speed; | |
| float direction; | | float direction; | |
| | | | |
| // for handling texture coordinates to simulate cloud movement | | // for handling texture coordinates to simulate cloud movement | |
| // from winds, and to simulate the clouds being tied to ground | | // from winds, and to simulate the clouds being tied to ground | |
| // position, not view position | | // position, not view position | |
| // double xoff, yoff; | | // double xoff, yoff; | |
| double last_lon, last_lat, last_course; | | double last_lon, last_lat, last_course; | |
| | | | |
|
| SGCloudField *layer3D; | | SGCloudField *layer3D; | |
| | | // random offset of cloud texture | |
| | | sgVec2 base; | |
| }; | | }; | |
| | | | |
| // make an ssgSimpleState for a cloud layer given the named texture | | // make an ssgSimpleState for a cloud layer given the named texture | |
| ssgSimpleState *sgCloudMakeState( const string &path ); | | ssgSimpleState *sgCloudMakeState( const string &path ); | |
| | | | |
| #endif // _SG_CLOUD_HXX_ | | #endif // _SG_CLOUD_HXX_ | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 6 lines changed or added | |
|
| interpolater.hxx | | interpolater.hxx | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| // | | // | |
| // This library is distributed in the hope that it will be useful, | | // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: interpolater.hxx,v 1.4 2006-03-08 18:16:08 mfranz Exp $ | | // $Id: interpolater.hxx,v 1.4.2.1 2007-03-31 12:23:38 mfranz Exp $ | |
| | | | |
| #ifndef _INTERPOLATER_H | | #ifndef _INTERPOLATER_H | |
| #define _INTERPOLATER_H | | #define _INTERPOLATER_H | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| | | | |
|
| #include <vector> | | #include "simgear/structure/SGReferenced.hxx" | |
| SG_USING_STD(vector); | | | |
| | | #include <map> | |
| | | | |
| #include STL_STRING | | #include STL_STRING | |
| SG_USING_STD(string); | | SG_USING_STD(string); | |
| | | | |
|
| | | class SGPropertyNode; | |
| | | | |
| /** | | /** | |
| * A class that provids a simple linear 2d interpolation lookup table. | | * A class that provids a simple linear 2d interpolation lookup table. | |
| * The actual table is expected to be loaded from a file. The | | * The actual table is expected to be loaded from a file. The | |
| * independant variable must be strictly ascending. The dependent | | * independant variable must be strictly ascending. The dependent | |
| * variable can be anything. | | * variable can be anything. | |
| */ | | */ | |
|
| class SGInterpTable { | | class SGInterpTable : public SGReferenced { | |
| | | | |
| struct Entry | | | |
| { | | | |
| Entry () | | | |
| : ind(0.0L), dep(0.0L) {} | | | |
| Entry (double independent, double dependent) | | | |
| : ind(independent), dep(dependent) {} | | | |
| double ind; | | | |
| double dep; | | | |
| }; | | | |
| | | | |
| int size; | | | |
| vector<Entry> table; | | | |
| | | | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Constructor. Creates a new, empty table. | | * Constructor. Creates a new, empty table. | |
| */ | | */ | |
| SGInterpTable(); | | SGInterpTable(); | |
| | | | |
| /** | | /** | |
|
| | | * Constructor. Loads the interpolation table from an interpolation | |
| | | * property node. | |
| | | * @param interpolation property node having entry children | |
| | | */ | |
| | | SGInterpTable(const SGPropertyNode* interpolation); | |
| | | | |
| | | /** | |
| * Constructor. Loads the interpolation table from the specified file. | | * Constructor. Loads the interpolation table from the specified file. | |
| * @param file name of interpolation file | | * @param file name of interpolation file | |
| */ | | */ | |
| SGInterpTable( const string& file ); | | SGInterpTable( const string& file ); | |
| | | | |
| /** | | /** | |
| * Add an entry to the table, extending the table's length. | | * Add an entry to the table, extending the table's length. | |
| * | | * | |
| * @param ind The independent variable. | | * @param ind The independent variable. | |
| * @param dep The dependent variable. | | * @param dep The dependent variable. | |
| | | | |
| skipping to change at line 93 | | skipping to change at line 89 | |
| | | | |
| /** | | /** | |
| * Given an x value, linearly interpolate the y value from the table. | | * Given an x value, linearly interpolate the y value from the table. | |
| * @param x independent variable | | * @param x independent variable | |
| * @return interpolated dependent variable | | * @return interpolated dependent variable | |
| */ | | */ | |
| double interpolate(double x) const; | | double interpolate(double x) const; | |
| | | | |
| /** Destructor */ | | /** Destructor */ | |
| ~SGInterpTable(); | | ~SGInterpTable(); | |
|
| | | | |
| | | private: | |
| | | typedef std::map<double, double> Table; | |
| | | Table _table; | |
| }; | | }; | |
| | | | |
| #endif // _INTERPOLATER_H | | #endif // _INTERPOLATER_H | |
| | | | |
End of changes. 6 change blocks. |
| 18 lines changed or deleted | | 18 lines changed or added | |
|
| location.hxx | | location.hxx | |
| | | | |
| skipping to change at line 21 | | skipping to change at line 21 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, but | | // This program is distributed in the hope that it will be useful, but | |
| // WITHOUT ANY WARRANTY; without even the implied warranty of | | // WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // General Public License for more details. | | // General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: location.hxx,v 1.6 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: location.hxx,v 1.7 2006-07-27 16:34:32 frohlich Exp $ | |
| | | | |
| #ifndef _SG_LOCATION_HXX | | #ifndef _SG_LOCATION_HXX | |
| #define _SG_LOCATION_HXX | | #define _SG_LOCATION_HXX | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| #include <simgear/constants.h> | | #include <simgear/constants.h> | |
| | | | |
| skipping to change at line 81 | | skipping to change at line 81 | |
| // Part 3: output vectors and matrices in FlightGear coordinates. | | // Part 3: output vectors and matrices in FlightGear coordinates. | |
| ////////////////////////////////////////////////////////////////////// | | ////////////////////////////////////////////////////////////////////// | |
| | | | |
| // Vectors and positions... | | // Vectors and positions... | |
| | | | |
| //! Get the absolute view position in fgfs coordinates. | | //! Get the absolute view position in fgfs coordinates. | |
| virtual double * get_absolute_view_pos( ); | | virtual double * get_absolute_view_pos( ); | |
| | | | |
| //! Return the position relative to the given scenery center. | | //! Return the position relative to the given scenery center. | |
| virtual float * get_view_pos( const Point3D& scenery_center ); | | virtual float * get_view_pos( const Point3D& scenery_center ); | |
|
| | | float * get_view_pos( const SGVec3d& sc ) | |
| | | { return get_view_pos(Point3D(sc[0], sc[1], sc[2])); } | |
| | | | |
| // Get world up vector | | // Get world up vector | |
| virtual float *get_world_up() | | virtual float *get_world_up() | |
| { recalcAbsolutePosition(); return _world_up; } | | { recalcAbsolutePosition(); return _world_up; } | |
| | | | |
| // Get surface east vector | | // Get surface east vector | |
| virtual float *get_surface_east() | | virtual float *get_surface_east() | |
| { recalcAbsolutePosition(); return _surface_east; } | | { recalcAbsolutePosition(); return _surface_east; } | |
| | | | |
| // Get surface south vector | | // Get surface south vector | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 111 | |
| virtual const sgVec4 *getTransformMatrix() { | | virtual const sgVec4 *getTransformMatrix() { | |
| recalcOrientation(); | | recalcOrientation(); | |
| return TRANS; | | return TRANS; | |
| } | | } | |
| virtual const sgVec4 *getCachedTransformMatrix() { return TRANS; } | | virtual const sgVec4 *getCachedTransformMatrix() { return TRANS; } | |
| | | | |
| virtual const sgVec4 *getUpMatrix(const Point3D& scenery_center) { | | virtual const sgVec4 *getUpMatrix(const Point3D& scenery_center) { | |
| recalcAbsolutePosition(); | | recalcAbsolutePosition(); | |
| return UP; | | return UP; | |
| } | | } | |
|
| | | const sgVec4 *getUpMatrix( const SGVec3d& sc ) | |
| | | { return getUpMatrix(Point3D(sc[0], sc[1], sc[2])); } | |
| | | | |
| virtual const sgVec4 *getCachedUpMatrix() { return UP; } | | virtual const sgVec4 *getCachedUpMatrix() { return UP; } | |
| | | | |
| private: | | private: | |
| | | | |
| ////////////////////////////////////////////////////////////////// | | ////////////////////////////////////////////////////////////////// | |
| // private data // | | // private data // | |
| ////////////////////////////////////////////////////////////////// | | ////////////////////////////////////////////////////////////////// | |
| | | | |
| // flag forcing a recalc of derived view parameters | | // flag forcing a recalc of derived view parameters | |
| mutable bool _orientation_dirty, _position_dirty; | | mutable bool _orientation_dirty, _position_dirty; | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 6 lines changed or added | |
|
| logstream.hxx | | logstream.hxx | |
| | | | |
| skipping to change at line 23 | | skipping to change at line 23 | |
| // | | // | |
| // This library is distributed in the hope that it will be useful, | | // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: logstream.hxx,v 1.9 2006-03-08 18:16:08 mfranz Exp $ | | // $Id: logstream.hxx,v 1.10.2.1 2007-07-02 12:55:21 mfranz Exp $ | |
| | | | |
| #ifndef _LOGSTREAM_H | | #ifndef _LOGSTREAM_H | |
| #define _LOGSTREAM_H | | #define _LOGSTREAM_H | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| # include <windows.h> | | # include <windows.h> | |
| #endif | | #endif | |
| | | | |
| | | | |
| skipping to change at line 137 | | skipping to change at line 137 | |
| * @return The priority cutoff for logging messages. | | * @return The priority cutoff for logging messages. | |
| */ | | */ | |
| static sgDebugPriority get_log_priority (); | | static sgDebugPriority get_log_priority (); | |
| | | | |
| /** | | /** | |
| * Set the stream buffer | | * Set the stream buffer | |
| * @param sb stream buffer | | * @param sb stream buffer | |
| */ | | */ | |
| void set_sb( streambuf* sb ); | | void set_sb( streambuf* sb ); | |
| | | | |
|
| | | #ifdef _MSC_VER | |
| | | static void has_no_console() { has_console = false; } | |
| | | #endif | |
| | | | |
| protected: | | protected: | |
| | | | |
| /** sync/flush */ | | /** sync/flush */ | |
| inline virtual int sync(); | | inline virtual int sync(); | |
| | | | |
| /** overflow */ | | /** overflow */ | |
| int_type overflow( int ch ); | | int_type overflow( int ch ); | |
| // int xsputn( const char* s, istreamsize n ); | | // int xsputn( const char* s, istreamsize n ); | |
| | | | |
| private: | | private: | |
| | | | |
| // The streambuf used for actual output. Defaults to cerr.rdbuf(). | | // The streambuf used for actual output. Defaults to cerr.rdbuf(). | |
| static streambuf* sbuf; | | static streambuf* sbuf; | |
| | | | |
| static bool logging_enabled; | | static bool logging_enabled; | |
|
| | | #ifdef _MSC_VER | |
| | | static bool has_console; | |
| | | #endif | |
| static sgDebugClass logClass; | | static sgDebugClass logClass; | |
| static sgDebugPriority logPriority; | | static sgDebugPriority logPriority; | |
| | | | |
| private: | | private: | |
| | | | |
| // Not defined. | | // Not defined. | |
| logbuf( const logbuf& ); | | logbuf( const logbuf& ); | |
| void operator= ( const logbuf& ); | | void operator= ( const logbuf& ); | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 182 | | skipping to change at line 189 | |
| inline void | | inline void | |
| logbuf::set_log_state( sgDebugClass c, sgDebugPriority p ) | | logbuf::set_log_state( sgDebugClass c, sgDebugPriority p ) | |
| { | | { | |
| logging_enabled = ((c & logClass) != 0 && p >= logPriority); | | logging_enabled = ((c & logClass) != 0 && p >= logPriority); | |
| } | | } | |
| | | | |
| inline logbuf::int_type | | inline logbuf::int_type | |
| logbuf::overflow( int c ) | | logbuf::overflow( int c ) | |
| { | | { | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
|
| static bool has_console = false; | | | |
| if ( logging_enabled ) { | | if ( logging_enabled ) { | |
| if ( !has_console ) { | | if ( !has_console ) { | |
| AllocConsole(); | | AllocConsole(); | |
| freopen("conin$", "r", stdin); | | freopen("conin$", "r", stdin); | |
| freopen("conout$", "w", stdout); | | freopen("conout$", "w", stdout); | |
| freopen("conout$", "w", stderr); | | freopen("conout$", "w", stderr); | |
| has_console = true; | | has_console = true; | |
| } | | } | |
| return sbuf->sputc(c); | | return sbuf->sputc(c); | |
| } | | } | |
| | | | |
| skipping to change at line 313 | | skipping to change at line 319 | |
| * @param M message | | * @param M message | |
| */ | | */ | |
| #ifdef FG_NDEBUG | | #ifdef FG_NDEBUG | |
| # define SG_LOG(C,P,M) | | # define SG_LOG(C,P,M) | |
| #elif defined( __MWERKS__ ) | | #elif defined( __MWERKS__ ) | |
| # define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl | | # define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl | |
| #else | | #else | |
| # define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl | | # define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl | |
| #endif | | #endif | |
| | | | |
|
| | | #define SG_STRINGIFY(x) #x | |
| | | #define SG_TOSTRING(x) SG_STRINGIFY(x) | |
| | | #define SG_ORIGIN __FILE__ ":" SG_TOSTRING(__LINE__) | |
| | | | |
| #endif // _LOGSTREAM_H | | #endif // _LOGSTREAM_H | |
| | | | |
End of changes. 5 change blocks. |
| 2 lines changed or deleted | | 12 lines changed or added | |
|
| mat.hxx | | mat.hxx | |
| | | | |
| skipping to change at line 23 | | skipping to change at line 23 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, but | | // This program is distributed in the hope that it will be useful, but | |
| // WITHOUT ANY WARRANTY; without even the implied warranty of | | // WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // General Public License for more details. | | // General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: mat.hxx,v 1.19 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: mat.hxx,v 1.24.2.1 2007-05-13 11:52:45 mfranz Exp $ | |
| | | | |
| #ifndef _SG_MAT_HXX | | #ifndef _SG_MAT_HXX | |
| #define _SG_MAT_HXX | | #define _SG_MAT_HXX | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| | | | |
| #include STL_STRING // Standard C++ string library | | #include STL_STRING // Standard C++ string library | |
| #include <vector> | | #include <vector> | |
|
| | | #include <map> | |
| | | | |
| | | #include <simgear/math/SGMath.hxx> | |
| | | | |
| #include <plib/sg.h> | | #include <plib/sg.h> | |
| #include <plib/ssg.h> | | #include <plib/ssg.h> | |
| | | | |
| #include <simgear/props/props.hxx> | | #include <simgear/props/props.hxx> | |
| #include <simgear/structure/ssgSharedPtr.hxx> | | #include <simgear/structure/ssgSharedPtr.hxx> | |
| #include <simgear/structure/SGSharedPtr.hxx> | | #include <simgear/structure/SGSharedPtr.hxx> | |
| | | | |
| #include "matmodel.hxx" | | #include "matmodel.hxx" | |
| | | | |
| SG_USING_STD(string); | | SG_USING_STD(string); | |
| SG_USING_STD(vector); | | SG_USING_STD(vector); | |
|
| | | SG_USING_STD(map); | |
| | | | |
| | | class SGMaterialGlyph; | |
| | | | |
| /** | | /** | |
| * A material in the scene graph. | | * A material in the scene graph. | |
| * | | * | |
| * A material represents information about a single surface type | | * A material represents information about a single surface type | |
| * in the 3D scene graph, including texture, colour, lighting, | | * in the 3D scene graph, including texture, colour, lighting, | |
| * tiling, and so on; most of the materials in FlightGear are | | * tiling, and so on; most of the materials in FlightGear are | |
| * defined in the $FG_ROOT/materials.xml file, and can be changed | | * defined in the $FG_ROOT/materials.xml file, and can be changed | |
| * at runtime. | | * at runtime. | |
| */ | | */ | |
| | | | |
| skipping to change at line 97 | | skipping to change at line 103 | |
| * low-level state for the scene graph and wrap a material around | | * low-level state for the scene graph and wrap a material around | |
| * it. Note: the pointer ownership is transferred to the material. | | * it. Note: the pointer ownership is transferred to the material. | |
| * | | * | |
| * @param s The SSG state for this material. | | * @param s The SSG state for this material. | |
| */ | | */ | |
| SGMaterial( ssgSimpleState *s ); | | SGMaterial( ssgSimpleState *s ); | |
| | | | |
| /** | | /** | |
| * Destructor. | | * Destructor. | |
| */ | | */ | |
|
| virtual ~SGMaterial( void ); | | ~SGMaterial( void ); | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| // Public methods. | | // Public methods. | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| | | | |
| /** | | /** | |
| * Force the texture to load if it hasn't already. | | * Force the texture to load if it hasn't already. | |
| * | | * | |
| * @return true if the texture loaded, false if it was loaded | | * @return true if the texture loaded, false if it was loaded | |
| * already. | | * already. | |
| */ | | */ | |
|
| virtual bool load_texture (int n = -1); | | bool load_texture (int n = -1); | |
| | | | |
| /** | | /** | |
| * Get the textured state. | | * Get the textured state. | |
| */ | | */ | |
|
| virtual ssgSimpleState *get_state (int n = -1) const; | | ssgSimpleState *get_state (int n = -1) const; | |
| | | | |
| /** | | /** | |
| * Get the number of textures assigned to this material. | | * Get the number of textures assigned to this material. | |
| */ | | */ | |
|
| virtual inline int get_num() const { return _status.size(); } | | inline int get_num() const { return _status.size(); } | |
| | | | |
| /** | | /** | |
| * Get the xsize of the texture, in meters. | | * Get the xsize of the texture, in meters. | |
| */ | | */ | |
|
| virtual inline double get_xsize() const { return xsize; } | | inline double get_xsize() const { return xsize; } | |
| | | | |
| /** | | /** | |
| * Get the ysize of the texture, in meters. | | * Get the ysize of the texture, in meters. | |
| */ | | */ | |
|
| virtual inline double get_ysize() const { return ysize; } | | inline double get_ysize() const { return ysize; } | |
| | | | |
| /** | | /** | |
| * Get the light coverage. | | * Get the light coverage. | |
| * | | * | |
| * A smaller number means more generated night lighting. | | * A smaller number means more generated night lighting. | |
| * | | * | |
| * @return The area (m^2?) covered by each light. | | * @return The area (m^2?) covered by each light. | |
| */ | | */ | |
|
| virtual inline double get_light_coverage () const { return light_coverage | | inline double get_light_coverage () const { return light_coverage; } | |
| ; } | | | |
| | | /** | |
| | | * Return if the surface material is solid, if it is not solid, a fluid | |
| | | * can be assumed, that is usually water. | |
| | | */ | |
| | | bool get_solid () const { return solid; } | |
| | | | |
| | | /** | |
| | | * Get the friction factor for that material | |
| | | */ | |
| | | double get_friction_factor () const { return friction_factor; } | |
| | | | |
| | | /** | |
| | | * Get the rolling friction for that material | |
| | | */ | |
| | | double get_rolling_friction () const { return rolling_friction; } | |
| | | | |
| | | /** | |
| | | * Get the bumpines for that material | |
| | | */ | |
| | | double get_bumpiness () const { return bumpiness; } | |
| | | | |
| | | /** | |
| | | * Get the load resistance | |
| | | */ | |
| | | double get_load_resistance () const { return load_resistance; } | |
| | | | |
| | | /** | |
| | | * Get the list of names for this material | |
| | | */ | |
| | | const vector<string>& get_names() const { return _names; } | |
| | | | |
| | | /** | |
| | | * add the given name to the list of names this material is known | |
| | | */ | |
| | | void add_name(const string& name) { _names.push_back(name); } | |
| | | | |
| /** | | /** | |
| * Get the number of randomly-placed objects defined for this material. | | * Get the number of randomly-placed objects defined for this material. | |
| */ | | */ | |
|
| virtual int get_object_group_count () const { return object_groups.size()
; } | | int get_object_group_count () const { return object_groups.size(); } | |
| | | | |
| /** | | /** | |
| * Get a randomly-placed object for this material. | | * Get a randomly-placed object for this material. | |
| */ | | */ | |
|
| virtual SGMatModelGroup * get_object_group (int index) const { | | SGMatModelGroup * get_object_group (int index) const { | |
| return object_groups[index]; | | return object_groups[index]; | |
| } | | } | |
| | | | |
|
| | | /** | |
| | | * Return pointer to glyph class, or 0 if it doesn't exist. | |
| | | */ | |
| | | SGMaterialGlyph * get_glyph (const string& name) const; | |
| | | | |
| protected: | | protected: | |
| | | | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| // Protected methods. | | // Protected methods. | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| | | | |
| /** | | /** | |
| * Initialization method, invoked by all public constructors. | | * Initialization method, invoked by all public constructors. | |
| */ | | */ | |
|
| virtual void init(); | | void init(); | |
| | | | |
| protected: | | protected: | |
| | | | |
| struct _internal_state { | | struct _internal_state { | |
| _internal_state( ssgSimpleState *s, const string &t, bool l ) | | _internal_state( ssgSimpleState *s, const string &t, bool l ) | |
| : state(s), texture_path(t), texture_loaded(l) {} | | : state(s), texture_path(t), texture_loaded(l) {} | |
| ssgSharedPtr<ssgSimpleState> state; | | ssgSharedPtr<ssgSimpleState> state; | |
| string texture_path; | | string texture_path; | |
| bool texture_loaded; | | bool texture_loaded; | |
| }; | | }; | |
| | | | |
| skipping to change at line 196 | | skipping to change at line 243 | |
| | | | |
| // wrap texture? | | // wrap texture? | |
| bool wrapu, wrapv; | | bool wrapu, wrapv; | |
| | | | |
| // use mipmapping? | | // use mipmapping? | |
| int mipmap; | | int mipmap; | |
| | | | |
| // coverage of night lighting. | | // coverage of night lighting. | |
| double light_coverage; | | double light_coverage; | |
| | | | |
|
| | | // True if the material is solid, false if it is a fluid | |
| | | bool solid; | |
| | | | |
| | | // the friction factor of that surface material | |
| | | double friction_factor; | |
| | | | |
| | | // the rolling friction of that surface material | |
| | | double rolling_friction; | |
| | | | |
| | | // the bumpiness of that surface material | |
| | | double bumpiness; | |
| | | | |
| | | // the load resistance of that surface material | |
| | | double load_resistance; | |
| | | | |
| // material properties | | // material properties | |
|
| sgVec4 ambient, diffuse, specular, emission; | | SGVec4f ambient, diffuse, specular, emission; | |
| double shininess; | | double shininess; | |
| | | | |
|
| | | // the list of names for this material. May be empty. | |
| | | vector<string> _names; | |
| | | | |
| vector<SGSharedPtr<SGMatModelGroup> > object_groups; | | vector<SGSharedPtr<SGMatModelGroup> > object_groups; | |
|
| | | | |
| | | // taxiway-/runway-sign texture elements | |
| | | map<string, SGSharedPtr<SGMaterialGlyph> > glyphs; | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| // Internal constructors and methods. | | // Internal constructors and methods. | |
| //////////////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////////////// | |
| | | | |
| SGMaterial( const string &fg_root, const SGMaterial &mat ); // unimplemen
ted | | SGMaterial( const string &fg_root, const SGMaterial &mat ); // unimplemen
ted | |
| | | | |
| void read_properties( const string &fg_root, const SGPropertyNode *props,
const char *season ); | | void read_properties( const string &fg_root, const SGPropertyNode *props,
const char *season ); | |
| void build_ssg_state( bool defer_tex_load ); | | void build_ssg_state( bool defer_tex_load ); | |
| void set_ssg_state( ssgSimpleState *s ); | | void set_ssg_state( ssgSimpleState *s ); | |
| | | | |
|
| | | void assignTexture( ssgSimpleState *state, string &fname, int _wrapu = TR | |
| | | UE, int _wrapv = TRUE, int _mipmap = TRUE ); | |
| | | | |
| | | }; | |
| | | | |
| | | class SGMaterialGlyph : public SGReferenced { | |
| | | public: | |
| | | SGMaterialGlyph(SGPropertyNode *); | |
| | | inline double get_left() const { return _left; } | |
| | | inline double get_right() const { return _right; } | |
| | | inline double get_width() const { return _right - _left; } | |
| | | | |
| | | protected: | |
| | | double _left; | |
| | | double _right; | |
| | | }; | |
| | | | |
| | | class SGMaterialUserData : public ssgBase { | |
| | | public: | |
| | | SGMaterialUserData(const SGMaterial* material) : | |
| | | mMaterial(material) | |
| | | {} | |
| | | const SGMaterial* getMaterial() const | |
| | | { return mMaterial; } | |
| | | private: | |
| | | SGSharedPtr<const SGMaterial> mMaterial; | |
| }; | | }; | |
| | | | |
| #endif // _SG_MAT_HXX | | #endif // _SG_MAT_HXX | |
| | | | |
End of changes. 19 change blocks. |
| 13 lines changed or deleted | | 106 lines changed or added | |
|
| nasal.h | | nasal.h | |
| #ifndef _NASAL_H | | #ifndef _NASAL_H | |
| #define _NASAL_H | | #define _NASAL_H | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| #ifndef BYTE_ORDER | | #include "naref.h" | |
| | | | |
|
| # if (BSD >= 199103) | | #if __GNUC__ > 2 | |
| # include <machine/endian.h> | | /* This marks the function as having no side effects and depending on | |
| # elif defined(__CYGWIN__) || defined(__MINGW32__) | | * nothing but its arguments, which allows the optimizer to avoid | |
| # include <sys/param.h> | | * duplicate calls to naNil(). */ | |
| # elif defined(linux) | | #define GCC_PURE __attribute__((__pure__)) | |
| # include <endian.h> | | #else | |
| # else | | #define GCC_PURE | |
| # ifndef LITTLE_ENDIAN | | | |
| # define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ | | | |
| # endif | | | |
| # ifndef BIG_ENDIAN | | | |
| # define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ | | | |
| # endif | | | |
| | | | |
| # if defined(ultrix) || defined(__alpha__) || defined(__alpha) || \ | | | |
| defined(__i386__) || defined(__i486__) || defined(_X86_) || \ | | | |
| defined(sun386) | | | |
| # define BYTE_ORDER LITTLE_ENDIAN | | | |
| # else | | | |
| # define BYTE_ORDER BIG_ENDIAN | | | |
| # endif | | | |
| # endif /* BSD */ | | | |
| #endif /* BYTE_ORDER */ | | | |
| | | | |
| #if BYTE_ORDER == BIG_ENDIAN | | | |
| # include <limits.h> | | | |
| # if (LONG_MAX == 2147483647) | | | |
| # define NASAL_BIG_ENDIAN_32_BIT 1 | | | |
| # endif | | | |
| #endif | | #endif | |
| | | | |
|
| // This is a nasal "reference". They are always copied by value, and | | | |
| // contain either a pointer to a garbage-collectable nasal object | | | |
| // (string, vector, hash) or a floating point number. Keeping the | | | |
| // number here is an optimization to prevent the generation of | | | |
| // zillions of tiny "number" object that have to be collected. Note | | | |
| // sneaky hack: on little endian systems, placing reftag after ptr and | | | |
| // putting 1's in the top 13 (except the sign bit) bits makes the | | | |
| // double value a NaN, and thus unmistakable (no actual number can | | | |
| // appear as a reference, and vice versa). Swap the structure order | | | |
| // on 32 bit big-endian systems. On 64 bit sytems of either | | | |
| // endianness, reftag and the double won't be coincident anyway. | | | |
| #define NASAL_REFTAG 0x7ff56789 // == 2,146,789,257 decimal | | | |
| typedef union { | | | |
| double num; | | | |
| struct { | | | |
| #ifdef NASAL_BIG_ENDIAN_32_BIT | | | |
| int reftag; // Big-endian systems need this here! | | | |
| #endif | | | |
| union { | | | |
| struct naObj* obj; | | | |
| struct naStr* str; | | | |
| struct naVec* vec; | | | |
| struct naHash* hash; | | | |
| struct naCode* code; | | | |
| struct naFunc* func; | | | |
| struct naCCode* ccode; | | | |
| struct naGhost* ghost; | | | |
| } ptr; | | | |
| #ifndef NASAL_BIG_ENDIAN_32_BIT | | | |
| int reftag; // Little-endian and 64 bit systems need this here! | | | |
| #endif | | | |
| } ref; | | | |
| } naRef; | | | |
| | | | |
| typedef struct Context* naContext; | | typedef struct Context* naContext; | |
| | | | |
| // The function signature for an extension function: | | // The function signature for an extension function: | |
| typedef naRef (*naCFunction)(naContext ctx, naRef me, int argc, naRef* args
); | | typedef naRef (*naCFunction)(naContext ctx, naRef me, int argc, naRef* args
); | |
| | | | |
| // All Nasal code runs under the watch of a naContext: | | // All Nasal code runs under the watch of a naContext: | |
| naContext naNewContext(); | | naContext naNewContext(); | |
| void naFreeContext(naContext c); | | void naFreeContext(naContext c); | |
| | | | |
|
| // Save this object in the context, preventing it (and objects | | // Use this when making a call to a new context "underneath" a | |
| | | // preexisting context on the same stack. It allows stack walking to | |
| | | // see through the boundary, and eliminates the need to release the | |
| | | // mod lock (i.e. must be called with the mod lock held!) | |
| | | naContext naSubContext(naContext super); | |
| | | | |
| | | // The naContext supports a user data pointer that can be used to | |
| | | // store data specific to an naCall invocation without exposing it to | |
| | | // Nasal as a ghost. FIXME: this API is semi-dangerous, there is no | |
| | | // provision for sharing it, nor for validating the source or type of | |
| | | // the pointer returned. | |
| | | void naSetUserData(naContext c, void* p); | |
| | | void* naGetUserData(naContext c) GCC_PURE; | |
| | | | |
| | | // "Save" this object in the context, preventing it (and objects | |
| // referenced by it) from being garbage collected. | | // referenced by it) from being garbage collected. | |
| void naSave(naContext ctx, naRef obj); | | void naSave(naContext ctx, naRef obj); | |
| | | | |
| // Similar, but the object is automatically released when the | | // Similar, but the object is automatically released when the | |
| // context next runs native bytecode. Useful for saving off C-space | | // context next runs native bytecode. Useful for saving off C-space | |
| // temporaries to protect them before passing back into a naCall. | | // temporaries to protect them before passing back into a naCall. | |
| void naTempSave(naContext c, naRef r); | | void naTempSave(naContext c, naRef r); | |
| | | | |
|
| // Parse a buffer in memory into a code object. | | // Parse a buffer in memory into a code object. The srcFile parameter | |
| | | // is a Nasal string representing the "file" from which the code is | |
| | | // read. The "first line" is typically 1, but is settable for | |
| | | // situations where the Nasal code is embedded in another context with | |
| | | // its own numbering convetions. If an error occurs, returns nil and | |
| | | // sets the errLine pointer to point to the line at fault. The string | |
| | | // representation of the error can be retrieved with naGetError() on | |
| | | // the context. | |
| naRef naParseCode(naContext c, naRef srcFile, int firstLine, | | naRef naParseCode(naContext c, naRef srcFile, int firstLine, | |
| char* buf, int len, int* errLine); | | char* buf, int len, int* errLine); | |
| | | | |
| // Binds a bare code object (as returned from naParseCode) with a | | // Binds a bare code object (as returned from naParseCode) with a | |
| // closure object (a hash) to act as the outer scope / namespace. | | // closure object (a hash) to act as the outer scope / namespace. | |
|
| // FIXME: this API is weak. It should expose the recursive nature of | | | |
| // closures, and allow for extracting the closure and namespace | | | |
| // information from function objects. | | | |
| naRef naBindFunction(naContext ctx, naRef code, naRef closure); | | naRef naBindFunction(naContext ctx, naRef code, naRef closure); | |
| | | | |
| // Similar, but it binds to the current context's closure (i.e. the | | // Similar, but it binds to the current context's closure (i.e. the | |
| // namespace at the top of the current call stack). | | // namespace at the top of the current call stack). | |
| naRef naBindToContext(naContext ctx, naRef code); | | naRef naBindToContext(naContext ctx, naRef code); | |
| | | | |
|
| // Call a code or function object with the specifed arguments "on" the | | // Call a code or function object with the specified arguments "on" | |
| // specified object and using the specified hash for the local | | // the specified object and using the specified hash for the local | |
| // variables. Any of args, obj or locals may be nil. | | // variables. Passing a null args array skips the parameter variables | |
| naRef naCall(naContext ctx, naRef func, int argc, naRef* args, naRef obj, n | | // (e.g. "arg") assignments; to get a zero-length arg instead, pass in | |
| aRef locals); | | // argc==0 and a non-null args vector. The obj or locals parameters | |
| | | // may be nil. Will attempt to acquire the mod lock, so call | |
| | | // naModUnlock() first if the lock is already held. | |
| | | naRef naCall(naContext ctx, naRef func, int argc, naRef* args, | |
| | | naRef obj, naRef locals); | |
| | | | |
| | | // As naCall(), but continues execution at the operation after a | |
| | | // previous die() call or runtime error. Useful to do "yield" | |
| | | // semantics, leaving the context in a condition where it can be | |
| | | // restarted from C code. Cannot be used currently to restart a | |
| | | // failed operation. Will attempt to acquire the mod lock, so call | |
| | | // naModUnlock() first if the lock is already held. | |
| | | naRef naContinue(naContext ctx); | |
| | | | |
| // Throw an error from the current call stack. This function makes a | | // Throw an error from the current call stack. This function makes a | |
| // longjmp call to a handler in naCall() and DOES NOT RETURN. It is | | // longjmp call to a handler in naCall() and DOES NOT RETURN. It is | |
| // intended for use in library code that cannot otherwise report an | | // intended for use in library code that cannot otherwise report an | |
| // error via the return value, and MUST be used carefully. If in | | // error via the return value, and MUST be used carefully. If in | |
|
| // doubt, return naNil() as your error condition. | | // doubt, return naNil() as your error condition. Works like | |
| void naRuntimeError(naContext ctx, char* msg); | | // printf(). | |
| | | void naRuntimeError(naContext c, const char* fmt, ...); | |
| // Call a method on an object (NOTE: func is a function binding, *not* | | | |
| // a code object as returned from naParseCode). | | // "Re-throws" a runtime error caught from the subcontext. Acts as a | |
| naRef naMethod(naContext ctx, naRef func, naRef object); | | // naRuntimeError() called on the parent context. Does not return. | |
| | | void naRethrowError(naContext subc); | |
| | | | |
| | | // Retrieve the specified member from the object, respecting the | |
| | | // "parents" array as for "object.field". Returns zero for missing | |
| | | // fields. | |
| | | int naMember_get(naRef obj, naRef field, naRef* out); | |
| | | int naMember_cget(naRef obj, const char* field, naRef* out); | |
| | | | |
| // Returns a hash containing functions from the Nasal standard library | | // Returns a hash containing functions from the Nasal standard library | |
| // Useful for passing as a namespace to an initial function call | | // Useful for passing as a namespace to an initial function call | |
|
| naRef naStdLib(naContext c); | | naRef naInit_std(naContext c); | |
| | | | |
| // Ditto, for other core libraries | | // Ditto, for other core libraries | |
|
| naRef naMathLib(naContext c); | | naRef naInit_math(naContext c); | |
| naRef naBitsLib(naContext c); | | naRef naInit_bits(naContext c); | |
| naRef naIOLib(naContext c); | | naRef naInit_io(naContext c); | |
| naRef naRegexLib(naContext c); | | naRef naInit_regex(naContext c); | |
| naRef naUnixLib(naContext c); | | naRef naInit_unix(naContext c); | |
| | | naRef naInit_thread(naContext c); | |
| | | naRef naInit_utf8(naContext c); | |
| | | naRef naInit_sqlite(naContext c); | |
| | | naRef naInit_readline(naContext c); | |
| | | naRef naInit_gtk(naContext ctx); | |
| | | naRef naInit_cairo(naContext ctx); | |
| | | | |
|
| // Current line number & error message | | // Context stack inspection, frame zero is the "top" | |
| int naStackDepth(naContext ctx); | | int naStackDepth(naContext ctx); | |
| int naGetLine(naContext ctx, int frame); | | int naGetLine(naContext ctx, int frame); | |
| naRef naGetSourceFile(naContext ctx, int frame); | | naRef naGetSourceFile(naContext ctx, int frame); | |
| char* naGetError(naContext ctx); | | char* naGetError(naContext ctx); | |
| | | | |
| // Type predicates | | // Type predicates | |
|
| int naIsNil(naRef r); | | int naIsNil(naRef r) GCC_PURE; | |
| int naIsNum(naRef r); | | int naIsNum(naRef r) GCC_PURE; | |
| int naIsString(naRef r); | | int naIsString(naRef r) GCC_PURE; | |
| int naIsScalar(naRef r); | | int naIsScalar(naRef r) GCC_PURE; | |
| int naIsVector(naRef r); | | int naIsVector(naRef r) GCC_PURE; | |
| int naIsHash(naRef r); | | int naIsHash(naRef r) GCC_PURE; | |
| int naIsCode(naRef r); | | int naIsCode(naRef r) GCC_PURE; | |
| int naIsFunc(naRef r); | | int naIsFunc(naRef r) GCC_PURE; | |
| int naIsCCode(naRef r); | | int naIsCCode(naRef r) GCC_PURE; | |
| | | | |
| // Allocators/generators: | | // Allocators/generators: | |
|
| naRef naNil(); | | naRef naNil() GCC_PURE; | |
| naRef naNum(double num); | | naRef naNum(double num) GCC_PURE; | |
| naRef naNewString(naContext c); | | naRef naNewString(naContext c); | |
| naRef naNewVector(naContext c); | | naRef naNewVector(naContext c); | |
| naRef naNewHash(naContext c); | | naRef naNewHash(naContext c); | |
| naRef naNewFunc(naContext c, naRef code); | | naRef naNewFunc(naContext c, naRef code); | |
| naRef naNewCCode(naContext c, naCFunction fptr); | | naRef naNewCCode(naContext c, naCFunction fptr); | |
| | | | |
| // Some useful conversion/comparison routines | | // Some useful conversion/comparison routines | |
|
| int naEqual(naRef a, naRef b); | | int naEqual(naRef a, naRef b) GCC_PURE; | |
| int naStrEqual(naRef a, naRef b); | | int naStrEqual(naRef a, naRef b) GCC_PURE; | |
| int naTrue(naRef b); | | int naTrue(naRef b) GCC_PURE; | |
| naRef naNumValue(naRef n); | | naRef naNumValue(naRef n) GCC_PURE; | |
| naRef naStringValue(naContext c, naRef n); | | naRef naStringValue(naContext c, naRef n); | |
| | | | |
| // String utilities: | | // String utilities: | |
| int naStr_len(naRef s); | | int naStr_len(naRef s); | |
| char* naStr_data(naRef s); | | char* naStr_data(naRef s); | |
| naRef naStr_fromdata(naRef dst, char* data, int len); | | naRef naStr_fromdata(naRef dst, char* data, int len); | |
| naRef naStr_concat(naRef dest, naRef s1, naRef s2); | | naRef naStr_concat(naRef dest, naRef s1, naRef s2); | |
| naRef naStr_substr(naRef dest, naRef str, int start, int len); | | naRef naStr_substr(naRef dest, naRef str, int start, int len); | |
| naRef naInternSymbol(naRef sym); | | naRef naInternSymbol(naRef sym); | |
| | | | |
| | | | |
| skipping to change at line 195 | | skipping to change at line 183 | |
| int naHash_get(naRef hash, naRef key, naRef* out); | | int naHash_get(naRef hash, naRef key, naRef* out); | |
| naRef naHash_cget(naRef hash, char* key); | | naRef naHash_cget(naRef hash, char* key); | |
| void naHash_set(naRef hash, naRef key, naRef val); | | void naHash_set(naRef hash, naRef key, naRef val); | |
| void naHash_cset(naRef hash, char* key, naRef val); | | void naHash_cset(naRef hash, char* key, naRef val); | |
| void naHash_delete(naRef hash, naRef key); | | void naHash_delete(naRef hash, naRef key); | |
| void naHash_keys(naRef dst, naRef hash); | | void naHash_keys(naRef dst, naRef hash); | |
| | | | |
| // Ghost utilities: | | // Ghost utilities: | |
| typedef struct naGhostType { | | typedef struct naGhostType { | |
| void (*destroy)(void* ghost); | | void (*destroy)(void* ghost); | |
|
| | | const char* name; | |
| } naGhostType; | | } naGhostType; | |
| naRef naNewGhost(naContext c, naGhostType* t, void* ghost); | | naRef naNewGhost(naContext c, naGhostType* t, void* ghost); | |
| naGhostType* naGhost_type(naRef ghost); | | naGhostType* naGhost_type(naRef ghost); | |
| void* naGhost_ptr(naRef ghost); | | void* naGhost_ptr(naRef ghost); | |
| int naIsGhost(naRef r); | | int naIsGhost(naRef r); | |
| | | | |
| // Acquires a "modification lock" on a context, allowing the C code to | | // Acquires a "modification lock" on a context, allowing the C code to | |
| // modify Nasal data without fear that such data may be "lost" by the | | // modify Nasal data without fear that such data may be "lost" by the | |
|
| // garbage collector (the C stack is not examined in GC!). This | | // garbage collector (nasal data the C stack is not examined in GC!). | |
| // disallows garbage collection until the current thread can be | | // This disallows garbage collection until the current thread can be | |
| // blocked. The lock should be acquired whenever modifications to | | // blocked. The lock should be acquired whenever nasal objects are | |
| // Nasal objects are made. It need not be acquired when only read | | // being modified. It need not be acquired when only read access is | |
| // access is needed. It MUST NOT be acquired by naCFunction's, as | | // needed, PRESUMING that the Nasal data being read is findable by the | |
| // those are called with the lock already held; acquiring two locks | | // collector (via naSave, for example) and that another Nasal thread | |
| // for the same thread will cause a deadlock when the GC is invoked. | | // cannot or will not delete the reference to the data. It MUST NOT | |
| // It should be UNLOCKED by naCFunction's when they are about to do | | // be acquired by naCFunction's, as those are called with the lock | |
| // any long term non-nasal processing and/or blocking I/O. | | // already held; acquiring two locks for the same thread will cause a | |
| | | // deadlock when the GC is invoked. It should be UNLOCKED by | |
| | | // naCFunction's when they are about to do any long term non-nasal | |
| | | // processing and/or blocking I/O. Note that naModLock() may need to | |
| | | // block to allow garbage collection to occur, and that garbage | |
| | | // collection by other threads may be blocked until naModUnlock() is | |
| | | // called. It must also be UNLOCKED by threads that hold a lock | |
| | | // already before making a naCall() or naContinue() call -- these | |
| | | // functions will attempt to acquire the lock again. | |
| void naModLock(); | | void naModLock(); | |
| void naModUnlock(); | | void naModUnlock(); | |
| | | | |
|
| | | // Library utilities. Generate namespaces and add symbols. | |
| | | typedef struct { char* name; naCFunction func; } naCFuncItem; | |
| | | naRef naGenLib(naContext c, naCFuncItem *funcs); | |
| | | void naAddSym(naContext c, naRef ns, char *sym, naRef val); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } // extern "C" | | } // extern "C" | |
| #endif | | #endif | |
| #endif // _NASAL_H | | #endif // _NASAL_H | |
| | | | |
End of changes. 17 change blocks. |
| 111 lines changed or deleted | | 112 lines changed or added | |
|
| oursun.hxx | | oursun.hxx | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| // | | // | |
| // This library is distributed in the hope that it will be useful, | | // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: oursun.hxx,v 1.7 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: oursun.hxx,v 1.8 2006-07-27 05:15:20 durk Exp $ | |
| | | | |
| #ifndef _SG_SUN_HXX_ | | #ifndef _SG_SUN_HXX_ | |
| #define _SG_SUN_HXX_ | | #define _SG_SUN_HXX_ | |
| | | | |
| #include <plib/ssg.h> | | #include <plib/ssg.h> | |
| | | | |
| #include <simgear/misc/sg_path.hxx> | | #include <simgear/misc/sg_path.hxx> | |
|
| | | #include <simgear/props/props.hxx> | |
| | | | |
| class SGSun { | | class SGSun { | |
| | | | |
| ssgTransform *sun_transform; | | ssgTransform *sun_transform; | |
|
| ssgSimpleState *orb_state; | | ssgSimpleState *sun_state; | |
| ssgSimpleState *halo_state; | | ssgSimpleState *ihalo_state; | |
| | | ssgSimpleState *ohalo_state; | |
| ssgColourArray *cl; | | | |
| | | ssgColourArray *sun_cl; | |
| ssgVertexArray *halo_vl; | | ssgColourArray *ihalo_cl; | |
| ssgTexCoordArray *halo_tl; | | ssgColourArray *ohalo_cl; | |
| | | | |
| | | ssgVertexArray *sun_vl; | |
| | | ssgVertexArray *ihalo_vl; | |
| | | ssgVertexArray *ohalo_vl; | |
| | | | |
| | | ssgTexCoordArray *sun_tl; | |
| | | ssgTexCoordArray *ihalo_tl; | |
| | | ssgTexCoordArray *ohalo_tl; | |
| | | | |
| GLuint sun_texid; | | GLuint sun_texid; | |
| GLubyte *sun_texbuf; | | GLubyte *sun_texbuf; | |
| | | | |
| double visibility; | | double visibility; | |
| double prev_sun_angle; | | double prev_sun_angle; | |
|
| | | // distance of light traveling through the atmosphere | |
| | | double path_distance; | |
| | | | |
| | | SGPropertyNode *env_node; | |
| | | | |
| public: | | public: | |
| | | | |
| // Constructor | | // Constructor | |
| SGSun( void ); | | SGSun( void ); | |
| | | | |
| // Destructor | | // Destructor | |
| ~SGSun( void ); | | ~SGSun( void ); | |
| | | | |
| // return the sun object | | // return the sun object | |
|
| ssgBranch *build( SGPath path, double sun_size ); | | ssgBranch *build( SGPath path, double sun_size, SGPropertyNode *propert
y_tree_Node ); | |
| | | | |
| // repaint the sun colors based on current value of sun_anglein | | // repaint the sun colors based on current value of sun_anglein | |
| // degrees relative to verticle | | // degrees relative to verticle | |
| // 0 degrees = high noon | | // 0 degrees = high noon | |
| // 90 degrees = sun rise/set | | // 90 degrees = sun rise/set | |
| // 180 degrees = darkest midnight | | // 180 degrees = darkest midnight | |
| bool repaint( double sun_angle, double new_visibility ); | | bool repaint( double sun_angle, double new_visibility ); | |
| | | | |
| // reposition the sun at the specified right ascension and | | // reposition the sun at the specified right ascension and | |
| // declination, offset by our current position (p) so that it | | // declination, offset by our current position (p) so that it | |
| // appears fixed at a great distance from the viewer. Also add in | | // appears fixed at a great distance from the viewer. Also add in | |
| // an optional rotation (i.e. for the current time of day.) | | // an optional rotation (i.e. for the current time of day.) | |
| bool reposition( sgVec3 p, double angle, | | bool reposition( sgVec3 p, double angle, | |
| double rightAscension, double declination, | | double rightAscension, double declination, | |
|
| double sun_dist ); | | double sun_dist, double lat, double alt_asl, double sun
_angle ); | |
| | | | |
| // retrun the current color of the sun | | // retrun the current color of the sun | |
|
| inline float *get_color() { return cl->get( 0 ); } | | inline float *get_color() { return ohalo_cl->get( 0 ); } | |
| | | | |
| // return the texture id of the sun halo texture | | // return the texture id of the sun halo texture | |
|
| inline GLuint get_texture_id() { return halo_state->getTextureHandle();
} | | inline GLuint get_texture_id() { return ohalo_state->getTextureHandle()
; } | |
| }; | | }; | |
| | | | |
| #endif // _SG_SUN_HXX_ | | #endif // _SG_SUN_HXX_ | |
| | | | |
End of changes. 8 change blocks. |
| 12 lines changed or deleted | | 25 lines changed or added | |
|
| props.hxx | | props.hxx | |
| /** | | /** | |
| * \file props.hxx | | * \file props.hxx | |
| * Interface definition for a property list. | | * Interface definition for a property list. | |
| * Started Fall 2000 by David Megginson, david@megginson.com | | * Started Fall 2000 by David Megginson, david@megginson.com | |
| * This code is released into the Public Domain. | | * This code is released into the Public Domain. | |
| * | | * | |
| * See props.html for documentation [replace with URL when available]. | | * See props.html for documentation [replace with URL when available]. | |
| * | | * | |
|
| * $Id: props.hxx,v 1.18 2006-03-14 15:55:24 mfranz Exp $ | | * $Id: props.hxx,v 1.18.2.4 2007-05-07 14:03:46 mfranz Exp $ | |
| */ | | */ | |
| | | | |
| #ifndef __PROPS_HXX | | #ifndef __PROPS_HXX | |
| #define __PROPS_HXX | | #define __PROPS_HXX | |
| | | | |
| #ifndef PROPS_STANDALONE | | #ifndef PROPS_STANDALONE | |
| #define PROPS_STANDALONE 0 | | #define PROPS_STANDALONE 0 | |
| #endif | | #endif | |
| | | | |
| #include <vector> | | #include <vector> | |
| | | | |
| skipping to change at line 999 | | skipping to change at line 999 | |
| */ | | */ | |
| void addChangeListener (SGPropertyChangeListener * listener, | | void addChangeListener (SGPropertyChangeListener * listener, | |
| bool initial = false); | | bool initial = false); | |
| | | | |
| /** | | /** | |
| * Remove a change listener from the property. | | * Remove a change listener from the property. | |
| */ | | */ | |
| void removeChangeListener (SGPropertyChangeListener * listener); | | void removeChangeListener (SGPropertyChangeListener * listener); | |
| | | | |
| /** | | /** | |
|
| | | * Get the number of listeners. | |
| | | */ | |
| | | int nListeners () const { return _listeners ? _listeners->size() : 0; } | |
| | | | |
| | | /** | |
| * Fire a value change event to all listeners. | | * Fire a value change event to all listeners. | |
| */ | | */ | |
| void fireValueChanged (); | | void fireValueChanged (); | |
| | | | |
| /** | | /** | |
| * Fire a child-added event to all listeners. | | * Fire a child-added event to all listeners. | |
| */ | | */ | |
| void fireChildAdded (SGPropertyNode * child); | | void fireChildAdded (SGPropertyNode * child); | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 1062 | | skipping to change at line 1067 | |
| /** | | /** | |
| * Trace a read access. | | * Trace a read access. | |
| */ | | */ | |
| void trace_read () const; | | void trace_read () const; | |
| | | | |
| /** | | /** | |
| * Trace a write access. | | * Trace a write access. | |
| */ | | */ | |
| void trace_write () const; | | void trace_write () const; | |
| | | | |
|
| | | /** | |
| | | * Remove this node from all nodes that link to it in their path cache. | |
| | | */ | |
| | | void remove_from_path_caches(); | |
| | | | |
| class hash_table; | | class hash_table; | |
| | | | |
| int _index; | | int _index; | |
| string _name; | | string _name; | |
| mutable string _display_name; | | mutable string _display_name; | |
| /// To avoid cyclic reference counting loops this shall not be a referenc
e | | /// To avoid cyclic reference counting loops this shall not be a referenc
e | |
| /// counted pointer | | /// counted pointer | |
| SGPropertyNode * _parent; | | SGPropertyNode * _parent; | |
| vector<SGPropertyNode_ptr> _children; | | vector<SGPropertyNode_ptr> _children; | |
| vector<SGPropertyNode_ptr> _removedChildren; | | vector<SGPropertyNode_ptr> _removedChildren; | |
|
| | | vector<hash_table *> _linkedNodes; | |
| mutable string _path; | | mutable string _path; | |
| mutable string _buffer; | | mutable string _buffer; | |
| hash_table * _path_cache; | | hash_table * _path_cache; | |
| Type _type; | | Type _type; | |
| bool _tied; | | bool _tied; | |
| int _attr; | | int _attr; | |
| | | | |
| // The right kind of pointer... | | // The right kind of pointer... | |
| union { | | union { | |
| SGPropertyNode * alias; | | SGPropertyNode * alias; | |
| | | | |
| skipping to change at line 1100 | | skipping to change at line 1111 | |
| union { | | union { | |
| bool bool_val; | | bool bool_val; | |
| int int_val; | | int int_val; | |
| long long_val; | | long long_val; | |
| float float_val; | | float float_val; | |
| double double_val; | | double double_val; | |
| char * string_val; | | char * string_val; | |
| } _local_val; | | } _local_val; | |
| | | | |
| vector <SGPropertyChangeListener *> * _listeners; | | vector <SGPropertyChangeListener *> * _listeners; | |
|
| | | | |
| | | /** | |
| | | * Register/unregister node that links to this node in its path cache. | |
| | | */ | |
| | | void add_linked_node (hash_table * node) { _linkedNodes.push_back(node); | |
| | | } | |
| | | bool remove_linked_node (hash_table * node); | |
| /** | | /** | |
|
| * A very simple hash table with no remove functionality. | | * A very simple hash table. | |
| */ | | */ | |
| class hash_table { | | class hash_table { | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * An entry in a bucket in a hash table. | | * An entry in a bucket in a hash table. | |
| */ | | */ | |
| class entry { | | class entry { | |
| public: | | public: | |
| entry (); | | entry (); | |
| ~entry (); | | ~entry (); | |
| const char * get_key () { return _key.c_str(); } | | const char * get_key () { return _key.c_str(); } | |
| void set_key (const char * key); | | void set_key (const char * key); | |
| SGPropertyNode * get_value () { return _value; } | | SGPropertyNode * get_value () { return _value; } | |
| void set_value (SGPropertyNode * value); | | void set_value (SGPropertyNode * value); | |
| private: | | private: | |
| string _key; | | string _key; | |
|
| SGSharedPtr<SGPropertyNode> _value; | | SGSharedPtr<SGPropertyNode> _value; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * A bucket in a hash table. | | * A bucket in a hash table. | |
| */ | | */ | |
| class bucket { | | class bucket { | |
| public: | | public: | |
| bucket (); | | bucket (); | |
| ~bucket (); | | ~bucket (); | |
| entry * get_entry (const char * key, bool create = false); | | entry * get_entry (const char * key, bool create = false); | |
|
| void erase(const char * key); | | bool erase (SGPropertyNode * node); | |
| | | void clear (hash_table * owner); | |
| private: | | private: | |
| int _length; | | int _length; | |
| entry ** _entries; | | entry ** _entries; | |
| }; | | }; | |
| | | | |
| friend class bucket; | | friend class bucket; | |
| | | | |
| hash_table (); | | hash_table (); | |
| ~hash_table (); | | ~hash_table (); | |
| SGPropertyNode * get (const char * key); | | SGPropertyNode * get (const char * key); | |
| void put (const char * key, SGPropertyNode * value); | | void put (const char * key, SGPropertyNode * value); | |
|
| void erase(const char * key); | | bool erase (SGPropertyNode * node); | |
| | | | |
| private: | | private: | |
| unsigned int hashcode (const char * key); | | unsigned int hashcode (const char * key); | |
| unsigned int _data_length; | | unsigned int _data_length; | |
| bucket ** _data; | | bucket ** _data; | |
| }; | | }; | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // __PROPS_HXX | | #endif // __PROPS_HXX | |
| | | | |
End of changes. 9 change blocks. |
| 5 lines changed or deleted | | 24 lines changed or added | |
|
| route.hxx | | route.hxx | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, but | | // This program is distributed in the hope that it will be useful, but | |
| // WITHOUT ANY WARRANTY; without even the implied warranty of | | // WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // General Public License for more details. | | // General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: route.hxx,v 1.2 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: route.hxx,v 1.4.2.1 2007-04-06 09:54:34 mfranz Exp $ | |
| | | | |
| #ifndef _ROUTE_HXX | | #ifndef _ROUTE_HXX | |
| #define _ROUTE_HXX | | #define _ROUTE_HXX | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| | | | |
| | | | |
| skipping to change at line 55 | | skipping to change at line 55 | |
| */ | | */ | |
| | | | |
| class SGRoute { | | class SGRoute { | |
| | | | |
| private: | | private: | |
| | | | |
| typedef vector < SGWayPoint > route_list; | | typedef vector < SGWayPoint > route_list; | |
| route_list route; | | route_list route; | |
| int current_wp; | | int current_wp; | |
| | | | |
|
| | | void update_distance(int index); | |
| | | | |
| public: | | public: | |
| | | | |
| /** Constructor */ | | /** Constructor */ | |
| SGRoute(); | | SGRoute(); | |
| | | | |
| /** Destructor */ | | /** Destructor */ | |
| ~SGRoute(); | | ~SGRoute(); | |
| | | | |
| /** Clear the entire route */ | | /** Clear the entire route */ | |
| inline void clear() { | | inline void clear() { | |
| route.clear(); | | route.clear(); | |
| current_wp = 0; | | current_wp = 0; | |
| } | | } | |
| | | | |
| /** | | /** | |
|
| * Add a waypoint. | | * Add waypoint (default), or insert waypoint at position n. | |
| * @param wp a waypoint | | * @param wp a waypoint | |
| */ | | */ | |
|
| inline void add_waypoint( const SGWayPoint &wp ) { | | void add_waypoint( const SGWayPoint &wp, int n = -1 ); | |
| route.push_back( wp ); | | | |
| | | | |
| int size = route.size(); | | | |
| if ( size > 1 ) { | | | |
| SGWayPoint next_to_last = route[ size - 2 ]; | | | |
| double tmpd, tmpc; | | | |
| wp.CourseAndDistance( next_to_last, &tmpc, &tmpd ); | | | |
| route[size - 1].set_distance( tmpd ); | | | |
| } | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Get the number of waypoints (i.e. route length ) | | * Get the number of waypoints (i.e. route length ) | |
| * @return route length | | * @return route length | |
| */ | | */ | |
| inline int size() const { return route.size(); } | | inline int size() const { return route.size(); } | |
| | | | |
| /** | | /** | |
| * Get the front waypoint. | | * Get the front waypoint. | |
| * @return the first waypoint. | | * @return the first waypoint. | |
| */ | | */ | |
| | | | |
| skipping to change at line 146 | | skipping to change at line 137 | |
| */ | | */ | |
| inline SGWayPoint get_waypoint( const int n ) const { | | inline SGWayPoint get_waypoint( const int n ) const { | |
| if ( n < (int)route.size() ) { | | if ( n < (int)route.size() ) { | |
| return route[n]; | | return route[n]; | |
| } else { | | } else { | |
| return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" )
; | | return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" )
; | |
| } | | } | |
| } | | } | |
| | | | |
| /** Delete the front waypoint */ | | /** Delete the front waypoint */ | |
|
| inline void delete_first() { | | inline void delete_first() { delete_waypoint(0); } | |
| if ( route.size() ) { | | | |
| route.erase( route.begin() ); | | /** Delete waypoint waypoint with index n (last one if n < 0) */ | |
| } | | void delete_waypoint( int n = 0 ); | |
| } | | | |
| | | | |
| /** | | /** | |
| * Calculate perpendicular distance from the current route segment | | * Calculate perpendicular distance from the current route segment | |
| * This routine assumes all points are laying on a flat plane and | | * This routine assumes all points are laying on a flat plane and | |
| * ignores the altitude (or Z) dimension. For most accurate | | * ignores the altitude (or Z) dimension. For most accurate | |
| * results, use with CARTESIAN way points. | | * results, use with CARTESIAN way points. | |
| */ | | */ | |
| double distance_off_route( double x, double y ) const; | | double distance_off_route( double x, double y ) const; | |
| }; | | }; | |
| | | | |
| | | | |
End of changes. 5 change blocks. |
| 19 lines changed or deleted | | 9 lines changed or added | |
|
| sample_openal.hxx | | sample_openal.hxx | |
| | | | |
| skipping to change at line 21 | | skipping to change at line 21 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, but | | // This program is distributed in the hope that it will be useful, but | |
| // WITHOUT ANY WARRANTY; without even the implied warranty of | | // WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // General Public License for more details. | | // General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: sample_openal.hxx,v 1.17 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: sample_openal.hxx,v 1.17.2.1 2007-07-07 18:37:58 mfranz Exp $ | |
| | | | |
| /** | | /** | |
| * \file sample.hxx | | * \file sample.hxx | |
| * Provides a sound sample encapsulation | | * Provides a sound sample encapsulation | |
| */ | | */ | |
| | | | |
| #ifndef _SG_SAMPLE_HXX | | #ifndef _SG_SAMPLE_HXX | |
| #define _SG_SAMPLE_HXX 1 | | #define _SG_SAMPLE_HXX 1 | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| | | | |
| skipping to change at line 55 | | skipping to change at line 55 | |
| #if defined(__APPLE__) | | #if defined(__APPLE__) | |
| # define AL_ILLEGAL_ENUM AL_INVALID_ENUM | | # define AL_ILLEGAL_ENUM AL_INVALID_ENUM | |
| # define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION | | # define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION | |
| # include <OpenAL/al.h> | | # include <OpenAL/al.h> | |
| # include <OpenAL/alut.h> | | # include <OpenAL/alut.h> | |
| #else | | #else | |
| # include <AL/al.h> | | # include <AL/al.h> | |
| # include <AL/alut.h> | | # include <AL/alut.h> | |
| #endif | | #endif | |
| | | | |
|
| | | #ifndef HAVE_WINDOWS_H | |
| | | #ifdef AL_VERSION_1_2 | |
| | | #define USE_OPEN_AL_DOPPLER should work | |
| | | #else | |
| | | #define USE_OPEN_AL_DOPPLER_WITH_FIXED_LISTENER better than nothing | |
| | | #endif | |
| | | #else | |
| | | //the Open_AL Doppler calculation seem to be buggy on windows | |
| | | #define USE_SOFTWARE_DOPPLER seem to be necessary | |
| | | #endif | |
| | | | |
| SG_USING_STD(string); | | SG_USING_STD(string); | |
| | | | |
| /** | | /** | |
| * manages everything we need to know for an individual sound sample | | * manages everything we need to know for an individual sound sample | |
| */ | | */ | |
| | | | |
| class SGSoundSample : public SGReferenced { | | class SGSoundSample : public SGReferenced { | |
| | | | |
| private: | | private: | |
| | | | |
| | | | |
| skipping to change at line 93 | | skipping to change at line 104 | |
| // Velocity of the source sound. | | // Velocity of the source sound. | |
| ALfloat source_vel[3]; | | ALfloat source_vel[3]; | |
| | | | |
| // configuration values | | // configuration values | |
| ALenum format; | | ALenum format; | |
| ALsizei size; | | ALsizei size; | |
| ALsizei freq; | | ALsizei freq; | |
| | | | |
| double pitch; | | double pitch; | |
| double volume; | | double volume; | |
|
| | | #ifdef USE_SOFTWARE_DOPPLER | |
| | | double doppler_pitch_factor; | |
| | | double doppler_volume_factor; | |
| | | #endif | |
| double reference_dist; | | double reference_dist; | |
| double max_dist; | | double max_dist; | |
| ALboolean loop; | | ALboolean loop; | |
| | | | |
| bool playing; | | bool playing; | |
| bool bind_source(); | | bool bind_source(); | |
|
| | | bool no_Doppler_effect; | |
| | | | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Empty constructor, can be used to read data to the systems | | * Empty constructor, can be used to read data to the systems | |
| * memory and not to the driver. | | * memory and not to the driver. | |
| */ | | */ | |
| SGSoundSample(); | | SGSoundSample(); | |
| | | | |
| /** | | /** | |
| * Constructor | | * Constructor | |
| * @param path Path name to sound | | * @param path Path name to sound | |
| * @param file File name of sound | | * @param file File name of sound | |
| should usually be true unless you want to manipulate the data | | should usually be true unless you want to manipulate the data | |
| later.) | | later.) | |
| */ | | */ | |
|
| SGSoundSample( const char *path, const char *file ); | | SGSoundSample( const char *path, const char *file, bool no_Doppler_effe
ct = true ); | |
| | | | |
| /** | | /** | |
| * Constructor. | | * Constructor. | |
| * @param _data Pointer to a memory buffer containing the sample data | | * @param _data Pointer to a memory buffer containing the sample data | |
| the application is responsible for freeing the buffer data. | | the application is responsible for freeing the buffer data. | |
| * @param len Byte length of array | | * @param len Byte length of array | |
| * @param _freq Frequency of the provided data (bytes per second) | | * @param _freq Frequency of the provided data (bytes per second) | |
| should usually be true unless you want to manipulate the data | | should usually be true unless you want to manipulate the data | |
| later.) | | later.) | |
| */ | | */ | |
|
| SGSoundSample( unsigned char *_data, int len, int _freq ); | | SGSoundSample( unsigned char *_data, int len, int _freq, bool no_Dopple
r_effect = true ); | |
| | | | |
| ~SGSoundSample(); | | ~SGSoundSample(); | |
| | | | |
| /** | | /** | |
| * Start playing this sample. | | * Start playing this sample. | |
| * | | * | |
| * @param _loop Define wether the sound should be played in a loop. | | * @param _loop Define wether the sound should be played in a loop. | |
| */ | | */ | |
| void play( bool _loop ); | | void play( bool _loop ); | |
| | | | |
| | | | |
| skipping to change at line 211 | | skipping to change at line 227 | |
| * Set the orientation of the sound source, both for direction | | * Set the orientation of the sound source, both for direction | |
| * and audio cut-off angles. | | * and audio cut-off angles. | |
| */ | | */ | |
| void set_orientation( ALfloat *dir, ALfloat inner_angle=360.0, | | void set_orientation( ALfloat *dir, ALfloat inner_angle=360.0, | |
| ALfloat outer_angle=360.0, | | ALfloat outer_angle=360.0, | |
| ALfloat outer_gain=0.0); | | ALfloat outer_gain=0.0); | |
| | | | |
| /** | | /** | |
| * Set velocity of sound source (uses same coordinate system as opengl) | | * Set velocity of sound source (uses same coordinate system as opengl) | |
| */ | | */ | |
|
| void set_source_vel( ALfloat *vel ); | | void set_source_vel( ALfloat *vel, ALfloat *listener_vel ); | |
| | | | |
| /** | | /** | |
| * Set reference distance of sound (the distance where the gain | | * Set reference distance of sound (the distance where the gain | |
| * will be half.) | | * will be half.) | |
| */ | | */ | |
| void set_reference_dist( ALfloat dist ); | | void set_reference_dist( ALfloat dist ); | |
| | | | |
| /** | | /** | |
| * Set maximume distance of sound (the distance where the sound is | | * Set maximume distance of sound (the distance where the sound is | |
| * no longer audible. | | * no longer audible. | |
| | | | |
End of changes. 7 change blocks. |
| 4 lines changed or deleted | | 20 lines changed or added | |
|
| sg_geodesy.hxx | | sg_geodesy.hxx | |
| #ifndef _SG_GEODESY_HXX | | #ifndef _SG_GEODESY_HXX | |
| #define _SG_GEODESY_HXX | | #define _SG_GEODESY_HXX | |
| | | | |
| #include <simgear/math/point3d.hxx> | | #include <simgear/math/point3d.hxx> | |
| #include "SGMath.hxx" | | #include "SGMath.hxx" | |
| | | | |
|
| // Returns the insersection of the line joining the center of the | | | |
| // earth and the specified cylindrical point with the surface of the | | | |
| // WGS84 ellipsoid. Works by finding a normalization constant (in | | | |
| // squashed space) that places the squashed point on the surface of | | | |
| // the sphere. | | | |
| inline double seaLevelRadius(double r, double z) | | | |
| { | | | |
| double sr = r * SGGeodesy::SQUASH; | | | |
| double zz = z*z; | | | |
| return SGGeodesy::POLRAD*sqrt((r*r + zz)/(sr*sr + zz)); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Convert from geocentric coordinates to geodetic coordinates | | * Convert from geocentric coordinates to geodetic coordinates | |
| * @param lat_geoc (in) Geocentric latitude, radians, + = North | | * @param lat_geoc (in) Geocentric latitude, radians, + = North | |
| * @param radius (in) C.G. radius to earth center (meters) | | * @param radius (in) C.G. radius to earth center (meters) | |
| * @param lat_geod (out) Geodetic latitude, radians, + = North | | * @param lat_geod (out) Geodetic latitude, radians, + = North | |
| * @param alt (out) C.G. altitude above mean sea level (meters) | | * @param alt (out) C.G. altitude above mean sea level (meters) | |
| * @param sea_level_r (out) radius from earth center to sea level at | | * @param sea_level_r (out) radius from earth center to sea level at | |
| * local vertical (surface normal) of C.G. (meters) | | * local vertical (surface normal) of C.G. (meters) | |
| */ | | */ | |
| inline void sgGeocToGeod(double lat_geoc, double radius, | | inline void sgGeocToGeod(double lat_geoc, double radius, | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 47 | |
| * | | * | |
| * @param lat_geod (in) Geodetic latitude, radians, + = North | | * @param lat_geod (in) Geodetic latitude, radians, + = North | |
| * @param alt (in) C.G. altitude above mean sea level (meters) | | * @param alt (in) C.G. altitude above mean sea level (meters) | |
| * @param sl_radius (out) SEA LEVEL radius to earth center (meters) | | * @param sl_radius (out) SEA LEVEL radius to earth center (meters) | |
| * @param lat_geoc (out) Geocentric latitude, radians, + = North | | * @param lat_geoc (out) Geocentric latitude, radians, + = North | |
| */ | | */ | |
| inline void sgGeodToGeoc(double lat_geod, double alt, | | inline void sgGeodToGeoc(double lat_geod, double alt, | |
| double *sl_radius, double *lat_geoc) | | double *sl_radius, double *lat_geoc) | |
| { | | { | |
| SGVec3<double> cart; | | SGVec3<double> cart; | |
|
| SGGeodesy::SGGeodToCart(SGGeod::fromRadM(0, lat_geod, alt), cart); | | SGGeod geod = SGGeod::fromRadM(0, lat_geod, alt); | |
| | | SGGeodesy::SGGeodToCart(geod, cart); | |
| SGGeoc geoc; | | SGGeoc geoc; | |
| SGGeodesy::SGCartToGeoc(cart, geoc); | | SGGeodesy::SGCartToGeoc(cart, geoc); | |
| *lat_geoc = geoc.getLatitudeRad(); | | *lat_geoc = geoc.getLatitudeRad(); | |
|
| *sl_radius = seaLevelRadius(cart(0), cart(2)); | | *sl_radius = SGGeodesy::SGGeodToSeaLevelRadius(geod); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Convert a cartesian point to a geodetic lat/lon/altitude. | | * Convert a cartesian point to a geodetic lat/lon/altitude. | |
| * | | * | |
| * @param xyz (in) Pointer to cartesian point. | | * @param xyz (in) Pointer to cartesian point. | |
| * @param lat (out) Latitude, in radians | | * @param lat (out) Latitude, in radians | |
| * @param lon (out) Longitude, in radians | | * @param lon (out) Longitude, in radians | |
| * @param alt (out) Altitude, in meters above the WGS84 ellipsoid | | * @param alt (out) Altitude, in meters above the WGS84 ellipsoid | |
| */ | | */ | |
| | | | |
| skipping to change at line 131 | | skipping to change at line 120 | |
| inline Point3D sgGeodToCart(const Point3D& geod) | | inline Point3D sgGeodToCart(const Point3D& geod) | |
| { | | { | |
| SGVec3<double> cart; | | SGVec3<double> cart; | |
| SGGeodesy::SGGeodToCart(SGGeod::fromRadM(geod.lon(), geod.lat(), geod.ele
v()), cart); | | SGGeodesy::SGGeodToCart(SGGeod::fromRadM(geod.lon(), geod.lat(), geod.ele
v()), cart); | |
| return Point3D::fromSGVec3(cart); | | return Point3D::fromSGVec3(cart); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Given a starting position and an offset radial and distance, | | * Given a starting position and an offset radial and distance, | |
| * calculate an ending positon on a wgs84 ellipsoid. | | * calculate an ending positon on a wgs84 ellipsoid. | |
|
| * @param alt (in) meters | | * @param alt (in) meters (unused) | |
| * @param lat1 (in) degrees | | * @param lat1 (in) degrees | |
| * @param lon1 (in) degrees | | * @param lon1 (in) degrees | |
| * @param az1 (in) degrees | | * @param az1 (in) degrees | |
| * @param s (in) distance in meters | | * @param s (in) distance in meters | |
| * @param lat2 (out) degrees | | * @param lat2 (out) degrees | |
| * @param lon2 (out) degrees | | * @param lon2 (out) degrees | |
| * @param az2 (out) return course in degrees | | * @param az2 (out) return course in degrees | |
| */ | | */ | |
|
| int geo_direct_wgs_84 ( double alt, double lat1, | | int geo_direct_wgs_84 ( double lat1, double lon1, double az1, | |
| double lon1, double az1, | | | |
| double s, double *lat2, double *lon2, | | double s, double *lat2, double *lon2, | |
| double *az2 ); | | double *az2 ); | |
|
| | | inline int geo_direct_wgs_84 ( double alt, double lat1, | |
| | | double lon1, double az1, | |
| | | double s, double *lat2, double *lon2, | |
| | | double *az2 ) | |
| | | { return geo_direct_wgs_84(lat1, lon1, az1, s, lat2, lon2, az2); } | |
| | | | |
| | | /** | |
| | | * Given a starting position and an offset radial and distance, | |
| | | * calculate an ending positon on a wgs84 ellipsoid. | |
| | | * @param p1 (in) geodetic position | |
| | | * @param az1 (in) degrees | |
| | | * @param s (in) distance in meters | |
| | | * @param p2 (out) geodetic position | |
| | | * @param az2 (out) return course in degrees | |
| | | */ | |
| | | inline int geo_direct_wgs_84(const SGGeod& p1, double az1, | |
| | | double s, SGGeod& p2, double *az2 ) | |
| | | { | |
| | | double lat2, lon2; | |
| | | int ret = geo_direct_wgs_84(p1.getLatitudeDeg(), p1.getLongitudeDeg(), | |
| | | az1, s, &lat2, &lon2, az2); | |
| | | p2.setLatitudeDeg(lat2); | |
| | | p2.setLongitudeDeg(lon2); | |
| | | return ret; | |
| | | } | |
| | | | |
| /** | | /** | |
| * Given an altitude and two sets of (lat, lon) calculate great circle | | * Given an altitude and two sets of (lat, lon) calculate great circle | |
| * distance between them as well as the starting and ending azimuths. | | * distance between them as well as the starting and ending azimuths. | |
|
| * @param alt (in) meters | | * @param alt (in) meters (unused) | |
| * @param lat1 (in) degrees | | * @param lat1 (in) degrees | |
| * @param lon1 (in) degrees | | * @param lon1 (in) degrees | |
| * @param lat2 (in) degrees | | * @param lat2 (in) degrees | |
| * @param lon2 (in) degrees | | * @param lon2 (in) degrees | |
| * @param az1 (out) start heading degrees | | * @param az1 (out) start heading degrees | |
| * @param az2 (out) end heading degrees | | * @param az2 (out) end heading degrees | |
| * @param s (out) distance meters | | * @param s (out) distance meters | |
| */ | | */ | |
|
| int geo_inverse_wgs_84( double alt, double lat1, | | int geo_inverse_wgs_84( double lat1, double lon1, double lat2, | |
| double lon1, double lat2, | | | |
| double lon2, double *az1, double *az2, | | double lon2, double *az1, double *az2, | |
| double *s ); | | double *s ); | |
|
| | | inline int geo_inverse_wgs_84( double alt, double lat1, | |
| | | double lon1, double lat2, | |
| | | double lon2, double *az1, double *az2, | |
| | | double *s ) | |
| | | { return geo_inverse_wgs_84(lat1, lon1, lat2, lon2, az1, az2, s); } | |
| | | | |
| | | /** | |
| | | * Given an altitude and two sets of (lat, lon) calculate great circle | |
| | | * distance between them as well as the starting and ending azimuths. | |
| | | * @param p1 (in) first position | |
| | | * @param p2 (in) fsecond position | |
| | | * @param az1 (out) start heading degrees | |
| | | * @param az2 (out) end heading degrees | |
| | | * @param s (out) distance meters | |
| | | */ | |
| | | inline int geo_inverse_wgs_84(const SGGeod& p1, const SGGeod& p2, | |
| | | double *az1, double *az2, double *s ) | |
| | | { | |
| | | return geo_inverse_wgs_84(p1.getLatitudeDeg(), p1.getLongitudeDeg(), | |
| | | p2.getLatitudeDeg(), p2.getLongitudeDeg(), | |
| | | az1, az2, s); | |
| | | } | |
| | | | |
| #endif // _SG_GEODESY_HXX | | #endif // _SG_GEODESY_HXX | |
| | | | |
End of changes. 9 change blocks. |
| 20 lines changed or deleted | | 54 lines changed or added | |
|
| sky.hxx | | sky.hxx | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| // | | // | |
| // This library is distributed in the hope that it will be useful, | | // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Library General Public License for more details. | | // Library General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: sky.hxx,v 1.17 2006-03-08 18:16:09 mfranz Exp $ | | // $Id: sky.hxx,v 1.18 2006-07-27 05:15:20 durk Exp $ | |
| | | | |
| #ifndef _SG_SKY_HXX | | #ifndef _SG_SKY_HXX | |
| #define _SG_SKY_HXX | | #define _SG_SKY_HXX | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # error This library requires C++ | | # error This library requires C++ | |
| #endif | | #endif | |
| | | | |
| #include <plib/ssg.h> // plib include | | #include <plib/ssg.h> // plib include | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| #include <simgear/misc/sg_path.hxx> | | #include <simgear/misc/sg_path.hxx> | |
|
| | | #include <simgear/props/props.hxx> | |
| | | | |
| #include <vector> | | #include <vector> | |
| | | | |
| #include <simgear/scene/sky/cloud.hxx> | | #include <simgear/scene/sky/cloud.hxx> | |
| #include <simgear/scene/sky/dome.hxx> | | #include <simgear/scene/sky/dome.hxx> | |
| #include <simgear/scene/sky/moon.hxx> | | #include <simgear/scene/sky/moon.hxx> | |
| #include <simgear/scene/sky/oursun.hxx> | | #include <simgear/scene/sky/oursun.hxx> | |
| #include <simgear/scene/sky/stars.hxx> | | #include <simgear/scene/sky/stars.hxx> | |
| | | | |
| SG_USING_STD(vector); | | SG_USING_STD(vector); | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 60 | |
| typedef vector < SGCloudLayer* > layer_list_type; | | typedef vector < SGCloudLayer* > layer_list_type; | |
| typedef layer_list_type::iterator layer_list_iterator; | | typedef layer_list_type::iterator layer_list_iterator; | |
| typedef layer_list_type::const_iterator layer_list_const_iterator; | | typedef layer_list_type::const_iterator layer_list_const_iterator; | |
| | | | |
| typedef struct { | | typedef struct { | |
| float *view_pos, *zero_elev, *view_up; | | float *view_pos, *zero_elev, *view_up; | |
| double lon, lat, alt, spin; | | double lon, lat, alt, spin; | |
| double gst; | | double gst; | |
| double sun_ra, sun_dec, sun_dist; | | double sun_ra, sun_dec, sun_dist; | |
| double moon_ra, moon_dec, moon_dist; | | double moon_ra, moon_dec, moon_dist; | |
|
| | | double sun_angle; | |
| } SGSkyState; | | } SGSkyState; | |
| | | | |
| typedef struct { | | typedef struct { | |
| float *sky_color, *fog_color, *cloud_color; | | float *sky_color, *fog_color, *cloud_color; | |
| double sun_angle, moon_angle; | | double sun_angle, moon_angle; | |
| int nplanets, nstars; | | int nplanets, nstars; | |
| sgdVec3 *planet_data, *star_data; | | sgdVec3 *planet_data, *star_data; | |
| } SGSkyColor; | | } SGSkyColor; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 258 | | skipping to change at line 260 | |
| * @param nplanets number of planets | | * @param nplanets number of planets | |
| * @param planet_data an array of planet right ascensions, declinations
, | | * @param planet_data an array of planet right ascensions, declinations
, | |
| * and magnitudes | | * and magnitudes | |
| * @param nstars number of stars | | * @param nstars number of stars | |
| * @param star_data an array of star right ascensions, declinations, | | * @param star_data an array of star right ascensions, declinations, | |
| * and magnitudes | | * and magnitudes | |
| */ | | */ | |
| void build( double h_radius_m, double v_radius_m, | | void build( double h_radius_m, double v_radius_m, | |
| double sun_size, double moon_size, | | double sun_size, double moon_size, | |
| int nplanets, sgdVec3 *planet_data, | | int nplanets, sgdVec3 *planet_data, | |
|
| int nstars, sgdVec3 *star_data ); | | int nstars, sgdVec3 *star_data, SGPropertyNode *property_tre
e_node ); | |
| | | | |
| /** | | /** | |
| * Repaint the sky components based on current value of sun_angle, | | * Repaint the sky components based on current value of sun_angle, | |
| * sky, and fog colors. You can also specify new star and planet | | * sky, and fog colors. You can also specify new star and planet | |
| * data so that we can optionally change the magnitude of these | | * data so that we can optionally change the magnitude of these | |
| * (for day/night transitions.) See discussion in detailed | | * (for day/night transitions.) See discussion in detailed | |
| * class description. | | * class description. | |
| * | | * | |
| * Sun and moon angles are specified in degrees relative to local up | | * Sun and moon angles are specified in degrees relative to local up | |
| * <li> 0 degrees = high noon | | * <li> 0 degrees = high noon | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 4 lines changed or added | |
|
| subsystem_mgr.hxx | | subsystem_mgr.hxx | |
| | | | |
| skipping to change at line 19 | | skipping to change at line 19 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, but | | // This program is distributed in the hope that it will be useful, but | |
| // WITHOUT ANY WARRANTY; without even the implied warranty of | | // WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // General Public License for more details. | | // General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU General Public License | | // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | | // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1, USA. | |
| // | | // | |
|
| // $Id: subsystem_mgr.hxx,v 1.3 2006-03-08 18:16:10 mfranz Exp $ | | // $Id: subsystem_mgr.hxx,v 1.3.2.4 2007-11-17 09:18:35 durk Exp $ | |
| | | | |
| #ifndef __SUBSYSTEM_MGR_HXX | | #ifndef __SUBSYSTEM_MGR_HXX | |
| #define __SUBSYSTEM_MGR_HXX 1 | | #define __SUBSYSTEM_MGR_HXX 1 | |
| | | | |
| #include <simgear/compiler.h> | | #include <simgear/compiler.h> | |
| | | | |
| #if 0 | | #if 0 | |
| #ifdef HAVE_WINDOWS_H | | #ifdef HAVE_WINDOWS_H | |
| # include <windows.h> | | # include <windows.h> | |
| # include <float.h> | | # include <float.h> | |
| #endif | | #endif | |
| | | | |
| #include STL_STRING | | #include STL_STRING | |
| SG_USING_STD(string); | | SG_USING_STD(string); | |
| | | | |
| #include <vector> | | #include <vector> | |
| SG_USING_STD(vector); | | SG_USING_STD(vector); | |
| #endif | | #endif | |
| | | | |
|
| | | #include <string> | |
| #include <map> | | #include <map> | |
|
| | | #include <vector> | |
| SG_USING_STD(map); | | SG_USING_STD(map); | |
|
| | | SG_USING_STD(vector); | |
| | | SG_USING_STD(string); | |
| | | | |
| #include <simgear/props/props.hxx> | | #include <simgear/props/props.hxx> | |
|
| | | #include <simgear/timing/timestamp.hxx> | |
| | | #include "SGSmplstat.hxx" | |
| | | | |
| | | class TimingInfo | |
| | | { | |
| | | private: | |
| | | string eventName; | |
| | | SGTimeStamp time; | |
| | | | |
| | | public: | |
| | | TimingInfo(string name, SGTimeStamp &t) { eventName = name; time = t;}; | |
| | | string getName() { return eventName; }; | |
| | | SGTimeStamp getTime() { return time; }; | |
| | | }; | |
| | | | |
| | | typedef vector<TimingInfo> eventTimeVec; | |
| | | typedef vector<TimingInfo>::iterator eventTimeVecIterator; | |
| /** | | /** | |
| * Basic interface for all FlightGear subsystems. | | * Basic interface for all FlightGear subsystems. | |
| * | | * | |
| * <p>This is an abstract interface that all FlightGear subsystems | | * <p>This is an abstract interface that all FlightGear subsystems | |
| * will eventually implement. It defines the basic operations for | | * will eventually implement. It defines the basic operations for | |
| * each subsystem: initialization, property binding and unbinding, and | | * each subsystem: initialization, property binding and unbinding, and | |
| * updating. Interfaces may define additional methods, but the | | * updating. Interfaces may define additional methods, but the | |
| * preferred way of exchanging information with other subsystems is | | * preferred way of exchanging information with other subsystems is | |
| * through the property tree.</p> | | * through the property tree.</p> | |
| * | | * | |
| | | | |
| skipping to change at line 223 | | skipping to change at line 244 | |
| */ | | */ | |
| virtual void resume (); | | virtual void resume (); | |
| | | | |
| /** | | /** | |
| * Test whether this subsystem is suspended. | | * Test whether this subsystem is suspended. | |
| * | | * | |
| * @return true if the subsystem is suspended, false if it is not. | | * @return true if the subsystem is suspended, false if it is not. | |
| */ | | */ | |
| virtual bool is_suspended () const; | | virtual bool is_suspended () const; | |
| | | | |
|
| | | /** | |
| | | * Keep track of execution time. | |
| | | * | |
| | | * <p>This method keeps track of timing statistics for each subsystem.</p | |
| | | > | |
| | | * | |
| | | * @param time execution time in ms of last call. | |
| | | */ | |
| | | void updateExecutionTime(double time); | |
| | | | |
| | | /** | |
| | | * Print details of execution time. | |
| | | * | |
| | | * <p>For debugging purposes, developers can place stamp() calls | |
| | | * at strategic points in the update() function of each subsystem, which | |
| | | * record the time between the successive calls to stamp. This method, | |
| | | * printExecutionTime() is called after exectution of the subsystem | |
| | | * update function itself to conduct a post-hoc analysis of excecution | |
| | | * time</p> | |
| | | */ | |
| | | void printTimingInformation(); | |
| | | | |
| | | /** | |
| | | * Place time stamps at strategic points in the execution of subsystems | |
| | | * update() member functions. Predominantly for debugging purposes. | |
| | | */ | |
| | | void stamp(string name); | |
| | | | |
| protected: | | protected: | |
| | | | |
| bool _suspended; | | bool _suspended; | |
| | | | |
|
| | | eventTimeVec timingInfo; | |
| | | //int test; | |
| | | | |
| }; | | }; | |
| /** | | /** | |
| * A group of FlightGear subsystems. | | * A group of FlightGear subsystems. | |
| */ | | */ | |
| class SGSubsystemGroup : public SGSubsystem | | class SGSubsystemGroup : public SGSubsystem | |
| { | | { | |
| public: | | public: | |
| | | | |
| SGSubsystemGroup (); | | SGSubsystemGroup (); | |
| virtual ~SGSubsystemGroup (); | | virtual ~SGSubsystemGroup (); | |
| | | | |
| skipping to change at line 255 | | skipping to change at line 306 | |
| virtual void resume (); | | virtual void resume (); | |
| virtual bool is_suspended () const; | | virtual bool is_suspended () const; | |
| | | | |
| virtual void set_subsystem (const string &name, | | virtual void set_subsystem (const string &name, | |
| SGSubsystem * subsystem, | | SGSubsystem * subsystem, | |
| double min_step_sec = 0); | | double min_step_sec = 0); | |
| virtual SGSubsystem * get_subsystem (const string &name); | | virtual SGSubsystem * get_subsystem (const string &name); | |
| virtual void remove_subsystem (const string &name); | | virtual void remove_subsystem (const string &name); | |
| virtual bool has_subsystem (const string &name) const; | | virtual bool has_subsystem (const string &name) const; | |
| | | | |
|
| | | void collectDebugTiming(bool collect); | |
| | | | |
| private: | | private: | |
| | | | |
| struct Member { | | struct Member { | |
| | | | |
| Member (); | | Member (); | |
| Member (const Member &member); | | Member (const Member &member); | |
| virtual ~Member (); | | virtual ~Member (); | |
| | | | |
| virtual void update (double delta_time_sec); | | virtual void update (double delta_time_sec); | |
|
| | | void printTimingInformation(double time); | |
| | | void printTimingStatistics(); | |
| | | void updateExecutionTime(double time); | |
| | | double getTimeWarningThreshold(); | |
| | | void collectDebugTiming (bool collect) { collectTimeStats = collect | |
| | | ; }; | |
| | | | |
|
| | | SampleStatistic timeStat; | |
| string name; | | string name; | |
| SGSubsystem * subsystem; | | SGSubsystem * subsystem; | |
| double min_step_sec; | | double min_step_sec; | |
| double elapsed_sec; | | double elapsed_sec; | |
|
| | | bool collectTimeStats; | |
| }; | | }; | |
| | | | |
| Member * get_member (const string &name, bool create = false); | | Member * get_member (const string &name, bool create = false); | |
| | | | |
| vector<Member *> _members; | | vector<Member *> _members; | |
| }; | | }; | |
| /** | | /** | |
| * Manage subsystems for FlightGear. | | * Manage subsystems for FlightGear. | |
| * | | * | |
| * This top-level subsystem will eventually manage all of the | | * This top-level subsystem will eventually manage all of the | |
| | | | |
| skipping to change at line 327 | | skipping to change at line 387 | |
| | | | |
| virtual void add (const char * name, | | virtual void add (const char * name, | |
| SGSubsystem * subsystem, | | SGSubsystem * subsystem, | |
| GroupType group = GENERAL, | | GroupType group = GENERAL, | |
| double min_time_sec = 0); | | double min_time_sec = 0); | |
| | | | |
| virtual SGSubsystemGroup * get_group (GroupType group); | | virtual SGSubsystemGroup * get_group (GroupType group); | |
| | | | |
| virtual SGSubsystem * get_subsystem(const string &name); | | virtual SGSubsystem * get_subsystem(const string &name); | |
| | | | |
|
| | | void collectDebugTiming(bool collect); | |
| | | | |
| private: | | private: | |
| | | | |
| SGSubsystemGroup _groups[MAX_GROUPS]; | | SGSubsystemGroup _groups[MAX_GROUPS]; | |
| map<string,SGSubsystem *> _subsystem_map; | | map<string,SGSubsystem *> _subsystem_map; | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // __SUBSYSTEM_MGR_HXX | | #endif // __SUBSYSTEM_MGR_HXX | |
| | | | |
End of changes. 12 change blocks. |
| 1 lines changed or deleted | | 65 lines changed or added | |
|