Removed geo plugin as the modelling tool it was assocaited is long defunct.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -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 <osg/ColorMask>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Depth>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -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 <osg/Group>
|
||||
#include <osg/Stencil>
|
||||
|
||||
|
||||
|
||||
/** 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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 <string>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <osg/Image>
|
||||
#include <osg/Group>
|
||||
#include <osg/LOD>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/Sequence>
|
||||
#include <osg/Switch>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Material>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
// 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 <osgText/Text> // needed for text nodes
|
||||
#include <osg/Timer>
|
||||
|
||||
|
||||
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 (v<inmin) v=inmin;
|
||||
if (v>inmax) 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 (v<min) v=min;
|
||||
if (v>max) 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<geoRange>::const_iterator itr=rangelist.begin();
|
||||
itr<rangelist.end(); itr++) {
|
||||
if (v>=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; i<nr; i++) {
|
||||
geoRange gr;
|
||||
rangelist.push_back(gr);
|
||||
}
|
||||
const geoField *gfdmin=grec->getField(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<nr; i++) {
|
||||
rangelist[i].setMin(fmin[i]);
|
||||
rangelist[i].setMax(fmax[i]);
|
||||
rangelist[i].setVal(fval[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void geoMoveBehaviour::doaction(osg::Node *node) {
|
||||
if (getVar()) {
|
||||
MatrixTransform *mtr=dynamic_cast<MatrixTransform *> (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<osg::Geometry *>(dr);
|
||||
if (gm) {
|
||||
osg::Vec4Array* cla = dynamic_cast<osg::Vec4Array*>(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<osgText::Text *>(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<MatrixTransform *> (node);
|
||||
if (mtr) mtr->setMatrix(Matrix::identity()); // all actions are multiplied to this
|
||||
// printf("setting matrix %x\n", mtr);
|
||||
// PositionAttitudeTransform *patr=dynamic_cast<PositionAttitudeTransform *> (node);
|
||||
// if (patr) patr->setMatrix(Matrix::identity()); // all actions are multiplied to this
|
||||
for (std::vector<geoBehaviour *>::const_iterator itr=gblist.begin();
|
||||
itr<gblist.end();
|
||||
itr++) { // motion behaviour
|
||||
(*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(node);
|
||||
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
|
||||
if (cb) cb->doaction(node);
|
||||
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
|
||||
if (cr) cr->doaction(node);
|
||||
geoCompareBehaviour *cmb=dynamic_cast<geoCompareBehaviour *>(*itr);
|
||||
if (cmb) cmb->doaction(node);
|
||||
geoDiscreteBehaviour *db=dynamic_cast<geoDiscreteBehaviour *>(*itr);
|
||||
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); */
|
||||
}
|
||||
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<geoBehaviour *>::const_iterator itr;
|
||||
for (itr=gblist.begin();
|
||||
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(nd);
|
||||
geoAr3Behaviour *a3=dynamic_cast<geoAr3Behaviour *>(*itr);
|
||||
if (a3) a3->doaction(nd);
|
||||
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
|
||||
if (cb) cb->doaction(nd);
|
||||
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
|
||||
if (cr) cr->doaction(nd);
|
||||
geoStrContentBehaviour *sb=dynamic_cast<geoStrContentBehaviour *>(*itr);
|
||||
if (sb) sb->doaction(dr);
|
||||
// colorbehaviour may be for 1 or all vertices
|
||||
geoColourBehaviour *clrb=dynamic_cast<geoColourBehaviour *>(*itr);
|
||||
if (clrb) clrb->doaction(dr);
|
||||
geoMoveVertexBehaviour *mvvb=dynamic_cast<geoMoveVertexBehaviour *>(*itr);
|
||||
if (mvvb && (prevvtr<0 || prevvtr==mvvb->getindex())) {
|
||||
mvvb->doaction(&mtr);
|
||||
pos=mvvb->getpos();
|
||||
prevvtr=mvvb->getindex();
|
||||
}
|
||||
}
|
||||
osg::Geometry *gm=dynamic_cast<osg::Geometry *>(dr);
|
||||
if (gm && prevvtr>=0) {
|
||||
osg::Vec3Array* vtxa = dynamic_cast<osg::Vec3Array*>(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<gblist.end();
|
||||
itr++) { // color or string action behaviour, can also do maths...
|
||||
geoMoveVertexBehaviour *mvvb=dynamic_cast<geoMoveVertexBehaviour *>(*itr);
|
||||
if (mvvb) {
|
||||
int vidx=mvvb->getindex();
|
||||
if (mvvb && (prevvtr<vidx || (newpos && prevvtr==vidx))) {
|
||||
mvvb->doaction(&mtr);
|
||||
prevvtr=vidx;
|
||||
pos=mvvb->getpos();
|
||||
newpos=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newpos) {
|
||||
osg::Vec3Array* vtxa = dynamic_cast<osg::Vec3Array*>(gm->getVertexArray());
|
||||
(*vtxa)[prevvtr]=pos*mtr;
|
||||
}
|
||||
} while (newpos);
|
||||
}
|
||||
}
|
||||
@@ -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 <20> 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_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 <20> 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_
|
||||
|
||||
@@ -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 <20> 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_
|
||||
@@ -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 <20> 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__
|
||||
@@ -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<geoBehaviour *> 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<geoRange> 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<geoBehaviour *> gblist;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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 <osg/PositionAttitudeTransform>
|
||||
|
||||
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<const geoHeaderGeo *> (&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
|
||||
@@ -1,187 +0,0 @@
|
||||
// special geo nodes
|
||||
#ifndef _GEO_NODES_H_
|
||||
#define _GEO_NODES_H_
|
||||
|
||||
#include <osg/Timer>
|
||||
|
||||
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<vmin) val.d=vmin;
|
||||
}
|
||||
}
|
||||
const std::string getName(void) const { return name;}
|
||||
void setName(const char *nm) { name=nm; }
|
||||
void setMinRange(const float f) { vmin=f;}
|
||||
void setMaxRange(const float f) { vmax=f; }
|
||||
void setConstrained(bool onoff=true) { constrained=onoff;}
|
||||
private:
|
||||
union {
|
||||
double d;
|
||||
float f;
|
||||
int i;
|
||||
unsigned int ui;
|
||||
} val;
|
||||
unsigned int token; // type of field
|
||||
unsigned int fid; // field identifier
|
||||
float vmin, vmax;
|
||||
std::string name;
|
||||
bool constrained; // are values limited by min,max
|
||||
}; // a numerical value, may be one of several types
|
||||
|
||||
class internalVars { // holds internal variables for whole model
|
||||
public:
|
||||
internalVars() { }
|
||||
internalVars(const internalVars &iv) {
|
||||
vars=iv.vars; }
|
||||
~internalVars() {
|
||||
}
|
||||
void addInternalVars(const georecord &gr);
|
||||
void update(const osg::FrameStamp *_frameStamp);
|
||||
double *getVar(const unsigned fid) {
|
||||
for (std::vector<geoValue>::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<geoValue>::const_iterator itr=vars.begin();
|
||||
itr!=vars.end();
|
||||
++itr)
|
||||
{// for each field
|
||||
if ((*itr).getFID() == fid) {
|
||||
return (&(*itr));
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
private:
|
||||
std::vector<geoValue> 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<geoValue> *getvars() { return &vars;}
|
||||
double *getVar(const unsigned fid) {
|
||||
for (std::vector<geoValue>::iterator itr=vars.begin(); itr<vars.end(); itr++) {
|
||||
if (itr->getFID() == fid) return (itr->getVar());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
const geoValue *getGeoVar(const unsigned fid) const {
|
||||
for (std::vector<geoValue>::const_iterator itr=vars.begin(); itr<vars.end(); itr++) {
|
||||
if (itr->getFID() == fid) return (&(*itr));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void addUserVar(const georecord &gr);
|
||||
private:
|
||||
std::vector<geoValue> 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
|
||||
@@ -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 <string.h>
|
||||
|
||||
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<numItems; i++) {
|
||||
switch (TypeId) {
|
||||
case DB_UINT:
|
||||
norms[3*i]=storage[4*i+1]/255.0f;
|
||||
norms[3*i+1]=storage[4*i+2]/255.0f;
|
||||
norms[3*i+2]=storage[4*i+3]/255.0f;
|
||||
if (storage[4*i] & 0x01) norms[3*i] *= -1;
|
||||
if (storage[4*i] & 0x02) norms[3*i+1] *= -1;
|
||||
if (storage[4*i] & 0x04) norms[3*i+2] *= -1;
|
||||
break;
|
||||
case DB_SHORT:
|
||||
norms[3*i]=(storage[6*i]*255+storage[6*i+1])/32767.0f;
|
||||
norms[3*i+1]=(storage[6*i+2]*255+storage[6*i+3])/32767.0f;
|
||||
norms[3*i+2]=(storage[6*i+4]*255+storage[6*i+5])/32767.0f;
|
||||
break;
|
||||
case DB_CHAR:
|
||||
norms[3*i]=storage[3*i]/127.0f;
|
||||
norms[3*i+1]=storage[3*i+1]/127.0f;
|
||||
norms[3*i+2]=storage[3*i+2]/127.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete [] storage;
|
||||
TypeId=DB_VEC3F;
|
||||
storage=(unsigned char *)norms;
|
||||
}
|
||||
}
|
||||
inline void warn(const char *type, unsigned tval) const
|
||||
{
|
||||
if (getType() != tval)
|
||||
{
|
||||
OSG_WARN << "Wrong type " << type << (int)tval <<" expecting "<< (int)getType() << std::endl;
|
||||
}
|
||||
}
|
||||
inline unsigned int getUInt() const {warn("getUInt",DB_UINT); return *((unsigned int*)storage);} // return int value
|
||||
inline char *getChar() const {warn("getChar",DB_CHAR); return (char *)storage;} // return chars, eg for name or file name
|
||||
inline unsigned char getUChar() const {warn("getUChar",DB_CHAR); return *storage;} // return chars, eg for name or file name
|
||||
inline int getInt() const
|
||||
{
|
||||
warn("getInt", DB_INT);
|
||||
int val;
|
||||
memcpy(&val,storage,sizeof(int));
|
||||
return val;
|
||||
} // return int value
|
||||
inline float getFloat() const {warn("getFloat", DB_FLOAT); return (*(float *)storage); }
|
||||
inline float *getFloatArr() const {warn("getFloatArr", DB_FLOAT); return ( (float *)storage); }
|
||||
inline int *getIntArr() const {warn("getIntArr", DB_INT); return ( (int *)storage); }
|
||||
inline float *getVec3Arr() const {warn("getVec3Arr", DB_VEC3F); return ( (float *)storage); }
|
||||
inline float *getMat44Arr() const {warn("getMat44Arr", DB_VEC16F); return ( (float *)storage); }
|
||||
inline double getDouble() const {warn("getDouble", DB_DOUBLE); return (*(double *)storage); }
|
||||
inline unsigned short getUShort() const {warn("getUShort", DB_USHORT); return (*(ushort *)storage); }
|
||||
inline unsigned short getShort() const {warn("getShort", DB_SHORT); return (*(short *)storage); }
|
||||
inline unsigned short getUShortPad() const {warn("getUShortPad", DB_USHORT_WITH_PADDING); return (*(ushort *)storage); }
|
||||
inline unsigned short getShortPad() const {warn("getShortPad", DB_SHORT_WITH_PADDING); return (*(short *)storage); }
|
||||
inline unsigned char *getUCh4Arr() const {warn("getUChArr", DB_VEC4UC); return ((unsigned char *)storage); }
|
||||
inline bool getBool() const {warn("getBool", DB_BOOL_WITH_PADDING); return (storage[0] != 0); }
|
||||
friend inline std::ostream& operator << (osgDB::Output& output, const geoField& gf)
|
||||
{
|
||||
if (gf.tokenId!=GEO_DB_LAST_FIELD) {
|
||||
output.indent() << " Field:token " << (int)gf.tokenId << " datatype " << (int)gf.TypeId
|
||||
<< " num its " << gf.numItems << " size " << gf.storeSize << std::endl;
|
||||
if (gf.TypeId==DB_CHAR) output.indent();
|
||||
for (unsigned int i=0; i<gf.numItems; i++) {
|
||||
if (gf.storage==NULL) {
|
||||
output.indent() << "No storage" << std::endl;
|
||||
} else {
|
||||
int j,k;
|
||||
union {
|
||||
unsigned char *uch;
|
||||
char *ch;
|
||||
float *ft;
|
||||
int *in;
|
||||
unsigned int *uin;
|
||||
short *sh;
|
||||
unsigned short *ush;
|
||||
long *ln;
|
||||
unsigned long *uln;
|
||||
double *dbl;
|
||||
} st;
|
||||
st.uch=gf.storage+i*gf.storeSize;
|
||||
switch (gf.TypeId) {
|
||||
case DB_CHAR:
|
||||
if (st.ch[0]) output << st.ch[0];
|
||||
break;
|
||||
case DB_SHORT:
|
||||
output.indent() << st.sh[0] << std::endl;
|
||||
break;
|
||||
case DB_INT:
|
||||
output.indent() << *(st.in) << std::endl;
|
||||
break;
|
||||
case DB_FLOAT:
|
||||
output.indent() << *(st.ft) << std::endl;
|
||||
break;
|
||||
case DB_LONG:
|
||||
output.indent() << st.ln[0] << std::endl;
|
||||
break;
|
||||
case DB_ULONG:
|
||||
output.indent() << st.uln[0] << std::endl;
|
||||
break;
|
||||
case DB_DOUBLE:
|
||||
output.indent() << st.dbl[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC2F:
|
||||
output.indent() << st.ft[0] << " " << st.ft[1];
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC3F:
|
||||
output.indent();
|
||||
for (j=0; j<3; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4F:
|
||||
output.indent();
|
||||
for (j=0; j<4; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16F:
|
||||
for (j=0; j<4; j++) {
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.ft[j*4+k] << " ";
|
||||
output << std::endl;
|
||||
}
|
||||
break;
|
||||
case DB_VEC2I:
|
||||
output.indent() << st.in[0] << " " << st.in[1] << std::endl;
|
||||
break;
|
||||
case DB_VEC3I:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << " " << st.in[j];
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4I:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.in[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC2D:
|
||||
output.indent();
|
||||
for ( j=0; j<2; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC3D:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4D:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16D:
|
||||
for (j=0; j<4; j++) {
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.dbl[j*4+k] << " ";
|
||||
output << std::endl;
|
||||
}
|
||||
break;
|
||||
case DB_VRTX_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_UINT:
|
||||
output.indent() << st.uin[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT:
|
||||
output.indent() << st.ush[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR:
|
||||
output.indent() << (int)st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_EXT_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_SHORT_WITH_PADDING:
|
||||
output.indent() << st.sh[0] << std::endl;
|
||||
break;
|
||||
case DB_CHAR_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT_WITH_PADDING:
|
||||
output.indent() << st.ush[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR_WITH_PADDING:
|
||||
output.indent() << st.ush << std::endl;
|
||||
break;
|
||||
case DB_BOOL_WITH_PADDING:
|
||||
output.indent() << (gf.getBool()?"True":"False") << std::endl;
|
||||
break;
|
||||
case DB_EXTENDED_FIELD_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC4UC:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << (int)st.uch[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_DISCRETE_MAPPING_STRUCT:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
case DB_BITFLAGS:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gf.TypeId==DB_CHAR) output << std::endl;
|
||||
return output; // to enable cascading, monkey copy from osg\plane or \quat, Ubyte4, vec2,3,4,...
|
||||
}
|
||||
osg::Matrix getMatrix() const {
|
||||
osg::Matrix mx;
|
||||
switch (tokenId) {
|
||||
case GEO_DB_GRP_TRANSLATE_TRANSFORM:
|
||||
{
|
||||
float * from=getVec3Arr();
|
||||
float * to=from+3;
|
||||
|
||||
mx.makeTranslate(to[0]-from[0],to[1]-from[1],to[2]-from[2]); // uses same convention as OSG else will need to use set(m44[0],m44[1]...)
|
||||
}
|
||||
break;
|
||||
case GEO_DB_GRP_ROTATE_TRANSFORM:
|
||||
{
|
||||
float *centre=getFloatArr();
|
||||
float *axis=centre+3;
|
||||
float *angle=centre+6;
|
||||
mx=osg::Matrix::translate(-osg::Vec3(centre[0], centre[1], centre[2]))*
|
||||
osg::Matrix::rotate(2*osg::inDegrees(*angle),axis[0], axis[1], axis[2])*
|
||||
osg::Matrix::translate(osg::Vec3(centre[0], centre[1], centre[2]));
|
||||
}
|
||||
break;
|
||||
case GEO_DB_GRP_SCALE_TRANSFORM:
|
||||
{
|
||||
float * centre=getVec3Arr();
|
||||
float * scale=centre+3;
|
||||
mx=osg::Matrix::translate(-osg::Vec3(centre[0], centre[1], centre[2]))*
|
||||
osg::Matrix::scale(scale[0], scale[1], scale[2])*
|
||||
osg::Matrix::translate( osg::Vec3(centre[0], centre[1], centre[2]));
|
||||
}
|
||||
break;
|
||||
case GEO_DB_GRP_MATRIX_TRANSFORM:
|
||||
{
|
||||
float * m44=getMat44Arr();
|
||||
mx.set(m44);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return mx;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned short tokenId, TypeId; // these are longer than standard field; are extended field length
|
||||
unsigned int numItems;
|
||||
unsigned char *storage; // data relating
|
||||
uint storeSize; // size*numItems in storage
|
||||
};
|
||||
|
||||
class georecord { // holds a single record with a vector of geoFields as read from disk
|
||||
public:
|
||||
typedef std::vector< geoField > geoFieldList;
|
||||
georecord() {id=0; parent=NULL; instance=NULL; nod=NULL; }
|
||||
~georecord() {;}
|
||||
inline const uint getType(void) const {return id;}
|
||||
typedef std::vector<osg::ref_ptr<osg::MatrixTransform> > 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<georecord *> 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 (number<getNumFields()) return &(fields[number]);
|
||||
else return NULL;
|
||||
}
|
||||
osg::MatrixTransform *getMatrix() const { // multiply up all matrix supported
|
||||
// Dec 2003 a single record can have multiple matrices to be multiplied up!
|
||||
osg::MatrixTransform *tr=NULL;
|
||||
bool nonIdentity=false;
|
||||
osg::Matrix total; // starts as identity matrix
|
||||
for (geoFieldList::const_iterator itr=fields.begin();
|
||||
itr!=fields.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Matrix mx=(*itr).getMatrix();
|
||||
total.preMult(mx);
|
||||
switch ((*itr).getToken()) {
|
||||
case GEO_DB_GRP_TRANSLATE_TRANSFORM:
|
||||
case GEO_DB_GRP_ROTATE_TRANSFORM:
|
||||
case GEO_DB_GRP_SCALE_TRANSFORM:
|
||||
case GEO_DB_GRP_MATRIX_TRANSFORM:
|
||||
nonIdentity=true;
|
||||
break;
|
||||
}
|
||||
if (nonIdentity) {
|
||||
tr=new osg::MatrixTransform;
|
||||
tr->setMatrix(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<geoField> 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<osg::Node> nod; // the node that this record has been converted to (useful for instances)
|
||||
instancelist mtrlist; // list of matrices of instances not yet satisfied
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector< georecord > geoRecordList;
|
||||
|
||||
#endif //_GEO_STRUCTS_H_
|
||||
Reference in New Issue
Block a user