From c0c5fc13b1a8d70a5d1b165af6f1ae10723c17c1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 4 Jun 2013 13:29:44 +0000 Subject: [PATCH] Removed geo plugin as the modelling tool it was assocaited is long defunct. --- src/osgPlugins/CMakeLists.txt | 3 +- src/osgPlugins/geo/CMakeLists.txt | 19 - src/osgPlugins/geo/ClipRegion.cpp | 140 -- src/osgPlugins/geo/ClipRegion.h | 54 - src/osgPlugins/geo/ReaderWriterGEO.cpp | 2287 ------------------------ src/osgPlugins/geo/geoActions.cpp | 697 -------- src/osgPlugins/geo/geoCore.h | 54 - src/osgPlugins/geo/geoFormat.h | 1957 -------------------- src/osgPlugins/geo/geoTypes.h | 618 ------- src/osgPlugins/geo/geoUnits.h | 74 - src/osgPlugins/geo/geoVersion.h | 81 - src/osgPlugins/geo/osgGeoAction.h | 289 --- src/osgPlugins/geo/osgGeoAnimation.h | 58 - src/osgPlugins/geo/osgGeoNodes.h | 187 -- src/osgPlugins/geo/osgGeoStructs.h | 728 -------- 15 files changed, 1 insertion(+), 7245 deletions(-) delete mode 100644 src/osgPlugins/geo/CMakeLists.txt delete mode 100644 src/osgPlugins/geo/ClipRegion.cpp delete mode 100644 src/osgPlugins/geo/ClipRegion.h delete mode 100644 src/osgPlugins/geo/ReaderWriterGEO.cpp delete mode 100644 src/osgPlugins/geo/geoActions.cpp delete mode 100644 src/osgPlugins/geo/geoCore.h delete mode 100644 src/osgPlugins/geo/geoFormat.h delete mode 100644 src/osgPlugins/geo/geoTypes.h delete mode 100644 src/osgPlugins/geo/geoUnits.h delete mode 100644 src/osgPlugins/geo/geoVersion.h delete mode 100644 src/osgPlugins/geo/osgGeoAction.h delete mode 100644 src/osgPlugins/geo/osgGeoAnimation.h delete mode 100644 src/osgPlugins/geo/osgGeoNodes.h delete mode 100644 src/osgPlugins/geo/osgGeoStructs.h diff --git a/src/osgPlugins/CMakeLists.txt b/src/osgPlugins/CMakeLists.txt index ad3fd41b3..32f3d8388 100644 --- a/src/osgPlugins/CMakeLists.txt +++ b/src/osgPlugins/CMakeLists.txt @@ -163,8 +163,7 @@ ADD_SUBDIRECTORY(bvh) ADD_SUBDIRECTORY(x) ADD_SUBDIRECTORY(dxf) ADD_SUBDIRECTORY(OpenFlight) -# ADD_SUBDIRECTORY(flt) -ADD_SUBDIRECTORY(geo) + ADD_SUBDIRECTORY(obj) ADD_SUBDIRECTORY(pic) diff --git a/src/osgPlugins/geo/CMakeLists.txt b/src/osgPlugins/geo/CMakeLists.txt deleted file mode 100644 index 121288dd1..000000000 --- a/src/osgPlugins/geo/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -SET(TARGET_SRC - ClipRegion.cpp - ReaderWriterGEO.cpp - geoActions.cpp ) -SET(TARGET_H - ClipRegion.h - geoCore.h - geoFormat.h - geoTypes.h - geoUnits.h - geoVersion.h - osgGeoAction.h - osgGeoAnimation.h - osgGeoNodes.h - osgGeoStructs.h -) -SET(TARGET_ADDED_LIBRARIES osgSim osgText) -#### end var setup ### -SETUP_PLUGIN(geo) diff --git a/src/osgPlugins/geo/ClipRegion.cpp b/src/osgPlugins/geo/ClipRegion.cpp deleted file mode 100644 index f80ea6ffc..000000000 --- a/src/osgPlugins/geo/ClipRegion.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// clip region -// GEO version, Nov 2003 -// may be replaced when clipRegion accepted into OSG proper. -// i) a clipregion is class derived from Group, with a Geode and any children of the group -// ii) a special draw is made that: -// sets stencil bits by drawing the clip Geode -// draws the children of group clipped by the stencil region. -// partly derived fromt he stencil code in osgreflect example. - -#include "ClipRegion.h" -#include -#include -#include -#include -#include - -using namespace osg; - -//===== -GeoClipRegion::GeoClipRegion(int bin) -{ - stencilbin=bin; -} - -GeoClipRegion::~GeoClipRegion() -{ -} - -GeoClipRegion::GeoClipRegion(const GeoClipRegion& clr,const osg::CopyOp& copyop): osg::Group(clr,copyop) -{ //_clipNodes=clr._clipNodes; -} - -void GeoClipRegion::addClipNode(osg::Node *gd) { - - osg::StateSet *state=gd->getOrCreateStateSet(); - // add clip node(s) to set stencil bit marking the clip area. - // stencil op so that the stencil buffer get set at the clip pixels - osg::Stencil* stencil = new osg::Stencil; - stencil->setFunction(osg::Stencil::ALWAYS,1,~0u); - stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::REPLACE); - state->setAttributeAndModes(stencil,osg::StateAttribute::ON); - - // switch off the writing to the color bit planes. (Dont show the clip area) - osg::ColorMask* colorMask = new osg::ColorMask; - colorMask->setMask(false,false,false,false); - - state->setRenderBinDetails(stencilbin,"RenderBin"); - state->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); - state->setAttribute(colorMask); - // set up depth so all writing to depth goes to maximum depth. (dont want to z-clip the cull stencil) - osg::Depth* depth = new osg::Depth; - depth->setFunction(osg::Depth::ALWAYS); - depth->setRange(1.0,1.0); - state->setAttribute(depth); - Group::addChild(gd); -} - -bool GeoClipRegion::addChild( osg::Node *child ) -{ - // bin the last - draw 'real' scenery last, using Z buffer to clip against any clip region... - - osg::StateSet* statesetBin2 = child->getOrCreateStateSet(); - statesetBin2->setRenderBinDetails(stencilbin+3,"RenderBin"); - /* osg::Stencil* stencil = new osg::Stencil; - stencil->setFunction(osg::Stencil::ALWAYS,0,~0); - stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::REPLACE); - statesetBin2->setAttributeAndModes(stencil,osg::StateAttribute::ON);*/ - return Group::addChild(child); -} - -bool GeoClipRegion::addClippedChild( osg::Node *child ) -{ -// these children of this clipregion are drawn in stencilBin+2, clipped at the edges of the clip region - osg::StateSet *state=child->getOrCreateStateSet(); - // state tests pixels against the set stencil. - osg::Stencil* stenciltest = new osg::Stencil; - stenciltest->setFunction(osg::Stencil::EQUAL,1,~0u); - stenciltest->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); - state->setAttributeAndModes(stenciltest,osg::StateAttribute::ON); - - osg::ColorMask* cMask = new osg::ColorMask; - cMask->setMask(true,true,true,true); - state->setAttribute(cMask); - - state->setRenderBinDetails(stencilbin+1,"RenderBin"); - // use depth for rest of the scene unless overriden. - osg::Depth* rootDepth = new osg::Depth; - rootDepth->setFunction(osg::Depth::LESS); - rootDepth->setRange(0.0,1.0); - state->setAttribute(rootDepth); - - return Group::addChild(child); -} -bool GeoClipRegion::addObscuredChild( osg::Node *child ) -{ -// other children of this node are drawn in stencilBin+2 outside the clip, hidden by the clip region - osg::StateSet *state=child->getOrCreateStateSet(); - // state tests pixels against the set stencil. - osg::Stencil* stenciltest = new osg::Stencil; - stenciltest->setFunction(osg::Stencil::NOTEQUAL,1,~0u); - stenciltest->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); - state->setAttributeAndModes(stenciltest,osg::StateAttribute::ON); - - osg::ColorMask* cMask = new osg::ColorMask; - cMask->setMask(true,true,true,true); - state->setAttribute(cMask); - - state->setRenderBinDetails(stencilbin+1,"RenderBin"); - // use depth for rest of the scene unless overriden. - osg::Depth* rootDepth = new osg::Depth; - rootDepth->setFunction(osg::Depth::LESS); - rootDepth->setRange(0.0,1.0); - state->setAttribute(rootDepth); - return Group::addChild(child); -} - -void GeoClipRegion::addDrawClipNode(osg::Node *ndclip) -{ - osg::StateSet *state=ndclip->getOrCreateStateSet(); - // last bin - draw clip area and blend it with the clipped, visible geometry. - - // set up depth so all writing to depth goes to maximum depth. - osg::Depth* depth = new osg::Depth; - depth->setFunction(osg::Depth::ALWAYS); - - osg::Stencil* stencil = new osg::Stencil; - stencil->setFunction(osg::Stencil::EQUAL,1,~0u); - stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::ZERO); - - // set up additive blending. - osg::BlendFunc* trans = new osg::BlendFunc; - trans->setFunction(osg::BlendFunc::ONE,osg::BlendFunc::ONE); - - state->setRenderBinDetails(stencilbin+2,"RenderBin"); - state->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); - state->setAttributeAndModes(stencil,osg::StateAttribute::ON); - state->setAttributeAndModes(trans,osg::StateAttribute::ON); - state->setAttribute(depth); - Group::addChild(ndclip); -} diff --git a/src/osgPlugins/geo/ClipRegion.h b/src/osgPlugins/geo/ClipRegion.h deleted file mode 100644 index ed0d52d1f..000000000 --- a/src/osgPlugins/geo/ClipRegion.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#ifndef OSG_GEOCLIPREGION -#define OSG_GEOCLIPREGION 1 - -#include -#include - - - -/** A ClipRegion is a group node for which all children are clipped - * by the projection into screen coordinates of the ClipGeode. - * Used for cutouts in instrumentation. - * - * -*/ -class GeoClipRegion : public osg::Group -{ - public : - - GeoClipRegion(int bin=osg::StateSet::TRANSPARENT_BIN+3); - - /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ - GeoClipRegion(const GeoClipRegion&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); - - // clip nodes define a screen region that is protected - void addClipNode(osg::Node *gd); - /* clipped children are only drawn inside the clip Node(s) protected screen area - * Obscured Nodes are (partly) hidden where the clipNodes overlap - */ - virtual bool addClippedChild( osg::Node *child ); - virtual bool addObscuredChild( osg::Node *child ); - virtual bool addChild( osg::Node *child ); - // drawClipNodes are special draw of geometry at the clip area which undoes the stencil value - void addDrawClipNode(osg::Node *ndclip); - void setBin(const int bin) { stencilbin=bin;} - protected : - - virtual ~GeoClipRegion(); - int stencilbin; -}; - -#endif // match OSG_GEOCLIPREGION diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp deleted file mode 100644 index 131637f1e..000000000 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ /dev/null @@ -1,2287 +0,0 @@ -// GEO format (carbon graphics Inc) loader for the OSG real time scene graph -// www.carbongraphics.com for more information about the Geo animation+ modeller -// 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.2 GWM Nov 2003 - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ClipRegion.h" - -#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 - - -// -geoHeaderGeo::geoHeaderGeo() -{ // animations for the header - actually updates all control variables - intVars=new internalVars; - useVars=new userVars; - extVars=new userVars; - color_palette=new colourPalette; - _initialTick = _timer.tick(); -} - -geoHeaderGeo::geoHeaderGeo(const geoHeaderGeo &geo,const osg::CopyOp& copyop) : - geoHeader(geo,copyop) -{ - intVars=new internalVars(*geo.intVars); - useVars=new userVars(*geo.useVars); - extVars=new userVars(*geo.extVars); - color_palette=new colourPalette; - _initialTick = _timer.tick(); -} - -geoHeaderGeo::~geoHeaderGeo() -{ - delete intVars; - delete useVars; - delete extVars; - - if (color_palette) - { - color_palette->clear(); - delete color_palette; - } -} - - -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(const osg::FrameStamp *_frameStamp) -{ // update the scene - osg::Timer_t _frameTick = _timer.tick(); - _lastFrameTick=_frameTick; - - double time = _frameStamp->getSimulationTime(); - intVars->update( _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 - geoHeaderGeo *gh=(geoHeaderGeo *)node; - gh->update(nv->getFrameStamp()); - 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<<"update callback - post traverse"<< (float)_frameStamp->getSimulationTime() < 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.get();} - inline osg::Vec3Array *getNorms() const { return norms.get();} - inline osg::Vec3Array *getCoords() const { return coords.get();} - inline osg::Vec2Array *getTexCoords() const { return txcoords.get();} - inline osg::IntArray *getColorIndices() const { return colorindices.get();} - inline osg::IntArray *getCoordIndices() const { return coordindices.get();} - inline osg::IntArray *getNormIndices() const { return normindices.get();} - inline osg::IntArray *getTextureIndices() const { return txindices.get();} - void addPolcolour( osg::Vec4 cl) { polycols->push_back(cl);} - osg::Vec4Array *getPolcolours() const { return polycols.get();} - 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 addFlat( const georecord *gface) - { // this must only be called with a vertex georecord. - bool isflat=false; - const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... - int shademodel=gfshade ? gfshade->getInt() : -1; - if (shademodel==GEO_POLY_SHADEMODEL_LIT) { // flat shaded - need the index - const geoField *gfd=gface->getField(GEO_DB_POLY_NORMAL); - if (gfd) { - float *normal= (gfd) ? (gfd->getVec3Arr()):NULL; - osg::Vec3 nrm(normal[0], normal[1], normal[2]); - norms->push_back(nrm); - isflat=true; - } - } - return isflat; - } - 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 || - gr->getType()==DB_DSK_FAT_VERTEX || - gr->getType()==DB_DSK_SLIM_VERTEX) { - const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... - int shademodel=gfshade ? gfshade->getInt() : -1; - if (shademodel!=GEO_POLY_SHADEMODEL_LIT && shademodel!=GEO_POLY_SHADEMODEL_FLAT) { - const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL); - if (gfd) - { - if (gfd->getType()==DB_UINT) - { - unsigned int idx=gfd->getUInt(); - normindices->push_back(idx); - norms->push_back((*npool)[idx]); - } - else if (gfd->getType()==DB_VEC3F) - { - float *p=gfd->getVec3Arr(); - osg::Vec3 nrm; - nrm.set(p[0],p[1],p[2]); - norms->push_back(nrm); - } - else - { - OSG_WARN << "No valid vertex index" << std::endl; - } - } - } - osg::Vec3 pos; - const geoField *gfd=gr->getField(GEO_DB_VRTX_COORD); - if (gfd) - { - if (gfd->getType()==DB_INT) - { - int idx=gfd->getInt(); - pos=(*cpool)[idx]; - coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2])); - coordindices->push_back(coords->size()); - } - else if (gfd->getType()==DB_VEC3F) - { - float *p=gfd->getVec3Arr(); - pos.set(p[0],p[1],p[2]); - coords->push_back(pos); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2])); - } - else - { - OSG_WARN << "No valid vertex index" << std::endl; - } - } - - 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); - mb->setpos(pos); - mb->setindx(ncoord-1); - BehList.push_back(mb); - } - if ((*rcitr)->getType()==DB_DSK_ROTATE_ACTION) { - geoMoveVertexBehaviour *mb=new geoMoveVertexBehaviour; - mb->makeBehave((*rcitr),ghdr); - mb->setpos(pos); - 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); - if (ok) 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_0); - if (gfd) { - uvc=(float *)gfd->getstore(0); - - if (uvc) { // then there are tx coords - osg::Vec2 uv(uvc[0], uvc[1]); - txcoords->push_back(uv); - } else { - txcoords->push_back(osg::Vec2(0,0)); - } - } else { - txcoords->push_back(osg::Vec2(0,0)); - } - gfd=gr->getField(GEO_DB_VRTX_PACKED_COLOR); - if (gfd) { - unsigned char *cp=gfd->getUCh4Arr(); - float red=cp[0]/255.0f; - float green=cp[1]/255.0f; - float blue=cp[2]/255.0f; - // may need alpha in future:: float alpha=cp[3]/255.0f; - colors->push_back(Vec4(red,green,blue,1.0)); - } else { // look for a colour index (exclusive!) - gfd=gr->getField(GEO_DB_VRTX_COLOR_INDEX); - if (gfd) { - 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 { - colors->push_back(Vec4(cdef[0],cdef[1],cdef[2],cdef[3])); - } - } 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) - { - const osg::Vec2Array *txa=vf.getTexCoords(); - osg::IntArray *normindices=vf.getNormIndices(); - osg::IntArray *txind = vf.getTextureIndices(); - output << " vertexinfo " << txa->size() << " nrm: " << normindices->size()<< - " txinds " << txind->size()<size(); i++) { - const osg::Vec2 uvt=(*txa)[i]; - output << " U " << uvt.x() << " v " << uvt.y() << std::endl; - } - for (i=0; isize(); i++) { - output << "Nind " << i << " = " << (*normindices)[i] << std::endl; - } - return output; // to enable cascading, monkey copy from osg\plane or \quat, Ubyte4, vec2,3,4,... - } -private: - const std::vector *cpool; // passed in from the geo file - const std::vector *npool; - osg::ref_ptr norms; - osg::ref_ptr coords; - osg::ref_ptr txcoords; - osg::ref_ptr colors; - osg::ref_ptr colorindices; - osg::ref_ptr coordindices; - osg::ref_ptr normindices; - osg::ref_ptr txindices; - drBehList BehList; - osg::ref_ptr 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 int bs=1) { texture=txidx; // will be -1 or 0-number of textures - geom=NULL; nstart=0; linewidth=1; - bothsides=bs; shademodel=sm; - } - virtual ~geoInfo() { }; - inline int getShademodel(void) const { return shademodel;} - inline int getBothsides(void) const { return bothsides;} - inline int getTexture(void) const { return texture;} - inline vertexInfo *getVinf(void) { return &vinf;} - void setPools(const std::vector *coord_pool, const std::vector *normal_pool) { - vinf.setPools(coord_pool,normal_pool); - } - float getlinewidth(void) const { return linewidth;} - void setlineWidth(const int w) { linewidth=w;} - void setGeom(osg::Geometry *nugeom) { geom=nugeom;} - osg::Geometry *getGeom() { return geom.get();} - 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 - int bothsides; // none, back,front - int shademodel; - int linewidth; - vertexInfo vinf; - uint nstart; // start vertex for a primitive - osg::ref_ptr geom; // the geometry created for this vinf and texture -}; - - -class ReaderGEO -{ - public: - - osgDB::ReaderWriter::ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) - { - - osgDB::ifstream fin(fileName.c_str(), std::ios::binary | std::ios::in ); - if (fin.is_open() ) - { // read the input file. - // code for setting up the database path so that internally referenced file are searched for on relative paths. - osg::ref_ptr local_opt = options ? - static_cast(options->clone(osg::CopyOp::SHALLOW_COPY)) : - new osgDB::ReaderWriter::Options; - local_opt->setDatabasePath(osgDB::getFilePath(fileName)); - - typedef std::vector NodeList; - NodeList nodeList; - osg::Material *mt=new osg::Material; - matlist.push_back(mt); - theHeader=NULL; - - // load all nodes in file, placing them in a linear list corresponding to the on disk file. - while(!fin.eof()) - { - georecord gr; - gr.readfile(fin); -// OSG_WARN << "end of record " << (int)gr.getType() << std::endl; - 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 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 -#ifdef _DEBUG - osgDB::Output fout("georex.txt"); //, std::ios_base::out ); - // fout << "Debug raw file " << fileName << std::endl; - // output(fout,recs); - fout << "Debug Sorted file " << fileName << std::endl; - output(fout,sorted); - fout.close(); -#endif /**/ - makeHeader(*(sorted.begin()), local_opt.get()); - - nodeList=makeosg(sorted, local_opt.get()); // make a list of osg nodes - geotxlist.clear(); - geomatlist.clear(); - txlist.clear(); - txenvlist.clear(); - matlist.clear();/* */ - coord_pool.clear(); - normal_pool.clear(); - osg::Node * groupnode = NULL; - if (nodeList.empty()) - { - return osgDB::ReaderWriter::ReadResult("No data loaded from "+fileName); - } - else if (nodeList.size()==1) - { - groupnode = nodeList.front(); - } - else - { - osg::Group *group = new Group; - group->setName("import group"); - for(NodeList::iterator itr=nodeList.begin(); - itr!=nodeList.end(); - ++itr) - { - group->addChild(*itr); - } - groupnode=group; - } - (theHeader.get())->addChild(groupnode); - groupnode=theHeader.get(); -#ifdef _DEBUG // output a .osg version - osgDB::writeNodeFile(*groupnode,"geoosg.osg"); -#endif /**/ - recs.clear(); - return groupnode; - } - return 0L; - } - std::vector sort(geoRecordList &recs) { // return a tree-list of sorted record pointers - // which mirrors the original .geo file (containers hold push/pop blocks). - std::vector sorted; - class georecord *curparent=NULL; - for (geoRecordList::iterator itr=recs.begin(); - itr!=recs.end(); - ++itr) { - const geoField *gfd; - // OSG_WARN << *itr << std::endl; - // now parse for push/pops and add to lists - - switch ((*itr).getType()) { - case 101: // old header - not appropriate! - curparent= &(*itr); - sorted.push_back(&(*itr)); - OSG_WARN << "Old version 2 header block found - possible error!" << std::endl; - break; - case DB_DSK_PUSH: - if (!(curparent->getchildren().empty())) { - curparent= curparent->getLastChild(); // itr-1; - } else { - //curparent=itr-1; - } - break; - case DB_DSK_POP: - if (curparent) curparent=curparent->getparent(); - break; - case DB_DSK_HEADER: // attach to previous - curparent= &(*itr); - sorted.push_back(&(*itr)); - cpalrec=NULL; - break; - case DB_DSK_INTERNAL_VARS: // attach to parent - case DB_DSK_LOCAL_VARS: - case DB_DSK_EXTERNAL_VARS: - (curparent)->addBehaviourRecord(&(*itr)); - break; - case DB_DSK_FLOAT_VAR: // attach to parent - 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: - // else if ((*itr).isVar(): - (curparent)->addBehaviourRecord(&(*itr)); - break; - case DB_DSK_TEXTURE: // attach to parent - geotxlist.push_back(&(*itr)); - break; - case DB_DSK_MATERIAL: // attach to parent - geomatlist.push_back(&(*itr)); - break; - case DB_DSK_VIEW: // not needed for Real Time - break; - case DB_DSK_COORD_POOL: // global - attach to readerwriterGEO class for whole model - gfd=itr->getField(GEO_DB_COORD_POOL_VALUES); - { - float *crds= (gfd) ? (gfd->getVec3Arr()):NULL; - uint nm=gfd->getNum(); - for (uint i=0; igetField(GEO_DB_NORMAL_POOL_VALUES); - { - float *nrms= (gfd) ? (gfd->getVec3Arr()):NULL; - uint nm=gfd->getNum(); - for (uint i=0; igetType()==DB_DSK_HEADER) - curparent->addBehaviourRecord(&(*itr)); - else { - class georecord *cp=curparent->getLastChild(); - if (cp) cp->addBehaviourRecord(&(*itr)); - } - break; - case DB_DSK_PERSPECTIVE_GRID_INFO: // Feb 2003 not sure what this is yet! - (curparent)->addchild(&(*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); - curparent->addchild(&(*itr)); - } - break; - } - } - return sorted; - } - void outputPrim(const georecord *grec, osgDB::Output &fout) { // output to file for debug - const std::vector gr=grec->getchildren(); - if (gr.size()>0) { - for (std::vector::const_iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - fout << *(*itr) << std::endl; - } - } - } - /* 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, int imat) { - const int shademodel=ginf.getShademodel(); - const int 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()); - StateSet *dstate=new StateSet; - if (bothsides==0) { - osg::CullFace *cf = new osg::CullFace; // to define non-default culling - cf->setMode(osg::CullFace::BACK); - dstate->setAttributeAndModes(cf,osg::StateAttribute::ON); - } - else if (bothsides==1) { - osg::CullFace *cf = new osg::CullFace; // to define non-default culling - cf->setMode(osg::CullFace::FRONT); - dstate->setAttributeAndModes(cf,osg::StateAttribute::ON); - } - else if (bothsides==2) { - osg::CullFace *cf = new osg::CullFace; // to define non-default culling - dstate->setAttributeAndModes(cf,osg::StateAttribute::OFF); - } - Point *pt=new Point; - pt->setSize(4); - dstate->setAttribute(pt); - if (txidx>=0 && (unsigned int)txidxsetTextureAttribute(0, txenvlist[txidx].get() ); - dstate->setTextureAttributeAndModes(0,txlist[txidx].get(),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>=(int)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->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON); - } - dstate->setAttribute(matlist[imat].get()); - 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 - 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() : 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 (shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) { - nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); - } else if (shademodel==GEO_POLY_SHADEMODEL_LIT) { - nug->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); - } - osg::Vec4Array *polycols=vinf->getPolcolours(); - nug->setColorArray(polycols); - nug->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); - } - } - } - osg::LineWidth *lw=new osg::LineWidth; - lw->setWidth(ginf.getlinewidth()); - dstate->setAttributeAndModes(lw,osg::StateAttribute::ON); - nug->setStateSet( dstate ); - ginf.setGeom(nug); - return nug; - } - 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 - 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]/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; - theHeader->getPalette(icp,defcol); - } else { - defcol[0]=defcol[1]=defcol[2]=defcol[3]=1.0f; - } - } - - if (gr.size()>0) { - vinf->addFlat(grec); // for flat normal shading - for (std::vector::const_iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - vinf->addIndices((*itr), theHeader.get(), defcol, grec); - nv++; - } - } - return nv; - } - void outputGeode(const georecord& grec, osgDB::Output &fout) { // - const std::vector gr=grec.getchildren(); - if (gr.size()>0) { - fout.moveIn(); - for (std::vector::const_iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - fout.indent() << *(*itr) << std::endl; - if ((*itr)->getType()==DB_DSK_POLYGON) { - outputPrim((*itr),fout); - } - } - fout.moveOut(); - } - } - osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text - osg::MatrixTransform *numt=NULL; - std::string ttfPath("fonts/times.ttf"); - // unused - //int gFontSize1=2; - osgText::Text *text= new osgText::Text; - text->setFont(ttfPath); - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - const char *name=gfd ? gfd->getChar() : "a text"; - gfd=gr->getField(GEO_DB_TEXT_STRING); - const char *content=gfd ? gfd->getChar() : " "; - text->setText(std::string(content)); - //gfd=gr->getField(GEO_DB_TEXT_SCALE_X); - //const float scx=gfd ? gfd->getFloat() : 1.0f; - //gfd=gr->getField(GEO_DB_TEXT_SCALE_Y); - //const float scy=gfd ? gfd->getFloat() : 1.0f; - gfd=gr->getField(GEO_DB_TEXT_JUSTIFICATION); // GEO_DB_TEXT_DIRECTION); - int tjus=gfd? gfd->getInt() : GEO_TEXT_LEFT_JUSTIFY; - switch(tjus) { - case GEO_TEXT_LEFT_JUSTIFY: text->setAlignment(osgText::Text::LEFT_BOTTOM); break; - case GEO_TEXT_CENTER_JUSTIFY: text->setAlignment(osgText::Text::CENTER_BOTTOM); break; - case GEO_TEXT_RIGHT_JUSTIFY: text->setAlignment(osgText::Text::RIGHT_BOTTOM); break; - } - 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; - text->setColor(osg::Vec4(red,green,blue,1.0f)); - } else { // lok for a colour index (exclusive!) - gfd=gr->getField(GEO_DB_TEXT_COLOR_INDEX); - if (gfd) { - int icp=gfd->getInt(); - float col[4]; - theHeader->getPalette(icp,col); - text->setColor(osg::Vec4(col[0],col[1],col[2],1.0)); - } - } - osg::Geode *geod=new osg::Geode; - osg::StateSet *textState = new osg::StateSet(); - textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF); - geod->setStateSet( textState ); - numt=new osg::MatrixTransform; - numt->setName(name); - gfd=gr->getField(GEO_DB_TEXT_MATRIX); - if (gfd) { - float *fmat=gfd->getMat44Arr(); - // text->setPosition(osg::Vec3(fmat[12],fmat[13],fmat[14])); - numt->setMatrix(Matrix(fmat)); - } - numt->addChild(geod); - geod->addDrawable(text); - { - 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->setUpdateCallback(gcb); - for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); - rcitr!=bhv.end(); - ++rcitr) - { - if ((*rcitr)->getType()==DB_DSK_STRING_CONTENT_ACTION) { - geoStrContentBehaviour *cb=new geoStrContentBehaviour; - gfd=(*rcitr)->getField(GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR); - if (gfd) { - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - // ok=false; - } - } - } - } - } - return numt; - } - 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->setUpdateCallback(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.get()); - 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_VERTEX || - (*itr)->getType()==DB_DSK_FAT_VERTEX || - (*itr)->getType()==DB_DSK_SLIM_VERTEX) - { // light point vertices - osg::Vec3 pos; - const geoField *gfd=(*itr)->getField(GEO_DB_VRTX_COORD); - if (gfd) { - if (gfd->getType()==DB_INT) - { - int idx=gfd->getInt(); - pos=coord_pool[idx]; - } - else if (gfd->getType()==DB_VEC3F) - { - float *p=gfd->getVec3Arr(); - pos.set(p[0],p[1],p[2]); - } - else { - OSG_WARN << "No valid vertex index" << std::endl; - } - } - - 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,pos,colour,1.0f,1.0f,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(pos, 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, 1); - ginf.setPools(&coord_pool, &normal_pool); // holds all types of coords, indices etc - osgSim::LightPointNode *gd=new osgSim::LightPointNode; - // to be implemented 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); - } - } - } - int makeAnimatedGeometry(const georecord& grec, const int imat,Group *nug) { - // animated polygons - create a matrix & geode & poly & add to group nug - const std::vector gr=grec.getchildren(); - int nanimations=0; - const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none - unsigned int bothsides=gfd ? gfd->getUInt() : 0; -// int 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 - nanimations++; - if (hasMotionAction(bhv)) { // make matrix if motion needed. - const geoField *gfd=(*itr)->getField(GEO_DB_POLY_TEX0); - int txidx= gfd ? gfd->getInt() : -1; - gfd=(*itr)->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat... - 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 - 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; - 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; - float col[4]; - theHeader->getPalette(icp, col); - ginf.getVinf()->addPolcolour(osg::Vec4(col[0],col[1],col[2],1.0)); - } - } - 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); - } - } - - } - return nanimations; - } - 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 int bothsides) { - int igidx=0, igeom=-1; - const geoField *gfd=grec->getField(GEO_DB_POLY_TEX0); - int txidx= gfd ? gfd->getInt() : -1; - for (std::vector::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()->getUpdateCallback()) 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); - gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width... - if (gfd) { - int w=gfd->getInt(); - gi.setlineWidth(w); - } - 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])); - } - int 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 - const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none - unsigned int bothsides=gfd ? gfd->getUInt() : 0; - // 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); - { - const vertexInfo *vinf=gi->getVinf(); - if (vinf->getNorms() && vinf->getNorms()->size()>0) { - gi->getGeom()->setNormalArray(vinf->getNorms()); - gi->getGeom()->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); - } else { - gi->getGeom()->setNormalBinding(osg::Geometry::BIND_OFF); - } - } - 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++; - } - } - } - return gr.size(); - } - void makeTexts(const 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) { - std::vector ia; // list of texture indices found in this geode; sort into new - for (std::vector::const_iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - if ((*itr)->getType()==DB_DSK_TEXT) { - osg::MatrixTransform *text=makeText((*itr)); - if (text) nug->addChild(text); - } - } - // OSG_WARN << vinf; - } - return; - } - Group *makeTextGeode(const georecord *gr) - { - // in geo text is defined with a matrix included in the geo.geode (gr is this geo.geode) - // - we need to create this tree to render text -#if 1 - return NULL; // temporary disable april 2003 -#else - Group *nug=new Group; - const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT); - // may be used in future const unsigned int imat=gfd ? gfd->getInt():0; - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - nug->setName(gfd->getChar()); - } - makeTexts((*gr),nug); - if (nug->getNumChildren() <=0) { - nug=NULL; - } - return nug; -#endif - } - - Group *makeLightPointGeodes(const georecord *gr) { - Group *nug=new Group; - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - char *name = gfd->getChar(); - nug->setName(name); - } - 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 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_NODE_NAME); - if (gfd) { - char *name = gfd->getChar(); - nug->setName(name); - } - int nans=makeAnimatedGeometry((*gr),imat,nug); - if (nans <=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_BILLBOARD); - bool isbillb = gfd ? gfd->getBool() : false; - osg::Geode *nug; - if (isbillb) { - Billboard *bilb= new Billboard ; - bilb->setAxis(Vec3(0,0,1)); - bilb->setNormal(Vec3(0,-1,0)); - nug=bilb; - } else { - nug=new Geode; - } - int nchild=makeGeometry(gr,imat,nug); - if (nchild>0) { // complete the geode - gfd=gr.getField(GEO_DB_NODE_NAME); - if (gfd) { - nug->setName(gfd->getChar()); - } - return nug; - } else { - return NULL; - } - } - osg::Group *makePage(const georecord *gr) - { - osg::Group *gp=new Group; - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - gp->setName(gfd->getChar()); - } - return gp; - } - osg::Group *setmatrix(const georecord *gr) { // find one of the types of matrix supported - const geoField *gfd=gr->getField(GEO_DB_GRP_MATRIX_TRANSFORM); - if (!gfd) gfd=gr->getField(GEO_DB_GRP_TRANSLATE_TRANSFORM); - if (!gfd) gfd=gr->getField(GEO_DB_GRP_ROTATE_TRANSFORM); - if (!gfd) gfd=gr->getField(GEO_DB_GRP_SCALE_TRANSFORM); - if (gfd) { - MatrixTransform *tr=new MatrixTransform; - osg::Matrix mx; - float * m44=gfd->getMat44Arr(); - mx.set(m44); // hope uses same convention as OSG else will need to use set(m44[0],m44[1]...) - tr->setMatrix(mx); - return tr; - } else { - return NULL; - } - } - osg::Group *makeGroup(const georecord *gr) { // group or Static transform - osg::Group *gp=setmatrix(gr); - if (!gp) { - gp=new osg::Group; - } - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - gp->setName(gfd->getChar()); - } - return gp; - } - 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; - - imask=gfd->getInt(); - - // set the bits in the osg::Switch. - int selector_mask = 0x1; - for(int pos=0;pos<32;++pos) - { - sw->setValue(pos,((imask&selector_mask)!=0)); - selector_mask <<= 1; - } - OSG_WARN << gr << " imask " << imask << std::endl; - } else { - sw->setSingleChildOn(0); - OSG_WARN << gr << " Switch has No mask- only 1 child " << std::endl; - } - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - sw->setName(gfd->getChar()); - } - return sw; - } - - osg::Sequence *makeSequence(const georecord *gr) - { - Sequence *sq=new Sequence; - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - sq->setName(gfd->getChar()); - } - return sq; - } - osg::LOD *makeLOD(const georecord *gr) - { - osg::LOD *gp=new LOD; - const geoField *gfd=gr->getField(GEO_DB_LOD_IN); - float in = gfd ? gfd->getFloat() : 100.0; - gfd=gr->getField(GEO_DB_LOD_OUT); - float out = gfd ? gfd->getFloat() : 0.0; - gp->setRange(0,out,in); - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - gp->setName(gfd->getChar()); - } - return gp; - } - osg::Drawable* createClipSurface(float xMin,float xMax,float yMin,float yMax,float z) - { // set up the Geometry that defines the clipped region. - osg::Geometry* geom = new osg::Geometry; - - osg::Vec3Array* coords = new osg::Vec3Array(4); - (*coords)[0].set(xMin,yMax,z); - (*coords)[1].set(xMin,yMin,z); - (*coords)[2].set(xMax,yMin,z); - (*coords)[3].set(xMax,yMax,z); - geom->setVertexArray(coords); - - geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); - - return geom; - } - Group *makeClipRegion(const georecord *gr) { - GeoClipRegion *clp=new GeoClipRegion; - const geoField *gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - clp->setName(gfd->getChar()); - } - gfd=gr->getField(140); - float *lleft = (gfd) ? (gfd->getVec3Arr()):NULL; - gfd=gr->getField(141); - float *uright= (gfd) ? (gfd->getVec3Arr()):NULL; - if (uright && lleft) { - Geode *geod=new Geode; - Drawable *drw=createClipSurface(lleft[0],uright[0],lleft[1],uright[1],lleft[2]); - geod->addDrawable(drw); - clp->addClipNode(geod); - } - return clp; - } - - geoHeader *makeHeader(const georecord *gr, const osgDB::ReaderWriter::Options* options) { - if (!theHeader.valid()) theHeader=new geoHeaderGeo(); - // the header contains variables as well as a transform for the XYZup cases - const geoField *gfd; - 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; - int iup=gfd ? gfd->getInt() : GEO_DB_UP_AXIS_Y; - - switch (iup) { - case GEO_DB_UP_AXIS_X: - q.set(0,1,0,1); - q/=q.length(); - theHeader->setAttitude(q); - break; - case GEO_DB_UP_AXIS_Y: - q.set(1,0,0,1); - q/=q.length(); -// theHeader->setMatrix(Matrix::rotate(pi2, osg::Vec3(1,0,0 )));//setAttitude(q); - theHeader->setAttitude(q); - break; - case GEO_DB_UP_AXIS_Z: // no change - q.set(0,0,0,1); - q/=q.length(); - theHeader->setAttitude(q); // set(q); - break; - } - std::vector::const_iterator itr; - for (itr=geotxlist.begin(); itrbhv=gr->getBehaviour(); - if (!bhv.empty()) { // then add internal, user, extern variables - for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); - rcitr!=bhv.end(); - ++rcitr) - { - if ((*rcitr)->getType()==DB_DSK_INTERNAL_VARS) { - theHeader->addInternalVars(**rcitr); - // theHeader->setUpdateCallback(theHeader->getInternalVars()); - } - if ((*rcitr)->getType()==DB_DSK_FLOAT_VAR) { - if (theHeader.valid()) theHeader->addUserVar((**rcitr)); - } - } - theHeader->setUpdateCallback(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.get(); - } - void makeTexture(const georecord *gr, const osgDB::ReaderWriter::Options* options) { - // scans the fields of this record and puts a new texture & environment into 'pool' stor - const geoField *gfd=gr->getField(GEO_DB_TEX_FILE_NAME); - const char *name = gfd->getChar(); - if (name) { - osg::ref_ptr tx = new Texture2D; - osg::ref_ptr ctx = osgDB::readImageFile(name,options); - if (ctx.valid()) { - ctx->setFileName(name); - tx->setImage(ctx.get()); - } - gfd=gr->getField(GEO_DB_TEX_WRAPS); - osg::Texture2D::WrapMode wm=Texture2D::REPEAT; - if (gfd) { - unsigned iwrap= gfd->getUInt(); - wm = (iwrap==GEO_DB_TEX_CLAMP) ? Texture2D::CLAMP : Texture2D::REPEAT; - } - tx->setWrap(Texture2D::WRAP_S, wm); - gfd=gr->getField(GEO_DB_TEX_WRAPT); - wm=Texture2D::REPEAT; - if (gfd) { - unsigned iwrap= gfd->getUInt(); - wm = (iwrap==GEO_DB_TEX_CLAMP) ? Texture2D::CLAMP : Texture2D::REPEAT; - } - tx->setWrap(Texture2D::WRAP_T, wm); - txlist.push_back(tx.get()); - osg::TexEnv* texenv = new osg::TexEnv; - osg::TexEnv::Mode md=osg::TexEnv::MODULATE; - gfd=gr->getField(GEO_DB_TEX_ENV); - texenv->setMode(md); - if (gfd) { - unsigned imod=gfd->getUInt(); - switch (imod) { - case GEO_DB_TEX_MODULATE: - md=osg::TexEnv::MODULATE; - break; - case GEO_DB_TEX_DECAL: - md=osg::TexEnv::DECAL; - break; - case GEO_DB_TEX_BLEND: - md=osg::TexEnv::BLEND; - break; - } - } - gfd=gr->getField(GEO_DB_TEX_MINFILTER); - osg::Texture::FilterMode filt=osg::Texture::NEAREST_MIPMAP_NEAREST; - if (gfd) { - unsigned imod=gfd->getUInt(); - switch (imod) { - case GEO_DB_TEX_NEAREST_MIPMAP_NEAREST: - filt=osg::Texture::LINEAR_MIPMAP_LINEAR; - break; - case GEO_DB_TEX_LINEAR_MIPMAP_NEAREST: - filt=osg::Texture::LINEAR_MIPMAP_NEAREST; - break; - case GEO_DB_TEX_NEAREST_MIPMAP_LINEAR: - filt=osg::Texture::NEAREST_MIPMAP_LINEAR; - break; - case GEO_DB_TEX_LINEAR_MIPMAP_LINEAR: - filt=osg::Texture::NEAREST_MIPMAP_NEAREST; - break; - } - } - tx->setFilter(osg::Texture::MIN_FILTER, filt); - gfd=gr->getField(GEO_DB_TEX_MAGFILTER); - if (gfd) { - unsigned imod=gfd->getUInt(); - switch (imod) { - case GEO_DB_TEX_NEAREST: - filt=osg::Texture::LINEAR; - break; - case GEO_DB_TEX_LINEAR: - filt=osg::Texture::NEAREST; - break; - } - } - txenvlist.push_back(texenv); - } - } - MatrixTransform *makeBehave(const georecord *gr) - { - MatrixTransform *mtr=NULL; - 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; - geoBehaviourCB *gcb=new geoBehaviourCB; - mtr->setUpdateCallback(gcb); - - for (std::vector< georecord *>::const_iterator rcitr=bhv.begin(); - rcitr!=bhv.end(); - ++rcitr) - { - switch ((*rcitr)->getType()) { - case DB_DSK_BEHAVIOR: { - const geoField *gfd=(*rcitr)->getField(GEO_DB_BEHAVIOR_NAME); - if (gfd) { - mtr->setName(gfd->getChar()); - } - } - break; - case DB_DSK_ROTATE_ACTION: { - geoMoveBehaviour *cb= new geoMoveBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - - case DB_DSK_SCALE_ACTION: { - geoMoveBehaviour *sb=new geoMoveBehaviour; - ok=sb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(sb); - else delete sb; - } - break; - case DB_DSK_TRANSLATE_ACTION: { - geoMoveBehaviour *cb= new geoMoveBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - - case DB_DSK_COMPARE_ACTION: { - geoCompareBehaviour *cb=new geoCompareBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - case DB_DSK_ARITHMETIC_ACTION: { - geoArithBehaviour *cb=new geoArithBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - case DB_DSK_CLAMP_ACTION: { - geoClampBehaviour *cb=new geoClampBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - case DB_DSK_RANGE_ACTION: { - geoRangeBehaviour *cb=new geoRangeBehaviour; - ok=cb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(cb); - else delete cb; - } - break; - case DB_DSK_VISIBILITY_ACTION: { - geoVisibBehaviour *vb = new geoVisibBehaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - 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.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; - case DB_DSK_INVERSE_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; - case DB_DSK_LINEAR_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; - case DB_DSK_PERIODIC_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; -#ifdef DB_DSK_PERIODIC2_ACTION - case DB_DSK_PERIODIC2_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; -#endif - case DB_DSK_TRUNCATE_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; - case DB_DSK_ABS_ACTION: { - geoAr3Behaviour *vb = new geoAr3Behaviour; - ok=vb->makeBehave((*rcitr), theHeader.get()); - 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.get()); - 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.get()); - if (ok) gcb->addBehaviour(vb); - else delete vb; - } - break; - } - } - } - if (!ok) { - mtr=NULL; - } - return mtr; - } - std::vector makeosg(const std::vector gr, const osgDB::ReaderWriter::Options* options) { - // recursive traversal of records and extract osg::Nodes equivalent - Group *geodeholder=NULL; - std::vector nodelist; - if (gr.size()>0) { - for (std::vector::const_iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - const georecord *gr=*itr; - Group *mtr=makeBehave(gr); - if (gr->getType()== DB_DSK_RENDERGROUP) { // geodes can require >1 geometry for example if polygons have different texture indices. - // 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 - const geoField *gfd=gr->getField(GEO_DB_GRP_ZBUFFER); - if (gfd) { - bool onoff=gfd->getBool(); - if (!onoff) { // no z buffer - force to use unsorted renderBin - StateSet *dstate=new StateSet; - osg::Depth* depth = new osg::Depth; - depth->setFunction(osg::Depth::ALWAYS); - dstate->setAttribute(depth); - dstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); - dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 1,"RenderBin"); - // dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 12, "UnSortedBin"); - if (geode) geode->setStateSet( dstate ); - if (animatedGeodes) animatedGeodes->setStateSet( dstate ); - if (lightptGeodes) lightptGeodes->setStateSet( dstate ); - if (textgeode) textgeode->setStateSet( dstate ); - } - } - - 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; - } else { - if (!geodeholder && (geode || textgeode)) { - geodeholder=new osg::Group; - geodeholder->setName("geodeHolder"); - } - if (geode) geodeholder->addChild(geode); - if (animatedGeodes) geodeholder->addChild(animatedGeodes); - if (lightptGeodes) geodeholder->addChild(lightptGeodes); - if (textgeode) geodeholder->addChild(textgeode); - } - } else { - Group *holder=NULL; - const geoField *gfd; - switch (gr->getType()) { - case 101: - case DB_DSK_HEADER: - holder=new osg::Group; // makeGroup(gr); - if (mtr) { - mtr->addChild(holder); - holder=mtr; - } - (*itr)->setNode(holder); - break; -/* holder= theHeader.get(); // makeHeader(gr);// - (*itr)->setNode(holder); - if (mtr) { - holder->addChild(mtr); - osg::Group *grp=makeGroup(gr); - mtr->addChild(grp); - holder=mtr; - } - break; */ - case DB_DSK_TEXTURE: - makeTexture(gr, options); - break; - case DB_DSK_BASE_GROUP: // start of a group plus extra features - holder=makeClipRegion(gr); - if (mtr) { - mtr->addChild(holder); - holder=mtr; - } - (*itr)->setNode(holder); - break; - case DB_DSK_GROUP: - holder=makeGroup(gr); - if (mtr) { - 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_NODE_NAME); - if (gfd) { - holder->setName(gfd->getChar()); - } - break; - case DB_DSK_SPHERE: - holder=new Group; - (*itr)->setNode(holder); - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - holder->setName(gfd->getChar()); - } - break; - case DB_DSK_CONE: - holder=new Group; - (*itr)->setNode(holder); - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - holder->setName(gfd->getChar()); - } - break; - case DB_DSK_CYLINDER: - holder=new Group; - (*itr)->setNode(holder); - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - holder->setName(gfd->getChar()); - } - break; - case DB_DSK_INSTANCE: - { - MatrixTransform *mtr=new MatrixTransform; - gfd=gr->getField(GEO_DB_NODE_NAME); - if (gfd) { - mtr->setName(gfd->getChar()); - } - gfd=gr->getField(GEO_DB_GRP_MATRIX_TRANSFORM); // was: 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_PERSPECTIVE_GRID_INFO: - { // relates to how model is viewed in Geo modeller - osg::Group *gp=new Group; - holder=gp; - } - break; - 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: - 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: - default: { - osg::Group *gp=new Group; - OSG_WARN << "Unhandled item " << gr->getType() << - "address " << (*itr) << std::endl; - holder=gp; - } - break; - } - if (holder) nodelist.push_back(holder); - - std::vector child=makeosg((*itr)->getchildren(), options); - GeoClipRegion *clip=dynamic_cast(holder); - for (std::vector::iterator itr=child.begin(); - itr!=child.end(); - ++itr) { - if (clip) clip->addClippedChild(*itr); - else holder->addChild(*itr); - } - } - } - } - if (geodeholder) { - osgUtil::Tessellator tessellator; - 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) tessellator.retessellatePolygons(*geom); - } - } - } - nodelist.push_back(geodeholder); - } - return nodelist; - } - void output(osgDB::Output &fout,std::vector gr) - { // debugging - print the tree of records - if (gr.size()>0) { - for (std::vector::iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - fout.indent() << "Node type " << (*itr).getType() << " "; - fout.indent() << (*itr) << std::endl; - } - } - } - void output(osgDB::Output &fout,std::vector gr) - { // debugging - print the tree of records - fout.moveIn(); - if (gr.size()>0) { - for (std::vector::iterator itr=gr.begin(); - itr!=gr.end(); - ++itr) { - fout.indent() << "Node type " << (*itr)->getType() << " "; - fout.indent() << (**itr) << std::endl; - fout.indent() << std::endl; - output(fout,(*itr)->getchildren()); - } - } - fout.moveOut(); - } - 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_INSTANCE_DEF); - if (gfd) { - uint fidnod=gfd->getUInt(); - if (fidnod==fid) return &(*itr); - } - break; - case DB_DSK_SEQUENCE: - gfd=(*itr).getField(GEO_DB_INSTANCE_DEF); - if (gfd) { - uint fidnod=gfd->getUInt(); - if (fidnod==fid) return &(*itr); - } - break; - case DB_DSK_SWITCH: - gfd=(*itr).getField(GEO_DB_INSTANCE_DEF); - if (gfd) { - uint fidnod=gfd->getUInt(); - if (fidnod==fid) return &(*itr); - } - break; - case DB_DSK_RENDERGROUP: - gfd=(*itr).getField(GEO_DB_INSTANCE_DEF); - if (gfd) { - uint fidnod=gfd->getUInt(); - if (fidnod==fid) return &(*itr); - } - break; - } - } - return NULL; - } - -private: - geoRecordList recs; // the records read from file - std::vector coord_pool; // current vertex ooords - std::vector normal_pool; // current pool of normal vectors - osg::ref_ptr theHeader; // an OSG class - 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< osg::ref_ptr > txlist; // list of osg::textures for this model - std::vector< osg::ref_ptr > txenvlist; // list of texture environments for the textures - std::vector< osg::ref_ptr > matlist; // list of materials for current model - georecord *cpalrec; // colour palette record -}; - -//======= -void internalVars::addInternalVars(const georecord &gr){ - const georecord::geoFieldList gfl=gr.getFields(); - for (georecord::geoFieldList::const_iterator itr=gfl.begin(); - itr!=gfl.end(); - ++itr) - {// for each variable - if ((*itr).getToken() >0) { - geoValue *nm=new geoValue((*itr).getToken(),(*itr).getUInt()); - vars.push_back(*nm); - } - } -} - -void userVars::addUserVar(const georecord &gr) { - const georecord::geoFieldList gfl=gr.getFields(); - if (gr.getType() == DB_DSK_FLOAT_VAR) { - unsigned int tok=0; // ? what for? - const geoField *gfd= gr.getField(GEO_DB_FLOAT_VAR_FID); - unsigned int fid=gfd ? gfd->getUInt():0; - geoValue *nm=new geoValue(tok,fid); - - gfd= gr.getField(GEO_DB_FLOAT_VAR_NAME); - const char *name=gfd->getChar(); - nm->setName(name); - - gfd= gr.getField(GEO_DB_FLOAT_VAR_VALUE); - 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); - if (gfd) { - nm->setConstrained(); - gfd= gr.getField(GEO_DB_FLOAT_VAR_MIN); - if (gfd) { - nm->setMinRange(gfd->getFloat()); - } - gfd= gr.getField(GEO_DB_FLOAT_VAR_MAX); - if (gfd) { - nm->setMaxRange(gfd->getFloat()); - } - } - gfd= gr.getField(GEO_DB_FLOAT_VAR_STEP); - //float fstp=gfd ? gfd->getFloat():0; - vars.push_back(*nm); - } -} - -void internalVars::update(const osg::FrameStamp *_frameStamp) { - double stmptime=_frameStamp->getSimulationTime(); - int iord=0; - for (std::vector::const_iterator itr=vars.begin(); //gfl.begin(); - itr!=vars.end(); // gfl.end(); - ++itr, iord++) - {// for each field - unsigned int typ=itr->getToken(); - switch (typ) { - case GEO_DB_INTERNAL_VAR_FRAMECOUNT: - vars[iord].setVal((float)_frameStamp->getFrameNumber()); - break; - case GEO_DB_INTERNAL_VAR_CURRENT_TIME: - { - 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->getSimulationTime(); - vars[iord].setVal(timeofday); - } - break; - case GEO_DB_INTERNAL_VAR_ELAPSED_TIME: - vars[iord].setVal(_frameStamp->getSimulationTime()); - break; - case GEO_DB_INTERNAL_VAR_SINE: - vars[iord].setVal(sin(stmptime)); - break; - case GEO_DB_INTERNAL_VAR_COSINE: - vars[iord].setVal(cos(stmptime)); - break; - case GEO_DB_INTERNAL_VAR_TANGENT: - vars[iord].setVal(tan(stmptime)); - break; - case GEO_DB_INTERNAL_VAR_MOUSE_X: // this is all windowing system dependent - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_MOUSE_Y: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_LEFT_MOUSE: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_MIDDLE_MOUSE: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_RIGHT_MOUSE: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_TEMP_FLOAT: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_TEMP_INT: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_TEMP_BOOL: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - case GEO_DB_INTERNAL_VAR_TEMP_STRING: - // vars[iord]=_frameStamp->getSimulationTime(); - break; - } - } - // std::cout<<"update callback - post traverse"<< (float)_frameStamp->getSimulationTime() <0) { - storageRead(fin); // allocate & fill the storage - if (tokenId == GEO_DB_NODE_EXT) { // added Nov 2003 to parse extension nodes - if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding - // if (TypeId == DB_CHAR ||TypeId == DB_UCHAR) fin.ignore(3); // skip padding - } - if (tokenId == GEO_DB_NODE_EXTENDED) { - if (id==DB_DSK_POLYGON || id==DB_DSK_RENDERGROUP || id==DB_DSK_GROUP - || id==DB_DSK_LOD || id==DB_DSK_MESH || id==DB_DSK_CUBE - || id==DB_DSK_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER - || id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) { - if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding - } - } - } - } - } -} - - -class ReaderWriterGEO : public osgDB::ReaderWriter -{ - public: - - ReaderWriterGEO() - { - supportsExtension("gem","CarbonGraphics Geo model format"); - supportsExtension("geo","CarbonGraphics Geo model format"); - } - - virtual const char* className() const { return "GEO Reader/Writer"; } - - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"gem") || osgDB::equalCaseInsensitive(extension,"geo"); - } - - virtual ReadResult readObject(const std::string& fileName, const Options* opt) const { return readNode(fileName,opt); } - - virtual ReadResult readNode(const std::string& file, const Options* options) const - { - std::string ext = osgDB::getLowerCaseFileExtension(file); - if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; - - std::string fileName = osgDB::findDataFile( file, options ); - if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; - - ReaderGEO reader; - return reader.readNode(fileName,options); - } - -}; - - -// now register with Registry to instantiate the above -// reader/writer. -REGISTER_OSGPLUGIN(geo, ReaderWriterGEO) diff --git a/src/osgPlugins/geo/geoActions.cpp b/src/osgPlugins/geo/geoActions.cpp deleted file mode 100644 index 47243d2bc..000000000 --- a/src/osgPlugins/geo/geoActions.cpp +++ /dev/null @@ -1,697 +0,0 @@ -// 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 -#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(unsigned int 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(osg::Node *) { // 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); - unsigned int 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(unsigned int 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(osg::Node *) { // 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) { - bool ok=false; - const geoField *gfd=grec->getField(GEO_DB_EQUATION_ACTION_INPUT_VAR); - const unsigned int act=grec->getType(); - 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(unsigned int 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(osg::Node *) { // do compare operation - if (in && out) { - double var2=varop? *varop : constant; - switch (oper) { - case 1: *out = (*in < var2) ? 1.0: -1.0; break;// Less - case 2: *out = (*in <= var2) ? 1.0: -1.0; break;//=LessOREQ - case 3: *out = (*in > var2) ? 1.0: -1.0; break; // greater... - case 4: *out = (*in >= var2) ? 1.0: -1.0; break; - case 5: *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); - unsigned int 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(osg::Node *) { // 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(osg::Node *) { // 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(osg::Node *) { // 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); - unsigned int nr=gfd?gfd->getUInt():1; - unsigned int 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)* // nov 2003 negative rotation convention - osg::Matrix::translate(centre)); - break; - } - } -} - -bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) { - bool ok=false; - const unsigned int act=grec->getType(); - 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); - const geoField *gfdir=grec->getField(GEO_DB_ROTATE_ACTION_DIR); - int flip=gfdir!=NULL; // ?(gfdir->getInt()):false; -// printf("Flip %d gfdir %x\n",flip, gfdir); - gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR); - if (gfd) { - float *ax= gfd->getVec3Arr(); // field identifier - if (flip) setAxis(-osg::Vec3(ax[0],ax[1],ax[2])); - else 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(osg::Matrix *mtr) { - // update the matrix mtr - if (getVar()) { - switch (getType()) { - case DB_DSK_SCALE_ACTION: - *mtr = (*mtr)*osg::Matrix::scale(getAxis()*(getValue())) ; - break; - case DB_DSK_TRANSLATE_ACTION: - *mtr = (*mtr)*osg::Matrix::translate(getAxis()*(getValue())) ; - break; - case DB_DSK_ROTATE_ACTION: - //std::cout << dr->getName() << " v: " << getVar() << " rotion " << DEG2RAD(getValue()) << std::endl; - *mtr = (*mtr)*osg::Matrix::translate(-getCentre())* - osg::Matrix::rotate(DEG2RAD(getValue()),getAxis())* - osg::Matrix::translate(getCentre()); - break; - } - } -} - -bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) -{ - const unsigned int act=grec->getType(); - 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; -} - -bool geoVisibBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) { - 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) -{ // 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) -{ // do visibility operation on Node - if (getVar()) { - double val=getValue(); - unsigned int idx=(unsigned int)val; - 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 (unsigned int i=nstart; i<(nend); i++) { - unsigned char col[4]; - unsigned int 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 -#ifdef USETEXT // buggy text feb 2003 - 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)); -#endif -} -bool geoStrContentBehaviour::makeBehave(const georecord *grec, const 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 -// printf("setting matrix %x\n", mtr); - // PositionAttitudeTransform *patr=dynamic_cast (node); - // if (patr) patr->setMatrix(Matrix::identity()); // all actions are multiplied to this - for (std::vector::const_iterator itr=gblist.begin(); - itrdoaction(node); -/* === the above is equivalent to my old code with lots of tests in: */ -/* geoArithBehaviour *ab=dynamic_cast(*itr); - if (ab) ab->doaction(node); - geoAr3Behaviour *a3=dynamic_cast(*itr); - if (a3) a3->doaction(node); - geoClampBehaviour *cb=dynamic_cast(*itr); - if (cb) cb->doaction(node); - geoRangeBehaviour *cr=dynamic_cast(*itr); - if (cr) cr->doaction(node); - geoCompareBehaviour *cmb=dynamic_cast(*itr); - if (cmb) cmb->doaction(node); - geoDiscreteBehaviour *db=dynamic_cast(*itr); - if (db) db->doaction(node); - 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::update(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(); - itrdoaction(dr); - Node *nd=NULL; - geoArithBehaviour *ab=dynamic_cast(*itr); - if (ab) ab->doaction(nd); - geoAr3Behaviour *a3=dynamic_cast(*itr); - if (a3) a3->doaction(nd); - geoClampBehaviour *cb=dynamic_cast(*itr); - if (cb) cb->doaction(nd); - geoRangeBehaviour *cr=dynamic_cast(*itr); - if (cr) cr->doaction(nd); - 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); - 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); - 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/geoCore.h b/src/osgPlugins/geo/geoCore.h deleted file mode 100644 index 76bbc96de..000000000 --- a/src/osgPlugins/geo/geoCore.h +++ /dev/null @@ -1,54 +0,0 @@ -/*===========================================================================*\ - - NAME: geoCore.h - - DESCRIPTION: High level DLL interface macros for the database library - - 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. - - This software file can only be used in conjunction with the Geo SDK & - libraries to create Plugin modules for the Geo 3D Modeling & Animation - package. - - COPYRIGHT NOTICE: - - Copyright © 1998-2001 Carbon Graphics Llc, ALL RIGHTS RESERVED - -\*===========================================================================*/ - - -#ifndef _GEO_CORE_H_ -#define _GEO_CORE_H_ - - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the GEO_DB_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// GEO_DB_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. - -#ifdef WIN32 - #ifdef GEO_DB_EXPORTS - #define GEO_DB_API __declspec( dllexport ) - #else - #define GEO_DB_API __declspec( dllimport ) - #endif -#else - #define GEO_DB_API -#endif - - -#include "geoTypes.h" -#include "geoVersion.h" - -#endif //_GEO_CORE_H_ - diff --git a/src/osgPlugins/geo/geoFormat.h b/src/osgPlugins/geo/geoFormat.h deleted file mode 100644 index 2240d0f7d..000000000 --- a/src/osgPlugins/geo/geoFormat.h +++ /dev/null @@ -1,1957 +0,0 @@ -/*===========================================================================*\ - -NAME: geoFormat.h - -DESCRIPTION: Native Format struct definitions, tokens & functionc - -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. - - Exception: - This Software file can be used by third-party software developers (without - using the Geo SDK libraries) for any purpose OTHER THAN loading Geo format - files into an application or executable (such as, though not limited to, - geometry Modelers & animation systems) which is primarily intended to allow for - the CREATION or MODIFICATION of geometric or animation data. - - Specifically,using this software (either all or part thereof) to aid in the - creation of a Geo format loader for a run-time system, game engine, toolkit - IG (Image Generation) System or any software where the PRIMARY purpose is - real-time image playback and interactivity and not Model Creation and/or - modification is permitted. - -COPYRIGHT NOTICE: - - Copyright © 1998-2001 Carbon Graphics Llc, ALL RIGHTS RESERVED - -\*===========================================================================*/ - - -#ifndef __GEO_FORMAT_H__ -#define __GEO_FORMAT_H__ - -#include "geoCore.h" - - -#define GEO_1_0_RC2 1132 -#define GEO_1_0_RC3 1133 -#define GEO_1_0_RC4 1134 -#define GEO_1_0 1141 - -#define GEO_1_1_RC1 1231 -#define GEO_1_1_RC2 1232 -#define GEO_1_1 1240 - - - - // GEO_VERSION = ((GEO_LIB_MAJOR_VERSION*1000)+ - // (GEO_LIB_MINOR_VERSION*100) + - // (GEO_LIB_LEVEL_VERSION*10) + - // (GEO_LIB_RELEASE_VERSION)) - - - - -// -// Constants to define the Node disk records. Used in RecordToken.id -// - - -/////////////////////////////////////////////////////////////////////////////// -// -// Record Ids -// -/////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------- -// Geo 1.0 RC 2 & Below -//---------------------------------------------------------------- - -//const unsigned int DB_DSK_HEADER = 101; - -//---------------------------------------------------------------- -// Geo 1.0 RC 3 & Above -//---------------------------------------------------------------- -const unsigned int DB_DSK_HEADER = 100; // NOTE File MAGIC ID *CHANGED* - -//---------------------------------------------------------------- -// -//---------------------------------------------------------------- - -const unsigned int DB_DSK_GROUP = 102; -const unsigned int DB_DSK_SEQUENCE = 104; -const unsigned int DB_DSK_LOD = 105; -const unsigned int DB_DSK_RENDERGROUP = 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_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; -// unsigned int DEPRICATED = 145; -const unsigned int DB_DSK_IF_CONDITION = 146; -const unsigned int DB_DSK_ELSE_CONDITION = 147; -// unsigned int DEPRICATED = 148; -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; -// unsigned int DEPRICATED = 157; -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_INSTANCE = 164; -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_NORMAL_POOL = 168; -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_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 -const unsigned int DB_DSK_PERSPECTIVE_GRID_INFO = 179; -const unsigned int DB_DSK_XY_GRID_INFO = 180; // not implemented in 1.0 -const unsigned int DB_DSK_XZ_GRID_INFO = 181; // not implemented in 1.0 -const unsigned int DB_DSK_YZ_GRID_INFO = 182; // not implemented in 1.0 -const unsigned int DB_DSK_MULTI_TEX_SHADER = 183; -const unsigned int DB_DSK_CULL_GROUP = 184; -const unsigned int DB_DSK_Z_OFFSET_GROUP = 185; -const unsigned int DB_DSK_MULTI_SAMPLE_AA_GROUP = 186; -const unsigned int DB_DSK_LINE_AA_GROUP = 187; -const unsigned int DB_DSK_FADE_GROUP = 188; -const unsigned int DB_DSK_TERRAIN = 189; -const unsigned int DB_DSK_BSP = 190; -const unsigned int DB_DSK_DECAL_GROUP = 191; -const unsigned int DB_DSK_STATE_MACHINE = 192; -const unsigned int DB_DSK_STATE = 193; -const unsigned int DB_DSK_TRANSITION = 194; -const unsigned int DB_DSK_STATE_MACHINE_ACTION = 195; -const unsigned int DB_DSK_STATE_RULE_ACTION = 196; -const unsigned int DB_DSK_TRANSITION_RULE_ACTION = 197; -const unsigned int DB_DSK_PUSH_ACTION = 198; // Indicates a list of child actions coming -const unsigned int DB_DSK_POP_ACTION = 199; // End of child action list -const unsigned int DB_DSK_LIGHT_GROUP = 200; -const unsigned int DB_DSK_CONTINUOUS_ACTION = 201; -const unsigned int DB_DSK_MOMENTARY_ACTION = 202; -const unsigned int DB_DSK_NSTATE_ACTION = 203; -const unsigned int DB_DSK_ROTARY_DRAG_ACTION = 204; -const unsigned int DB_DSK_DCS = 205; -const unsigned int DB_DSK_FAT_VERTEX = 206; -const unsigned int DB_DSK_SLIM_VERTEX = 207; -const unsigned int DB_DSK_CG_SHADER = 208; -const unsigned int DB_DSK_CGFX_SHADER = 209; -const unsigned int DB_DSK_GLSL_SHADER = 210; - - - - - - - -// -// 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_VEC2S = 35; // 2 dim array of shorts - -// -// 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 char MIN_CHAR_VAL = -128; -const char MAX_CHAR_VAL = 127; -const unsigned char MAX_UCHAR_VAL = 255; -const short MIN_SHORT_VAL = -32768; -const short MAX_SHORT_VAL = 32767; -const unsigned short MAX_USHORT_VAL = 65535; - - - - - -// -// Valid field size values are any value cleanly divisible by 4 & < 65536 -// - - -/** Record identifiers can be read as ints or this structure. All subsequent - * fields are considered part of this Node until an special EOF(ield) record - * is found. The only exception to this rule id DB_DSK_PUSH & DB_DSK_POP - * which have no fields. User parse code should expect another REcord header - * immediately after reading the Push/Pop record. - */ -struct GEO_DB_API geoRecordHeader -{ - unsigned int id; // e.g. DB_DSK_HEADER etc. -}; - - - - -/** When you are reading a Node's fields you read into this structure & expect - * a 1 byte id. When you are expecting records - you expect 4 byte int id's - */ -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 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 - -}; - - - - - -/** 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 geoExtendedFieldHeader 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. - * - * This field header exists only when field data items exceed the maximum - * number addressable by the size of an unsigned short (i.e. 65535). Typically - * this record will be the "data item" of a standard geoFieldHeader. Take the - * example of a large vertex palette... - * - * on disk: - * - * geoFieldHeader - * { - * DB_UCHAR id GEO_DB_VRTX_COORDS - * DB_UCHAR type DB_EXTENDED_FIELD_STRUCT - * DB_USHORT num 1 - * } - * - * parse code now knows there is 1 record of an extended field struct - * following the header. It just so happens that the following "data item" - * is itself a header (this time of the extended variety) - * - * next we find the geoExtendedFieldHeader. Id is repeated. - * - * geoExtendedFieldHeader - * { - * DB_USHORT id GEO_DB_VRTX_COORDS - * DB_USHORT type DB_VEC3F - * DB_UINT num number-of-verts - * } - * - * Read the data items "as normal". The id should be the same as the previous - * geoFieldHeader. Basically you will only ever find an geoExtendedFieldHeader - * after being informed of such by a preceeding geoFieldHeader. This means that - * parse code only needs to look for geoRecordHeader & geoFieldHeader records. - * It also means that there is enough info grouped together, so that an - * ignoreField function can work - given a geoFieldHeader to ignore. - * - * The id field is also an unsigned short in this header - meaning that records - * will be able to have more than 255 fields (the limit of a typical - * 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_NODE_EXTENDED - * DB_UCHAR type DB_EXTENDED_FIELD_STRUCT - * DB_USHORT num 1 - * } - * - * followed by... - * - * geoExtendedFieldHeader - * { - * DB_USHORT id GEO_DB_SOME_FUTURE_USHORT_ID - * DB_USHORT type DB_VEC3F - * DB_UINT num number_of_data_items - * } - * - * The GEO_DB_EXTENDED_FIELD is a special token which indicates that the "real" - * id will be a ushort and be found in the following geoExtendedFieldHeader - * - */ -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 - - /** 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 - -}; - - - - -/////////////////////////////////////////////////////////////////////////////// -// Constant to define the last field types -// -const unsigned char GEO_DB_LAST_FIELD = 0; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// Common NODE field types - can found for all SceneGraph Nodes -// -/////////////////////////////////////////////////////////////////////////////// - -const unsigned char GEO_DB_NODE_EXT = 1; -const unsigned char GEO_DB_NODE_PADDING = 2; -const unsigned char GEO_DB_NODE_EXTENDED = 4; -const unsigned char GEO_DB_NODE_COMMENT = 5; -const unsigned char GEO_DB_NODE_NAME = 6; -const unsigned char GEO_DB_NODE_ID = 7; // internal use only - - -/////////////////////////////////////////////////////////////////////////////// -// -// Field ID Address Ranges... -// -//NODE 1 through 19 -// DERIVED_A : public NODE 20 through 79 -// DERIVED_B : public DERIVED_A 80 through 139 -// DERIVED_C : public DERIVED_B 140 through 199 -// DERIVED_D : public DERIVED_C 200 through 255 -// -//Examples: -// -//GEO_DSK_MULTI_TEX_SHADER: -// Node Property IDs 1 through 19 -// Group Property IDs 20 through 79 -// RenderGroup property IDs 80 through 139 -// MultiTexShader Property IDs 140 through 199 -// -// -//DB_DSK_LIGHTPT: -// Node Property IDs 1 through 19 -// Polygon Property IDs 20 through 79 -// LightPt property IDs 80 through 139 -// -/////////////////////////////////////////////////////////////////////////////// - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_HEADER Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -const unsigned char GEO_DB_HDR_EXT = 1; // From Node -const unsigned char GEO_DB_HDR_PADDING = 2; // From Node -const unsigned char GEO_DB_HDR_EXTENDED = 4; // From Node -const unsigned char GEO_DB_HDR_COMMENT = 5; // From Node -const unsigned char GEO_DB_HDR_NAME = 6; // From Node -const unsigned char GEO_DB_HDR_NODE_ID = 7; // From Node - -const unsigned char GEO_DB_HDR_UNITS = 20; // Header Additions -const unsigned char GEO_DB_HDR_BBOX = 21; -const unsigned char GEO_DB_HDR_VERSION = 22; -const unsigned char GEO_DB_HDR_EXT_TEMPLATE = 23; -const unsigned char GEO_DB_HDR_UP_AXIS = 24; -const unsigned char GEO_DB_HDR_PROJ_TYPE = 25; -const unsigned char GEO_DB_HDR_LAMBERT1 = 26; -const unsigned char GEO_DB_HDR_LAMBERT2 = 27; -const unsigned char GEO_DB_HDR_UTM_ZONE = 28; -const unsigned char GEO_DB_HDR_SOUTHERN_HEMISPHERE = 29; -const unsigned char GEO_DB_HDR_ELLIPSOID = 30; -const unsigned char GEO_DB_HDR_ORIGIN_LAT = 31; -const unsigned char GEO_DB_HDR_ORIGIN_LON = 32; -const unsigned char GEO_DB_HDR_SW_CORNER_LAT = 33; -const unsigned char GEO_DB_HDR_SW_CORNER_LON = 34; -const unsigned char GEO_DB_HDR_NE_CORNER_LAT = 35; -const unsigned char GEO_DB_HDR_NE_CORNER_LON = 36; -const unsigned char GEO_DB_HDR_SW_CORNER_X = 37; -const unsigned char GEO_DB_HDR_SW_CORNER_Y = 38; -const unsigned char GEO_DB_HDR_OFFSET_X = 39; -const unsigned char GEO_DB_HDR_OFFSET_Y = 40; -const unsigned char GEO_DB_HDR_OFFSET_Z = 41; -const unsigned char GEO_DB_HDR_MAJOR_AXIS = 42; -const unsigned char GEO_DB_HDR_MINOR_AXIS = 43; - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// 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; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// 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; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// 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; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_COLOR_PALETTE Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -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_NAME = 7; -const unsigned char GEO_DB_TEX_CUBE_XP_FILE_NAME = 8; -const unsigned char GEO_DB_TEX_CUBE_XN_FILE_NAME = 9; -const unsigned char GEO_DB_TEX_CUBE_YP_FILE_NAME = 10; -const unsigned char GEO_DB_TEX_CUBE_YN_FILE_NAME = 11; -const unsigned char GEO_DB_TEX_CUBE_ZP_FILE_NAME = 12; -const unsigned char GEO_DB_TEX_CUBE_ZN_FILE_NAME = 13; -const unsigned char GEO_DB_TEX_INTERNAL_FORMAT = 14; -const unsigned char GEO_DB_TEX_ANISOTROPIC_FILTER = 15; -const unsigned char GEO_DB_TEX_REAL_WORLD_WIDTH = 16; -const unsigned char GEO_DB_TEX_REAL_WORLD_HEIGHT = 17; -const unsigned char GEO_DB_TEX_SENSOR_FILE_NAME = 18; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// Common SHADER field types - can found for all Shader Types -// -/////////////////////////////////////////////////////////////////////////////// - -const unsigned char GEO_DB_SHADER_NAME = 1; -const unsigned char GEO_DB_SHADER_VERTEX_PROGRAM = 2; -const unsigned char GEO_DB_SHADER_FRAGMENT_PROGRAM = 3; - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_CG_SHADER Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All shader Fields + - -const unsigned char GEO_DB_SHADER_CG_VERTEX_ENTRY = 20; -const unsigned char GEO_DB_SHADER_CG_VERTEX_PROFILE = 21; -const unsigned char GEO_DB_SHADER_CG_FRAGMENT_ENTRY = 22; -const unsigned char GEO_DB_SHADER_CG_FRAGMENT_PROFILE = 23; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_CGFX_SHADER Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All shader Fields + - -// currently No additional fields = 20 will be first addition - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_GLSL_SHADER Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All shader Fields + - -// currently No additional fields = 20 will be first addition - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_VIEW Record - Field 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_BACKFACE = 6; -const unsigned char GEO_DB_VIEW_TEXTURE = 7; -const unsigned char GEO_DB_VIEW_ILLUMINATED = 8; -const unsigned char GEO_DB_VIEW_ZBUFFER = 9; -const unsigned char GEO_DB_VIEW_SELECTIVE_ZBUFFER = 10; -const unsigned char GEO_DB_VIEW_DRAWSTYLE = 11; -const unsigned char GEO_DB_VIEW_SELECTIVE_CULLFACE = 12; -const unsigned char GEO_DB_VIEW_SELECTIVE_BLENDING = 13; -const unsigned char GEO_DB_VIEW_SELECTIVE_SHADING = 14; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_PERSPECTIVE_GRID_INFO Record -// -// DB_DSK_XY_GRID_INFO Record -// DB_DSK_XZ_GRID_INFO Record -// DB_DSK_YZ_GRID_INFO Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -const unsigned char GEO_DB_GRID_ON = 1; -const unsigned char GEO_DB_GRID_ZBUFFER = 2; -const unsigned char GEO_DB_GRID_SNAP = 3; -const unsigned char GEO_DB_GRID_OVER = 4; -const unsigned char GEO_DB_GRID_MAJOR = 5; -const unsigned char GEO_DB_GRID_MINOR = 6; -const unsigned char GEO_DB_GRID_NUM_CELLS = 7; -const unsigned char GEO_DB_GRID_POS = 8; -const unsigned char GEO_DB_GRID_MATRIX = 9; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + - -const unsigned char GEO_DB_GRP_BBOX = 20; // Group Additions -const unsigned char GEO_DB_GRP_INSTANCE_DEF = 21; -const unsigned char GEO_DB_GRP_FLAG_SHOW_BBOX = 22; -const unsigned char GEO_DB_GRP_ZBUFFER = 23; -const unsigned char GEO_DB_GRP_MATRIX_TRANSFORM = 24; -const unsigned char GEO_DB_GRP_TRANSLATE_TRANSFORM = 25; -const unsigned char GEO_DB_GRP_ROTATE_TRANSFORM = 26; -const unsigned char GEO_DB_GRP_SCALE_TRANSFORM = 27; -const unsigned char GEO_DB_GRP_TOD_DISPLAY = 28; -const unsigned char GEO_DB_GRP_NOISECT = 29; - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_LIGHT_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_LIGHT_GROUP_ENABLED = 80; -const unsigned char GEO_DB_LIGHT_GROUP_INTENSITY = 81; -const unsigned char GEO_DB_LIGHT_GROUP_ANIMATION = 82; -const unsigned char GEO_DB_LIGHT_GROUP_STABILIZED = 83; -const unsigned char GEO_DB_LIGHT_GROUP_TYPE = 84; -const unsigned char GEO_DB_LIGHT_GROUP_IG_LIGHTGROUP_ID = 85; - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_DCS Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_DCS_ACTIVE = 80; - -const unsigned char GEO_DB_DCS_TRANSLATE_X_DEFAULT = 81; -const unsigned char GEO_DB_DCS_TRANSLATE_X_MIN = 82; -const unsigned char GEO_DB_DCS_TRANSLATE_X_MAX = 83; -const unsigned char GEO_DB_DCS_TRANSLATE_X_STEP = 84; -const unsigned char GEO_DB_DCS_TRANSLATE_X_CLAMP = 85; - -const unsigned char GEO_DB_DCS_TRANSLATE_Y_DEFAULT = 86; -const unsigned char GEO_DB_DCS_TRANSLATE_Y_MIN = 87; -const unsigned char GEO_DB_DCS_TRANSLATE_Y_MAX = 88; -const unsigned char GEO_DB_DCS_TRANSLATE_Y_STEP = 89; -const unsigned char GEO_DB_DCS_TRANSLATE_Y_CLAMP = 90; - -const unsigned char GEO_DB_DCS_TRANSLATE_Z_DEFAULT = 91; -const unsigned char GEO_DB_DCS_TRANSLATE_Z_MIN = 92; -const unsigned char GEO_DB_DCS_TRANSLATE_Z_MAX = 93; -const unsigned char GEO_DB_DCS_TRANSLATE_Z_STEP = 94; -const unsigned char GEO_DB_DCS_TRANSLATE_Z_CLAMP = 95; - -const unsigned char GEO_DB_DCS_ROTATE_X_DEFAULT = 96; -const unsigned char GEO_DB_DCS_ROTATE_X_MIN = 97; -const unsigned char GEO_DB_DCS_ROTATE_X_MAX = 98; -const unsigned char GEO_DB_DCS_ROTATE_X_STEP = 99; -const unsigned char GEO_DB_DCS_ROTATE_X_CLAMP = 100; - -const unsigned char GEO_DB_DCS_ROTATE_Y_DEFAULT = 101; -const unsigned char GEO_DB_DCS_ROTATE_Y_MIN = 102; -const unsigned char GEO_DB_DCS_ROTATE_Y_MAX = 103; -const unsigned char GEO_DB_DCS_ROTATE_Y_STEP = 104; -const unsigned char GEO_DB_DCS_ROTATE_Y_CLAMP = 105; - -const unsigned char GEO_DB_DCS_ROTATE_Z_DEFAULT = 106; -const unsigned char GEO_DB_DCS_ROTATE_Z_MIN = 107; -const unsigned char GEO_DB_DCS_ROTATE_Z_MAX = 108; -const unsigned char GEO_DB_DCS_ROTATE_Z_STEP = 109; -const unsigned char GEO_DB_DCS_ROTATE_Z_CLAMP = 110; - -const unsigned char GEO_DB_DCS_SCALE_X_DEFAULT = 111; -const unsigned char GEO_DB_DCS_SCALE_X_MIN = 112; -const unsigned char GEO_DB_DCS_SCALE_X_MAX = 113; -const unsigned char GEO_DB_DCS_SCALE_X_STEP = 114; -const unsigned char GEO_DB_DCS_SCALE_X_CLAMP = 115; - -const unsigned char GEO_DB_DCS_SCALE_Y_DEFAULT = 116; -const unsigned char GEO_DB_DCS_SCALE_Y_MIN = 117; -const unsigned char GEO_DB_DCS_SCALE_Y_MAX = 118; -const unsigned char GEO_DB_DCS_SCALE_Y_STEP = 119; -const unsigned char GEO_DB_DCS_SCALE_Y_CLAMP = 120; - -const unsigned char GEO_DB_DCS_SCALE_Z_DEFAULT = 121; -const unsigned char GEO_DB_DCS_SCALE_Z_MIN = 122; -const unsigned char GEO_DB_DCS_SCALE_Z_MAX = 123; -const unsigned char GEO_DB_DCS_SCALE_Z_STEP = 124; -const unsigned char GEO_DB_DCS_SCALE_Z_CLAMP = 125; - -const unsigned char GEO_DB_DCS_ORIGIN = 126; -const unsigned char GEO_DB_DCS_XPOS = 127; -const unsigned char GEO_DB_DCS_ZPOS = 128; -const unsigned char GEO_DB_DCS_VECTOR = 129; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_CULL_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_CULL_GRP_RADIUS = 80; // CullGroup Additions - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_Z_OFFSET_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_Z_GRP_DEPTH_OFFSET = 80; // ZOffsetGroup Additions -const unsigned char GEO_DB_Z_GRP_DEPTH_OFFSET_CONSTANT = 81; -const unsigned char GEO_DB_Z_GRP_TYPE = 82; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_MULTI_SAMPLE_AA_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_MULTI_SAMPLE_AA_GRP_NUM_SAMPLES = 80; // MultiSampleAAGroup Additions -const unsigned char GEO_DB_MULTI_SAMPLE_AA_GRP_JITTER_RADIUS= 81; -const unsigned char GEO_DB_MULTI_SAMPLE_AA_GRP_ALPHA_CLAMP = 82; - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_LINE_AA_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_LINE_AA_GRP_RANGE = 80; // LineAAGroup Additions -const unsigned char GEO_DB_LINE_AA_GRP_ALPHA_FACTOR = 81; - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_FADE_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_FADE_GRP_NEAR_RANGE = 80; // FadeGroup Additions -const unsigned char GEO_DB_FADE_GRP_NEAR_TRANSITION = 81; -const unsigned char GEO_DB_FADE_GRP_FAR_RANGE = 82; -const unsigned char GEO_DB_FADE_GRP_FAR_TRANSITION = 83; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_TERRAIN Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - - // No Terrain Additions - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_DECAL_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -// No Decal Group Additions - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// DB_DSK_BSP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_BSP_PLANE_EQUATION = 80; // BSP Additions - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_LOD Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_LOD_IN = 80; // LOD Additions -const unsigned char GEO_DB_LOD_OUT = 81; -const unsigned char GEO_DB_LOD_CENTER = 82; -const unsigned char GEO_DB_LOD_CALC = 83; -const unsigned char GEO_DB_LOD_FREEZE_CENTER = 84; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_SEQUENCE Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_SEQUENCE_MODE = 80; // Sequence Additions -const unsigned char GEO_DB_SEQUENCE_ACTIVE = 81; -const unsigned char GEO_DB_SEQUENCE_FRAME_TIME = 82; -const unsigned char GEO_DB_SEQUENCE_USE_FRAME_TIME = 83; -const unsigned char GEO_DB_SEQUENCE_SWING = 84; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_INSTANCE Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_INSTANCE_DEF = 80; // instance Additions - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_SWITCH Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_SWITCH_CURRENT_MASK = 80; // switch Additions -const unsigned char GEO_DB_SWITCH_MASK_WIDTH = 81; -const unsigned char GEO_DB_SWITCH_NUM_MASKS = 82; -const unsigned char GEO_DB_SWITCH_MASKS = 83; - - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_PAGE Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_PAGE_ACTIVE_CHILD = 80; // page Additions - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_BASE_GROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// It is important to note that user extended Group fields begin with a field -// ID of 140 (GEO_DB_BASE_GROUP_START_EXTERNAL). This allows Geo to add -// additional fields to the BaseGroup class - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_BASE_GROUP_CLASSNAME = 80; // BaseGroup Additions -const unsigned char GEO_DB_BASE_GROUP_EXTENDED_TYPE = 81; -const unsigned char GEO_DB_BASE_GROUP_PLUGIN_REQUIRED = 82; - -const unsigned char GEO_DB_BASE_GROUP_START_EXTERNAL = 140; // User Derived Node Additions - - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// GEO_DB_BASE_SURFACE Record - Field Ids -// -// It is important to note that user extended Surface fields begin with a field -// ID of 80 (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 -// -// NOT IMPLEMENTED IN GEO 1.0 -// -/////////////////////////////////////////////////////////////////////////////// - - -// All Node Fields + - -const unsigned char GEO_DB_BASE_SURFACE_CLASSNAME = 20; // BaseSurface Additions -const unsigned char GEO_DB_BASE_SURFACE_EXTENDED_TYPE = 21; -const unsigned char GEO_DB_BASE_SURFACE_PLUGIN_REQUIRED = 22; - -const unsigned char GEO_DB_BASE_SURFACE_START_EXTERNAL = 80; // User Derived Node Additions - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_RENDERGROUP Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_RENDERGROUP_MAT = 80; // RenderGroup Additions -const unsigned char GEO_DB_RENDERGROUP_TERRAIN = 81; -const unsigned char GEO_DB_RENDERGROUP_BILLBOARD = 82; -const unsigned char GEO_DB_RENDERGROUP_LIGHTING = 83; -const unsigned char GEO_DB_RENDERGROUP_FOG = 84; -const unsigned char GEO_DB_RENDERGROUP_GAIN = 85; -const unsigned char GEO_DB_RENDERGROUP_TRANSPARENCY = 86; -const unsigned char GEO_DB_RENDERGROUP_CULLING = 87; -const unsigned char GEO_DB_RENDERGROUP_BLENDING = 88; -const unsigned char GEO_DB_RENDERGROUP_ALPHA_REF = 89; -const unsigned char GEO_DB_RENDERGROUP_LIGHTPTS = 90; - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_MULTI_TEX_SHADER Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + -// All RenderGroup Fields + - -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX0 = 140; // MultiTexShader Additions -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX1 = 141; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX2 = 142; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX3 = 143; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX4 = 144; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX5 = 145; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX6 = 146; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX7 = 147; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX0_FUNCTION = 148; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX1_FUNCTION = 149; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX2_FUNCTION = 150; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX3_FUNCTION = 151; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX4_FUNCTION = 152; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX5_FUNCTION = 153; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX6_FUNCTION = 154; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX7_FUNCTION = 155; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX0_BLEND_COLOR= 156; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX1_BLEND_COLOR= 157; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX2_BLEND_COLOR= 158; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX3_BLEND_COLOR= 159; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX4_BLEND_COLOR= 160; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX5_BLEND_COLOR= 161; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX6_BLEND_COLOR= 162; -const unsigned char GEO_DB_MULTI_TEX_SHADER_TEX7_BLEND_COLOR= 163; - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_POLYGON Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + - -const unsigned char GEO_DB_POLY_NORMAL = 20; // Polygon Additions -const unsigned char GEO_DB_POLY_CENTER = 21; -const unsigned char GEO_DB_POLY_PACKED_COLOR = 22; -const unsigned char GEO_DB_POLY_DSTYLE = 23; -const unsigned char GEO_DB_POLY_SHADEMODEL = 24; -const unsigned char GEO_DB_POLY_USE_MATERIAL_DIFFUSE = 25; -const unsigned char GEO_DB_POLY_USE_VERTEX_COLORS = 26; -const unsigned char GEO_DB_POLY_COLOR_INDEX = 27; -const unsigned char GEO_DB_POLY_PT_SIZE = 28; -const unsigned char GEO_DB_POLY_LINE_WIDTH = 29; -const unsigned char GEO_DB_POLY_TEX0 = 30; -const unsigned char GEO_DB_POLY_TEX1 = 31; -const unsigned char GEO_DB_POLY_TEX2 = 32; -const unsigned char GEO_DB_POLY_TEX3 = 33; -const unsigned char GEO_DB_POLY_TEX4 = 34; -const unsigned char GEO_DB_POLY_TEX5 = 35; -const unsigned char GEO_DB_POLY_TEX6 = 36; -const unsigned char GEO_DB_POLY_TEX7 = 37; -const unsigned char GEO_DB_POLY_TEX0_FUNCTION = 38; -const unsigned char GEO_DB_POLY_TEX1_FUNCTION = 39; -const unsigned char GEO_DB_POLY_TEX2_FUNCTION = 40; -const unsigned char GEO_DB_POLY_TEX3_FUNCTION = 41; -const unsigned char GEO_DB_POLY_TEX4_FUNCTION = 42; -const unsigned char GEO_DB_POLY_TEX5_FUNCTION = 43; -const unsigned char GEO_DB_POLY_TEX6_FUNCTION = 44; -const unsigned char GEO_DB_POLY_TEX7_FUNCTION = 45; -const unsigned char GEO_DB_POLY_TEX0_BLEND_COLOR = 46; -const unsigned char GEO_DB_POLY_TEX1_BLEND_COLOR = 47; -const unsigned char GEO_DB_POLY_TEX2_BLEND_COLOR = 48; -const unsigned char GEO_DB_POLY_TEX3_BLEND_COLOR = 49; -const unsigned char GEO_DB_POLY_TEX4_BLEND_COLOR = 50; -const unsigned char GEO_DB_POLY_TEX5_BLEND_COLOR = 51; -const unsigned char GEO_DB_POLY_TEX6_BLEND_COLOR = 52; -const unsigned char GEO_DB_POLY_TEX7_BLEND_COLOR = 53; -const unsigned char GEO_DB_POLY_WHITE_IF_TEXTURED = 54; -const unsigned char GEO_DB_POLY_BASE = 55; -const unsigned char GEO_DB_POLY_DECAL = 56; -const unsigned char GEO_DB_POLY_HIDDEN = 57; -const unsigned char GEO_DB_POLY_HELPER_TYPE = 58; -const unsigned char GEO_DB_POLY_BINORMAL = 59; -const unsigned char GEO_DB_POLY_TANGENT = 60; -const unsigned char GEO_DB_POLY_SHADER = 61; -const unsigned char GEO_DB_POLY_SMC = 62; -const unsigned char GEO_DB_POLY_FID = 63; -const unsigned char GEO_DB_POLY_FOOTPRINT = 64; - - - - -/////////////////////////////////////////////////////////////////// -// -// 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; -const unsigned char GEO_DB_PLANE_TEXTURE_MAPPING_INFO_TEXTURE_UNIT = 4; - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_LIGHTPT Record - Field Ids -// -// Many of the possible LightPt fields do not make sense in the context of a -// Light point - namely most of the Polygon rendering & texturing properties. -// These will likely not be present in a Geo file - if they are they can be -// ignored. -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Poly Fields + - -const unsigned char GEO_DB_LIGHTPT_TYPE = 80; // LightPt Additions -const unsigned char GEO_DB_LIGHTPT_DIRECTION_VECTOR = 81; -const unsigned char GEO_DB_LIGHTPT_BACK_PACKED_COLOR = 82; -const unsigned char GEO_DB_LIGHTPT_MIN_PIXEL_SIZE = 83; -const unsigned char GEO_DB_LIGHTPT_MAX_PIXEL_SIZE = 84; -const unsigned char GEO_DB_LIGHTPT_HORIZ_LOBE_ANGLE = 85; -const unsigned char GEO_DB_LIGHTPT_VERT_LOBE_ANGLE = 86; -const unsigned char GEO_DB_LIGHTPT_DAY_DISPLAY = 87; -const unsigned char GEO_DB_LIGHTPT_DUSK_DISPLAY = 88; -const unsigned char GEO_DB_LIGHTPT_NIGHT_DISPLAY = 89; -const unsigned char GEO_DB_LIGHTPT_BACK_COLOR_INDEX = 90; -const unsigned char GEO_DB_LIGHTPT_SPECIAL_FX = 91; -const unsigned char GEO_DB_LIGHTPT_ANIM_FRAME_COUNT = 92; -const unsigned char GEO_DB_LIGHTPT_ANIM_ACTUAL_COUNT = 93; -const unsigned char GEO_DB_LIGHTPT_IG_LIGHTGROUP_ID = 94; -const unsigned char GEO_DB_LIGHTPT_ANIM_PHASE_DELAY = 95; -const unsigned char GEO_DB_LIGHTPT_OPTIMIZATION = 96; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_TEXT Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + - -const unsigned char GEO_DB_TEXT_TYPE = 20; // Text Additions -const unsigned char GEO_DB_TEXT_STRING = 21; -const unsigned char GEO_DB_TEXT_JUSTIFICATION = 22; -const unsigned char GEO_DB_TEXT_DIRECTION = 23; -const unsigned char GEO_DB_TEXT_LINEWIDTH = 24; -const unsigned char GEO_DB_TEXT_PACKED_COLOR = 25; -const unsigned char GEO_DB_TEXT_SCALE_X = 26; -const unsigned char GEO_DB_TEXT_SCALE_Y = 27; -const unsigned char GEO_DB_TEXT_MATRIX = 28; -const unsigned char GEO_DB_TEXT_EXPANSION = 29; -const unsigned char GEO_DB_TEXT_COLOR_INDEX = 30; -const unsigned char GEO_DB_TEXT_FONT = 31; - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_MESH Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Poly Fields + - -const unsigned char GEO_DB_MESH_TYPE = 80; // Mesh Additions - - - - - - - - - - - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_VERTEX Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + - -const unsigned char GEO_DB_VRTX_COORD_INDEX = 20; // Vertex Additions -const unsigned char GEO_DB_VRTX_UV_SET_0 = 21; -const unsigned char GEO_DB_VRTX_UV_SET_1 = 22; -const unsigned char GEO_DB_VRTX_UV_SET_2 = 23; -const unsigned char GEO_DB_VRTX_UV_SET_3 = 24; -const unsigned char GEO_DB_VRTX_UV_SET_4 = 25; -const unsigned char GEO_DB_VRTX_UV_SET_5 = 26; -const unsigned char GEO_DB_VRTX_UV_SET_6 = 27; -const unsigned char GEO_DB_VRTX_UV_SET_7 = 28; -const unsigned char GEO_DB_VRTX_NORMAL = 29; -const unsigned char GEO_DB_VRTX_PACKED_COLOR = 30; -const unsigned char GEO_DB_VRTX_COLOR_INDEX = 31; -const unsigned char GEO_DB_VRTX_COORD = 32; -const unsigned char GEO_DB_VRTX_HARD_EDGE = 33; -const unsigned char GEO_DB_VRTX_FREEZE_NORMAL = 34; -const unsigned char GEO_DB_VRTX_BINORMAL = 59; -const unsigned char GEO_DB_VRTX_TANGENT = 60; - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_FAT_VERTEX Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - - -// All Node Fields + -// All VERTEX Fields + - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_SLIM_VERTEX Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - - -// All Node Fields + -// All VERTEX Fields + - -const unsigned char GEO_DB_VRTX_FLAGS = 80; -/* packed 32-bit flags with following format... - bit 0 GEO_DB_VRTX_UV_SET_0 is set - bit 1 GEO_DB_VRTX_UV_SET_1 is set - bit 2 spare - bit 3 spare - bit 4 hard_edge - bit 5 freeze_normal - bits 6-31 spare */ - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO_DB_EXTERNAL Record - Field Ids -// -/////////////////////////////////////////////////////////////////////////////// - -// All Node Fields + -// All Group Fields + - -const unsigned char GEO_DB_EXTERNAL_FILENAME = 80; // External Additions - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// -// GEO BEHAVIOR & ARTICULATION SYSTEM RECORDS -// -/////////////////////////////////////////////////////////////////////////////// - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_INTERNAL_VARS Record Field Ids -// -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_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_TRIGGER1 = 17; -const unsigned char GEO_DB_INTERNAL_VAR_TRIGGER2 = 18; -const unsigned char GEO_DB_INTERNAL_VAR_TRIGGER3 = 19; -const unsigned char GEO_DB_INTERNAL_VAR_TRIGGER4 = 20; - - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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; - - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_STATE_MACHINE Record Field Ids -// -const unsigned char GEO_DB_STATE_MACHINE_NAME = 1; - - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_STATE Record Field Ids (states of the State machine) -// -const unsigned char GEO_DB_STATE_NAME = 1; -const unsigned char GEO_DB_STATE_DEFAULT = 2; -const unsigned char GEO_DB_STATE_POSITION = 3; -const unsigned char GEO_DB_STATE_DEFAULT_TRANSITION = 4; - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_TRANSITION Record Field Ids (transitions of the State machine) -// -const unsigned char GEO_DB_TRANSITION_NAME = 1; -const unsigned char GEO_DB_TRANSITION_SOURCE = 2; -const unsigned char GEO_DB_TRANSITION_DESTINATION = 3; -const unsigned char GEO_DB_TRANSITION_DURATION = 4; -const unsigned char GEO_DB_TRANSITION_TRIGGER = 5; -const unsigned char GEO_DB_TRANSITION_CONNECTORS = 6; -const unsigned char GEO_DB_TRANSITION_RATIO = 7; - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_STATE_MACHINE_ACTION Record Field Ids -// -// Record structure for a State Machine Action with 2 States & 2 Transitions -// (where the 1st transition rule used a rotation & the second a translation) -// would be: -// DB_DSK_STATE_MACHINE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_STATE_RULE_ACTION -// DB_DSK_STATE_RULE_ACTION -// DB_DSK_TRANSITION_RULE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_ROTATE_ACTION -// DB_DSK_POP_ACTION -// DB_DSK_TRANSITION_RULE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_TRANSLATE_ACTION -// DB_DSK_POP_ACTION -// DB_DSK_POP_ACTION -// -// if the first state had an optional set of actions to perform when -// active it would have the following construct... -// DB_DSK_STATE_MACHINE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_STATE_RULE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_ARITHMETIC -// DB_DSK_VISIBILITY -// DB_DSK_POP_ACTION -// DB_DSK_STATE_RULE_ACTION -// DB_DSK_TRANSITION_RULE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_ROTATE_ACTION -// DB_DSK_POP_ACTION -// DB_DSK_TRANSITION_RULE_ACTION -// DB_DSK_PUSH_ACTION -// DB_DSK_TRANSLATE_ACTION -// DB_DSK_POP_ACTION -// DB_DSK_POP_ACTION -const unsigned char GEO_DB_STATE_MACHINE_ACTION_NAME = 1; - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_STATE_RULE_ACTION Record Field Ids -// -const unsigned char GEO_DB_STATE_RULE_ACTION_STATE_MACHINE_NAME = 1; -const unsigned char GEO_DB_STATE_RULE_ACTION_STATE_NAME = 2; -const unsigned char GEO_DB_STATE_RULE_ACTION_HIDDEN = 3; -const unsigned char GEO_DB_STATE_RULE_ACTION_IDENTITY = 4; // deprecated - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_TRANSITION_RULE_ACTION Record Field Ids -// -const unsigned char GEO_DB_TRANSITION_RULE_ACTION_STATE_MACHINE_NAME = 1; -const unsigned char GEO_DB_TRANSITION_RULE_ACTION_TRANSITION_NAME = 2; -const unsigned char GEO_DB_TRANSITION_RULE_ACTION_HIDDEN = 3; - - - - -/////////////////////////////////////////////////////////////////// -// GEO_DSK_BEHAVIOR Record Field Ids -// -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_MAX = 6; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_PERIODIC_ACTION Record Field Ids -// -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; - - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_CONTINUOUS_ACTION Record Field Ids -// -const unsigned char GEO_DB_CONTINUOUS_ACTION_INPUT_VAR = 1; // Not used -const unsigned char GEO_DB_CONTINUOUS_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_CONTINUOUS_ACTION_UPDATE_TYPE = 4; -const unsigned char GEO_DB_CONTINUOUS_ACTION_UPDATE_VAL = 5; -const unsigned char GEO_DB_CONTINUOUS_ACTION_DEFAULT_VAL = 6; -const unsigned char GEO_DB_CONTINUOUS_ACTION_MIN_VAL = 7; -const unsigned char GEO_DB_CONTINUOUS_ACTION_MAX_VAL = 8; -const unsigned char GEO_DB_CONTINUOUS_ACTION_DIRECTION = 9; -const unsigned char GEO_DB_CONTINUOUS_ACTION_MINMAX_BEHAVIOR = 10; - - - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_MOMENTARY_ACTION Record Field Ids -// -const unsigned char GEO_DB_MOMENTARY_ACTION_INPUT_VAR = 1; // Not used -const unsigned char GEO_DB_MOMENTARY_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_MOMENTARY_ACTION_DEFAULT_VAL = 3; -const unsigned char GEO_DB_MOMENTARY_ACTION_VAL = 4; - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_NSTATE_ACTION Record Field Ids -// -const unsigned char GEO_DB_NSTATE_ACTION_INPUT_VAR = 1; // Not used -const unsigned char GEO_DB_NSTATE_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_NSTATE_ACTION_DIRECTION = 3; -const unsigned char GEO_DB_NSTATE_ACTION_BEHAVIOR = 4; -const unsigned char GEO_DB_NSTATE_ACTION_NUM_ITEMS = 5; -const unsigned char GEO_DB_NSTATE_ACTION_OUTPUT_VAR_TYPE = 6; -const unsigned char GEO_DB_NSTATE_ACTION_VALS = 7; - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_ROTARY_DRAG_ACTION Record Field Ids -// -const unsigned char GEO_DB_ROTARY_DRAG_ACTION_INPUT_VAR = 1; // Not used -const unsigned char GEO_DB_ROTARY_DRAG_ACTION_OUTPUT_VAR = 2; -const unsigned char GEO_DB_ROTARY_DRAG_ACTION_BEHAVIOR = 3; -const unsigned char GEO_DB_ROTARY_DRAG_ACTION_ORIGIN = 4; - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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 - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////// -// 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_OPERAND_VALUE = 4; -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_MAX = 7; - - - -/////////////////////////////////////////////////////////////////// -// 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; -const unsigned char GEO_DB_SCALE_ACTION_MAX = 8; - - - -/////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////// -// 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 - - -/////////////////////////////////////////////////////////////////// -// DB_DSK_CONDITIONAL_ACTION Record Field Ids -// -// Record structure for compound if-the-else block of Actions -// The conditional action has an optional list of actions if the -// input var passes the conditional test (Not equal zero) and an -// alternative list of actions if the input var does not pass -// the conditional test (the else selction). In a simple case -// where the conditional action had one rotate action on pass & -// a range & rotate on fail the disk rep would be... -// would be: -// DB_DSK_CONDITIONAL_ACTION -// DB_DSK_PUSH_ACTION // indicates list of child actions -// DB_DSK_IF_CONDITION // all following are for If list -// DB_DSK_ROTATE -// DB_DSK_ELSE_CONDITION // all following are for Else list -// DB_DSK_RANGE -// DB_DSK_ROTATE -// DB_DSK_POP_ACTION -// -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; - - - - - - - -/////////////////////////////////////////////////////////////////// -// 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; - - - - - -/** Record identifiers can be read as ints or this structure. All subsequent - * fields are considered part of this Node until an special EOF(ield) record - * is found. The only exception to this rule id DB_DSK_PUSH & DB_DSK_POP - * which have no fields. User parse code should expect another REcord header - * immediately after reading the Push/Pop record. - */ -struct GEO_DB_API geoExtensionDefRec -{ - - /** 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_DATATYPE_INT - * GEO_DB_DATATYPE_FLOAT, GEO_DB_DATATYPE_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_DATATYPE_BOOL means that this extension will be accessed as one - * of many in an option menu - */ - unsigned char subdatatype; // 1 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_DATATYPE_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 - - - - -#endif // __GEO_FORMAT_H__ - diff --git a/src/osgPlugins/geo/geoTypes.h b/src/osgPlugins/geo/geoTypes.h deleted file mode 100644 index 24b2b034d..000000000 --- a/src/osgPlugins/geo/geoTypes.h +++ /dev/null @@ -1,618 +0,0 @@ -/*===========================================================================*\ - -NAME: geoTypes.h - -DESCRIPTION: Constants fro Node types etc. - -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. - - Exception: - This Software file can be used by third-party software developers (without - using the Geo SDK libraries) for any purpose OTHER THAN loading Geo format - files into an application or executable (such as, though not limited to, - geometry Modelers & animation systems) which is primarily intended to allow for - the CREATION or MODIFICATION of geometric or animation data. - - Specifically,using this software (either all or part thereof) to aid in the - creation of a Geo format loader for a run-time system, game engine, toolkit - IG (Image Generation) System or any software where the PRIMARY purpose is - real-time image playback and interactivity and not Model Creation and/or - modification is permitted. - -COPYRIGHT NOTICE: - - Copyright © 1998-2001 Carbon Graphics Llc, ALL RIGHTS RESERVED - -\*===========================================================================*/ - - - -#ifndef _GEO_TYPES_H_ -#define _GEO_TYPES_H_ - - - -#ifndef uint -#define uint unsigned int -#endif - -#ifndef ushort -#define ushort unsigned short -#endif - -#ifndef ubyte -#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_SURFACE_NODE_DEF = 8; -const uint GEO_PLUGIN_TYPE_TASK = 9; -const uint GEO_PLUGIN_TYPE_LAST = GEO_PLUGIN_TYPE_TASK; - - - - -/** put nowhere */ -const uint GEO_TOOL_TYPE_NONE = 0; - -/** user tool constant - put in favorites menu & toolbar */ -const uint GEO_TOOL_TYPE_USER = 1; - -/** create tool constant - put in create menu & toolbar */ -const uint GEO_TOOL_TYPE_CREATE = 2; - -/** modify tool constant - put in modify menu & toolbar */ -const uint GEO_TOOL_TYPE_MODIFY = 3; - -/** helper point tool constant - put in helpers menu & toolbar */ -const uint GEO_TOOL_TYPE_HELPER_PT = 4; - -/** appearance tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_APPEARANCE = 5; - -/** behavior tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_BEHAVIOR = 6; - -/** optimize tool constant - put in plugins menu & toolbar */ -const uint GEO_TOOL_TYPE_OPTIMIZE = 7; - -/** scenegraph tool constant - put in scenegraph menu & toolbar */ -const uint GEO_TOOL_TYPE_SCENEGRAPH = 8; - -const uint GEO_TOOL_TYPE_FILE = 9; - -const uint GEO_TOOL_TYPE_EDIT = 10; - -const uint GEO_TOOL_TYPE_VIEW = 11; - -const uint GEO_TOOL_TYPE_LOD = 12; - -const uint GEO_TOOL_TYPE_SELECT = 13; - -const uint GEO_TOOL_TYPE_GRID = 14; - -/** convenience constant */ -const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_GRID; - - - -/** - * Node Type identifiers. These tokens encode the Node's inheritance - * information within the type - * - * The GEO Node Type Class Hierarchy is as follows... - * - * GEO_DB_BASE - * GEO_DB_GROUP - * GEO_DB_SEQUENCE - * GEO_DB_LOD - * GEO_DB_SWITCH - * GEO_DB_BASE_GROUP - * GEO_DB_RENDERGROUP - * GEO_DB_MULTI_TEX_SHADER - * GEO_DB_BASE_RENDERGROUP (*) - * GEO_DB_EXTERNAL - * GEO_DB_INSTANCE - * GEO_DB_PAGE - * GEO_DB_CULL_GROUP - * GEO_DB_Z_OFFSET_GROUP - * GEO_DB_MULTI_SAMPLE_AA_GROUP - * GEO_DB_LINE_AA_GROUP - * GEO_DB_FADE_GROUP - * GEO_DB_TERRAIN - * GEO_DB_BSP - * GEO_DB_DECAL_GROUP - * GEO_DB_LIGHT_GROUP - * GEO_DB_DCS - * GEO_DB_GEOMETRY - * GEO_DB_SURFACE - * GEO_DB_POLYGON - * GEO_DB_LIGHTPT - * GEO_DB_MESH - * GEO_DB_BASE_SURFACE (*) - * GEO_DB_TEXT - * GEO_DB_VERTEX - * GEO_DB_FAT_VERTEX - * GEO_DB_SLIM_VERTEX - * GEO_DB_HEADER - * - * (*) Not available in Geo Version 1.0 - */ - - -//-------------------------------------------------------------------- -// Geo Node type Identifiers -//-------------------------------------------------------------------- -// -const uint GEO_DB_BASE = 0x00000003; -const uint GEO_DB_GROUP = (0x00000004 | GEO_DB_BASE); -const uint GEO_DB_TERRAIN = (0x00000008 | GEO_DB_GROUP); -//------------ -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_BSP = (0x00000400 | GEO_DB_GROUP); -const uint GEO_DB_POLYGON = (0x00000800 | GEO_DB_SURFACE); -//------------ -const uint GEO_DB_MESH = (0x00001000 | GEO_DB_POLYGON); -const uint GEO_DB_CULL_GROUP = (0x00002000 | GEO_DB_GROUP); -const uint GEO_DB_MULTI_TEX_SHADER = (0x00004000 | GEO_DB_RENDERGROUP); -const uint GEO_DB_PAGE = (0x00008000 | GEO_DB_GROUP); -//------------ -const uint GEO_DB_Z_OFFSET_GROUP = (0x00010000 | GEO_DB_GROUP); -const uint GEO_DB_MULTI_SAMPLE_AA_GROUP = (0x00020000 | GEO_DB_GROUP); -const uint GEO_DB_TEXT = (0x00040000 | GEO_DB_GEOMETRY); -const uint GEO_DB_VERTEX = (0x00080000 | GEO_DB_GEOMETRY); -//------------ -const uint GEO_DB_HEADER = (0x00100000 | GEO_DB_BASE); -const uint GEO_DB_LINE_AA_GROUP = (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_BASE_RENDERGROUP = (0x02000000 | GEO_DB_RENDERGROUP); -const uint GEO_DB_INSTANCE = (0x04000000 | GEO_DB_GROUP); -const uint GEO_DB_LIGHTPT = (0x08000000 | GEO_DB_POLYGON); -//------------ -const uint GEO_DB_FADE_GROUP = (0x10000000 | GEO_DB_GROUP); -const uint GEO_DB_DECAL_GROUP = (0x20000000 | GEO_DB_GROUP); -const uint GEO_DB_LIGHT_GROUP = (0x40000000 | GEO_DB_GROUP); -const uint GEO_DB_FAT_VERTEX = (0x80000000 | GEO_DB_VERTEX); -//------------ - -//-------------------------------------------------------------------- -// Geo Extended Node type Identifiers -//-------------------------------------------------------------------- -const uint GEO_DB_SLIM_VERTEX = (0x00000010 | GEO_DB_VERTEX); -const uint GEO_DB_DCS = (0x00001000 | GEO_DB_GROUP); - - - - -// 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_GEOMETRY_TYPES = GEO_DB_GEOMETRY; -const uint GEO_DB_ALL_SURFACE_TYPES = GEO_DB_SURFACE; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** 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_GRID = 0x00000010; -const uint GEO_PICK_NON_NODE = 0x00000020; // manipulators, user geometry etc. -const uint GEO_PICK_EXTERNAL = 0x00000040; -const uint GEO_PICK_TEXT = 0x00000080; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** 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; - - -/////////////////////////////////////////////////////////////////// -// PROPERTY TYPES -/////////////////////////////////////////////////////////////////// - -// Identifiers for Geo data types - Used in geoProperty & geoPropertyExtension Classes -const unsigned char GEO_DB_DATATYPE_STRING = 1; -const unsigned char GEO_DB_DATATYPE_SHORT = 2; -const unsigned char GEO_DB_DATATYPE_INT = 3; -const unsigned char GEO_DB_DATATYPE_FLOAT = 4; -const unsigned char GEO_DB_DATATYPE_LONG = 5; -const unsigned char GEO_DB_DATATYPE_DOUBLE = 6; -const unsigned char GEO_DB_DATATYPE_VEC3F = 8; -const unsigned char GEO_DB_DATATYPE_VEC4F = 9; -const unsigned char GEO_DB_DATATYPE_BOOL = 28; - -/////////////////////////////////////////////////////////////////// -// VARIABLE TYPES -/////////////////////////////////////////////////////////////////// - -const uint GEO_VAR_TYPE_FLOAT = 1; -const uint GEO_VAR_TYPE_INT = 2; -const uint GEO_VAR_TYPE_LONG = 3; -const uint GEO_VAR_TYPE_DOUBLE = 4; -const uint GEO_VAR_TYPE_BOOL = 5; -const uint GEO_VAR_TYPE_2FV = 6; -const uint GEO_VAR_TYPE_3FV = 7; -const uint GEO_VAR_TYPE_4FV = 8; -const uint GEO_VAR_TYPE_STRING = 9; -const uint GEO_VAR_TYPE_2IV = 10; -const uint GEO_VAR_TYPE_3IV = 11; -const uint GEO_VAR_TYPE_4IV = 12; -const uint GEO_VAR_TYPE_16FV = 13; -const uint GEO_VAR_TYPE_2BV = 14; -const uint GEO_VAR_TYPE_3BV = 15; -const uint GEO_VAR_TYPE_4BV = 16; -const uint GEO_VAR_TYPE_SAMPLER_1D = 17; -const uint GEO_VAR_TYPE_SAMPLER_2D = 18; -const uint GEO_VAR_TYPE_SAMPLER_3D = 19; -const uint GEO_VAR_TYPE_SAMPLER_CUBE = 20; -const uint GEO_VAR_TYPE_SAMPLER_1D_SHADOW = 21; -const uint GEO_VAR_TYPE_SAMPLER_2D_SHADOW = 22; - - - -/////////////////////////////////////////////////////////////////// -// TRANSFORM TYPES -/////////////////////////////////////////////////////////////////// - -const uint GEO_TRANSFORM_TYPE_TRANSLATE = 1; -const uint GEO_TRANSFORM_TYPE_ROTATE = 2; -const uint GEO_TRANSFORM_TYPE_SCALE = 3; -const uint GEO_TRANSFORM_TYPE_MATRIX = 4; - - - -/////////////////////////////////////////////////////////////////////////////// -/** 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; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** 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 short GEO_DB_PROJ_TYPE_FLAT_EARTH = 0; -const short GEO_DB_PROJ_TYPE_TRAPEZOIDAL = 1; -const short GEO_DB_PROJ_TYPE_ROUND_EARTH = 2; -const short GEO_DB_PROJ_TYPE_LAMBERT = 3; -const short GEO_DB_PROJ_TYPE_UTM = 4; -const short GEO_DB_PROJ_TYPE_GEODETIC = 5; -const short GEO_DB_PROJ_TYPE_GEOCENTRIC = 6; -const short GEO_DB_PROJ_TYPE_LAST = GEO_DB_PROJ_TYPE_GEOCENTRIC; - - - - -/////////////////////////////////////////////////////////////////////////////// -// DB_HDR_ELLIPSOID - defines -// Constants to define the ellipsoid model used for the projection -// -const short GEO_DB_ELLIPSOID_USER_DEFINED = -1; -const short GEO_DB_ELLIPSOID_WGS_1984 = 0; -const short GEO_DB_ELLIPSOID_WGS_1972 = 1; -const short GEO_DB_ELLIPSOID_BESSEL = 2; -const short GEO_DB_ELLIPSOID_CLARKE_1866 = 3; -const short GEO_DB_ELLIPSOID_NAD_1927 = 4; -const short GEO_DB_ELLIPSOID_LAST = GEO_DB_ELLIPSOID_NAD_1927; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** 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 = (GEO_DB_SOLID | GEO_DB_WIRE); -const uint GEO_DB_WIRE_ON_MOVE = 0x00000004; -const uint GEO_DB_DETEXTURE_ON_MOVE = 0x00000008; -const uint GEO_DB_PROXY_ON_MOVE = 0x00000010; - -const uint GEO_DB_SHRINK = 0x00000080; - -const uint GEO_DB_ZBUFFER = 0x00000100; -const uint GEO_DB_BBOX_HIGHLIGHT = 0x00000200; -const uint GEO_DB_BACKFACE = 0x00000400; -const uint GEO_DB_SELECTIVE_CULLFACE = 0x00000800; - - -const uint GEO_DB_DRAW_FACE_NORMALS = 0x00001000; -const uint GEO_DB_DRAW_VERTEX_NORMALS = 0x00002000; -const uint GEO_DB_SELECTIVE_BLENDING = 0x00008000; - -const uint GEO_DB_TEXTURE = 0x00010000; -const uint GEO_DB_HIGHLIGHT = 0x00020000; -const uint GEO_DB_USE_VERTEX_ARRAYS = 0x00040000; -const uint GEO_DB_REBUILD_VERTEX_ARRAYS = 0x00080000; - -const uint GEO_DB_SELECTIVE_SHADING = 0x00100000; -const uint GEO_DB_DRAW_SIMPLE = 0x00200000; - -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_SELECTIVE_ZBUFFER = 0x80000000; - - - - - -/////////////////////////////////////////////////////////////////////////////// -/** constants to identify the different Group types -*/ -const uint GEO_GROUP_TYPE_CONTAINER = 1; -const uint GEO_GROUP_TYPE_CULL = 2; -const uint GEO_GROUP_TYPE_Z_OFFSET = 3; -const uint GEO_GROUP_TYPE_MULTI_SAMPLE_AA = 4; -const uint GEO_GROUP_TYPE_LINE_AA = 5; -const uint GEO_GROUP_TYPE_FADE = 6; -const uint GEO_GROUP_TYPE_TERRAIN = 7; -const uint GEO_GROUP_TYPE_DECAL = 8; - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants to control the display of a Group based on time-of-day -* -*/ -const uint GEO_DB_GROUP_TOD_DISPLAY_NIGHT = 0x00000001; -const uint GEO_DB_GROUP_TOD_DISPLAY_DAWN = 0x00000002; -const uint GEO_DB_GROUP_TOD_DISPLAY_DAY = 0x00000004; -const uint GEO_DB_GROUP_TOD_DISPLAY_DUSK = 0x00000008; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants to control the intersection testing of this Group at runtime -* -*/ -const uint GEO_DB_GROUP_ISECT_IG_DEFINED = 0; -const uint GEO_DB_GROUP_ISECT_YES = 1; -const uint GEO_DB_GROUP_ISECT_NO = 2; - - - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants to control the switch Node behavior - * - * Switch Nodes can either be addative (in which case the - * accumulate drawable children) or selective (in which case - * the determine which of their children should be drawn). - * - * Selctive control is not implemented. - */ -const uint GEO_SWITCH_TYPE_ADDATIVE = 1; -const uint GEO_SWITCH_TYPE_SELECTIVE = 2; - - - - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants to identify special behavior int ZOffset GRoups - */ -const uint GEO_DB_ZOFFSET_GROUP_TYPE_UNDEFINED = 0; -const uint GEO_DB_ZOFFSET_GROUP_TYPE_RUNWAY = 1; -const uint GEO_DB_ZOFFSET_GROUP_TYPE_MARKINGS = 2; - - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants to control the Light Group behavior -* -* Light Groups are Groups with the Light-Group flag set. Any Light pt children -* are effected by these settings -*/ -const uint GEO_LIGHT_GROUP_ANIM_OFF = 0; -const uint GEO_LIGHT_GROUP_ANIM_ON = 1; -const uint GEO_LIGHT_GROUP_ANIM_RANDOM = 2; - - -/////////////////////////////////////////////////////////////////////////////// -/** Constants that specify the type of Light Group -* -* FIXED is for airfields etc. -* MOVING is for aircraft/ships etc. -*/ -const uint GEO_LIGHT_GROUP_TYPE_FIXED = 0; -const uint GEO_LIGHT_GROUP_TYPE_MOVING = 1; - - -/////////////////////////////////////////////////////////////////////////////// -/** Type Tokens for Node & Tool Gui Widgets -*/ -const int GUI_FLOAT = 1; -const int GUI_INT = 2; -const int GUI_STRING = 3; - - -/////////////////////////////////////////////////////////////////////////////// -/** geoWidget Typedef - Used by Node & Tool Gui Widgets -*/ -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; - - -/////////////////////////////////////////////////////////////////////////////// -// 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; - - - -/////////////////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////////////////// -// Texture Mapping types -// - -const int GEO_POLY_PLANAR_MAP = 0; -const int GEO_POLY_CYLINDRICAL_MAP = 1; -const int GEO_POLY_SPHERICAL_MAP = 2; - - - -/////////////////////////////////////////////////////////////////////////////// -// Texture Unit Functions - used in Polys, meshes & multi-tex shaders -// - -const int GEO_DB_TEXTURE_UNIT_FUNC_AS_DEFINED = 0; -const int GEO_DB_TEXTURE_UNIT_FUNC_MODULATE = 1; -const int GEO_DB_TEXTURE_UNIT_FUNC_DECAL = 2; -const int GEO_DB_TEXTURE_UNIT_FUNC_BLEND = 3; -const int GEO_DB_TEXTURE_UNIT_FUNC_REPLACE = 4; -const int GEO_DB_TEXTURE_UNIT_FUNC_COMBINE = 5; - - - -/////////////////////////////////////////////////////////////////////////////// -// STring type constants -// -const int GEO_TEXT_RASTER = 0; -const int GEO_TEXT_STROKE = 1; -const int GEO_TEXT_POLY = 2; - -/////////////////////////////////////////////////////////////////////////////// -// Justification constants -// -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; - - - -/////////////////////////////////////////////////////////////////////////////// -// 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; - - -/////////////////////////////////////////////////////////////////////////////// -// Texture Record Wrap S & T Modes -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; - - -/////////////////////////////////////////////////////////////////////////////// -// Texture Record MinFilter -const unsigned GEO_DB_TEX_NEAREST_MIPMAP_NEAREST = 0x00000004; -const unsigned GEO_DB_TEX_LINEAR_MIPMAP_NEAREST = 0x00000008; -const unsigned GEO_DB_TEX_NEAREST_MIPMAP_LINEAR = 0x00000010; -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_REPLACE = 0x00000008; - - -/////////////////////////////////////////////////////////////////////////////// -// Header Vertex Table Usage -const unsigned GEO_DB_USES_PRIVATE_DATA = 0x00000000; -const unsigned GEO_DB_USES_SHARED_TABLE_DATA = 0x00000001; -const unsigned GEO_DB_USES_UNSHARED_TABLE_DATA = 0x00000002; - - -#endif //_GEO_TYPES_H_ - diff --git a/src/osgPlugins/geo/geoUnits.h b/src/osgPlugins/geo/geoUnits.h deleted file mode 100644 index 2ad062c01..000000000 --- a/src/osgPlugins/geo/geoUnits.h +++ /dev/null @@ -1,74 +0,0 @@ -/*===========================================================================*\ - -NAME: geoUnits.h - -DESCRIPTION: Constants to convert coordinate data to/from meters (Geo - default) - -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. - - Exception: - This Software file can be used by third-party software developers (without - using the Geo SDK libraries) for any purpose OTHER THAN loading Geo format - files into an application or executable (such as, though not limited to, - geometry Modelers & animation systems) which is primarily intended to allow for - the CREATION or MODIFICATION of geometric or animation data. - - Specifically,using this software (either all or part thereof) to aid in the - creation of a Geo format loader for a run-time system, game engine, toolkit - IG (Image Generation) System or any software where the PRIMARY purpose is - real-time image playback and interactivity and not Model Creation and/or - modification is permitted. - -COPYRIGHT NOTICE: - - Copyright © 1998-2001 Carbon Graphics Llc, ALL RIGHTS RESERVED - -\*===========================================================================*/ - - - -#ifndef _GEO_UNITS_H_ -#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 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 MPH_TO_FPS = 1.4667f; -const float MPH_TO_MPS = 0.447f; - - - -#endif //_GEO_UNITS_H_ diff --git a/src/osgPlugins/geo/geoVersion.h b/src/osgPlugins/geo/geoVersion.h deleted file mode 100644 index cac5b6360..000000000 --- a/src/osgPlugins/geo/geoVersion.h +++ /dev/null @@ -1,81 +0,0 @@ -/*===========================================================================*\ - - NAME: geoVersion.h - - DESCRIPTION: Compile Time Library Version Info - - 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. - - This software file can only be used in conjunction with the Geo SDK & - libraries to create Plugin modules for the Geo 3D Modeling & Animation - package. - -COPYRIGHT NOTICE: - - Copyright © 1998-2001 Carbon Graphics Llc, ALL RIGHTS RESERVED - -\*===========================================================================*/ - - - -#ifndef __GEO_VERSION_H__ -#define __GEO_VERSION_H__ - - -#include "geoCore.h" - - -/////////////////////////////////////////////////////////////////////////////// -// Constants for the GEO_LIB_LEVEL_VERSION -/////////////////////////////////////////////////////////////////////////////// - -/** Signifies a pre-alpha version of the software */ -const unsigned char GEO_DEV_RELEASE = 10; - -/** Signifies an alpha version of the software */ -const unsigned char GEO_ALPHA_RELEASE = 11; - -/** Signifies an beta version of the software */ -const unsigned char GEO_BETA_RELEASE = 12; - -/** Signifies a late beta version of the software - potential release candidate, depending on user feedback */ -const unsigned char GEO_RELEASE_CANDIDATE = 13; - -/** Signifies an full version of the software */ -const unsigned char GEO_FULL_RELEASE = 14; - - -/////////////////////////////////////////////////////////////////////////////// -// Constants to identify the Geo version -/////////////////////////////////////////////////////////////////////////////// - -/** this constant specifies the Geo Major release number */ -#define GEO_LIB_MAJOR_VERSION 1 - -/** this constant specifies the Geo Minor release number */ -#define GEO_LIB_MINOR_VERSION 2 - -/** This constant defines the level of type of release - ie alpha,beta */ -#define GEO_LIB_LEVEL_VERSION GEO_FULL_RELEASE - -/** This constant defines the number of releases made at a particular level */ -#define GEO_LIB_RELEASE_VERSION 2 - -#define GEO_VERSION ((GEO_LIB_MAJOR_VERSION*1000)+(GEO_LIB_MINOR_VERSION*100)+(GEO_LIB_LEVEL_VERSION*10)+(GEO_LIB_RELEASE_VERSION)) - -// returns the GEO_VERSION value of the running Geo application. Users can use -// this to control code calls in the plugin. -extern GEO_DB_API int GetGeoLibraryVersion(void); - - - -#endif // __GEO_VERSION_H__ diff --git a/src/osgPlugins/geo/osgGeoAction.h b/src/osgPlugins/geo/osgGeoAction.h deleted file mode 100644 index 6b5e75b40..000000000 --- a/src/osgPlugins/geo/osgGeoAction.h +++ /dev/null @@ -1,289 +0,0 @@ -// geo actions header - -#ifndef _GEO_ACTIONS_H_ -#define _GEO_ACTIONS_H_ - -using namespace osg; - -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(osg::Node *)=0;// {} // do math or action operation - - virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader)=0; // pure virtual -protected: -}; - -class geoBehaviourDrawableCB: public osg::Drawable::UpdateCallback { -public: - geoBehaviourDrawableCB() { } - ~geoBehaviourDrawableCB() { } - void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);} - void update(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(osg::Node *)=0; // do math operation eg *out=*in or =f(*in). - virtual bool makeBehave(const georecord* , const geoHeaderGeo* ) { return true;}; // pure virtual -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==var2; } -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();} - virtual void doaction(osg::Node *); // do math operation - virtual 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); - - virtual void doaction(osg::Node *); // do math operation - virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader); -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;} - - virtual void doaction(osg::Node *); // do compare operation - virtual 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;} - virtual void doaction(osg::Node *); // do math operation - virtual 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;} - virtual void doaction(osg::Node *); // do math operation - virtual 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() {} - virtual void doaction(osg::Node *); // do math operation - virtual 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 *) { - } - - virtual bool makeBehave(const georecord *, const geoHeaderGeo * )=0;// { - // 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;} - virtual void doaction(osg::Node *node); - - virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader); -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 geoMoveBehaviour { // 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;} - virtual void doaction(osg::Matrix *); // Matrix &mtr); - - virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader); -private: - // for fast transform behaviours - int index; // which index in the geometry - Vec3 pos; // raw position of the vertex -}; - -class geoVisibBehaviour : public geoActionBehaviour { // visibility action -- sets node mask -public: - geoVisibBehaviour() { } - virtual ~geoVisibBehaviour() { } - - virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader); - virtual void doaction(osg::Node *node); -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}; - virtual void doaction(osg::Drawable *dr); - void setVertIndices(const uint ns, const uint n) { nstart=ns; nend=ns+n;} - void setColorPalette(const colourPalette *color_palette) {colours=color_palette;} - virtual bool makeBehave(const georecord *, const geoHeaderGeo * ); -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;} - virtual void doaction(osg::Drawable *node); // do new text - virtual bool makeBehave(const georecord *grec, const 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 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 deleted file mode 100644 index 6279cfef3..000000000 --- a/src/osgPlugins/geo/osgGeoAnimation.h +++ /dev/null @@ -1,58 +0,0 @@ -// animation features of the CarbonGraphics .geo format -// 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 the 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 - -class geoHeader: public osg::PositionAttitudeTransform { - // structure for header of .geo file - // adds position attitude orientation for not Z up models, - // plus animation variables. -public: - geoHeader() { - uvarupdate=NULL; extvarupdate=NULL; - }; - geoHeader(const geoHeader &geo,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : - osg::PositionAttitudeTransform(geo,copyop) - { - // const geoHeaderGeo *ghg=static_cast (&geo); - } - - ~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 Update phase. - 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 Update phase. - 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 deleted file mode 100644 index 923adbd7b..000000000 --- a/src/osgPlugins/geo/osgGeoNodes.h +++ /dev/null @@ -1,187 +0,0 @@ -// 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(const userVars &iv) - { - vars=iv.vars; - } - ~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(const geoHeaderGeo &geo,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); - - 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(const osg::FrameStamp *); - 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]=(unsigned char)(col[i]*frac); // prevents warning under gcc from *=frac with frac=real - 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;} - -protected: - virtual ~geoHeaderGeo(); - -private: - void moveit(const double t); - osg::Timer_t _lastFrameTick,_initialTick; - osg::Timer _timer; - internalVars *intVars; - userVars *useVars; - userVars *extVars; - 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 deleted file mode 100644 index a3350741d..000000000 --- a/src/osgPlugins/geo/osgGeoStructs.h +++ /dev/null @@ -1,728 +0,0 @@ -/*===========================================================================*\ - -NAME: osgGeoStructs.h - -DESCRIPTION: OSG data format for reading a Geo file into OSG - -AUTHOR: Geoff Michel - -// ------------------------------------------------------------------------- - - -\ *===========================================================================*/ - - - -#ifndef _GEO_STRUCTS_H_ -#define _GEO_STRUCTS_H_ 1 - -#include - -typedef std::vector< geoExtensionDefRec > geoExtensionDefList; - -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; storage=NULL; - } - void init() { - tokenId=TypeId=0; numItems=0;storeSize=0; storage=NULL; - } - 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 set(unsigned short id,unsigned int fid) { // to set values - TypeId=DB_UINT; - tokenId=id; - storeSize=SIZEOF_UINT; - numItems=1; - storage=new unsigned char[SIZEOF_UINT]; - memcpy(storage,&fid,SIZEOF_UINT); - } - void set(unsigned short id,float *cen,const int nsize) { // to set values - if (nsize==3) { - TypeId=DB_VEC3F; - tokenId=id; - storeSize=SIZEOF_VEC3F; - } else if (nsize==2) { - TypeId=DB_VEC2F; - tokenId=id; - storeSize=SIZEOF_VEC2F; - } else if (nsize==4) { - TypeId=DB_VEC4F; - tokenId=id; - storeSize=SIZEOF_VEC4F; - } - numItems=1; - storage=new unsigned char[storeSize]; - memcpy(storage,cen,storeSize); - } - void readfile(std::ifstream &fin, const unsigned int id); // is part of a record id - void parseExt(std::ifstream &fin) const; // Feb 2003 parse node extension fields - void writefile(std::ofstream &fout) { // write binary file - if (numItems<32767 && tokenId<256) { - unsigned char tokid=tokenId, type=TypeId; - fout.write((char *)&tokid, 1);fout.write((char *)&type,1); - fout.write((char *)&numItems,sizeof(unsigned short)); - } else { - } - fout.write((char *)storage, storeSize*numItems); - } - inline unsigned char getToken() const { return tokenId;} - inline unsigned char 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() { // follow the recipe to uncompress - if (TypeId==DB_VEC3F) { // already uncompressed - } else { - float *norms=new float[numItems*SIZEOF_VEC3F]; // uncompressed size - for (unsigned int i=0; i geoFieldList; - georecord() {id=0; parent=NULL; instance=NULL; nod=NULL; } - ~georecord() {;} - inline const uint getType(void) const {return id;} - typedef std::vector > instancelist; // list 0f 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).get()->addChild(nod.get()); - } - mtrlist.clear(); - } - } - inline osg::Node *getNode() { return nod.get();} - 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 : - //deprecated in 1,2,1 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.init(); - gf.readfile(fin, id); -// 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_RENDERGROUP: output << "Rendergroup 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_PERSPECTIVE_GRID_INFO: output << "Perspective Grid Info" << 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_DCS_ACTION: output << "DCS 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,... - } - 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; - } - const geoField *getFieldNumber(const unsigned int number) const { // return field number. - if (numbersetMatrix(total); - } - } - return tr; - } - 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();} - void addField(geoField &gf){fields.push_back(gf);} -private: - unsigned int 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::ref_ptr nod; // the node that this record has been converted to (useful for instances) - instancelist mtrlist; // list of matrices of instances not yet satisfied -}; - - -typedef std::vector< georecord > geoRecordList; - -#endif //_GEO_STRUCTS_H_