2002-11-07 21:47:39 +08:00
|
|
|
// animation features of the CarbonGraphics .geo format
|
2002-12-11 04:00:56 +08:00
|
|
|
// This file is required by external simulations to enable the user to
|
|
|
|
// control the GEO internal, user & external variables.
|
|
|
|
|
|
|
|
// The user creates one or two functions (here uvarupdate, extvarupdate).
|
|
|
|
// These functions are demonstrated in geodemo.cpp.
|
|
|
|
|
|
|
|
// Consider a model as being a class (or a subroutine). The class has a 'draw' method
|
|
|
|
// supplied by OSG, and the model can be animated (parts of the model
|
|
|
|
// rotate, move, change colour, become invisible etc.).
|
|
|
|
//
|
|
|
|
// The model developer attaches 'behaviours' to parts of the model (using the Geo graphical editor)
|
|
|
|
// and assigns these behaviours to depend on variables. There are 3 pools of variables:
|
|
|
|
// Internal, usually time dependent variables which cannot be modified by the developer.
|
|
|
|
// User variables - may be a function of other variables, defined in the editor.
|
|
|
|
// External variables - the user written callback function extvarupdate sets these values on each frame of simulation.
|
|
|
|
// User & external variables may be defined as a mathematical or logical function of
|
2003-11-28 22:37:46 +08:00
|
|
|
// all the variables (external variables, internal variables & user variables).
|
2002-12-11 04:00:56 +08:00
|
|
|
|
|
|
|
// as a design rule, you should not normally attach a function to uvarupdate
|
|
|
|
// these variables should be considered as local variables within a function and not accessed by the program.
|
|
|
|
// The external variables should call a user written extvarupdate routine which can
|
|
|
|
// access Ethernet, a data file, shared memory or any other code to model the dynamics of your model.
|
|
|
|
|
2002-11-07 21:47:39 +08:00
|
|
|
#ifndef _GEO_ANIM_H_
|
|
|
|
#define _GEO_ANIM_H_
|
|
|
|
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
|
|
|
class geoHeader: public osg::PositionAttitudeTransform {
|
2002-12-11 04:00:56 +08:00
|
|
|
// structure for header of .geo file
|
|
|
|
// adds position attitude orientation for not Z up models,
|
|
|
|
// plus animation variables.
|
2002-11-07 21:47:39 +08:00
|
|
|
public:
|
2002-12-11 04:00:56 +08:00
|
|
|
geoHeader() {
|
|
|
|
uvarupdate=NULL; extvarupdate=NULL;
|
|
|
|
};
|
2003-11-28 22:37:46 +08:00
|
|
|
geoHeader(const geoHeader &geo,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) :
|
2004-01-29 23:47:51 +08:00
|
|
|
osg::PositionAttitudeTransform(geo,copyop)
|
2003-11-28 22:37:46 +08:00
|
|
|
{
|
|
|
|
// const geoHeaderGeo *ghg=static_cast<const geoHeaderGeo *> (&geo);
|
|
|
|
}
|
|
|
|
|
2002-12-11 04:00:56 +08:00
|
|
|
~geoHeader() {}
|
|
|
|
void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
2002-12-19 23:55:40 +08:00
|
|
|
{ // pass the address of a user written function in the Update phase.
|
2002-12-11 04:00:56 +08:00
|
|
|
uvarupdate=ufn;
|
|
|
|
}
|
|
|
|
void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
2002-12-19 23:55:40 +08:00
|
|
|
{ // pass the address of a user written function in the Update phase.
|
2002-12-11 04:00:56 +08:00
|
|
|
extvarupdate=ufn;
|
|
|
|
}
|
|
|
|
double (* uvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
|
|
|
double (* extvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
|
|
|
private:
|
2002-11-07 21:47:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|