Updates from Geoff Michel to geo loader and demo.
This commit is contained in:
@@ -26,6 +26,7 @@ CFG=osgPlugin geo - Win32 Release
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
F90=df.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
@@ -94,6 +95,10 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\geoActions.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\ReaderWriterGEO.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
@@ -114,16 +119,28 @@ SOURCE=..\..\..\src\osgPlugins\geo\geoUnits.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\osgGeoStructs.h
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\osgGeoAction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\osgGeoAnimation.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\osgGeoNodes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\geo\osgGeoStructs.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\osgGeoNodes.asp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -129,7 +129,7 @@ SOURCE=..\..\include\osgSim\LightPoint
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgSim\LightPointDrawable
|
||||
SOURCE=..\..\src\osgSim\LightPointDrawable.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
@@ -65,8 +66,9 @@ class geodemoEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
geodemoEventHandler( ) {speed=0; heading=0; mouse_x=mouse_y=0;}
|
||||
|
||||
geodemoEventHandler( ) { mouse_x=mouse_y=0;}
|
||||
virtual ~geodemoEventHandler( ) {}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
mouse_x=ea.getX();
|
||||
@@ -79,49 +81,47 @@ public:
|
||||
{
|
||||
v.visit(*this);
|
||||
}
|
||||
void moveit(userVars *l)
|
||||
{
|
||||
std::vector<geoValue> *lvals=l->getvars();
|
||||
for (std::vector<geoValue>::iterator itr=lvals->begin();
|
||||
itr!=lvals->end();
|
||||
++itr) {// for each user var
|
||||
if (itr->getName() == "xpos") {
|
||||
itr->setVal((*itr->getValue())+speed*sin(heading));
|
||||
// std::cout << " nx " << (*itr->getValue()) ;
|
||||
} else if (itr->getName() == "ypos") {
|
||||
itr->setVal((*itr->getValue())+speed*cos(heading));
|
||||
// std::cout << " ny " << (*itr->getValue()) ;
|
||||
} else if (itr->getName() == "sped") {
|
||||
itr->setVal(0.00025*(mouse_y-300));
|
||||
speed=(*itr->getValue());
|
||||
// std::cout << " nspd " << speed << std::endl;
|
||||
} else if (itr->getName() == "heading") {
|
||||
itr->setVal((*itr->getValue())-0.0001*(mouse_x-400));
|
||||
heading=(*itr->getValue());
|
||||
// std::cout << " nhdg " << heading << std::endl;
|
||||
} else if (itr->getName() == "conerot") {
|
||||
itr->setVal((mouse_x-400));
|
||||
} else if (itr->getName() == "planrot") {
|
||||
itr->setVal((mouse_y-300)/200.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline int getMouseX(void) {return mouse_x;};
|
||||
inline int getMouseY(void) {return mouse_y;};
|
||||
|
||||
private:
|
||||
int mouse_x, mouse_y;
|
||||
float speed, heading;
|
||||
};
|
||||
|
||||
static geodemoEventHandler *ghand=NULL;
|
||||
inline double DEG2RAD(const double val) { return val*0.0174532925199432957692369076848861;}
|
||||
inline double RAD2DEG(const double val) { return val*57.2957795130823208767981548141052;}
|
||||
|
||||
void moveit(const double t, userVars *l,userVars *e)
|
||||
{ // all the local and external variables declared in the geo modeller are here available.
|
||||
ghand->moveit(l);
|
||||
double dodynamics(const double time, const double val, const std::string name)
|
||||
{ // Each local variable named 'name' declared in the geo modeller is passed into here.
|
||||
// its current value is val; returns new value. Time - elapsed time
|
||||
static double heading,speed; // these are only required for my 'dynamics'
|
||||
if (name == "xpos") {
|
||||
return (val+speed*sin(heading));
|
||||
// std::cout << " nx " << (*itr->getValue()) ;
|
||||
} else if (name == "ypos") {
|
||||
return (val+speed*cos(heading));
|
||||
// std::cout << " ny " << (*itr->getValue()) ;
|
||||
} else if (name == "sped") {
|
||||
speed=(0.00025*(ghand->getMouseY()-300)); // (*itr->getValue());
|
||||
return (speed);
|
||||
} else if (name == "heading") {
|
||||
heading-= 0.01*DEG2RAD(ghand->getMouseX()-400); // =DEG2RAD(*itr->getValue());
|
||||
return (RAD2DEG(heading));
|
||||
} else if (name == "conerot") {
|
||||
return ((ghand->getMouseX()-400));
|
||||
} else if (name == "planrot") {
|
||||
return ((ghand->getMouseY()-300)/200.0);
|
||||
} else if (name == "secint" || name == "minutehand"|| name == "hourhand") {
|
||||
// std::cout << " updating " << name << " " << val << std::endl;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
std::string pathfile;
|
||||
float camera_fov=-1;
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
@@ -142,6 +142,9 @@ int main( int argc, char **argv )
|
||||
}
|
||||
else
|
||||
pathfile = std::string(argv[++i]);
|
||||
} else if( std::string(argv[i]) == "-fov" ) {
|
||||
camera_fov=atof(argv[i+1]);
|
||||
++i; // skip the value
|
||||
}
|
||||
else
|
||||
commandLine.push_back(argv[i]);
|
||||
@@ -150,6 +153,28 @@ int main( int argc, char **argv )
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.setWindowTitle(argv[0]);
|
||||
|
||||
// geoff's path code.. needs replacing as it isn't cross platform.
|
||||
// {
|
||||
// char *gdpath=getenv("PATH");
|
||||
// int lenpath=(gdpath ? strlen(gdpath):1) + strlen(argv[0]);
|
||||
// char *nupath=new char[lenpath+20];
|
||||
//
|
||||
// strcpy(nupath,"PATH=");
|
||||
// strcat(nupath,argv[0]);
|
||||
// // strip the executable name (xxx.exe)
|
||||
// char *epath=strrchr(nupath, '\\');
|
||||
// if (epath) *epath='\0'; // remove executable
|
||||
// else {
|
||||
// epath=strrchr(nupath, '/');
|
||||
// if (epath) *epath='\0'; // remove executable, UNIX style path
|
||||
// }
|
||||
// strcat(nupath,";");
|
||||
// strcat(nupath,gdpath);
|
||||
// _putenv(nupath);
|
||||
// delete [] nupath;
|
||||
// }
|
||||
// std::cout << "Path " << getenv("PATH") << std::endl;
|
||||
|
||||
// configure the viewer from the commandline arguments, and eat any
|
||||
// parameters that have been matched.
|
||||
@@ -188,10 +213,9 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
geoHeader *gh = dynamic_cast<geoHeader *>(rootnode);
|
||||
if (gh)
|
||||
{ // it is a geo file, so set function to update its animation variables.
|
||||
if (gh) { // it is a geo file, so set function to update its animation variables.
|
||||
ghand=new geodemoEventHandler();
|
||||
gh->setUserUpdate(moveit);
|
||||
gh->setUserUpdate(dodynamics);
|
||||
viewer.prependEventHandler(ghand);
|
||||
} else { // maybe a group with geo models below.
|
||||
osg::Group *gpall=dynamic_cast<osg::Group *>(rootnode);
|
||||
@@ -203,14 +227,18 @@ int main( int argc, char **argv )
|
||||
if (gh)
|
||||
{
|
||||
ghand=new geodemoEventHandler();
|
||||
gh->setUserUpdate(moveit);
|
||||
gh->setUserUpdate(dodynamics);
|
||||
viewer.prependEventHandler(ghand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// open the viewer window.
|
||||
osgUtil::SceneView *sc=viewer.getViewportSceneView(0);
|
||||
if (sc && camera_fov>0) {
|
||||
osg::Camera *cm=sc->getCamera();
|
||||
if (cm) cm->setFOV(camera_fov,camera_fov*(600.0f/800.0f),1.0f,1000.0f);
|
||||
}
|
||||
// open the viewer window.
|
||||
viewer.open();
|
||||
|
||||
// fire up the event loop.
|
||||
|
||||
@@ -39,7 +39,9 @@ osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor ©,
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
{
|
||||
// continue only if enabled
|
||||
if (enabled_) {
|
||||
if (enabled_ )
|
||||
{
|
||||
|
||||
|
||||
// typecast the NodeVisitor to CullVisitor
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
@@ -48,35 +50,45 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
if (cv) {
|
||||
|
||||
// continue only if the particle system is valid
|
||||
if (ps_.valid()) {
|
||||
if (ps_.valid())
|
||||
{
|
||||
|
||||
// retrieve the current time
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
if (nv.getFrameStamp())
|
||||
{
|
||||
|
||||
// skip if we haven't initialized t0_ yet
|
||||
if (t0_ != -1) {
|
||||
// retrieve the current time
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
|
||||
// check whether the particle system is frozen/culled
|
||||
if (!ps_->isFrozen() && (ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) {
|
||||
// skip if we haven't initialized t0_ yet
|
||||
if (t0_ != -1) {
|
||||
|
||||
// initialize matrix flags
|
||||
need_ltw_matrix_ = true;
|
||||
need_wtl_matrix_ = true;
|
||||
current_nodevisitor_ = &nv;
|
||||
// check whether the particle system is frozen/culled
|
||||
if (!ps_->isFrozen() && (ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) {
|
||||
|
||||
// do some process (unimplemented in this base class)
|
||||
process(t - t0_);
|
||||
// initialize matrix flags
|
||||
need_ltw_matrix_ = true;
|
||||
need_wtl_matrix_ = true;
|
||||
current_nodevisitor_ = &nv;
|
||||
|
||||
// do some process (unimplemented in this base class)
|
||||
process(t - t0_);
|
||||
}
|
||||
}
|
||||
|
||||
// update t0_
|
||||
t0_ = t;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::WARN) << "osgParticle::ParticleProcessor::traverse(NodeVisitor&) requires a valid FrameStamp to function, particles not updated.\n";
|
||||
}
|
||||
|
||||
// update t0_
|
||||
t0_ = t;
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
osg::notify(osg::WARN) << "ParticleProcessor \"" << getName() << "\": invalid particle system\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// call the inherited method
|
||||
|
||||
@@ -24,16 +24,27 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor &nv)
|
||||
{
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
if (cv) {
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
if (t0_ != -1) {
|
||||
ParticleSystem_Vector::iterator i;
|
||||
for (i=psv_.begin(); i!=psv_.end(); ++i) {
|
||||
if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull())) {
|
||||
i->get()->update(t - t0_);
|
||||
if (nv.getFrameStamp())
|
||||
{
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
if (t0_ != -1)
|
||||
{
|
||||
ParticleSystem_Vector::iterator i;
|
||||
for (i=psv_.begin(); i!=psv_.end(); ++i)
|
||||
{
|
||||
if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull()))
|
||||
{
|
||||
i->get()->update(t - t0_);
|
||||
}
|
||||
}
|
||||
}
|
||||
t0_ = t;
|
||||
}
|
||||
t0_ = t;
|
||||
else
|
||||
{
|
||||
osg::notify(osg::WARN) << "osgParticle::ParticleSystemUpdater::traverse(NodeVisitor&) requires a valid FrameStamp to function, particles not updated.\n";
|
||||
}
|
||||
|
||||
}
|
||||
Node::traverse(nv);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
geoActions.cpp\
|
||||
ReaderWriterGEO.cpp
|
||||
|
||||
LIBS += -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgText -losgSim $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = geo
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
676
src/osgPlugins/geo/geoActions.cpp
Normal file
676
src/osgPlugins/geo/geoActions.cpp
Normal file
@@ -0,0 +1,676 @@
|
||||
// GEO format (carbon graphics Inc) loader for the OSG real time scene graph
|
||||
// www.carbongraphics.com for more information about the Geo animation+ modeller
|
||||
// 2002
|
||||
// actions & behaviours for Geo loader in OSG
|
||||
|
||||
#include <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(uint iop) {
|
||||
switch (iop) {
|
||||
case 1: op=addv; break; /* op=addv; addv is a function so the operation can be accessed without a switch(type)... */
|
||||
case 2: op=subv; break;
|
||||
case 3: op=mulv; break;
|
||||
case 4: op=divv; break;
|
||||
case 5: op=equa; break;
|
||||
}
|
||||
}
|
||||
void geoArithBehaviour::doaction(void) const { // do math operation
|
||||
if (in && out && op) {
|
||||
(*out)=op(*in,acon.get());
|
||||
// std::cout << " math sum " << out<< " " << (*out) << " " << in <<" " << (*in) << std::endl;
|
||||
}
|
||||
}
|
||||
bool geoArithBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
in=theHeader->getVar(fid); // returns address of input var with fid
|
||||
//std::cout<< "Input " << fid << " : " << theHeader->getVarname(fid) ;
|
||||
if (in) {
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OUTPUT_VAR);
|
||||
if (gfd) {
|
||||
fid= gfd->getUInt(); // field identifier
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
//std::cout<< " Output " << fid << " : " << theHeader->getVarname(fid) << std::endl;
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OP_TYPE);
|
||||
uint iop=gfd?gfd->getUInt():1;
|
||||
setType(iop); // default add?
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE);
|
||||
if (gfd) {
|
||||
acon.set(gfd->getFloat()); // field identifier
|
||||
ok=true;
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
ok=acon.set(theHeader->getVar(fid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoAr3Behaviour::setType(uint iact) {
|
||||
switch (iact) {
|
||||
case DB_DSK_LINEAR_ACTION: op=linear; break; /* op=addv; */
|
||||
case DB_DSK_INVERSE_ACTION: op=lininv; break;
|
||||
// case 3: op=linmod; break;
|
||||
// case 4: op=linsqr; break;
|
||||
case DB_DSK_TRUNCATE_ACTION: op=trunc; break;
|
||||
case DB_DSK_PERIODIC_ACTION: op=linabs; break;
|
||||
case DB_DSK_IF_THEN_ELSE_ACTION: op=ifelse; break;
|
||||
}
|
||||
}
|
||||
void geoAr3Behaviour::setTrigType(int iop) {
|
||||
switch (iop) {
|
||||
case 1: op=trigsin; break; /* op=trigonometric, sine; */
|
||||
case 2: op=trigcos; break;
|
||||
case 3: op=trigtan; break;
|
||||
case 4: op=trigasin; break;
|
||||
case 5: op=trigacos; break;
|
||||
case 6: op=trigatan; break;
|
||||
case 7: op=trigatan2; break;
|
||||
case 8: op=trighypot; break;
|
||||
}
|
||||
}
|
||||
void geoAr3Behaviour::setPeriodicType(int iop) {
|
||||
switch (iop) {
|
||||
case 1: op=period_1; break; /* op=period type 1; */
|
||||
case 2: op=period_2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void geoAr3Behaviour::doaction(void) { // do math operation
|
||||
if (in && out && op) {
|
||||
double var3=bcon.get();
|
||||
*out=op(*in,getconstant(),var3);
|
||||
//std::cout << " ar3 sum " << out<< " " << (*out) << " con " << getconstant() <<" b: " << bcon.get() << std::endl;
|
||||
}
|
||||
}
|
||||
bool geoAr3Behaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_EQUATION_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
in=theHeader->getVar(fid); // returns address of input var with fid
|
||||
if (in) {
|
||||
gfd=grec->getField(GEO_DB_EQUATION_ACTION_OUTPUT_VAR);
|
||||
if (gfd) {
|
||||
fid= gfd->getUInt(); // field identifier
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
if (act==DB_DSK_TRIG_ACTION) {
|
||||
gfd=grec->getField(GEO_DB_TRIG_ACTION_OP);
|
||||
int iop=gfd?gfd->getInt():1;
|
||||
setTrigType(iop); // one of sin...
|
||||
} else if (act==DB_DSK_PERIODIC_ACTION) {
|
||||
gfd=grec->getField(GEO_DB_PERIODIC_ACTION_TYPE);
|
||||
int iop=gfd?gfd->getInt():1; // type 1 or 2 periodic
|
||||
setPeriodicType(iop); // one of period 1 or 2...
|
||||
} else if (act==DB_DSK_IF_THEN_ELSE_ACTION) {
|
||||
setType(act); // if..else if (a is in range (-1,1) =b else=c
|
||||
} else {
|
||||
setType(act); // default linear, inverse, mod.. a.b+c
|
||||
setConstant(1);
|
||||
ok=true;
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_EQUATION_ACTION_A_VAL);
|
||||
if (gfd) {
|
||||
setConstant(gfd->getFloat()); // field identifier
|
||||
ok=true;
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_EQUATION_ACTION_A_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
ok=setVariable(theHeader->getVar(fid));
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_EQUATION_ACTION_C_VAL);
|
||||
if (gfd) {
|
||||
bcon.set(gfd->getFloat()); // field identifier
|
||||
ok=true;
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_EQUATION_ACTION_C_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
ok=bcon.set(theHeader->getVar(fid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoCompareBehaviour::setType(uint iop) {
|
||||
switch (iop) {
|
||||
case 1: oper=LESS;break;
|
||||
case 2: oper=LESSOREQ; break;
|
||||
case 3: oper=GREATER; break;
|
||||
case 4: oper=GREATOREQ; break;
|
||||
case 5: oper=EQUALTO; break;
|
||||
}
|
||||
}
|
||||
|
||||
void geoCompareBehaviour::doaction(void) const { // do compare operation
|
||||
if (in && out) {
|
||||
double var2=varop? *varop : constant;
|
||||
switch (oper) {
|
||||
case 1: oper; *out = (*in < var2) ? 1.0: -1.0; break;// Less
|
||||
case 2: oper; *out = (*in <= var2) ? 1.0: -1.0; break;//=LessOREQ
|
||||
case 3: oper; *out = (*in > var2) ? 1.0: -1.0; break; // greater...
|
||||
case 4: oper; *out = (*in >= var2) ? 1.0: -1.0; break;
|
||||
case 5: oper; *out = (*in == var2) ? 1.0: -1.0; break;
|
||||
case UNKNOWN: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool geoCompareBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_COMPARE_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
in=theHeader->getVar(fid); // returns address of input var with fid
|
||||
if (in) {
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OUTPUT_VAR);
|
||||
if (gfd) {
|
||||
fid= gfd->getUInt(); // field identifier
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OP_TYPE);
|
||||
uint iop=gfd?gfd->getUInt():1;
|
||||
setType(iop); // default add?
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OPERAND_VALUE);
|
||||
if (gfd) {
|
||||
constant= gfd->getFloat(); // field identifier
|
||||
ok=true;
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OPERAND_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
varop=theHeader->getVar(fid);
|
||||
ok=varop != NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoRangeBehaviour::doaction(void) const { // do math operation
|
||||
if (in && out) {
|
||||
float v=*in;
|
||||
if (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(void) const { // 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(void) const { // 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);
|
||||
uint nr=gfd?gfd->getUInt():1;
|
||||
uint 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)*
|
||||
osg::Matrix::translate(centre));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act) {
|
||||
bool ok=false;
|
||||
setType(act);
|
||||
if (act==DB_DSK_ROTATE_ACTION) {
|
||||
const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
double *vcon=theHeader->getVar(fid); // returns address of var with fid
|
||||
if (vcon) {
|
||||
// std::cout<< "rotInput " << fid << " : " << theHeader->getVarname(fid)<< std::endl ;
|
||||
setVar(vcon);
|
||||
gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR);
|
||||
if (gfd) {
|
||||
float *ax= gfd->getVec3Arr(); // field identifier
|
||||
setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN);
|
||||
if (gfd) {
|
||||
float *ct= gfd->getVec3Arr(); // field identifier
|
||||
setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
|
||||
}
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
} else if (act==DB_DSK_TRANSLATE_ACTION) {
|
||||
const geoField *gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
double *vcon=theHeader->getVar(fid); // returns address of var with fid
|
||||
if (vcon) {
|
||||
setVar(vcon);
|
||||
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR);
|
||||
if (gfd) {
|
||||
float *ax= gfd->getVec3Arr(); // field identifier
|
||||
setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN);
|
||||
if (gfd) {
|
||||
float *ct= gfd->getVec3Arr(); // field identifier
|
||||
setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
|
||||
}
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
} else if (act==DB_DSK_SCALE_ACTION) { // Nov 2002 not yet implemented in the modeller!
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
void geoMoveVertexBehaviour::doaction(Matrix &mtr,osg::Drawable *dr) {
|
||||
// update the matrix mtr
|
||||
if (getVar()) {
|
||||
switch (getType()) {
|
||||
case DB_DSK_SCALE_ACTION:
|
||||
mtr = mtr*osg::Matrix::scale(movb.getAxis()*(getValue())) ;
|
||||
break;
|
||||
case DB_DSK_TRANSLATE_ACTION:
|
||||
mtr = mtr*osg::Matrix::translate(movb.getAxis()*(getValue())) ;
|
||||
break;
|
||||
case DB_DSK_ROTATE_ACTION:
|
||||
//std::cout << dr->getName() << " v: " << getVar() << " rotion " << DEG2RAD(getValue()) << std::endl;
|
||||
mtr = mtr*osg::Matrix::translate(-movb.getCentre())*
|
||||
osg::Matrix::rotate(DEG2RAD(getValue()),movb.getAxis())*
|
||||
osg::Matrix::translate(movb.getCentre());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act) {
|
||||
bool ok=false;
|
||||
setType(act);
|
||||
if (act==DB_DSK_ROTATE_ACTION) {
|
||||
const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
double *vcon=theHeader->getVar(fid); // returns address of var with fid
|
||||
if (vcon) {
|
||||
// std::cout<< "rotInput " << fid << " : " << theHeader->getVarname(fid)<< std::endl ;
|
||||
setVar(vcon);
|
||||
gfd=grec->getField(GEO_DB_ROTATE_ACTION_VECTOR);
|
||||
if (gfd) {
|
||||
float *ax= gfd->getVec3Arr(); // field identifier
|
||||
movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_ROTATE_ACTION_ORIGIN);
|
||||
if (gfd) {
|
||||
float *ct= gfd->getVec3Arr(); // field identifier
|
||||
movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
|
||||
}
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
} else if (act==DB_DSK_TRANSLATE_ACTION) {
|
||||
const geoField *gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
double *vcon=theHeader->getVar(fid); // returns address of var with fid
|
||||
if (vcon) {
|
||||
setVar(vcon);
|
||||
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_VECTOR);
|
||||
if (gfd) {
|
||||
float *ax= gfd->getVec3Arr(); // field identifier
|
||||
movb.setAxis(osg::Vec3(ax[0],ax[1],ax[2]));
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_TRANSLATE_ACTION_ORIGIN);
|
||||
if (gfd) {
|
||||
float *ct= gfd->getVec3Arr(); // field identifier
|
||||
movb.setCentre(osg::Vec3(ct[0],ct[1],ct[2]));
|
||||
}
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
} else if (act==DB_DSK_SCALE_ACTION) { // Nov 2002 not yet implemented in the modeller!
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) {
|
||||
bool ok=false;
|
||||
const geoField *gfd= grec->getField(GEO_DB_VISIBILITY_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
setVar(theHeader->getVar(fid)); // returns address of input var with fid
|
||||
ok=true; // all data supplied
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
void geoVisibBehaviour::doaction(osg::Node *node) const
|
||||
{ // do visibility operation on Node
|
||||
if (getVar()) {
|
||||
if (getValue() <0.0) {
|
||||
node->setNodeMask(0x0); // invisible
|
||||
} else {
|
||||
node->setNodeMask(0xffffffff); // visible
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool geoColourBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd= grec->getField(GEO_DB_COLOR_RAMP_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
setVar(theHeader->getVar(fid)); // returns address of input var with fid
|
||||
gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_COLOR_FROM_PALETTE);
|
||||
if (gfd) {}
|
||||
gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_TOP_COLOR_INDEX);
|
||||
topcindx=(gfd? gfd->getUInt():4096);
|
||||
gfd=grec->getField(GEO_DB_COLOR_RAMP_ACTION_BOTTOM_COLOR_INDEX);
|
||||
botcindx=(gfd? gfd->getUInt():0);
|
||||
//also available: GEO_DB_COLOR_RAMP_ACTION_MATCH_COLUMNS
|
||||
ok=true; // all data supplied
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
void geoColourBehaviour::doaction(osg::Drawable *dr) const
|
||||
{ // do visibility operation on Node
|
||||
if (getVar()) {
|
||||
uint idx=getValue();
|
||||
osg::Geometry *gm=dynamic_cast<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 (uint i=nstart; i<(nend); i++) {
|
||||
unsigned char col[4];
|
||||
uint idxtop=idx/128;
|
||||
(*colours)[idxtop].get(col); // from the colour palette
|
||||
float frac=(float)(idx-idxtop*128)/128.0f;
|
||||
(*cla)[i].set(col[0]*frac/255.0,col[1]*frac/255.0,col[2]*frac/255.0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void geoStrContentBehaviour::doaction(osg::Drawable *node) { // do new text
|
||||
osgText::Text *txt=dynamic_cast<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));
|
||||
}
|
||||
bool geoStrContentBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
setVar(theHeader->getVar(fid)); // returns address of input var with fid
|
||||
if (getVar()) {
|
||||
gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_FORMAT);
|
||||
if (gfd) {
|
||||
char *ch=gfd->getChar();
|
||||
format=new char[strlen(ch)+1];
|
||||
strcpy(format, ch);
|
||||
{
|
||||
char *ctmp=format;
|
||||
while (*ctmp) {
|
||||
if (*ctmp=='d') vt=INT;
|
||||
if (*ctmp=='f' && vt!=DOUBLE) vt=FLOAT;
|
||||
if (*ctmp=='l') vt=DOUBLE;
|
||||
ctmp++;
|
||||
}
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE);
|
||||
gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_PADDING_TYPE);
|
||||
ok=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv)
|
||||
{ // callback updates the transform, colour, string content...
|
||||
MatrixTransform *mtr=dynamic_cast<MatrixTransform *> (node);
|
||||
if (mtr) mtr->setMatrix(Matrix::identity()); // all actions are multiplied to this
|
||||
for (std::vector<geoBehaviour *>::const_iterator itr=gblist.begin();
|
||||
itr<gblist.end();
|
||||
itr++) { // motion behaviour
|
||||
geoArithBehaviour *ab=dynamic_cast<geoArithBehaviour *>(*itr);
|
||||
if (ab) ab->doaction();
|
||||
geoAr3Behaviour *a3=dynamic_cast<geoAr3Behaviour *>(*itr);
|
||||
if (a3) a3->doaction();
|
||||
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
|
||||
if (cb) cb->doaction();
|
||||
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
|
||||
if (cr) cr->doaction();
|
||||
geoCompareBehaviour *cmb=dynamic_cast<geoCompareBehaviour *>(*itr);
|
||||
if (cmb) cmb->doaction();
|
||||
geoDiscreteBehaviour *db=dynamic_cast<geoDiscreteBehaviour *>(*itr);
|
||||
if (db) db->doaction();
|
||||
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::app(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...
|
||||
geoArithBehaviour *ab=dynamic_cast<geoArithBehaviour *>(*itr);
|
||||
if (ab) ab->doaction();
|
||||
geoAr3Behaviour *a3=dynamic_cast<geoAr3Behaviour *>(*itr);
|
||||
if (a3) a3->doaction();
|
||||
geoClampBehaviour *cb=dynamic_cast<geoClampBehaviour *>(*itr);
|
||||
if (cb) cb->doaction();
|
||||
geoRangeBehaviour *cr=dynamic_cast<geoRangeBehaviour *>(*itr);
|
||||
if (cr) cr->doaction();
|
||||
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,dr);
|
||||
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,dr);
|
||||
prevvtr=vidx;
|
||||
pos=mvvb->getpos();
|
||||
newpos=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newpos) {
|
||||
osg::Vec3Array* vtxa = dynamic_cast<osg::Vec3Array*>(gm->getVertexArray());
|
||||
(*vtxa)[prevvtr]=pos*mtr;
|
||||
}
|
||||
} while (newpos);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
/*===========================================================================*\
|
||||
|
||||
NAME: geoTypes.h
|
||||
NAME: geoTypes.h
|
||||
|
||||
DESCRIPTION: Constants fro Node types etc.
|
||||
DESCRIPTION: Constants fro Node types etc.
|
||||
|
||||
AUTHOR: Andy Bushnell
|
||||
AUTHOR: Andy Bushnell
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
PROPRIETARY RIGHTS NOTICE:
|
||||
|
||||
@@ -41,58 +41,58 @@ COPYRIGHT NOTICE:
|
||||
|
||||
|
||||
#ifndef uint
|
||||
#define uint unsigned int
|
||||
#define uint unsigned int
|
||||
#endif
|
||||
|
||||
#ifndef ushort
|
||||
//#define ushort unsigned short
|
||||
//#define ushort unsigned short
|
||||
#endif
|
||||
|
||||
#ifndef ubyte
|
||||
#define ubyte unsigned char
|
||||
#define ubyte unsigned char
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* constants to identify the plugin type
|
||||
*/
|
||||
const uint GEO_PLUGIN_TYPE_UNDEFINED = 1;
|
||||
const uint GEO_PLUGIN_TYPE_GEOMETRY_IMPORTER = 2;
|
||||
const uint GEO_PLUGIN_TYPE_GEOMETRY_EXPORTER = 3;
|
||||
const uint GEO_PLUGIN_TYPE_IMAGE_IMPORTER = 4;
|
||||
const uint GEO_PLUGIN_TYPE_TOOL = 5;
|
||||
const uint GEO_PLUGIN_TYPE_BEHAVIOR = 6;
|
||||
const uint GEO_PLUGIN_TYPE_GROUP_NODE_DEF = 7;
|
||||
const uint GEO_PLUGIN_TYPE_LAST = GEO_PLUGIN_TYPE_GROUP_NODE_DEF;
|
||||
const uint GEO_PLUGIN_TYPE_UNDEFINED = 1;
|
||||
const uint GEO_PLUGIN_TYPE_GEOMETRY_IMPORTER = 2;
|
||||
const uint GEO_PLUGIN_TYPE_GEOMETRY_EXPORTER = 3;
|
||||
const uint GEO_PLUGIN_TYPE_IMAGE_IMPORTER = 4;
|
||||
const uint GEO_PLUGIN_TYPE_TOOL = 5;
|
||||
const uint GEO_PLUGIN_TYPE_BEHAVIOR = 6;
|
||||
const uint GEO_PLUGIN_TYPE_GROUP_NODE_DEF = 7;
|
||||
const uint GEO_PLUGIN_TYPE_LAST = GEO_PLUGIN_TYPE_GROUP_NODE_DEF;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** user tool constant - put in favorites menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_USER = 1;
|
||||
const uint GEO_TOOL_TYPE_USER = 1;
|
||||
|
||||
/** create tool constant - put in create menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_CREATE = 2;
|
||||
const uint GEO_TOOL_TYPE_CREATE = 2;
|
||||
|
||||
/** modify tool constant - put in modify menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_MODIFY = 3;
|
||||
const uint GEO_TOOL_TYPE_MODIFY = 3;
|
||||
|
||||
/** helper point tool constant - put in helpers menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_HELPER_PT = 4;
|
||||
const uint GEO_TOOL_TYPE_HELPER_PT = 4;
|
||||
|
||||
/** appearance tool constant - put in plugins menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_APPEARANCE = 5;
|
||||
const uint GEO_TOOL_TYPE_APPEARANCE = 5;
|
||||
|
||||
/** behavior tool constant - put in plugins menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_BEHAVIOR = 6;
|
||||
const uint GEO_TOOL_TYPE_BEHAVIOR = 6;
|
||||
|
||||
/** behavior tool constant - put in plugins menu & toolbar */
|
||||
const uint GEO_TOOL_TYPE_OPTIMIZE = 7;
|
||||
const uint GEO_TOOL_TYPE_OPTIMIZE = 7;
|
||||
|
||||
/** convenience constant */
|
||||
const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE;
|
||||
const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE;
|
||||
|
||||
|
||||
|
||||
@@ -102,155 +102,155 @@ const uint GEO_TOOL_TYPE_LAST = GEO_TOOL_TYPE_OPTIMIZE;
|
||||
*
|
||||
* The GEO Node Type Class Hierarchy is as follows...
|
||||
*
|
||||
* GEO_DB_BASE
|
||||
* GEO_DB_GROUP
|
||||
* GEO_DB_BILLBOARD
|
||||
* GEO_DB_SEQUENCE
|
||||
* GEO_DB_LOD
|
||||
* GEO_DB_SWITCH
|
||||
* GEO_DB_RENDERGROUP
|
||||
* GEO_DB_BASE_GROUP
|
||||
* GEO_DB_EXTERNAL
|
||||
* GEO_DB_INSTANCE
|
||||
* GEO_DB_PAGE
|
||||
* GEO_DB_TRANSFORM (*)
|
||||
* GEO_DB_GEOMETRY
|
||||
* GEO_DB_SURFACE
|
||||
* GEO_DB_COORDINATE_SURFACE
|
||||
* GEO_DB_POLYGON
|
||||
* GEO_DB_LIGHTPT
|
||||
* GEO_DB_MESH (*)
|
||||
* GEO_DB_PARAMETRIC_SURFACE (*)
|
||||
* GEO_DB_QUADRIC (*)
|
||||
* GEO_DB_TEXT
|
||||
* GEO_DB_BASE_SURFACE (*)
|
||||
* GEO_DB_VERTEX
|
||||
* GEO_DB_HEADER
|
||||
* GEO_DB_BASE
|
||||
* GEO_DB_GROUP
|
||||
* GEO_DB_BILLBOARD
|
||||
* GEO_DB_SEQUENCE
|
||||
* GEO_DB_LOD
|
||||
* GEO_DB_SWITCH
|
||||
* GEO_DB_RENDERGROUP
|
||||
* GEO_DB_BASE_GROUP
|
||||
* GEO_DB_EXTERNAL
|
||||
* GEO_DB_INSTANCE
|
||||
* GEO_DB_PAGE
|
||||
* GEO_DB_TRANSFORM (*)
|
||||
* GEO_DB_GEOMETRY
|
||||
* GEO_DB_SURFACE
|
||||
* GEO_DB_COORDINATE_SURFACE
|
||||
* GEO_DB_POLYGON
|
||||
* GEO_DB_LIGHTPT
|
||||
* GEO_DB_MESH (*)
|
||||
* GEO_DB_PARAMETRIC_SURFACE (*)
|
||||
* GEO_DB_QUADRIC (*)
|
||||
* GEO_DB_TEXT
|
||||
* GEO_DB_BASE_SURFACE (*)
|
||||
* GEO_DB_VERTEX
|
||||
* GEO_DB_HEADER
|
||||
*
|
||||
* (*) Not available in Geo Version 1.0
|
||||
*/
|
||||
const uint GEO_DB_BASE = 0x00000003;
|
||||
const uint GEO_DB_GROUP = (0x00000004 | GEO_DB_BASE);
|
||||
const uint GEO_DB_SEQUENCE = (0x00000010 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_LOD = (0x00000020 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_SWITCH = (0x00000040 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_RENDERGROUP = (0x00000080 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_GEOMETRY = (0x00000100 | GEO_DB_BASE);
|
||||
const uint GEO_DB_SURFACE = (0x00000200 | GEO_DB_GEOMETRY);
|
||||
const uint GEO_DB_COORDINATE_SURFACE = (0x00000400 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_POLYGON = (0x00000800 | GEO_DB_COORDINATE_SURFACE);
|
||||
const uint GEO_DB_MESH = (0x00001000 | GEO_DB_POLYGON);
|
||||
const uint GEO_DB_PARAMETRIC_SURFACE = (0x00002000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_QUADRIC = (0x00004000 | GEO_DB_PARAMETRIC_SURFACE);
|
||||
const uint GEO_DB_PAGE = (0x00008000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_TEXT = (0x00040000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_VERTEX = (0x00080000 | GEO_DB_GEOMETRY);
|
||||
const uint GEO_DB_HEADER = (0x00100000 | GEO_DB_BASE);
|
||||
const uint GEO_DB_TRANSFORM = (0x00200000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_BASE_GROUP = (0x00400000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_BASE_SURFACE = (0x00800000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_EXTERNAL = (0x01000000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_INSTANCE = (0x04000000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_LIGHTPT = (0x08000000 | GEO_DB_POLYGON);
|
||||
const uint GEO_DB_BASE = 0x00000003;
|
||||
const uint GEO_DB_GROUP = (0x00000004 | GEO_DB_BASE);
|
||||
const uint GEO_DB_SEQUENCE = (0x00000010 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_LOD = (0x00000020 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_SWITCH = (0x00000040 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_RENDERGROUP = (0x00000080 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_GEOMETRY = (0x00000100 | GEO_DB_BASE);
|
||||
const uint GEO_DB_SURFACE = (0x00000200 | GEO_DB_GEOMETRY);
|
||||
const uint GEO_DB_COORDINATE_SURFACE = (0x00000400 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_POLYGON = (0x00000800 | GEO_DB_COORDINATE_SURFACE);
|
||||
const uint GEO_DB_MESH = (0x00001000 | GEO_DB_POLYGON);
|
||||
const uint GEO_DB_PARAMETRIC_SURFACE = (0x00002000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_QUADRIC = (0x00004000 | GEO_DB_PARAMETRIC_SURFACE);
|
||||
const uint GEO_DB_PAGE = (0x00008000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_TEXT = (0x00040000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_VERTEX = (0x00080000 | GEO_DB_GEOMETRY);
|
||||
const uint GEO_DB_HEADER = (0x00100000 | GEO_DB_BASE);
|
||||
const uint GEO_DB_TRANSFORM = (0x00200000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_BASE_GROUP = (0x00400000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_BASE_SURFACE = (0x00800000 | GEO_DB_SURFACE);
|
||||
const uint GEO_DB_EXTERNAL = (0x01000000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_INSTANCE = (0x04000000 | GEO_DB_GROUP);
|
||||
const uint GEO_DB_LIGHTPT = (0x08000000 | GEO_DB_POLYGON);
|
||||
|
||||
// older version types for Compatability & convenience
|
||||
//
|
||||
const uint GEO_DB_ALL = GEO_DB_BASE;
|
||||
const uint GEO_DB_ALL_GROUP_TYPES = GEO_DB_GROUP;
|
||||
const uint GEO_DB_ALL_SURFACE_TYPES = GEO_DB_SURFACE;
|
||||
const uint GEO_DB_ALL_SHAPE_TYPES = GEO_DB_PARAMETRIC_SURFACE;
|
||||
const uint GEO_DB_ALL_GEOMETRY_TYPES = GEO_DB_GEOMETRY;
|
||||
const uint GEO_DB_ALL = GEO_DB_BASE;
|
||||
const uint GEO_DB_ALL_GROUP_TYPES = GEO_DB_GROUP;
|
||||
const uint GEO_DB_ALL_SURFACE_TYPES = GEO_DB_SURFACE;
|
||||
const uint GEO_DB_ALL_SHAPE_TYPES = GEO_DB_PARAMETRIC_SURFACE;
|
||||
const uint GEO_DB_ALL_GEOMETRY_TYPES = GEO_DB_GEOMETRY;
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** constants to identify the type of picking to be done */
|
||||
const uint GEO_PICK_GROUP = 0x00000001;
|
||||
const uint GEO_PICK_PRIM = 0x00000002;
|
||||
const uint GEO_PICK_VERTEX = 0x00000004;
|
||||
const uint GEO_PICK_EDGE = 0x00000008; // Future
|
||||
const uint GEO_PICK_GRID = 0x00000010;
|
||||
const uint GEO_PICK_NON_NODE = 0x00000020; // manipulators, user geometry etc.
|
||||
const uint GEO_PICK_EXTERNAL = 0x00000040;
|
||||
const uint GEO_PICK_GROUP = 0x00000001;
|
||||
const uint GEO_PICK_PRIM = 0x00000002;
|
||||
const uint GEO_PICK_VERTEX = 0x00000004;
|
||||
const uint GEO_PICK_EDGE = 0x00000008; // Future
|
||||
const uint GEO_PICK_GRID = 0x00000010;
|
||||
const uint GEO_PICK_NON_NODE = 0x00000020; // manipulators, user geometry etc.
|
||||
const uint GEO_PICK_EXTERNAL = 0x00000040;
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** constants to identify mouse button usage */
|
||||
const uint GEO_NO_MOUSE = 0x00000000;
|
||||
const uint GEO_LEFT_MOUSE = 0x00000001;
|
||||
const uint GEO_MIDDLE_MOUSE = 0x00000002;
|
||||
const uint GEO_RIGHT_MOUSE = 0x00000004;
|
||||
const uint GEO_LEFT_AND_RIGHT_MOUSE = 0x00000008;
|
||||
const uint GEO_MIDDLE_AND_RIGHT_MOUSE = 0x00000010;
|
||||
const uint GEO_NO_MOUSE = 0x00000000;
|
||||
const uint GEO_LEFT_MOUSE = 0x00000001;
|
||||
const uint GEO_MIDDLE_MOUSE = 0x00000002;
|
||||
const uint GEO_RIGHT_MOUSE = 0x00000004;
|
||||
const uint GEO_LEFT_AND_RIGHT_MOUSE = 0x00000008;
|
||||
const uint GEO_MIDDLE_AND_RIGHT_MOUSE = 0x00000010;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Predefined model unit identifier. database model units can be modified
|
||||
* via set/getUnits
|
||||
*/
|
||||
const uint GEO_DB_INCHES = 1;
|
||||
const uint GEO_DB_FEET = 2;
|
||||
const uint GEO_DB_YARDS = 3;
|
||||
const uint GEO_DB_MILES = 4;
|
||||
const uint GEO_DB_CENTIMETERS = 5;
|
||||
const uint GEO_DB_METERS = 6;
|
||||
const uint GEO_DB_KILOMETERS = 7;
|
||||
const uint GEO_DB_INCHES = 1;
|
||||
const uint GEO_DB_FEET = 2;
|
||||
const uint GEO_DB_YARDS = 3;
|
||||
const uint GEO_DB_MILES = 4;
|
||||
const uint GEO_DB_CENTIMETERS = 5;
|
||||
const uint GEO_DB_METERS = 6;
|
||||
const uint GEO_DB_KILOMETERS = 7;
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Constants to define the modeler's intended "up" direction if that
|
||||
* makes any sense
|
||||
*/
|
||||
|
||||
const int GEO_DB_UP_AXIS_X = 1;
|
||||
const int GEO_DB_UP_AXIS_Y = 2; // the default
|
||||
const int GEO_DB_UP_AXIS_Z = 3;
|
||||
|
||||
const int GEO_DB_UP_AXIS_X = 1;
|
||||
const int GEO_DB_UP_AXIS_Y = 2; // the default
|
||||
const int GEO_DB_UP_AXIS_Z = 3;
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Constants to control the drawing effect
|
||||
*
|
||||
* Constants to control the drawing of geometry primitives - usefull if user
|
||||
* wants to call standard draw method in a tool postDraw callback
|
||||
*/
|
||||
const uint GEO_DB_SOLID = 0x00000001;
|
||||
const uint GEO_DB_WIRE = 0x00000002;
|
||||
const uint GEO_DB_OUTLINED = 0x00000008;
|
||||
const uint GEO_DB_SOLID = 0x00000001;
|
||||
const uint GEO_DB_WIRE = 0x00000002;
|
||||
const uint GEO_DB_OUTLINED = 0x00000008;
|
||||
|
||||
const uint GEO_DB_ZBUFFER = 0x00000100;
|
||||
const uint GEO_DB_BACKFACE = 0x00000400;
|
||||
const uint GEO_DB_ZBUFFER = 0x00000100;
|
||||
const uint GEO_DB_BACKFACE = 0x00000400;
|
||||
|
||||
const uint GEO_DB_DRAW_FACE_NORMALS = 0x00001000;
|
||||
const uint GEO_DB_DRAW_VERTEX_NORMALS = 0x00002000;
|
||||
const uint GEO_DB_DRAW_FACE_NORMALS = 0x00001000;
|
||||
const uint GEO_DB_DRAW_VERTEX_NORMALS = 0x00002000;
|
||||
|
||||
const uint GEO_DB_TEXTURE = 0x00010000;
|
||||
const uint GEO_DB_HIGHLIGHT = 0x00020000;
|
||||
const uint GEO_DB_PICKING = 0x00040000;
|
||||
const uint GEO_DB_HIGHLIGHT_DASHED = 0x00080000;
|
||||
const uint GEO_DB_TEXTURE = 0x00010000;
|
||||
const uint GEO_DB_HIGHLIGHT = 0x00020000;
|
||||
const uint GEO_DB_PICKING = 0x00040000;
|
||||
const uint GEO_DB_HIGHLIGHT_DASHED = 0x00080000;
|
||||
|
||||
const uint GEO_DB_ILLUMINATED = 0x01000000;
|
||||
const uint GEO_DB_NORMAL_PER_PRIM = 0x04000000;
|
||||
const uint GEO_DB_NORMAL_PER_VERTEX = 0x08000000;
|
||||
const uint GEO_DB_ILLUMINATED = 0x01000000;
|
||||
const uint GEO_DB_NORMAL_PER_PRIM = 0x04000000;
|
||||
const uint GEO_DB_NORMAL_PER_VERTEX = 0x08000000;
|
||||
|
||||
const uint GEO_DB_COLOR_PER_GEODE = 0x10000000;
|
||||
const uint GEO_DB_COLOR_PER_PRIM = 0x20000000;
|
||||
const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000;
|
||||
const uint GEO_DB_COLOR_PER_GEODE = 0x10000000;
|
||||
const uint GEO_DB_COLOR_PER_PRIM = 0x20000000;
|
||||
const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Constants to control the switch Node behavior
|
||||
*
|
||||
* Switch Nodes can either be addative (in which case the
|
||||
@@ -259,16 +259,16 @@ const uint GEO_DB_COLOR_PER_VERTEX = 0x40000000;
|
||||
*
|
||||
* Selctive control is not implemented.
|
||||
*/
|
||||
const uint GEO_SWITCH_TYPE_ADDATIVE = 1;
|
||||
const uint GEO_SWITCH_TYPE_SELECTIVE = 2;
|
||||
const uint GEO_SWITCH_TYPE_ADDATIVE = 1;
|
||||
const uint GEO_SWITCH_TYPE_SELECTIVE = 2;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Type Tokens for Node & Tool Gui Widgets */
|
||||
const int GUI_FLOAT = 1;
|
||||
const int GUI_INT = 2;
|
||||
const int GUI_STRING = 3;
|
||||
const int GUI_FLOAT = 1;
|
||||
const int GUI_INT = 2;
|
||||
const int GUI_STRING = 3;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -278,19 +278,19 @@ typedef void geoWidget;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/** Animated String padding tokens */
|
||||
const int GEO_TEXT_PAD_NONE = 0;
|
||||
const int GEO_TEXT_PAD_WITH_SPACES = 1;
|
||||
const int GEO_TEXT_PAD_WITH_ZEROES = 2;
|
||||
const int GEO_TEXT_PAD_NONE = 0;
|
||||
const int GEO_TEXT_PAD_WITH_SPACES = 1;
|
||||
const int GEO_TEXT_PAD_WITH_ZEROES = 2;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Polygon draw style types
|
||||
//
|
||||
const int GEO_POLY_DSTYLE_SOLID = 0;
|
||||
const int GEO_POLY_DSTYLE_OPEN_WIRE = 1;
|
||||
const int GEO_POLY_DSTYLE_CLOSED_WIRE = 2;
|
||||
const int GEO_POLY_DSTYLE_POINTS = 3;
|
||||
const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4;
|
||||
const int GEO_POLY_DSTYLE_SOLID = 0;
|
||||
const int GEO_POLY_DSTYLE_OPEN_WIRE = 1;
|
||||
const int GEO_POLY_DSTYLE_CLOSED_WIRE = 2;
|
||||
const int GEO_POLY_DSTYLE_POINTS = 3;
|
||||
const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4;
|
||||
|
||||
|
||||
|
||||
@@ -298,63 +298,63 @@ const int GEO_POLY_DSTYLE_SOLID_BOTH_SIDES = 4;
|
||||
// Polygon shade style types
|
||||
//
|
||||
|
||||
const int GEO_POLY_SHADEMODEL_FLAT = 0;
|
||||
const int GEO_POLY_SHADEMODEL_GOURAUD = 1;
|
||||
const int GEO_POLY_SHADEMODEL_LIT = 2;
|
||||
const int GEO_POLY_SHADEMODEL_LIT_GOURAUD = 3;
|
||||
const int GEO_POLY_SHADEMODEL_FLAT = 0;
|
||||
const int GEO_POLY_SHADEMODEL_GOURAUD = 1;
|
||||
const int GEO_POLY_SHADEMODEL_LIT = 2;
|
||||
const int GEO_POLY_SHADEMODEL_LIT_GOURAUD = 3;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Texture Mapping types
|
||||
//
|
||||
|
||||
const int GEO_POLY_PLANAR_MAP = 0;
|
||||
const int GEO_POLY_CYLINDRICAL_MAP = 1;
|
||||
const int GEO_POLY_SPHERICAL_MAP = 2;
|
||||
const int GEO_POLY_PLANAR_MAP = 0;
|
||||
const int GEO_POLY_CYLINDRICAL_MAP = 1;
|
||||
const int GEO_POLY_SPHERICAL_MAP = 2;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// STring type constants
|
||||
//
|
||||
const int GEO_TEXT_RASTER = 0;
|
||||
const int GEO_TEXT_STROKE = 1;
|
||||
const int GEO_TEXT_RASTER = 0;
|
||||
const int GEO_TEXT_STROKE = 1;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Justification constants
|
||||
//
|
||||
const int GEO_TEXT_LEFT_JUSTIFY = 0;
|
||||
const int GEO_TEXT_CENTER_JUSTIFY = 1;
|
||||
const int GEO_TEXT_RIGHT_JUSTIFY = 2;
|
||||
const int GEO_TEXT_LEFT_JUSTIFY = 0;
|
||||
const int GEO_TEXT_CENTER_JUSTIFY = 1;
|
||||
const int GEO_TEXT_RIGHT_JUSTIFY = 2;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Direction constants
|
||||
//
|
||||
const int GEO_TEXT_LEFT_TO_RIGHT = 0;
|
||||
const int GEO_TEXT_RIGHT_TO_LEFT = 1;
|
||||
const int GEO_TEXT_TOP_TO_BOTTOM = 2;
|
||||
const int GEO_TEXT_BOTTOM_TO_TOP = 3;
|
||||
const int GEO_TEXT_LEFT_TO_RIGHT = 0;
|
||||
const int GEO_TEXT_RIGHT_TO_LEFT = 1;
|
||||
const int GEO_TEXT_TOP_TO_BOTTOM = 2;
|
||||
const int GEO_TEXT_BOTTOM_TO_TOP = 3;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LightPoint Type constants
|
||||
//
|
||||
const int GEO_DB_LIGHTPT_OMNI_DIRECTIONAL = 0;
|
||||
const int GEO_DB_LIGHTPT_UNI_DIRECTIONAL = 1;
|
||||
const int GEO_DB_LIGHTPT_BI_DIRECTIONAL = 2;
|
||||
const int GEO_DB_LIGHTPT_OMNI_DIRECTIONAL = 0;
|
||||
const int GEO_DB_LIGHTPT_UNI_DIRECTIONAL = 1;
|
||||
const int GEO_DB_LIGHTPT_BI_DIRECTIONAL = 2;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Texture Record Wrap S & T Modes
|
||||
const unsigned GEO_DB_TEX_CLAMP = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_REPEAT = 0x00000002;
|
||||
const unsigned GEO_DB_TEX_CLAMP = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_REPEAT = 0x00000002;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Texture Record MagFilter
|
||||
const unsigned GEO_DB_TEX_NEAREST = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_LINEAR = 0x00000002;
|
||||
const unsigned GEO_DB_TEX_NEAREST = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_LINEAR = 0x00000002;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -367,9 +367,9 @@ const unsigned GEO_DB_TEX_LINEAR_MIPMAP_LINEAR = 0x00000020;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Texture Record TexEnv
|
||||
const unsigned GEO_DB_TEX_MODULATE = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_DECAL = 0x00000002;
|
||||
const unsigned GEO_DB_TEX_BLEND = 0x00000004;
|
||||
const unsigned GEO_DB_TEX_MODULATE = 0x00000001;
|
||||
const unsigned GEO_DB_TEX_DECAL = 0x00000002;
|
||||
const unsigned GEO_DB_TEX_BLEND = 0x00000004;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*===========================================================================*\
|
||||
|
||||
NAME: geoUnits.h
|
||||
NAME: geoUnits.h
|
||||
|
||||
DESCRIPTION: Constants to convert coordinate data to/from meters (Geo
|
||||
default)
|
||||
DESCRIPTION: Constants to convert coordinate data to/from meters (Geo
|
||||
default)
|
||||
|
||||
AUTHOR: Andy Bushnell
|
||||
AUTHOR: Andy Bushnell
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
PROPRIETARY RIGHTS NOTICE:
|
||||
|
||||
|
||||
This software contains proprietary information and trade secrets of Carbon
|
||||
Graphics LLC. No part or all of this software may be reproduced in any form,
|
||||
without the written permission of Carbon Graphics LLC.
|
||||
@@ -40,34 +40,34 @@ COPYRIGHT NOTICE:
|
||||
#define _GEO_UNITS_H_
|
||||
|
||||
|
||||
const float KM_TO_METERS = 1000.0f;
|
||||
const float CM_TO_METERS = 0.01f;
|
||||
const float MM_TO_METERS = 0.001f;
|
||||
const float NM_TO_METERS = 1852.0f;
|
||||
const float MILES_TO_METERS = 1609.344f;
|
||||
const float YARDS_TO_METERS = 0.9144f;
|
||||
const float FEET_TO_METERS = 0.3048f;
|
||||
const float INCHES_TO_METERS= 0.0254f;
|
||||
const float KM_TO_METERS = 1000.0f;
|
||||
const float CM_TO_METERS = 0.01f;
|
||||
const float MM_TO_METERS = 0.001f;
|
||||
const float NM_TO_METERS = 1852.0f;
|
||||
const float MILES_TO_METERS = 1609.344f;
|
||||
const float YARDS_TO_METERS = 0.9144f;
|
||||
const float FEET_TO_METERS = 0.3048f;
|
||||
const float INCHES_TO_METERS= 0.0254f;
|
||||
|
||||
const float METERS_TO_KM = 0.001f;
|
||||
const float METERS_TO_CM = 100.0f;
|
||||
const float METERS_TO_MM = 1000.0f;
|
||||
const float METERS_TO_NM = 0.0005399568035f;
|
||||
const float METERS_TO_MILES = 0.0006213711922f;
|
||||
const float METERS_TO_YARDS = 1.093613298f;
|
||||
const float METERS_TO_FEET = 3.280839895f;
|
||||
const float METERS_TO_INCHES= 39.37007874f;
|
||||
const float METERS_TO_KM = 0.001f;
|
||||
const float METERS_TO_CM = 100.0f;
|
||||
const float METERS_TO_MM = 1000.0f;
|
||||
const float METERS_TO_NM = 0.0005399568035f;
|
||||
const float METERS_TO_MILES = 0.0006213711922f;
|
||||
const float METERS_TO_YARDS = 1.093613298f;
|
||||
const float METERS_TO_FEET = 3.280839895f;
|
||||
const float METERS_TO_INCHES= 39.37007874f;
|
||||
|
||||
const float CM_TO_FEET = 0.03280839895f;
|
||||
const float CM_TO_INCHES = 0.3937007874f;
|
||||
const float FEET_TO_YARDS = 0.333333333f;
|
||||
const float FEET_TO_CM = 30.48f;
|
||||
const float FEET_TO_INCHES = 12.0f;
|
||||
const float INCHES_TO_FEET = 0.083333333f;
|
||||
const float INCHES_TO_CM = 2.54f;
|
||||
const float CM_TO_FEET = 0.03280839895f;
|
||||
const float CM_TO_INCHES = 0.3937007874f;
|
||||
const float FEET_TO_YARDS = 0.333333333f;
|
||||
const float FEET_TO_CM = 30.48f;
|
||||
const float FEET_TO_INCHES = 12.0f;
|
||||
const float INCHES_TO_FEET = 0.083333333f;
|
||||
const float INCHES_TO_CM = 2.54f;
|
||||
|
||||
const float MPH_TO_FPS = 1.4667f;
|
||||
const float MPH_TO_MPS = 0.447f;
|
||||
const float MPH_TO_FPS = 1.4667f;
|
||||
const float MPH_TO_MPS = 0.447f;
|
||||
|
||||
|
||||
|
||||
|
||||
292
src/osgPlugins/geo/osgGeoAction.h
Normal file
292
src/osgPlugins/geo/osgGeoAction.h
Normal file
@@ -0,0 +1,292 @@
|
||||
// geo actions header
|
||||
|
||||
#ifndef _GEO_ACTIONS_H_
|
||||
#define _GEO_ACTIONS_H_
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
class georecord; // You don't need to know how I read a geo record,
|
||||
// but objects of this class are passed to some of the parsing routines.
|
||||
// The values are defined in osgGeoStructs.h which is distributed with OSG.
|
||||
|
||||
class geoBehaviour { // base class for action & math functions where var out = f(var in)
|
||||
public:
|
||||
geoBehaviour() { }
|
||||
virtual ~geoBehaviour() { }
|
||||
virtual void doaction(void) const
|
||||
{ // do math or action operation
|
||||
}
|
||||
protected:
|
||||
};
|
||||
|
||||
class geoBehaviourDrawableCB: public osg::Drawable::AppCallback {
|
||||
public:
|
||||
geoBehaviourDrawableCB() { }
|
||||
~geoBehaviourDrawableCB() { }
|
||||
void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);}
|
||||
void app(osg::NodeVisitor *,osg::Drawable *dr);
|
||||
private:
|
||||
std::vector<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(void) const
|
||||
{ // do math operation eg *out=*in or =f(*in).
|
||||
}
|
||||
protected:
|
||||
const double *in; // address of input variable
|
||||
double *out; // address of output
|
||||
};
|
||||
|
||||
// in these functions, var1 is the input value x, var2 (& 3) are constants.
|
||||
inline double DEG2RAD(const double var) { return var*0.0174532925199432957692369076848861; }
|
||||
inline double addv(const double var1,const double var2) { return var1+var2; }
|
||||
inline double subv(const double var1,const double var2) { return var1-var2; }
|
||||
inline double mulv(const double var1,const double var2) { return var1*var2; }
|
||||
inline double divv(const double var1,const double var2) { return var1/var2; }
|
||||
inline double equa(const double var1,const double var2) { return var1; }
|
||||
inline double linear(const double var1,const double var2,const double var3) { return var2*var1+var3; }
|
||||
inline double lininv(const double var1,const double var2,const double var3) { return var2/var1+var3; }
|
||||
inline double linmod(const double var1,const double var2,const double var3) { return var2*fmod(var1,var3); }
|
||||
inline double linsqr(const double var1,const double var2,const double var3) { return var2*sqrt(var1)+var3; }
|
||||
inline double linabs(const double var1,const double var2,const double var3) { return var1*fmod(var2,var3); }
|
||||
inline double trunc(const double var1,const double var2,const double var3) { return ((int)(var1/var2)+var3); }
|
||||
inline double trigsin(const double var1,const double var2,const double var3) { return var2*sin(DEG2RAD(var1*var3)); }
|
||||
inline double trigcos(const double var1,const double var2,const double var3) { return var2*cos(DEG2RAD(var1*var3)); }
|
||||
inline double trigtan(const double var1,const double var2,const double var3) { return var2*tan(DEG2RAD(var1*var3)); }
|
||||
inline double trigasin(const double var1,const double var2,const double var3) { return var2*asin(var1*var3); }
|
||||
inline double trigacos(const double var1,const double var2,const double var3) { return var2*acos(var1*var3); }
|
||||
inline double trigatan(const double var1,const double var2,const double var3) { return var2*atan(var1*var3); }
|
||||
inline double trigatan2(const double var1,const double var2,const double var3) { return var2*atan2(var1,var3); }
|
||||
inline double trighypot(const double var1,const double var2,const double var3) { return var2*hypot(var1,var3); }
|
||||
inline double period_1(const double var1,const double var2,const double var3) { return var2*fmod(var1,var3); }
|
||||
inline double period_2(const double var1,const double var2,const double var3) { return fmod(var1*var2,var3); }
|
||||
inline double ifelse(const double var1,const double var2,const double var3) { return ((var1<1.0 && var1>-1.0) ? var2:var3); }
|
||||
|
||||
class geoArithConstant { // a constant can be a fixed double OR address of variable
|
||||
public:
|
||||
geoArithConstant(const float v=0) { constant=v; varop=NULL; }
|
||||
virtual ~geoArithConstant() {}
|
||||
void set(const float v) { constant=v; varop=NULL; }
|
||||
bool set(const double *v) { varop=v; return (v!=NULL);}
|
||||
inline double get(void) const { return varop? *varop : constant;}
|
||||
private:
|
||||
float constant;
|
||||
const double *varop; // if null use constant value in maths; else
|
||||
};
|
||||
|
||||
class geoArithBehaviour : public geoMathBehaviour {
|
||||
public:
|
||||
geoArithBehaviour() { op=NULL; }
|
||||
virtual ~geoArithBehaviour() { }
|
||||
void setType(uint iop);
|
||||
bool setVariable(const double *varvar) { return acon.set(varvar);}
|
||||
void setConstant(float v) {acon.set(v); }
|
||||
inline double getconstant(void) { return acon.get();}
|
||||
void doaction(void) const; // do math operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
private:
|
||||
double (* op)(const double d1, const double v2);
|
||||
geoArithConstant acon;
|
||||
};
|
||||
|
||||
class geoAr3Behaviour : public geoArithBehaviour { // extended to 3 constants, out=f(a,b,c)
|
||||
public:
|
||||
geoAr3Behaviour() { op=NULL; }
|
||||
virtual ~geoAr3Behaviour() { }
|
||||
|
||||
void setType(uint iact);
|
||||
void setTrigType(int iop);
|
||||
void setPeriodicType(int iop);
|
||||
|
||||
void doaction(void); // do math operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act);
|
||||
private:
|
||||
geoArithConstant bcon;
|
||||
double (* op)(const double d1, const double v2, const double v3);
|
||||
};
|
||||
class geoCompareBehaviour : public geoMathBehaviour {
|
||||
public:
|
||||
geoCompareBehaviour() { constant=0; oper=UNKNOWN; varop=NULL;}
|
||||
virtual ~geoCompareBehaviour() { }
|
||||
enum optype{UNKNOWN, GREATER, GREATOREQ, LESS, LESSOREQ, EQUALTO};
|
||||
// void setConstant(const float v) { constant=v;}
|
||||
void setType(uint iop);
|
||||
void setVariable(const double *varvar) { varop=varvar;}
|
||||
|
||||
void doaction(void) const; // do compare operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
private:
|
||||
float constant;
|
||||
optype oper;
|
||||
const double *varop; // if null use constant value in maths; else
|
||||
};
|
||||
|
||||
class geoRangeBehaviour :public geoMathBehaviour {
|
||||
// output = outmin + frac*(outmax-min) where frac = (in-min)/(max-min)
|
||||
public:
|
||||
geoRangeBehaviour() { inmin=outmin=(float)-1.e32; inmax=outmax=(float)1.e32; in=out=NULL;}
|
||||
~geoRangeBehaviour() { }
|
||||
void setInMax(const double v) { inmax=v;}
|
||||
void setInMin(const double v) { inmin=v;}
|
||||
void setOutMax(const double v) { outmax=v;}
|
||||
void setOutMin(const double v) { outmin=v;}
|
||||
void doaction(void) const; // do math operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
private:
|
||||
float inmin,inmax;
|
||||
float outmin,outmax;
|
||||
};
|
||||
class geoClampBehaviour :public geoMathBehaviour {
|
||||
public:
|
||||
geoClampBehaviour() { min=(float)-1.e32; max=(float)1.e32; in=out=NULL;}
|
||||
~geoClampBehaviour() { }
|
||||
void setMax(const double v) { max=v;}
|
||||
void setMin(const double v) { min=v;}
|
||||
void doaction(void) const; // do math operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
private:
|
||||
float min,max;
|
||||
};
|
||||
class geoRange { // discrete range -- min,max,output
|
||||
public:
|
||||
geoRange() { min.set(0.0); max.set(0.0); val.set(0.0);}
|
||||
virtual ~geoRange() {}
|
||||
inline void setMin(const float v) { min.set(v);}
|
||||
inline void setMax(const float v) { max.set(v);}
|
||||
inline void setVal(const float v) { val.set(v);}
|
||||
const double getMin(void) const { return min.get();}
|
||||
const double getMax(void) const { return max.get();}
|
||||
const double getVal(void) const { return val.get();}
|
||||
private:
|
||||
geoArithConstant min,max,val;
|
||||
};
|
||||
class geoDiscreteBehaviour : public geoMathBehaviour { // discrete action -- output= 1 of several
|
||||
public:
|
||||
geoDiscreteBehaviour() {nrange=1; }
|
||||
virtual ~geoDiscreteBehaviour() {}
|
||||
void doaction(void) const; // do math operation
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
|
||||
private:
|
||||
int nrange;
|
||||
std::vector<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 *node) const {
|
||||
}
|
||||
|
||||
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) {
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
// for fast transform behaviours
|
||||
unsigned int type; // eg GEO_DB_ROTATE_ACTION_INPUT_VAR, translate etc
|
||||
const double *var; // variable controls this behaviour
|
||||
};
|
||||
class geoMoveBehaviour : public geoActionBehaviour { // class of rotate & translate actions
|
||||
public:
|
||||
geoMoveBehaviour() { axis.set(0,0,1); centre.set(0,0,0);}
|
||||
virtual ~geoMoveBehaviour() { }
|
||||
void setCentre(const Vec3 v) { centre=v;}
|
||||
void setAxis(const Vec3 v) { axis=v;}
|
||||
inline Vec3 getAxis() { return axis;}
|
||||
inline Vec3 getCentre() { return centre;}
|
||||
void doaction(osg::Node *node);
|
||||
|
||||
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act);
|
||||
private:
|
||||
// for fast transform behaviours
|
||||
osg::Vec3 axis; // axis of rotation or translate or scale
|
||||
osg::Vec3 centre; // centre of rotation or scale
|
||||
};
|
||||
class geoMoveVertexBehaviour : public geoActionBehaviour { // class of rotate & translate vertex actions
|
||||
public:
|
||||
geoMoveVertexBehaviour() { index=0; pos.set(0,0,0);}
|
||||
virtual ~geoMoveVertexBehaviour() { }
|
||||
inline Vec3 getpos() { return pos;}
|
||||
void setpos(const osg::Vec3 p) { pos=p;}
|
||||
void setindx(const int idx) { index=idx;}
|
||||
inline int getindex(void) const { return index;}
|
||||
void doaction(Matrix &mtr,osg::Drawable *dr);
|
||||
|
||||
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act);
|
||||
private:
|
||||
// for fast transform behaviours
|
||||
int index; // which index in the geometry
|
||||
Vec3 pos; // raw position of the vertex
|
||||
geoMoveBehaviour movb;
|
||||
};
|
||||
|
||||
class geoVisibBehaviour : public geoActionBehaviour { // visibility action -- sets node mask
|
||||
public:
|
||||
geoVisibBehaviour() { }
|
||||
virtual ~geoVisibBehaviour() { }
|
||||
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act);
|
||||
void doaction(osg::Node *node) const;
|
||||
private:
|
||||
};
|
||||
class geoColourBehaviour : public geoActionBehaviour { // colour action
|
||||
// sets content of case DB_DSK_COLOR_RAMP_ACTION
|
||||
public:
|
||||
geoColourBehaviour() { topcindx=4096; botcindx=0; numramps=1; type=UNKNOWN; colours=NULL;}
|
||||
virtual ~geoColourBehaviour() { }
|
||||
enum cacts {UNKNOWN, PALETTE, RAMP};
|
||||
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
|
||||
void doaction(osg::Drawable *dr) const;
|
||||
void setVertIndices(const uint ns, const uint n) { nstart=ns; nend=ns+n;}
|
||||
void setColorPalette(const colourPalette *color_palette) {colours=color_palette;}
|
||||
private:
|
||||
uint numramps;
|
||||
uint topcindx,botcindx; // top & bottom colour indices
|
||||
cacts type; //
|
||||
uint nstart,nend; // start index in the colours array, and number of indices
|
||||
const colourPalette *colours; // where the colours come from - actually held in the geoHeader structure
|
||||
};
|
||||
|
||||
class geoStrContentBehaviour : public geoActionBehaviour { // string content actions
|
||||
// sets content of a string...
|
||||
public:
|
||||
geoStrContentBehaviour() {format=NULL;PADDING_TYPE=0;
|
||||
PAD_FOR_SIGN=0; vt=UNKNOWN; }
|
||||
virtual ~geoStrContentBehaviour() { delete [] format;}
|
||||
void doaction(osg::Drawable *node); // do new text
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
enum valuetype {UNKNOWN, INT, FLOAT, DOUBLE, CHAR};
|
||||
private:
|
||||
char *format;
|
||||
uint PADDING_TYPE;
|
||||
uint PAD_FOR_SIGN;
|
||||
valuetype vt;
|
||||
};
|
||||
|
||||
class geoBehaviourCB: public osg::NodeCallback {
|
||||
public:
|
||||
geoBehaviourCB() { }
|
||||
~geoBehaviourCB() { }
|
||||
void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);}
|
||||
virtual void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv);
|
||||
private:
|
||||
std::vector<geoBehaviour *> gblist;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,163 +1,52 @@
|
||||
// animation features of the CarbonGraphics .geo format
|
||||
// require access to the internal Vars & External Vars.
|
||||
// This file is required by external simulations to enable the user to
|
||||
// control the GEO internal, user & external variables.
|
||||
|
||||
// The user creates one or two functions (here uvarupdate, extvarupdate).
|
||||
// These functions are demonstrated in geodemo.cpp.
|
||||
|
||||
// Consider a model as being a class (or a subroutine). The class has a 'draw' method
|
||||
// supplied by OSG, and the model can be animated (parts of the model
|
||||
// rotate, move, change colour, become invisible etc.).
|
||||
//
|
||||
// The model developer attaches 'behaviours' to parts of the model (using the Geo graphical editor)
|
||||
// and assigns these behaviours to depend on variables. There are 3 pools of variables:
|
||||
// Internal, usually time dependent variables which cannot be modified by the developer.
|
||||
// User variables - may be a function of other variables, defined in the editor.
|
||||
// External variables - the user written callback function extvarupdate sets these values on each frame of simulation.
|
||||
// User & external variables may be defined as a mathematical or logical function of
|
||||
// all teh variables (external variables, internal variables & user variables).
|
||||
|
||||
// as a design rule, you should not normally attach a function to uvarupdate
|
||||
// these variables should be considered as local variables within a function and not accessed by the program.
|
||||
// The external variables should call a user written extvarupdate routine which can
|
||||
// access Ethernet, a data file, shared memory or any other code to model the dynamics of your model.
|
||||
|
||||
#ifndef _GEO_ANIM_H_
|
||||
#define _GEO_ANIM_H_
|
||||
|
||||
#include <osg/Timer>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
|
||||
class georecord; // You don't need to know how I read a geo record,
|
||||
// but objects of this class are passed to some of the parsing routines.
|
||||
// The values are defined in osgGeoStructs.h which is distributed with OSG.
|
||||
|
||||
class geoValue {
|
||||
public:
|
||||
geoValue() {
|
||||
token=0; fid=0; val.d=0; name="";
|
||||
vmin=0; vmax=0;
|
||||
constrained=false;
|
||||
}
|
||||
geoValue(const unsigned int tok, const unsigned int fident) {
|
||||
token=tok; fid=fident; val.d=0; name="";
|
||||
vmin=0; vmax=0;
|
||||
constrained=false;
|
||||
}
|
||||
~geoValue() {}
|
||||
inline unsigned int getToken() const { return token;}
|
||||
inline unsigned int getFID() const { return fid;}
|
||||
inline double *getValue() { return &(val.d);}
|
||||
void setVal(double v) { val.d=v;
|
||||
if (constrained) {
|
||||
if (v>vmax) val.d=vmax;
|
||||
if (v<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() {
|
||||
}
|
||||
void addInternalVars(const georecord &gr);
|
||||
void update(osg::Timer &_timer,osg::FrameStamp &_frameStamp);
|
||||
double *getVar(const unsigned fid) {
|
||||
int iord=0;
|
||||
for (std::vector<geoValue>::iterator itr=vars.begin();
|
||||
itr!=vars.end();
|
||||
++itr, iord++)
|
||||
{// for each field
|
||||
if ((*itr).getFID() == fid) {
|
||||
return ((*itr).getValue());
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<geoValue> vars; // these fields define internal vars
|
||||
};
|
||||
|
||||
class userVars {
|
||||
public:
|
||||
userVars() {}
|
||||
~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->getValue());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void addUserVar(const georecord &gr);
|
||||
void update() {
|
||||
for (std::vector<geoValue>::iterator itr=vars.begin();
|
||||
itr!=vars.end();
|
||||
++itr)
|
||||
{// for each user var
|
||||
// itr->setVal((*itr->getValue())+0.01);
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::vector<geoValue> vars;
|
||||
};
|
||||
|
||||
class geoHeader: public osg::PositionAttitudeTransform {
|
||||
// structure for header of .geo file
|
||||
// adds position attitude orientation for not Z up models,
|
||||
// plus animation variables.
|
||||
// structure for header of .geo file
|
||||
// adds position attitude orientation for not Z up models,
|
||||
// plus animation variables.
|
||||
public:
|
||||
geoHeader() { intVars=new internalVars; useVars=new userVars;
|
||||
extVars=new userVars;
|
||||
_frameStamp.setFrameNumber(0); // vars=NULL;
|
||||
tstart=_frameStamp.getReferenceTime();_initialTick = _timer.tick();
|
||||
ucb=NULL;
|
||||
};
|
||||
void setUserUpdate(void (*ufn)(const double time, userVars *locVars,userVars *extVars) )
|
||||
{ // pass the address of a user written function in the App process.
|
||||
ucb=ufn;
|
||||
}
|
||||
void addInternalVars(const georecord &gr) { intVars->addInternalVars(gr);}
|
||||
internalVars *getInternalVars(void) const { return intVars;}
|
||||
double *getVar(const unsigned fid) {
|
||||
double *dv=NULL;
|
||||
dv=intVars->getVar(fid);
|
||||
if (!dv) {
|
||||
dv=useVars->getVar(fid);
|
||||
if (!dv) {
|
||||
dv=extVars->getVar(fid);
|
||||
}
|
||||
}
|
||||
return dv;
|
||||
}
|
||||
void addUserVar(const georecord &gr)
|
||||
{ // this georecord defines a single variable of type<>
|
||||
useVars->addUserVar(gr);
|
||||
}
|
||||
void update() {
|
||||
osg::Timer_t _frameTick = _timer.tick();;
|
||||
_lastFrameTick=_frameTick;
|
||||
|
||||
_frameStamp.setFrameNumber(_frameStamp.getFrameNumber()+1);
|
||||
_frameStamp.setReferenceTime(_timer.delta_s(_initialTick,_frameTick));
|
||||
double time = _frameStamp.getReferenceTime();
|
||||
intVars->update(_timer, _frameStamp);
|
||||
useVars->update();
|
||||
extVars->update();
|
||||
if (ucb) ucb(time,useVars, extVars);
|
||||
}
|
||||
userVars *getLocalVars() const { return useVars;}
|
||||
userVars *getExternalVars() const { return extVars;}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~geoHeader() {}
|
||||
|
||||
osg::Timer_t _lastFrameTick,_initialTick;
|
||||
osg::Timer _timer;
|
||||
double tstart; // start time
|
||||
osg::FrameStamp _frameStamp ; // time utilities
|
||||
internalVars *intVars;
|
||||
userVars *useVars;
|
||||
userVars *extVars;
|
||||
void (* ucb)(const double t, userVars *l,userVars *e); // called when variables are updated, you write this!
|
||||
geoHeader() {
|
||||
uvarupdate=NULL; extvarupdate=NULL;
|
||||
};
|
||||
~geoHeader() {}
|
||||
void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
||||
{ // pass the address of a user written function in the App process.
|
||||
uvarupdate=ufn;
|
||||
}
|
||||
void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
||||
{ // pass the address of a user written function in the App process.
|
||||
extvarupdate=ufn;
|
||||
}
|
||||
double (* uvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
||||
double (* extvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
177
src/osgPlugins/geo/osgGeoNodes.h
Normal file
177
src/osgPlugins/geo/osgGeoNodes.h
Normal file
@@ -0,0 +1,177 @@
|
||||
// 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() {
|
||||
}
|
||||
void addInternalVars(const georecord &gr);
|
||||
void update(osg::Timer &_timer,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() {}
|
||||
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() { color_palette->clear(); }
|
||||
void addInternalVars(const georecord &gr) { intVars->addInternalVars(gr);}
|
||||
internalVars *getInternalVars(void) const { return intVars;}
|
||||
const std::string getVarname(const unsigned fid) const {
|
||||
const geoValue *gv=getGeoVar(fid);
|
||||
return gv->getName();
|
||||
}
|
||||
const geoValue *getGeoVar(const unsigned fid) const;
|
||||
double *getVar(const unsigned fid) const;
|
||||
void addUserVar(const georecord &gr);
|
||||
//== handler for updating internal variables
|
||||
void update(void);
|
||||
inline void getPalette(uint icp, float cll[4]) const { // get color from palette
|
||||
uint maxcol=icp/128; // the maximum intensity index
|
||||
float frac = (float)(icp-maxcol*128)/128.0f;
|
||||
|
||||
if (maxcol < color_palette->size()) {
|
||||
unsigned char col[4];
|
||||
(*color_palette)[maxcol].get(col);
|
||||
for (int i=0; i<4; i++) {
|
||||
col[i]*=frac;
|
||||
cll[i]=col[i]/255.0f;
|
||||
}
|
||||
} else {
|
||||
unsigned char col[4];
|
||||
col[0]=(icp & 0xff000000)>> 24;
|
||||
col[1]=(icp & 0xff0000) >> 16;
|
||||
col[2]=(icp & 0xff00) >> 8;
|
||||
col[3]= icp & 0xff;
|
||||
for (int i=0; i<4; i++) {
|
||||
cll[i]=col[i]/255.0f;
|
||||
}
|
||||
cll[0]=cll[1]=cll[2]=1.0f;
|
||||
}
|
||||
cll[3]=1.0f; // default alpha {0-1}
|
||||
}
|
||||
void addColour(unsigned char *cpal) {(*color_palette).push_back(cpal);}
|
||||
inline colourPalette *getColorPalette() const { return color_palette;}
|
||||
private:
|
||||
osg::Timer_t _lastFrameTick,_initialTick;
|
||||
osg::Timer _timer;
|
||||
double tstart; // start time
|
||||
osg::FrameStamp _frameStamp ; // time utilities
|
||||
internalVars *intVars;
|
||||
userVars *useVars;
|
||||
userVars *extVars;
|
||||
void moveit(const double t);
|
||||
colourPalette *color_palette; // the colour palette - used in colour animations
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user