root/OpenSceneGraph/trunk/src/osgPlugins/geo/osgGeoAnimation.h
@
13041
| Revision 13041, 2.7 kB (checked in by robert, 14 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | // animation features of the CarbonGraphics .geo format |
| 2 | // This file is required by external simulations to enable the user to |
| 3 | // control the GEO internal, user & external variables. |
| 4 | |
| 5 | // The user creates one or two functions (here uvarupdate, extvarupdate). |
| 6 | // These functions are demonstrated in geodemo.cpp. |
| 7 | |
| 8 | // Consider a model as being a class (or a subroutine). The class has a 'draw' method |
| 9 | // supplied by OSG, and the model can be animated (parts of the model |
| 10 | // rotate, move, change colour, become invisible etc.). |
| 11 | // |
| 12 | // The model developer attaches 'behaviours' to parts of the model (using the Geo graphical editor) |
| 13 | // and assigns these behaviours to depend on variables. There are 3 pools of variables: |
| 14 | // Internal, usually time dependent variables which cannot be modified by the developer. |
| 15 | // User variables - may be a function of other variables, defined in the editor. |
| 16 | // External variables - the user written callback function extvarupdate sets these values on each frame of simulation. |
| 17 | // User & external variables may be defined as a mathematical or logical function of |
| 18 | // all the variables (external variables, internal variables & user variables). |
| 19 | |
| 20 | // as a design rule, you should not normally attach a function to uvarupdate |
| 21 | // these variables should be considered as local variables within a function and not accessed by the program. |
| 22 | // The external variables should call a user written extvarupdate routine which can |
| 23 | // access Ethernet, a data file, shared memory or any other code to model the dynamics of your model. |
| 24 | |
| 25 | #ifndef _GEO_ANIM_H_ |
| 26 | #define _GEO_ANIM_H_ |
| 27 | |
| 28 | #include <osg/PositionAttitudeTransform> |
| 29 | |
| 30 | class geoHeader: public osg::PositionAttitudeTransform { |
| 31 | // structure for header of .geo file |
| 32 | // adds position attitude orientation for not Z up models, |
| 33 | // plus animation variables. |
| 34 | public: |
| 35 | geoHeader() { |
| 36 | uvarupdate=NULL; extvarupdate=NULL; |
| 37 | }; |
| 38 | geoHeader(const geoHeader &geo,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : |
| 39 | osg::PositionAttitudeTransform(geo,copyop) |
| 40 | { |
| 41 | // const geoHeaderGeo *ghg=static_cast<const geoHeaderGeo *> (&geo); |
| 42 | } |
| 43 | |
| 44 | ~geoHeader() {} |
| 45 | void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) ) |
| 46 | { // pass the address of a user written function in the Update phase. |
| 47 | uvarupdate=ufn; |
| 48 | } |
| 49 | void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) ) |
| 50 | { // pass the address of a user written function in the Update phase. |
| 51 | extvarupdate=ufn; |
| 52 | } |
| 53 | double (* uvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this! |
| 54 | double (* extvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this! |
| 55 | private: |
| 56 | }; |
| 57 | |
| 58 | #endif |
Note: See TracBrowser
for help on using the browser.
