2002-02-23 21:20:00 +00:00
|
|
|
// model.hxx - manage a 3D aircraft model.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain, and comes with no warranty.
|
|
|
|
|
|
|
|
#ifndef __MODEL_HXX
|
|
|
|
#define __MODEL_HXX 1
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
SG_USING_STD(string);
|
|
|
|
SG_USING_STD(vector);
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
#include "fgfs.hxx"
|
2002-02-25 20:07:34 +00:00
|
|
|
#include <simgear/misc/props.hxx>
|
2002-02-23 21:20:00 +00:00
|
|
|
#include <simgear/timing/timestamp.hxx>
|
|
|
|
|
|
|
|
class FGAircraftModel : public FGSubsystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
FGAircraftModel ();
|
|
|
|
virtual ~FGAircraftModel ();
|
|
|
|
|
|
|
|
virtual void init ();
|
|
|
|
virtual void bind ();
|
|
|
|
virtual void unbind ();
|
|
|
|
virtual void update (int dt);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
struct Animation
|
|
|
|
{
|
|
|
|
enum Type {
|
|
|
|
None,
|
2002-02-26 14:30:04 +00:00
|
|
|
Spin,
|
|
|
|
Rotate
|
2002-02-26 00:10:06 +00:00
|
|
|
};
|
|
|
|
string name;
|
|
|
|
Type type;
|
|
|
|
ssgTransform * transform;
|
|
|
|
sgMat4 matrix;
|
|
|
|
SGPropertyNode * prop;
|
2002-02-26 14:30:04 +00:00
|
|
|
float factor;
|
2002-02-27 12:46:38 +00:00
|
|
|
float offset;
|
2002-02-26 00:10:06 +00:00
|
|
|
float position;
|
2002-02-27 12:46:38 +00:00
|
|
|
sgVec3 center;
|
|
|
|
sgVec3 axis;
|
|
|
|
void setRotation ();
|
2002-02-26 00:10:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Animation read_animation (const SGPropertyNode * node);
|
|
|
|
void do_animation (Animation &animation, long elapsed_ms);
|
|
|
|
|
|
|
|
ssgEntity * _model;
|
2002-02-23 21:20:00 +00:00
|
|
|
ssgSelector * _selector;
|
|
|
|
ssgTransform * _position;
|
|
|
|
|
|
|
|
SGTimeStamp _last_timestamp;
|
|
|
|
SGTimeStamp _current_timestamp;
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
vector<Animation> _animations;
|
2002-02-23 21:20:00 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FGAircraftModel current_model;
|
|
|
|
|
|
|
|
#endif // __MODEL_HXX
|
|
|
|
|