Merge branch 'next' of git://gitorious.org/fg/simgear into next

This commit is contained in:
Erik Hofman
2010-07-23 20:05:40 +02:00
3 changed files with 17 additions and 2 deletions

View File

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

View File

@@ -62,11 +62,13 @@ void GlobalParticleCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
osg::Matrix om(toOsg(q));
osg::Vec3 v(0,0,9.81);
gravity = om.preMult(v);
// NOTE: THIS WIND COMPUTATION DOESN'T SEEM TO AFFECT PARTICLES
const osg::Vec3& zUpWind = Particles::getWindVector();
osg::Vec3 w(zUpWind.y(), zUpWind.x(), - zUpWind.z());
osg::Vec3 w(zUpWind.y(), zUpWind.x(), -zUpWind.z());
wind = om.preMult(w);
//SG_LOG(SG_GENERAL, SG_ALERT, "wind vector:"<<w[0]<<","<<w[1]<<","<<w[2]<<"\n");
// SG_LOG(SG_GENERAL, SG_ALERT,
// "wind vector:" << w[0] << "," <<w[1] << "," << w[2]);
}

View File

@@ -257,6 +257,13 @@ public:
* magnitude is the velocity in meters per second.
*/
static void setWindVector(const osg::Vec3& wind) { _wind = wind; }
static void setWindFrom(const double from_deg, const double speed_kt) {
double map_rad = -from_deg * SG_DEGREES_TO_RADIANS;
double speed_mps = speed_kt * SG_KT_TO_MPS;
_wind[0] = cos(map_rad) * speed_mps;
_wind[1] = sin(map_rad) * speed_mps;
_wind[2] = 0.0;
}
static const osg::Vec3& getWindVector() { return _wind; }
protected:
float shooterExtraRange;