2001-12-01 06:22:24 +00:00
|
|
|
#ifndef _MODEL_HPP
|
|
|
|
#define _MODEL_HPP
|
|
|
|
|
|
|
|
#include "Integrator.hpp"
|
|
|
|
#include "RigidBody.hpp"
|
|
|
|
#include "BodyEnvironment.hpp"
|
|
|
|
#include "util/Vector.hpp"
|
|
|
|
|
|
|
|
namespace yasim {
|
|
|
|
|
|
|
|
// Declare the types whose pointers get passed around here
|
|
|
|
class Integrator;
|
|
|
|
class Thruster;
|
|
|
|
class Surface;
|
|
|
|
class Gear;
|
|
|
|
|
|
|
|
class Model : public BodyEnvironment {
|
|
|
|
public:
|
|
|
|
Model();
|
|
|
|
virtual ~Model();
|
|
|
|
|
|
|
|
RigidBody* getBody();
|
|
|
|
Integrator* getIntegrator();
|
|
|
|
|
|
|
|
State* getState();
|
|
|
|
void setState(State* s);
|
|
|
|
|
|
|
|
void iterate();
|
|
|
|
|
|
|
|
// Externally-managed subcomponents
|
|
|
|
int addThruster(Thruster* t);
|
|
|
|
int addSurface(Surface* surf);
|
|
|
|
int addGear(Gear* gear);
|
|
|
|
Surface* getSurface(int handle);
|
|
|
|
Gear* getGear(int handle);
|
|
|
|
|
|
|
|
// Semi-private methods for use by the Airplane solver.
|
2001-12-06 18:13:24 +00:00
|
|
|
int numThrusters();
|
2001-12-01 06:22:24 +00:00
|
|
|
Thruster* getThruster(int handle);
|
|
|
|
void setThruster(int handle, Thruster* t);
|
|
|
|
void initIteration();
|
|
|
|
void getThrust(float* out);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Per-iteration settables
|
|
|
|
//
|
|
|
|
void setGroundPlane(double* planeNormal, double fromOrigin);
|
2001-12-06 18:13:24 +00:00
|
|
|
void setGroundEffect(float* pos, float span, float mul);
|
2001-12-01 06:22:24 +00:00
|
|
|
void setWind(float* wind);
|
|
|
|
void setAir(float pressure, float temp);
|
|
|
|
|
|
|
|
// BodyEnvironment callbacks
|
|
|
|
virtual void calcForces(State* s);
|
|
|
|
virtual void newState(State* s);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void calcGearForce(Gear* g, float* v, float* rot, float* ground);
|
|
|
|
float gearFriction(float wgt, float v, Gear* g);
|
|
|
|
float localGround(State* s, float* out);
|
|
|
|
void localWind(float* pos, State* s, float* out);
|
|
|
|
|
|
|
|
Integrator _integrator;
|
|
|
|
RigidBody _body;
|
|
|
|
|
|
|
|
Vector _thrusters;
|
|
|
|
Vector _surfaces;
|
|
|
|
Vector _gears;
|
|
|
|
|
2001-12-06 18:13:24 +00:00
|
|
|
float _groundEffectSpan;
|
|
|
|
float _groundEffect;
|
|
|
|
float _wingCenter[3];
|
|
|
|
|
2001-12-01 06:22:24 +00:00
|
|
|
double _ground[4];
|
2001-12-06 18:13:24 +00:00
|
|
|
float _P;
|
|
|
|
float _T;
|
2001-12-01 06:22:24 +00:00
|
|
|
float _rho;
|
|
|
|
float _wind[3];
|
|
|
|
|
|
|
|
// Accumulators for the total internal gyro and engine torque
|
|
|
|
float _gyro[3];
|
|
|
|
float _torque[3];
|
|
|
|
|
|
|
|
State* _s;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace yasim
|
|
|
|
#endif // _MODEL_HPP
|