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>
|
|
|
|
|
2002-03-27 13:00:25 +00:00
|
|
|
// Has anyone done anything *really* stupid, like making min and max macros?
|
|
|
|
#ifdef min
|
|
|
|
#undef min
|
|
|
|
#endif
|
|
|
|
#ifdef max
|
|
|
|
#undef max
|
|
|
|
#endif
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
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
|
|
|
|
{
|
2002-03-26 03:14:20 +00:00
|
|
|
Animation ();
|
|
|
|
virtual ~Animation ();
|
2002-02-26 00:10:06 +00:00
|
|
|
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-03-02 16:07:42 +00:00
|
|
|
bool has_min;
|
|
|
|
float min;
|
|
|
|
bool has_max;
|
|
|
|
float max;
|
2002-02-27 12:46:38 +00:00
|
|
|
sgVec3 center;
|
|
|
|
sgVec3 axis;
|
|
|
|
void setRotation ();
|
2002-02-26 00:10:06 +00:00
|
|
|
};
|
|
|
|
|
2002-03-26 03:14:20 +00:00
|
|
|
void read_animation (Animation &animation,
|
|
|
|
const string &object_name,
|
|
|
|
const SGPropertyNode * node);
|
2002-02-26 00:10:06 +00:00
|
|
|
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
|
|
|
|
|