81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
|
#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.
|
||
|
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);
|
||
|
void setWind(float* wind);
|
||
|
void setAirDensity(float rho);
|
||
|
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;
|
||
|
|
||
|
double _ground[4];
|
||
|
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
|