diff --git a/src/osgPlugins/geo/osgGeoAnimation.h b/src/osgPlugins/geo/osgGeoAnimation.h index 7fdc78003..6c3d6bbed 100644 --- a/src/osgPlugins/geo/osgGeoAnimation.h +++ b/src/osgPlugins/geo/osgGeoAnimation.h @@ -7,157 +7,157 @@ #include class georecord; // You don't need to know how I read a geo record, -// but objects of this class are passed to some of the parsing routines. +// but objects of this class are passed to some of the parsing routines. // The values are defined in osgGeoStructs.h which is distributed with OSG. class geoValue { public: - geoValue() { - token=0; fid=0; val.d=0; name=""; - vmin=0; vmax=0; - constrained=false; - } - geoValue(const unsigned int tok, const unsigned int fident) { - token=tok; fid=fident; val.d=0; name=""; - vmin=0; vmax=0; - constrained=false; - } - ~geoValue() {} - inline unsigned int getToken() const { return token;} - inline unsigned int getFID() const { return fid;} - inline double *getValue() { return &(val.d);} - void setVal(double v) { val.d=v; - if (constrained) { - if (v>vmax) val.d=vmax; - if (vvmax) val.d=vmax; + if (v::iterator itr=vars.begin(); - itr!=vars.end(); - ++itr, iord++) - {// for each field - if ((*itr).getFID() == fid) { - return ((*itr).getValue()); - } - } - return NULL; - } + internalVars() { } + ~internalVars() { + } + void addInternalVars(const georecord &gr); + void update(osg::Timer &_timer,osg::FrameStamp &_frameStamp); + double *getVar(const unsigned fid) { + int iord=0; + for (std::vector::iterator itr=vars.begin(); + itr!=vars.end(); + ++itr, iord++) + {// for each field + if ((*itr).getFID() == fid) { + return ((*itr).getValue()); + } + } + return NULL; + } private: - std::vector vars; // these fields define internal vars + std::vector vars; // these fields define internal vars }; class userVars { public: - userVars() {} - ~userVars() {} - unsigned int number() { return vars.size();} - std::vector *getvars() { return &vars;} - double *getVar(const unsigned fid) { - for (std::vector::iterator itr=vars.begin(); itrgetFID() == fid) return (itr->getValue()); - } - return NULL; - } - void addUserVar(const georecord &gr); - void update() { - for (std::vector::iterator itr=vars.begin(); - itr!=vars.end(); - ++itr) - {// for each user var - // itr->setVal((*itr->getValue())+0.01); - } - } + userVars() {} + ~userVars() {} + unsigned int number() { return vars.size();} + std::vector *getvars() { return &vars;} + double *getVar(const unsigned fid) { + for (std::vector::iterator itr=vars.begin(); itrgetFID() == fid) return (itr->getValue()); + } + return NULL; + } + void addUserVar(const georecord &gr); + void update() { + for (std::vector::iterator itr=vars.begin(); + itr!=vars.end(); + ++itr) + {// for each user var + // itr->setVal((*itr->getValue())+0.01); + } + } private: - std::vector vars; + std::vector vars; }; class geoHeader: public osg::PositionAttitudeTransform { - // structure for header of .geo file - // adds position attitude orientation for not Z up models, - // plus animation variables. + // structure for header of .geo file + // adds position attitude orientation for not Z up models, + // plus animation variables. public: - geoHeader() { intVars=new internalVars; useVars=new userVars; - extVars=new userVars; - _frameStamp.setFrameNumber(0); // vars=NULL; - tstart=_frameStamp.getReferenceTime();_initialTick = _timer.tick(); - ucb=NULL; - }; - void setUserUpdate(void (*ufn)(const double time, userVars *locVars,userVars *extVars) ) - { // pass the address of a user written function in the App process. - ucb=ufn; - } - void addInternalVars(const georecord &gr) { intVars->addInternalVars(gr);} - internalVars *getInternalVars(void) const { return intVars;} - double *getVar(const unsigned fid) { - double *dv=NULL; - dv=intVars->getVar(fid); - if (!dv) { - dv=useVars->getVar(fid); - if (!dv) { - dv=extVars->getVar(fid); - } - } - return dv; - } - void addUserVar(const georecord &gr) - { // this georecord defines a single variable of type<> - useVars->addUserVar(gr); - } - void update() { - osg::Timer_t _frameTick = _timer.tick();; - _lastFrameTick=_frameTick; - - _frameStamp.setFrameNumber(_frameStamp.getFrameNumber()+1); - _frameStamp.setReferenceTime(_timer.delta_s(_initialTick,_frameTick)); - double time = _frameStamp.getReferenceTime(); - intVars->update(_timer, _frameStamp); - useVars->update(); - extVars->update(); - if (ucb) ucb(time,useVars, extVars); - } - userVars *getLocalVars() const { return useVars;} - userVars *getExternalVars() const { return extVars;} + geoHeader() { intVars=new internalVars; useVars=new userVars; + extVars=new userVars; + _frameStamp.setFrameNumber(0); // vars=NULL; + tstart=_frameStamp.getReferenceTime();_initialTick = _timer.tick(); + ucb=NULL; + }; + void setUserUpdate(void (*ufn)(const double time, userVars *locVars,userVars *extVars) ) + { // pass the address of a user written function in the App process. + ucb=ufn; + } + void addInternalVars(const georecord &gr) { intVars->addInternalVars(gr);} + internalVars *getInternalVars(void) const { return intVars;} + double *getVar(const unsigned fid) { + double *dv=NULL; + dv=intVars->getVar(fid); + if (!dv) { + dv=useVars->getVar(fid); + if (!dv) { + dv=extVars->getVar(fid); + } + } + return dv; + } + void addUserVar(const georecord &gr) + { // this georecord defines a single variable of type<> + useVars->addUserVar(gr); + } + void update() { + osg::Timer_t _frameTick = _timer.tick();; + _lastFrameTick=_frameTick; + + _frameStamp.setFrameNumber(_frameStamp.getFrameNumber()+1); + _frameStamp.setReferenceTime(_timer.delta_s(_initialTick,_frameTick)); + double time = _frameStamp.getReferenceTime(); + intVars->update(_timer, _frameStamp); + useVars->update(); + extVars->update(); + if (ucb) ucb(time,useVars, extVars); + } + userVars *getLocalVars() const { return useVars;} + userVars *getExternalVars() const { return extVars;} protected: - virtual ~geoHeader() {} + virtual ~geoHeader() {} - osg::Timer_t _lastFrameTick,_initialTick; - osg::Timer _timer; - double tstart; // start time - osg::FrameStamp _frameStamp ; // time utilities - internalVars *intVars; - userVars *useVars; - userVars *extVars; - void (* ucb)(const double t, userVars *l,userVars *e); // called when variables are updated, you write this! + osg::Timer_t _lastFrameTick,_initialTick; + osg::Timer _timer; + double tstart; // start time + osg::FrameStamp _frameStamp ; // time utilities + internalVars *intVars; + userVars *useVars; + userVars *extVars; + void (* ucb)(const double t, userVars *l,userVars *e); // called when variables are updated, you write this! }; #endif diff --git a/src/osgPlugins/geo/osgGeoStructs.h b/src/osgPlugins/geo/osgGeoStructs.h index b65703df0..0ef37526b 100644 --- a/src/osgPlugins/geo/osgGeoStructs.h +++ b/src/osgPlugins/geo/osgGeoStructs.h @@ -1,12 +1,12 @@ /*===========================================================================*\ -NAME: osgGeoStructs.h +NAME: osgGeoStructs.h -DESCRIPTION: OSG data format for reading a Geo file into OSG +DESCRIPTION: OSG data format for reading a Geo file into OSG -AUTHOR: Geoff Michel +AUTHOR: Geoff Michel -// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- \ *===========================================================================*/ @@ -19,546 +19,546 @@ AUTHOR: Geoff Michel class geoField { // holds one field of data as read from the disk of a GEO file public: - geoField() { - tokenId=TypeId=0; numItems=0;storeSize=0; - } + geoField() { + tokenId=TypeId=0; numItems=0;storeSize=0; + } - unsigned char *readStorage(std::ifstream &fin, const unsigned sz) { - unsigned char *st=new unsigned char[numItems*sz]; - storeSize=sz; - fin.read((char *)st, sz*numItems); - return st; - } - void storageRead(std::ifstream &fin) { - switch (TypeId) { - case DB_CHAR: - storage=readStorage(fin,SIZEOF_CHAR); - break; - case DB_SHORT: - storage=readStorage(fin,SIZEOF_SHORT); - break; - case DB_INT: - storage=readStorage(fin,SIZEOF_INT); - break; - case DB_FLOAT: - storage=readStorage(fin,SIZEOF_FLOAT); - break; - case DB_LONG: - storage=readStorage(fin,SIZEOF_LONG); - break; - case DB_ULONG: - storage=readStorage(fin,SIZEOF_ULONG); - break; - case DB_DOUBLE: - storage=readStorage(fin,SIZEOF_DOUBLE); - break; - case DB_VEC2F: - storage=readStorage(fin,SIZEOF_VEC2F); - break; - case DB_VEC3F: - storage=readStorage(fin,SIZEOF_VEC3F); - break; - case DB_VEC4F: - storage=readStorage(fin,SIZEOF_VEC4F); - break; - case DB_VEC16F: - storage=readStorage(fin,SIZEOF_VEC16F); - break; - case DB_VEC2I: - storage=readStorage(fin,SIZEOF_VEC2I); - break; - case DB_VEC3I: - storage=readStorage(fin,SIZEOF_VEC3I); - break; - case DB_VEC4I: - storage=readStorage(fin,SIZEOF_VEC4I); - break; - case DB_VEC2D: - storage=readStorage(fin,SIZEOF_VEC2D); - break; - case DB_VEC3D: - storage=readStorage(fin,SIZEOF_VEC3D); - break; - case DB_VEC4D: - storage=readStorage(fin,SIZEOF_VEC4D); - break; - case DB_VEC16D: - storage=readStorage(fin,SIZEOF_VEC16D); - break; - case DB_VRTX_STRUCT: - storage=readStorage(fin,SIZEOF_VRTX_STRUCT); - break; - case DB_UINT: - storage=readStorage(fin,SIZEOF_UINT); - break; - case DB_USHORT: - storage=readStorage(fin,SIZEOF_USHORT); - break; - case DB_UCHAR: - storage=readStorage(fin,SIZEOF_UCHAR); - break; - case DB_EXT_STRUCT: - storage=readStorage(fin,SIZEOF_EXT_STRUCT); - break; - case DB_SHORT_WITH_PADDING: - storage=readStorage(fin,SIZEOF_ULONG); - break; - case DB_CHAR_WITH_PADDING: - storage=readStorage(fin,SIZEOF_CHAR_WITH_PADDING); - break; - case DB_USHORT_WITH_PADDING: - storage=readStorage(fin,SIZEOF_USHORT_WITH_PADDING); - break; - case DB_UCHAR_WITH_PADDING: - storage=readStorage(fin,SIZEOF_UCHAR_WITH_PADDING); - break; - case DB_BOOL_WITH_PADDING: - storage=readStorage(fin,SIZEOF_BOOL_WITH_PADDING); - break; - case DB_EXTENDED_FIELD_STRUCT: - storage=readStorage(fin,SIZEOF_EXTENDED_FIELD_STRUCT); - break; - case DB_VEC4UC: - storage=readStorage(fin,SIZEOF_VEC4UC); - break; - case DB_DISCRETE_MAPPING_STRUCT: - storage=readStorage(fin,SIZEOF_DISCRETE_MAPPING_STRUCT); - break; - case DB_BITFLAGS: - storage=readStorage(fin,SIZEOF_BITFLAGS); - break; - } - } - void readfile(std::ifstream &fin) { - osg::uchar tokid, type; - osg::ushort nits; - if (!fin.eof()) { - fin.read((char *)&tokid,1);fin.read((char *)&type,1); - fin.read((char *)&nits,sizeof(unsigned short)); - if (TypeId == GEO_DB_EXTENDED_FIELD) { - fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId)); - fin.read((char *)&numItems,sizeof(unsigned int)); - } else { - tokenId=tokid; TypeId=type; - numItems=nits; - } - storageRead(fin); // allocate & fill the storage - } - } - inline osg::uchar getToken() const { return tokenId;} - inline osg::uchar getType() const { return TypeId;} - inline unsigned short getNum() const { return numItems;} - inline unsigned char *getstore (unsigned int i) const { - return storage+i*storeSize; - } - void uncompress() { // folow the recipe to uncompress - if (TypeId==DB_VEC3F) { // already uncompressed - } else { - float *norms=new float[numItems*SIZEOF_VEC3F]; // uncompressed size - for (uint i=0; i geoFieldList; - georecord() {id=0; parent=NULL; instance=NULL;} - ~georecord() {;} - inline const uint getType(void) const {return id;} - inline void setparent(georecord *p) { parent=p;} - inline class georecord *getparent() const { return parent;} - inline std::vector getchildren(void) const { return children;} - void addchild(class georecord *gr) { children.push_back(gr);} - georecord *getLastChild(void) const { return children.back();} - void addBehaviour(class georecord *gr) { behaviour.push_back(gr);} - std::vector< georecord *>getBehaviour() const { return behaviour;} - const geoFieldList getFields() const { return fields;} - inline bool isVar(void) const { - switch (id) { - case DB_DSK_FLOAT_VAR: - case DB_DSK_INT_VAR: - case DB_DSK_LONG_VAR: - case DB_DSK_DOUBLE_VAR: - case DB_DSK_BOOL_VAR: - case DB_DSK_FLOAT2_VAR: - case DB_DSK_FLOAT3_VAR: - case DB_DSK_FLOAT4_VAR: - - case DB_DSK_INTERNAL_VARS: - case DB_DSK_LOCAL_VARS: - case DB_DSK_EXTERNAL_VARS: - return true; - default: - return false; - } - } - inline bool isAction(void) const { - switch (id) { - case DB_DSK_CLAMP_ACTION: - case DB_DSK_RANGE_ACTION : - case DB_DSK_ROTATE_ACTION : - case DB_DSK_TRANSLATE_ACTION : - case DB_DSK_SCALE_ACTION : - case DB_DSK_ARITHMETIC_ACTION : - case DB_DSK_LOGIC_ACTION : - case DB_DSK_CONDITIONAL_ACTION : - case DB_DSK_LOOPING_ACTION : - case DB_DSK_COMPARE_ACTION : - case DB_DSK_VISIBILITY_ACTION : - case DB_DSK_STRING_CONTENT_ACTION : - case DB_DSK_COLOR_RAMP_ACTION: - case DB_DSK_LINEAR_ACTION : - case DB_DSK_TASK_ACTION : - case DB_DSK_PERIODIC_ACTION : - case DB_DSK_PERIODIC2_ACTION : - case DB_DSK_TRIG_ACTION : - case DB_DSK_INVERSE_ACTION : - case DB_DSK_TRUNCATE_ACTION : - case DB_DSK_ABS_ACTION : - case DB_DSK_IF_THEN_ELSE_ACTION : - case DB_DSK_DCS_ACTION : - return true; - default: - return false; - } - return false; - } - void readfile(std::ifstream &fin) { - if (!fin.eof()) { - fin.read((char *)&id,sizeof(int)); - if (id==DB_DSK_PUSH) { - // there are no fields for a push - } else if (id==DB_DSK_POP) { - // there are no fields for a pop - } else { // get the fields - geoField gf; - do { - gf.readfile(fin); - if (id == DB_DSK_NORMAL_POOL && gf.getToken()==GEO_DB_NORMAL_POOL_VALUES) { - // uncompress the normals - gf.uncompress(); - } - fields.push_back(gf); - } while (gf.getToken()!=GEO_DB_LAST_FIELD); - } - } - } - friend inline std::ostream& operator << (osgDB::Output& output, const georecord& gr) + georecord() {id=0; parent=NULL; instance=NULL;} + ~georecord() {;} + inline const uint getType(void) const {return id;} + inline void setparent(georecord *p) { parent=p;} + inline class georecord *getparent() const { return parent;} + inline std::vector getchildren(void) const { return children;} + void addchild(class georecord *gr) { children.push_back(gr);} + georecord *getLastChild(void) const { return children.back();} + void addBehaviour(class georecord *gr) { behaviour.push_back(gr);} + std::vector< georecord *>getBehaviour() const { return behaviour;} + const geoFieldList getFields() const { return fields;} + inline bool isVar(void) const { + switch (id) { + case DB_DSK_FLOAT_VAR: + case DB_DSK_INT_VAR: + case DB_DSK_LONG_VAR: + case DB_DSK_DOUBLE_VAR: + case DB_DSK_BOOL_VAR: + case DB_DSK_FLOAT2_VAR: + case DB_DSK_FLOAT3_VAR: + case DB_DSK_FLOAT4_VAR: + + case DB_DSK_INTERNAL_VARS: + case DB_DSK_LOCAL_VARS: + case DB_DSK_EXTERNAL_VARS: + return true; + default: + return false; + } + } + inline bool isAction(void) const { + switch (id) { + case DB_DSK_CLAMP_ACTION: + case DB_DSK_RANGE_ACTION : + case DB_DSK_ROTATE_ACTION : + case DB_DSK_TRANSLATE_ACTION : + case DB_DSK_SCALE_ACTION : + case DB_DSK_ARITHMETIC_ACTION : + case DB_DSK_LOGIC_ACTION : + case DB_DSK_CONDITIONAL_ACTION : + case DB_DSK_LOOPING_ACTION : + case DB_DSK_COMPARE_ACTION : + case DB_DSK_VISIBILITY_ACTION : + case DB_DSK_STRING_CONTENT_ACTION : + case DB_DSK_COLOR_RAMP_ACTION: + case DB_DSK_LINEAR_ACTION : + case DB_DSK_TASK_ACTION : + case DB_DSK_PERIODIC_ACTION : + case DB_DSK_PERIODIC2_ACTION : + case DB_DSK_TRIG_ACTION : + case DB_DSK_INVERSE_ACTION : + case DB_DSK_TRUNCATE_ACTION : + case DB_DSK_ABS_ACTION : + case DB_DSK_IF_THEN_ELSE_ACTION : + case DB_DSK_DCS_ACTION : + return true; + default: + return false; + } + return false; + } + void readfile(std::ifstream &fin) { + if (!fin.eof()) { + fin.read((char *)&id,sizeof(int)); + if (id==DB_DSK_PUSH) { + // there are no fields for a push + } else if (id==DB_DSK_POP) { + // there are no fields for a pop + } else { // get the fields + geoField gf; + do { + gf.readfile(fin); + if (id == DB_DSK_NORMAL_POOL && gf.getToken()==GEO_DB_NORMAL_POOL_VALUES) { + // uncompress the normals + gf.uncompress(); + } + fields.push_back(gf); + } while (gf.getToken()!=GEO_DB_LAST_FIELD); + } + } + } + friend inline std::ostream& operator << (osgDB::Output& output, const georecord& gr) { - if (gr.id == DB_DSK_PUSH) output << "Push" << std::endl; - else if (gr.id == DB_DSK_POP) output << "Pop" << std::endl; - else if (gr.id == DB_DSK_HEADER) output << "Header" << std::endl; - else if (gr.id == DB_DSK_GROUP) output << "Group" << std::endl; - else if (gr.id == DB_DSK_BILLBOARD) output << "Billboard" << std::endl; - else if (gr.id == DB_DSK_SEQUENCE) output << "Sequence" << std::endl; - else if (gr.id == DB_DSK_LOD) output << "LOD" << std::endl; - else if (gr.id == DB_DSK_GEODE) output << "Geode" << std::endl; - else if (gr.id == DB_DSK_POLYGON) output << "Polygon" << std::endl; - else if (gr.id == DB_DSK_MESH) output << "Mesh" << std::endl; - else if (gr.id == DB_DSK_CUBE) output << "Cube" << std::endl; - else if (gr.id == DB_DSK_SPHERE) output << "Sphere" << std::endl; - else if (gr.id == DB_DSK_CONE) output << "Cone" << std::endl; - else if (gr.id == DB_DSK_CYLINDER) output << "Cylinder" << std::endl; - else if (gr.id == DB_DSK_VERTEX) output << "Vertex" << std::endl; - else if (gr.id == DB_DSK_TEXTURE) output << "Texture" << std::endl; - else if (gr.id == DB_DSK_MATERIAL) output << "Material" << std::endl; - else if (gr.id == DB_DSK_VIEW) output << "View" << std::endl; - else if (gr.id == DB_DSK_EXTENSION_LIST) output << "Extensions" << std::endl; - else if (gr.id == DB_DSK_COORD_POOL) output << "Coords" << std::endl; - else if (gr.id == DB_DSK_NORMAL_POOL) output << "Normals" << std::endl; - else if (gr.id == DB_DSK_SWITCH) output << "Switch" << std::endl; - else if (gr.id == DB_DSK_TEXT) output << "Text" << std::endl; - else if (gr.id == DB_DSK_BASE_GROUP) output << "Base group" << std::endl; - else if (gr.id == DB_DSK_BASE_SURFACE) output << "Base Surface" << std::endl; - else if (gr.id == DB_DSK_INSTANCE) output << "Instance" << std::endl; - else if (gr.id == DB_DSK_LIGHTPT) output << "Light Point" << std::endl; - else if (gr.id == DB_DSK_EXTERNAL) output << "External" << std::endl; - else if (gr.id == DB_DSK_PAGE) output << "Page" << std::endl; - else if (gr.id == DB_DSK_COLOR_PALETTE) output << "Colour palette" << std::endl; - else if (gr.id == DB_DSK_INTERNAL_VARS) output << "Internal vars" << std::endl; - else if (gr.id == DB_DSK_LOCAL_VARS) output << "Local vars" << std::endl; - else if (gr.id == DB_DSK_EXTERNAL_VARS) output << "External vars" << std::endl; - // behaviours - else if (gr.id == DB_DSK_BEHAVIOR) output << "Behaviour" << std::endl; - else if (gr.id == DB_DSK_CLAMP_ACTION) output << "clamp action" << std::endl; - else if (gr.id == DB_DSK_RANGE_ACTION) output << "range action" << std::endl; - else if (gr.id == DB_DSK_ROTATE_ACTION) output << "rotate action" << std::endl; - else if (gr.id == DB_DSK_TRANSLATE_ACTION) output << "translate action" << std::endl; - else if (gr.id == DB_DSK_SCALE_ACTION) output << "scale action" << std::endl; - else if (gr.id == DB_DSK_ARITHMETIC_ACTION) output << "arithmetic action" << std::endl; - else if (gr.id == DB_DSK_LOGIC_ACTION) output << "logic action" << std::endl; - else if (gr.id == DB_DSK_CONDITIONAL_ACTION) output << "conditional action" << std::endl; - else if (gr.id == DB_DSK_LOOPING_ACTION) output << "looping action" << std::endl; - else if (gr.id == DB_DSK_COMPARE_ACTION) output << "compare action" << std::endl; - else if (gr.id == DB_DSK_VISIBILITY_ACTION) output << "visibility action" << std::endl; - else if (gr.id == DB_DSK_STRING_CONTENT_ACTION) output << "string content action" << std::endl; - // var types - else if (gr.id == DB_DSK_FLOAT_VAR) output << "Float var" << std::endl; - else if (gr.id == DB_DSK_INT_VAR) output << "Int var" << std::endl; - else if (gr.id == DB_DSK_LONG_VAR) output << "Long var" << std::endl; - else if (gr.id == DB_DSK_DOUBLE_VAR) output << "Double var" << std::endl; - else if (gr.id == DB_DSK_BOOL_VAR) output << "Bool var" << std::endl; - else output << " inp record " << gr.id << std::endl; + if (gr.id == DB_DSK_PUSH) output << "Push" << std::endl; + else if (gr.id == DB_DSK_POP) output << "Pop" << std::endl; + else if (gr.id == DB_DSK_HEADER) output << "Header" << std::endl; + else if (gr.id == DB_DSK_GROUP) output << "Group" << std::endl; + else if (gr.id == DB_DSK_BILLBOARD) output << "Billboard" << std::endl; + else if (gr.id == DB_DSK_SEQUENCE) output << "Sequence" << std::endl; + else if (gr.id == DB_DSK_LOD) output << "LOD" << std::endl; + else if (gr.id == DB_DSK_GEODE) output << "Geode" << std::endl; + else if (gr.id == DB_DSK_POLYGON) output << "Polygon" << std::endl; + else if (gr.id == DB_DSK_MESH) output << "Mesh" << std::endl; + else if (gr.id == DB_DSK_CUBE) output << "Cube" << std::endl; + else if (gr.id == DB_DSK_SPHERE) output << "Sphere" << std::endl; + else if (gr.id == DB_DSK_CONE) output << "Cone" << std::endl; + else if (gr.id == DB_DSK_CYLINDER) output << "Cylinder" << std::endl; + else if (gr.id == DB_DSK_VERTEX) output << "Vertex" << std::endl; + else if (gr.id == DB_DSK_TEXTURE) output << "Texture" << std::endl; + else if (gr.id == DB_DSK_MATERIAL) output << "Material" << std::endl; + else if (gr.id == DB_DSK_VIEW) output << "View" << std::endl; + else if (gr.id == DB_DSK_EXTENSION_LIST) output << "Extensions" << std::endl; + else if (gr.id == DB_DSK_COORD_POOL) output << "Coords" << std::endl; + else if (gr.id == DB_DSK_NORMAL_POOL) output << "Normals" << std::endl; + else if (gr.id == DB_DSK_SWITCH) output << "Switch" << std::endl; + else if (gr.id == DB_DSK_TEXT) output << "Text" << std::endl; + else if (gr.id == DB_DSK_BASE_GROUP) output << "Base group" << std::endl; + else if (gr.id == DB_DSK_BASE_SURFACE) output << "Base Surface" << std::endl; + else if (gr.id == DB_DSK_INSTANCE) output << "Instance" << std::endl; + else if (gr.id == DB_DSK_LIGHTPT) output << "Light Point" << std::endl; + else if (gr.id == DB_DSK_EXTERNAL) output << "External" << std::endl; + else if (gr.id == DB_DSK_PAGE) output << "Page" << std::endl; + else if (gr.id == DB_DSK_COLOR_PALETTE) output << "Colour palette" << std::endl; + else if (gr.id == DB_DSK_INTERNAL_VARS) output << "Internal vars" << std::endl; + else if (gr.id == DB_DSK_LOCAL_VARS) output << "Local vars" << std::endl; + else if (gr.id == DB_DSK_EXTERNAL_VARS) output << "External vars" << std::endl; + // behaviours + else if (gr.id == DB_DSK_BEHAVIOR) output << "Behaviour" << std::endl; + else if (gr.id == DB_DSK_CLAMP_ACTION) output << "clamp action" << std::endl; + else if (gr.id == DB_DSK_RANGE_ACTION) output << "range action" << std::endl; + else if (gr.id == DB_DSK_ROTATE_ACTION) output << "rotate action" << std::endl; + else if (gr.id == DB_DSK_TRANSLATE_ACTION) output << "translate action" << std::endl; + else if (gr.id == DB_DSK_SCALE_ACTION) output << "scale action" << std::endl; + else if (gr.id == DB_DSK_ARITHMETIC_ACTION) output << "arithmetic action" << std::endl; + else if (gr.id == DB_DSK_LOGIC_ACTION) output << "logic action" << std::endl; + else if (gr.id == DB_DSK_CONDITIONAL_ACTION) output << "conditional action" << std::endl; + else if (gr.id == DB_DSK_LOOPING_ACTION) output << "looping action" << std::endl; + else if (gr.id == DB_DSK_COMPARE_ACTION) output << "compare action" << std::endl; + else if (gr.id == DB_DSK_VISIBILITY_ACTION) output << "visibility action" << std::endl; + else if (gr.id == DB_DSK_STRING_CONTENT_ACTION) output << "string content action" << std::endl; + // var types + else if (gr.id == DB_DSK_FLOAT_VAR) output << "Float var" << std::endl; + else if (gr.id == DB_DSK_INT_VAR) output << "Int var" << std::endl; + else if (gr.id == DB_DSK_LONG_VAR) output << "Long var" << std::endl; + else if (gr.id == DB_DSK_DOUBLE_VAR) output << "Double var" << std::endl; + else if (gr.id == DB_DSK_BOOL_VAR) output << "Bool var" << std::endl; + else output << " inp record " << gr.id << std::endl; - for (geoFieldList::const_iterator itr=gr.fields.begin(); - itr!=gr.fields.end(); - ++itr) - { - output << *itr; - } - output << std::endl; - std::vector< georecord *>bhv=gr.getBehaviour(); - for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); - rcitr!=bhv.end(); - ++rcitr) - { - output.indent() << "Behave "; - output << (**rcitr); - } - return output; // to enable cascading, monkey copy from osg\plane or \quat, Ubyte4, vec2,3,4,... - } - const geoField *getField(const int fieldid) const { // return field if it exists. - for (geoFieldList::const_iterator itr=fields.begin(); - itr!=fields.end(); - ++itr) - { - if (itr->getToken()==fieldid) return itr; - } - return NULL; - } - void setMaterial(osg::Material *mt) const { - if (id == DB_DSK_MATERIAL) { - for (geoFieldList::const_iterator itr=fields.begin(); - itr!=fields.end(); - ++itr) - { - float *fval; - if (itr->getToken()==GEO_DB_MAT_AMBIENT) { - fval= (float *)(*itr).getstore(0); - mt->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); - } - if (itr->getToken()==GEO_DB_MAT_DIFFUSE) { - fval= (float *)(*itr).getstore(0); - mt->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); - } - if (itr->getToken()==GEO_DB_MAT_SPECULAR) { - fval= (float *)(*itr).getstore(0); - mt->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); - } - if (itr->getToken()==GEO_DB_MAT_EMISSIVE) { - fval= (float *)(*itr).getstore(0); - mt->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); - } - if (itr->getToken()==GEO_DB_MAT_SHININESS) { - fval= (float *)(*itr).getstore(0); - mt->setShininess(osg::Material::FRONT_AND_BACK, fval[0]); - } - } - } - } - unsigned int getNumFields(void) const { return fields.size();} + for (geoFieldList::const_iterator itr=gr.fields.begin(); + itr!=gr.fields.end(); + ++itr) + { + output << *itr; + } + output << std::endl; + std::vector< georecord *>bhv=gr.getBehaviour(); + for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); + rcitr!=bhv.end(); + ++rcitr) + { + output.indent() << "Behave "; + output << (**rcitr); + } + return output; // to enable cascading, monkey copy from osg\plane or \quat, Ubyte4, vec2,3,4,... + } + const geoField *getField(const int fieldid) const { // return field if it exists. + for (geoFieldList::const_iterator itr=fields.begin(); + itr!=fields.end(); + ++itr) + { + if (itr->getToken()==fieldid) return &(*itr); + } + return NULL; + } + void setMaterial(osg::Material *mt) const { + if (id == DB_DSK_MATERIAL) { + for (geoFieldList::const_iterator itr=fields.begin(); + itr!=fields.end(); + ++itr) + { + float *fval; + if (itr->getToken()==GEO_DB_MAT_AMBIENT) { + fval= (float *)(*itr).getstore(0); + mt->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); + } + if (itr->getToken()==GEO_DB_MAT_DIFFUSE) { + fval= (float *)(*itr).getstore(0); + mt->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); + } + if (itr->getToken()==GEO_DB_MAT_SPECULAR) { + fval= (float *)(*itr).getstore(0); + mt->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); + } + if (itr->getToken()==GEO_DB_MAT_EMISSIVE) { + fval= (float *)(*itr).getstore(0); + mt->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(fval[0],fval[1],fval[2],fval[3])); + } + if (itr->getToken()==GEO_DB_MAT_SHININESS) { + fval= (float *)(*itr).getstore(0); + mt->setShininess(osg::Material::FRONT_AND_BACK, fval[0]); + } + } + } + } + unsigned int getNumFields(void) const { return fields.size();} private: - uint id; - std::vector fields; // each geo record has a variable number of fields - class georecord *parent; // parent of pushed/popped records - class georecord *instance; // this record is an instance of the pointed to record - std::vector< georecord *> behaviour; // behaviour & action records of this record - std::vector< georecord *> children; // children of this record + uint id; + std::vector fields; // each geo record has a variable number of fields + class georecord *parent; // parent of pushed/popped records + class georecord *instance; // this record is an instance of the pointed to record + std::vector< georecord *> behaviour; // behaviour & action records of this record + std::vector< georecord *> children; // children of this record }; diff --git a/src/osgPlugins/logos/Makefile b/src/osgPlugins/logos/Makefile index 5ed797290..ccea33bfa 100644 --- a/src/osgPlugins/logos/Makefile +++ b/src/osgPlugins/logos/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ ReaderWriterLOGO.cpp\ -##LIBS += $(OSG_LIBS) $(GL_LIBS) $(OTHER_LIBS) +LIBS += $(OSG_LIBS) $(GL_LIBS) $(OTHER_LIBS) TARGET_BASENAME = logo include $(TOPDIR)/Make/cygwin_plugin_def