From Geoff Michel, updates to the Geo loader including handling of

.geo files from the rc1 of the GEO modeller.
This commit is contained in:
Robert Osfield
2003-02-10 15:16:51 +00:00
parent 1b08b02df2
commit fa643c8795
5 changed files with 132 additions and 89 deletions

View File

@@ -44,8 +44,10 @@
#include "osgGeoStructs.h"
#include "osgGeoNodes.h"
#include "osgGeoAction.h"
#include <osgText/Text> // needed for text nodes
#ifdef USETEXT // buggy text feb 2003
#include <osgText/Text> // needed for text nodes
#endif
//
@@ -195,14 +197,14 @@ public:
{
if ((*rcitr)->getType()==DB_DSK_TRANSLATE_ACTION) {
geoMoveVertexBehaviour *mb=new geoMoveVertexBehaviour;
mb->makeBehave((*rcitr),ghdr,DB_DSK_TRANSLATE_ACTION);
mb->makeBehave((*rcitr),ghdr);
mb->setpos((*cpool)[idx]);
mb->setindx(ncoord-1);
BehList.push_back(mb);
}
if ((*rcitr)->getType()==DB_DSK_ROTATE_ACTION) {
geoMoveVertexBehaviour *mb=new geoMoveVertexBehaviour;
mb->makeBehave((*rcitr),ghdr,DB_DSK_ROTATE_ACTION);
mb->makeBehave((*rcitr),ghdr);
mb->setpos((*cpool)[idx]);
mb->setindx(ncoord-1);
BehList.push_back(mb);
@@ -381,12 +383,12 @@ class ReaderWriterGEO : public ReaderWriter
//fdup.close();
// now sort the records so that any record followed by a PUSh has a child set = next record, etc
std::vector<georecord *> sorted=sort(recs); // tree-list of sorted record pointers
#ifdef _DEBUG
//#ifdef _DEBUG
osgDB::Output fout("georex.txt"); //, std::ios_base::out );
fout << "Debug file " << fileName << std::endl;
output(fout,sorted);
fout.close();
#endif
//#endif
nodeList=makeosg(sorted); // make a list of osg nodes
@@ -523,6 +525,9 @@ class ReaderWriterGEO : public ReaderWriter
case DB_DSK_SQRT_ACTION: // square root action
(curparent->getLastChild())->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
@@ -696,6 +701,8 @@ class ReaderWriterGEO : public ReaderWriter
}
}
osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text
osg::MatrixTransform *numt=NULL;
#ifdef USETEXT // buggy text feb 2003
std::string ttfPath("fonts/times.ttf");
int gFontSize1=2;
osgText::PolygonFont* polygonFont= new osgText::PolygonFont(ttfPath,
@@ -738,7 +745,7 @@ class ReaderWriterGEO : public ReaderWriter
osg::StateSet *textState = new osg::StateSet();
textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geod->setStateSet( textState );
osg::MatrixTransform *numt=new osg::MatrixTransform;
numt=new osg::MatrixTransform;
gfd=gr->getField(GEO_DB_TEXT_MATRIX);
if (gfd) {
float *fmat=gfd->getMat44Arr();
@@ -770,6 +777,7 @@ class ReaderWriterGEO : public ReaderWriter
}
}
}
#endif
return numt;
}
void addPolyActions(std::vector< georecord *>bhv, geoInfo &gi , const uint nv) {
@@ -1395,7 +1403,7 @@ class ReaderWriterGEO : public ReaderWriter
break;
case DB_DSK_ROTATE_ACTION: {
geoMoveBehaviour *cb= new geoMoveBehaviour;
ok=cb->makeBehave((*rcitr), theHeader,DB_DSK_ROTATE_ACTION);
ok=cb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(cb);
else delete cb;
}
@@ -1403,14 +1411,14 @@ class ReaderWriterGEO : public ReaderWriter
case DB_DSK_SCALE_ACTION: {
geoMoveBehaviour *sb=new geoMoveBehaviour;
ok=sb->makeBehave((*rcitr), theHeader,DB_DSK_SCALE_ACTION);
ok=sb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(sb);
else delete sb;
}
break;
case DB_DSK_TRANSLATE_ACTION: {
geoMoveBehaviour *cb= new geoMoveBehaviour;
ok=cb->makeBehave((*rcitr), theHeader,DB_DSK_TRANSLATE_ACTION);
ok=cb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(cb);
else delete cb;
}
@@ -1454,49 +1462,49 @@ class ReaderWriterGEO : public ReaderWriter
// ar3 types
case DB_DSK_TRIG_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_TRIG_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_INVERSE_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_INVERSE_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_LINEAR_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_LINEAR_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_PERIODIC_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_PERIODIC_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_PERIODIC2_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_PERIODIC2_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_TRUNCATE_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_TRUNCATE_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
break;
case DB_DSK_ABS_ACTION: {
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_ABS_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}
@@ -1517,7 +1525,7 @@ class ReaderWriterGEO : public ReaderWriter
case DB_DSK_IF_THEN_ELSE_ACTION:
{
geoAr3Behaviour *vb = new geoAr3Behaviour;
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_IF_THEN_ELSE_ACTION);
ok=vb->makeBehave((*rcitr), theHeader);
if (ok) gcb->addBehaviour(vb);
else delete vb;
}

View File

@@ -44,7 +44,7 @@ void geoArithBehaviour::setType(uint iop) {
case 5: op=equa; break;
}
}
void geoArithBehaviour::doaction(void) const { // do math operation
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;
@@ -112,16 +112,17 @@ void geoAr3Behaviour::setPeriodicType(int iop) {
}
}
void geoAr3Behaviour::doaction(void) { // do math operation
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, const uint act) {
bool geoAr3Behaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
bool ok=false;
const geoField *gfd=grec->getField(GEO_DB_EQUATION_ACTION_INPUT_VAR);
const uint act=grec->getType();
if (gfd) {
unsigned fid= gfd->getUInt(); // field identifier
in=theHeader->getVar(fid); // returns address of input var with fid
@@ -181,7 +182,7 @@ void geoCompareBehaviour::setType(uint iop) {
}
}
void geoCompareBehaviour::doaction(void) const { // do compare operation
void geoCompareBehaviour::doaction(osg::Node *) { // do compare operation
if (in && out) {
double var2=varop? *varop : constant;
switch (oper) {
@@ -225,7 +226,7 @@ bool geoCompareBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHea
return ok;
}
void geoRangeBehaviour::doaction(void) const { // do math operation
void geoRangeBehaviour::doaction(osg::Node *) { // do math operation
if (in && out) {
float v=*in;
if (v<inmin) v=inmin;
@@ -260,7 +261,7 @@ bool geoRangeBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeade
return ok;
}
void geoClampBehaviour::doaction(void) const { // do math operation
void geoClampBehaviour::doaction(osg::Node *) { // do math operation
if (in && out) {
float v=*in;
if (v<min) v=min;
@@ -290,7 +291,7 @@ bool geoClampBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeade
return ok;
}
void geoDiscreteBehaviour::doaction(void) const { // do math operation
void geoDiscreteBehaviour::doaction(osg::Node *) { // do math operation
if (in && out) {
float v=*in;
*out=rangelist.begin()->getVal();
@@ -361,8 +362,9 @@ void geoMoveBehaviour::doaction(osg::Node *node) {
}
}
bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act) {
bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) {
bool ok=false;
const uint act=grec->getType();
setType(act);
if (act==DB_DSK_ROTATE_ACTION) {
const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR);
@@ -409,27 +411,29 @@ bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *the
}
return ok;
}
void geoMoveVertexBehaviour::doaction(Matrix &mtr) {
void geoMoveVertexBehaviour::doaction(osg::Matrix *mtr) {
// update the matrix mtr
if (getVar()) {
switch (getType()) {
case DB_DSK_SCALE_ACTION:
mtr = mtr*osg::Matrix::scale(movb.getAxis()*(getValue())) ;
*mtr = (*mtr)*osg::Matrix::scale(getAxis()*(getValue())) ;
break;
case DB_DSK_TRANSLATE_ACTION:
mtr = mtr*osg::Matrix::translate(movb.getAxis()*(getValue())) ;
*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(-movb.getCentre())*
osg::Matrix::rotate(DEG2RAD(getValue()),movb.getAxis())*
osg::Matrix::translate(movb.getCentre());
*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 uint act) {
bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader)
{
const uint act=grec->getType();
bool ok=false;
setType(act);
if (act==DB_DSK_ROTATE_ACTION) {
@@ -443,12 +447,12 @@ bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGe
gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR);
if (gfd) {
float *ax= gfd->getVec3Arr(); // field identifier
movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
}
gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN);
if (gfd) {
float *ct= gfd->getVec3Arr(); // field identifier
movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
}
ok=true;
}
@@ -463,12 +467,12 @@ bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGe
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR);
if (gfd) {
float *ax= gfd->getVec3Arr(); // field identifier
movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
}
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN);
if (gfd) {
float *ct= gfd->getVec3Arr(); // field identifier
movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
}
ok=true;
}
@@ -478,7 +482,7 @@ bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGe
return ok;
}
bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
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) {
@@ -488,7 +492,7 @@ bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeade
}
return ok;
}
void geoVisibBehaviour::doaction(osg::Node *node) const
void geoVisibBehaviour::doaction(osg::Node *node)
{ // do visibility operation on Node
if (getVar()) {
if (getValue() <0.0) {
@@ -516,7 +520,7 @@ bool geoColourBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *t
}
return ok;
}
void geoColourBehaviour::doaction(osg::Drawable *dr) const
void geoColourBehaviour::doaction(osg::Drawable *dr)
{ // do visibility operation on Node
if (getVar()) {
double val=getValue();
@@ -538,6 +542,7 @@ void geoColourBehaviour::doaction(osg::Drawable *dr) const
}
void geoStrContentBehaviour::doaction(osg::Drawable *node) { // do new text
#ifdef USETEXT // buggy text feb 2003
osgText::Text *txt=dynamic_cast<osgText::Text *>(node);
char content[32];
switch (vt) {
@@ -557,6 +562,7 @@ void geoStrContentBehaviour::doaction(osg::Drawable *node) { // do new text
sprintf(content, format, (char *)getVar());
}
txt->setText(std::string(content));
#endif
}
bool geoStrContentBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
bool ok=false;
@@ -595,23 +601,25 @@ void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv)
for (std::vector<geoBehaviour *>::const_iterator itr=gblist.begin();
itr<gblist.end();
itr++) { // motion behaviour
geoArithBehaviour *ab=dynamic_cast<geoArithBehaviour *>(*itr);
if (ab) ab->doaction();
(*itr)->doaction(node);
/* === the above is equivalent to my old code with lots of tests in: */
/* geoArithBehaviour *ab=dynamic_cast<geoArithBehaviour *>(*itr);
if (ab) ab->doaction(node);
geoAr3Behaviour *a3=dynamic_cast<geoAr3Behaviour *>(*itr);
if (a3) a3->doaction();
if (a3) a3->doaction(node);
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
if (cb) cb->doaction();
if (cb) cb->doaction(node);
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
if (cr) cr->doaction();
if (cr) cr->doaction(node);
geoCompareBehaviour *cmb=dynamic_cast<geoCompareBehaviour *>(*itr);
if (cmb) cmb->doaction();
if (cmb) cmb->doaction(node);
geoDiscreteBehaviour *db=dynamic_cast<geoDiscreteBehaviour *>(*itr);
if (db) db->doaction();
if (db) db->doaction(node);
geoMoveBehaviour *mb=dynamic_cast<geoMoveBehaviour *>(*itr);
if (mb) mb->doaction(node);
// or visibility..
geoVisibBehaviour *vb=dynamic_cast<geoVisibBehaviour *>(*itr);
if (vb) vb->doaction(node);
if (vb) vb->doaction(node); */
}
traverse(node,nv);
}
@@ -626,14 +634,16 @@ void geoBehaviourDrawableCB::update(osg::NodeVisitor *,osg::Drawable *dr) {
itr<gblist.end();
itr++)
{ // color or string action behaviour, can also do maths...
// (*itr)->doaction(dr);
Node *nd=NULL;
geoArithBehaviour *ab=dynamic_cast<geoArithBehaviour *>(*itr);
if (ab) ab->doaction();
if (ab) ab->doaction(nd);
geoAr3Behaviour *a3=dynamic_cast<geoAr3Behaviour *>(*itr);
if (a3) a3->doaction();
if (a3) a3->doaction(nd);
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
if (cb) cb->doaction();
if (cb) cb->doaction(nd);
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
if (cr) cr->doaction();
if (cr) cr->doaction(nd);
geoStrContentBehaviour *sb=dynamic_cast<geoStrContentBehaviour *>(*itr);
if (sb) sb->doaction(dr);
// colorbehaviour may be for 1 or all vertices
@@ -641,7 +651,7 @@ void geoBehaviourDrawableCB::update(osg::NodeVisitor *,osg::Drawable *dr) {
if (clrb) clrb->doaction(dr);
geoMoveVertexBehaviour *mvvb=dynamic_cast<geoMoveVertexBehaviour *>(*itr);
if (mvvb && (prevvtr<0 || prevvtr==mvvb->getindex())) {
mvvb->doaction(mtr);
mvvb->doaction(&mtr);
pos=mvvb->getpos();
prevvtr=mvvb->getindex();
}
@@ -661,7 +671,7 @@ void geoBehaviourDrawableCB::update(osg::NodeVisitor *,osg::Drawable *dr) {
if (mvvb) {
int vidx=mvvb->getindex();
if (mvvb && (prevvtr<vidx || (newpos && prevvtr==vidx))) {
mvvb->doaction(mtr);
mvvb->doaction(&mtr);
prevvtr=vidx;
pos=mvvb->getpos();
newpos=true;

View File

@@ -143,6 +143,10 @@ const unsigned int DB_DSK_CYLINDER_TEXTURE_MAPPING_INFO = 176; // not implemente
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
@@ -224,10 +228,10 @@ const unsigned char SIZEOF_BITFLAGS = (SIZEOF_INT);
const short MIN_CHAR_VAL = -128;
const unsigned short MIN_CHAR_VAL = -128;
const unsigned short MAX_CHAR_VAL = 127;
const unsigned short MAX_UCHAR_VAL = 255;
const short MIN_SHORT_VAL = -32768;
const unsigned short MIN_SHORT_VAL = -32768;
const unsigned short MAX_SHORT_VAL = 32767;
const unsigned short MAX_USHORT_VAL = 65535;
@@ -449,6 +453,24 @@ const unsigned char GEO_DB_VIEW_CEN = 4;
const unsigned char GEO_DB_VIEW_TRACKBALL = 5;
///////////////////////////////////////////////////////////////////////////////
// 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 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;
///////////////////////////////////////////////////////////////////////////////
// GEO_DB_GROUP Record - Field Ids IDs
//
@@ -486,6 +508,8 @@ const unsigned char GEO_DB_SEQUENCE_NAME = 2;
const unsigned char GEO_DB_SEQUENCE_MODE = 3;
const unsigned char GEO_DB_SEQUENCE_ACTIVE = 4;
const unsigned char GEO_DB_SEQUENCE_INSTANCE_DEF = 5;
const unsigned char GEO_DB_SEQUENCE_FRAME_TIME = 6;
const unsigned char GEO_DB_SEQUENCE_USE_FRAME_TIME = 7;
const unsigned char GEO_DB_SEQUENCE_TRANSFORM = 253;
const unsigned char GEO_DB_SEQUENCE_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD
const unsigned char GEO_DB_SEQUENCE_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD
@@ -598,6 +622,8 @@ const unsigned char GEO_DB_POLY_SHADEMODEL = 8;
const unsigned char GEO_DB_POLY_USE_MATERIAL_DIFFUSE= 9;
const unsigned char GEO_DB_POLY_USE_VERTEX_COLORS = 10;
const unsigned char GEO_DB_POLY_COLOR_INDEX = 11;
const unsigned char GEO_DB_POLY_PT_SIZE = 12;
const unsigned char GEO_DB_POLY_LINE_WIDTH = 13;
const unsigned char GEO_DB_POLY_EXTENDED = 254; // alias for GEO_DB_EXTENDED_FIELD
const unsigned char GEO_DB_POLY_COMMENT = 255; // alias for GEO_DB_COMMENT_FIELD

View File

@@ -14,9 +14,9 @@ class geoBehaviour { // base class for action & math functions where var out = f
public:
geoBehaviour() { }
virtual ~geoBehaviour() { }
virtual void doaction(void) const
{ // do math or action operation
}
virtual void doaction(osg::Node *)=0;// {} // do math or action operation
virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader)=0; // pure virtual
protected:
};
@@ -36,9 +36,8 @@ public:
virtual ~geoMathBehaviour() { }
virtual void setInVar(const double *indvar) {in=indvar;}
virtual void setOutVar(double *outdvar) {out=outdvar;}
virtual void doaction(void) const
{ // do math operation eg *out=*in or =f(*in).
}
virtual void doaction(osg::Node *)=0; // do math operation eg *out=*in or =f(*in).
virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) { return true;}; // pure virtual
protected:
const double *in; // address of input variable
double *out; // address of output
@@ -89,8 +88,8 @@ public:
bool setVariable(const double *varvar) { return acon.set(varvar);}
void setConstant(float v) {acon.set(v); }
inline double getconstant(void) { return acon.get();}
void doaction(void) const; // do math operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
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;
@@ -105,8 +104,8 @@ public:
void setTrigType(int iop);
void setPeriodicType(int iop);
void doaction(void); // do math operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act);
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);
@@ -120,8 +119,8 @@ public:
void setType(uint iop);
void setVariable(const double *varvar) { varop=varvar;}
void doaction(void) const; // do compare operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
virtual void doaction(osg::Node *); // do compare operation
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
private:
float constant;
optype oper;
@@ -137,8 +136,8 @@ public:
void setInMin(const double v) { inmin=v;}
void setOutMax(const double v) { outmax=v;}
void setOutMin(const double v) { outmin=v;}
void doaction(void) const; // do math operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
virtual void doaction(osg::Node *); // do math operation
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
private:
float inmin,inmax;
float outmin,outmax;
@@ -149,8 +148,8 @@ public:
~geoClampBehaviour() { }
void setMax(const double v) { max=v;}
void setMin(const double v) { min=v;}
void doaction(void) const; // do math operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
virtual void doaction(osg::Node *); // do math operation
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
private:
float min,max;
};
@@ -171,8 +170,8 @@ class geoDiscreteBehaviour : public geoMathBehaviour { // discrete action -- out
public:
geoDiscreteBehaviour() {nrange=1; }
virtual ~geoDiscreteBehaviour() {}
void doaction(void) const; // do math operation
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
virtual void doaction(osg::Node *); // do math operation
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
private:
int nrange;
@@ -190,12 +189,12 @@ public:
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 *) const {
virtual void doaction(osg::Node *) {
}
virtual bool makeBehave(const georecord *, geoHeaderGeo *, const uint ) {
return true;
}
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
@@ -209,15 +208,15 @@ public:
void setAxis(const Vec3 v) { axis=v;}
inline Vec3 getAxis() { return axis;}
inline Vec3 getCentre() { return centre;}
void doaction(osg::Node *node);
virtual void doaction(osg::Node *node);
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act);
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 geoActionBehaviour { // class of rotate & translate vertex actions
class geoMoveVertexBehaviour : public geoMoveBehaviour { // class of rotate & translate vertex actions
public:
geoMoveVertexBehaviour() { index=0; pos.set(0,0,0);}
virtual ~geoMoveVertexBehaviour() { }
@@ -225,14 +224,13 @@ public:
void setpos(const osg::Vec3 p) { pos=p;}
void setindx(const int idx) { index=idx;}
inline int getindex(void) const { return index;}
void doaction(Matrix &mtr);
virtual void doaction(osg::Matrix *); // Matrix &mtr);
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act);
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
geoMoveBehaviour movb;
};
class geoVisibBehaviour : public geoActionBehaviour { // visibility action -- sets node mask
@@ -240,8 +238,8 @@ public:
geoVisibBehaviour() { }
virtual ~geoVisibBehaviour() { }
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
void doaction(osg::Node *node) const;
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
virtual void doaction(osg::Node *node);
private:
};
class geoColourBehaviour : public geoActionBehaviour { // colour action
@@ -250,10 +248,10 @@ public:
geoColourBehaviour() { topcindx=4096; botcindx=0; numramps=1; type=UNKNOWN; colours=NULL;}
virtual ~geoColourBehaviour() { }
enum cacts {UNKNOWN, PALETTE, RAMP};
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
void doaction(osg::Drawable *dr) const;
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
@@ -268,8 +266,8 @@ public:
geoStrContentBehaviour() {format=NULL;PADDING_TYPE=0;
PAD_FOR_SIGN=0; vt=UNKNOWN; }
virtual ~geoStrContentBehaviour() { delete [] format;}
void doaction(osg::Drawable *node); // do new text
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
virtual void doaction(osg::Drawable *node); // do new text
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
enum valuetype {UNKNOWN, INT, FLOAT, DOUBLE, CHAR};
private:
char *format;

View File

@@ -510,6 +510,7 @@ public:
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;