diff --git a/VisualStudio/osgPlugins/geo/geo.dsp b/VisualStudio/osgPlugins/geo/geo.dsp index f64630334..23288f73f 100644 --- a/VisualStudio/osgPlugins/geo/geo.dsp +++ b/VisualStudio/osgPlugins/geo/geo.dsp @@ -26,6 +26,7 @@ CFG=osgPlugin geo - Win32 Release # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe +F90=df.exe MTL=midl.exe RSC=rc.exe @@ -94,6 +95,10 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=..\..\..\src\osgPlugins\geo\geoActions.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\geo\ReaderWriterGEO.cpp # End Source File # End Group @@ -114,16 +119,28 @@ SOURCE=..\..\..\src\osgPlugins\geo\geoUnits.h # End Source File # Begin Source File -SOURCE=..\..\..\src\osgPlugins\geo\osgGeoStructs.h +SOURCE=..\..\..\src\osgPlugins\geo\osgGeoAction.h # End Source File # Begin Source File SOURCE=..\..\..\src\osgPlugins\geo\osgGeoAnimation.h # End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\geo\osgGeoNodes.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\geo\osgGeoStructs.h +# End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group +# Begin Source File + +SOURCE=.\osgGeoNodes.asp +# End Source File # End Target # End Project diff --git a/VisualStudio/osgSim/osgSim.dsp b/VisualStudio/osgSim/osgSim.dsp index f122f30ad..17c49e593 100644 --- a/VisualStudio/osgSim/osgSim.dsp +++ b/VisualStudio/osgSim/osgSim.dsp @@ -129,7 +129,7 @@ SOURCE=..\..\include\osgSim\LightPoint # End Source File # Begin Source File -SOURCE=..\..\include\osgSim\LightPointDrawable +SOURCE=..\..\src\osgSim\LightPointDrawable.h # End Source File # Begin Source File diff --git a/src/Demos/osggeodemo/osggeodemo.cpp b/src/Demos/osggeodemo/osggeodemo.cpp index a44f1f00e..dbcc665da 100644 --- a/src/Demos/osggeodemo/osggeodemo.cpp +++ b/src/Demos/osggeodemo/osggeodemo.cpp @@ -16,6 +16,7 @@ #include #include +#include #include @@ -65,8 +66,9 @@ class geodemoEventHandler : public osgGA::GUIEventHandler { public: - geodemoEventHandler( ) {speed=0; heading=0; mouse_x=mouse_y=0;} - + geodemoEventHandler( ) { mouse_x=mouse_y=0;} + virtual ~geodemoEventHandler( ) {} + virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) { mouse_x=ea.getX(); @@ -79,49 +81,47 @@ public: { v.visit(*this); } - void moveit(userVars *l) - { - std::vector *lvals=l->getvars(); - for (std::vector::iterator itr=lvals->begin(); - itr!=lvals->end(); - ++itr) {// for each user var - if (itr->getName() == "xpos") { - itr->setVal((*itr->getValue())+speed*sin(heading)); - // std::cout << " nx " << (*itr->getValue()) ; - } else if (itr->getName() == "ypos") { - itr->setVal((*itr->getValue())+speed*cos(heading)); - // std::cout << " ny " << (*itr->getValue()) ; - } else if (itr->getName() == "sped") { - itr->setVal(0.00025*(mouse_y-300)); - speed=(*itr->getValue()); - // std::cout << " nspd " << speed << std::endl; - } else if (itr->getName() == "heading") { - itr->setVal((*itr->getValue())-0.0001*(mouse_x-400)); - heading=(*itr->getValue()); - // std::cout << " nhdg " << heading << std::endl; - } else if (itr->getName() == "conerot") { - itr->setVal((mouse_x-400)); - } else if (itr->getName() == "planrot") { - itr->setVal((mouse_y-300)/200.0); - } - } - } + inline int getMouseX(void) {return mouse_x;}; + inline int getMouseY(void) {return mouse_y;}; private: int mouse_x, mouse_y; - float speed, heading; }; static geodemoEventHandler *ghand=NULL; +inline double DEG2RAD(const double val) { return val*0.0174532925199432957692369076848861;} +inline double RAD2DEG(const double val) { return val*57.2957795130823208767981548141052;} -void moveit(const double t, userVars *l,userVars *e) -{ // all the local and external variables declared in the geo modeller are here available. - ghand->moveit(l); +double dodynamics(const double time, const double val, const std::string name) +{ // Each local variable named 'name' declared in the geo modeller is passed into here. + // its current value is val; returns new value. Time - elapsed time + static double heading,speed; // these are only required for my 'dynamics' + if (name == "xpos") { + return (val+speed*sin(heading)); + // std::cout << " nx " << (*itr->getValue()) ; + } else if (name == "ypos") { + return (val+speed*cos(heading)); + // std::cout << " ny " << (*itr->getValue()) ; + } else if (name == "sped") { + speed=(0.00025*(ghand->getMouseY()-300)); // (*itr->getValue()); + return (speed); + } else if (name == "heading") { + heading-= 0.01*DEG2RAD(ghand->getMouseX()-400); // =DEG2RAD(*itr->getValue()); + return (RAD2DEG(heading)); + } else if (name == "conerot") { + return ((ghand->getMouseX()-400)); + } else if (name == "planrot") { + return ((ghand->getMouseY()-300)/200.0); + } else if (name == "secint" || name == "minutehand"|| name == "hourhand") { + // std::cout << " updating " << name << " " << val << std::endl; + } + return val; } int main( int argc, char **argv ) { std::string pathfile; + float camera_fov=-1; // initialize the GLUT glutInit( &argc, argv ); @@ -142,6 +142,9 @@ int main( int argc, char **argv ) } else pathfile = std::string(argv[++i]); + } else if( std::string(argv[i]) == "-fov" ) { + camera_fov=atof(argv[i+1]); + ++i; // skip the value } else commandLine.push_back(argv[i]); @@ -150,6 +153,28 @@ int main( int argc, char **argv ) // initialize the viewer. osgGLUT::Viewer viewer; viewer.setWindowTitle(argv[0]); + + // geoff's path code.. needs replacing as it isn't cross platform. +// { +// char *gdpath=getenv("PATH"); +// int lenpath=(gdpath ? strlen(gdpath):1) + strlen(argv[0]); +// char *nupath=new char[lenpath+20]; +// +// strcpy(nupath,"PATH="); +// strcat(nupath,argv[0]); +// // strip the executable name (xxx.exe) +// char *epath=strrchr(nupath, '\\'); +// if (epath) *epath='\0'; // remove executable +// else { +// epath=strrchr(nupath, '/'); +// if (epath) *epath='\0'; // remove executable, UNIX style path +// } +// strcat(nupath,";"); +// strcat(nupath,gdpath); +// _putenv(nupath); +// delete [] nupath; +// } +// std::cout << "Path " << getenv("PATH") << std::endl; // configure the viewer from the commandline arguments, and eat any // parameters that have been matched. @@ -188,10 +213,9 @@ int main( int argc, char **argv ) } geoHeader *gh = dynamic_cast(rootnode); - if (gh) - { // it is a geo file, so set function to update its animation variables. + if (gh) { // it is a geo file, so set function to update its animation variables. ghand=new geodemoEventHandler(); - gh->setUserUpdate(moveit); + gh->setUserUpdate(dodynamics); viewer.prependEventHandler(ghand); } else { // maybe a group with geo models below. osg::Group *gpall=dynamic_cast(rootnode); @@ -203,14 +227,18 @@ int main( int argc, char **argv ) if (gh) { ghand=new geodemoEventHandler(); - gh->setUserUpdate(moveit); + gh->setUserUpdate(dodynamics); viewer.prependEventHandler(ghand); } } } } - - // open the viewer window. + osgUtil::SceneView *sc=viewer.getViewportSceneView(0); + if (sc && camera_fov>0) { + osg::Camera *cm=sc->getCamera(); + if (cm) cm->setFOV(camera_fov,camera_fov*(600.0f/800.0f),1.0f,1000.0f); + } + // open the viewer window. viewer.open(); // fire up the event loop. diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp index 13596f048..b2f64b76d 100644 --- a/src/osgParticle/ParticleProcessor.cpp +++ b/src/osgParticle/ParticleProcessor.cpp @@ -39,7 +39,9 @@ osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor ©, void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv) { // continue only if enabled - if (enabled_) { + if (enabled_ ) + { + // typecast the NodeVisitor to CullVisitor osgUtil::CullVisitor *cv = dynamic_cast(&nv); @@ -48,35 +50,45 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv) if (cv) { // continue only if the particle system is valid - if (ps_.valid()) { + if (ps_.valid()) + { - // retrieve the current time - double t = nv.getFrameStamp()->getReferenceTime(); + if (nv.getFrameStamp()) + { - // skip if we haven't initialized t0_ yet - if (t0_ != -1) { + // retrieve the current time + double t = nv.getFrameStamp()->getReferenceTime(); - // check whether the particle system is frozen/culled - if (!ps_->isFrozen() && (ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) { + // skip if we haven't initialized t0_ yet + if (t0_ != -1) { - // initialize matrix flags - need_ltw_matrix_ = true; - need_wtl_matrix_ = true; - current_nodevisitor_ = &nv; + // check whether the particle system is frozen/culled + if (!ps_->isFrozen() && (ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) { - // do some process (unimplemented in this base class) - process(t - t0_); + // initialize matrix flags + need_ltw_matrix_ = true; + need_wtl_matrix_ = true; + current_nodevisitor_ = &nv; + + // do some process (unimplemented in this base class) + process(t - t0_); + } } + + // update t0_ + t0_ = t; + + } + else + { + osg::notify(osg::WARN) << "osgParticle::ParticleProcessor::traverse(NodeVisitor&) requires a valid FrameStamp to function, particles not updated.\n"; } - // update t0_ - t0_ = t; - - } else { + } else + { osg::notify(osg::WARN) << "ParticleProcessor \"" << getName() << "\": invalid particle system\n"; } } - } // call the inherited method diff --git a/src/osgParticle/ParticleSystemUpdater.cpp b/src/osgParticle/ParticleSystemUpdater.cpp index 96bd8a875..5a90f8be6 100644 --- a/src/osgParticle/ParticleSystemUpdater.cpp +++ b/src/osgParticle/ParticleSystemUpdater.cpp @@ -24,16 +24,27 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor &nv) { osgUtil::CullVisitor *cv = dynamic_cast(&nv); if (cv) { - double t = nv.getFrameStamp()->getReferenceTime(); - if (t0_ != -1) { - ParticleSystem_Vector::iterator i; - for (i=psv_.begin(); i!=psv_.end(); ++i) { - if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull())) { - i->get()->update(t - t0_); + if (nv.getFrameStamp()) + { + double t = nv.getFrameStamp()->getReferenceTime(); + if (t0_ != -1) + { + ParticleSystem_Vector::iterator i; + for (i=psv_.begin(); i!=psv_.end(); ++i) + { + if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull())) + { + i->get()->update(t - t0_); + } } } + t0_ = t; } - t0_ = t; + else + { + osg::notify(osg::WARN) << "osgParticle::ParticleSystemUpdater::traverse(NodeVisitor&) requires a valid FrameStamp to function, particles not updated.\n"; + } + } Node::traverse(nv); } diff --git a/src/osgPlugins/geo/Makefile b/src/osgPlugins/geo/Makefile index 362ea3b08..ec7b53e62 100644 --- a/src/osgPlugins/geo/Makefile +++ b/src/osgPlugins/geo/Makefile @@ -2,9 +2,10 @@ TOPDIR = ../../.. include $(TOPDIR)/Make/makedefs CXXFILES =\ + geoActions.cpp\ ReaderWriterGEO.cpp -LIBS += -losgText $(OSG_LIBS) $(OTHER_LIBS) +LIBS += -losgText -losgSim $(OSG_LIBS) $(OTHER_LIBS) TARGET_BASENAME = geo include $(TOPDIR)/Make/cygwin_plugin_def diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp index a1c85fc31..333d333f0 100644 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ b/src/osgPlugins/geo/ReaderWriterGEO.cpp @@ -1,6 +1,11 @@ // GEO format (carbon graphics Inc) loader for the OSG real time scene graph // www.carbongraphics.com for more information about the Geo animation+ modeller -// 2002 +// supports geometry and group & face level animations. +// Vertex level animation partly supported - defines movement (translate, rotate, colour)! +// Loader has been divided into two parts +// 1- general geometry (here) & +// 2- animation (see geoActions.cpp). +// ver 1.1 GWM Dec 2002 #include #include @@ -16,13 +21,17 @@ #include #include #include +#include +#include +#include #include #include #include #include #include +#include #include @@ -33,497 +42,145 @@ #include "geoUnits.h" #include "osgGeoAnimation.h" #include "osgGeoStructs.h" +#include "osgGeoNodes.h" +#include "osgGeoAction.h" #include // needed for text nodes -using namespace osg; -using namespace osgDB; +// +geoHeaderGeo::geoHeaderGeo() +{ // animations for the header - actually updates all control variables + intVars=new internalVars; useVars=new userVars; + extVars=new userVars; + _frameStamp.setFrameNumber(0); // vars=NULL; + tstart=_frameStamp.getReferenceTime(); + _initialTick = _timer.tick(); + color_palette=new colourPalette; +}; +const geoValue *geoHeaderGeo::getGeoVar(const unsigned fid) const { + const geoValue *st=intVars->getGeoVar(fid); + if (!st) { + st=useVars->getGeoVar(fid); + if (!st) { + st=extVars->getGeoVar(fid); + } + } + return st; +} +double *geoHeaderGeo::getVar(const unsigned fid) const { + double *dv=NULL; + dv=intVars->getVar(fid); + if (!dv) { + dv=useVars->getVar(fid); + if (!dv) { + dv=extVars->getVar(fid); + } + } + return dv; +} +void geoHeaderGeo::addUserVar(const georecord &gr) +{ // this georecord defines a single variable of type<> + useVars->addUserVar(gr); +} +//== handler for updating internal variables +void geoHeaderGeo::update(void) +{ // update the scene + 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); + moveit(time); +} +void geoHeaderGeo::moveit(const double t) +{ // all the local and external variables declared in the geo modeller are here available. + if (uvarupdate) { + std::vector *lvals=useVars->getvars(); + for (std::vector::iterator itr=lvals->begin(); + itr!=lvals->end(); + ++itr) {// for each user var + double vv=uvarupdate(t, itr->getVal(), itr->getName()); + // std::cout << " updatee " << itr->getName() << " " << vv << " " << itr->getVar() << std::endl; + itr->setVal(vv); + // vv=itr->getVal(); std::cout << " result " << itr->getName() << " " << vv << std::endl; + } + } + if (extvarupdate) { + std::vector *lvals=extVars->getvars(); + for (std::vector::iterator itr=lvals->begin(); + itr!=lvals->end(); + ++itr) {// for each user var + itr->setVal(extvarupdate(t, itr->getVal(), itr->getName())); + } + } +} + class geoHeaderCB: public osg::NodeCallback { public: geoHeaderCB() {} ~geoHeaderCB() {} virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { // update action vars - geoHeader *gh=(geoHeader *)node; + geoHeaderGeo *gh=(geoHeaderGeo *)node; gh->update(); + nv->setNodeMaskOverride(0xffffffff); // need to make the visitor override the nodemask + // so that it visits 'invisible' nodes to update visibility. Or could use + // a visitor with setTraversalMode(TraversalMode==TRAVERSE_ALL_CHILDREN)? traverse(node,nv); // std::cout<<"app callback - post traverse"<< (float)_frameStamp.getReferenceTime() <getField(GEO_DB_ARITHMETIC_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - in=theHeader->getVar(fid); // returns address of input var with fid - if (in) { - gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OUTPUT_VAR); - if (gfd) { - fid= gfd->getUInt(); // field identifier - out=theHeader->getVar(fid); // returns address of output var with fid - gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OP_TYPE); - uint iop=gfd?gfd->getUInt():1; - setType(iop); // default add? - gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE); - if (gfd) { - constant= gfd->getFloat(); // field identifier - ok=true; - } - gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - varop=theHeader->getVar(fid); - ok=varop != NULL; - } - } - } - } - return ok; - } -private: - float constant; - optype oper; - const double *varop; // if null use constant value in maths; else -}; - -class geoRangeBehaviour :public geoMathBehaviour { - // output = outmin + frac*(outmax-min) where frac = (in-min)/(max-min) -public: - geoRangeBehaviour() { inmin=outmin=(float)-1.e32; inmax=outmax=(float)1.e32; in=out=NULL;} - ~geoRangeBehaviour() { } - void setInMax(const double v) { inmax=v;} - void setInMin(const double v) { inmin=v;} - void setOutMax(const double v) { outmax=v;} - void setOutMin(const double v) { outmin=v;} - void doaction(osg::Node*) const { // do math operation - if (in && out) { - float v=*in; - if (vinmax) v=inmax; - v=(v-inmin)/(inmax-inmin); - *out = outmin+v*(outmax-outmin); - } - } - bool makeBehave(const georecord *grec, geoHeader *theHeader) { - bool ok=false; - const geoField *gfd=grec->getField(GEO_DB_RANGE_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - in=theHeader->getVar(fid); // returns address of input var with fid - if (in) { - gfd=grec->getField(GEO_DB_RANGE_ACTION_OUTPUT_VAR); - if (gfd) { - fid= gfd->getUInt(); // field identifier - out=theHeader->getVar(fid); // returns address of output var with fid - gfd=grec->getField(GEO_DB_RANGE_ACTION_IN_MIN_VAL); - inmin=gfd?gfd->getFloat():-1.e32; - gfd=grec->getField(GEO_DB_RANGE_ACTION_IN_MAX_VAL); - inmax= gfd?gfd->getFloat() : 1.e32; // field identifier - gfd=grec->getField(GEO_DB_RANGE_ACTION_OUT_MIN_VAL); - outmin=gfd?gfd->getFloat():-1.e32; - gfd=grec->getField(GEO_DB_RANGE_ACTION_OUT_MAX_VAL); - outmax= gfd?gfd->getFloat() : 1.e32; // field identifier - ok=true; - } - } - } - return ok; - } -private: - float inmin,inmax; - float outmin,outmax; -}; -class geoClampBehaviour :public geoMathBehaviour { -public: - geoClampBehaviour() { min=(float)-1.e32; max=(float)1.e32; in=out=NULL;} - ~geoClampBehaviour() { } - void setMax(const double v) { max=v;} - void setMin(const double v) { min=v;} - void doaction(osg::Node *) const { // do math operation - if (in && out) { - float v=*in; - if (vmax) v=max; - *out = v; - } - } - bool makeBehave(const georecord *grec, geoHeader *theHeader) { - bool ok=false; - const geoField *gfd=grec->getField(GEO_DB_CLAMP_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - in=theHeader->getVar(fid); // returns address of input var with fid - if (in) { - gfd=grec->getField(GEO_DB_CLAMP_ACTION_OUTPUT_VAR); - if (gfd) { - fid= gfd->getUInt(); // field identifier - out=theHeader->getVar(fid); // returns address of output var with fid - gfd=grec->getField(GEO_DB_CLAMP_ACTION_MIN_VAL); - min=gfd?gfd->getFloat():-1.e32; - gfd=grec->getField(GEO_DB_CLAMP_ACTION_MAX_VAL); - max= gfd?gfd->getFloat() : 1.e32; // field identifier - ok=true; - } - } - } - return ok; - } -private: - float min,max; -}; - -class geoMoveBehaviour { -public: - geoMoveBehaviour() { var=NULL; type=0;axis.set(0,0,1); centre.set(0,0,0);} - ~geoMoveBehaviour() { - var=NULL;} - void setType(const unsigned int t) { type=t; } - void setVar(const double *v) { var=v;} - void setCentre(const Vec3 v) { centre=v;} - void setAxis(const Vec3 v) { axis=v;} - inline unsigned int getType(void) const { return type;} - inline const double *getVar(void) { return var;} - inline double getValue(void) { return *var;} - inline double DEG2RAD(const double var) const { return var*0.0174532925199432957692369076848861; } - void doaction(osg::Node *node) const { - if (var) { - MatrixTransform *mtr=dynamic_cast (node); - switch (type) { - case DB_DSK_TRANSLATE_ACTION: - mtr->preMult( osg::Matrix::translate(axis*(*var)) ); - break; - case DB_DSK_ROTATE_ACTION: - mtr->preMult( osg::Matrix::translate(-centre)* - osg::Matrix::rotate(DEG2RAD(*var),axis)* - osg::Matrix::translate(centre)); - break; - } - } - } - - bool makeBehave(const georecord *grec, geoHeader *theHeader, const uint act) { - bool ok=false; - setType(act); - if (act==DB_DSK_ROTATE_ACTION) { - const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - var=theHeader->getVar(fid); // returns address of var with fid - if (var) { - gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR); - if (gfd) { - float *ax= gfd->getVec3Arr(); // field identifier - setAxis(osg::Vec3(ax[0],ax[1],ax[2])); - } - gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN); - if (gfd) { - float *ct= gfd->getVec3Arr(); // field identifier - setCentre(osg::Vec3(ct[0],ct[1],ct[2])); - } - ok=true; - } - } - } else if (act==DB_DSK_TRANSLATE_ACTION) { - const geoField *gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - var=theHeader->getVar(fid); // returns address of var with fid - if (var) { - gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR); - if (gfd) { - float *ax= gfd->getVec3Arr(); // field identifier - setAxis(osg::Vec3(ax[0],ax[1],ax[2])); - } - gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN); - if (gfd) { - float *ct= gfd->getVec3Arr(); // field identifier - setCentre(osg::Vec3(ct[0],ct[1],ct[2])); - } - ok=true; - } - } - } - return ok; - } -private: - // for fast transform behaviours - unsigned int type; // eg GEO_DB_ROTATE_ACTION_INPUT_VAR, translate etc - const double *var; // variable controls this behaviour - osg::Vec3 axis; // axis of rotation - osg::Vec3 centre; // centre of rotation -}; - -class geoStrContentBehaviour : public geoMoveBehaviour { - // sets content of a string... -public: - geoStrContentBehaviour() {format=NULL;PADDING_TYPE=0; - PAD_FOR_SIGN=0; vt=UNKNOWN; } - virtual ~geoStrContentBehaviour() { delete [] format;} - void doaction(osg::Drawable *node) { // do new text - osgText::Text *txt=dynamic_cast(node); - char content[32]; - switch (vt) { - case INT: - sprintf(content, format, (int)getValue()); - break; - case FLOAT: - sprintf(content, format, (float)getValue()); - break; - case DOUBLE: - sprintf(content, format, getValue()); - break; - case CHAR: - sprintf(content, format, (char *)getVar()); - break; - default: - sprintf(content, format, (char *)getVar()); - } - txt->setText(std::string(content)); - } - bool makeBehave(const georecord *grec, geoHeader *theHeader) { - bool ok=false; - const geoField *gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR); - if (gfd) { - unsigned fid= gfd->getUInt(); // field identifier - setVar(theHeader->getVar(fid)); // returns address of input var with fid - if (getVar()) { - gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_FORMAT); - if (gfd) { - char *ch=gfd->getChar(); - format=new char[strlen(ch)+1]; - strcpy(format, ch); - { - char *ctmp=format; - while (*ctmp) { - if (*ctmp=='d') vt=INT; - if (*ctmp=='f' && vt!=DOUBLE) vt=FLOAT; - if (*ctmp=='l') vt=DOUBLE; - ctmp++; - } - } - gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE); - // inmin=gfd?gfd->getFloat():-1.e32; - gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE); - ok=true; - } - } - } - return ok; - } - virtual void operator() (osg::Node *node, osg::NodeVisitor*) - { // update the string content - if (getVar()) { - osgText::Text *txt=dynamic_cast(node); - switch (getType()) { - case DB_DSK_STRING_CONTENT_ACTION: - { - char content[32]; - sprintf(content,"%f", getValue()); - txt->setText(std::string(content)); - } - break; - default: - break; - } - } - } - enum valuetype {UNKNOWN, INT, FLOAT, DOUBLE, CHAR}; -private: - char *format; - uint PADDING_TYPE; - uint PAD_FOR_SIGN; - valuetype vt; -}; - -class geoBehaviourCB: public osg::NodeCallback { -public: - geoBehaviourCB() { } - ~geoBehaviourCB() { } - void addBehaviour(geoMoveBehaviour *gb) {gblist.push_back(gb);} - void addBehaviour(geoClampBehaviour *gb) {galist.push_back(gb);} - void addBehaviour(geoArithBehaviour *gb) {galist.push_back(gb);} - void addBehaviour(geoRangeBehaviour *gb) {galist.push_back(gb);} - virtual void operator() (osg::Node *node, osg::NodeVisitor* nv) - { // update the transform - // std::cout<<"geoBehaviourCB callback - "<< var << " " << (*var) < (node); - mtr->setMatrix(Matrix::identity()); - { - for (std::vector::iterator itr=galist.begin(); - itr(*itr); - if (ab) ab->doaction(node); - geoClampBehaviour *cb=dynamic_cast(*itr); - if (cb) cb->doaction(node); - geoRangeBehaviour *cr=dynamic_cast(*itr); - if (cr) cr->doaction(node); - } - } - { - for (std::vector::const_iterator itr=gblist.begin(); - itrdoaction(node); - } - } - traverse(node,nv); - } -private: - std::vector gblist; - std::vector galist; -}; -class geoBehaviourDrawableCB: public osg::Drawable::AppCallback { -public: - geoBehaviourDrawableCB() { } - ~geoBehaviourDrawableCB() { } - void addBehaviour(geoStrContentBehaviour *gb) {gblist.push_back(gb);} - void addBehaviour(geoClampBehaviour *gb) {galist.push_back(gb);} - void addBehaviour(geoArithBehaviour *gb) {galist.push_back(gb);} - void addBehaviour(geoRangeBehaviour *gb) {galist.push_back(gb);} - void app(osg::NodeVisitor *,osg::Drawable *dr) { - //osgText::Text *mtr=dynamic_cast (dr); - { - for (std::vector::iterator itr=galist.begin(); - itr(*itr); - // if (ab) ab->doaction(dr); - // geoClampBehaviour *cb=dynamic_cast(*itr); - // if (cb) cb->doaction(dr); - // geoRangeBehaviour *cr=dynamic_cast(*itr); - // if (cr) cr->doaction(dr); - } - } - { - for (std::vector::const_iterator itr=gblist.begin(); - itrdoaction(dr); - } - } - } -/* virtual void operator() (osg::Node *node, osg::NodeVisitor* nv) - { // update the transform - // std::cout<<"geoBehaviourCB callback - "<< var << " " << (*var) < (node); - { - for (std::vector::iterator itr=galist.begin(); - itr(*itr); - if (ab) ab->doaction(node); - geoClampBehaviour *cb=dynamic_cast(*itr); - if (cb) cb->doaction(node); - geoRangeBehaviour *cr=dynamic_cast(*itr); - if (cr) cr->doaction(node); - } - } - { - for (std::vector::const_iterator itr=gblist.begin(); - itrdoaction(node); - } - } - // traverse(node,nv); - } */ -private: - std::vector gblist; - std::vector galist; -}; - -class pack_colour { -public: - pack_colour() { cr=cg=cb=0; ca=1;} - ~pack_colour() {} - pack_colour(const unsigned char col[4]) { cr= col[0]; cg= col[1];cb= col[2];; ca= col[2];} - void get(unsigned char col[4]) const { col[0]=cr; col[1]=cg; col[2]=cb; col[3]=ca; } - friend inline std::ostream& operator << (std::ostream& output, const pack_colour& pc) - { - output << " cpalette: " <<(int)pc.cr << " " <<(int)pc.cg << " " <<(int)pc.cb << " " <<(int)pc.ca; - return output; // to enable cascading.. - } -private: - unsigned char cr, cg, cb, ca; -}; +//============= class vertexInfo { // holds vertex information for an entire osg::geometry public: - vertexInfo(const std::vector *coord_pool, const std::vector *normal_pool) { + vertexInfo() { norms=new osg::Vec3Array; coords=new osg::Vec3Array; txcoords=new osg::Vec2Array; + colorindices=new osg::IntArray; coordindices=new osg::IntArray; normindices=new osg::IntArray; txindices=new osg::IntArray; colors=new osg::Vec4Array; + cpool=NULL; npool=NULL; + polycols= new osg::Vec4Array; // polygon colours + } + typedef std::vector drBehList; + void setPools(const std::vector *coord_pool, const std::vector *normal_pool) { cpool=coord_pool; npool=normal_pool; } + inline bool hasVertexActions(void) const { return !(BehList.empty()); } inline osg::Vec4Array *getColors() const { return colors;} inline osg::Vec3Array *getNorms() const { return norms;} inline osg::Vec3Array *getCoords() const { return coords;} inline osg::Vec2Array *getTexCoords() const { return txcoords;} + inline osg::IntArray *getColorIndices() const { return colorindices;} inline osg::IntArray *getCoordIndices() const { return coordindices;} inline osg::IntArray *getNormIndices() const { return normindices;} inline osg::IntArray *getTextureIndices() const { return txindices;} - void addIndices(georecord *gr, const std::vector color_palette, const unsigned char cdef[4]) + void addPolcolour( osg::Vec4 cl) { polycols->push_back(cl);} + osg::Vec4Array *getPolcolours() const { return polycols;} + void addVertexActions(geoBehaviourDrawableCB *gcb) const { // add the actions to callback + if ( !(BehList.empty()) ) { + for (drBehList::const_iterator rcitr=BehList.begin(); + rcitr!=BehList.end(); + ++rcitr) + { + gcb->addBehaviour(*rcitr); + } + } + } + bool addIndices(georecord *gr, const geoHeaderGeo *ghdr, const float cdef[4], const georecord *gface) { // this must only be called with a vertex georecord. + // gr is tha vertex; gface is the face containing the vertex + bool hbeh=false; // true if this vertex has a behaviour if (gr->getType()==DB_DSK_VERTEX) { const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL); int nrmindex=gfd ? gfd->getUInt():0; @@ -533,6 +190,47 @@ public: unsigned int idx=gfd ? gfd->getInt():0; coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2])); coordindices->push_back(txcoords->size()); + std::vector< georecord *>bhv=gr->getBehaviour(); // behaviours for vertices, eg tranlate, colour! + if (!bhv.empty()) { + int ncoord=coords->size(); + for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); + rcitr!=bhv.end(); + ++rcitr) + { + if ((*rcitr)->getType()==DB_DSK_TRANSLATE_ACTION) { + geoMoveVertexBehaviour *mb=new geoMoveVertexBehaviour; + mb->makeBehave((*rcitr),ghdr,DB_DSK_TRANSLATE_ACTION); + mb->setpos((*cpool)[idx]); + mb->setindx(ncoord-1); + BehList.push_back(mb); + } + if ((*rcitr)->getType()==DB_DSK_ROTATE_ACTION) { + geoMoveVertexBehaviour *mb=new geoMoveVertexBehaviour; + mb->makeBehave((*rcitr),ghdr,DB_DSK_ROTATE_ACTION); + mb->setpos((*cpool)[idx]); + mb->setindx(ncoord-1); + BehList.push_back(mb); + } + if ((*rcitr)->getType()==DB_DSK_COLOR_RAMP_ACTION) { + const geoField *gfd=gface->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... + bool usemat= gfd ? gfd->getBool() : false; + if (!usemat) { // modify the per vertex colours + gfd=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... + int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD; + gfd=gface->getField(GEO_DB_POLY_USE_VERTEX_COLORS); // true: use material... + bool usevert=gfd ? gfd->getBool() : false; + if (usevert || shademodel==GEO_POLY_SHADEMODEL_GOURAUD) { // then the vertex colours are used + geoColourBehaviour *cb=new geoColourBehaviour; + cb->setColorPalette(ghdr->getColorPalette()); + cb->setVertIndices(ncoord-1,1); // part of colours array to be modified + bool ok=cb->makeBehave((*rcitr), ghdr); + BehList.push_back(cb); + } // if the model does not use vertex colours... there can be no colour animation at vertex level + } + } + } + hbeh=true; + } txindices->push_back(txcoords->size()); float *uvc=NULL; gfd=gr->getField(GEO_DB_VRTX_UV_SET_1); @@ -549,39 +247,30 @@ public: gfd=gr->getField(GEO_DB_VRTX_PACKED_COLOR); if (gfd) { unsigned char *cp=gfd->getUCh4Arr(); - float red=cp[0]; - float green=cp[1]; - float blue=cp[2]; + float red=cp[0]/255.0f; + float green=cp[1]/255.0f; + float blue=cp[2]/255.0f; + float alpha=cp[3]/255.0f; colors->push_back(Vec4(red,green,blue,1.0)); - } else { // lok for a colour index (exclusive!) + } else { // look for a colour index (exclusive!) gfd=gr->getField(GEO_DB_VRTX_COLOR_INDEX); if (gfd) { - int icp=gfd->getInt(); - float red=1.0f; // convert to range {0-1} - float green=1.0f; - float blue=1.0f; - float alpha=1.0f; - uint maxcol=(icp)/128; // the maximum intensity, 0-127 in bank 0, 128-255 =b2 - float frac = (float)(icp-maxcol*128)/128.0f; - unsigned char col[4]; - if (maxcol < color_palette.size()) { - color_palette[maxcol].get(col); - red=col[0]*frac/255.0f; // convert to range {0-1} - green=col[1]*frac/255.0f; - blue=col[2]*frac/255.0f; - alpha=1.0; // col[3]*frac/255.0f; + uint icp=gfd->getInt(); + if (icp<128*(ghdr->getColorPalette())->size()) { + float col[4]; + ghdr->getPalette(icp,col); + colors->push_back(Vec4(col[0],col[1],col[2],1.0)); } else { - red=cdef[0]/255.0f; // convert to range {0-1} - green=cdef[1]/255.0f; - blue=cdef[2]/255.0f; - alpha=1.0; // col[3]*frac/255.0f; + colors->push_back(Vec4(cdef[0],cdef[1],cdef[2],cdef[3])); } - colors->push_back(Vec4(red,green,blue,alpha)); + } else { + colors->push_back(Vec4(cdef[0],cdef[1],cdef[2],cdef[3])); } + int idx=colors->size()-1; + colorindices->push_back(idx); } - - } + return hbeh; } friend inline std::ostream& operator << (std::ostream& output, const vertexInfo& vf) { @@ -607,15 +296,53 @@ private: osg::Vec3Array *coords; osg::Vec2Array *txcoords; osg::Vec4Array *colors; + osg::IntArray *colorindices; osg::IntArray *coordindices; osg::IntArray *normindices; osg::IntArray *txindices; + drBehList BehList; + Vec4Array *polycols; }; +class geoInfo { // identifies properties required to make a new Geometry, and holds collection of vertices, indices, etc +public: + geoInfo(const int txidx=-2, const int sm=1, const bool bs=true) { texture=txidx; // will be -1 or 0-number of textures + geom=NULL; nstart=0; + bothsides=bs; shademodel=sm; + } + virtual ~geoInfo() { }; + inline int getShademodel() const { return shademodel;} + inline bool getBothsides() const { return bothsides;} + inline int getTexture() const { return texture;} + inline vertexInfo *getVinf() { return &vinf;} + void setPools(const std::vector *coord_pool, const std::vector *normal_pool) { + vinf.setPools(coord_pool,normal_pool); + } + void setGeom(osg::Geometry *nugeom) { geom=nugeom;} + osg::Geometry *getGeom() const { return geom;} + osg::Geometry *getGeom() { return geom;} + uint getStart(uint nv) { uint ns=nstart; nstart+=nv; return ns; } + bool operator == (const geoInfo *gt) { // compare two geoInfos for same type of geometry + if (gt->texture!=texture) return false; + if (gt->bothsides == !bothsides) return false; + if (gt->shademodel!=shademodel) return false; + // other tests if failed return false + return true; + } +private: + int texture; // texture index + bool bothsides; + int shademodel; + vertexInfo vinf; + uint nstart; // start vertex for a primitive + osg::Geometry *geom; // the geometry created for this vinf and texture +}; + + class ReaderWriterGEO : public ReaderWriter { public: - ReaderWriterGEO() { } + ReaderWriterGEO() { cpalrec=NULL; } ~ReaderWriterGEO() { } virtual const char* className() { return "GEO Reader/Writer"; } @@ -633,11 +360,11 @@ class ReaderWriterGEO : public ReaderWriter if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; std::ifstream fin(fileName.c_str(), std::ios::binary | std::ios::in ); + std::ofstream fdup("geodup.geo", std::ios::binary | std::ios::out ); if (fin.is_open() ) { // read the input file. typedef std::vector NodeList; NodeList nodeList; - geoRecordList recs; osg::Material *mt=new osg::Material; matlist.push_back(mt); theHeader=NULL; @@ -647,26 +374,35 @@ class ReaderWriterGEO : public ReaderWriter { georecord gr; gr.readfile(fin); - // osg::notify(osg::WARN) << gr << std::endl; + if (gr.getType() != DB_DSK_INSTANCE) gr.writefile(fdup); // create a duplicate file + if (gr.getType() == DB_DSK_NORMAL_POOL) { + geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);; + gfff->uncompress();// uncompress the normals + } recs.push_back(gr); // add to a list of all records } fin.close(); - // now sort the reocrds so that any record followed by a PUSh has a child set = next record, etc + fdup.close(); + // now sort the records so that any record followed by a PUSh has a child set = next record, etc std::vector sorted=sort(recs); // tree-list of sorted record pointers - // osgDB::Output fout("georex.txt"); //, std::ios_base::out ); - // fout << "Debug file " << fileName << std::endl; +#ifdef _DEBUG + osgDB::Output fout("georex.txt"); //, std::ios_base::out ); + fout << "Debug file " << fileName << std::endl; + output(fout,sorted); + fout.close(); +#endif + nodeList=makeosg(sorted); // make a list of osg nodes - // fout.close(); + - recs.erase(recs.begin(),recs.end()); - color_palette.erase(color_palette.begin(),color_palette.end()); - geotxlist.erase(geotxlist.begin(),geotxlist.end()); - geomatlist.erase(geomatlist.begin(),geomatlist.end()); - txlist.erase(txlist.begin(),txlist.end()); - txenvlist.erase(txenvlist.begin(),txenvlist.end()); - matlist.erase(matlist.begin(),matlist.end());/* */ - coord_pool.erase(coord_pool.begin(),coord_pool.end()); - normal_pool.erase(normal_pool.begin(),normal_pool.end()); + recs.clear(); + geotxlist.clear(); + geomatlist.clear(); + txlist.clear(); + txenvlist.clear(); + matlist.clear();/* */ + coord_pool.clear(); + normal_pool.clear(); if (nodeList.empty()) { return ReadResult("No data loaded from "+fileName); @@ -761,15 +497,7 @@ class ReaderWriterGEO : public ReaderWriter } break; case DB_DSK_COLOR_PALETTE: // global - attach to readerwriterGEO - gfd=itr->getField(GEO_DB_COLOR_PALETTE_HIGHEST_INTENSITIES); - if (gfd) { - unsigned char *cpal=gfd->getstore(0); - for (uint i=1; igetNum(); i++) { - color_palette.push_back(cpal); - cpal+=4; - } - //color_palette= (gfd) ? (gfd->getUCh4Arr()):NULL; - } + cpalrec=&(*itr); break; case DB_DSK_BEHAVIOR: // || (*itr).isAction() // attach to previous case DB_DSK_CLAMP_ACTION: @@ -790,13 +518,21 @@ class ReaderWriterGEO : public ReaderWriter case DB_DSK_PERIODIC_ACTION: case DB_DSK_PERIODIC2_ACTION: case DB_DSK_TRIG_ACTION: + case DB_DSK_DISCRETE_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: + case DB_DSK_SQRT_ACTION: // square root action (curparent->getLastChild())->addBehaviourRecord(&(*itr)); break; + case DB_DSK_PLANE_TEXTURE_MAPPING_INFO: // not needed for real time + case DB_DSK_CYLINDER_TEXTURE_MAPPING_INFO: // not implemented in 1.0 + case DB_DSK_SPHERE_TEXTURE_MAPPING_INFO: // not implemented in 1.0 + case DB_DSK_GRID_TEXTURE_MAPPING_INFO: // not implemented in 1.0 + (curparent->getLastChild())->addMappingRecord(&(*itr)); + break; default: if (curparent) { (*itr).setparent(curparent); @@ -817,74 +553,120 @@ class ReaderWriterGEO : public ReaderWriter } } } - osg::Geometry *makeNewGeometry(const georecord *grec, const vertexInfo &vinf, int txidx, uint imat, - int shademodel, Vec4Array *polycols) { + bool allOneSided(const georecord *grec) { + bool one=false; + const std::vector gr=grec->getchildren(); + if (gr.size()>0) { + for (std::vector::const_iterator itr=gr.begin(); + itr!=gr.end() && !one; + ++itr) { + if ((*itr)->getType()==DB_DSK_POLYGON) { + const geoField *gfd=(*itr)->getField(GEO_DB_POLY_DSTYLE); + if (gfd) { + int dstyle=gfd->getInt(); + one=(dstyle==GEO_POLY_DSTYLE_SOLID_BOTH_SIDES); + } + } + } + } + return one; + } + osg::Geometry *makeNewGeometry(const georecord *grec, geoInfo &ginf, uint imat) { + const int shademodel=ginf.getShademodel(); + const bool bothsides=ginf.getBothsides(); osg::Geometry *nug; + int txidx=ginf.getTexture(); nug=new osg::Geometry; + const vertexInfo *vinf=ginf.getVinf(); nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); - nug->setVertexArray(vinf.getCoords()); - nug->setNormalArray(vinf.getNorms()); + nug->setVertexArray(vinf->getCoords()); + nug->setNormalArray(vinf->getNorms()); StateSet *dstate=new StateSet; + if (!bothsides) { + osg::CullFace *cf = new osg::CullFace; // to define non-default culling + cf->setMode(osg::CullFace::BACK); + dstate->setAttributeAndModes(cf,osg::StateAttribute::ON); + } + Point *pt=new Point; + pt->setSize(4); + dstate->setAttribute(pt); if (txidx>=0 && (unsigned int)txidxsetTextureAttribute(0, txenvlist[txidx] ); dstate->setTextureAttributeAndModes(0,txlist[txidx],osg::StateAttribute::ON); + const Image *txim=txlist[txidx]->getImage(); + if (txim) { + GLint icm=txim->computeNumComponents(txim->getPixelFormat()); + if (icm ==2 || icm==4) { // an alpha texture + dstate->setMode(GL_BLEND,StateAttribute::ON); + dstate->setRenderingHint(StateSet::TRANSPARENT_BIN); + } + } } - if (imat>0 && imat=matlist.size()) imat=0; + const geoField *gfd=grec->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... + bool usemat= gfd ? gfd->getBool() : false; + if (!usemat) { matlist[imat]->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); - dstate->setAttribute(matlist[imat]); - } else { - matlist[0]->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); - dstate->setAttribute(matlist[0]); + dstate->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON); } - dstate->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON); + dstate->setAttribute(matlist[imat]); + Vec4 col=matlist[imat]->getAmbient(Material::FRONT); + if (col[3]<0.99) { + dstate->setMode(GL_BLEND,StateAttribute::ON); + dstate->setRenderingHint(StateSet::TRANSPARENT_BIN); + } + if (shademodel==GEO_POLY_SHADEMODEL_LIT || shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON ); else dstate->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); { // reclaim the colours - const geoField *gfd=grec->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... + gfd=grec->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... bool usemat= gfd ? gfd->getBool() : false; if (!usemat) { // get the per vertex colours OR per face colours. gfd=grec->getField(GEO_DB_POLY_USE_VERTEX_COLORS); // true: use material... - bool usevert=gfd ? gfd->getBool() : true; - if (usevert) { - Vec4Array *cls=vinf.getColors(); + bool usevert=gfd ? gfd->getBool() : false; + if (usevert || shademodel==GEO_POLY_SHADEMODEL_GOURAUD) { + Vec4Array *cls=vinf->getColors(); if (cls) { nug->setColorArray(cls); nug->setColorBinding(osg::Geometry::BIND_PER_VERTEX); } } else { - if (polycols->size() > 0) { + osg::Vec4Array *polycols=vinf->getPolcolours(); + //if (polycols->size() > 0) { nug->setColorArray(polycols); - nug->setColorBinding(osg::Geometry::BIND_PER_VERTEX); //PRIMITIVE); - } + nug->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); + //} } } } nug->setStateSet( dstate ); + ginf.setGeom(nug); return nug; } - int getprim(const georecord *grec,vertexInfo &vinf) + int getprim(const georecord *grec, geoInfo &gi) { // fills vinf with txcoords = texture coordinates, txindex=txindex etc + // for one primitive (one tri, quad, pol, tristrip.... + vertexInfo *vinf=gi.getVinf(); int nv=0; const std::vector gr=grec->getchildren(); const geoField *gfd=grec->getField(GEO_DB_POLY_PACKED_COLOR); // the colour - unsigned char defcol[4]; // a default colour for vertices - defcol[0]=defcol[1]=defcol[2]=defcol[3]=255; + float defcol[4]; // a default colour for vertices + defcol[0]=defcol[1]=defcol[2]=defcol[3]=1.0f; if (gfd) { unsigned char *cls=gfd->getUCh4Arr(); - defcol[0]=cls[0]; - defcol[1]=cls[1]; - defcol[2]=cls[2]; - defcol[3]=255; + defcol[0]=cls[0]/255.0f; + defcol[1]=cls[1]/255.0f; + defcol[2]=cls[2]/255.0f; + defcol[3]=1.0f; } else { gfd=grec->getField(GEO_DB_POLY_COLOR_INDEX); // the colour if (gfd) { int icp= gfd ? gfd->getInt() : 0; - int maxcol=icp/128; // the maximum intensity index - color_palette[maxcol].get(defcol); + theHeader->getPalette(icp,defcol); } else { - defcol[0]=defcol[1]=defcol[2]=defcol[3]=255; + defcol[0]=defcol[1]=defcol[2]=defcol[3]=1.0f; } } @@ -892,25 +674,28 @@ class ReaderWriterGEO : public ReaderWriter for (std::vector::const_iterator itr=gr.begin(); itr!=gr.end(); ++itr) { - vinf.addIndices((*itr), color_palette, defcol); + bool hbeh=vinf->addIndices((*itr), theHeader, defcol, grec); + if (hbeh) { // then add a behaviour callback to the primitive + bool hasbehave=true; + } nv++; } } return nv; } - void outputGeode(georecord grec) { // , osgDB::Output &fout + void outputGeode(georecord grec, osgDB::Output &fout) { // const std::vector gr=grec.getchildren(); if (gr.size()>0) { - // fout.moveIn(); + fout.moveIn(); for (std::vector::const_iterator itr=gr.begin(); itr!=gr.end(); ++itr) { - //fout.indent() << *(*itr) << std::endl; + fout.indent() << *(*itr) << std::endl; if ((*itr)->getType()==DB_DSK_POLYGON) { - //outputPrim((*itr),fout); + outputPrim((*itr),fout); } } - // fout.moveOut(); + fout.moveOut(); } } osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text @@ -939,9 +724,9 @@ class ReaderWriterGEO : public ReaderWriter gfd=gr->getField(GEO_DB_TEXT_PACKED_COLOR); if (gfd) { unsigned char *cp=gfd->getUCh4Arr(); - float red=(float)cp[0]*255.0f; - float green=(float)cp[1]*255.0f; - float blue=(float)cp[2]*255.0f; + float red=(float)cp[0]/255.0f; + float green=(float)cp[1]/255.0f; + float blue=(float)cp[2]/255.0f; text->setColor(osg::Vec4(red,green,blue,1.0f)); } else { // lok for a colour index (exclusive!) gfd=gr->getField(GEO_DB_TEXT_COLOR_INDEX); @@ -951,26 +736,16 @@ class ReaderWriterGEO : public ReaderWriter float green=1.0f; float blue=1.0f; float alpha=1.0f; - uint maxcol=(icp)/128; // the maximum intensity, 0-127 in bank 0, 128-255 =b2 - float frac = (float)(icp-maxcol*128)/128.0f; - unsigned char col[4]; - if (maxcol < color_palette.size()) { - color_palette[maxcol].get(col); - red=col[0]*frac/255.0f; // convert to range {0-1} - green=col[1]*frac/255.0f; - blue=col[2]*frac/255.0f; - alpha=1.0; // col[3]*frac/255.0f; - } else { - red=1.0f; // default colour range {0-1} - green=1.0f; - blue=1.0f; - alpha=1.0; // col[3]*frac/255.0f; - } - text->setColor(osg::Vec4(red,green,blue,1.0)); + float col[4]; + theHeader->getPalette(icp,col); + text->setColor(osg::Vec4(col[0],col[1],col[2],1.0)); } } - osg::MatrixTransform *numt=new osg::MatrixTransform; osg::Geode *geod=new osg::Geode; + osg::StateSet *textState = osgNew osg::StateSet(); + textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + geod->setStateSet( textState ); + osg::MatrixTransform *numt=new osg::MatrixTransform; gfd=gr->getField(GEO_DB_TEXT_MATRIX); if (gfd) { float *fmat=gfd->getMat44Arr(); @@ -983,8 +758,8 @@ class ReaderWriterGEO : public ReaderWriter std::vector< georecord *>bhv=gr->getBehaviour(); if (!bhv.empty()) { // then check for a string content/colour.. action bool ok=false; - geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB; - text->setAppCallback(gcb); + geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB; + text->setAppCallback(gcb); for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); rcitr!=bhv.end(); ++rcitr) @@ -996,7 +771,7 @@ class ReaderWriterGEO : public ReaderWriter ok=cb->makeBehave((*rcitr), theHeader); if (ok) gcb->addBehaviour(cb); else delete cb; - ok=false; + // ok=false; } } } @@ -1004,31 +779,106 @@ class ReaderWriterGEO : public ReaderWriter } return numt; } - void makeGeometry(georecord grec, const unsigned int imat,Geode *nug) - { // makegeometry returns a set of Geometrys attached to current parent (Geode nug) - const std::vector gr=grec.getchildren(); - std::vector geom; - if (gr.size()>0) { - Vec4Array *polycols= new osg::Vec4Array; // polygon colours - std::vector ia; // list of texture indices found i this geode; sort into new - vertexInfo vinf(&coord_pool, &normal_pool); // holds all types of coords, indices etc - int nstart=0; // start of list - for (std::vector::const_iterator itr=gr.begin(); + void addPolyActions(std::vector< georecord *>bhv, geoInfo &gi , const uint nv) { + const vertexInfo *vinf=gi.getVinf(); + const uint nstart=gi.getStart(nv); + if (hasColorAction(bhv) || vinf->hasVertexActions()) { + osg::Geometry *nugeom=gi.getGeom(); + geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB; + nugeom->setAppCallback(gcb); + nugeom->setUseDisplayList(false); // as we are updating arrays, cannot change colours + for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); + rcitr!=bhv.end(); + ++rcitr) + { + if ((*rcitr)->getType()==DB_DSK_COLOR_RAMP_ACTION) { + geoColourBehaviour *cb=new geoColourBehaviour; + cb->setColorPalette(theHeader->getColorPalette()); + if (nugeom->getColorBinding()==osg::Geometry::BIND_PER_VERTEX) { + cb->setVertIndices(nstart,nv); // part of colours array to be modified + } else if (nugeom->getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) { // per primitive + const uint nst=nugeom->getNumPrimitiveSets(); + cb->setVertIndices(nst,1); // part of colours array to be modified + } else { // overall + cb->setVertIndices(0,1); // part of colours array to be modified + } + bool ok=cb->makeBehave((*rcitr), theHeader); + if (ok) gcb->addBehaviour(cb); + else delete cb; + } + } + vinf->addVertexActions(gcb); + } + } + void makeLightPointNode(const georecord *grec, osgSim::LightPointNode *lpn) { + // light points.. require OSG professional license + // OR LGPL software. + const std::vector gr=grec->getchildren(); + for (std::vector::const_iterator itr=gr.begin(); itr!=gr.end(); - ++itr) { - if ((*itr)->getType()==DB_DSK_POLYGON) { + ++itr) + { + if ((*itr)->getType()==DB_DSK_VERTEX) + { // light point vertices + const geoField *gfd=(*itr)->getField(GEO_DB_VRTX_COORD); + unsigned int idx=gfd ? gfd->getInt():0; + gfd=(*itr)->getField(GEO_DB_VRTX_PACKED_COLOR); + if (gfd) { + unsigned char *cls=gfd->getUCh4Arr(); + float red=cls[0]/255.0f; + float green=cls[1]/255.0f; + float blue=cls[2]/255.0f; + float alpha=1.0f; // cls[3]*frac/255.0f; + osg::Vec4 colour(red,green,blue,1.0f); + lpn->addLightPoint(osgSim::LightPoint(true,coord_pool[idx],colour,1.0f,1.0f,30,0,0,osgSim::LightPoint::BLENDED)); + } else { // get colour from palette + gfd=(*itr)->getField(GEO_DB_VRTX_COLOR_INDEX); // use color pool... + int icp= gfd ? gfd->getInt() : 0; + float col[4]; + theHeader->getPalette(icp, col); + lpn->addLightPoint(osgSim::LightPoint((coord_pool)[idx], osg::Vec4(col[0],col[1],col[2],1.0f))); + } + } + } + } + void makeLightPointGeometry(const georecord *grec, Group *nug) { + const std::vector gr=grec->getchildren(); + for (std::vector::const_iterator itr=gr.begin(); + itr!=gr.end(); + ++itr) + { + if ((*itr)->getType()==DB_DSK_LIGHTPT) { // light points ONLY + geoInfo ginf(0,0, true);; + ginf.setPools(&coord_pool, &normal_pool); // holds all types of coords, indices etc + osgSim::LightPointNode *gd=new osgSim::LightPointNode; + const geoField *gfd=(*itr)->getField(GEO_DB_LIGHTPT_TYPE); // omni, uni, bi + makeLightPointNode((*itr),gd); // add vertex positions to light point set + nug->addChild(gd); + } + } + } + void makeAnimatedGeometry(const georecord grec, const unsigned int imat,Group *nug) { + // animated polygons - create a matrix & geode & poly & add to group nug + const std::vector gr=grec.getchildren(); + bool bothsides=allOneSided(&grec); + for (std::vector::const_iterator itr=gr.begin(); + itr!=gr.end(); + ++itr) { + std::vector< georecord *>bhv=(*itr)->getBehaviour(); // behaviours attached to facets, eg colour! + if ((*itr)->getType()==DB_DSK_POLYGON && !bhv.empty()) { // animated facets go here + if (hasMotionAction(bhv)) { // make matrix if motion needed. const geoField *gfd=(*itr)->getField(GEO_DB_POLY_TEX); int txidx= gfd ? gfd->getInt() : -1; - int igidx=0, igeom=-1; - - gfd=(*itr)->getField(GEO_DB_POLY_DSTYLE); // solid, wire... - int dstyle= gfd ? gfd->getInt() : (int)GEO_DB_SOLID; gfd=(*itr)->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... - int shademodel=gfd ? (uint)gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD; - //shade models GEO_POLY_SHADEMODEL_FLAT GEO_POLY_SHADEMODEL_GOURAUD - // GEO_POLY_SHADEMODEL_LIT GEO_POLY_SHADEMODEL_LIT_GOURAUD + int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD; gfd=(*itr)->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... bool usemat= gfd ? gfd->getBool() : false; + geoInfo ginf(txidx,shademodel, bothsides);; + ginf.setPools(&coord_pool, &normal_pool); // holds all types of coords, indices etc + MatrixTransform *mtr=makeBehave(*itr); + Geode *gd=new Geode; + gfd=(*itr)->getField(GEO_DB_POLY_DSTYLE); // solid, wire... + int dstyle= gfd ? gfd->getInt() : GEO_POLY_DSTYLE_SOLID; if (!usemat && (shademodel== GEO_POLY_SHADEMODEL_LIT ||shademodel== GEO_POLY_SHADEMODEL_LIT_GOURAUD) ) { // get the per vertex colours OR per face colours. gfd=(*itr)->getField(GEO_DB_POLY_PACKED_COLOR); // the colour @@ -1038,62 +888,185 @@ class ReaderWriterGEO : public ReaderWriter float green=cls[1]/255.0f; float blue=cls[2]/255.0f; float alpha=1.0f; // cls[3]*frac/255.0f; - polycols->push_back(osg::Vec4(red,green,blue,alpha)); + ginf.getVinf()->addPolcolour(osg::Vec4(red,green,blue,alpha)); } else { // get colour from palette gfd=(*itr)->getField(GEO_DB_POLY_COLOR_INDEX); // use color pool... int icp= gfd ? gfd->getInt() : 0; - int maxcol=icp/128; // the maximum intensity index - unsigned char col[4]; - color_palette[maxcol].get(col); - float frac = (float)(icp-maxcol*128)/128.0f; // how high up the intensity we are - float red=col[0]*frac/255.0f; - float green=col[1]*frac/255.0f; - float blue=col[2]*frac/255.0f; - float alpha=col[3]*frac/255.0f; - polycols->push_back(osg::Vec4(red,green,blue,alpha)); + float col[4]; + theHeader->getPalette(icp, col); + ginf.getVinf()->addPolcolour(osg::Vec4(col[0],col[1],col[2],1.0)); } } - gfd=(*itr)->getField(GEO_DB_POLY_NORMAL); // polygon normal for whole poly - for (IntArray::const_iterator itrint=ia.begin(); - itrint!=ia.end(); - ++itrint) { // find a geometry that shares this texture. - if (txidx==(*itrint)) igeom=igidx; - igidx++; - } - int nv=getprim((*itr),vinf); - if (igeom<0) { // we need a new geometry for this due to new texture/material combo - osg::Geometry *nugeom=makeNewGeometry((*itr), vinf, txidx, imat,shademodel, polycols); - geom.push_back(nugeom); - nug->addDrawable(nugeom); - igeom=ia.size(); - ia.push_back(txidx); // look up table for which texture corresponds to which geom - } - - if (dstyle==0x00000004 || dstyle & GEO_DB_SOLID || dstyle & GEO_DB_OUTLINED) geom[igeom]->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,nstart,nv)); - if (dstyle & GEO_DB_WIRE || dstyle & GEO_DB_OUTLINED) geom[igeom]->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,nstart,nv)); - nstart+=nv; + nug->addChild(mtr); + mtr->addChild(gd); + osg::Geometry *nugeom=makeNewGeometry((*itr), ginf, imat); + int nv=getprim((*itr),ginf); + gd->addDrawable(nugeom); // now add the polygon + if (dstyle==GEO_POLY_DSTYLE_SOLID_BOTH_SIDES || dstyle == GEO_POLY_DSTYLE_SOLID) nugeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,nv)); + if (dstyle==GEO_POLY_DSTYLE_OPEN_WIRE) nugeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,nv)); + if (dstyle==GEO_POLY_DSTYLE_CLOSED_WIRE) nugeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,nv)); + if (dstyle==GEO_POLY_DSTYLE_POINTS) nugeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,nv)); + addPolyActions(bhv, ginf ,nv); } } - osg::Vec2Array *txa=vinf.getTexCoords(); - if (txa->size() > 0 ) { - for (std::vector::iterator itr=geom.begin(); - itr!=geom.end(); - ++itr) { - (*itr)->setTexCoordArray(0, txa); + + } + return; + } + bool hasColorAction(std::vector< georecord *>bhv) { // true if one of the actions changes colour + bool ok=false; + // if (bhv) { + for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); + rcitr!=bhv.end() && !ok; + ++rcitr) + { + switch ((*rcitr)->getType()) { + case DB_DSK_COLOR_RAMP_ACTION: + ok=true; + break; + default: + break; + } + } + // } + return ok; + } + bool hasMotionAction(std::vector< georecord *>bhv) { // true if one of the actions is a motion + bool ok=false; + // if (bhv) { + for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); + rcitr!=bhv.end() && !ok; + ++rcitr) + { + switch ((*rcitr)->getType()) { + case DB_DSK_ROTATE_ACTION: + case DB_DSK_SCALE_ACTION: + case DB_DSK_TRANSLATE_ACTION: + ok=true; + break; + default: + break; + } + } + // } + return ok; + } + geoInfo *getGeometry(const georecord *grec,Geode *nug, std::vector *ia, + const unsigned int imat, const int shademodel, const bool bothsides) { + //gfd=(*itr)->getField(GEO_DB_POLY_NORMAL); // polygon normal for whole poly + int igidx=0, igeom=-1; + const geoField *gfd=grec->getField(GEO_DB_POLY_TEX); + int txidx= gfd ? gfd->getInt() : -1; + for (std::vector::const_iterator itrint=ia->begin(); + itrint!=ia->end() && igeom<0; + ++itrint) { // find a geometry that shares this texture. + // also test for other properties of a unique material: + // - use material/vertex colours; + geoInfo gu(txidx,shademodel, bothsides); + if (gu==&(*itrint) && !(*itrint).getGeom()->getAppCallback()) igeom=igidx; + igidx++; + } + std::vector< georecord *>bhv=grec->getBehaviour(); // behaviours attached to facets, eg colour! + if (igeom<0 || hasColorAction(bhv)) { // we need a new geometry for this due to new texture/material combo or an action + gfd=grec->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... + int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD; + geoInfo gi(txidx,shademodel, bothsides); + gi.setPools(&coord_pool, &normal_pool); + osg::Geometry *nugeom=makeNewGeometry(grec, gi, imat); + nug->addDrawable(nugeom); + igeom=ia->size(); + ia->push_back(gi); // look up table for which texture corresponds to which geom + } + return (&((*ia)[igeom])); + } + void makeGeometry(const georecord &grec, const unsigned int imat,Geode *nug) + { // makegeometry makes a set of Geometrys attached to current parent (Geode nug) + const std::vector gr=grec.getchildren(); + // std::vector geom; + if (gr.size()>0) { + std::vector ia; // list of texture indices & vinfo found in this geode; sort into new + // vertexInfo vinf(&coord_pool, &normal_pool); // holds all types of coords, indices etc + bool bothsides=allOneSided(&grec); + for (std::vector::const_iterator itr=gr.begin(); + itr!=gr.end(); + ++itr) { + std::vector< georecord *>bhv=(*itr)->getBehaviour(); // behaviours attached to facets, eg colour! + if ( !hasMotionAction(bhv)) { // animated facets go elsewhere + if ((*itr)->getType()==DB_DSK_POLYGON) { // a normal facet + const geoField *gfd=(*itr)->getField(GEO_DB_POLY_DSTYLE); // solid, wire... + int dstyle= gfd ? gfd->getInt() : GEO_POLY_DSTYLE_SOLID; + gfd=(*itr)->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... + int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD; + geoInfo *gi=getGeometry((*itr), nug, &ia, imat,shademodel, bothsides); + + //shade models GEO_POLY_SHADEMODEL_FLAT GEO_POLY_SHADEMODEL_GOURAUD + // GEO_POLY_SHADEMODEL_LIT GEO_POLY_SHADEMODEL_LIT_GOURAUD + gfd=(*itr)->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material... + bool usemat= gfd ? gfd->getBool() : false; + if (!usemat || + shademodel== GEO_POLY_SHADEMODEL_LIT /*||shademodel== GEO_POLY_SHADEMODEL_LIT_GOURAUD) */ ) { // get the per vertex colours OR per face colours. + gfd=(*itr)->getField(GEO_DB_POLY_PACKED_COLOR); // the colour + if (gfd) { + unsigned char *cls=gfd->getUCh4Arr(); + float red=cls[0]/255.0f; + float green=cls[1]/255.0f; + float blue=cls[2]/255.0f; + float alpha=1.0f; // cls[3]*frac/255.0f; + gi->getVinf()->addPolcolour(osg::Vec4(red,green,blue,alpha)); + } else { // get colour from palette + gfd=(*itr)->getField(GEO_DB_POLY_COLOR_INDEX); // use color pool... + int icp= gfd ? gfd->getInt() : 0; + float col[4]; + theHeader->getPalette(icp, col); + gi->getVinf()->addPolcolour(osg::Vec4(col[0],col[1],col[2],1.0)); + } + } + int nv=getprim((*itr), *gi); + if (hasColorAction(bhv)) addPolyActions(bhv, *gi, nv); + + if (dstyle==GEO_POLY_DSTYLE_SOLID_BOTH_SIDES || dstyle == GEO_POLY_DSTYLE_SOLID) { + osg::DrawArrays *drw=new osg::DrawArrays(osg::PrimitiveSet::POLYGON,gi->getStart(nv),nv); + gi->getGeom()->addPrimitiveSet(drw); + } + if (dstyle == GEO_POLY_DSTYLE_OPEN_WIRE) { + osg::DrawArrays *drw=new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,gi->getStart(nv),nv); + gi->getGeom()->addPrimitiveSet(drw); + } + if (dstyle == GEO_POLY_DSTYLE_CLOSED_WIRE) { + osg::DrawArrays *drw=new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,gi->getStart(nv),nv); + gi->getGeom()->addPrimitiveSet(drw); + } + if (dstyle==GEO_POLY_DSTYLE_POINTS) { + osg::DrawArrays *drw=new osg::DrawArrays(osg::PrimitiveSet::POINTS,gi->getStart(nv),nv); + gi->getGeom()->addPrimitiveSet(drw); + } + } + } + } + { + int igeom=0; + for (std::vector::iterator itr=ia.begin(); + itr!=ia.end(); + ++itr) { + if ((*itr).getTexture() >=0) { + osg::Vec2Array *txa=ia[igeom].getVinf()->getTexCoords(); + if (txa->size() > 0 ) { + ((*itr).getGeom())->setTexCoordArray(0, txa); + } + } + igeom++; } } // osg::notify(osg::WARN) << vinf; } return; } - void makeTexts(georecord grec, unsigned int /*imat*/,Group *nug) - { // makegeometry returns a set of Geometrys attached to current parent (Geode nug) + void makeTexts(georecord grec, Group *nug) + { // makeTexts adds a set of text+transform Geometrys attached to current parent (Group nug) const std::vector gr=grec.getchildren(); std::vector geom; if (gr.size()>0) { - //Vec4Array *polycols= new osg::Vec4Array; // polygon colours std::vector ia; // list of texture indices found in this geode; sort into new - //int nstart=0; // start of list for (std::vector::const_iterator itr=gr.begin(); itr!=gr.end(); ++itr) { @@ -1116,29 +1089,72 @@ class ReaderWriterGEO : public ReaderWriter if (gfd) { nug->setName(gfd->getChar()); } - makeTexts((*gr),imat,nug); + makeTexts((*gr),nug); return nug; } - Geode *makeGeode(const georecord *gr) - { + Group *makeLightPointGeodes(const georecord *gr) { + const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT); + Group *nug=new Group; + gfd=gr->getField(GEO_DB_RENDERGROUP_NAME); + if (gfd) { + char *name = gfd->getChar(); + nug->setName(name); + } + Geode *gd=new Geode; + makeLightPointGeometry(gr,nug); + if (nug->getNumChildren() <=0) { + nug=NULL; + } + return nug; + } + Group *makeAnimatedGeodes(const georecord *gr) + { // create a group full of animated geodes. Used for any animations applied to facets! + // movement actions require a transform node to be inserted, and this cannot be + // derived from Geode. So create a group, add matrix transform(s) for each animated polygon const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT); const unsigned int imat=gfd ? gfd->getInt():0; gfd=gr->getField(GEO_DB_RENDERGROUP_IS_BILLBOARD); bool isbillb = gfd ? gfd->getBool() : false; + Group *nug=new Group; + /* if (isbillb) { + Billboard *bilb= new Billboard ; + bilb->setAxis(Vec3(0,0,1)); + bilb->setNormal(Vec3(0,-1,0)); + nug=bilb; + } else { + nug=new Geode; + } */ + gfd=gr->getField(GEO_DB_RENDERGROUP_NAME); + if (gfd) { + char *name = gfd->getChar(); + nug->setName(name); + } + makeAnimatedGeometry((*gr),imat,nug); + if (nug->getNumChildren() <=0) { + nug=NULL; + } + return nug; + } + Geode *makeGeode(const georecord &gr) + { + const geoField *gfd=gr.getField(GEO_DB_RENDERGROUP_MAT); + const unsigned int imat=gfd ? gfd->getInt():0; + gfd=gr.getField(GEO_DB_RENDERGROUP_IS_BILLBOARD); + bool isbillb = gfd ? gfd->getBool() : false; Geode *nug; if (isbillb) { Billboard *bilb= new Billboard ; bilb->setAxis(Vec3(0,0,1)); - bilb->setNormal(Vec3(0,1,0)); + bilb->setNormal(Vec3(0,-1,0)); nug=bilb; } else { nug=new Geode; } - gfd=gr->getField(GEO_DB_RENDERGROUP_NAME); + gfd=gr.getField(GEO_DB_RENDERGROUP_NAME); if (gfd) { nug->setName(gfd->getChar()); } - makeGeometry((*gr),imat,nug); + makeGeometry(gr,imat,nug); return nug; } osg::Group *makePage(const georecord *gr) @@ -1169,20 +1185,21 @@ class ReaderWriterGEO : public ReaderWriter } return gp; } - osg::Group *makeSwitch(const georecord *gr) { + osg::Group *makeSwitch(const georecord *gr) + { osg::Switch *sw=new Switch; const geoField *gfd=gr->getField(GEO_DB_SWITCH_CURRENT_MASK); sw->setAllChildrenOff(); if (gfd) { - int imask; // bit surprised this isn't a uint.. Robert Dec 2002. + int imask; + imask=gfd->getInt(); - - // will set all 32 bits of the mask into the switch right now, - // should cap to only set the number of children in the switch. + + // set the bits in the osg::Switch. int selector_mask = 0x1; - for(unsigned int i=0;i<32;++i) + for(int pos=0;pos<32;++pos) { - sw->setValue(i,(imask&selector_mask)); + sw->setValue(pos,imask&selector_mask); selector_mask <<= 1; } osg::notify(osg::WARN) << gr << " imask " << imask << std::endl; @@ -1196,6 +1213,7 @@ class ReaderWriterGEO : public ReaderWriter } return sw; } + osg::Sequence *makeSequence(const georecord *gr) { Sequence *sq=new Sequence; @@ -1221,14 +1239,25 @@ class ReaderWriterGEO : public ReaderWriter } geoHeader *makeHeader(const georecord *gr) { // the header contains variables as well as a transform for the XYZup cases - theHeader=new geoHeader(); - const geoField *gfd=gr->getField(GEO_DB_HDR_UP_AXIS); + const geoField *gfd; + theHeader=new geoHeaderGeo(); + if (cpalrec) { // global - attach to geoheader + gfd=cpalrec->getField(GEO_DB_COLOR_PALETTE_HIGHEST_INTENSITIES); + if (gfd) { + unsigned char *cpal=gfd->getstore(0); + for (uint i=1; igetNum(); i++) { + theHeader->addColour(cpal); + cpal+=4; + } + } + } + gfd=gr->getField(GEO_DB_HDR_UP_AXIS); osg::Quat q; - unsigned iup=gfd ? gfd->getUInt() : GEO_DB_UP_AXIS_Y; + int iup=gfd ? gfd->getInt() : GEO_DB_UP_AXIS_Y; switch (iup) { case GEO_DB_UP_AXIS_X: - q.set(1,0,1,0); + q.set(0,1,0,1); q/=q.length(); theHeader->setAttitude(q); break; @@ -1239,12 +1268,13 @@ class ReaderWriterGEO : public ReaderWriter theHeader->setAttitude(q); break; case GEO_DB_UP_AXIS_Z: // no change - q.set(1,0,0,0); + q.set(0,0,0,1); q/=q.length(); theHeader->setAttitude(q); break; } - for (std::vector::const_iterator itr=geotxlist.begin(); itr::const_iterator itr; + for (itr=geotxlist.begin(); itrbhv=gr->getBehaviour(); @@ -1263,6 +1293,11 @@ class ReaderWriterGEO : public ReaderWriter } theHeader->setAppCallback(new geoHeaderCB); } + for (itr=geomatlist.begin(); itr< geomatlist.end(); itr++) { + osg::Material *mt=new osg::Material; + (*itr)->setMaterial(mt); + matlist.push_back(mt); + } return theHeader; } void makeTexture(const georecord *gr) { @@ -1347,7 +1382,7 @@ class ReaderWriterGEO : public ReaderWriter MatrixTransform *makeBehave(const georecord *gr) { MatrixTransform *mtr=NULL; - bool ok=false; // true if the matrix transform is a matrix transform + bool ok=false; // true if the matrix transform is required std::vector< georecord *>bhv=gr->getBehaviour(); if (!bhv.empty()) { // then add a DCS/matrix_transform mtr=new MatrixTransform; @@ -1358,44 +1393,143 @@ class ReaderWriterGEO : public ReaderWriter rcitr!=bhv.end(); ++rcitr) { - if ((*rcitr)->getType()==DB_DSK_BEHAVIOR) { + switch ((*rcitr)->getType()) { + case DB_DSK_BEHAVIOR: { const geoField *gfd=(*rcitr)->getField(GEO_DB_BEHAVIOR_NAME); if (gfd) { mtr->setName(gfd->getChar()); } - } - if ((*rcitr)->getType()==DB_DSK_ROTATE_ACTION) { + } + break; + case DB_DSK_ROTATE_ACTION: { geoMoveBehaviour *cb= new geoMoveBehaviour; ok=cb->makeBehave((*rcitr), theHeader,DB_DSK_ROTATE_ACTION); if (ok) gcb->addBehaviour(cb); else delete cb; - } - if ((*rcitr)->getType()==DB_DSK_TRANSLATE_ACTION) { + } + break; + + case DB_DSK_SCALE_ACTION: { + geoMoveBehaviour *sb=new geoMoveBehaviour; + ok=sb->makeBehave((*rcitr), theHeader,DB_DSK_SCALE_ACTION); + if (ok) gcb->addBehaviour(sb); + else delete sb; + } + break; + case DB_DSK_TRANSLATE_ACTION: { geoMoveBehaviour *cb= new geoMoveBehaviour; ok=cb->makeBehave((*rcitr), theHeader,DB_DSK_TRANSLATE_ACTION); if (ok) gcb->addBehaviour(cb); else delete cb; - } - if ((*rcitr)->getType()==DB_DSK_ARITHMETIC_ACTION) { + } + break; + + case DB_DSK_COMPARE_ACTION: { + geoCompareBehaviour *cb=new geoCompareBehaviour; + ok=cb->makeBehave((*rcitr), theHeader); + if (ok) gcb->addBehaviour(cb); + else delete cb; + } + break; + case DB_DSK_ARITHMETIC_ACTION: { geoArithBehaviour *cb=new geoArithBehaviour; ok=cb->makeBehave((*rcitr), theHeader); if (ok) gcb->addBehaviour(cb); else delete cb; - } - if ((*rcitr)->getType()==DB_DSK_CLAMP_ACTION) { + } + break; + case DB_DSK_CLAMP_ACTION: { geoClampBehaviour *cb=new geoClampBehaviour; ok=cb->makeBehave((*rcitr), theHeader); if (ok) gcb->addBehaviour(cb); else delete cb; - } - if ((*rcitr)->getType()==DB_DSK_RANGE_ACTION) { + } + break; + case DB_DSK_RANGE_ACTION: { geoRangeBehaviour *cb=new geoRangeBehaviour; ok=cb->makeBehave((*rcitr), theHeader); if (ok) gcb->addBehaviour(cb); else delete cb; - } - if ((*rcitr)->getType()==DB_DSK_STRING_CONTENT_ACTION) { - ok=false; + } + break; + case DB_DSK_VISIBILITY_ACTION: { + geoVisibBehaviour *vb = new geoVisibBehaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_VISIBILITY_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + // ar3 types + case DB_DSK_TRIG_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_TRIG_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_INVERSE_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_INVERSE_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_LINEAR_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_LINEAR_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_PERIODIC_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_PERIODIC_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_PERIODIC2_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_PERIODIC2_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_TRUNCATE_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_TRUNCATE_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + case DB_DSK_ABS_ACTION: { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_ABS_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; + /* + case DB_DSK_DCS_ACTION: */ + case DB_DSK_DISCRETE_ACTION: { + geoDiscreteBehaviour *db = new geoDiscreteBehaviour; + ok=db->makeBehave((*rcitr), theHeader); + if (ok) gcb->addBehaviour(db); + else delete db; + } + break; + case DB_DSK_STRING_CONTENT_ACTION: {// cant be shared with this + // ok=false; can be a mixed action, rotate & string content + } + break; + case DB_DSK_IF_THEN_ELSE_ACTION: + { + geoAr3Behaviour *vb = new geoAr3Behaviour; + ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_IF_THEN_ELSE_ACTION); + if (ok) gcb->addBehaviour(vb); + else delete vb; + } + break; } } } @@ -1408,21 +1542,23 @@ class ReaderWriterGEO : public ReaderWriter // recursive traversal of records and extract osg::Nodes equivalent Group *geodeholder=NULL; std::vector nodelist; - // fout.moveIn(); // increase indent if (gr.size()>0) { for (std::vector::const_iterator itr=gr.begin(); itr!=gr.end(); ++itr) { const georecord *gr=*itr; - MatrixTransform *mtr=makeBehave(gr); - //fout.indent() << (*gr) << std::endl; + Group *mtr=makeBehave(gr); if (gr->getType()== DB_DSK_GEODE) { // geodes can require >1 geometry for example if polygons have different texture indices. - Geode *geode=makeGeode(gr); // geode of geometrys + // and for example if the node has a colour or other fine behaviour + Geode *geode=makeGeode(*gr); // geode of geometrys + Group *animatedGeodes= makeAnimatedGeodes(gr); + Group *lightptGeodes= makeLightPointGeodes(gr); Group *textgeode=makeTextGeode(gr); // group of matrices & texts - outputGeode((*gr)); if (mtr) { if (geode) mtr->addChild(geode); + if (animatedGeodes) mtr->addChild(animatedGeodes); + if (lightptGeodes) mtr->addChild(lightptGeodes); if (textgeode) mtr->addChild(textgeode); nodelist.push_back(mtr); mtr=NULL; @@ -1431,6 +1567,8 @@ class ReaderWriterGEO : public ReaderWriter geodeholder=new osg::Group; } if (geode) geodeholder->addChild(geode); + if (animatedGeodes) geodeholder->addChild(animatedGeodes); + if (lightptGeodes) geodeholder->addChild(lightptGeodes); if (textgeode) geodeholder->addChild(textgeode); } } else { @@ -1439,20 +1577,7 @@ class ReaderWriterGEO : public ReaderWriter switch (gr->getType()) { case DB_DSK_HEADER: holder=makeHeader(gr); - /*{ - for (std::vector::const_iterator itr=color_palette.begin(); - itr!=color_palette.end(); - ++itr) { - fout << (*itr) << std::endl; - } - } */ - - break; - case DB_DSK_MATERIAL: { - osg::Material *mt=new osg::Material; - gr->setMaterial(mt); - matlist.push_back(mt); - } + (*itr)->setNode(holder); break; case DB_DSK_TEXTURE: makeTexture(gr); @@ -1463,18 +1588,23 @@ class ReaderWriterGEO : public ReaderWriter mtr->addChild(holder); holder=mtr; } + (*itr)->setNode(holder); break; case DB_DSK_LOD: holder=makeLOD(gr); + (*itr)->setNode(holder); break; case DB_DSK_SEQUENCE: holder=makeSequence(gr); + (*itr)->setNode(holder); break; case DB_DSK_SWITCH: holder=makeSwitch(gr); + (*itr)->setNode(holder); break; case DB_DSK_CUBE: holder=new Group; + (*itr)->setNode(holder); gfd=gr->getField(GEO_DB_GRP_NAME); if (gfd) { holder->setName(gfd->getChar()); @@ -1482,6 +1612,7 @@ class ReaderWriterGEO : public ReaderWriter break; case DB_DSK_SPHERE: holder=new Group; + (*itr)->setNode(holder); gfd=gr->getField(GEO_DB_GRP_NAME); if (gfd) { holder->setName(gfd->getChar()); @@ -1489,6 +1620,7 @@ class ReaderWriterGEO : public ReaderWriter break; case DB_DSK_CONE: holder=new Group; + (*itr)->setNode(holder); gfd=gr->getField(GEO_DB_GRP_NAME); if (gfd) { holder->setName(gfd->getChar()); @@ -1496,20 +1628,43 @@ class ReaderWriterGEO : public ReaderWriter break; case DB_DSK_CYLINDER: holder=new Group; + (*itr)->setNode(holder); gfd=gr->getField(GEO_DB_GRP_NAME); if (gfd) { holder->setName(gfd->getChar()); } break; case DB_DSK_INSTANCE: - holder=new Group; - /*gfd=gr->getField(GEO_DB_GRP_NAME); - if (gfd) { - holder->setName(gfd->getChar()); - } */ + { + MatrixTransform *mtr=new MatrixTransform; + gfd=gr->getField(GEO_DB_INSTANCE_NAME); + if (gfd) { + mtr->setName(gfd->getChar()); + } + gfd=gr->getField(GEO_DB_INSTANCE_TRANSFORM); + if (gfd) { + float *fmat=gfd->getMat44Arr(); + mtr->setMatrix(Matrix(fmat)); + } + gfd=gr->getField(GEO_DB_INSTANCE_DEF); + if (gfd) { // get the fID of a node + uint fid=gfd->getUInt(); + georecord *grec=getInstance(fid); + if (grec) { + osg::Node *nd=grec->getNode(); + if (nd) { // node already loaded, so instance + mtr->addChild(nd); + holder=mtr; + } else { // store unsatisfied instance matrix in georecord... + grec->addInstance(mtr); + } + } + } + } break; case DB_DSK_PAGE: holder=makePage(gr); + (*itr)->setNode(holder); break; case DB_DSK_FLOAT_VAR: case DB_DSK_INT_VAR: @@ -1519,16 +1674,10 @@ class ReaderWriterGEO : public ReaderWriter case DB_DSK_FLOAT2_VAR: case DB_DSK_FLOAT3_VAR: case DB_DSK_FLOAT4_VAR: - // fout.indent() << "AVars " << gr->getType() << std::endl; - // fout.indent() << (*gr) << std::endl; - break; case DB_DSK_INTERNAL_VARS: case DB_DSK_LOCAL_VARS: case DB_DSK_EXTERNAL_VARS: - // fout.indent() << "==Vars " << gr->getType() << std::endl; - // fout.indent() << (*gr) << std::endl; - break; - case DB_DSK_CLAMP_ACTION: + case DB_DSK_CLAMP_ACTION: case DB_DSK_RANGE_ACTION: case DB_DSK_ROTATE_ACTION: case DB_DSK_TRANSLATE_ACTION: @@ -1540,17 +1689,14 @@ class ReaderWriterGEO : public ReaderWriter case DB_DSK_COMPARE_ACTION: case DB_DSK_VISIBILITY_ACTION: case DB_DSK_STRING_CONTENT_ACTION: - holder=new Group; - // fout.indent() << "==Poorly handled option " << gr->getType() << std::endl; - // fout.indent() << (*gr) << std::endl; - break; default: { osg::Group *gp=new Group; + std::cout << "Unhandled item " << gr->getType() << std::endl; + std::cout << "Unhandled item " << (*itr) << std::endl; holder=gp; } break; } - // fout.indent() << (*gr) << std::endl; if (holder) nodelist.push_back(holder); std::vector child=makeosg((*itr)->getchildren()); @@ -1562,20 +1708,29 @@ class ReaderWriterGEO : public ReaderWriter } } } - if (geodeholder) nodelist.push_back(geodeholder); - //fout.moveOut(); // decrease indent + if (geodeholder) { + osgUtil::Tesselator tesselator; + for(unsigned int ige=0;igegetNumChildren();++ige) { + osg::Geode *geode=dynamic_cast(geodeholder->getChild(ige)); + if (geode) { + for(unsigned int i=0;igetNumDrawables();++i) + { + osg::Geometry* geom = dynamic_cast(geode->getDrawable(i)); + if (geom) tesselator.retesselatePolygons(*geom); + } + } + } + nodelist.push_back(geodeholder); + } return nodelist; } void output(osgDB::Output &fout,std::vector gr) { // debugging - print the tree of records - // static int depth=0; - // depth++; fout.moveIn(); if (gr.size()>0) { for (std::vector::iterator itr=gr.begin(); itr!=gr.end(); ++itr) { - // osg::notify(osg::WARN) fout.indent() << "Node type " << (*itr)->getType() << " "; fout.indent() << (**itr) << std::endl; fout.indent() << std::endl; @@ -1583,20 +1738,63 @@ class ReaderWriterGEO : public ReaderWriter } } fout.moveOut(); - // depth--; + } + georecord *getInstance(uint fid) { // find record with instance fid + for (geoRecordList::iterator itr=recs.begin(); + itr!=recs.end(); + ++itr) { + const geoField *gfd; + switch ((*itr).getType()) { + case DB_DSK_GROUP: + gfd=(*itr).getField(GEO_DB_GRP_INSTANCE_DEF); + if (gfd) { + uint fidnod=gfd->getUInt(); + if (fidnod==fid) return &(*itr); + } + break; + case DB_DSK_LOD: + gfd=(*itr).getField(GEO_DB_LOD_INSTANCE_DEF); + if (gfd) { + uint fidnod=gfd->getUInt(); + if (fidnod==fid) return &(*itr); + } + break; + case DB_DSK_SEQUENCE: + gfd=(*itr).getField(GEO_DB_SEQUENCE_INSTANCE_DEF); + if (gfd) { + uint fidnod=gfd->getUInt(); + if (fidnod==fid) return &(*itr); + } + break; + case DB_DSK_SWITCH: + gfd=(*itr).getField(GEO_DB_SWITCH_INSTANCE_DEF); + if (gfd) { + uint fidnod=gfd->getUInt(); + if (fidnod==fid) return &(*itr); + } + break; + case DB_DSK_GEODE: + gfd=(*itr).getField(GEO_DB_RENDERGROUP_INSTANCE_DEF); + if (gfd) { + uint fidnod=gfd->getUInt(); + if (fidnod==fid) return &(*itr); + } + break; + } + } + return NULL; } private: -// std::fstream fout; // debug output + geoRecordList recs; // the records read from file std::vector coord_pool; // current vertex ooords std::vector normal_pool; // current pool of normal vectors - //static unsigned char * - std::vector color_palette; - geoHeader *theHeader; // has animation vars etc + geoHeaderGeo *theHeader; // has animation vars etc std::vector geotxlist; // list of geo::textures for this model std::vector geomatlist; // list of geo::materials for this model std::vector txlist; // list of osg::textures for this model std::vector txenvlist; // list of texture environments for the textures std::vector matlist; // list of materials for current model + georecord *cpalrec; // colour palette record }; //======= @@ -1626,8 +1824,10 @@ void userVars::addUserVar(const georecord &gr) { nm->setName(name); gfd= gr.getField(GEO_DB_FLOAT_VAR_VALUE); - //float fval=gfd ? gfd->getFloat():0.0f; + nm->setVal(gfd ? gfd->getFloat():0.0f); + gfd= gr.getField(GEO_DB_FLOAT_VAR_DEFAULT); + //nm->setdefault(gfd ? gfd->getFloat():0.0f); //float fdef=gfd ? gfd->getFloat():0.0f; gfd= gr.getField(GEO_DB_FLOAT_VAR_CONSTRAINED); @@ -1647,8 +1847,9 @@ void userVars::addUserVar(const georecord &gr) { vars.push_back(*nm); } } + void internalVars::update(osg::Timer &_timer,osg::FrameStamp &_frameStamp) { - double time=_frameStamp.getReferenceTime(); + double stmptime=_frameStamp.getReferenceTime(); osg::Timer_t _frameTick = _timer.tick();; int iord=0; for (std::vector::const_iterator itr=vars.begin(); //gfl.begin(); @@ -1661,19 +1862,31 @@ void internalVars::update(osg::Timer &_timer,osg::FrameStamp &_frameStamp) { vars[iord].setVal((float)_frameStamp.getFrameNumber()); break; case GEO_DB_INTERNAL_VAR_CURRENT_TIME: - vars[iord].setVal(_timer.delta_s(0,_frameTick)); + { + static double timestart=-1; + if (timestart<0) { + time_t long_time; + struct tm *newtime; + + long_time=time( NULL ); // * Get time as long integer. + newtime = localtime( &long_time ); // * Convert to local time. + timestart=newtime->tm_hour*3600 +newtime->tm_min*60+ newtime->tm_sec; + } + double timeofday=timestart+_frameStamp.getReferenceTime(); + vars[iord].setVal(timeofday); + } break; case GEO_DB_INTERNAL_VAR_ELAPSED_TIME: vars[iord].setVal(_frameStamp.getReferenceTime()); break; case GEO_DB_INTERNAL_VAR_SINE: - vars[iord].setVal(sin(time)); + vars[iord].setVal(sin(stmptime)); break; case GEO_DB_INTERNAL_VAR_COSINE: - vars[iord].setVal(cos(time)); + vars[iord].setVal(cos(stmptime)); break; case GEO_DB_INTERNAL_VAR_TANGENT: - vars[iord].setVal(tan(time)); + vars[iord].setVal(tan(stmptime)); break; case GEO_DB_INTERNAL_VAR_MOUSE_X: // this is all windowing system dependent // vars[iord]=_frameStamp.getReferenceTime(); diff --git a/src/osgPlugins/geo/geoActions.cpp b/src/osgPlugins/geo/geoActions.cpp new file mode 100644 index 000000000..c93bb89be --- /dev/null +++ b/src/osgPlugins/geo/geoActions.cpp @@ -0,0 +1,676 @@ +// GEO format (carbon graphics Inc) loader for the OSG real time scene graph +// www.carbongraphics.com for more information about the Geo animation+ modeller +// 2002 +// actions & behaviours for Geo loader in OSG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// specific to GEO + +#include "geoFormat.h" +#include "geoTypes.h" +#include "geoUnits.h" +#include "osgGeoAnimation.h" +#include "osgGeoStructs.h" +#include "osgGeoNodes.h" +#include "osgGeoAction.h" +#include // needed for text nodes +#include + + +void geoArithBehaviour::setType(uint iop) { + switch (iop) { + case 1: op=addv; break; /* op=addv; addv is a function so the operation can be accessed without a switch(type)... */ + case 2: op=subv; break; + case 3: op=mulv; break; + case 4: op=divv; break; + case 5: op=equa; break; + } +} +void geoArithBehaviour::doaction(void) const { // do math operation + if (in && out && op) { + (*out)=op(*in,acon.get()); + // std::cout << " math sum " << out<< " " << (*out) << " " << in <<" " << (*in) << std::endl; + } +} +bool geoArithBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + //std::cout<< "Input " << fid << " : " << theHeader->getVarname(fid) ; + if (in) { + gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + //std::cout<< " Output " << fid << " : " << theHeader->getVarname(fid) << std::endl; + gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OP_TYPE); + uint iop=gfd?gfd->getUInt():1; + setType(iop); // default add? + gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE); + if (gfd) { + acon.set(gfd->getFloat()); // field identifier + ok=true; + } + gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + ok=acon.set(theHeader->getVar(fid)); + } + } + } + } + return ok; +} + +void geoAr3Behaviour::setType(uint iact) { + switch (iact) { + case DB_DSK_LINEAR_ACTION: op=linear; break; /* op=addv; */ + case DB_DSK_INVERSE_ACTION: op=lininv; break; + // case 3: op=linmod; break; + // case 4: op=linsqr; break; + case DB_DSK_TRUNCATE_ACTION: op=trunc; break; + case DB_DSK_PERIODIC_ACTION: op=linabs; break; + case DB_DSK_IF_THEN_ELSE_ACTION: op=ifelse; break; + } +} +void geoAr3Behaviour::setTrigType(int iop) { + switch (iop) { + case 1: op=trigsin; break; /* op=trigonometric, sine; */ + case 2: op=trigcos; break; + case 3: op=trigtan; break; + case 4: op=trigasin; break; + case 5: op=trigacos; break; + case 6: op=trigatan; break; + case 7: op=trigatan2; break; + case 8: op=trighypot; break; + } +} +void geoAr3Behaviour::setPeriodicType(int iop) { + switch (iop) { + case 1: op=period_1; break; /* op=period type 1; */ + case 2: op=period_2; break; + } +} + +void geoAr3Behaviour::doaction(void) { // do math operation + if (in && out && op) { + double var3=bcon.get(); + *out=op(*in,getconstant(),var3); + //std::cout << " ar3 sum " << out<< " " << (*out) << " con " << getconstant() <<" b: " << bcon.get() << std::endl; + } +} +bool geoAr3Behaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_EQUATION_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + if (in) { + gfd=grec->getField(GEO_DB_EQUATION_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + if (act==DB_DSK_TRIG_ACTION) { + gfd=grec->getField(GEO_DB_TRIG_ACTION_OP); + int iop=gfd?gfd->getInt():1; + setTrigType(iop); // one of sin... + } else if (act==DB_DSK_PERIODIC_ACTION) { + gfd=grec->getField(GEO_DB_PERIODIC_ACTION_TYPE); + int iop=gfd?gfd->getInt():1; // type 1 or 2 periodic + setPeriodicType(iop); // one of period 1 or 2... + } else if (act==DB_DSK_IF_THEN_ELSE_ACTION) { + setType(act); // if..else if (a is in range (-1,1) =b else=c + } else { + setType(act); // default linear, inverse, mod.. a.b+c + setConstant(1); + ok=true; + } + gfd=grec->getField(GEO_DB_EQUATION_ACTION_A_VAL); + if (gfd) { + setConstant(gfd->getFloat()); // field identifier + ok=true; + } + gfd=grec->getField(GEO_DB_EQUATION_ACTION_A_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + ok=setVariable(theHeader->getVar(fid)); + } + gfd=grec->getField(GEO_DB_EQUATION_ACTION_C_VAL); + if (gfd) { + bcon.set(gfd->getFloat()); // field identifier + ok=true; + } + gfd=grec->getField(GEO_DB_EQUATION_ACTION_C_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + ok=bcon.set(theHeader->getVar(fid)); + } + } + } + } + return ok; +} + +void geoCompareBehaviour::setType(uint iop) { + switch (iop) { + case 1: oper=LESS;break; + case 2: oper=LESSOREQ; break; + case 3: oper=GREATER; break; + case 4: oper=GREATOREQ; break; + case 5: oper=EQUALTO; break; + } +} + +void geoCompareBehaviour::doaction(void) const { // do compare operation + if (in && out) { + double var2=varop? *varop : constant; + switch (oper) { + case 1: oper; *out = (*in < var2) ? 1.0: -1.0; break;// Less + case 2: oper; *out = (*in <= var2) ? 1.0: -1.0; break;//=LessOREQ + case 3: oper; *out = (*in > var2) ? 1.0: -1.0; break; // greater... + case 4: oper; *out = (*in >= var2) ? 1.0: -1.0; break; + case 5: oper; *out = (*in == var2) ? 1.0: -1.0; break; + case UNKNOWN: break; + } + } +} +bool geoCompareBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_COMPARE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + if (in) { + gfd=grec->getField(GEO_DB_COMPARE_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + gfd=grec->getField(GEO_DB_COMPARE_ACTION_OP_TYPE); + uint iop=gfd?gfd->getUInt():1; + setType(iop); // default add? + gfd=grec->getField(GEO_DB_COMPARE_ACTION_OPERAND_VALUE); + if (gfd) { + constant= gfd->getFloat(); // field identifier + ok=true; + } + gfd=grec->getField(GEO_DB_COMPARE_ACTION_OPERAND_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + varop=theHeader->getVar(fid); + ok=varop != NULL; + } + } + } + } + return ok; +} + +void geoRangeBehaviour::doaction(void) const { // do math operation + if (in && out) { + float v=*in; + if (vinmax) v=inmax; + v=(v-inmin)/(inmax-inmin); + *out = outmin+v*(outmax-outmin); + } +} +bool geoRangeBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_RANGE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + if (in) { + gfd=grec->getField(GEO_DB_RANGE_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + gfd=grec->getField(GEO_DB_RANGE_ACTION_IN_MIN_VAL); + inmin=gfd?gfd->getFloat():-1.e32; + gfd=grec->getField(GEO_DB_RANGE_ACTION_IN_MAX_VAL); + inmax= gfd?gfd->getFloat() : 1.e32; // field identifier + gfd=grec->getField(GEO_DB_RANGE_ACTION_OUT_MIN_VAL); + outmin=gfd?gfd->getFloat():-1.e32; + gfd=grec->getField(GEO_DB_RANGE_ACTION_OUT_MAX_VAL); + outmax= gfd?gfd->getFloat() : 1.e32; // field identifier + ok=true; + } + } + } + return ok; +} + +void geoClampBehaviour::doaction(void) const { // do math operation + if (in && out) { + float v=*in; + if (vmax) v=max; + *out = v; + } +} +bool geoClampBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_CLAMP_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + if (in) { + gfd=grec->getField(GEO_DB_CLAMP_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + gfd=grec->getField(GEO_DB_CLAMP_ACTION_MIN_VAL); + min=gfd?gfd->getFloat():-1.e32; + gfd=grec->getField(GEO_DB_CLAMP_ACTION_MAX_VAL); + max= gfd?gfd->getFloat() : 1.e32; // field identifier + ok=true; + } + } + } + return ok; +} + +void geoDiscreteBehaviour::doaction(void) const { // do math operation + if (in && out) { + float v=*in; + *out=rangelist.begin()->getVal(); + for (std::vector::const_iterator itr=rangelist.begin(); + itr=itr->getMin() && v<=itr->getMax()) *out=itr->getVal(); + } + } +} +bool geoDiscreteBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_DISCRETE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + in=theHeader->getVar(fid); // returns address of input var with fid + if (in) { + gfd=grec->getField(GEO_DB_DISCRETE_ACTION_OUTPUT_VAR); + if (gfd) { + fid= gfd->getUInt(); // field identifier + out=theHeader->getVar(fid); // returns address of output var with fid + gfd=grec->getField(GEO_DB_DISCRETE_ACTION_NUM_ITEMS); + uint nr=gfd?gfd->getUInt():1; + uint i; + for (i=0; igetField(GEO_DB_DISCRETE_ACTION_MIN_VALS); + const geoField *gfdmax=grec->getField(GEO_DB_DISCRETE_ACTION_MAX_VALS); + const geoField *gfdval=grec->getField(GEO_DB_DISCRETE_ACTION_MAP_VALS); + if (gfdmin) { + float *fmin=gfdmin->getFloatArr(); + float *fmax=gfdmax->getFloatArr(); + float *fval=gfdval->getFloatArr(); + if (fmin && fmax && fval) { + for (i=0; i (node); + switch (getType()) { + case DB_DSK_SCALE_ACTION: + mtr->preMult( osg::Matrix::scale(axis*(getValue())) ); + break; + case DB_DSK_TRANSLATE_ACTION: + mtr->preMult( osg::Matrix::translate(axis*(getValue())) ); + break; + case DB_DSK_ROTATE_ACTION: + //std::cout << node->getName() << " v: " << getVar() << " rotion " << DEG2RAD(getValue()) << std::endl; + mtr->preMult( osg::Matrix::translate(-centre)* + osg::Matrix::rotate(DEG2RAD(getValue()),axis)* + osg::Matrix::translate(centre)); + break; + } + } +} + +bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act) { + bool ok=false; + setType(act); + if (act==DB_DSK_ROTATE_ACTION) { + const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + double *vcon=theHeader->getVar(fid); // returns address of var with fid + if (vcon) { + // std::cout<< "rotInput " << fid << " : " << theHeader->getVarname(fid)<< std::endl ; + setVar(vcon); + gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR); + if (gfd) { + float *ax= gfd->getVec3Arr(); // field identifier + setAxis(osg::Vec3(ax[0],ax[1],ax[2])); + } + gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN); + if (gfd) { + float *ct= gfd->getVec3Arr(); // field identifier + setCentre(osg::Vec3(ct[0],ct[1],ct[2])); + } + ok=true; + } + } + } else if (act==DB_DSK_TRANSLATE_ACTION) { + const geoField *gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + double *vcon=theHeader->getVar(fid); // returns address of var with fid + if (vcon) { + setVar(vcon); + gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR); + if (gfd) { + float *ax= gfd->getVec3Arr(); // field identifier + setAxis(osg::Vec3(ax[0],ax[1],ax[2])); + } + gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN); + if (gfd) { + float *ct= gfd->getVec3Arr(); // field identifier + setCentre(osg::Vec3(ct[0],ct[1],ct[2])); + } + ok=true; + } + } + } else if (act==DB_DSK_SCALE_ACTION) { // Nov 2002 not yet implemented in the modeller! + } + return ok; +} +void geoMoveVertexBehaviour::doaction(Matrix &mtr,osg::Drawable *dr) { + // update the matrix mtr + if (getVar()) { + switch (getType()) { + case DB_DSK_SCALE_ACTION: + mtr = mtr*osg::Matrix::scale(movb.getAxis()*(getValue())) ; + break; + case DB_DSK_TRANSLATE_ACTION: + mtr = mtr*osg::Matrix::translate(movb.getAxis()*(getValue())) ; + break; + case DB_DSK_ROTATE_ACTION: + //std::cout << dr->getName() << " v: " << getVar() << " rotion " << DEG2RAD(getValue()) << std::endl; + mtr = mtr*osg::Matrix::translate(-movb.getCentre())* + osg::Matrix::rotate(DEG2RAD(getValue()),movb.getAxis())* + osg::Matrix::translate(movb.getCentre()); + break; + } + } +} + +bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act) { + bool ok=false; + setType(act); + if (act==DB_DSK_ROTATE_ACTION) { + const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + double *vcon=theHeader->getVar(fid); // returns address of var with fid + if (vcon) { + // std::cout<< "rotInput " << fid << " : " << theHeader->getVarname(fid)<< std::endl ; + setVar(vcon); + gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR); + if (gfd) { + float *ax= gfd->getVec3Arr(); // field identifier + movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2])); + } + gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN); + if (gfd) { + float *ct= gfd->getVec3Arr(); // field identifier + movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2])); + } + ok=true; + } + } + } else if (act==DB_DSK_TRANSLATE_ACTION) { + const geoField *gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + double *vcon=theHeader->getVar(fid); // returns address of var with fid + if (vcon) { + setVar(vcon); + gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR); + if (gfd) { + float *ax= gfd->getVec3Arr(); // field identifier + movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2])); + } + gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN); + if (gfd) { + float *ct= gfd->getVec3Arr(); // field identifier + movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2])); + } + ok=true; + } + } + } else if (act==DB_DSK_SCALE_ACTION) { // Nov 2002 not yet implemented in the modeller! + } + return ok; +} + +bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) { + bool ok=false; + const geoField *gfd= grec->getField(GEO_DB_VISIBILITY_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + setVar(theHeader->getVar(fid)); // returns address of input var with fid + ok=true; // all data supplied + } + return ok; +} +void geoVisibBehaviour::doaction(osg::Node *node) const +{ // do visibility operation on Node + if (getVar()) { + if (getValue() <0.0) { + node->setNodeMask(0x0); // invisible + } else { + node->setNodeMask(0xffffffff); // visible + } + } +} + +bool geoColourBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd= grec->getField(GEO_DB_COLOR_RAMP_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + setVar(theHeader->getVar(fid)); // returns address of input var with fid + gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_COLOR_FROM_PALETTE); + if (gfd) {} + gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR_INDEX); + topcindx=(gfd? gfd->getUInt():4096); + gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR_INDEX); + botcindx=(gfd? gfd->getUInt():0); + //also available: GEO_DB_COLOR_RAMP_ACTION_MATCH_COLUMNS + ok=true; // all data supplied + } + return ok; +} +void geoColourBehaviour::doaction(osg::Drawable *dr) const +{ // do visibility operation on Node + if (getVar()) { + uint idx=getValue(); + osg::Geometry *gm=dynamic_cast(dr); + if (gm) { + osg::Vec4Array* cla = dynamic_cast(gm->getColorArray()); + if (cla) { // traps a colour behaviour added when using material for colour. + for (uint i=nstart; i<(nend); i++) { + unsigned char col[4]; + uint idxtop=idx/128; + (*colours)[idxtop].get(col); // from the colour palette + float frac=(float)(idx-idxtop*128)/128.0f; + (*cla)[i].set(col[0]*frac/255.0,col[1]*frac/255.0,col[2]*frac/255.0,1); + } + } + } + } +} + +void geoStrContentBehaviour::doaction(osg::Drawable *node) { // do new text + osgText::Text *txt=dynamic_cast(node); + char content[32]; + switch (vt) { + case INT: + sprintf(content, format, (int)getValue()); + break; + case FLOAT: + sprintf(content, format, (float)getValue()); + break; + case DOUBLE: + sprintf(content, format, getValue()); + break; + case CHAR: + sprintf(content, format, (char *)getVar()); + break; + default: + sprintf(content, format, (char *)getVar()); + } + txt->setText(std::string(content)); +} +bool geoStrContentBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) { + bool ok=false; + const geoField *gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR); + if (gfd) { + unsigned fid= gfd->getUInt(); // field identifier + setVar(theHeader->getVar(fid)); // returns address of input var with fid + if (getVar()) { + gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_FORMAT); + if (gfd) { + char *ch=gfd->getChar(); + format=new char[strlen(ch)+1]; + strcpy(format, ch); + { + char *ctmp=format; + while (*ctmp) { + if (*ctmp=='d') vt=INT; + if (*ctmp=='f' && vt!=DOUBLE) vt=FLOAT; + if (*ctmp=='l') vt=DOUBLE; + ctmp++; + } + } + gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE); + gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE); + ok=true; + } + } + } + return ok; +} + +void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv) +{ // callback updates the transform, colour, string content... + MatrixTransform *mtr=dynamic_cast (node); + if (mtr) mtr->setMatrix(Matrix::identity()); // all actions are multiplied to this + for (std::vector::const_iterator itr=gblist.begin(); + itr(*itr); + if (ab) ab->doaction(); + geoAr3Behaviour *a3=dynamic_cast(*itr); + if (a3) a3->doaction(); + geoClampBehaviour *cb=dynamic_cast(*itr); + if (cb) cb->doaction(); + geoRangeBehaviour *cr=dynamic_cast(*itr); + if (cr) cr->doaction(); + geoCompareBehaviour *cmb=dynamic_cast(*itr); + if (cmb) cmb->doaction(); + geoDiscreteBehaviour *db=dynamic_cast(*itr); + if (db) db->doaction(); + geoMoveBehaviour *mb=dynamic_cast(*itr); + if (mb) mb->doaction(node); + // or visibility.. + geoVisibBehaviour *vb=dynamic_cast(*itr); + if (vb) vb->doaction(node); + } + traverse(node,nv); +} + +void geoBehaviourDrawableCB::app(osg::NodeVisitor *,osg::Drawable *dr) { + Matrix mtr; + int prevvtr=-1; // previously moved vertex + Vec3 pos; + mtr.identity(); + std::vector::const_iterator itr; + for (itr=gblist.begin(); + itr(*itr); + if (ab) ab->doaction(); + geoAr3Behaviour *a3=dynamic_cast(*itr); + if (a3) a3->doaction(); + geoClampBehaviour *cb=dynamic_cast(*itr); + if (cb) cb->doaction(); + geoRangeBehaviour *cr=dynamic_cast(*itr); + if (cr) cr->doaction(); + geoStrContentBehaviour *sb=dynamic_cast(*itr); + if (sb) sb->doaction(dr); + // colorbehaviour may be for 1 or all vertices + geoColourBehaviour *clrb=dynamic_cast(*itr); + if (clrb) clrb->doaction(dr); + geoMoveVertexBehaviour *mvvb=dynamic_cast(*itr); + if (mvvb && (prevvtr<0 || prevvtr==mvvb->getindex())) { + mvvb->doaction(mtr,dr); + pos=mvvb->getpos(); + prevvtr=mvvb->getindex(); + } + } + osg::Geometry *gm=dynamic_cast(dr); + if (gm && prevvtr>=0) { + osg::Vec3Array* vtxa = dynamic_cast(gm->getVertexArray()); + bool newpos=false; + (*vtxa)[prevvtr]=pos*mtr; + do { // check for other vertices that may be animated + newpos=false; + mtr.identity(); + for (itr=gblist.begin(); + itr(*itr); + if (mvvb) { + int vidx=mvvb->getindex(); + if (mvvb && (prevvtrdoaction(mtr,dr); + prevvtr=vidx; + pos=mvvb->getpos(); + newpos=true; + } + } + } + if (newpos) { + osg::Vec3Array* vtxa = dynamic_cast(gm->getVertexArray()); + (*vtxa)[prevvtr]=pos*mtr; + } + } while (newpos); + } +} diff --git a/src/osgPlugins/geo/geoFormat.h b/src/osgPlugins/geo/geoFormat.h index b1965bb6f..c180140a2 100644 --- a/src/osgPlugins/geo/geoFormat.h +++ b/src/osgPlugins/geo/geoFormat.h @@ -1,15 +1,15 @@ /*===========================================================================*\ -NAME: geoFormat.h +NAME: geoFormat.h -DESCRIPTION: Native Format struct definitions, tokens & functionc +DESCRIPTION: Native Format struct definitions, tokens & functionc -AUTHOR: Andy Bushnell +AUTHOR: Andy Bushnell - ------------------------------------------------------------------------- + ------------------------------------------------------------------------- PROPRIETARY RIGHTS NOTICE: - + This software contains proprietary information and trade secrets of Carbon Graphics LLC. No part or all of this software may be reproduced in any form, without the written permission of Carbon Graphics LLC. @@ -37,8 +37,7 @@ COPYRIGHT NOTICE: #ifndef __GEO_FORMAT_H__ #define __GEO_FORMAT_H__ -//#include "geoCore.h" // cunningly not suplied by Carbon Graphics. - +//#include "geoCore.h" #define GEO_DB_API @@ -46,97 +45,106 @@ COPYRIGHT NOTICE: // // Constants to define the Node disk records. Used in RecordToken.id // -const unsigned int DB_DSK_HEADER = 101; -const unsigned int DB_DSK_GROUP = 102; -const unsigned int DB_DSK_BILLBOARD = 103; -const unsigned int DB_DSK_SEQUENCE = 104; -const unsigned int DB_DSK_LOD = 105; -const unsigned int DB_DSK_GEODE = 106; -const unsigned int DB_DSK_POLYGON = 107; -const unsigned int DB_DSK_MESH = 108; // Unused - Possible Future expansion -const unsigned int DB_DSK_CUBE = 109; // Unused - Possible Future expansion -const unsigned int DB_DSK_SPHERE = 110; // Unused - Possible Future expansion -const unsigned int DB_DSK_CONE = 111; // Unused - Possible Future expansion -const unsigned int DB_DSK_CYLINDER = 112; // Unused - Possible Future expansion -const unsigned int DB_DSK_VERTEX = 113; -const unsigned int DB_DSK_PUSH = 114; -const unsigned int DB_DSK_POP = 115; -const unsigned int DB_DSK_TEXTURE = 116; -const unsigned int DB_DSK_MATERIAL = 117; -const unsigned int DB_DSK_VIEW = 118; -const unsigned int DB_DSK_EXTENSION_LIST = 119; -const unsigned int DB_DSK_SWITCH = 120; -const unsigned int DB_DSK_TEXT = 121; -const unsigned int DB_DSK_BASE_GROUP = 122; -const unsigned int DB_DSK_BASE_SURFACE = 123; +const unsigned int DB_DSK_HEADER = 101; +const unsigned int DB_DSK_GROUP = 102; -const unsigned int DB_DSK_BEHAVIOR = 124; +const unsigned int DB_DSK_SEQUENCE = 104; +const unsigned int DB_DSK_LOD = 105; +const unsigned int DB_DSK_GEODE = 106; +const unsigned int DB_DSK_POLYGON = 107; +const unsigned int DB_DSK_MESH = 108; // Unused - Possible Future expansion +const unsigned int DB_DSK_CUBE = 109; // Unused - Possible Future expansion +const unsigned int DB_DSK_SPHERE = 110; // Unused - Possible Future expansion +const unsigned int DB_DSK_CONE = 111; // Unused - Possible Future expansion +const unsigned int DB_DSK_CYLINDER = 112; // Unused - Possible Future expansion +const unsigned int DB_DSK_VERTEX = 113; +const unsigned int DB_DSK_PUSH = 114; +const unsigned int DB_DSK_POP = 115; +const unsigned int DB_DSK_TEXTURE = 116; +const unsigned int DB_DSK_MATERIAL = 117; +const unsigned int DB_DSK_VIEW = 118; +const unsigned int DB_DSK_EXTENSION_LIST = 119; +const unsigned int DB_DSK_SWITCH = 120; +const unsigned int DB_DSK_TEXT = 121; +const unsigned int DB_DSK_BASE_GROUP = 122; +const unsigned int DB_DSK_BASE_SURFACE = 123; -const unsigned int DB_DSK_CLAMP_ACTION = 125; -const unsigned int DB_DSK_RANGE_ACTION = 126; -const unsigned int DB_DSK_ROTATE_ACTION = 127; -const unsigned int DB_DSK_TRANSLATE_ACTION = 128; -const unsigned int DB_DSK_SCALE_ACTION = 129; -const unsigned int DB_DSK_ARITHMETIC_ACTION = 130; -const unsigned int DB_DSK_LOGIC_ACTION = 131; -const unsigned int DB_DSK_CONDITIONAL_ACTION = 132; -const unsigned int DB_DSK_LOOPING_ACTION = 133; -const unsigned int DB_DSK_COMPARE_ACTION = 134; -const unsigned int DB_DSK_VISIBILITY_ACTION = 135; -const unsigned int DB_DSK_STRING_CONTENT_ACTION = 136; - -const unsigned int DB_DSK_INTERNAL_VARS = 137; -const unsigned int DB_DSK_LOCAL_VARS = 138; -const unsigned int DB_DSK_EXTERNAL_VARS = 139; - -const unsigned int DB_DSK_FLOAT_VAR = 140; -const unsigned int DB_DSK_INT_VAR = 141; -const unsigned int DB_DSK_LONG_VAR = 142; -const unsigned int DB_DSK_DOUBLE_VAR = 143; -const unsigned int DB_DSK_BOOL_VAR = 144; +const unsigned int DB_DSK_BEHAVIOR = 124; + +const unsigned int DB_DSK_CLAMP_ACTION = 125; +const unsigned int DB_DSK_RANGE_ACTION = 126; +const unsigned int DB_DSK_ROTATE_ACTION = 127; +const unsigned int DB_DSK_TRANSLATE_ACTION = 128; +const unsigned int DB_DSK_SCALE_ACTION = 129; +const unsigned int DB_DSK_ARITHMETIC_ACTION = 130; +const unsigned int DB_DSK_LOGIC_ACTION = 131; +const unsigned int DB_DSK_CONDITIONAL_ACTION = 132; +const unsigned int DB_DSK_LOOPING_ACTION = 133; +const unsigned int DB_DSK_COMPARE_ACTION = 134; +const unsigned int DB_DSK_VISIBILITY_ACTION = 135; +const unsigned int DB_DSK_STRING_CONTENT_ACTION = 136; + +const unsigned int DB_DSK_INTERNAL_VARS = 137; +const unsigned int DB_DSK_LOCAL_VARS = 138; +const unsigned int DB_DSK_EXTERNAL_VARS = 139; + +const unsigned int DB_DSK_FLOAT_VAR = 140; +const unsigned int DB_DSK_INT_VAR = 141; +const unsigned int DB_DSK_LONG_VAR = 142; +const unsigned int DB_DSK_DOUBLE_VAR = 143; +const unsigned int DB_DSK_BOOL_VAR = 144; -const unsigned int DB_DSK_CONDITIONAL_BEGIN_CHILDREN = 145; // complex nested action branch mechanism -const unsigned int DB_DSK_IF_CONDITION = 146; -const unsigned int DB_DSK_ELSE_CONDITION = 147; -const unsigned int DB_DSK_CONDITIONAL_END_CHILDREN = 148; +const unsigned int DB_DSK_CONDITIONAL_BEGIN_CHILDREN = 145; // complex nested action branch mechanism +const unsigned int DB_DSK_IF_CONDITION = 146; +const unsigned int DB_DSK_ELSE_CONDITION = 147; +const unsigned int DB_DSK_CONDITIONAL_END_CHILDREN = 148; -const unsigned int DB_DSK_COLOR_PALETTE = 149; -const unsigned int DB_DSK_COLOR_RAMP_ACTION = 150; +const unsigned int DB_DSK_COLOR_PALETTE = 149; +const unsigned int DB_DSK_COLOR_RAMP_ACTION = 150; -const unsigned int DB_DSK_FLOAT2_VAR = 151; -const unsigned int DB_DSK_FLOAT3_VAR = 152; -const unsigned int DB_DSK_FLOAT4_VAR = 153; - -const unsigned int DB_DSK_LINEAR_ACTION = 154; -const unsigned int DB_DSK_TASK_ACTION = 155; - -const unsigned int DB_DSK_PERIODIC_ACTION = 156; -const unsigned int DB_DSK_PERIODIC2_ACTION = 157; // Redundant record - Periodic supports types 1 & 2 -const unsigned int DB_DSK_TRIG_ACTION = 158; -const unsigned int DB_DSK_INVERSE_ACTION = 159; -const unsigned int DB_DSK_TRUNCATE_ACTION = 160; -const unsigned int DB_DSK_ABS_ACTION = 161; -const unsigned int DB_DSK_IF_THEN_ELSE_ACTION = 162; // simple variable value check +const unsigned int DB_DSK_FLOAT2_VAR = 151; +const unsigned int DB_DSK_FLOAT3_VAR = 152; +const unsigned int DB_DSK_FLOAT4_VAR = 153; + +const unsigned int DB_DSK_LINEAR_ACTION = 154; +const unsigned int DB_DSK_TASK_ACTION = 155; + +const unsigned int DB_DSK_PERIODIC_ACTION = 156; +const unsigned int DB_DSK_PERIODIC2_ACTION = 157; // Redundant record - Periodic supports types 1 & 2 +const unsigned int DB_DSK_TRIG_ACTION = 158; +const unsigned int DB_DSK_INVERSE_ACTION = 159; +const unsigned int DB_DSK_TRUNCATE_ACTION = 160; +const unsigned int DB_DSK_ABS_ACTION = 161; +const unsigned int DB_DSK_IF_THEN_ELSE_ACTION = 162; // simple variable value check -const unsigned int DB_DSK_DCS_ACTION = 163; +const unsigned int DB_DSK_DCS_ACTION = 163; -const unsigned int DB_DSK_INSTANCE = 164; +const unsigned int DB_DSK_INSTANCE = 164; -const unsigned int DB_DSK_COORD_POOL = 165; +const unsigned int DB_DSK_COORD_POOL = 165; -const unsigned int DB_DSK_LIGHTPT = 166; -const unsigned int DB_DSK_EXTERNAL = 167; +const unsigned int DB_DSK_LIGHTPT = 166; +const unsigned int DB_DSK_EXTERNAL = 167; -const unsigned int DB_DSK_NORMAL_POOL = 168; +const unsigned int DB_DSK_NORMAL_POOL = 168; -const unsigned int DB_DSK_DISCRETE_ACTION = 169; +const unsigned int DB_DSK_DISCRETE_ACTION = 169; -const unsigned int DB_DSK_STRING_VAR = 170; -const unsigned int DB_DSK_STRING_COPY_ACTION = 171; +const unsigned int DB_DSK_STRING_VAR = 170; +const unsigned int DB_DSK_STRING_COPY_ACTION = 171; -const unsigned int DB_DSK_PAGE = 172; - - +const unsigned int DB_DSK_PAGE = 172; + +const unsigned int DB_DSK_SQRT_ACTION = 173; +const unsigned int DB_DSK_LOG_ACTION = 174; + +const unsigned int DB_DSK_PLANE_TEXTURE_MAPPING_INFO = 175; +const unsigned int DB_DSK_CYLINDER_TEXTURE_MAPPING_INFO = 176; // not implemented in 1.0 +const unsigned int DB_DSK_SPHERE_TEXTURE_MAPPING_INFO = 177; // not implemented in 1.0 +const unsigned int DB_DSK_GRID_TEXTURE_MAPPING_INFO = 178; // not implemented in 1.0 + + + @@ -144,86 +152,84 @@ const unsigned int DB_DSK_PAGE = 172; // // Constants to define the data types supported in the format // -const unsigned char DB_CHAR = 1; -const unsigned char DB_SHORT = 2; -const unsigned char DB_INT = 3; -const unsigned char DB_FLOAT = 4; -const unsigned char DB_LONG = 5; -const unsigned char DB_DOUBLE = 6; -const unsigned char DB_VEC2F = 7; -const unsigned char DB_VEC3F = 8; -const unsigned char DB_VEC4F = 9; -const unsigned char DB_VEC2I = 10; -const unsigned char DB_VEC3I = 11; -const unsigned char DB_VEC4I = 12; -const unsigned char DB_VEC16F = 13; -const unsigned char DB_VEC2D = 14; -const unsigned char DB_VEC3D = 15; -const unsigned char DB_VEC4D = 16; -const unsigned char DB_VEC16D = 17; -const unsigned char DB_VRTX_STRUCT = 18; // deprecated (obsolete) after 0.982 -const unsigned char DB_UINT = 19; -const unsigned char DB_USHORT = 20; -const unsigned char DB_UCHAR = 21; -const unsigned char DB_ULONG = 22; -const unsigned char DB_EXT_STRUCT = 23; -const unsigned char DB_SHORT_WITH_PADDING = 24; -const unsigned char DB_CHAR_WITH_PADDING = 25; -const unsigned char DB_USHORT_WITH_PADDING = 26; -const unsigned char DB_UCHAR_WITH_PADDING = 27; -const unsigned char DB_BOOL_WITH_PADDING = 28; -const unsigned char DB_EXTENDED_FIELD_STRUCT = 31; -const unsigned char DB_VEC4UC = 32; // array of 4 unsigned chars -const unsigned char DB_DISCRETE_MAPPING_STRUCT = 33; -const unsigned char DB_BITFLAGS = 34; +const unsigned char DB_CHAR = 1; +const unsigned char DB_SHORT = 2; +const unsigned char DB_INT = 3; +const unsigned char DB_FLOAT = 4; +const unsigned char DB_LONG = 5; +const unsigned char DB_DOUBLE = 6; +const unsigned char DB_VEC2F = 7; +const unsigned char DB_VEC3F = 8; +const unsigned char DB_VEC4F = 9; +const unsigned char DB_VEC2I = 10; +const unsigned char DB_VEC3I = 11; +const unsigned char DB_VEC4I = 12; +const unsigned char DB_VEC16F = 13; +const unsigned char DB_VEC2D = 14; +const unsigned char DB_VEC3D = 15; +const unsigned char DB_VEC4D = 16; +const unsigned char DB_VEC16D = 17; +const unsigned char DB_VRTX_STRUCT = 18; // deprecated (obsolete) after 0.982 +const unsigned char DB_UINT = 19; +const unsigned char DB_USHORT = 20; +const unsigned char DB_UCHAR = 21; +const unsigned char DB_ULONG = 22; +const unsigned char DB_EXT_STRUCT = 23; +const unsigned char DB_SHORT_WITH_PADDING = 24; +const unsigned char DB_CHAR_WITH_PADDING = 25; +const unsigned char DB_USHORT_WITH_PADDING = 26; +const unsigned char DB_UCHAR_WITH_PADDING = 27; +const unsigned char DB_BOOL_WITH_PADDING = 28; +const unsigned char DB_EXTENDED_FIELD_STRUCT = 31; +const unsigned char DB_VEC4UC = 32; // array of 4 unsigned chars +const unsigned char DB_DISCRETE_MAPPING_STRUCT = 33; +const unsigned char DB_BITFLAGS = 34; // // Constants to define sizeof() values // -const unsigned char SIZEOF_FIELD_STRUCT = 4; -const unsigned char SIZEOF_EXTENDED_FIELD_STRUCT = 8; -const unsigned char SIZEOF_CHAR = 1; -const unsigned char SIZEOF_SHORT = 2; -const unsigned char SIZEOF_INT = 4; -const unsigned char SIZEOF_FLOAT = 4; -const unsigned char SIZEOF_LONG = 4; -const unsigned char SIZEOF_ULONG = 4; -const unsigned char SIZEOF_DOUBLE = 8; -const unsigned char SIZEOF_VEC2F = (SIZEOF_FLOAT*2); -const unsigned char SIZEOF_VEC3F = (SIZEOF_FLOAT*3); -const unsigned char SIZEOF_VEC4F = (SIZEOF_FLOAT*4); -const unsigned char SIZEOF_VEC16F = (SIZEOF_FLOAT*16); -const unsigned char SIZEOF_VEC2I = (SIZEOF_INT*2); -const unsigned char SIZEOF_VEC3I = (SIZEOF_INT*3); -const unsigned char SIZEOF_VEC4I = (SIZEOF_INT*4); -const unsigned char SIZEOF_VEC2D = (SIZEOF_DOUBLE*2); -const unsigned char SIZEOF_VEC3D = (SIZEOF_DOUBLE*3); -const unsigned char SIZEOF_VEC4D = (SIZEOF_DOUBLE*4); -const unsigned char SIZEOF_VEC16D = (SIZEOF_DOUBLE*16); -const unsigned char SIZEOF_VRTX_STRUCT = 32; -const unsigned char SIZEOF_EXT_STRUCT = 32; -const unsigned char SIZEOF_UCHAR = (SIZEOF_CHAR); -const unsigned char SIZEOF_USHORT = (SIZEOF_SHORT); -const unsigned char SIZEOF_UINT = (SIZEOF_INT); -const unsigned char SIZEOF_VEC4UC = (SIZEOF_INT); -const unsigned char SIZEOF_SHORT_WITH_PADDING = (SIZEOF_INT); -const unsigned char SIZEOF_CHAR_WITH_PADDING = (SIZEOF_INT); -const unsigned char SIZEOF_USHORT_WITH_PADDING = (SIZEOF_INT); -const unsigned char SIZEOF_UCHAR_WITH_PADDING = (SIZEOF_INT); -const unsigned char SIZEOF_BOOL_WITH_PADDING = (SIZEOF_INT); -const unsigned char SIZEOF_DISCRETE_MAPPING_STRUCT = 12; -const unsigned char SIZEOF_BITFLAGS = (SIZEOF_INT); +const unsigned char SIZEOF_FIELD_STRUCT = 4; +const unsigned char SIZEOF_EXTENDED_FIELD_STRUCT = 8; +const unsigned char SIZEOF_CHAR = 1; +const unsigned char SIZEOF_SHORT = 2; +const unsigned char SIZEOF_INT = 4; +const unsigned char SIZEOF_FLOAT = 4; +const unsigned char SIZEOF_LONG = 4; +const unsigned char SIZEOF_ULONG = 4; +const unsigned char SIZEOF_DOUBLE = 8; +const unsigned char SIZEOF_VEC2F = (SIZEOF_FLOAT*2); +const unsigned char SIZEOF_VEC3F = (SIZEOF_FLOAT*3); +const unsigned char SIZEOF_VEC4F = (SIZEOF_FLOAT*4); +const unsigned char SIZEOF_VEC16F = (SIZEOF_FLOAT*16); +const unsigned char SIZEOF_VEC2I = (SIZEOF_INT*2); +const unsigned char SIZEOF_VEC3I = (SIZEOF_INT*3); +const unsigned char SIZEOF_VEC4I = (SIZEOF_INT*4); +const unsigned char SIZEOF_VEC2D = (SIZEOF_DOUBLE*2); +const unsigned char SIZEOF_VEC3D = (SIZEOF_DOUBLE*3); +const unsigned char SIZEOF_VEC4D = (SIZEOF_DOUBLE*4); +const unsigned char SIZEOF_VEC16D = (SIZEOF_DOUBLE*16); +const unsigned char SIZEOF_VRTX_STRUCT = 32; +const unsigned char SIZEOF_EXT_STRUCT = 32; +const unsigned char SIZEOF_UCHAR = (SIZEOF_CHAR); +const unsigned char SIZEOF_USHORT = (SIZEOF_SHORT); +const unsigned char SIZEOF_UINT = (SIZEOF_INT); +const unsigned char SIZEOF_VEC4UC = (SIZEOF_INT); +const unsigned char SIZEOF_SHORT_WITH_PADDING = (SIZEOF_INT); +const unsigned char SIZEOF_CHAR_WITH_PADDING = (SIZEOF_INT); +const unsigned char SIZEOF_USHORT_WITH_PADDING = (SIZEOF_INT); +const unsigned char SIZEOF_UCHAR_WITH_PADDING = (SIZEOF_INT); +const unsigned char SIZEOF_BOOL_WITH_PADDING = (SIZEOF_INT); +const unsigned char SIZEOF_DISCRETE_MAPPING_STRUCT = 12; +const unsigned char SIZEOF_BITFLAGS = (SIZEOF_INT); -/* these parameters set by Carbon Graphics, not needed for OSG loader -const unsigned short MIN_CHAR_VAL = -128; -const unsigned short MAX_CHAR_VAL = 127; -const unsigned short MAX_UCHAR_VAL = 255; -const unsigned short MIN_SHORT_VAL = -32768; -const unsigned short MAX_SHORT_VAL = 32767; -const unsigned short MAX_USHORT_VAL = 65535; -*/ +const unsigned short MIN_CHAR_VAL = -128; +const unsigned short MAX_CHAR_VAL = 127; +const unsigned short MAX_UCHAR_VAL = 255; +const unsigned short MIN_SHORT_VAL = -32768; +const unsigned short MAX_SHORT_VAL = 32767; +const unsigned short MAX_USHORT_VAL = 65535; @@ -242,7 +248,7 @@ const unsigned short MAX_USHORT_VAL = 65535; */ struct GEO_DB_API geoRecordHeader { - unsigned int id; // e.g. DB_DSK_HEADER etc. + unsigned int id; // e.g. DB_DSK_HEADER etc. }; @@ -253,19 +259,19 @@ struct GEO_DB_API geoRecordHeader */ struct GEO_DB_API geoFieldHeader { - /** The Field ID for the data about to be read from disk. This Field - * token record in effect describes the data which is going to - * follow this geoFieldToken struct. This description is sufficient to - * allow parsing code to step over and ignore either fields or whole - * records if they are unknown or unwanted. - */ - unsigned char id; // field ID for record + /** The Field ID for the data about to be read from disk. This Field + * token record in effect describes the data which is going to + * follow this geoFieldToken struct. This description is sufficient to + * allow parsing code to step over and ignore either fields or whole + * records if they are unknown or unwanted. + */ + unsigned char id; // field ID for record - /** The data type of the field coming up */ - unsigned char type; // DB_INT, etc. + /** The data type of the field coming up */ + unsigned char type; // DB_INT, etc. - /** How many of the data types (described above) must be read */ - unsigned short num; // How many of them follow + /** How many of the data types (described above) must be read */ + unsigned short num; // How many of them follow }; @@ -285,10 +291,10 @@ struct GEO_DB_API geoFieldHeader * example of a large vertex palette... * * on disk: - * + * * geoFieldHeader * { - * DB_UCHAR id GEO_DB_VRTX_COORDS + * DB_UCHAR id GEO_DB_VRTX_COORDS * DB_UCHAR type DB_EXTENDED_FIELD_STRUCT * DB_USHORT num 1 * } @@ -301,7 +307,7 @@ struct GEO_DB_API geoFieldHeader * * geoExtendedFieldHeader * { - * DB_USHORT id GEO_DB_VRTX_COORDS + * DB_USHORT id GEO_DB_VRTX_COORDS * DB_USHORT type DB_VEC3F * DB_UINT num number-of-verts * } @@ -318,10 +324,10 @@ struct GEO_DB_API geoFieldHeader * geoFieldHeader field - since its "id" field is only an unsigned char). If any * records have more than 255 fields then their ids will be unsigned shorts and * on disk they will be represented by... - * + * * geoFieldHeader * { - * DB_UCHAR id GEO_DB_EXTENDED_FIELD + * DB_UCHAR id GEO_DB_EXTENDED_FIELD * DB_UCHAR type DB_EXTENDED_FIELD_STRUCT * DB_USHORT num 1 * } @@ -330,7 +336,7 @@ struct GEO_DB_API geoFieldHeader * * geoExtendedFieldHeader * { - * DB_USHORT id GEO_DB_SOME_FUTURE_USHORT_ID + * DB_USHORT id GEO_DB_SOME_FUTURE_USHORT_ID * DB_USHORT type DB_VEC3F * DB_UINT num number_of_data_items * } @@ -341,16 +347,16 @@ struct GEO_DB_API geoFieldHeader */ struct GEO_DB_API geoExtendedFieldHeader { - /** Id of the field. This should be the same ID as the previous geoFieldHeader - * which indicated the existence of this record. - */ - unsigned short id; // field ID for record + /** Id of the field. This should be the same ID as the previous geoFieldHeader + * which indicated the existence of this record. + */ + unsigned short id; // field ID for record - /** The data type of the field coming up */ - unsigned short type; // DB_INT, etc. + /** The data type of the field coming up */ + unsigned short type; // DB_INT, etc. - /** How many of the data types (described above) must be read */ - unsigned int num; // How many of them follow + /** How many of the data types (described above) must be read */ + unsigned int num; // How many of them follow }; @@ -360,16 +366,16 @@ struct GEO_DB_API geoExtendedFieldHeader /////////////////////////////////////////////////////////////////////////////// // Constant to define the last field types // -const unsigned char GEO_DB_LAST_FIELD = 0; +const unsigned char GEO_DB_LAST_FIELD = 0; /////////////////////////////////////////////////////////////////////////////// // Common field types for all Nodes // -const unsigned char GEO_DB_USER_EXT_VALUE_FIELD = 1; -const unsigned char GEO_DB_PADDING = 252; -const unsigned char GEO_DB_TRANSFORM_FIELD = 253; -const unsigned char GEO_DB_EXTENDED_FIELD = 254; -const unsigned char GEO_DB_COMMENT_FIELD = 255; +const unsigned char GEO_DB_USER_EXT_VALUE_FIELD = 1; +const unsigned char GEO_DB_PADDING = 252; +const unsigned char GEO_DB_TRANSFORM_FIELD = 253; +const unsigned char GEO_DB_EXTENDED_FIELD = 254; +const unsigned char GEO_DB_COMMENT_FIELD = 255; @@ -379,41 +385,41 @@ const unsigned char GEO_DB_COMMENT_FIELD = 255; /////////////////////////////////////////////////////////////////////////////// // GEO_DB_HEADER Record - Field Ids // -const unsigned char GEO_DB_HDR_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_HDR_UNITS = 2; -const unsigned char GEO_DB_HDR_BBOX = 3; -const unsigned char GEO_DB_HDR_NAME = 5; -const unsigned char GEO_DB_HDR_VERSION = 8; -const unsigned char GEO_DB_HDR_EXT_TEMPLATE = 9; -const unsigned char GEO_DB_HDR_UP_AXIS = 12; -const unsigned char GEO_DB_HDR_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_HDR_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_HDR_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_HDR_UNITS = 2; +const unsigned char GEO_DB_HDR_BBOX = 3; +const unsigned char GEO_DB_HDR_NAME = 5; +const unsigned char GEO_DB_HDR_VERSION = 8; +const unsigned char GEO_DB_HDR_EXT_TEMPLATE = 9; +const unsigned char GEO_DB_HDR_UP_AXIS = 12; +const unsigned char GEO_DB_HDR_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_HDR_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // DB_DSK_COORD_POOL Record - Field Ids // -const unsigned char GEO_DB_COORD_POOL_SIZE = 1; -const unsigned char GEO_DB_COORD_POOL_VALUES = 2; -const unsigned char GEO_DB_COORD_POOL_SCALE = 3; -const unsigned char GEO_DB_COORD_POOL_OFFSET = 4; +const unsigned char GEO_DB_COORD_POOL_SIZE = 1; +const unsigned char GEO_DB_COORD_POOL_VALUES = 2; +const unsigned char GEO_DB_COORD_POOL_SCALE = 3; +const unsigned char GEO_DB_COORD_POOL_OFFSET = 4; /////////////////////////////////////////////////////////////////////////////// // DB_DSK_NORMAL_POOL Record - Field Ids // -const unsigned char GEO_DB_NORMAL_POOL_SIZE = 1; -const unsigned char GEO_DB_NORMAL_POOL_VALUES = 2; +const unsigned char GEO_DB_NORMAL_POOL_SIZE = 1; +const unsigned char GEO_DB_NORMAL_POOL_VALUES = 2; /////////////////////////////////////////////////////////////////////////////// // DB_DSK_MATERIAL Record - Field Ids // -const unsigned char GEO_DB_MAT_AMBIENT = 1; -const unsigned char GEO_DB_MAT_DIFFUSE = 2; -const unsigned char GEO_DB_MAT_SPECULAR = 3; -const unsigned char GEO_DB_MAT_SHININESS = 4; -const unsigned char GEO_DB_MAT_NAME = 5; -const unsigned char GEO_DB_MAT_EMISSIVE = 6; +const unsigned char GEO_DB_MAT_AMBIENT = 1; +const unsigned char GEO_DB_MAT_DIFFUSE = 2; +const unsigned char GEO_DB_MAT_SPECULAR = 3; +const unsigned char GEO_DB_MAT_SHININESS = 4; +const unsigned char GEO_DB_MAT_NAME = 5; +const unsigned char GEO_DB_MAT_EMISSIVE = 6; /////////////////////////////////////////////////////////////////////////////// @@ -425,100 +431,101 @@ const unsigned char GEO_DB_COLOR_PALETTE_HIGHEST_INTENSITIES = 1; /////////////////////////////////////////////////////////////////////////////// // DB_DSK_TEXTURE Record - Field Ids // -const unsigned char GEO_DB_TEX_WRAPS = 1; -const unsigned char GEO_DB_TEX_WRAPT = 2; -const unsigned char GEO_DB_TEX_MAGFILTER = 3; -const unsigned char GEO_DB_TEX_MINFILTER = 4; -const unsigned char GEO_DB_TEX_ENV = 5; -const unsigned char GEO_DB_TEX_FILE_NAME = 6; +const unsigned char GEO_DB_TEX_WRAPS = 1; +const unsigned char GEO_DB_TEX_WRAPT = 2; +const unsigned char GEO_DB_TEX_MAGFILTER = 3; +const unsigned char GEO_DB_TEX_MINFILTER = 4; +const unsigned char GEO_DB_TEX_ENV = 5; +const unsigned char GEO_DB_TEX_FILE_NAME = 6; /////////////////////////////////////////////////////////////////////////////// // DB_DSK_VIEW Record - Field Ids Ids // -const unsigned char GEO_DB_VIEW_NEAR = 1; -const unsigned char GEO_DB_VIEW_FAR = 2; -const unsigned char GEO_DB_VIEW_POS = 3; -const unsigned char GEO_DB_VIEW_CEN = 4; -const unsigned char GEO_DB_VIEW_TRACKBALL = 5; +const unsigned char GEO_DB_VIEW_NEAR = 1; +const unsigned char GEO_DB_VIEW_FAR = 2; +const unsigned char GEO_DB_VIEW_POS = 3; +const unsigned char GEO_DB_VIEW_CEN = 4; +const unsigned char GEO_DB_VIEW_TRACKBALL = 5; /////////////////////////////////////////////////////////////////////////////// // GEO_DB_GROUP Record - Field Ids IDs // -const unsigned char GEO_DB_GRP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_GRP_BBOX = 2; -const unsigned char GEO_DB_GRP_NAME = 3; -const unsigned char GEO_DB_GRP_INSTANCE_DEF = 4; -const unsigned char GEO_DB_GRP_FLAG_SHOW_BBOX = 5; -const unsigned char GEO_DB_GRP_TRANSFORM = 253; -const unsigned char GEO_DB_GRP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_GRP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_GRP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_GRP_BBOX = 2; +const unsigned char GEO_DB_GRP_NAME = 3; +const unsigned char GEO_DB_GRP_INSTANCE_DEF = 4; +const unsigned char GEO_DB_GRP_FLAG_SHOW_BBOX = 5; +const unsigned char GEO_DB_GRP_TRANSFORM = 253; +const unsigned char GEO_DB_GRP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_GRP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_LOD Record - Field Ids IDs // -const unsigned char GEO_DB_LOD_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_LOD_IN = 2; -const unsigned char GEO_DB_LOD_OUT = 3; -const unsigned char GEO_DB_LOD_CENTER = 4; -const unsigned char GEO_DB_LOD_CALC = 5; // depricated Field only some pre 1.0 databases should have this field -const unsigned char GEO_DB_LOD_NAME = 6; -const unsigned char GEO_DB_LOD_INSTANCE_DEF = 7; -const unsigned char GEO_DB_LOD_TRANSFORM = 253; -const unsigned char GEO_DB_LOD_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_LOD_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_LOD_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_LOD_IN = 2; +const unsigned char GEO_DB_LOD_OUT = 3; +const unsigned char GEO_DB_LOD_CENTER = 4; +const unsigned char GEO_DB_LOD_CALC = 5; // depricated Field only some pre 1.0 databases should have this field +const unsigned char GEO_DB_LOD_NAME = 6; +const unsigned char GEO_DB_LOD_INSTANCE_DEF = 7; +const unsigned char GEO_DB_LOD_FREEZE_CENTER = 8; +const unsigned char GEO_DB_LOD_TRANSFORM = 253; +const unsigned char GEO_DB_LOD_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_LOD_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_SEQUENCE Record - Field Ids IDs // -const unsigned char GEO_DB_SEQUENCE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_SEQUENCE_NAME = 2; -const unsigned char GEO_DB_SEQUENCE_MODE = 3; -const unsigned char GEO_DB_SEQUENCE_ACTIVE = 4; -const unsigned char GEO_DB_SEQUENCE_INSTANCE_DEF = 5; -const unsigned char GEO_DB_SEQUENCE_TRANSFORM = 253; -const unsigned char GEO_DB_SEQUENCE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_SEQUENCE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_SEQUENCE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_SEQUENCE_NAME = 2; +const unsigned char GEO_DB_SEQUENCE_MODE = 3; +const unsigned char GEO_DB_SEQUENCE_ACTIVE = 4; +const unsigned char GEO_DB_SEQUENCE_INSTANCE_DEF = 5; +const unsigned char GEO_DB_SEQUENCE_TRANSFORM = 253; +const unsigned char GEO_DB_SEQUENCE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_SEQUENCE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_INSTANCE Record - Field Ids IDs // -const unsigned char GEO_DB_INSTANCE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_INSTANCE_NAME = 2; -const unsigned char GEO_DB_INSTANCE_DEF = 3; -const unsigned char GEO_DB_INSTANCE_TRANSFORM = 253; -const unsigned char GEO_DB_INSTANCE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_INSTANCE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_INSTANCE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_INSTANCE_NAME = 2; +const unsigned char GEO_DB_INSTANCE_DEF = 3; +const unsigned char GEO_DB_INSTANCE_TRANSFORM = 253; +const unsigned char GEO_DB_INSTANCE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_INSTANCE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_SWITCH Record - Field Ids IDs // -const unsigned char GEO_DB_SWITCH_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_SWITCH_CURRENT_MASK = 2; -const unsigned char GEO_DB_SWITCH_MASK_WIDTH = 3;// Not used -const unsigned char GEO_DB_SWITCH_NUM_MASKS = 4; -const unsigned char GEO_DB_SWITCH_MASKS = 5; -const unsigned char GEO_DB_SWITCH_NAME = 6; -const unsigned char GEO_DB_SWITCH_INSTANCE_DEF = 7; -const unsigned char GEO_DB_SWITCH_TRANSFORM = 253; -const unsigned char GEO_DB_SWITCH_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_SWITCH_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_SWITCH_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_SWITCH_CURRENT_MASK = 2; +const unsigned char GEO_DB_SWITCH_MASK_WIDTH = 3;// Not used +const unsigned char GEO_DB_SWITCH_NUM_MASKS = 4; +const unsigned char GEO_DB_SWITCH_MASKS = 5; +const unsigned char GEO_DB_SWITCH_NAME = 6; +const unsigned char GEO_DB_SWITCH_INSTANCE_DEF = 7; +const unsigned char GEO_DB_SWITCH_TRANSFORM = 253; +const unsigned char GEO_DB_SWITCH_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_SWITCH_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_PAGE Record - Field Ids IDs // -const unsigned char GEO_DB_PAGE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_PAGE_NAME = 2; -const unsigned char GEO_DB_PAGE_ACTIVE_CHILD = 3; -const unsigned char GEO_DB_PAGE_TRANSFORM = 253; -const unsigned char GEO_DB_PAGE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_PAGE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_PAGE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_PAGE_NAME = 2; +const unsigned char GEO_DB_PAGE_ACTIVE_CHILD = 3; +const unsigned char GEO_DB_PAGE_TRANSFORM = 253; +const unsigned char GEO_DB_PAGE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_PAGE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD @@ -529,16 +536,16 @@ const unsigned char GEO_DB_PAGE_COMMENT = 255; // alias for GEO_D // ID of 20 (GEO_DB_BASE_GROUP_START_EXTERNAL). This allows Geo to add // additional fields which will be common to all derived groups up to this // number -const unsigned char GEO_DB_BASE_GROUP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_BASE_GROUP_CLASSNAME = 2; -const unsigned char GEO_DB_BASE_GROUP_EXTENDED_TYPE = 3; -const unsigned char GEO_DB_BASE_GROUP_NAME = 4; -const unsigned char GEO_DB_BASE_GROUP_INSTANCE_DEF = 5; +const unsigned char GEO_DB_BASE_GROUP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_BASE_GROUP_CLASSNAME = 2; +const unsigned char GEO_DB_BASE_GROUP_EXTENDED_TYPE = 3; +const unsigned char GEO_DB_BASE_GROUP_NAME = 4; +const unsigned char GEO_DB_BASE_GROUP_INSTANCE_DEF = 5; const unsigned char GEO_DB_BASE_GROUP_PLUGIN_REQUIRED=6; const unsigned char GEO_DB_BASE_GROUP_START_EXTERNAL= 20; -const unsigned char GEO_DB_BASE_GROUP_TRANSFORM = 253; -const unsigned char GEO_DB_BASE_GROUP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_BASE_GROUP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_BASE_GROUP_TRANSFORM = 253; +const unsigned char GEO_DB_BASE_GROUP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_BASE_GROUP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD @@ -549,30 +556,30 @@ const unsigned char GEO_DB_BASE_GROUP_COMMENT = 255; // alias for GEO_DB_ // ID of 20 (GEO_DB_BASE_SURFACE_START_EXTERNAL). This allows Geo to add // additional fields which will be common to all derived groups up to this // number -const unsigned char GEO_DB_BASE_SURFACE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_BASE_SURFACE_CLASSNAME = 2; -const unsigned char GEO_DB_BASE_SURFACE_EXTENDED_TYPE = 3; -const unsigned char GEO_DB_BASE_SURFACE_NAME = 4; -const unsigned char GEO_DB_BASE_SURFACE_PLUGIN_REQUIRED = 5; +const unsigned char GEO_DB_BASE_SURFACE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_BASE_SURFACE_CLASSNAME = 2; +const unsigned char GEO_DB_BASE_SURFACE_EXTENDED_TYPE = 3; +const unsigned char GEO_DB_BASE_SURFACE_NAME = 4; +const unsigned char GEO_DB_BASE_SURFACE_PLUGIN_REQUIRED = 5; const unsigned char GEO_DB_BASE_SURFACE_START_EXTERNAL = 20; -const unsigned char GEO_DB_BASE_SURFACE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_BASE_SURFACE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_BASE_SURFACE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_BASE_SURFACE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_RENDERGROUP Record - Field Ids IDs // -const unsigned char GEO_DB_RENDERGROUP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_RENDERGROUP_MAT = 2; -const unsigned char GEO_DB_RENDERGROUP_NAME = 3; -const unsigned char GEO_DB_RENDERGROUP_INSTANCE_DEF = 4; +const unsigned char GEO_DB_RENDERGROUP_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_RENDERGROUP_MAT = 2; +const unsigned char GEO_DB_RENDERGROUP_NAME = 3; +const unsigned char GEO_DB_RENDERGROUP_INSTANCE_DEF = 4; const unsigned char GEO_DB_RENDERGROUP_FLAG_SHOW_BBOX=5; // deprecated in 0.9.9.10 -const unsigned char GEO_DB_RENDERGROUP_IS_TERRAIN =6; +const unsigned char GEO_DB_RENDERGROUP_IS_TERRAIN =6; const unsigned char GEO_DB_RENDERGROUP_IS_BILLBOARD =7; -const unsigned char GEO_DB_RENDERGROUP_TRANSFORM = 253; -const unsigned char GEO_DB_RENDERGROUP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_RENDERGROUP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_RENDERGROUP_TRANSFORM = 253; +const unsigned char GEO_DB_RENDERGROUP_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_RENDERGROUP_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD @@ -580,136 +587,145 @@ const unsigned char GEO_DB_RENDERGROUP_COMMENT = 255; // alias for GEO_DB /////////////////////////////////////////////////////////////////////////////// // GEO_DB_POLYGON Record - Field Ids IDs // -const unsigned char GEO_DB_POLY_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_POLY_NORMAL = 2; -const unsigned char GEO_DB_POLY_CENTER = 3; -const unsigned char GEO_DB_POLY_PACKED_COLOR = 4; -const unsigned char GEO_DB_POLY_TEX = 5; -const unsigned char GEO_DB_POLY_NAME = 6; -const unsigned char GEO_DB_POLY_DSTYLE = 7; -const unsigned char GEO_DB_POLY_SHADEMODEL = 8; +const unsigned char GEO_DB_POLY_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_POLY_NORMAL = 2; +const unsigned char GEO_DB_POLY_CENTER = 3; +const unsigned char GEO_DB_POLY_PACKED_COLOR = 4; +const unsigned char GEO_DB_POLY_TEX = 5; +const unsigned char GEO_DB_POLY_NAME = 6; +const unsigned char GEO_DB_POLY_DSTYLE = 7; +const unsigned char GEO_DB_POLY_SHADEMODEL = 8; const unsigned char GEO_DB_POLY_USE_MATERIAL_DIFFUSE= 9; const unsigned char GEO_DB_POLY_USE_VERTEX_COLORS = 10; -const unsigned char GEO_DB_POLY_COLOR_INDEX = 11; -const unsigned char GEO_DB_POLY_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_POLY_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_POLY_COLOR_INDEX = 11; +const unsigned char GEO_DB_POLY_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_POLY_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +/////////////////////////////////////////////////////////////////// +// DB_DSK_PLANE_TEXTURE_MAPPING_INFO Record Field Ids +/////////////////////////////////////////////////////////////////// +const unsigned char GEO_DB_PLANE_TEXTURE_MAPPING_INFO_ORIGIN_PT = 1; +const unsigned char GEO_DB_PLANE_TEXTURE_MAPPING_INFO_U_AXIS_PT = 2; +const unsigned char GEO_DB_PLANE_TEXTURE_MAPPING_INFO_V_AXIS_PT = 3; + + /////////////////////////////////////////////////////////////////////////////// // GEO_DB_LIGHTPT Record - Field Ids IDs // -const unsigned char GEO_DB_LIGHTPT_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_LIGHTPT_TYPE = 2; -const unsigned char GEO_DB_LIGHTPT_DIRECTION_VECTOR = 3; -const unsigned char GEO_DB_LIGHTPT_PACKED_COLOR = 4; +const unsigned char GEO_DB_LIGHTPT_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_LIGHTPT_TYPE = 2; +const unsigned char GEO_DB_LIGHTPT_DIRECTION_VECTOR = 3; +const unsigned char GEO_DB_LIGHTPT_PACKED_COLOR = 4; const unsigned char GEO_DB_LIGHTPT_BACK_PACKED_COLOR= 5; -const unsigned char GEO_DB_LIGHTPT_MIN_PIXEL_SIZE = 6; -const unsigned char GEO_DB_LIGHTPT_MAX_PIXEL_SIZE = 7; -const unsigned char GEO_DB_LIGHTPT_HORIZ_LOBE_ANGLE = 8; -const unsigned char GEO_DB_LIGHTPT_VERT_LOBE_ANGLE = 9; -const unsigned char GEO_DB_LIGHTPT_DAY_DISPLAY = 10; -const unsigned char GEO_DB_LIGHTPT_DUSK_DISPLAY = 11; -const unsigned char GEO_DB_LIGHTPT_NIGHT_DISPLAY = 12; -const unsigned char GEO_DB_LIGHTPT_NAME = 13; -const unsigned char GEO_DB_LIGHTPT_COLOR_INDEX = 14; -const unsigned char GEO_DB_LIGHTPT_BACK_COLOR_INDEX = 15; -const unsigned char GEO_DB_LIGHTPT_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_LIGHTPT_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_LIGHTPT_MIN_PIXEL_SIZE = 6; +const unsigned char GEO_DB_LIGHTPT_MAX_PIXEL_SIZE = 7; +const unsigned char GEO_DB_LIGHTPT_HORIZ_LOBE_ANGLE = 8; +const unsigned char GEO_DB_LIGHTPT_VERT_LOBE_ANGLE = 9; +const unsigned char GEO_DB_LIGHTPT_DAY_DISPLAY = 10; +const unsigned char GEO_DB_LIGHTPT_DUSK_DISPLAY = 11; +const unsigned char GEO_DB_LIGHTPT_NIGHT_DISPLAY = 12; +const unsigned char GEO_DB_LIGHTPT_NAME = 13; +const unsigned char GEO_DB_LIGHTPT_COLOR_INDEX = 14; +const unsigned char GEO_DB_LIGHTPT_BACK_COLOR_INDEX = 15; +const unsigned char GEO_DB_LIGHTPT_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_LIGHTPT_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_TEXT Record - Field Ids IDs // -const unsigned char GEO_DB_TEXT_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_TEXT_NAME = 2; -const unsigned char GEO_DB_TEXT_TYPE = 3; -const unsigned char GEO_DB_TEXT_STRING = 4; -const unsigned char GEO_DB_TEXT_JUSTIFICATION = 5; -const unsigned char GEO_DB_TEXT_DIRECTION = 6; -const unsigned char GEO_DB_TEXT_LINEWIDTH = 7; -const unsigned char GEO_DB_TEXT_PACKED_COLOR = 8; -const unsigned char GEO_DB_TEXT_SCALE_X = 9; -const unsigned char GEO_DB_TEXT_SCALE_Y = 10; -const unsigned char GEO_DB_TEXT_MATRIX = 11; -const unsigned char GEO_DB_TEXT_EXPANSION = 12; -const unsigned char GEO_DB_TEXT_COLOR_INDEX = 13; -const unsigned char GEO_DB_TEXT_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_TEXT_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_TEXT_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_TEXT_NAME = 2; +const unsigned char GEO_DB_TEXT_TYPE = 3; +const unsigned char GEO_DB_TEXT_STRING = 4; +const unsigned char GEO_DB_TEXT_JUSTIFICATION = 5; +const unsigned char GEO_DB_TEXT_DIRECTION = 6; +const unsigned char GEO_DB_TEXT_LINEWIDTH = 7; +const unsigned char GEO_DB_TEXT_PACKED_COLOR = 8; +const unsigned char GEO_DB_TEXT_SCALE_X = 9; +const unsigned char GEO_DB_TEXT_SCALE_Y = 10; +const unsigned char GEO_DB_TEXT_MATRIX = 11; +const unsigned char GEO_DB_TEXT_EXPANSION = 12; +const unsigned char GEO_DB_TEXT_COLOR_INDEX = 13; +const unsigned char GEO_DB_TEXT_FONT = 14; +const unsigned char GEO_DB_TEXT_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_TEXT_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// -// GEO_DB_IMAGE Record - Field Ids IDs - Not Yet Implemented +// GEO_DB_IMAGE Record - Field Ids IDs - Not Yet Implemented // -const unsigned char GEO_DB_IMAGE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_IMAGE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_IMAGE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_IMAGE_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_IMAGE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_IMAGE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// -// GEO_DB_MESH Record - Field Ids IDs - Not Yet Implemented +// GEO_DB_MESH Record - Field Ids IDs - Not Yet Implemented // -const unsigned char GEO_DB_MESH_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_MESH_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_MESH_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_MESH_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_MESH_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_MESH_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_VERTEX Record - Field Ids IDs // -const unsigned char GEO_DB_VRTX_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_VRTX_COORD = 2; -const unsigned char GEO_DB_VRTX_UV_SET_1 = 3; +const unsigned char GEO_DB_VRTX_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_VRTX_COORD = 2; +const unsigned char GEO_DB_VRTX_UV_SET_1 = 3; -const unsigned char GEO_DB_VRTX_UV_SET_2 = 4; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_3 = 5; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_4 = 6; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_5 = 7; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_6 = 8; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_7 = 9; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_UV_SET_8 = 10; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_2 = 4; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_3 = 5; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_4 = 6; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_5 = 7; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_6 = 8; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_7 = 9; // Unused - Possible Future expansion +const unsigned char GEO_DB_VRTX_UV_SET_8 = 10; // Unused - Possible Future expansion -const unsigned char GEO_DB_VRTX_NORMAL = 11; -const unsigned char GEO_DB_VRTX_PACKED_COLOR = 12; -const unsigned char GEO_DB_VRTX_COLOR_INDEX = 13; +const unsigned char GEO_DB_VRTX_NORMAL = 11; +const unsigned char GEO_DB_VRTX_PACKED_COLOR = 12; +const unsigned char GEO_DB_VRTX_COLOR_INDEX = 13; -const unsigned char GEO_DB_VRTX_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_VRTX_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_VRTX_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_VRTX_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////////////////// // GEO_DB_EXTERNAL Record - Field Ids IDs // -const unsigned char GEO_DB_EXTERNAL_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD -const unsigned char GEO_DB_EXTERNAL_NAME = 2; -const unsigned char GEO_DB_EXTERNAL_INSTANCE_DEF = 3; -const unsigned char GEO_DB_EXTERNAL_FILENAME = 4; -const unsigned char GEO_DB_EXTERNAL_TRANSFORM = 253; -const unsigned char GEO_DB_EXTERNAL_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD -const unsigned char GEO_DB_EXTERNAL_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD +const unsigned char GEO_DB_EXTERNAL_EXT = 1; // alias for GEO_DB_USER_EXT_VALUE_FIELD +const unsigned char GEO_DB_EXTERNAL_NAME = 2; +const unsigned char GEO_DB_EXTERNAL_INSTANCE_DEF = 3; +const unsigned char GEO_DB_EXTERNAL_FILENAME = 4; +const unsigned char GEO_DB_EXTERNAL_TRANSFORM = 253; +const unsigned char GEO_DB_EXTERNAL_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD +const unsigned char GEO_DB_EXTERNAL_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD /////////////////////////////////////////////////////////////////// // DB_DSK_INTERNAL_VARS Record Field Ids // -const unsigned char GEO_DB_INTERNAL_VAR_FRAMECOUNT = 1; +const unsigned char GEO_DB_INTERNAL_VAR_FRAMECOUNT = 1; const unsigned char GEO_DB_INTERNAL_VAR_CURRENT_TIME= 2; const unsigned char GEO_DB_INTERNAL_VAR_ELAPSED_TIME= 3; -const unsigned char GEO_DB_INTERNAL_VAR_SINE = 4; -const unsigned char GEO_DB_INTERNAL_VAR_COSINE = 5; -const unsigned char GEO_DB_INTERNAL_VAR_TANGENT = 6; -const unsigned char GEO_DB_INTERNAL_VAR_MOUSE_X = 7; -const unsigned char GEO_DB_INTERNAL_VAR_MOUSE_Y = 8; -const unsigned char GEO_DB_INTERNAL_VAR_LEFT_MOUSE = 9; +const unsigned char GEO_DB_INTERNAL_VAR_SINE = 4; +const unsigned char GEO_DB_INTERNAL_VAR_COSINE = 5; +const unsigned char GEO_DB_INTERNAL_VAR_TANGENT = 6; +const unsigned char GEO_DB_INTERNAL_VAR_MOUSE_X = 7; +const unsigned char GEO_DB_INTERNAL_VAR_MOUSE_Y = 8; +const unsigned char GEO_DB_INTERNAL_VAR_LEFT_MOUSE = 9; const unsigned char GEO_DB_INTERNAL_VAR_MIDDLE_MOUSE= 10; -const unsigned char GEO_DB_INTERNAL_VAR_RIGHT_MOUSE = 11; -const unsigned char GEO_DB_INTERNAL_VAR_KEYBOARD = 12; -const unsigned char GEO_DB_INTERNAL_VAR_TEMP_FLOAT = 13; -const unsigned char GEO_DB_INTERNAL_VAR_TEMP_INT = 14; -const unsigned char GEO_DB_INTERNAL_VAR_TEMP_BOOL = 15; -const unsigned char GEO_DB_INTERNAL_VAR_TEMP_STRING = 16; +const unsigned char GEO_DB_INTERNAL_VAR_RIGHT_MOUSE = 11; +const unsigned char GEO_DB_INTERNAL_VAR_KEYBOARD = 12; +const unsigned char GEO_DB_INTERNAL_VAR_TEMP_FLOAT = 13; +const unsigned char GEO_DB_INTERNAL_VAR_TEMP_INT = 14; +const unsigned char GEO_DB_INTERNAL_VAR_TEMP_BOOL = 15; +const unsigned char GEO_DB_INTERNAL_VAR_TEMP_STRING = 16; @@ -717,163 +733,163 @@ const unsigned char GEO_DB_INTERNAL_VAR_TEMP_STRING = 16; /////////////////////////////////////////////////////////////////// // DB_DSK_FLOAT_VAR Record Field Ids // -const unsigned char GEO_DB_FLOAT_VAR_NAME = 1; -const unsigned char GEO_DB_FLOAT_VAR_VALUE = 2; -const unsigned char GEO_DB_FLOAT_VAR_DEFAULT = 3; -const unsigned char GEO_DB_FLOAT_VAR_FID = 4; -const unsigned char GEO_DB_FLOAT_VAR_CONSTRAINED = 5; -const unsigned char GEO_DB_FLOAT_VAR_MIN = 6; -const unsigned char GEO_DB_FLOAT_VAR_MAX = 7; -const unsigned char GEO_DB_FLOAT_VAR_STEP = 8; +const unsigned char GEO_DB_FLOAT_VAR_NAME = 1; +const unsigned char GEO_DB_FLOAT_VAR_VALUE = 2; +const unsigned char GEO_DB_FLOAT_VAR_DEFAULT = 3; +const unsigned char GEO_DB_FLOAT_VAR_FID = 4; +const unsigned char GEO_DB_FLOAT_VAR_CONSTRAINED = 5; +const unsigned char GEO_DB_FLOAT_VAR_MIN = 6; +const unsigned char GEO_DB_FLOAT_VAR_MAX = 7; +const unsigned char GEO_DB_FLOAT_VAR_STEP = 8; /////////////////////////////////////////////////////////////////// // DB_DSK_FLOAT3_VAR Record Field Ids // -const unsigned char GEO_DB_FLOAT3_VAR_NAME = 1; -const unsigned char GEO_DB_FLOAT3_VAR_VALUE = 2; -const unsigned char GEO_DB_FLOAT3_VAR_DEFAULT = 3; -const unsigned char GEO_DB_FLOAT3_VAR_FID = 4; -const unsigned char GEO_DB_FLOAT3_VAR_CONSTRAINED = 5; -const unsigned char GEO_DB_FLOAT3_VAR_MIN = 6; -const unsigned char GEO_DB_FLOAT3_VAR_MAX = 7; -const unsigned char GEO_DB_FLOAT3_VAR_STEP = 8; +const unsigned char GEO_DB_FLOAT3_VAR_NAME = 1; +const unsigned char GEO_DB_FLOAT3_VAR_VALUE = 2; +const unsigned char GEO_DB_FLOAT3_VAR_DEFAULT = 3; +const unsigned char GEO_DB_FLOAT3_VAR_FID = 4; +const unsigned char GEO_DB_FLOAT3_VAR_CONSTRAINED = 5; +const unsigned char GEO_DB_FLOAT3_VAR_MIN = 6; +const unsigned char GEO_DB_FLOAT3_VAR_MAX = 7; +const unsigned char GEO_DB_FLOAT3_VAR_STEP = 8; /////////////////////////////////////////////////////////////////// // DB_DSK_INT_VAR Record Field Ids // -const unsigned char GEO_DB_INT_VAR_NAME = 1; -const unsigned char GEO_DB_INT_VAR_VALUE = 2; -const unsigned char GEO_DB_INT_VAR_DEFAULT = 3; -const unsigned char GEO_DB_INT_VAR_FID = 4; -const unsigned char GEO_DB_INT_VAR_CONSTRAINED = 5; -const unsigned char GEO_DB_INT_VAR_MIN = 6; -const unsigned char GEO_DB_INT_VAR_MAX = 7; -const unsigned char GEO_DB_INT_VAR_STEP = 8; +const unsigned char GEO_DB_INT_VAR_NAME = 1; +const unsigned char GEO_DB_INT_VAR_VALUE = 2; +const unsigned char GEO_DB_INT_VAR_DEFAULT = 3; +const unsigned char GEO_DB_INT_VAR_FID = 4; +const unsigned char GEO_DB_INT_VAR_CONSTRAINED = 5; +const unsigned char GEO_DB_INT_VAR_MIN = 6; +const unsigned char GEO_DB_INT_VAR_MAX = 7; +const unsigned char GEO_DB_INT_VAR_STEP = 8; /////////////////////////////////////////////////////////////////// // DB_DSK_STRING_VAR Record Field Ids // -const unsigned char GEO_DB_STRING_VAR_NAME = 1; -const unsigned char GEO_DB_STRING_VAR_VALUE = 2; -const unsigned char GEO_DB_STRING_VAR_DEFAULT = 3; -const unsigned char GEO_DB_STRING_VAR_FID = 4; +const unsigned char GEO_DB_STRING_VAR_NAME = 1; +const unsigned char GEO_DB_STRING_VAR_VALUE = 2; +const unsigned char GEO_DB_STRING_VAR_DEFAULT = 3; +const unsigned char GEO_DB_STRING_VAR_FID = 4; /////////////////////////////////////////////////////////////////// // DB_DSK_BOOL_VAR Record Field Ids // -const unsigned char GEO_DB_BOOL_VAR_NAME = 1; -const unsigned char GEO_DB_BOOL_VAR_VALUE = 2; -const unsigned char GEO_DB_BOOL_VAR_DEFAULT = 3; -const unsigned char GEO_DB_BOOL_VAR_FID = 4; +const unsigned char GEO_DB_BOOL_VAR_NAME = 1; +const unsigned char GEO_DB_BOOL_VAR_VALUE = 2; +const unsigned char GEO_DB_BOOL_VAR_DEFAULT = 3; +const unsigned char GEO_DB_BOOL_VAR_FID = 4; /////////////////////////////////////////////////////////////////// // DB_DSK_LONG_VAR Record Field Ids // -const unsigned char GEO_DB_LONG_VAR_NAME = 1; -const unsigned char GEO_DB_LONG_VAR_VALUE = 2; -const unsigned char GEO_DB_LONG_VAR_DEFAULT = 3; -const unsigned char GEO_DB_LONG_VAR_FID = 4; -const unsigned char GEO_DB_LONG_VAR_CONSTRAINED = 5; -const unsigned char GEO_DB_LONG_VAR_MIN = 6; -const unsigned char GEO_DB_LONG_VAR_MAX = 7; -const unsigned char GEO_DB_LONG_VAR_STEP = 8; +const unsigned char GEO_DB_LONG_VAR_NAME = 1; +const unsigned char GEO_DB_LONG_VAR_VALUE = 2; +const unsigned char GEO_DB_LONG_VAR_DEFAULT = 3; +const unsigned char GEO_DB_LONG_VAR_FID = 4; +const unsigned char GEO_DB_LONG_VAR_CONSTRAINED = 5; +const unsigned char GEO_DB_LONG_VAR_MIN = 6; +const unsigned char GEO_DB_LONG_VAR_MAX = 7; +const unsigned char GEO_DB_LONG_VAR_STEP = 8; /////////////////////////////////////////////////////////////////// // DB_DSK_DOUBLE_VAR Record Field Ids // -const unsigned char GEO_DB_DOUBLE_VAR_NAME = 1; -const unsigned char GEO_DB_DOUBLE_VAR_VALUE = 2; -const unsigned char GEO_DB_DOUBLE_VAR_DEFAULT = 3; -const unsigned char GEO_DB_DOUBLE_VAR_FID = 4; -const unsigned char GEO_DB_DOUBLE_VAR_CONSTRAINED = 5; -const unsigned char GEO_DB_DOUBLE_VAR_MIN = 6; -const unsigned char GEO_DB_DOUBLE_VAR_MAX = 7; -const unsigned char GEO_DB_DOUBLE_VAR_STEP = 8; +const unsigned char GEO_DB_DOUBLE_VAR_NAME = 1; +const unsigned char GEO_DB_DOUBLE_VAR_VALUE = 2; +const unsigned char GEO_DB_DOUBLE_VAR_DEFAULT = 3; +const unsigned char GEO_DB_DOUBLE_VAR_FID = 4; +const unsigned char GEO_DB_DOUBLE_VAR_CONSTRAINED = 5; +const unsigned char GEO_DB_DOUBLE_VAR_MIN = 6; +const unsigned char GEO_DB_DOUBLE_VAR_MAX = 7; +const unsigned char GEO_DB_DOUBLE_VAR_STEP = 8; /////////////////////////////////////////////////////////////////// // GEO_DSK_BEHAVIOR Record Field Ids // -const unsigned char GEO_DB_BEHAVIOR_NAME = 1; +const unsigned char GEO_DB_BEHAVIOR_NAME = 1; /////////////////////////////////////////////////////////////////// // DB_DSK_ROTATE_ACTION Record Field Ids // -const unsigned char GEO_DB_ROTATE_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_ROTATE_ACTION_OUTPUT_VAR = 2; // not used -const unsigned char GEO_DB_ROTATE_ACTION_ORIGIN = 3; -const unsigned char GEO_DB_ROTATE_ACTION_VECTOR = 4; -const unsigned char GEO_DB_ROTATE_ACTION_DIR = 5; +const unsigned char GEO_DB_ROTATE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_ROTATE_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_ROTATE_ACTION_ORIGIN = 3; +const unsigned char GEO_DB_ROTATE_ACTION_VECTOR = 4; +const unsigned char GEO_DB_ROTATE_ACTION_DIR = 5; /////////////////////////////////////////////////////////////////// // DB_DSK_CLAMP_ACTION Record Field Ids // -const unsigned char GEO_DB_CLAMP_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_CLAMP_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_CLAMP_ACTION_MIN_VAL = 3; -const unsigned char GEO_DB_CLAMP_ACTION_MAX_VAL = 4; +const unsigned char GEO_DB_CLAMP_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_CLAMP_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_CLAMP_ACTION_MIN_VAL = 3; +const unsigned char GEO_DB_CLAMP_ACTION_MAX_VAL = 4; /////////////////////////////////////////////////////////////////// // DB_DSK_RANGE_ACTION Record Field Ids // -const unsigned char GEO_DB_RANGE_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_RANGE_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_RANGE_ACTION_IN_MIN_VAL = 3; -const unsigned char GEO_DB_RANGE_ACTION_IN_MAX_VAL = 4; -const unsigned char GEO_DB_RANGE_ACTION_OUT_MIN_VAL = 5; -const unsigned char GEO_DB_RANGE_ACTION_OUT_MAX_VAL = 6; +const unsigned char GEO_DB_RANGE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_RANGE_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_RANGE_ACTION_IN_MIN_VAL = 3; +const unsigned char GEO_DB_RANGE_ACTION_IN_MAX_VAL = 4; +const unsigned char GEO_DB_RANGE_ACTION_OUT_MIN_VAL = 5; +const unsigned char GEO_DB_RANGE_ACTION_OUT_MAX_VAL = 6; /////////////////////////////////////////////////////////////////// // DB_DSK_ARITHMETIC_ACTION Record Field Ids // -const unsigned char GEO_DB_ARITHMETIC_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_ARITHMETIC_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_ARITHMETIC_ACTION_OP_TYPE = 3; -const unsigned char GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE = 4; -const unsigned char GEO_DB_ARITHMETIC_ACTION_OPERAND_VAR = 5; +const unsigned char GEO_DB_ARITHMETIC_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_ARITHMETIC_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_ARITHMETIC_ACTION_OP_TYPE = 3; +const unsigned char GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE = 4; +const unsigned char GEO_DB_ARITHMETIC_ACTION_OPERAND_VAR = 5; /////////////////////////////////////////////////////////////////// // DB_DSK_EQUATION_ACTION Record Field Ids // -const unsigned char GEO_DB_EQUATION_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_EQUATION_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_EQUATION_ACTION_A_VAL = 3; -const unsigned char GEO_DB_EQUATION_ACTION_C_VAL = 4; -const unsigned char GEO_DB_EQUATION_ACTION_A_VAR = 5; -const unsigned char GEO_DB_EQUATION_ACTION_C_VAR = 6; +const unsigned char GEO_DB_EQUATION_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_EQUATION_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_EQUATION_ACTION_A_VAL = 3; +const unsigned char GEO_DB_EQUATION_ACTION_C_VAL = 4; +const unsigned char GEO_DB_EQUATION_ACTION_A_VAR = 5; +const unsigned char GEO_DB_EQUATION_ACTION_C_VAR = 6; /////////////////////////////////////////////////////////////////// // DB_DSK_PERIODIC_ACTION Record Field Ids // -const unsigned char GEO_DB_PERIODIC_ACTION_TYPE = 7; +const unsigned char GEO_DB_PERIODIC_ACTION_TYPE = 7; /////////////////////////////////////////////////////////////////// // DB_DSK_TRIG_ACTION Record Field Ids // -const unsigned char GEO_DB_TRIG_ACTION_OP = 7; +const unsigned char GEO_DB_TRIG_ACTION_OP = 7; @@ -882,39 +898,39 @@ const unsigned char GEO_DB_TRIG_ACTION_OP = 7; /////////////////////////////////////////////////////////////////// // DB_DSK_TASK_ACTION Record Field Ids // -const unsigned char GEO_DB_TASK_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_TASK_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_TASK_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_TASK_ACTION_OUTPUT_VAR = 2; /////////////////////////////////////////////////////////////////// // DB_DSK_VISIBILITY_ACTION Record Field Ids // -const unsigned char GEO_DB_VISIBILITY_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_VISIBILITY_ACTION_OUTPUT_VAR = 2; // Not used +const unsigned char GEO_DB_VISIBILITY_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_VISIBILITY_ACTION_OUTPUT_VAR = 2; // Not used /////////////////////////////////////////////////////////////////// // DB_DSK_COLOR_RAMP_ACTION Record Field Ids // -const unsigned char GEO_DB_COLOR_RAMP_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_OUTPUT_VAR = 2; // Not used -const unsigned char GEO_DB_COLOR_RAMP_ACTION_COLOR_FROM_PALETTE = 3; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR_INDEX = 4; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR_INDEX = 5; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_NUM_RAMPS = 6; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR = 7; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR = 8; -const unsigned char GEO_DB_COLOR_RAMP_ACTION_MATCH_COLUMNS = 9; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_OUTPUT_VAR = 2; // Not used +const unsigned char GEO_DB_COLOR_RAMP_ACTION_COLOR_FROM_PALETTE = 3; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR_INDEX = 4; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR_INDEX = 5; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_NUM_RAMPS = 6; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR = 7; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR = 8; +const unsigned char GEO_DB_COLOR_RAMP_ACTION_MATCH_COLUMNS = 9; /////////////////////////////////////////////////////////////////// // DB_DSK_COMPARE_ACTION Record Field Ids // -const unsigned char GEO_DB_COMPARE_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_COMPARE_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_COMPARE_ACTION_OP_TYPE = 3; +const unsigned char GEO_DB_COMPARE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_COMPARE_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_COMPARE_ACTION_OP_TYPE = 3; const unsigned char GEO_DB_COMPARE_ACTION_OPERAND_VALUE = 4; const unsigned char GEO_DB_COMPARE_ACTION_OPERAND_VAR = 5; @@ -922,56 +938,70 @@ const unsigned char GEO_DB_COMPARE_ACTION_OPERAND_VAR = 5; /////////////////////////////////////////////////////////////////// // DB_DSK_TRANSLATE_ACTION Record Field Ids // -const unsigned char GEO_DB_TRANSLATE_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_TRANSLATE_ACTION_OUTPUT_VAR = 2; // not used -const unsigned char GEO_DB_TRANSLATE_ACTION_ORIGIN = 3; -const unsigned char GEO_DB_TRANSLATE_ACTION_VECTOR = 4; -const unsigned char GEO_DB_TRANSLATE_ACTION_DIR = 5; -const unsigned char GEO_DB_TRANSLATE_ACTION_SCALAR = 6; +const unsigned char GEO_DB_TRANSLATE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_TRANSLATE_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_TRANSLATE_ACTION_ORIGIN = 3; +const unsigned char GEO_DB_TRANSLATE_ACTION_VECTOR = 4; +const unsigned char GEO_DB_TRANSLATE_ACTION_DIR = 5; +const unsigned char GEO_DB_TRANSLATE_ACTION_SCALAR = 6; + + + +/////////////////////////////////////////////////////////////////// +// DB_DSK_SCALE_ACTION Record Field Ids +// +const unsigned char GEO_DB_SCALE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_SCALE_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_SCALE_ACTION_ORIGIN = 3; +const unsigned char GEO_DB_SCALE_ACTION_VECTOR = 4; +const unsigned char GEO_DB_SCALE_ACTION_DIR = 5; +const unsigned char GEO_DB_SCALE_ACTION_SCALAR = 6; +const unsigned char GEO_DB_SCALE_ACTION_SCALE_ALL = 7; + /////////////////////////////////////////////////////////////////// // DB_DSK_STRING_CONTENT_ACTION Record Field Ids // -const unsigned char GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_STRING_CONTENT_ACTION_OUTPUT_VAR = 2; // not used -const unsigned char GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE = 3; -const unsigned char GEO_DB_STRING_CONTENT_ACTION_PAD_FOR_SIGN = 4; -const unsigned char GEO_DB_STRING_CONTENT_ACTION_FORMAT = 5; +const unsigned char GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_STRING_CONTENT_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE = 3; +const unsigned char GEO_DB_STRING_CONTENT_ACTION_PAD_FOR_SIGN = 4; +const unsigned char GEO_DB_STRING_CONTENT_ACTION_FORMAT = 5; /////////////////////////////////////////////////////////////////// // DB_DSK_STRING_COPY_ACTION Record Field Ids // -const unsigned char GEO_DB_STRING_COPY_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_STRING_COPY_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_STRING_COPY_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_STRING_COPY_ACTION_OUTPUT_VAR = 2; // not used /////////////////////////////////////////////////////////////////// // DB_DSK_CONDITIONAL_ACTION Record Field Ids // -const unsigned char GEO_DB_CONDITIONAL_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_CONDITIONAL_ACTION_INPUT_VAR = 1; const unsigned char GEO_DB_CONDITIONAL_ACTION_OUTPUT_VAR= 2; // not used /////////////////////////////////////////////////////////////////// // DB_DSK_DCS_ACTION Record Field Ids // -const unsigned char GEO_DB_DCS_ACTION_INPUT_VAR = 1; // not used -const unsigned char GEO_DB_DCS_ACTION_OUTPUT_VAR = 2; // not used -const unsigned char GEO_DB_DCS_ACTION_ORIGIN = 3; -const unsigned char GEO_DB_DCS_ACTION_XPOS = 4; -const unsigned char GEO_DB_DCS_ACTION_ZPOS = 5; -const unsigned char GEO_DB_DCS_ACTION_VECTOR = 6; -const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_X_VAR = 7; -const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_Y_VAR = 8; -const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_Z_VAR = 9; -const unsigned char GEO_DB_DCS_ACTION_ROTATE_X_VAR = 10; -const unsigned char GEO_DB_DCS_ACTION_ROTATE_Y_VAR = 11; -const unsigned char GEO_DB_DCS_ACTION_ROTATE_Z_VAR = 12; -const unsigned char GEO_DB_DCS_ACTION_SCALE_X_VAR = 13; -const unsigned char GEO_DB_DCS_ACTION_SCALE_Y_VAR = 14; -const unsigned char GEO_DB_DCS_ACTION_SCALE_Z_VAR = 15; +const unsigned char GEO_DB_DCS_ACTION_INPUT_VAR = 1; // not used +const unsigned char GEO_DB_DCS_ACTION_OUTPUT_VAR = 2; // not used +const unsigned char GEO_DB_DCS_ACTION_ORIGIN = 3; +const unsigned char GEO_DB_DCS_ACTION_XPOS = 4; +const unsigned char GEO_DB_DCS_ACTION_ZPOS = 5; +const unsigned char GEO_DB_DCS_ACTION_VECTOR = 6; +const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_X_VAR = 7; +const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_Y_VAR = 8; +const unsigned char GEO_DB_DCS_ACTION_TRANSLATE_Z_VAR = 9; +const unsigned char GEO_DB_DCS_ACTION_ROTATE_X_VAR = 10; +const unsigned char GEO_DB_DCS_ACTION_ROTATE_Y_VAR = 11; +const unsigned char GEO_DB_DCS_ACTION_ROTATE_Z_VAR = 12; +const unsigned char GEO_DB_DCS_ACTION_SCALE_X_VAR = 13; +const unsigned char GEO_DB_DCS_ACTION_SCALE_Y_VAR = 14; +const unsigned char GEO_DB_DCS_ACTION_SCALE_Z_VAR = 15; @@ -982,13 +1012,15 @@ const unsigned char GEO_DB_DCS_ACTION_SCALE_Z_VAR = 15; /////////////////////////////////////////////////////////////////// // DB_DSK_DISCRETE_ACTION Record Field Ids // -const unsigned char GEO_DB_DISCRETE_ACTION_INPUT_VAR = 1; -const unsigned char GEO_DB_DISCRETE_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_DISCRETE_ACTION_NUM_ITEMS = 3; -const unsigned char GEO_DB_DISCRETE_ACTION_OUTPUT_VAR_TYPE = 4; -const unsigned char GEO_DB_DISCRETE_ACTION_MIN_VALS = 5; -const unsigned char GEO_DB_DISCRETE_ACTION_MAX_VALS = 6; -const unsigned char GEO_DB_DISCRETE_ACTION_MAP_VALS = 7; +const unsigned char GEO_DB_DISCRETE_ACTION_INPUT_VAR = 1; +const unsigned char GEO_DB_DISCRETE_ACTION_OUTPUT_VAR = 2; +const unsigned char GEO_DB_DISCRETE_ACTION_NUM_ITEMS = 3; +const unsigned char GEO_DB_DISCRETE_ACTION_OUTPUT_VAR_TYPE = 4; +const unsigned char GEO_DB_DISCRETE_ACTION_MIN_VALS = 5; +const unsigned char GEO_DB_DISCRETE_ACTION_MAX_VALS = 6; +const unsigned char GEO_DB_DISCRETE_ACTION_MAP_VALS = 7; + + @@ -1001,41 +1033,45 @@ const unsigned char GEO_DB_DISCRETE_ACTION_MAP_VALS = 7; struct GEO_DB_API geoExtensionDefRec { - /** The Node type for which this extension exists */ - unsigned int nodetype; // 4 bytes + /** The Node type for which this extension exists */ + unsigned int nodetype; // 4 bytes - /** The data type of the extension - defined in terms of GEO_DB_EXT_INT - * GEO_DB_EXT_FLOAT, GEO_DB_EXT_BOOL etc. - */ - unsigned char datatype; // 1 byte + /** The data type of the extension - defined in terms of GEO_DB_EXT_INT + * GEO_DB_EXT_FLOAT, GEO_DB_EXT_BOOL etc. + */ + unsigned char datatype; // 1 byte - /** The extension can have a special "sub type" value. This could be - * values like GEO_DB_EXT_MENU_ITEM which (when associated with a datatype - * of GEO_DB_EXT_BOOL means that this extension will be accessed as one - * of many in an option menu - */ - unsigned char subdatatype; // 1 bytes + /** The extension can have a special "sub type" value. This could be + * values like GEO_DB_EXT_MENU_ITEM which (when associated with a datatype + * of GEO_DB_EXT_BOOL means that this extension will be accessed as one + * of many in an option menu + */ + unsigned char subdatatype; // 1 bytes - unsigned short spare; // 2 bytes + /** The User ID (uid) is the optional value provided (in code) by the user + * to identify this particular extension. Users can search & retrieve + * extension values based on this user ID number. + */ + unsigned short uid; // 2 bytes - /** The name of the extension. - * - * Note that the "name" field is sized for the Geo 1.0 maximum property - * label length that can be accomodated. The name field is also used to - * encode the name/label of the option menu when the extension is flagged - * as one of those. The following rules should be taken into consideration: - * 1. When the extension is an option menu (datatype=GEO_DB_EXT_BOOL - * and subdatatype=GEO_DB_EXT_MENU_ITEM) then the name field is - * divided up as 15 chars for the option menu title, 8 chars for - * this particular option menu's label and 1 char for the terminator - * 2. When the extension is a text field or boolean toggle value - it is - * recommended that only the 15 chars for the field label be used - - * setting a 23 char-length label for a text input field will be a - * waste of time, as it will get truncated on display anyway. - */ - char name[24]; // 24 bytes - //----------------------------- -}; // total: 32 bytes + /** The name of the extension. + * + * Note that the "name" field is sized for the Geo 1.0 maximum property + * label length that can be accomodated. The name field is also used to + * encode the name/label of the option menu when the extension is flagged + * as one of those. The following rules should be taken into consideration: + * 1. When the extension is an option menu (datatype=GEO_DB_EXT_BOOL + * and subdatatype=GEO_DB_EXT_MENU_ITEM) then the name field is + * divided up as 15 chars for the option menu title, 8 chars for + * this particular option menu's label and 1 char for the terminator + * 2. When the extension is a text field or boolean toggle value - it is + * recommended that only the 15 chars for the field label be used - + * setting a 23 char-length label for a text input field will be a + * waste of time, as it will get truncated on display anyway. + */ + char name[24]; // 24 bytes + //----------------------------- +}; // total: 32 bytes @@ -1044,15 +1080,15 @@ struct GEO_DB_API geoExtensionDefRec /////////////////////////////////////////////////////////////////// // Utility Parse/Read/Write Functions // -GEO_DB_API int geoIgnoreField(FILE* fp,geoFieldHeader field); -GEO_DB_API int geoIgnoreFields(FILE* fp); -GEO_DB_API int geoWriteString(FILE*,int, char*); -GEO_DB_API int geoWriteString(FILE* fp,char* string); -GEO_DB_API char* geoGetWritableString(char* string,int* num_chars); -GEO_DB_API char* geoReadString(FILE*,geoFieldHeader); -GEO_DB_API char* geoReadString(FILE*,int); -GEO_DB_API int geoIgnoreDataItems(FILE* fp, int type,int num ); -GEO_DB_API int geoGetSizeOfFormatDataType(int type); +GEO_DB_API int geoIgnoreField(FILE* fp,geoFieldHeader field); +GEO_DB_API int geoIgnoreFields(FILE* fp); +GEO_DB_API int geoWriteString(FILE*,int, char*); +GEO_DB_API int geoWriteString(FILE* fp,char* string); +GEO_DB_API char* geoGetWritableString(char* string,int* num_chars); +GEO_DB_API char* geoReadString(FILE*,geoFieldHeader); +GEO_DB_API char* geoReadString(FILE*,int); +GEO_DB_API int geoIgnoreDataItems(FILE* fp, int type,int num ); +GEO_DB_API int geoGetSizeOfFormatDataType(int type); #endif // __GEO_FORMAT_H__ diff --git a/src/osgPlugins/geo/geoTypes.h b/src/osgPlugins/geo/geoTypes.h index 16e30908a..b967b1685 100644 --- a/src/osgPlugins/geo/geoTypes.h +++ b/src/osgPlugins/geo/geoTypes.h @@ -1,12 +1,12 @@ /*===========================================================================*\ -NAME: geoTypes.h +NAME: geoTypes.h -DESCRIPTION: Constants fro Node types etc. +DESCRIPTION: Constants fro Node types etc. -AUTHOR: Andy Bushnell +AUTHOR: Andy Bushnell - ------------------------------------------------------------------------- + ------------------------------------------------------------------------- PROPRIETARY RIGHTS NOTICE: @@ -41,58 +41,58 @@ COPYRIGHT NOTICE: #ifndef uint -#define uint unsigned int +#define uint unsigned int #endif #ifndef ushort -//#define ushort unsigned short +//#define ushort unsigned short #endif #ifndef ubyte -#define ubyte unsigned char +#define ubyte unsigned char #endif - + /** * constants to identify the plugin type */ -const uint GEO_PLUGIN_TYPE_UNDEFINED = 1; -const uint GEO_PLUGIN_TYPE_GEOMETRY_IMPORTER = 2; -const uint GEO_PLUGIN_TYPE_GEOMETRY_EXPORTER = 3; -const uint GEO_PLUGIN_TYPE_IMAGE_IMPORTER = 4; -const uint GEO_PLUGIN_TYPE_TOOL = 5; -const uint GEO_PLUGIN_TYPE_BEHAVIOR = 6; -const uint GEO_PLUGIN_TYPE_GROUP_NODE_DEF = 7; -const uint GEO_PLUGIN_TYPE_LAST = GEO_PLUGIN_TYPE_GROUP_NODE_DEF; +const uint GEO_PLUGIN_TYPE_UNDEFINED = 1; +const uint GEO_PLUGIN_TYPE_GEOMETRY_IMPORTER = 2; +const uint GEO_PLUGIN_TYPE_GEOMETRY_EXPORTER = 3; +const uint GEO_PLUGIN_TYPE_IMAGE_IMPORTER = 4; +const uint GEO_PLUGIN_TYPE_TOOL = 5; +const uint GEO_PLUGIN_TYPE_BEHAVIOR = 6; +const uint GEO_PLUGIN_TYPE_GROUP_NODE_DEF = 7; +const uint GEO_PLUGIN_TYPE_LAST = GEO_PLUGIN_TYPE_GROUP_NODE_DEF; - + /** user tool constant - put in favorites menu & toolbar */ -const uint GEO_TOOL_TYPE_USER = 1; +const uint GEO_TOOL_TYPE_USER = 1; /** create tool constant - put in create menu & toolbar */ -const uint GEO_TOOL_TYPE_CREATE = 2; +const uint GEO_TOOL_TYPE_CREATE = 2; /** modify tool constant - put in modify menu & toolbar */ -const uint GEO_TOOL_TYPE_MODIFY = 3; +const uint GEO_TOOL_TYPE_MODIFY = 3; /** helper point tool constant - put in helpers menu & toolbar */ -const uint GEO_TOOL_TYPE_HELPER_PT = 4; +const uint GEO_TOOL_TYPE_HELPER_PT = 4; /** appearance tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_APPEARANCE = 5; +const uint GEO_TOOL_TYPE_APPEARANCE = 5; /** behavior tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_BEHAVIOR = 6; +const uint GEO_TOOL_TYPE_BEHAVIOR = 6; /** behavior tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_OPTIMIZE = 7; +const uint GEO_TOOL_TYPE_OPTIMIZE = 7; /** convenience constant */ -const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE; +const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE; @@ -102,155 +102,155 @@ const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE; * * The GEO Node Type Class Hierarchy is as follows... * - * GEO_DB_BASE - * GEO_DB_GROUP - * GEO_DB_BILLBOARD - * GEO_DB_SEQUENCE - * GEO_DB_LOD - * GEO_DB_SWITCH - * GEO_DB_RENDERGROUP - * GEO_DB_BASE_GROUP - * GEO_DB_EXTERNAL - * GEO_DB_INSTANCE - * GEO_DB_PAGE - * GEO_DB_TRANSFORM (*) - * GEO_DB_GEOMETRY - * GEO_DB_SURFACE - * GEO_DB_COORDINATE_SURFACE - * GEO_DB_POLYGON - * GEO_DB_LIGHTPT - * GEO_DB_MESH (*) - * GEO_DB_PARAMETRIC_SURFACE (*) - * GEO_DB_QUADRIC (*) - * GEO_DB_TEXT - * GEO_DB_BASE_SURFACE (*) - * GEO_DB_VERTEX - * GEO_DB_HEADER + * GEO_DB_BASE + * GEO_DB_GROUP + * GEO_DB_BILLBOARD + * GEO_DB_SEQUENCE + * GEO_DB_LOD + * GEO_DB_SWITCH + * GEO_DB_RENDERGROUP + * GEO_DB_BASE_GROUP + * GEO_DB_EXTERNAL + * GEO_DB_INSTANCE + * GEO_DB_PAGE + * GEO_DB_TRANSFORM (*) + * GEO_DB_GEOMETRY + * GEO_DB_SURFACE + * GEO_DB_COORDINATE_SURFACE + * GEO_DB_POLYGON + * GEO_DB_LIGHTPT + * GEO_DB_MESH (*) + * GEO_DB_PARAMETRIC_SURFACE (*) + * GEO_DB_QUADRIC (*) + * GEO_DB_TEXT + * GEO_DB_BASE_SURFACE (*) + * GEO_DB_VERTEX + * GEO_DB_HEADER * * (*) Not available in Geo Version 1.0 */ -const uint GEO_DB_BASE = 0x00000003; -const uint GEO_DB_GROUP = (0x00000004 | GEO_DB_BASE); -const uint GEO_DB_SEQUENCE = (0x00000010 | GEO_DB_GROUP); -const uint GEO_DB_LOD = (0x00000020 | GEO_DB_GROUP); -const uint GEO_DB_SWITCH = (0x00000040 | GEO_DB_GROUP); -const uint GEO_DB_RENDERGROUP = (0x00000080 | GEO_DB_GROUP); -const uint GEO_DB_GEOMETRY = (0x00000100 | GEO_DB_BASE); -const uint GEO_DB_SURFACE = (0x00000200 | GEO_DB_GEOMETRY); -const uint GEO_DB_COORDINATE_SURFACE = (0x00000400 | GEO_DB_SURFACE); -const uint GEO_DB_POLYGON = (0x00000800 | GEO_DB_COORDINATE_SURFACE); -const uint GEO_DB_MESH = (0x00001000 | GEO_DB_POLYGON); -const uint GEO_DB_PARAMETRIC_SURFACE = (0x00002000 | GEO_DB_SURFACE); -const uint GEO_DB_QUADRIC = (0x00004000 | GEO_DB_PARAMETRIC_SURFACE); -const uint GEO_DB_PAGE = (0x00008000 | GEO_DB_GROUP); -const uint GEO_DB_TEXT = (0x00040000 | GEO_DB_SURFACE); -const uint GEO_DB_VERTEX = (0x00080000 | GEO_DB_GEOMETRY); -const uint GEO_DB_HEADER = (0x00100000 | GEO_DB_BASE); -const uint GEO_DB_TRANSFORM = (0x00200000 | GEO_DB_GROUP); -const uint GEO_DB_BASE_GROUP = (0x00400000 | GEO_DB_GROUP); -const uint GEO_DB_BASE_SURFACE = (0x00800000 | GEO_DB_SURFACE); -const uint GEO_DB_EXTERNAL = (0x01000000 | GEO_DB_GROUP); -const uint GEO_DB_INSTANCE = (0x04000000 | GEO_DB_GROUP); -const uint GEO_DB_LIGHTPT = (0x08000000 | GEO_DB_POLYGON); +const uint GEO_DB_BASE = 0x00000003; +const uint GEO_DB_GROUP = (0x00000004 | GEO_DB_BASE); +const uint GEO_DB_SEQUENCE = (0x00000010 | GEO_DB_GROUP); +const uint GEO_DB_LOD = (0x00000020 | GEO_DB_GROUP); +const uint GEO_DB_SWITCH = (0x00000040 | GEO_DB_GROUP); +const uint GEO_DB_RENDERGROUP = (0x00000080 | GEO_DB_GROUP); +const uint GEO_DB_GEOMETRY = (0x00000100 | GEO_DB_BASE); +const uint GEO_DB_SURFACE = (0x00000200 | GEO_DB_GEOMETRY); +const uint GEO_DB_COORDINATE_SURFACE = (0x00000400 | GEO_DB_SURFACE); +const uint GEO_DB_POLYGON = (0x00000800 | GEO_DB_COORDINATE_SURFACE); +const uint GEO_DB_MESH = (0x00001000 | GEO_DB_POLYGON); +const uint GEO_DB_PARAMETRIC_SURFACE = (0x00002000 | GEO_DB_SURFACE); +const uint GEO_DB_QUADRIC = (0x00004000 | GEO_DB_PARAMETRIC_SURFACE); +const uint GEO_DB_PAGE = (0x00008000 | GEO_DB_GROUP); +const uint GEO_DB_TEXT = (0x00040000 | GEO_DB_SURFACE); +const uint GEO_DB_VERTEX = (0x00080000 | GEO_DB_GEOMETRY); +const uint GEO_DB_HEADER = (0x00100000 | GEO_DB_BASE); +const uint GEO_DB_TRANSFORM = (0x00200000 | GEO_DB_GROUP); +const uint GEO_DB_BASE_GROUP = (0x00400000 | GEO_DB_GROUP); +const uint GEO_DB_BASE_SURFACE = (0x00800000 | GEO_DB_SURFACE); +const uint GEO_DB_EXTERNAL = (0x01000000 | GEO_DB_GROUP); +const uint GEO_DB_INSTANCE = (0x04000000 | GEO_DB_GROUP); +const uint GEO_DB_LIGHTPT = (0x08000000 | GEO_DB_POLYGON); // older version types for Compatability & convenience // -const uint GEO_DB_ALL = GEO_DB_BASE; -const uint GEO_DB_ALL_GROUP_TYPES = GEO_DB_GROUP; -const uint GEO_DB_ALL_SURFACE_TYPES = GEO_DB_SURFACE; -const uint GEO_DB_ALL_SHAPE_TYPES = GEO_DB_PARAMETRIC_SURFACE; -const uint GEO_DB_ALL_GEOMETRY_TYPES = GEO_DB_GEOMETRY; +const uint GEO_DB_ALL = GEO_DB_BASE; +const uint GEO_DB_ALL_GROUP_TYPES = GEO_DB_GROUP; +const uint GEO_DB_ALL_SURFACE_TYPES = GEO_DB_SURFACE; +const uint GEO_DB_ALL_SHAPE_TYPES = GEO_DB_PARAMETRIC_SURFACE; +const uint GEO_DB_ALL_GEOMETRY_TYPES = GEO_DB_GEOMETRY; - -/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// /** constants to identify the type of picking to be done */ -const uint GEO_PICK_GROUP = 0x00000001; -const uint GEO_PICK_PRIM = 0x00000002; -const uint GEO_PICK_VERTEX = 0x00000004; -const uint GEO_PICK_EDGE = 0x00000008; // Future -const uint GEO_PICK_GRID = 0x00000010; -const uint GEO_PICK_NON_NODE = 0x00000020; // manipulators, user geometry etc. -const uint GEO_PICK_EXTERNAL = 0x00000040; +const uint GEO_PICK_GROUP = 0x00000001; +const uint GEO_PICK_PRIM = 0x00000002; +const uint GEO_PICK_VERTEX = 0x00000004; +const uint GEO_PICK_EDGE = 0x00000008; // Future +const uint GEO_PICK_GRID = 0x00000010; +const uint GEO_PICK_NON_NODE = 0x00000020; // manipulators, user geometry etc. +const uint GEO_PICK_EXTERNAL = 0x00000040; -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// /** constants to identify mouse button usage */ -const uint GEO_NO_MOUSE = 0x00000000; -const uint GEO_LEFT_MOUSE = 0x00000001; -const uint GEO_MIDDLE_MOUSE = 0x00000002; -const uint GEO_RIGHT_MOUSE = 0x00000004; -const uint GEO_LEFT_AND_RIGHT_MOUSE = 0x00000008; -const uint GEO_MIDDLE_AND_RIGHT_MOUSE = 0x00000010; +const uint GEO_NO_MOUSE = 0x00000000; +const uint GEO_LEFT_MOUSE = 0x00000001; +const uint GEO_MIDDLE_MOUSE = 0x00000002; +const uint GEO_RIGHT_MOUSE = 0x00000004; +const uint GEO_LEFT_AND_RIGHT_MOUSE = 0x00000008; +const uint GEO_MIDDLE_AND_RIGHT_MOUSE = 0x00000010; -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// /** Predefined model unit identifier. database model units can be modified * via set/getUnits */ -const uint GEO_DB_INCHES = 1; -const uint GEO_DB_FEET = 2; -const uint GEO_DB_YARDS = 3; -const uint GEO_DB_MILES = 4; -const uint GEO_DB_CENTIMETERS = 5; -const uint GEO_DB_METERS = 6; -const uint GEO_DB_KILOMETERS = 7; +const uint GEO_DB_INCHES = 1; +const uint GEO_DB_FEET = 2; +const uint GEO_DB_YARDS = 3; +const uint GEO_DB_MILES = 4; +const uint GEO_DB_CENTIMETERS = 5; +const uint GEO_DB_METERS = 6; +const uint GEO_DB_KILOMETERS = 7; - -/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// /** Constants to define the modeler's intended "up" direction if that * makes any sense */ - -const int GEO_DB_UP_AXIS_X = 1; -const int GEO_DB_UP_AXIS_Y = 2; // the default -const int GEO_DB_UP_AXIS_Z = 3; + +const int GEO_DB_UP_AXIS_X = 1; +const int GEO_DB_UP_AXIS_Y = 2; // the default +const int GEO_DB_UP_AXIS_Z = 3; -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// /** Constants to control the drawing effect * * Constants to control the drawing of geometry primitives - usefull if user * wants to call standard draw method in a tool postDraw callback */ -const uint GEO_DB_SOLID = 0x00000001; -const uint GEO_DB_WIRE = 0x00000002; -const uint GEO_DB_OUTLINED = 0x00000008; +const uint GEO_DB_SOLID = 0x00000001; +const uint GEO_DB_WIRE = 0x00000002; +const uint GEO_DB_OUTLINED = 0x00000008; -const uint GEO_DB_ZBUFFER = 0x00000100; -const uint GEO_DB_BACKFACE = 0x00000400; +const uint GEO_DB_ZBUFFER = 0x00000100; +const uint GEO_DB_BACKFACE = 0x00000400; -const uint GEO_DB_DRAW_FACE_NORMALS = 0x00001000; -const uint GEO_DB_DRAW_VERTEX_NORMALS = 0x00002000; +const uint GEO_DB_DRAW_FACE_NORMALS = 0x00001000; +const uint GEO_DB_DRAW_VERTEX_NORMALS = 0x00002000; -const uint GEO_DB_TEXTURE = 0x00010000; -const uint GEO_DB_HIGHLIGHT = 0x00020000; -const uint GEO_DB_PICKING = 0x00040000; -const uint GEO_DB_HIGHLIGHT_DASHED = 0x00080000; +const uint GEO_DB_TEXTURE = 0x00010000; +const uint GEO_DB_HIGHLIGHT = 0x00020000; +const uint GEO_DB_PICKING = 0x00040000; +const uint GEO_DB_HIGHLIGHT_DASHED = 0x00080000; -const uint GEO_DB_ILLUMINATED = 0x01000000; -const uint GEO_DB_NORMAL_PER_PRIM = 0x04000000; -const uint GEO_DB_NORMAL_PER_VERTEX = 0x08000000; +const uint GEO_DB_ILLUMINATED = 0x01000000; +const uint GEO_DB_NORMAL_PER_PRIM = 0x04000000; +const uint GEO_DB_NORMAL_PER_VERTEX = 0x08000000; -const uint GEO_DB_COLOR_PER_GEODE = 0x10000000; -const uint GEO_DB_COLOR_PER_PRIM = 0x20000000; -const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000; +const uint GEO_DB_COLOR_PER_GEODE = 0x10000000; +const uint GEO_DB_COLOR_PER_PRIM = 0x20000000; +const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000; -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// /** Constants to control the switch Node behavior * * Switch Nodes can either be addative (in which case the @@ -259,16 +259,16 @@ const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000; * * Selctive control is not implemented. */ -const uint GEO_SWITCH_TYPE_ADDATIVE = 1; -const uint GEO_SWITCH_TYPE_SELECTIVE = 2; +const uint GEO_SWITCH_TYPE_ADDATIVE = 1; +const uint GEO_SWITCH_TYPE_SELECTIVE = 2; /////////////////////////////////////////////////////////////////////////////// /** Type Tokens for Node & Tool Gui Widgets */ -const int GUI_FLOAT = 1; -const int GUI_INT = 2; -const int GUI_STRING = 3; +const int GUI_FLOAT = 1; +const int GUI_INT = 2; +const int GUI_STRING = 3; /////////////////////////////////////////////////////////////////////////////// @@ -278,19 +278,19 @@ typedef void geoWidget; /////////////////////////////////////////////////////////////////////////////// /** Animated String padding tokens */ -const int GEO_TEXT_PAD_NONE = 0; -const int GEO_TEXT_PAD_WITH_SPACES = 1; -const int GEO_TEXT_PAD_WITH_ZEROES = 2; +const int GEO_TEXT_PAD_NONE = 0; +const int GEO_TEXT_PAD_WITH_SPACES = 1; +const int GEO_TEXT_PAD_WITH_ZEROES = 2; /////////////////////////////////////////////////////////////////////////////// // Polygon draw style types // -const int GEO_POLY_DSTYLE_SOLID = 0; -const int GEO_POLY_DSTYLE_OPEN_WIRE = 1; -const int GEO_POLY_DSTYLE_CLOSED_WIRE = 2; -const int GEO_POLY_DSTYLE_POINTS = 3; -const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4; +const int GEO_POLY_DSTYLE_SOLID = 0; +const int GEO_POLY_DSTYLE_OPEN_WIRE = 1; +const int GEO_POLY_DSTYLE_CLOSED_WIRE = 2; +const int GEO_POLY_DSTYLE_POINTS = 3; +const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4; @@ -298,63 +298,63 @@ const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4; // Polygon shade style types // -const int GEO_POLY_SHADEMODEL_FLAT = 0; -const int GEO_POLY_SHADEMODEL_GOURAUD = 1; -const int GEO_POLY_SHADEMODEL_LIT = 2; -const int GEO_POLY_SHADEMODEL_LIT_GOURAUD = 3; +const int GEO_POLY_SHADEMODEL_FLAT = 0; +const int GEO_POLY_SHADEMODEL_GOURAUD = 1; +const int GEO_POLY_SHADEMODEL_LIT = 2; +const int GEO_POLY_SHADEMODEL_LIT_GOURAUD = 3; /////////////////////////////////////////////////////////////////////////////// // Texture Mapping types // -const int GEO_POLY_PLANAR_MAP = 0; -const int GEO_POLY_CYLINDRICAL_MAP = 1; -const int GEO_POLY_SPHERICAL_MAP = 2; +const int GEO_POLY_PLANAR_MAP = 0; +const int GEO_POLY_CYLINDRICAL_MAP = 1; +const int GEO_POLY_SPHERICAL_MAP = 2; /////////////////////////////////////////////////////////////////////////////// // STring type constants // -const int GEO_TEXT_RASTER = 0; -const int GEO_TEXT_STROKE = 1; +const int GEO_TEXT_RASTER = 0; +const int GEO_TEXT_STROKE = 1; /////////////////////////////////////////////////////////////////////////////// // Justification constants // -const int GEO_TEXT_LEFT_JUSTIFY = 0; -const int GEO_TEXT_CENTER_JUSTIFY = 1; -const int GEO_TEXT_RIGHT_JUSTIFY = 2; +const int GEO_TEXT_LEFT_JUSTIFY = 0; +const int GEO_TEXT_CENTER_JUSTIFY = 1; +const int GEO_TEXT_RIGHT_JUSTIFY = 2; /////////////////////////////////////////////////////////////////////////////// // Direction constants // -const int GEO_TEXT_LEFT_TO_RIGHT = 0; -const int GEO_TEXT_RIGHT_TO_LEFT = 1; -const int GEO_TEXT_TOP_TO_BOTTOM = 2; -const int GEO_TEXT_BOTTOM_TO_TOP = 3; +const int GEO_TEXT_LEFT_TO_RIGHT = 0; +const int GEO_TEXT_RIGHT_TO_LEFT = 1; +const int GEO_TEXT_TOP_TO_BOTTOM = 2; +const int GEO_TEXT_BOTTOM_TO_TOP = 3; /////////////////////////////////////////////////////////////////////////////// // LightPoint Type constants // -const int GEO_DB_LIGHTPT_OMNI_DIRECTIONAL = 0; -const int GEO_DB_LIGHTPT_UNI_DIRECTIONAL = 1; -const int GEO_DB_LIGHTPT_BI_DIRECTIONAL = 2; +const int GEO_DB_LIGHTPT_OMNI_DIRECTIONAL = 0; +const int GEO_DB_LIGHTPT_UNI_DIRECTIONAL = 1; +const int GEO_DB_LIGHTPT_BI_DIRECTIONAL = 2; /////////////////////////////////////////////////////////////////////////////// // Texture Record Wrap S & T Modes -const unsigned GEO_DB_TEX_CLAMP = 0x00000001; -const unsigned GEO_DB_TEX_REPEAT = 0x00000002; +const unsigned GEO_DB_TEX_CLAMP = 0x00000001; +const unsigned GEO_DB_TEX_REPEAT = 0x00000002; /////////////////////////////////////////////////////////////////////////////// // Texture Record MagFilter -const unsigned GEO_DB_TEX_NEAREST = 0x00000001; -const unsigned GEO_DB_TEX_LINEAR = 0x00000002; +const unsigned GEO_DB_TEX_NEAREST = 0x00000001; +const unsigned GEO_DB_TEX_LINEAR = 0x00000002; /////////////////////////////////////////////////////////////////////////////// @@ -367,9 +367,9 @@ const unsigned GEO_DB_TEX_LINEAR_MIPMAP_LINEAR = 0x00000020; /////////////////////////////////////////////////////////////////////////////// // Texture Record TexEnv -const unsigned GEO_DB_TEX_MODULATE = 0x00000001; -const unsigned GEO_DB_TEX_DECAL = 0x00000002; -const unsigned GEO_DB_TEX_BLEND = 0x00000004; +const unsigned GEO_DB_TEX_MODULATE = 0x00000001; +const unsigned GEO_DB_TEX_DECAL = 0x00000002; +const unsigned GEO_DB_TEX_BLEND = 0x00000004; diff --git a/src/osgPlugins/geo/geoUnits.h b/src/osgPlugins/geo/geoUnits.h index 835f87ff3..0fc32a4c4 100644 --- a/src/osgPlugins/geo/geoUnits.h +++ b/src/osgPlugins/geo/geoUnits.h @@ -1,16 +1,16 @@ /*===========================================================================*\ -NAME: geoUnits.h +NAME: geoUnits.h -DESCRIPTION: Constants to convert coordinate data to/from meters (Geo - default) +DESCRIPTION: Constants to convert coordinate data to/from meters (Geo + default) -AUTHOR: Andy Bushnell +AUTHOR: Andy Bushnell - ------------------------------------------------------------------------- + ------------------------------------------------------------------------- PROPRIETARY RIGHTS NOTICE: - + This software contains proprietary information and trade secrets of Carbon Graphics LLC. No part or all of this software may be reproduced in any form, without the written permission of Carbon Graphics LLC. @@ -40,34 +40,34 @@ COPYRIGHT NOTICE: #define _GEO_UNITS_H_ -const float KM_TO_METERS = 1000.0f; -const float CM_TO_METERS = 0.01f; -const float MM_TO_METERS = 0.001f; -const float NM_TO_METERS = 1852.0f; -const float MILES_TO_METERS = 1609.344f; -const float YARDS_TO_METERS = 0.9144f; -const float FEET_TO_METERS = 0.3048f; -const float INCHES_TO_METERS= 0.0254f; +const float KM_TO_METERS = 1000.0f; +const float CM_TO_METERS = 0.01f; +const float MM_TO_METERS = 0.001f; +const float NM_TO_METERS = 1852.0f; +const float MILES_TO_METERS = 1609.344f; +const float YARDS_TO_METERS = 0.9144f; +const float FEET_TO_METERS = 0.3048f; +const float INCHES_TO_METERS= 0.0254f; -const float METERS_TO_KM = 0.001f; -const float METERS_TO_CM = 100.0f; -const float METERS_TO_MM = 1000.0f; -const float METERS_TO_NM = 0.0005399568035f; -const float METERS_TO_MILES = 0.0006213711922f; -const float METERS_TO_YARDS = 1.093613298f; -const float METERS_TO_FEET = 3.280839895f; -const float METERS_TO_INCHES= 39.37007874f; +const float METERS_TO_KM = 0.001f; +const float METERS_TO_CM = 100.0f; +const float METERS_TO_MM = 1000.0f; +const float METERS_TO_NM = 0.0005399568035f; +const float METERS_TO_MILES = 0.0006213711922f; +const float METERS_TO_YARDS = 1.093613298f; +const float METERS_TO_FEET = 3.280839895f; +const float METERS_TO_INCHES= 39.37007874f; -const float CM_TO_FEET = 0.03280839895f; -const float CM_TO_INCHES = 0.3937007874f; -const float FEET_TO_YARDS = 0.333333333f; -const float FEET_TO_CM = 30.48f; -const float FEET_TO_INCHES = 12.0f; -const float INCHES_TO_FEET = 0.083333333f; -const float INCHES_TO_CM = 2.54f; +const float CM_TO_FEET = 0.03280839895f; +const float CM_TO_INCHES = 0.3937007874f; +const float FEET_TO_YARDS = 0.333333333f; +const float FEET_TO_CM = 30.48f; +const float FEET_TO_INCHES = 12.0f; +const float INCHES_TO_FEET = 0.083333333f; +const float INCHES_TO_CM = 2.54f; -const float MPH_TO_FPS = 1.4667f; -const float MPH_TO_MPS = 0.447f; +const float MPH_TO_FPS = 1.4667f; +const float MPH_TO_MPS = 0.447f; diff --git a/src/osgPlugins/geo/osgGeoAction.h b/src/osgPlugins/geo/osgGeoAction.h new file mode 100644 index 000000000..7097b6bd3 --- /dev/null +++ b/src/osgPlugins/geo/osgGeoAction.h @@ -0,0 +1,292 @@ +// geo actions header + +#ifndef _GEO_ACTIONS_H_ +#define _GEO_ACTIONS_H_ + +using namespace osg; +using namespace osgDB; + +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. +// The values are defined in osgGeoStructs.h which is distributed with OSG. + +class geoBehaviour { // base class for action & math functions where var out = f(var in) +public: + geoBehaviour() { } + virtual ~geoBehaviour() { } + virtual void doaction(void) const + { // do math or action operation + } +protected: +}; + +class geoBehaviourDrawableCB: public osg::Drawable::AppCallback { +public: + geoBehaviourDrawableCB() { } + ~geoBehaviourDrawableCB() { } + void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);} + void app(osg::NodeVisitor *,osg::Drawable *dr); +private: + std::vector gblist; +}; + +class geoMathBehaviour : public geoBehaviour { // base class for math functions where var out = f(var in) +public: + geoMathBehaviour() { in=out=NULL; } + virtual ~geoMathBehaviour() { } + virtual void setInVar(const double *indvar) {in=indvar;} + virtual void setOutVar(double *outdvar) {out=outdvar;} + virtual void doaction(void) const + { // do math operation eg *out=*in or =f(*in). + } +protected: + const double *in; // address of input variable + double *out; // address of output +}; + +// in these functions, var1 is the input value x, var2 (& 3) are constants. +inline double DEG2RAD(const double var) { return var*0.0174532925199432957692369076848861; } +inline double addv(const double var1,const double var2) { return var1+var2; } +inline double subv(const double var1,const double var2) { return var1-var2; } +inline double mulv(const double var1,const double var2) { return var1*var2; } +inline double divv(const double var1,const double var2) { return var1/var2; } +inline double equa(const double var1,const double var2) { return var1; } +inline double linear(const double var1,const double var2,const double var3) { return var2*var1+var3; } +inline double lininv(const double var1,const double var2,const double var3) { return var2/var1+var3; } +inline double linmod(const double var1,const double var2,const double var3) { return var2*fmod(var1,var3); } +inline double linsqr(const double var1,const double var2,const double var3) { return var2*sqrt(var1)+var3; } +inline double linabs(const double var1,const double var2,const double var3) { return var1*fmod(var2,var3); } +inline double trunc(const double var1,const double var2,const double var3) { return ((int)(var1/var2)+var3); } +inline double trigsin(const double var1,const double var2,const double var3) { return var2*sin(DEG2RAD(var1*var3)); } +inline double trigcos(const double var1,const double var2,const double var3) { return var2*cos(DEG2RAD(var1*var3)); } +inline double trigtan(const double var1,const double var2,const double var3) { return var2*tan(DEG2RAD(var1*var3)); } +inline double trigasin(const double var1,const double var2,const double var3) { return var2*asin(var1*var3); } +inline double trigacos(const double var1,const double var2,const double var3) { return var2*acos(var1*var3); } +inline double trigatan(const double var1,const double var2,const double var3) { return var2*atan(var1*var3); } +inline double trigatan2(const double var1,const double var2,const double var3) { return var2*atan2(var1,var3); } +inline double trighypot(const double var1,const double var2,const double var3) { return var2*hypot(var1,var3); } +inline double period_1(const double var1,const double var2,const double var3) { return var2*fmod(var1,var3); } +inline double period_2(const double var1,const double var2,const double var3) { return fmod(var1*var2,var3); } +inline double ifelse(const double var1,const double var2,const double var3) { return ((var1<1.0 && var1>-1.0) ? var2:var3); } + +class geoArithConstant { // a constant can be a fixed double OR address of variable +public: + geoArithConstant(const float v=0) { constant=v; varop=NULL; } + virtual ~geoArithConstant() {} + void set(const float v) { constant=v; varop=NULL; } + bool set(const double *v) { varop=v; return (v!=NULL);} + inline double get(void) const { return varop? *varop : constant;} +private: + float constant; + const double *varop; // if null use constant value in maths; else +}; + +class geoArithBehaviour : public geoMathBehaviour { +public: + geoArithBehaviour() { op=NULL; } + virtual ~geoArithBehaviour() { } + void setType(uint iop); + bool setVariable(const double *varvar) { return acon.set(varvar);} + void setConstant(float v) {acon.set(v); } + inline double getconstant(void) { return acon.get();} + void doaction(void) const; // do math operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); +private: + double (* op)(const double d1, const double v2); + geoArithConstant acon; +}; + +class geoAr3Behaviour : public geoArithBehaviour { // extended to 3 constants, out=f(a,b,c) +public: + geoAr3Behaviour() { op=NULL; } + virtual ~geoAr3Behaviour() { } + + void setType(uint iact); + void setTrigType(int iop); + void setPeriodicType(int iop); + + void doaction(void); // do math operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act); +private: + geoArithConstant bcon; + double (* op)(const double d1, const double v2, const double v3); +}; +class geoCompareBehaviour : public geoMathBehaviour { +public: + geoCompareBehaviour() { constant=0; oper=UNKNOWN; varop=NULL;} + virtual ~geoCompareBehaviour() { } + enum optype{UNKNOWN, GREATER, GREATOREQ, LESS, LESSOREQ, EQUALTO}; +// void setConstant(const float v) { constant=v;} + void setType(uint iop); + void setVariable(const double *varvar) { varop=varvar;} + + void doaction(void) const; // do compare operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); +private: + float constant; + optype oper; + const double *varop; // if null use constant value in maths; else +}; + +class geoRangeBehaviour :public geoMathBehaviour { + // output = outmin + frac*(outmax-min) where frac = (in-min)/(max-min) +public: + geoRangeBehaviour() { inmin=outmin=(float)-1.e32; inmax=outmax=(float)1.e32; in=out=NULL;} + ~geoRangeBehaviour() { } + void setInMax(const double v) { inmax=v;} + void setInMin(const double v) { inmin=v;} + void setOutMax(const double v) { outmax=v;} + void setOutMin(const double v) { outmin=v;} + void doaction(void) const; // do math operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); +private: + float inmin,inmax; + float outmin,outmax; +}; +class geoClampBehaviour :public geoMathBehaviour { +public: + geoClampBehaviour() { min=(float)-1.e32; max=(float)1.e32; in=out=NULL;} + ~geoClampBehaviour() { } + void setMax(const double v) { max=v;} + void setMin(const double v) { min=v;} + void doaction(void) const; // do math operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); +private: + float min,max; +}; +class geoRange { // discrete range -- min,max,output +public: + geoRange() { min.set(0.0); max.set(0.0); val.set(0.0);} + virtual ~geoRange() {} + inline void setMin(const float v) { min.set(v);} + inline void setMax(const float v) { max.set(v);} + inline void setVal(const float v) { val.set(v);} + const double getMin(void) const { return min.get();} + const double getMax(void) const { return max.get();} + const double getVal(void) const { return val.get();} +private: + geoArithConstant min,max,val; +}; +class geoDiscreteBehaviour : public geoMathBehaviour { // discrete action -- output= 1 of several +public: + geoDiscreteBehaviour() {nrange=1; } + virtual ~geoDiscreteBehaviour() {} + void doaction(void) const; // do math operation + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); + +private: + int nrange; + std::vector rangelist; +}; + + +class geoActionBehaviour : public geoBehaviour { // base class for any scenegraph changes +public: + geoActionBehaviour() { var=NULL; type=0;} + virtual ~geoActionBehaviour() { + var=NULL;} + void setType(const unsigned int t) { type=t; } + void setVar(const double *v) { var=v;} + inline unsigned int getType(void) const { return type;} + inline const double *getVar(void) const { return var;} + inline double getValue(void) const { return *var;} + virtual void doaction(osg::Node *node) const { + } + + virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) { + return true; + } +private: + // for fast transform behaviours + unsigned int type; // eg GEO_DB_ROTATE_ACTION_INPUT_VAR, translate etc + const double *var; // variable controls this behaviour +}; +class geoMoveBehaviour : public geoActionBehaviour { // class of rotate & translate actions +public: + geoMoveBehaviour() { axis.set(0,0,1); centre.set(0,0,0);} + virtual ~geoMoveBehaviour() { } + void setCentre(const Vec3 v) { centre=v;} + void setAxis(const Vec3 v) { axis=v;} + inline Vec3 getAxis() { return axis;} + inline Vec3 getCentre() { return centre;} + void doaction(osg::Node *node); + + bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act); +private: + // for fast transform behaviours + osg::Vec3 axis; // axis of rotation or translate or scale + osg::Vec3 centre; // centre of rotation or scale +}; +class geoMoveVertexBehaviour : public geoActionBehaviour { // class of rotate & translate vertex actions +public: + geoMoveVertexBehaviour() { index=0; pos.set(0,0,0);} + virtual ~geoMoveVertexBehaviour() { } + inline Vec3 getpos() { return pos;} + void setpos(const osg::Vec3 p) { pos=p;} + void setindx(const int idx) { index=idx;} + inline int getindex(void) const { return index;} + void doaction(Matrix &mtr,osg::Drawable *dr); + + bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act); +private: + // for fast transform behaviours + int index; // which index in the geometry + Vec3 pos; // raw position of the vertex + geoMoveBehaviour movb; +}; + +class geoVisibBehaviour : public geoActionBehaviour { // visibility action -- sets node mask +public: + geoVisibBehaviour() { } + virtual ~geoVisibBehaviour() { } + + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act); + void doaction(osg::Node *node) const; +private: +}; +class geoColourBehaviour : public geoActionBehaviour { // colour action + // sets content of case DB_DSK_COLOR_RAMP_ACTION +public: + geoColourBehaviour() { topcindx=4096; botcindx=0; numramps=1; type=UNKNOWN; colours=NULL;} + virtual ~geoColourBehaviour() { } + enum cacts {UNKNOWN, PALETTE, RAMP}; + bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader); + void doaction(osg::Drawable *dr) const; + void setVertIndices(const uint ns, const uint n) { nstart=ns; nend=ns+n;} + void setColorPalette(const colourPalette *color_palette) {colours=color_palette;} +private: + uint numramps; + uint topcindx,botcindx; // top & bottom colour indices + cacts type; // + uint nstart,nend; // start index in the colours array, and number of indices + const colourPalette *colours; // where the colours come from - actually held in the geoHeader structure +}; + +class geoStrContentBehaviour : public geoActionBehaviour { // string content actions + // sets content of a string... +public: + geoStrContentBehaviour() {format=NULL;PADDING_TYPE=0; + PAD_FOR_SIGN=0; vt=UNKNOWN; } + virtual ~geoStrContentBehaviour() { delete [] format;} + void doaction(osg::Drawable *node); // do new text + bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); + enum valuetype {UNKNOWN, INT, FLOAT, DOUBLE, CHAR}; +private: + char *format; + uint PADDING_TYPE; + uint PAD_FOR_SIGN; + valuetype vt; +}; + +class geoBehaviourCB: public osg::NodeCallback { +public: + geoBehaviourCB() { } + ~geoBehaviourCB() { } + void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);} + virtual void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv); +private: + std::vector gblist; +}; + + +#endif diff --git a/src/osgPlugins/geo/osgGeoAnimation.h b/src/osgPlugins/geo/osgGeoAnimation.h index 6c3d6bbed..90beeed44 100644 --- a/src/osgPlugins/geo/osgGeoAnimation.h +++ b/src/osgPlugins/geo/osgGeoAnimation.h @@ -1,163 +1,52 @@ // animation features of the CarbonGraphics .geo format -// require access to the internal Vars & External Vars. +// 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 +// all teh variables (external variables, internal variables & user variables). + +// 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. + #ifndef _GEO_ANIM_H_ #define _GEO_ANIM_H_ -#include #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. -// 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 (v::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 -}; - -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); - } - } -private: - 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;} - -protected: - - 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! + geoHeader() { + uvarupdate=NULL; extvarupdate=NULL; + }; + ~geoHeader() {} + void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) ) + { // pass the address of a user written function in the App process. + uvarupdate=ufn; + } + void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) ) + { // pass the address of a user written function in the App process. + 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: }; #endif diff --git a/src/osgPlugins/geo/osgGeoNodes.h b/src/osgPlugins/geo/osgGeoNodes.h new file mode 100644 index 000000000..b474b3050 --- /dev/null +++ b/src/osgPlugins/geo/osgGeoNodes.h @@ -0,0 +1,177 @@ +// special geo nodes +#ifndef _GEO_NODES_H_ +#define _GEO_NODES_H_ + +#include + +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 *getVar() { + return &(val.d);} // address of variable + inline const double getVal() const { return (val.d);} + void setVal(double v) { val.d=v; + if (constrained) { + if (v>vmax) val.d=vmax; + if (v::iterator itr=vars.begin(); + itr!=vars.end(); + ++itr) + {// for each field + if ((*itr).getFID() == fid) { + return ((*itr).getVar()); + } + } + return NULL; + } + const geoValue *getGeoVar(const unsigned fid) const { + for (std::vector::const_iterator itr=vars.begin(); + itr!=vars.end(); + ++itr) + {// for each field + if ((*itr).getFID() == fid) { + return (&(*itr)); + } + } + return NULL; + } +private: + 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->getVar()); + } + return NULL; + } + const geoValue *getGeoVar(const unsigned fid) const { + for (std::vector::const_iterator itr=vars.begin(); itrgetFID() == fid) return (&(*itr)); + } + return NULL; + } + void addUserVar(const georecord &gr); +private: + std::vector vars; +}; + +class pack_colour { // holds the top colour of each colour ramp +public: + pack_colour() { cr=cg=cb=0; ca=1;} + ~pack_colour() {} + pack_colour(const unsigned char col[4]) { cr= col[0]; cg= col[1];cb= col[2];; ca= col[2];} + void get(unsigned char col[4]) const { col[0]=cr; col[1]=cg; col[2]=cb; col[3]=ca; } + friend inline std::ostream& operator << (std::ostream& output, const pack_colour& pc) + { + output << " cpalette: " <<(int)pc.cr << " " <<(int)pc.cg << " " <<(int)pc.cb << " " <<(int)pc.ca; + return output; // to enable cascading.. + } +private: + unsigned char cr, cg, cb, ca; +}; + +typedef std::vector< pack_colour > colourPalette; + +class geoHeaderGeo: public geoHeader { + // detailed structure for header of .geo file, + // including animation variables. +public: + geoHeaderGeo(); + ~geoHeaderGeo() { color_palette->clear(); } + void addInternalVars(const georecord &gr) { intVars->addInternalVars(gr);} + internalVars *getInternalVars(void) const { return intVars;} + const std::string getVarname(const unsigned fid) const { + const geoValue *gv=getGeoVar(fid); + return gv->getName(); + } + const geoValue *getGeoVar(const unsigned fid) const; + double *getVar(const unsigned fid) const; + void addUserVar(const georecord &gr); + //== handler for updating internal variables + void update(void); + inline void getPalette(uint icp, float cll[4]) const { // get color from palette + uint maxcol=icp/128; // the maximum intensity index + float frac = (float)(icp-maxcol*128)/128.0f; + + if (maxcol < color_palette->size()) { + unsigned char col[4]; + (*color_palette)[maxcol].get(col); + for (int i=0; i<4; i++) { + col[i]*=frac; + cll[i]=col[i]/255.0f; + } + } else { + unsigned char col[4]; + col[0]=(icp & 0xff000000)>> 24; + col[1]=(icp & 0xff0000) >> 16; + col[2]=(icp & 0xff00) >> 8; + col[3]= icp & 0xff; + for (int i=0; i<4; i++) { + cll[i]=col[i]/255.0f; + } + cll[0]=cll[1]=cll[2]=1.0f; + } + cll[3]=1.0f; // default alpha {0-1} + } + void addColour(unsigned char *cpal) {(*color_palette).push_back(cpal);} + inline colourPalette *getColorPalette() const { return color_palette;} +private: + osg::Timer_t _lastFrameTick,_initialTick; + osg::Timer _timer; + double tstart; // start time + osg::FrameStamp _frameStamp ; // time utilities + internalVars *intVars; + userVars *useVars; + userVars *extVars; + void moveit(const double t); + colourPalette *color_palette; // the colour palette - used in colour animations +}; + +#endif diff --git a/src/osgPlugins/geo/osgGeoStructs.h b/src/osgPlugins/geo/osgGeoStructs.h index 57bddc2c2..c126b1785 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,550 +19,600 @@ 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 addBehaviourRecord(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; nod=NULL; } + ~georecord() {;} + inline const uint getType(void) const {return id;} + typedef std::vector instancelist; // list if unused instance matrices + void addInstance(osg::MatrixTransform *mtr) { mtrlist.push_back(mtr);} + inline void setNode(osg::Node *n) { + nod=n; + { + for (instancelist::iterator itr=mtrlist.begin(); + itr!=mtrlist.end(); + ++itr) { + (*itr)->addChild(nod); + } + mtrlist.clear(); + } + } + inline osg::Node *getNode() const { return nod;} + 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 addBehaviourRecord(class georecord *gr) { behaviour.push_back(gr);} + void addMappingRecord(class georecord *gr) { tmap.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 : + case DB_DSK_DISCRETE_ACTION: + case DB_DSK_SQRT_ACTION : // an undefined, square root 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); + } + } + } + void writefile(std::ofstream &fout) { // write binary file + fout.write((char *)&id,sizeof(int)); + { // output the fields + for (geoFieldList::iterator itr=fields.begin(); + itr!=fields.end(); + ++itr) + { + itr->writefile(fout); + } + } + } + friend inline std::ostream& operator << (osgDB::Output& output, const georecord& gr) { - switch (gr.id) { - case DB_DSK_PUSH: output << "Push" << std::endl; break; - case DB_DSK_POP: output << "Pop" << std::endl; break; - case DB_DSK_HEADER: output << "Header" << std::endl; break; - case DB_DSK_GROUP: output << "Group" << std::endl; break; - case DB_DSK_BILLBOARD: output << "Billboard" << std::endl; break; - case DB_DSK_SEQUENCE: output << "Sequence" << std::endl; break; - case DB_DSK_LOD: output << "LOD" << std::endl; break; - case DB_DSK_GEODE: output << "Geode" << std::endl; break; - case DB_DSK_POLYGON: output << "Polygon" << std::endl; break; - case DB_DSK_MESH: output << "Mesh" << std::endl; break; - case DB_DSK_CUBE: output << "Cube" << std::endl; break; - case DB_DSK_SPHERE: output << "Sphere" << std::endl; break; - case DB_DSK_CONE: output << "Cone" << std::endl; break; - case DB_DSK_CYLINDER: output << "Cylinder" << std::endl; break; - case DB_DSK_VERTEX: output << "Vertex" << std::endl; break; - case DB_DSK_TEXTURE: output << "Texture" << std::endl; break; - case DB_DSK_MATERIAL: output << "Material" << std::endl; break; - case DB_DSK_VIEW: output << "View" << std::endl; break; - case DB_DSK_EXTENSION_LIST: output << "Extensions" << std::endl; break; - case DB_DSK_COORD_POOL: output << "Coords" << std::endl; break; - case DB_DSK_NORMAL_POOL: output << "Normals" << std::endl; break; - case DB_DSK_SWITCH: output << "Switch" << std::endl; break; - case DB_DSK_TEXT: output << "Text" << std::endl; break; - case DB_DSK_BASE_GROUP: output << "Base group" << std::endl; break; - case DB_DSK_BASE_SURFACE: output << "Base Surface" << std::endl; break; - case DB_DSK_INSTANCE: output << "Instance" << std::endl; break; - case DB_DSK_LIGHTPT: output << "Light Point" << std::endl; break; - case DB_DSK_EXTERNAL: output << "External" << std::endl; break; - case DB_DSK_PAGE: output << "Page" << std::endl; break; - case DB_DSK_COLOR_PALETTE: output << "Colour palette" << std::endl; break; - case DB_DSK_INTERNAL_VARS: output << "Internal vars" << std::endl; break; - case DB_DSK_LOCAL_VARS: output << "Local vars" << std::endl; break; - case DB_DSK_EXTERNAL_VARS: output << "External vars" << std::endl; break; - // behaviours - case DB_DSK_BEHAVIOR: output << "Behaviour" << std::endl; break; - case DB_DSK_CLAMP_ACTION: output << "clamp action" << std::endl; break; - case DB_DSK_RANGE_ACTION: output << "range action" << std::endl; break; - case DB_DSK_ROTATE_ACTION: output << "rotate action" << std::endl; break; - case DB_DSK_TRANSLATE_ACTION: output << "translate action" << std::endl; break; - case DB_DSK_SCALE_ACTION: output << "scale action" << std::endl; break; - case DB_DSK_ARITHMETIC_ACTION: output << "arithmetic action" << std::endl; break; - case DB_DSK_LOGIC_ACTION: output << "logic action" << std::endl; break; - case DB_DSK_CONDITIONAL_ACTION: output << "conditional action" << std::endl; break; - case DB_DSK_LOOPING_ACTION: output << "looping action" << std::endl; break; - case DB_DSK_COMPARE_ACTION: output << "compare action" << std::endl; break; - case DB_DSK_VISIBILITY_ACTION: output << "visibility action" << std::endl; break; - case DB_DSK_STRING_CONTENT_ACTION: output << "string content action" << std::endl; break; - // var types - case DB_DSK_FLOAT_VAR: output << "Float var" << std::endl; break; - case DB_DSK_INT_VAR: output << "Int var" << std::endl; break; - case DB_DSK_LONG_VAR: output << "Long var" << std::endl; break; - case DB_DSK_DOUBLE_VAR: output << "Double var" << std::endl; break; - case DB_DSK_BOOL_VAR: output << "Bool var" << std::endl; break; - default: output << " inp record " << gr.id << std::endl; break; - } + switch (gr.id) { + case DB_DSK_PUSH: output << "Push" << std::endl; break; + case DB_DSK_POP: output << "Pop" << std::endl; break; + case DB_DSK_HEADER: output << "Header" << std::endl; break; + case DB_DSK_GROUP: output << "Group" << std::endl; break; + // case DB_DSK_BILLBOARD: output << "Billboard" << std::endl; break; + case DB_DSK_SEQUENCE: output << "Sequence" << std::endl; break; + case DB_DSK_LOD: output << "LOD" << std::endl; break; + case DB_DSK_GEODE: output << "Geode" << std::endl; break; + case DB_DSK_POLYGON: output << "Polygon" << std::endl; break; + case DB_DSK_MESH: output << "Mesh" << std::endl; break; + case DB_DSK_CUBE: output << "Cube" << std::endl; break; + case DB_DSK_SPHERE: output << "Sphere" << std::endl; break; + case DB_DSK_CONE: output << "Cone" << std::endl; break; + case DB_DSK_CYLINDER: output << "Cylinder" << std::endl; break; + case DB_DSK_VERTEX: output << "Vertex" << std::endl; break; + case DB_DSK_TEXTURE: output << "Texture" << std::endl; break; + case DB_DSK_MATERIAL: output << "Material" << std::endl; break; + case DB_DSK_VIEW: output << "View" << std::endl; break; + case DB_DSK_EXTENSION_LIST: output << "Extensions" << std::endl; break; + case DB_DSK_COORD_POOL: output << "Coords" << std::endl; break; + case DB_DSK_NORMAL_POOL: output << "Normals" << std::endl; break; + case DB_DSK_SWITCH: output << "Switch" << std::endl; break; + case DB_DSK_TEXT: output << "Text" << std::endl; break; + case DB_DSK_BASE_GROUP: output << "Base group" << std::endl; break; + case DB_DSK_BASE_SURFACE: output << "Base Surface" << std::endl; break; + case DB_DSK_INSTANCE: output << "Instance" << std::endl; break; + case DB_DSK_LIGHTPT: output << "Light Point" << std::endl; break; + case DB_DSK_EXTERNAL: output << "External" << std::endl; break; + case DB_DSK_PAGE: output << "Page" << std::endl; break; + case DB_DSK_COLOR_PALETTE: output << "Colour palette" << std::endl; break; + case DB_DSK_INTERNAL_VARS: output << "Internal vars" << std::endl; break; + case DB_DSK_LOCAL_VARS: output << "Local vars" << std::endl; break; + case DB_DSK_EXTERNAL_VARS: output << "External vars" << std::endl; break; + // behaviours + case DB_DSK_BEHAVIOR: output << "Behaviour" << std::endl; break; + case DB_DSK_CLAMP_ACTION: output << "clamp action" << std::endl; break; + case DB_DSK_RANGE_ACTION: output << "range action" << std::endl; break; + case DB_DSK_ROTATE_ACTION: output << "rotate action" << std::endl; break; + case DB_DSK_TRANSLATE_ACTION: output << "translate action" << std::endl; break; + case DB_DSK_SCALE_ACTION: output << "scale action" << std::endl; break; + case DB_DSK_ARITHMETIC_ACTION: output << "arithmetic action" << std::endl; break; + case DB_DSK_LOGIC_ACTION: output << "logic action" << std::endl; break; + case DB_DSK_CONDITIONAL_ACTION: output << "conditional action" << std::endl; break; + case DB_DSK_LOOPING_ACTION: output << "looping action" << std::endl; break; + case DB_DSK_COMPARE_ACTION: output << "compare action" << std::endl; break; + case DB_DSK_VISIBILITY_ACTION: output << "visibility action" << std::endl; break; + case DB_DSK_STRING_CONTENT_ACTION: output << "string content action" << std::endl; break; + // var types + case DB_DSK_FLOAT_VAR: output << "Float var" << std::endl; break; + case DB_DSK_INT_VAR: output << "Int var" << std::endl; break; + case DB_DSK_LONG_VAR: output << "Long var" << std::endl; break; + case DB_DSK_DOUBLE_VAR: output << "Double var" << std::endl; break; + case DB_DSK_BOOL_VAR: output << "Bool var" << std::endl; break; + default: output << " inp record " << gr.id << std::endl; break; + } - 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,... + } + geoField *getModField(const int fieldid) { // return modifiable field if it exists. + for (geoFieldList::iterator itr=fields.begin(); + itr!=fields.end(); + ++itr) + { + if (itr->getToken()==fieldid) return &(*itr); + } + return NULL; + } + 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 *> tmap; // texture mapping records of this record + std::vector< georecord *> behaviour; // behaviour & action records of this record + std::vector< georecord *> children; // children of this record + osg::Node *nod; // the node that this record has been converted to (useful for instances) + instancelist mtrlist; // list of matrices of instances not yet satisfied };