Added a bunch of files synched with 0.8.42
@@ -1,29 +1,32 @@
|
||||
#!smake
|
||||
SHELL=/bin/sh
|
||||
|
||||
DIRS = sgv cube
|
||||
DIRS = sgv osgconv osgcube osgreflect osgtexture osgimpostor osgviews hangglide
|
||||
|
||||
all :
|
||||
for f in $(DIRS) ; do cd $$f; make ; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) || exit 1; cd ..; done
|
||||
|
||||
clean :
|
||||
for f in $(DIRS) ; do cd $$f; make clean; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) clean; cd ..; done
|
||||
|
||||
clobber :
|
||||
for f in $(DIRS) ; do cd $$f; make clobber; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) clobber; cd ..; done
|
||||
|
||||
depend :
|
||||
for f in $(DIRS) ; do cd $$f; make depend; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) depend; cd ..; done
|
||||
|
||||
to_unix :
|
||||
for f in $(DIRS) ; do cd $$f; to_unix Makefile Makefile; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; make to_unix; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE)to_unix; cd ..; done
|
||||
|
||||
beautify :
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE)beautify; cd ..; done
|
||||
|
||||
install :
|
||||
for f in $(DIRS) ; do cd $$f; make install; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) install; cd ..; done
|
||||
|
||||
instlinks :
|
||||
for f in $(DIRS) ; do cd $$f; make instlinks; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) instlinks; cd ..; done
|
||||
|
||||
instclean :
|
||||
for f in $(DIRS) ; do cd $$f; make instclean; cd ..; done
|
||||
for f in $(DIRS) ; do cd $$f; $(MAKE) instclean; cd ..; done
|
||||
|
||||
229
src/Demos/hangglide/GliderManipulator.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
#include <osg/Notify>
|
||||
#include <osg/Types>
|
||||
|
||||
#include "GliderManipulator.h"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
|
||||
GliderManipulator::GliderManipulator()
|
||||
{
|
||||
_modelScale = 0.01f;
|
||||
_velocity = 0.0f;
|
||||
_yawMode = YAW_AUTOMATICALLY_WHEN_BANKED;
|
||||
}
|
||||
|
||||
|
||||
GliderManipulator::~GliderManipulator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GliderManipulator::setNode(osg::Node* node)
|
||||
{
|
||||
_node = node;
|
||||
if (_node.get())
|
||||
{
|
||||
const osg::BoundingSphere& boundingSphere=_node->getBound();
|
||||
_modelScale = boundingSphere._radius;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const osg::Node* GliderManipulator::getNode() const
|
||||
{
|
||||
return _node.get();
|
||||
}
|
||||
|
||||
|
||||
void GliderManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
{
|
||||
if(_node.get() && _camera.get())
|
||||
{
|
||||
|
||||
const osg::BoundingSphere& boundingSphere=_node->getBound();
|
||||
|
||||
osg::Vec3 eye = boundingSphere._center+osg::Vec3(-boundingSphere._radius*0.15f,-boundingSphere._radius*0.15f,-boundingSphere._radius*0.03f);
|
||||
|
||||
_camera->setView(eye,
|
||||
eye+osg::Vec3(1.0f,1.0f,-0.1f),
|
||||
osg::Vec3(0.0f,0.0f,1.0f));
|
||||
|
||||
_velocity = boundingSphere._radius*0.01f;
|
||||
|
||||
us.requestRedraw();
|
||||
|
||||
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2,(ea.getYmin()+ea.getYmax())/2);
|
||||
|
||||
flushMouseEventStack();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GliderManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
{
|
||||
flushMouseEventStack();
|
||||
|
||||
us.requestContinuousUpdate(false);
|
||||
|
||||
const osg::BoundingSphere& boundingSphere=_node->getBound();
|
||||
_velocity = boundingSphere._radius*0.01f;
|
||||
|
||||
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2,(ea.getYmin()+ea.getYmax())/2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool GliderManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
{
|
||||
if(!_camera.get()) return false;
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(GUIEventAdapter::PUSH):
|
||||
{
|
||||
|
||||
addMouseEvent(ea);
|
||||
us.requestContinuousUpdate(true);
|
||||
if (calcMovement()) us.requestRedraw();
|
||||
|
||||
}
|
||||
return true;
|
||||
case(GUIEventAdapter::RELEASE):
|
||||
{
|
||||
|
||||
addMouseEvent(ea);
|
||||
us.requestContinuousUpdate(true);
|
||||
if (calcMovement()) us.requestRedraw();
|
||||
|
||||
}
|
||||
return true;
|
||||
case(GUIEventAdapter::DRAG):
|
||||
{
|
||||
|
||||
addMouseEvent(ea);
|
||||
us.requestContinuousUpdate(true);
|
||||
if (calcMovement()) us.requestRedraw();
|
||||
|
||||
}
|
||||
return true;
|
||||
case(GUIEventAdapter::MOVE):
|
||||
{
|
||||
|
||||
addMouseEvent(ea);
|
||||
us.requestContinuousUpdate(true);
|
||||
if (calcMovement()) us.requestRedraw();
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
case(GUIEventAdapter::KEYBOARD):
|
||||
if (ea.getKey()==' ')
|
||||
{
|
||||
flushMouseEventStack();
|
||||
home(ea,us);
|
||||
us.requestRedraw();
|
||||
us.requestContinuousUpdate(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case(GUIEventAdapter::FRAME):
|
||||
addMouseEvent(ea);
|
||||
if (calcMovement()) us.requestRedraw();
|
||||
return true;
|
||||
case(GUIEventAdapter::RESIZE):
|
||||
{
|
||||
init(ea,us);
|
||||
us.requestRedraw();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GliderManipulator::flushMouseEventStack()
|
||||
{
|
||||
_ga_t1 = NULL;
|
||||
_ga_t0 = NULL;
|
||||
}
|
||||
|
||||
|
||||
void GliderManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
||||
{
|
||||
_ga_t1 = _ga_t0;
|
||||
_ga_t0 = &ea;
|
||||
}
|
||||
|
||||
|
||||
bool GliderManipulator::calcMovement()
|
||||
{
|
||||
// return if less then two events have been added.
|
||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||
|
||||
float dt = _ga_t0->time()-_ga_t1->time();
|
||||
|
||||
if (dt<0.0f)
|
||||
{
|
||||
notify(WARN) << "warning dt = "<<dt<<endl;
|
||||
dt = 0.0f;
|
||||
}
|
||||
|
||||
unsigned int buttonMask = _ga_t1->getButtonMask();
|
||||
if (buttonMask==GUIEventAdapter::LEFT_BUTTON)
|
||||
{
|
||||
// pan model.
|
||||
|
||||
_velocity += dt*_modelScale*0.05f;
|
||||
|
||||
}
|
||||
else if (buttonMask==GUIEventAdapter::MIDDLE_BUTTON ||
|
||||
buttonMask==(GUIEventAdapter::LEFT_BUTTON|GUIEventAdapter::RIGHT_BUTTON))
|
||||
{
|
||||
|
||||
_velocity = 0.0f;
|
||||
|
||||
}
|
||||
else if (buttonMask==GUIEventAdapter::RIGHT_BUTTON)
|
||||
{
|
||||
|
||||
_velocity -= dt*_modelScale*0.05f;
|
||||
|
||||
}
|
||||
|
||||
float mx = (_ga_t0->getXmin()+_ga_t0->getXmax())/2.0f;
|
||||
float my = (_ga_t0->getYmin()+_ga_t0->getYmax())/2.0f;
|
||||
|
||||
float dx = _ga_t0->getX()-mx;
|
||||
float dy = _ga_t0->getY()-my;
|
||||
|
||||
osg::Vec3 center = _camera->getEyePoint();
|
||||
osg::Vec3 sv = _camera->getSideVector();
|
||||
osg::Vec3 lv = _camera->getLookVector();
|
||||
|
||||
float pitch = -dy*0.15f*dt;
|
||||
float roll = -dx*0.1f*dt;
|
||||
|
||||
osg::Matrix mat;
|
||||
mat.makeTrans(-center.x(),-center.y(),-center.z());
|
||||
mat.postRot(pitch,sv.x(),sv.y(),sv.z());
|
||||
mat.postRot(roll,lv.x(),lv.y(),lv.z());
|
||||
if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED)
|
||||
{
|
||||
float bank = asinf(sv.z());
|
||||
float yaw = (-bank*180.0f/M_PI)*dt;
|
||||
mat.postRot(yaw,0.0f,0.0f,1.0f);
|
||||
}
|
||||
mat.postTrans(center.x(),center.y(),center.z());
|
||||
|
||||
lv *= (_velocity*dt);
|
||||
|
||||
mat.postTrans(lv.x(),lv.y(),lv.z());
|
||||
|
||||
_camera->transformLookAt(mat);
|
||||
|
||||
return true;
|
||||
}
|
||||
65
src/Demos/hangglide/GliderManipulator.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef HANGGLIDE_GLIDERMANIPULATOR
|
||||
#define HANGGLIDE_GLIDERMANIPULATOR 1
|
||||
|
||||
#include <osgUtil/CameraManipulator>
|
||||
|
||||
class GliderManipulator : public osgUtil::CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
GliderManipulator();
|
||||
virtual ~GliderManipulator();
|
||||
|
||||
/** Attach a node to the manipulator.
|
||||
Automatically detaches previously attached node.
|
||||
setNode(NULL) detaches previously nodes.
|
||||
Is ignored by manipulators which do not require a reference model.*/
|
||||
virtual void setNode(osg::Node*);
|
||||
|
||||
/** Return node if attached.*/
|
||||
virtual const osg::Node* getNode() const;
|
||||
|
||||
/** Move the camera to the default position.
|
||||
May be ignored by manipulators if home functionality is not appropriate.*/
|
||||
virtual void home(const osgUtil::GUIEventAdapter& ea,osgUtil::GUIActionAdapter& us);
|
||||
|
||||
/** Start/restart the manipulator.*/
|
||||
virtual void init(const osgUtil::GUIEventAdapter& ea,osgUtil::GUIActionAdapter& us);
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const osgUtil::GUIEventAdapter& ea,osgUtil::GUIActionAdapter& us);
|
||||
|
||||
enum YawControlMode {
|
||||
YAW_AUTOMATICALLY_WHEN_BANKED,
|
||||
NO_AUTOMATIC_YAW
|
||||
};
|
||||
|
||||
/** Set the yaw control between no yaw and yawing when banked.*/
|
||||
void setYawControlMode(YawControlMode ycm) { _yawMode = ycm; }
|
||||
|
||||
private:
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const osgUtil::GUIEventAdapter& ea);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
bool calcMovement();
|
||||
|
||||
// Internal event stack comprising last three mouse events.
|
||||
osg::ref_ptr<const osgUtil::GUIEventAdapter> _ga_t1;
|
||||
osg::ref_ptr<const osgUtil::GUIEventAdapter> _ga_t0;
|
||||
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
|
||||
float _modelScale;
|
||||
float _velocity;
|
||||
|
||||
YawControlMode _yawMode;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
0
src/Demos/hangglide/Makedepend
Normal file
28
src/Demos/hangglide/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
hangglide.cpp\
|
||||
ReaderWriterFLY.cpp\
|
||||
GliderManipulator.cpp\
|
||||
hat.cpp\
|
||||
terrain.cpp\
|
||||
tank.cpp\
|
||||
sky.cpp\
|
||||
base.cpp\
|
||||
trees.cpp\
|
||||
|
||||
TARGET = ../../../bin/hangglide
|
||||
|
||||
TARGET_BIN_FILES = hangglide
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
C++FLAGS += -I. -I../../../include
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
13
src/Demos/hangglide/README
Normal file
@@ -0,0 +1,13 @@
|
||||
A simple hang gliding flight simulator demo. The current GliderManipulator
|
||||
does not yet have any dynamics built into it, something TODO...
|
||||
|
||||
A small database is built into the program - Ed Levin park, Don's local flying
|
||||
to be precise! You'll need the textures found in the OpenSceneGraph-Data
|
||||
distribution. To run type :
|
||||
|
||||
hangglide
|
||||
|
||||
To run type with other databases, treat it just like sgv such as :
|
||||
|
||||
hangglide town.osg
|
||||
|
||||
101
src/Demos/hangglide/ReaderWriterFLY.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/Registry>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
extern Node *makeTerrain( void );
|
||||
extern Node *makeTrees( void );
|
||||
extern Node *makeTank( void );
|
||||
extern Node *makeWindsocks( void );
|
||||
extern Node *makeGliders( void );
|
||||
extern Node *makeGlider( void );
|
||||
extern Node *makeSky( void );
|
||||
extern Node *makeBase( void );
|
||||
extern Node *makeClouds( void );
|
||||
|
||||
static struct _nodes
|
||||
{
|
||||
char *name;
|
||||
Node *(*fptr)(void);
|
||||
}
|
||||
|
||||
|
||||
nodes[] =
|
||||
{
|
||||
{ "terrain", makeTerrain },
|
||||
{ "tank", makeTank },
|
||||
{ "sky", makeSky },
|
||||
{ "base", makeBase },
|
||||
{ "trees", makeTrees },
|
||||
// { "gliders", makeGliders },
|
||||
// { "clouds", makeClouds },
|
||||
|
||||
{ 0L, 0L }
|
||||
};
|
||||
|
||||
class ReaderWriterFLY : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual const char* className() { return "FLY Database Reader"; }
|
||||
|
||||
virtual bool acceptsExtension(const std::string& extension)
|
||||
{
|
||||
return osgDB::equalCaseInsensitive(extension,"fly");
|
||||
}
|
||||
|
||||
virtual Node* readNode(const std::string& fileName)
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return NULL;
|
||||
|
||||
char buff[256];
|
||||
|
||||
notify(INFO)<< "ReaderWriterFLY::readNode( "<<fileName.c_str()<<" )\n";
|
||||
|
||||
FILE *fp;
|
||||
|
||||
if( (fp = fopen( fileName.c_str(), "r" )) == (FILE *)0L )
|
||||
{
|
||||
notify(WARN)<< "Unable to open file \""<<fileName.c_str()<<"\"\n";
|
||||
return 0L;
|
||||
}
|
||||
Group *grp = new Group;
|
||||
|
||||
while( !feof( fp ) )
|
||||
{
|
||||
_nodes *nptr;
|
||||
fgets( buff, sizeof( buff ), fp );
|
||||
if( buff[0] == '#' )
|
||||
continue;
|
||||
|
||||
for( nptr = nodes; nptr->name; nptr ++ )
|
||||
{
|
||||
if( !strncmp( buff, nptr->name, strlen( nptr->name ) ))
|
||||
{
|
||||
Node *node = nptr->fptr();
|
||||
node->setName( nptr->name );
|
||||
grp->addChild( node );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
|
||||
return grp;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// now register with osg::Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterFLY> g_readerWriter_FLY_Proxy;
|
||||
|
||||
94
src/Demos/hangglide/base.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Node *makeBase( void )
|
||||
{
|
||||
int i, c;
|
||||
float theta;
|
||||
float ir, ori;
|
||||
ir = 6.0;
|
||||
ori = 20.0;
|
||||
|
||||
Vec3 *coords = new Vec3[38];
|
||||
Vec2 *tcoords = new Vec2[38];
|
||||
Vec4 *colors = new Vec4[1];
|
||||
int *lengths = new int[1];
|
||||
|
||||
colors[0][0] = colors[0][1] = colors[0][2] = colors[0][3] = 1;
|
||||
|
||||
c = 0;
|
||||
for( i = 0; i <= 18; i++ )
|
||||
{
|
||||
theta = (float)i * 20.0 * M_PI/180.0;
|
||||
|
||||
coords[c][0] = ir * cosf( theta );
|
||||
coords[c][1] = ir * sinf( theta );
|
||||
coords[c][2] = 0.0;
|
||||
tcoords[c][0] = coords[c][0]/36.;
|
||||
tcoords[c][1] = coords[c][1]/36.;
|
||||
|
||||
c++;
|
||||
|
||||
coords[c][0] = ori * cosf( theta );
|
||||
coords[c][1] = ori * sinf( theta );
|
||||
coords[c][2] = 0.0f;
|
||||
|
||||
tcoords[c][0] = coords[c][0]/36.;
|
||||
tcoords[c][1] = coords[c][1]/36.;
|
||||
|
||||
c++;
|
||||
}
|
||||
*lengths = 38;
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
|
||||
gset->setCoords( coords );
|
||||
|
||||
gset->setTextureCoords( tcoords );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setColors( colors );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lengths );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
tex->setImage(osgDB::readImageFile("water.rgb"));
|
||||
tex->setWrap( Texture::WRAP_S, Texture::REPEAT );
|
||||
tex->setWrap( Texture::WRAP_T, Texture::REPEAT );
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
|
||||
dstate->setAttribute( new TexEnv );
|
||||
/*
|
||||
pfFog *fog = new pfFog;
|
||||
|
||||
fog->setFogType( PFFOG_PIX_EXP2 );
|
||||
fog->setColor( 0.1, 0.2, 0.2 );
|
||||
fog->setRange( 16.0, 22.0 );
|
||||
|
||||
gstate->setMode( PFSTATE_ENFOG, PF_ON );
|
||||
gstate->setAttr( PFSTATE_FOG, fog );
|
||||
*/
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
|
||||
return geode;
|
||||
}
|
||||
152
src/Demos/hangglide/hangglide.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include "GliderManipulator.h"
|
||||
|
||||
extern osg::Node *makeTerrain( void );
|
||||
extern osg::Node *makeTrees( void );
|
||||
extern osg::Node *makeTank( void );
|
||||
extern osg::Node *makeWindsocks( void );
|
||||
extern osg::Node *makeGliders( void );
|
||||
extern osg::Node *makeGlider( void );
|
||||
extern osg::Node *makeSky( void );
|
||||
extern osg::Node *makeBase( void );
|
||||
extern osg::Node *makeClouds( void );
|
||||
|
||||
/*
|
||||
* Function to read several files (typically one) as specified on the command
|
||||
* line, and return them in an osg::Node
|
||||
*/
|
||||
osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
typedef std::vector<osg::Node*> NodeList;
|
||||
NodeList nodeList;
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
|
||||
if (argv[i][0]=='-')
|
||||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osgDB::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile( argv[i] );
|
||||
|
||||
if( node != (osg::Node *)0L )
|
||||
{
|
||||
if (node->getName().empty()) node->setName( argv[i] );
|
||||
nodeList.push_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nodeList.size()==0)
|
||||
{
|
||||
osg::notify(osg::INFO) << "No data loaded."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
osg::Node *rootnode = new osg::Node;
|
||||
if (nodeList.size()==1)
|
||||
{
|
||||
rootnode = nodeList.front();
|
||||
}
|
||||
else // size >1
|
||||
{
|
||||
osg::Group* group = new osg::Group();
|
||||
for(NodeList::iterator itr=nodeList.begin();
|
||||
itr!=nodeList.end();
|
||||
++itr)
|
||||
{
|
||||
group->addChild(*itr);
|
||||
}
|
||||
|
||||
rootnode = group;
|
||||
}
|
||||
|
||||
return rootnode;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// if (argc<2)
|
||||
// {
|
||||
// osg::notify(osg::NOTICE)<<"usage:"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" sgv [options] infile1 [infile2 ...]"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<endl;
|
||||
// osg::notify(osg::NOTICE)<<"options:"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" -l libraryName - load plugin of name libraryName"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" i.e. -l osgdb_pfb"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" Useful for loading reader/writers which can load"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" other file formats in addition to its extension."<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" -e extensionName - load reader/wrter plugin for file extension"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" i.e. -e pfb"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" Useful short hand for specifying full library name as"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" done with -l above, as it automatically expands to the"<<endl;
|
||||
// osg::notify(osg::NOTICE)<<" full library name appropriate for each platform."<<endl;
|
||||
// osg::notify(osg::NOTICE)<<endl;
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
osg::Node* rootnode = getNodeFromFiles( argc, argv);
|
||||
if (rootnode==NULL)
|
||||
{
|
||||
// no database loaded so automatically create Ed Levin Park..
|
||||
osg::Group* group = new osg::Group;
|
||||
rootnode = group;
|
||||
group->addChild(makeTerrain());
|
||||
group->addChild(makeTank());
|
||||
group->addChild(makeSky());
|
||||
group->addChild(makeBase());
|
||||
group->addChild(makeTrees());
|
||||
// add the following in the future...
|
||||
// makeGliders
|
||||
// makeClouds
|
||||
|
||||
}
|
||||
|
||||
glutInit( &argc, argv );
|
||||
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootnode );
|
||||
|
||||
unsigned int pos = viewer.registerCameraManipulator(new GliderManipulator());
|
||||
|
||||
// Open window so camera manipulator's warp pointer request will succeed
|
||||
viewer.open();
|
||||
|
||||
viewer.selectCameraManipulator(pos);
|
||||
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
150
src/Demos/hangglide/hat.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#pragma warning( disable : 4244 )
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "terrain_data.h"
|
||||
#include "hat.h"
|
||||
|
||||
static int inited = 0;
|
||||
|
||||
static float dbcenter[3];
|
||||
static float dbradius;
|
||||
|
||||
static void getDatabaseCenterRadius( float dbcenter[3], float *dbradius )
|
||||
{
|
||||
int i;
|
||||
double n=0.0;
|
||||
double center[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float cnt;
|
||||
|
||||
cnt = 39 * 38;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
center[0] += (double)vertex[i][0];
|
||||
center[1] += (double)vertex[i][1];
|
||||
center[2] += (double)vertex[i][2];
|
||||
|
||||
n = n + 1.0;
|
||||
}
|
||||
|
||||
center[0] /= n;
|
||||
center[1] /= n;
|
||||
center[2] /= n;
|
||||
|
||||
float r = 0.0;
|
||||
|
||||
// for( i = 0; i < sizeof( vertex ) / (sizeof( float[3] )); i++ )
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
double d = sqrt(
|
||||
(((double)vertex[i][0] - center[0]) * ((double)vertex[i][0] - center[0])) +
|
||||
(((double)vertex[i][1] - center[1]) * ((double)vertex[i][1] - center[1])) +
|
||||
(((double)vertex[i][2] - center[2]) * ((double)vertex[i][2] - center[2])) );
|
||||
|
||||
if( d > (double)r ) r = (float)d;
|
||||
|
||||
}
|
||||
|
||||
*dbradius = r;
|
||||
dbcenter[0] = (float)center[0];
|
||||
dbcenter[1] = (float)center[1];
|
||||
dbcenter[2] = (float)center[2];
|
||||
|
||||
int index = 19 * 39 + 19;
|
||||
dbcenter[0] = vertex[index][0] - 0.15;
|
||||
dbcenter[1] = vertex[index][1];
|
||||
dbcenter[2] = vertex[index][2] + 0.35;
|
||||
}
|
||||
|
||||
|
||||
static void init( void )
|
||||
{
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
inited = 1;
|
||||
}
|
||||
|
||||
|
||||
static void getNormal( float *v1, float *v2, float *v3, float *n )
|
||||
{
|
||||
float V1[4], V2[4];
|
||||
float f;
|
||||
int i;
|
||||
|
||||
/* Two vectors v2->v1 and v2->v3 */
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
V1[i] = v1[i] - v2[i];
|
||||
V2[i] = v3[i] - v2[i];
|
||||
}
|
||||
|
||||
/* Cross product between V1 and V2 */
|
||||
|
||||
n[0] = (V1[1] * V2[2]) - (V1[2] * V2[1]);
|
||||
n[1] = -((V1[0] * V2[2]) - ( V1[2] * V2[0] ));
|
||||
n[2] = (V1[0] * V2[1] ) - (V1[1] * V2[0] );
|
||||
|
||||
/* Normalize */
|
||||
|
||||
f = sqrtf( ( n[0] * n[0] ) + ( n[1] * n[1] ) + ( n[2] * n[2] ) );
|
||||
n[0] /= f;
|
||||
n[1] /= f;
|
||||
n[2] /= f;
|
||||
}
|
||||
|
||||
|
||||
float Hat( float x, float y, float z )
|
||||
{
|
||||
int m, n;
|
||||
int i, j;
|
||||
float tri[3][3];
|
||||
float norm[3];
|
||||
float d, pz;
|
||||
|
||||
if( inited == 0 ) init();
|
||||
|
||||
// m = columns
|
||||
// n = rows
|
||||
m = (sizeof( vertex ) /(sizeof( float[3])))/39;
|
||||
n = 39;
|
||||
|
||||
i = 0;
|
||||
while( i < ((m-1)*39) && x > (vertex[i+n][0] - dbcenter[0]) )
|
||||
i += n;
|
||||
|
||||
j = 0;
|
||||
|
||||
while( j < n-1 && y > (vertex[i+j+1][1] - dbcenter[1]) )
|
||||
j++;
|
||||
|
||||
tri[0][0] = vertex[i+0+j+0][0] - dbcenter[0];
|
||||
tri[0][1] = vertex[i+0+j+0][1] - dbcenter[1];
|
||||
//tri[0][2] = vertex[i+0+j+0][2] - dbcenter[2];
|
||||
tri[0][2] = vertex[i+0+j+0][2];
|
||||
|
||||
tri[1][0] = vertex[i+n+j+0][0] - dbcenter[0];
|
||||
tri[1][1] = vertex[i+n+j+0][1] - dbcenter[1];
|
||||
//tri[1][2] = vertex[i+n+j+0][2] - dbcenter[2];
|
||||
tri[1][2] = vertex[i+n+j+0][2];
|
||||
|
||||
tri[2][0] = vertex[i+0+j+1][0] - dbcenter[0];
|
||||
tri[2][1] = vertex[i+0+j+1][1] - dbcenter[1];
|
||||
//tri[2][2] = vertex[i+0+j+1][2] - dbcenter[2];
|
||||
tri[2][2] = vertex[i+0+j+1][2];
|
||||
|
||||
getNormal( tri[0], tri[1], tri[2], norm );
|
||||
|
||||
d = (tri[0][0] * norm[0]) +
|
||||
(tri[0][1] * norm[1]) +
|
||||
(tri[0][2] * norm[2]);
|
||||
|
||||
d *= -1;
|
||||
pz = (-(norm[0] * x) - (norm[1] * y) - d)/norm[2];
|
||||
|
||||
return z - pz;
|
||||
}
|
||||
4
src/Demos/hangglide/hat.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef __HAT_H
|
||||
#define __HAT_H
|
||||
extern float Hat( float x, float y, float z );
|
||||
#endif
|
||||
108
src/Demos/hangglide/sky.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4305 )
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Node *makeSky( void )
|
||||
{
|
||||
int i, j;
|
||||
float lev[] = { -5, -1.0, 1.0, 15.0, 30.0, 60.0, 90.0 };
|
||||
float cc[][4] =
|
||||
{
|
||||
{ 0.0, 0.0, 0.15 },
|
||||
{ 0.0, 0.0, 0.15 },
|
||||
{ 0.4, 0.4, 0.7 },
|
||||
{ 0.2, 0.2, 0.6 },
|
||||
{ 0.1, 0.1, 0.6 },
|
||||
{ 0.1, 0.1, 0.6 },
|
||||
{ 0.1, 0.1, 0.6 },
|
||||
};
|
||||
float x, y, z;
|
||||
float alpha, theta;
|
||||
float radius = 20.0f;
|
||||
int nlev = sizeof( lev )/sizeof(float);
|
||||
|
||||
Vec3 *coords = new Vec3[19*nlev];
|
||||
Vec4 *colors = new Vec4[19*nlev];
|
||||
Vec2 *tcoords = new Vec2[19*nlev];
|
||||
osg::ushort *idx = new osg::ushort[38* nlev];
|
||||
int *lengths = new int[nlev];
|
||||
|
||||
int ci, ii;
|
||||
ii = ci = 0;
|
||||
|
||||
for( i = 0; i < nlev; i++ )
|
||||
{
|
||||
for( j = 0; j <= 18; j++ )
|
||||
{
|
||||
alpha = lev[i] * M_PI/180.0;
|
||||
theta = (float)(j*20) * M_PI/180.0;
|
||||
|
||||
x = radius * cosf( alpha ) * cosf( theta );
|
||||
y = radius * cosf( alpha ) * -sinf( theta );
|
||||
z = radius * sinf( alpha );
|
||||
|
||||
coords[ci][0] = x;
|
||||
coords[ci][1] = y;
|
||||
coords[ci][2] = z;
|
||||
|
||||
colors[ci][0] = cc[i][0];
|
||||
colors[ci][1] = cc[i][1];
|
||||
colors[ci][2] = cc[i][2];
|
||||
colors[ci][3] = 1.0;
|
||||
|
||||
tcoords[ci][0] = (float)j/18.0;
|
||||
tcoords[ci][0] = (float)i/(float)(nlev-1);
|
||||
|
||||
ci++;
|
||||
|
||||
idx[ii++] = ((i+1)*19+j);
|
||||
idx[ii++] = ((i+0)*19+j);
|
||||
}
|
||||
lengths[i] = 38;
|
||||
}
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
|
||||
gset->setCoords( coords, idx );
|
||||
gset->setTextureCoords( tcoords, idx );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setColors( colors, idx );
|
||||
gset->setColorBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( nlev - 1 );
|
||||
gset->setPrimLengths( lengths );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
tex->setImage(osgDB::readImageFile("white.rgb"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::OFF );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
dstate->setMode( GL_CULL_FACE, StateAttribute::ON );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
|
||||
geode->setName( "Sky" );
|
||||
|
||||
return geode;
|
||||
}
|
||||
192
src/Demos/hangglide/tank.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <osg/GL>
|
||||
#include <osg/Group>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4305 )
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
|
||||
extern void getDatabaseCenterRadius( float dbcenter[3], float *dbradius );
|
||||
|
||||
static float radius = 2.0;
|
||||
static float dbcenter[3], dbradius;
|
||||
|
||||
static void conv( const Vec3& a, const Matrix& mat, Vec3& b )
|
||||
{
|
||||
int i;
|
||||
Vec3 t;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
t[i] = (a[0] * mat._mat[0][i]) +
|
||||
(a[1] * mat._mat[1][i]) +
|
||||
(a[2] * mat._mat[2][i]) +
|
||||
mat._mat[3][i];
|
||||
}
|
||||
b[0] = t[0];
|
||||
b[1] = t[1];
|
||||
b[2] = t[2];
|
||||
}
|
||||
|
||||
|
||||
Node *makeTank( void )
|
||||
{
|
||||
|
||||
Geode *geode1 = new Geode;
|
||||
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
|
||||
ref_ptr<Matrix> mat = new Matrix(
|
||||
0.05, 0, 0, 0,
|
||||
0, 0.05, 0, 0,
|
||||
0, 0, 0.05, 0,
|
||||
1.5999 - 0.3,
|
||||
3.1474,
|
||||
dbcenter[2] + 0.6542 - 0.09,
|
||||
1
|
||||
);
|
||||
|
||||
Vec3 *vc = new Vec3[42];
|
||||
Vec2 *tc = new Vec2[42];
|
||||
int *lens = new int[1];
|
||||
int i, c;
|
||||
|
||||
c = 0;
|
||||
for( i = 0; i <= 360; i += 18 )
|
||||
{
|
||||
float x, y, z;
|
||||
float s, t;
|
||||
float theta = (float)i * M_PI/180.0;
|
||||
|
||||
s = (float)i/90.0;
|
||||
t = 1.0;
|
||||
|
||||
x = radius * cosf( theta );
|
||||
y = radius * sinf( theta );
|
||||
z = 1.0;
|
||||
|
||||
vc[c][0] = x;
|
||||
vc[c][1] = y;
|
||||
vc[c][2] = z;
|
||||
|
||||
tc[c][0] = s;
|
||||
tc[c][1] = t;
|
||||
|
||||
c++;
|
||||
|
||||
t = 0.0;
|
||||
z = 0.0;
|
||||
|
||||
vc[c][0] = x;
|
||||
vc[c][1] = y;
|
||||
vc[c][2] = z;
|
||||
|
||||
tc[c][0] = s;
|
||||
tc[c][1] = t;
|
||||
c++;
|
||||
}
|
||||
*lens = 42;
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
gset->setCoords( vc );
|
||||
|
||||
gset->setTextureCoords( tc );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
tex->setWrap( Texture::WRAP_S, Texture::REPEAT );
|
||||
tex->setWrap( Texture::WRAP_T, Texture::REPEAT );
|
||||
tex->setImage(osgDB::readImageFile("tank.rgb"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geode1->addDrawable( gset );
|
||||
|
||||
lens = new int[1];
|
||||
*lens = 22;
|
||||
|
||||
vc = new Vec3[22];
|
||||
tc = new Vec2[22];
|
||||
|
||||
c = 0;
|
||||
vc[c][0] = 0.0f;
|
||||
vc[c][1] = 0.0f;
|
||||
vc[c][2] = 1.0f;
|
||||
|
||||
tc[c][0] = 0.0f;
|
||||
tc[c][1] = 0.0f;
|
||||
c++;
|
||||
|
||||
for( i = 0; i <= 360; i += 18 )
|
||||
{
|
||||
float x, y, z;
|
||||
float s, t;
|
||||
float theta = (float)i * M_PI/180.0;
|
||||
|
||||
// s = (float)i/360.0;
|
||||
// t = 1.0;
|
||||
s = cosf( theta );
|
||||
t = sinf( theta );
|
||||
|
||||
x = radius * cosf( theta );
|
||||
y = radius * sinf( theta );
|
||||
z = 1.0;
|
||||
|
||||
vc[c][0] = x;
|
||||
vc[c][1] = y;
|
||||
vc[c][2] = z;
|
||||
|
||||
tc[c][0] = s;
|
||||
tc[c][1] = t;
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
|
||||
gset = new GeoSet;
|
||||
gset->setCoords( vc );
|
||||
gset->setTextureCoords( tc );
|
||||
gset->setPrimType(GeoSet::TRIANGLE_FAN);
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
Geode *geode2 = new Geode;
|
||||
geode2->addDrawable( gset );
|
||||
|
||||
|
||||
Group *grp = new Group;
|
||||
grp->addChild( geode1 );
|
||||
grp->addChild( geode2 );
|
||||
|
||||
geode1->setName( "Geode 1" );
|
||||
geode2->setName( "Geode 2" );
|
||||
|
||||
return grp;
|
||||
}
|
||||
136
src/Demos/hangglide/terrain.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
// #include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include "terrain_data.h"
|
||||
|
||||
using namespace osg;
|
||||
|
||||
void getDatabaseCenterRadius( float dbcenter[3], float *dbradius )
|
||||
{
|
||||
int i;
|
||||
double n=0.0;
|
||||
double center[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float cnt;
|
||||
|
||||
cnt = 39 * 38;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
center[0] += (double)vertex[i][0];
|
||||
center[1] += (double)vertex[i][1];
|
||||
center[2] += (double)vertex[i][2];
|
||||
|
||||
n = n + 1.0;
|
||||
}
|
||||
|
||||
center[0] /= n;
|
||||
center[1] /= n;
|
||||
center[2] /= n;
|
||||
|
||||
float r = 0.0;
|
||||
|
||||
// for( i = 0; i < sizeof( vertex ) / (sizeof( float[3] )); i++ )
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
double d = sqrt(
|
||||
(((double)vertex[i][0] - center[0]) * ((double)vertex[i][0] - center[0])) +
|
||||
(((double)vertex[i][1] - center[1]) * ((double)vertex[i][1] - center[1])) +
|
||||
(((double)vertex[i][2] - center[2]) * ((double)vertex[i][2] - center[2])) );
|
||||
|
||||
if( d > (double)r ) r = (float)d;
|
||||
|
||||
}
|
||||
|
||||
*dbradius = r;
|
||||
dbcenter[0] = (float)center[0];
|
||||
dbcenter[1] = (float)center[1];
|
||||
dbcenter[2] = (float)center[2];
|
||||
|
||||
int index = 19 * 39 + 19;
|
||||
dbcenter[0] = vertex[index][0] - 0.15;
|
||||
dbcenter[1] = vertex[index][1];
|
||||
dbcenter[2] = vertex[index][2] + 0.35;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Node *makeTerrain( void )
|
||||
{
|
||||
int m, n;
|
||||
int i, j, c;
|
||||
float dbcenter[3];
|
||||
float dbradius;
|
||||
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
|
||||
m = (sizeof( vertex ) /(sizeof( float[3])))/39;
|
||||
n = 39;
|
||||
|
||||
Vec3 *v = new Vec3[m*n];
|
||||
Vec2 *t = new Vec2[m*n];
|
||||
Vec4 *col = new Vec4[1];
|
||||
osg::ushort *cidx = new osg::ushort;
|
||||
osg::ushort *idx = new osg::ushort[m*n*2];
|
||||
int *lens = new int[m];
|
||||
|
||||
col[0][0] = col[0][1] = col[0][2] = col[0][3] = 1;
|
||||
*cidx = 0;
|
||||
|
||||
for( i = 0; i < m * n; i++ )
|
||||
{
|
||||
v[i][0] = vertex[i][0] - dbcenter[0];
|
||||
v[i][1] = vertex[i][1] - dbcenter[1];
|
||||
v[i][2] = vertex[i][2];
|
||||
|
||||
t[i][0] = texcoord[i][0] + 0.025;
|
||||
t[i][1] = texcoord[i][1];
|
||||
}
|
||||
|
||||
c = 0;
|
||||
for( i = 0; i < m-2; i++ )
|
||||
{
|
||||
for( j = 0; j < n; j++ )
|
||||
{
|
||||
idx[c++] = (i+0)*n+j;
|
||||
idx[c++] = (i+1)*n+j;
|
||||
}
|
||||
lens[i] = 39*2;
|
||||
}
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
|
||||
gset->setCoords( v, idx );
|
||||
gset->setTextureCoords( t, idx );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setColors( col, cidx );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( m-2 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
tex->setImage(osgDB::readImageFile("lz.rgb"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
|
||||
gset->check();
|
||||
|
||||
return geode;
|
||||
}
|
||||
5944
src/Demos/hangglide/terrain_data.h
Normal file
275
src/Demos/hangglide/trees.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <osg/Billboard>
|
||||
#include <osg/Group>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Transparency>
|
||||
#include <osg/AlphaFunc>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include "hat.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4305 )
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
|
||||
#define sqr(x) ((x)*(x))
|
||||
|
||||
extern void getDatabaseCenterRadius( float dbcenter[3], float *dbradius );
|
||||
|
||||
static float dbcenter[3], dbradius;
|
||||
|
||||
static struct _tree
|
||||
{
|
||||
int n;
|
||||
float x, y, z;
|
||||
float w, h;
|
||||
}
|
||||
|
||||
|
||||
trees[] =
|
||||
{
|
||||
{ 0, -0.4769, -0.8972, -0.4011, 0.2000, 0.1200 },
|
||||
{ 1, -0.2543, -0.9117, -0.3873, 0.2000, 0.1200 },
|
||||
{ 2, -0.0424, -0.8538, -0.3728, 0.2000, 0.1200 },
|
||||
{ 3, 0.1590, -0.8827, -0.3594, 0.2000, 0.1200 },
|
||||
{ 4, -0.4981, -1.0853, -0.4016, 0.3500, 0.1200 },
|
||||
{ 5, -0.5405, -1.2590, -0.4050, 0.2000, 0.1200 },
|
||||
{ 6, -0.5723, -1.5339, -0.4152, 0.2000, 0.1200 },
|
||||
{ 7, -0.6252, -1.8667, -0.4280, 0.2000, 0.1200 },
|
||||
{ 8, -0.5617, -2.1851, -0.4309, 0.2000, 0.1200 },
|
||||
{ 9, -0.5087, -2.4166, -0.4215, 0.2000, 0.1200 },
|
||||
{ 10, -0.4345, -2.3443, -0.4214, 0.2000, 0.1200 },
|
||||
{ 11, -3.0308, -1.5484, -0.4876, 0.2000, 0.1200 },
|
||||
{ 12, -3.0202, -1.6497, -0.4963, 0.2000, 0.1200 },
|
||||
{ 13, -2.9355, -1.8378, -0.4969, 0.2000, 0.1200 },
|
||||
{ 14, -0.6040, -2.0259, -0.4300, 0.2000, 0.1200 },
|
||||
{ 15, -0.5442, -1.3442, -0.4080, 0.1000, 0.1200 },
|
||||
{ 16, -0.5639, -1.6885, -0.4201, 0.1000, 0.1200 },
|
||||
{ 17, 0.9246, 3.4835, 0.5898, 0.2500, 0.1000 },
|
||||
{ 18, 0.0787, 3.8687, 0.3329, 0.2500, 0.1200 },
|
||||
{ 19, 0.2885, 3.7130, 0.4047, 0.2500, 0.1200 },
|
||||
{ 20, 0.2033, 3.6228, 0.3704, 0.2500, 0.1200 },
|
||||
{ 21, -0.2098, 3.9015, 0.2327, 0.2500, 0.1200 },
|
||||
{ 22, -0.3738, 3.7376, 0.1722, 0.2500, 0.1200 },
|
||||
{ 23, -0.2557, 3.6064, 0.1989, 0.2500, 0.1200 },
|
||||
{ 24, 0.0590, 3.7294, 0.3210, 0.2500, 0.1200 },
|
||||
{ 25, -0.4721, 3.8851, 0.1525, 0.2500, 0.1200 },
|
||||
{ 26, 0.9639, 3.2048, 0.5868, 0.1200, 0.0800 },
|
||||
{ 27, 0.7082, -1.0409, -0.3221, 0.1000, 0.1000 },
|
||||
{ 28, -0.2426, -2.3442, -0.4150, 0.1000, 0.1380 },
|
||||
{ 29, -0.1770, -2.4179, -0.4095, 0.1000, 0.1580 },
|
||||
{ 30, -0.0852, -2.5327, -0.4056, 0.1000, 0.1130 },
|
||||
{ 31, -0.0131, -2.6065, -0.4031, 0.1000, 0.1150 },
|
||||
{ 32, 0.0787, -2.6638, -0.4012, 0.1000, 0.1510 },
|
||||
{ 33, 0.1049, -2.7622, -0.3964, 0.1000, 0.1270 },
|
||||
{ 34, 0.1770, -2.8687, -0.3953, 0.1000, 0.1100 },
|
||||
{ 35, 0.3213, -2.9507, -0.3974, 0.1000, 0.1190 },
|
||||
{ 36, 0.4065, -3.0163, -0.4014, 0.1000, 0.1120 },
|
||||
{ 37, 0.3738, -3.1802, -0.4025, 0.1000, 0.1860 },
|
||||
{ 38, 0.5508, -3.2048, -0.3966, 0.1000, 0.1490 },
|
||||
{ 39, 0.5836, -3.3031, -0.3900, 0.1000, 0.1670 },
|
||||
{ 40, -0.3082, -2.7212, -0.3933, 0.1000, 0.1840 },
|
||||
{ 41, -0.1967, -2.6474, -0.4017, 0.1000, 0.1600 },
|
||||
{ 42, -0.1180, -2.7458, -0.3980, 0.1000, 0.1250 },
|
||||
{ 43, -0.3344, -2.8359, -0.3964, 0.1000, 0.1430 },
|
||||
{ 44, -0.2492, -2.8933, -0.3838, 0.1000, 0.1890 },
|
||||
{ 45, -0.1246, -3.0491, -0.3768, 0.1000, 0.1830 },
|
||||
{ 46, 0.0000, -3.0818, -0.3696, 0.1000, 0.1370 },
|
||||
{ 47, -0.2295, -3.0409, -0.3706, 0.1000, 0.1660 },
|
||||
{ 48, -1.3245, 2.6638, 0.0733, 0.0500, 0.0500 },
|
||||
{ 49, 2.2425, -1.5491, -0.2821, 0.2300, 0.1200 },
|
||||
{ 50, 0.2164, -2.1311, -0.4000, 0.1000, 0.0690 },
|
||||
{ 51, 0.2885, -2.2130, -0.4000, 0.1000, 0.0790 },
|
||||
{ 52, 0.3606, -2.2786, -0.4000, 0.1000, 0.0565 },
|
||||
{ 53, 0.4328, -2.3442, -0.4000, 0.1000, 0.0575 },
|
||||
{ 54, 0.5246, -2.4343, -0.4086, 0.1000, 0.0755 },
|
||||
{ 55, 0.6360, -2.5245, -0.4079, 0.1000, 0.0635 },
|
||||
{ 56, 0.7541, -2.4261, -0.4007, 0.1000, 0.0550 },
|
||||
{ 57, 0.7934, -2.2786, -0.3944, 0.1000, 0.0595 },
|
||||
{ 58, 1.0295, -2.2868, -0.3837, 0.1000, 0.0560 },
|
||||
{ 59, 0.8459, -2.6474, -0.4051, 0.1000, 0.0930 },
|
||||
{ 60, 1.0426, -2.6884, -0.4001, 0.1000, 0.0745 },
|
||||
{ 61, 1.1475, -2.7458, -0.3883, 0.1000, 0.0835 },
|
||||
{ 62, -0.1967, -1.4180, -0.3988, 0.1000, 0.0920 },
|
||||
{ 63, -0.0131, -1.2704, -0.3856, 0.1000, 0.0690 },
|
||||
{ 64, 0.2098, -1.2049, -0.3664, 0.1000, 0.0790 },
|
||||
{ 65, 0.3410, -1.3196, -0.3652, 0.1000, 0.0565 },
|
||||
{ 66, 0.5705, -1.2704, -0.3467, 0.1000, 0.0575 },
|
||||
{ 67, 0.6360, -1.4344, -0.3532, 0.1000, 0.0755 },
|
||||
{ 68, 0.9246, -1.4180, -0.3329, 0.1000, 0.0635 },
|
||||
{ 69, 1.0623, -1.3360, -0.3183, 0.1000, 0.0550 },
|
||||
{ 70, 1.2393, -1.3934, -0.3103, 0.1000, 0.0595 },
|
||||
{ 71, 1.3639, -1.4753, -0.3079, 0.1000, 0.0560 },
|
||||
{ 72, 1.4819, -1.5983, -0.3210, 0.1000, 0.0930 },
|
||||
{ 73, 1.7835, -1.5819, -0.3065, 0.1000, 0.0745 },
|
||||
{ 74, 1.9343, -2.1065, -0.3307, 0.1000, 0.0835 },
|
||||
{ 75, 2.1245, -2.3196, -0.3314, 0.1000, 0.0920 },
|
||||
{ 76, 2.2556, -2.3032, -0.3230, 0.1000, 0.0800 },
|
||||
{ 77, 2.4196, -2.3688, -0.3165, 0.1000, 0.0625 },
|
||||
{ 78, 1.7835, -2.5327, -0.3543, 0.1000, 0.0715 },
|
||||
{ 79, 1.7180, -2.8933, -0.3742, 0.1000, 0.0945 },
|
||||
{ 80, 1.9343, -3.0409, -0.3727, 0.1000, 0.0915 },
|
||||
{ 81, 2.4524, -3.4671, -0.3900, 0.1000, 0.0685 },
|
||||
{ 82, 2.4786, -2.8851, -0.3538, 0.1000, 0.0830 },
|
||||
{ 83, 2.3343, -2.6228, -0.3420, 0.1000, 0.0830 },
|
||||
{ 84, 2.8130, -2.0737, -0.2706, 0.1000, 0.0890 },
|
||||
{ 85, 2.6360, -1.8278, -0.2661, 0.1000, 0.0975 },
|
||||
{ 86, 2.3958, -1.7130, -0.2774, 0.2000, 0.1555 },
|
||||
{ 87, 2.2688, -1.2868, -0.2646, 0.1000, 0.0835 },
|
||||
{ 88, 2.4196, -1.1147, -0.2486, 0.1000, 0.0770 },
|
||||
{ 89, 2.7802, -2.3933, -0.3017, 0.1000, 0.0655 },
|
||||
{ 90, 3.0163, -2.4179, -0.2905, 0.1000, 0.0725 },
|
||||
{ 91, 2.9310, -2.2540, -0.2798, 0.1000, 0.0910 },
|
||||
{ 92, 2.6622, -2.0983, -0.2823, 0.1000, 0.0680 },
|
||||
{ 93, 2.3147, -1.9753, -0.2973, 0.1000, 0.0620 },
|
||||
{ 94, 2.1573, -1.8770, -0.3013, 0.1000, 0.0525 },
|
||||
{ 95, 2.0196, -1.7868, -0.3044, 0.1000, 0.0970 },
|
||||
{ 96, 2.7802, -3.3031, -0.3900, 0.1000, 0.0510 },
|
||||
{ 97, 2.8589, -3.1720, -0.3900, 0.1000, 0.0755 },
|
||||
{ 98, 3.0163, -2.8114, -0.3383, 0.1000, 0.0835 },
|
||||
{ 99, 3.5081, -2.4179, -0.2558, 0.1000, 0.0770 },
|
||||
{ 100, 3.5277, -2.3196, -0.2366, 0.1000, 0.0765 },
|
||||
{ 101, 3.6654, -2.5819, -0.2566, 0.1000, 0.0805 },
|
||||
{ 102, 3.7179, -2.7622, -0.2706, 0.1000, 0.0980 },
|
||||
{ 103, 3.7769, -2.4671, -0.2339, 0.1000, 0.0640 },
|
||||
{ 104, 3.3441, -2.4671, -0.2693, 0.1000, 0.0940 },
|
||||
{ -1, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
static GeoSet *makeTree( _tree *tree, StateSet *dstate )
|
||||
{
|
||||
float vv[][3] =
|
||||
{
|
||||
{ -tree->w/2.0, 0.0, 0.0 },
|
||||
{ tree->w/2.0, 0.0, 0.0 },
|
||||
{ tree->w/2.0, 0.0, 2 * tree->h },
|
||||
{ -tree->w/2.0, 0.0, 2 * tree->h },
|
||||
};
|
||||
|
||||
Vec3 *v = new Vec3[4];
|
||||
Vec2 *t = new Vec2[4];
|
||||
Vec4 *l = new Vec4[1];
|
||||
|
||||
int i;
|
||||
|
||||
l[0][0] = l[0][1] = l[0][2] = l[0][3] = 1;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
v[i][0] = vv[i][0];
|
||||
v[i][1] = vv[i][1];
|
||||
v[i][2] = vv[i][2];
|
||||
}
|
||||
|
||||
t[0][0] = 0.0; t[0][1] = 0.0;
|
||||
t[1][0] = 1.0; t[1][1] = 0.0;
|
||||
t[2][0] = 1.0; t[2][1] = 1.0;
|
||||
t[3][0] = 0.0; t[3][1] = 1.0;
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
|
||||
gset->setCoords( v );
|
||||
|
||||
gset->setTextureCoords( t );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setColors( l );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::QUADS );
|
||||
gset->setNumPrims( 1 );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
return gset;
|
||||
}
|
||||
|
||||
|
||||
static float ttx, tty;
|
||||
|
||||
static int ct( const void *a, const void *b )
|
||||
{
|
||||
_tree *ta = (_tree *)a;
|
||||
_tree *tb = (_tree *)b;
|
||||
|
||||
float da = sqrtf( sqr(ta->x - ttx) + sqr(ta->y - tty) );
|
||||
float db = sqrtf( sqr(tb->x - ttx) + sqr(tb->y - tty) );
|
||||
|
||||
if( da < db )
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Node *makeTrees( void )
|
||||
{
|
||||
Group *group = new Group;
|
||||
int i;
|
||||
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
struct _tree *t;
|
||||
|
||||
Texture *tex = new Texture;
|
||||
tex->setImage(osgDB::readImageFile("tree0.rgba"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
dstate->setAttributeAndModes( new Transparency, StateAttribute::ON );
|
||||
|
||||
AlphaFunc* alphaFunc = new AlphaFunc;
|
||||
alphaFunc->setFunction(AlphaFunc::GEQUAL,0.05f);
|
||||
dstate->setAttributeAndModes( alphaFunc, StateAttribute::ON );
|
||||
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
|
||||
dstate->setRenderingHint( StateSet::TRANSPARENT_BIN );
|
||||
|
||||
int tt[] = { 15, 30, 45, 58, 72, 75, 93, 96, 105, -1 };
|
||||
int *ttp = tt;
|
||||
|
||||
i = 0;
|
||||
while( i < 105 )
|
||||
{
|
||||
ttx = trees[i].x;
|
||||
tty = trees[i].y;
|
||||
qsort( &trees[i], 105 - i, sizeof( _tree ), ct );
|
||||
|
||||
i += *ttp;
|
||||
ttp++;
|
||||
}
|
||||
|
||||
t = trees;
|
||||
i = 0;
|
||||
ttp = tt;
|
||||
while( *ttp != -1 )
|
||||
{
|
||||
Billboard *bb = new Billboard;
|
||||
//int starti = i;
|
||||
|
||||
for( ; i < (*ttp); i++ )
|
||||
{
|
||||
t->x -= 0.3f;
|
||||
float h = Hat(t->x, t->y, t->z );
|
||||
Vec3 pos( t->x, t->y, t->z-h );
|
||||
GeoSet *gset = makeTree( t, dstate );
|
||||
bb->addDrawable( gset, pos );
|
||||
t++;
|
||||
}
|
||||
group->addChild( bb );
|
||||
ttp++;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
0
src/Demos/osgconv/Makedepend
Normal file
20
src/Demos/osgconv/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
osgconv.cpp
|
||||
|
||||
TARGET = ../../../bin/osgconv
|
||||
|
||||
TARGET_BIN_FILES = osgconv
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
C++FLAGS += -I../../../include
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
119
src/Demos/osgconv/osgconv.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
osg::notify(osg::NOTICE)<<"usage:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" osgconv [options] infile1 [infile2 ...] outfile"<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
osg::notify(osg::NOTICE)<<"options:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -l libraryName - load plugin of name libraryName"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -l osgdb_pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful for loading reader/writers which can load"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" other file formats in addition to its extension."<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -e extensionName - load reader/wrter plugin for file extension"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -e pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful short hand for specifying full library name as"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" done with -l above, as it automatically expands to the"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" full library name appropriate for each platform."<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef std::vector<std::string> FileNameList;
|
||||
FileNameList fileNames;
|
||||
|
||||
for(int i = 1; i < argc; i++ )
|
||||
{
|
||||
|
||||
if (argv[i][0]=='-')
|
||||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osgDB::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
fileNames.push_back(argv[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fileNames.empty())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"No files specfied."<<endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fileNames.size()==1)
|
||||
{
|
||||
osg::Node* root = osgDB::readNodeFile(fileNames.front());
|
||||
if (root)
|
||||
{
|
||||
osgDB::writeNodeFile(*root,"converted.osg");
|
||||
osg::notify(osg::NOTICE)<<"Data written to 'converted.osg'."<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error no data loaded."<<endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fileNameOut = fileNames.back();
|
||||
fileNames.pop_back();
|
||||
|
||||
osg::Group* group = new osg::Group();
|
||||
for(FileNameList::iterator itr=fileNames.begin();
|
||||
itr<fileNames.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Node* child = osgDB::readNodeFile(*itr);
|
||||
if (child)
|
||||
{
|
||||
group->addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
if (group->getNumChildren()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error no data loaded."<<endl;
|
||||
return 1;
|
||||
}
|
||||
else if (group->getNumChildren()==1)
|
||||
{
|
||||
osgDB::writeNodeFile(*(group->getChild(0)),fileNameOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
osgDB::writeNodeFile(*group,fileNameOut);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
src/Demos/osgcube/Makedepend
Normal file
15
src/Demos/osgcube/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
osgcube.cpp
|
||||
|
||||
TARGET = ../../../bin/osgcube
|
||||
|
||||
TARGET_BIN_FILES = osgcube
|
||||
|
||||
LIBS = -losgGLUT -losgDB -losgUtil -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
C++FLAGS += -I../../../include
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
189
src/Demos/osgcube/osgcube.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
// simple animation demo written by Graeme Harkness.
|
||||
// note from Robert to Robert. The animiation techinque
|
||||
// present here using glut timer callbacks is one
|
||||
// approach, other approaches will soon be supported
|
||||
// within the osg itself via an app cullback which
|
||||
// can be attached to nodes themselves. This later
|
||||
// method will be the prefered approach (have a look
|
||||
// at osgreflect's app visitor for a clue.)
|
||||
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Material>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Transform>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Global variables - this is basically the stuff which will be animated
|
||||
// ----------------------------------------------------------------------
|
||||
osg::Transform* myTransform;
|
||||
osg::GeoSet* cube;
|
||||
|
||||
int mytime=0; // in milliseconds
|
||||
unsigned int dt=50; // in milliseconds
|
||||
double omega=0.002; // in inverse milliseconds
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// This is the callback function registered with GLUT to be called
|
||||
// at a future time in the GLUT loop
|
||||
// ----------------------------------------------------------------
|
||||
void timedCB( int delta_t )
|
||||
{
|
||||
|
||||
static float lastdx = 0;
|
||||
static float lastdy = 0;
|
||||
static float lastdz = 0;
|
||||
|
||||
mytime+=dt;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Update the Transform so that the cube will appear to oscillate
|
||||
// ---------------------------------------------------------
|
||||
double dx = 0.5 * cos( (double) omega * (double) mytime );
|
||||
double dy = 0.5 * sin( (double) omega * (double) mytime );
|
||||
double dz = 0.0;
|
||||
myTransform->preTranslate( -lastdx, -lastdy, -lastdz );
|
||||
myTransform->preTranslate( (float) dx, (float) dy, dz );
|
||||
lastdx=dx; lastdy=dy; lastdz=dz;
|
||||
|
||||
// Graeme, commeted out this call as the cube itself remains static.
|
||||
// cube->dirtyDisplayList();
|
||||
|
||||
// -------------------------------------------
|
||||
// If required, reschedule the timed callback
|
||||
// -------------------------------------------
|
||||
if ( delta_t != 0 )
|
||||
{
|
||||
glutTimerFunc( (unsigned int) delta_t, timedCB, delta_t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
osg::Geode* createCube()
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
// -------------------------------------------
|
||||
// Set up a new GeoSet which will be our cube
|
||||
// -------------------------------------------
|
||||
cube = new osg::GeoSet();
|
||||
|
||||
// set up the primitives
|
||||
cube->setPrimType( osg::GeoSet::POLYGON );
|
||||
cube->setNumPrims( 6 ); // the six square faces
|
||||
|
||||
// set up the primitive indices
|
||||
int* cubeLengthList = new int[6];
|
||||
cubeLengthList[0] = 4; // each side of the cube has 4 vertices
|
||||
cubeLengthList[1] = 4;
|
||||
cubeLengthList[2] = 4;
|
||||
cubeLengthList[3] = 4;
|
||||
cubeLengthList[4] = 4;
|
||||
cubeLengthList[5] = 4;
|
||||
|
||||
cube->setPrimLengths( cubeLengthList );
|
||||
|
||||
|
||||
// set up the coordinates.
|
||||
osg::Vec3 *cubeCoords = new osg::Vec3[24];
|
||||
cubeCoords[0].set( -1.0000f, 1.0000f, -1.000f );
|
||||
cubeCoords[1].set( 1.0000f, 1.0000f, -1.0000f );
|
||||
cubeCoords[2].set( 1.0000f, -1.0000f, -1.0000f );
|
||||
cubeCoords[3].set( -1.0000f, -1.0000f, -1.000 );
|
||||
|
||||
cubeCoords[4].set( 1.0000f, 1.0000f, -1.0000f );
|
||||
cubeCoords[5].set( 1.0000f, 1.0000f, 1.0000f );
|
||||
cubeCoords[6].set( 1.0000f, -1.0000f, 1.0000f );
|
||||
cubeCoords[7].set( 1.0000f, -1.0000f, -1.0000f );
|
||||
|
||||
cubeCoords[8].set( 1.0000f, 1.0000f, 1.0000f );
|
||||
cubeCoords[9].set( -1.0000f, 1.0000f, 1.000f );
|
||||
cubeCoords[10].set( -1.0000f, -1.0000f, 1.000f );
|
||||
cubeCoords[11].set( 1.0000f, -1.0000f, 1.0000f );
|
||||
|
||||
cubeCoords[12].set( -1.0000f, 1.0000f, 1.000 );
|
||||
cubeCoords[13].set( -1.0000f, 1.0000f, -1.000 );
|
||||
cubeCoords[14].set( -1.0000f, -1.0000f, -1.000 );
|
||||
cubeCoords[15].set( -1.0000f, -1.0000f, 1.000 );
|
||||
|
||||
cubeCoords[16].set( -1.0000f, 1.0000f, 1.000 );
|
||||
cubeCoords[17].set( 1.0000f, 1.0000f, 1.0000f );
|
||||
cubeCoords[18].set( 1.0000f, 1.0000f, -1.0000f );
|
||||
cubeCoords[19].set( -1.0000f, 1.0000f, -1.000f );
|
||||
|
||||
cubeCoords[20].set( -1.0000f, -1.0000f, 1.000f );
|
||||
cubeCoords[21].set( -1.0000f, -1.0000f, -1.000f );
|
||||
cubeCoords[22].set( 1.0000f, -1.0000f, -1.0000f );
|
||||
cubeCoords[23].set( 1.0000f, -1.0000f, 1.0000f );
|
||||
|
||||
cube->setCoords( cubeCoords );
|
||||
|
||||
|
||||
// set up the normals.
|
||||
osg::Vec3 *cubeNormals = new osg::Vec3[6];
|
||||
cubeNormals[0].set(0.0f,0.0f,-1.0f);
|
||||
cubeNormals[1].set(1.0f,0.0f,0.0f);
|
||||
cubeNormals[2].set(0.0f,0.0f,1.0f);
|
||||
cubeNormals[3].set(-1.0f,0.0f,0.0f);
|
||||
cubeNormals[4].set(0.0f,1.0f,0.0f);
|
||||
cubeNormals[5].set(0.0f,-1.0f,0.0f);
|
||||
cube->setNormals( cubeNormals );
|
||||
cube->setNormalBinding( osg::GeoSet::BIND_PERPRIM );
|
||||
|
||||
// ---------------------------------------
|
||||
// Set up a StateSet to make the cube red
|
||||
// ---------------------------------------
|
||||
osg::StateSet* cubeState = new osg::StateSet();
|
||||
osg::Material* redMaterial = new osg::Material();
|
||||
osg::Vec4 red( 1.0f, 0.0f, 0.0f, 1.0f );
|
||||
redMaterial->setEmission( osg::Material::FRONT_AND_BACK, red );
|
||||
redMaterial->setAmbient( osg::Material::FRONT_AND_BACK, red );
|
||||
redMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, red );
|
||||
redMaterial->setSpecular( osg::Material::FRONT_AND_BACK, red );
|
||||
cubeState->setAttribute( redMaterial );
|
||||
|
||||
cube->setStateSet( cubeState );
|
||||
|
||||
geode->addDrawable( cube );
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
glutInit( &argc, argv );
|
||||
|
||||
|
||||
myTransform = new osg::Transform();
|
||||
myTransform->addChild( createCube() );
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Register a timer callback with GLUT, in the first instance as a test
|
||||
// This will call the function "timedCB(value)" after dt ms
|
||||
// I have decided to use value as the time for the next scheduling
|
||||
// If the last parameter=0 then don't reschedule the timer.
|
||||
// ---------------------------------------------------------------------
|
||||
glutTimerFunc( dt, timedCB, dt );
|
||||
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( myTransform );
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
|
||||
viewer.open();
|
||||
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
src/Demos/osgimpostor/Makedepend
Normal file
21
src/Demos/osgimpostor/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
osgimpostor.cpp
|
||||
|
||||
TARGET = ../../../bin/osgimpostor
|
||||
|
||||
TARGET_BIN_FILES = osgimpostor
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
C++FLAGS += -I../../../include
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
|
||||
26
src/Demos/osgimpostor/README
Normal file
@@ -0,0 +1,26 @@
|
||||
Note: Using sgv with Peformer (for IRIX and Linux users only)
|
||||
=============================================================
|
||||
|
||||
If you find problems with loading .pfb files its likely that its due to undefined
|
||||
symbols. This isn't a problem with the OSG implementation, but alas the only
|
||||
current solution is to directly link you app with the Performer libraries. The
|
||||
Makefile contains two library list. In Makefile you'll see something like :
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
Simple comment in the LIBS line with PFLIBS and comment out the standard LIBS,
|
||||
then :
|
||||
|
||||
make clean
|
||||
make
|
||||
|
||||
Hopefully the Performer distribution will eventually work as a dynamic plugin
|
||||
but until that day we're stuck with this 'hack'...
|
||||
|
||||
|
||||
Robert Osfield,
|
||||
March 20001.
|
||||
198
src/Demos/osgimpostor/osgimpostor.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
#ifdef USE_MEM_CHECK
|
||||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
#include <osg/Impostor>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgUtil/FlightManipulator>
|
||||
#include <osgUtil/DriveManipulator>
|
||||
#include <osgUtil/InsertImpostorsVisitor>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osg/Quat>
|
||||
|
||||
/*
|
||||
* Function to read several files (typically one) as specified on the command
|
||||
* line, and return them in an osg::Node
|
||||
*/
|
||||
osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
{
|
||||
osg::Node *rootnode = new osg::Node;
|
||||
|
||||
int i;
|
||||
|
||||
typedef std::vector<osg::Node*> NodeList;
|
||||
NodeList nodeList;
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
|
||||
if (argv[i][0]=='-')
|
||||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osgDB::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile( argv[i] );
|
||||
|
||||
if( node != (osg::Node *)0L )
|
||||
{
|
||||
if (node->getName().empty()) node->setName( argv[i] );
|
||||
nodeList.push_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nodeList.size()==0)
|
||||
{
|
||||
osg::notify(osg::WARN) << "No data loaded."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (nodeList.size()==1)
|
||||
{
|
||||
rootnode = nodeList.front();
|
||||
}
|
||||
else // size >1
|
||||
{
|
||||
osg::Group* group = new osg::Group();
|
||||
for(NodeList::iterator itr=nodeList.begin();
|
||||
itr!=nodeList.end();
|
||||
++itr)
|
||||
{
|
||||
group->addChild(*itr);
|
||||
}
|
||||
|
||||
rootnode = group;
|
||||
}
|
||||
|
||||
return rootnode;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
#ifdef USE_MEM_CHECK
|
||||
mtrace();
|
||||
#endif
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"usage:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" osgimpostor [options] infile1 [infile2 ...]"<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
osg::notify(osg::NOTICE)<<"options:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -l libraryName - load plugin of name libraryName"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -l osgdb_pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful for loading reader/writers which can load"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" other file formats in addition to its extension."<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -e extensionName - load reader/wrter plugin for file extension"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -e pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful short hand for specifying full library name as"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" done with -l above, as it automatically expands to the"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" full library name appropriate for each platform."<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
osg::Timer timer;
|
||||
osg::Timer_t before_load = timer.tick();
|
||||
|
||||
osg::Node* model = getNodeFromFiles( argc, argv);
|
||||
|
||||
|
||||
// the osgUtil::InsertImpostorsVisitor used lower down to insert impostors
|
||||
// only operators on subclass of Group's, if the model top node is not
|
||||
// a group then it won't be able to insert an impostor. We therefore
|
||||
// manually insert an impostor above the model.
|
||||
if (dynamic_cast<osg::Group*>(model)==0)
|
||||
{
|
||||
const osg::BoundingSphere& bs = model->getBound();
|
||||
if (bs.isValid())
|
||||
{
|
||||
|
||||
osg::Impostor* impostor = new osg::Impostor;
|
||||
|
||||
// standard LOD settings
|
||||
impostor->addChild(model);
|
||||
impostor->setRange(0,0.0f);
|
||||
impostor->setRange(1,1e7f);
|
||||
impostor->setCenter(bs.center());
|
||||
|
||||
// impostor specfic settings.
|
||||
impostor->setImpostorThresholdToBound(5.0f);
|
||||
|
||||
model = impostor;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// we insert an impostor node above the model, so we keep a handle
|
||||
// on the rootnode of the model, the is required since the
|
||||
// InsertImpostorsVisitor can add a new root in automatically and
|
||||
// we would know about it, other than by following the parent path
|
||||
// up from model. This is really what should be done, but I'll pass
|
||||
// on it right now as it requires a getRoots() method to be added to
|
||||
// osg::Node, and we're about to make a release so no new features!
|
||||
osg::Group* rootnode = new osg::Group;
|
||||
rootnode->addChild(model);
|
||||
|
||||
|
||||
// now insert impostors in the model using the InsertImpostorsVisitor.
|
||||
osgUtil::InsertImpostorsVisitor ov;
|
||||
|
||||
// traverse the model and collect all osg::Group's and osg::LOD's.
|
||||
// however, don't traverse the rootnode since we want to keep it as
|
||||
// the start of traversal, otherwise the insertImpostor could insert
|
||||
// and Impostor above the current root, making it nolonger a root!
|
||||
model->accept(ov);
|
||||
|
||||
// insert the Impostors above groups and LOD's
|
||||
ov.insertImpostors();
|
||||
|
||||
|
||||
osg::Timer_t after_load = timer.tick();
|
||||
cout << "Time for load = "<<timer.delta_s(before_load,after_load)<<" seconds"<<endl;
|
||||
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootnode );
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::FlightManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::DriveManipulator);
|
||||
|
||||
viewer.open();
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
src/Demos/osgviews/Makedepend
Normal file
21
src/Demos/osgviews/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
osgviews.cpp
|
||||
|
||||
TARGET = ../../../bin/osgviews
|
||||
|
||||
TARGET_BIN_FILES = osgviews
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
C++FLAGS += -I../../../include
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
|
||||
26
src/Demos/osgviews/README
Normal file
@@ -0,0 +1,26 @@
|
||||
Note: Using sgv with Peformer (for IRIX and Linux users only)
|
||||
=============================================================
|
||||
|
||||
If you find problems with loading .pfb files its likely that its due to undefined
|
||||
symbols. This isn't a problem with the OSG implementation, but alas the only
|
||||
current solution is to directly link you app with the Performer libraries. The
|
||||
Makefile contains two library list. In Makefile you'll see something like :
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgDB -losg -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
Simple comment in the LIBS line with PFLIBS and comment out the standard LIBS,
|
||||
then :
|
||||
|
||||
make clean
|
||||
make
|
||||
|
||||
Hopefully the Performer distribution will eventually work as a dynamic plugin
|
||||
but until that day we're stuck with this 'hack'...
|
||||
|
||||
|
||||
Robert Osfield,
|
||||
March 20001.
|
||||
148
src/Demos/osgviews/osgviews.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifdef USE_MEM_CHECK
|
||||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgUtil/FlightManipulator>
|
||||
#include <osgUtil/DriveManipulator>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osg/Quat>
|
||||
|
||||
/*
|
||||
* Function to read several files (typically one) as specified on the command
|
||||
* line, and return them in an osg::Node
|
||||
*/
|
||||
osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
{
|
||||
osg::Node *rootnode = new osg::Node;
|
||||
|
||||
int i;
|
||||
|
||||
typedef std::vector<osg::Node*> NodeList;
|
||||
NodeList nodeList;
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
|
||||
if (argv[i][0]=='-')
|
||||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osgDB::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile( argv[i] );
|
||||
|
||||
if( node != (osg::Node *)0L )
|
||||
{
|
||||
if (node->getName().empty()) node->setName( argv[i] );
|
||||
nodeList.push_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nodeList.size()==0)
|
||||
{
|
||||
osg::notify(osg::WARN) << "No data loaded."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (nodeList.size()==1)
|
||||
{
|
||||
rootnode = nodeList.front();
|
||||
}
|
||||
else // size >1
|
||||
{
|
||||
osg::Group* group = new osg::Group();
|
||||
for(NodeList::iterator itr=nodeList.begin();
|
||||
itr!=nodeList.end();
|
||||
++itr)
|
||||
{
|
||||
group->addChild(*itr);
|
||||
}
|
||||
|
||||
rootnode = group;
|
||||
}
|
||||
|
||||
return rootnode;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
#ifdef USE_MEM_CHECK
|
||||
mtrace();
|
||||
#endif
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"usage:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" osgviews [options] infile1 [infile2 ...]"<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
osg::notify(osg::NOTICE)<<"options:"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -l libraryName - load plugin of name libraryName"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -l osgdb_pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful for loading reader/writers which can load"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" other file formats in addition to its extension."<<endl;
|
||||
osg::notify(osg::NOTICE)<<" -e extensionName - load reader/wrter plugin for file extension"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" i.e. -e pfb"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" Useful short hand for specifying full library name as"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" done with -l above, as it automatically expands to the"<<endl;
|
||||
osg::notify(osg::NOTICE)<<" full library name appropriate for each platform."<<endl;
|
||||
osg::notify(osg::NOTICE)<<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
osg::Timer timer;
|
||||
osg::Timer_t before_load = timer.tick();
|
||||
|
||||
osg::Node* rootnode = getNodeFromFiles( argc, argv);
|
||||
|
||||
osg::Timer_t after_load = timer.tick();
|
||||
cout << "Time for load = "<<timer.delta_s(before_load,after_load)<<" seconds"<<endl;
|
||||
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootnode,0.0,0.0,0.5,0.5);
|
||||
viewer.addViewport( rootnode,0.5,0.0,0.5,0.5);
|
||||
viewer.addViewport( rootnode,0.0,0.5,1.0,0.5);
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::FlightManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::DriveManipulator);
|
||||
|
||||
viewer.open();
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -8,12 +8,14 @@ TARGET = ../../../bin/sgv
|
||||
|
||||
TARGET_BIN_FILES = sgv
|
||||
|
||||
# LIBS = -losg -lglut -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
# C++FLAGS += -I../../include
|
||||
# LDFLAGS += -L../../lib -L/usr/X11R6/lib
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
LIBS = -losgGLUT -losgUtil -losg -lglut -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
C++FLAGS += -I../../../include
|
||||
LDFLAGS += -L../../../lib -L/usr/X11R6/lib
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
#include "osg/OSG"
|
||||
#include "osg/Node"
|
||||
#include "osg/Registry"
|
||||
#include "osg/Notify"
|
||||
#ifdef USE_MEM_CHECK
|
||||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgUtil/FlightManipulator>
|
||||
#include <osgUtil/DriveManipulator>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include "osgGLUT/Viewer"
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osg/Quat>
|
||||
|
||||
/*
|
||||
* Function to read several files (typically one) as specified on the command
|
||||
@@ -25,33 +36,33 @@ osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osg::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osg::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osg::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
case('l'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
osgDB::Registry::instance()->loadLibrary(argv[i]);
|
||||
}
|
||||
break;
|
||||
case('e'):
|
||||
++i;
|
||||
if (i<argc)
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(argv[i]);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
osg::Node *node = osg::loadNodeFile( argv[i] );
|
||||
osg::Node *node = osgDB::readNodeFile( argv[i] );
|
||||
|
||||
if( node != (osg::Node *)0L )
|
||||
{
|
||||
if (node->getName().empty()) node->setName( argv[i] );
|
||||
nodeList.push_back(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (nodeList.size()==0)
|
||||
@@ -59,12 +70,12 @@ osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
osg::notify(osg::WARN) << "No data loaded."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if (nodeList.size()==1)
|
||||
{
|
||||
rootnode = nodeList.front();
|
||||
}
|
||||
else // size >1
|
||||
else // size >1
|
||||
{
|
||||
osg::Group* group = new osg::Group();
|
||||
for(NodeList::iterator itr=nodeList.begin();
|
||||
@@ -76,7 +87,7 @@ osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
|
||||
rootnode = group;
|
||||
}
|
||||
|
||||
|
||||
return rootnode;
|
||||
}
|
||||
|
||||
@@ -84,6 +95,13 @@ osg::Node* getNodeFromFiles(int argc,char **argv)
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
#ifdef USE_MEM_CHECK
|
||||
mtrace();
|
||||
#endif
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"usage:"<<endl;
|
||||
@@ -104,15 +122,25 @@ int main( int argc, char **argv )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
osg::Node* rootnode = getNodeFromFiles( argc, argv);
|
||||
|
||||
osgGLUT::Viewer viewer;
|
||||
glutInit( &argc, argv );
|
||||
viewer.init( rootnode );
|
||||
viewer.run();
|
||||
osg::Timer timer;
|
||||
osg::Timer_t before_load = timer.tick();
|
||||
|
||||
osg::Node* rootnode = getNodeFromFiles( argc, argv);
|
||||
|
||||
osg::Timer_t after_load = timer.tick();
|
||||
cout << "Time for load = "<<timer.delta_s(before_load,after_load)<<" seconds"<<endl;
|
||||
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootnode );
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::FlightManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::DriveManipulator);
|
||||
|
||||
viewer.open();
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
0
src/Demos/wxsgv/Makedepend
Normal file
27
src/Demos/wxsgv/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
#!smake
|
||||
include ../../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
$(wildcard *.cpp)
|
||||
|
||||
TARGET = ../../../bin/wxsgv
|
||||
|
||||
TARGET_BIN_FILES = wxsgv
|
||||
|
||||
C++FLAGS += -I../../include `wx-config --cflags`
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgWX -losgUtil -losgDB -losg \
|
||||
# `wx-config --libs` -lwx_gtk_gl \
|
||||
# -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgWX -losgUtil -losgDB -losg \
|
||||
`wx-config --libs` -lwx_gtk_gl \
|
||||
-lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
C++FLAGS += -I../../../include -I./icons
|
||||
LDFLAGS += -L../../../lib
|
||||
|
||||
include ../../../Make/makerules
|
||||
|
||||
314
src/Demos/wxsgv/SceneGraphDlg.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
//
|
||||
// Name: SceneGraphDlg.cpp
|
||||
// Author: Ben Discoe, ben@washedashore.com
|
||||
//
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "SceneGraphDlg.cpp"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
#include "wx/treectrl.h"
|
||||
#include <typeinfo>
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/LOD>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Transform>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/ImpostorSprite>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
#include "app.h"
|
||||
DECLARE_APP(wxosgApp)
|
||||
|
||||
//#include <string>
|
||||
|
||||
#include "SceneGraphDlg.h"
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
# include "wxsgv.xpm"
|
||||
# include "icon1.xpm"
|
||||
# include "icon2.xpm"
|
||||
# include "icon3.xpm"
|
||||
# include "icon4.xpm"
|
||||
# include "icon5.xpm"
|
||||
# include "icon6.xpm"
|
||||
# include "icon7.xpm"
|
||||
# include "icon8.xpm"
|
||||
# include "icon9.xpm"
|
||||
# include "icon10.xpm"
|
||||
#endif
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
class MyTreeItemData : public wxTreeItemData
|
||||
{
|
||||
public:
|
||||
MyTreeItemData(Node *pNode)
|
||||
{
|
||||
m_pNode = pNode;
|
||||
}
|
||||
Node *m_pNode;
|
||||
};
|
||||
|
||||
|
||||
// WDR: class implementations
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// SceneGraphDlg
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// WDR: event table for SceneGraphDlg
|
||||
|
||||
BEGIN_EVENT_TABLE(SceneGraphDlg,wxDialog)
|
||||
EVT_INIT_DIALOG (SceneGraphDlg::OnInitDialog)
|
||||
EVT_TREE_SEL_CHANGED( ID_SCENETREE, SceneGraphDlg::OnTreeSelChanged )
|
||||
EVT_BUTTON( ID_ZOOMTO, SceneGraphDlg::OnZoomTo )
|
||||
EVT_BUTTON( ID_REFRESH, SceneGraphDlg::OnRefresh )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
SceneGraphDlg::SceneGraphDlg( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &position, const wxSize& size, long style ) :
|
||||
wxDialog( parent, id, title, position, size, style )
|
||||
{
|
||||
SceneGraphFunc( this, TRUE );
|
||||
|
||||
m_pZoomTo = GetZoomto();
|
||||
m_pTree = GetScenetree();
|
||||
|
||||
m_pZoomTo->Enable(false);
|
||||
|
||||
m_imageListNormal = NULL;
|
||||
CreateImageList(16);
|
||||
}
|
||||
|
||||
SceneGraphDlg::~SceneGraphDlg()
|
||||
{
|
||||
}
|
||||
|
||||
///////////
|
||||
|
||||
void SceneGraphDlg::CreateImageList(int size)
|
||||
{
|
||||
delete m_imageListNormal;
|
||||
|
||||
if ( size == -1 )
|
||||
{
|
||||
m_imageListNormal = NULL;
|
||||
return;
|
||||
}
|
||||
// Make an image list containing small icons
|
||||
m_imageListNormal = new wxImageList(size, size, TRUE);
|
||||
|
||||
// should correspond to TreeCtrlIcon_xxx enum
|
||||
wxIcon icons[10];
|
||||
icons[0] = wxICON(icon1);
|
||||
icons[1] = wxICON(icon2);
|
||||
icons[2] = wxICON(icon3);
|
||||
icons[3] = wxICON(icon4);
|
||||
icons[4] = wxICON(icon5);
|
||||
icons[5] = wxICON(icon6);
|
||||
icons[6] = wxICON(icon7);
|
||||
icons[7] = wxICON(icon8);
|
||||
icons[8] = wxICON(icon9);
|
||||
icons[9] = wxICON(icon10);
|
||||
|
||||
int sizeOrig = icons[0].GetWidth();
|
||||
for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
|
||||
{
|
||||
if ( size == sizeOrig )
|
||||
m_imageListNormal->Add(icons[i]);
|
||||
else
|
||||
m_imageListNormal->Add(wxImage(icons[i]).Rescale(size, size).
|
||||
ConvertToBitmap());
|
||||
}
|
||||
m_pTree->SetImageList(m_imageListNormal);
|
||||
}
|
||||
|
||||
|
||||
void SceneGraphDlg::RefreshTreeContents()
|
||||
{
|
||||
// start with a blank slate
|
||||
m_pTree->DeleteAllItems();
|
||||
|
||||
Node *pRoot = wxGetApp().Root();
|
||||
if (!pRoot)
|
||||
return;
|
||||
|
||||
// Fill in the tree with nodes
|
||||
wxTreeItemId hRootItem = m_pTree->AddRoot("Root");
|
||||
AddNodeItemsRecursively(hRootItem, pRoot, 0);
|
||||
m_pTree->Expand(hRootItem);
|
||||
|
||||
m_pSelectedNode = NULL;
|
||||
}
|
||||
|
||||
|
||||
void SceneGraphDlg::AddNodeItemsRecursively(wxTreeItemId hParentItem,
|
||||
Node *pNode, int depth)
|
||||
{
|
||||
wxString str;
|
||||
int nImage;
|
||||
wxTreeItemId hNewItem;
|
||||
|
||||
if (!pNode) return;
|
||||
|
||||
else if (dynamic_cast<LightSource*>(pNode))
|
||||
{
|
||||
str = "Light";
|
||||
nImage = 4;
|
||||
}
|
||||
else if (dynamic_cast<Geode*>(pNode))
|
||||
{
|
||||
str = "Geode";
|
||||
nImage = 2;
|
||||
}
|
||||
else if (dynamic_cast<LOD*>(pNode))
|
||||
{
|
||||
str = "LOD";
|
||||
nImage = 5;
|
||||
}
|
||||
else if (dynamic_cast<Transform*>(pNode))
|
||||
{
|
||||
str = "XForm";
|
||||
nImage = 9;
|
||||
}
|
||||
else if (dynamic_cast<Group*>(pNode))
|
||||
{
|
||||
// must be just a group for grouping's sake
|
||||
str = "Group";
|
||||
nImage = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// must be something else
|
||||
str = "Other";
|
||||
nImage = 8;
|
||||
}
|
||||
std::string name = pNode->getName();
|
||||
if (!name.empty())
|
||||
{
|
||||
const char *name2 = name.c_str();
|
||||
str += " \"";
|
||||
str += name2;
|
||||
str += "\"";
|
||||
}
|
||||
|
||||
hNewItem = m_pTree->AppendItem(hParentItem, str, nImage, nImage);
|
||||
|
||||
Geode *pGeode = dynamic_cast<Geode*>(pNode);
|
||||
if (pGeode)
|
||||
{
|
||||
int num_mesh = pGeode->getNumDrawables();
|
||||
wxTreeItemId hDItem;
|
||||
|
||||
for (int i = 0; i < num_mesh; i++)
|
||||
{
|
||||
Drawable *pDraw = pGeode->getDrawable(i);
|
||||
GeoSet *pGeoSet = dynamic_cast<GeoSet*>(pDraw);
|
||||
if (pGeoSet)
|
||||
{
|
||||
int iNumPrim = pGeoSet->getNumPrims();
|
||||
|
||||
GeoSet::PrimitiveType pt = pGeoSet->getPrimType();
|
||||
const char *mtype;
|
||||
switch (pt)
|
||||
{
|
||||
case (GeoSet::POINTS) : mtype = "Points"; break;
|
||||
case (GeoSet::LINES) : mtype = "Lines"; break;
|
||||
case (GeoSet::LINE_LOOP) : mtype = "LineLoop"; break;
|
||||
case (GeoSet::LINE_STRIP): mtype = "LineStrip"; break;
|
||||
case (GeoSet::FLAT_LINE_STRIP) : mtype = "FlatLineStrip"; break;
|
||||
case (GeoSet::TRIANGLES) : mtype = "Triangles"; break;
|
||||
case (GeoSet::TRIANGLE_STRIP) : mtype = "TriStrip"; break;
|
||||
case (GeoSet::FLAT_TRIANGLE_STRIP) : mtype = "FlatTriStrip"; break;
|
||||
case (GeoSet::TRIANGLE_FAN) : mtype = "TriFan"; break;
|
||||
case (GeoSet::FLAT_TRIANGLE_FAN) : mtype = "FlatTriFan"; break;
|
||||
case (GeoSet::QUADS) : mtype = "Quads"; break;
|
||||
case (GeoSet::QUAD_STRIP) : mtype = "QuadStrip"; break;
|
||||
case (GeoSet::POLYGON) : mtype = "Polygon"; break;
|
||||
}
|
||||
str.Printf("GeoSet %d, %s, %d prims", i, mtype, iNumPrim);
|
||||
hDItem = m_pTree->AppendItem(hNewItem, str, 6, 6);
|
||||
}
|
||||
ImpostorSprite *pImpostorSprite = dynamic_cast<ImpostorSprite*>(pDraw);
|
||||
if (pImpostorSprite)
|
||||
{
|
||||
str.Printf("ImposterSprite");
|
||||
hDItem = m_pTree->AppendItem(hNewItem, str, 9, 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pTree->SetItemData(hNewItem, new MyTreeItemData(pNode));
|
||||
|
||||
Group *pGroup = dynamic_cast<Group*>(pNode);
|
||||
if (pGroup)
|
||||
{
|
||||
int num_children = pGroup->getNumChildren();
|
||||
if (num_children > 200)
|
||||
{
|
||||
wxTreeItemId hSubItem;
|
||||
str.Format("(%d children)", num_children);
|
||||
hSubItem = m_pTree->AppendItem(hNewItem, str, 8, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < num_children; i++)
|
||||
{
|
||||
Node *pChild = pGroup->getChild(i);
|
||||
if (!pChild) continue;
|
||||
|
||||
AddNodeItemsRecursively(hNewItem, pChild, depth+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// expand a bit so that the tree is initially partially exposed
|
||||
if (depth < 2)
|
||||
m_pTree->Expand(hNewItem);
|
||||
}
|
||||
|
||||
|
||||
// WDR: handler implementations for SceneGraphDlg
|
||||
|
||||
void SceneGraphDlg::OnRefresh( wxCommandEvent &event )
|
||||
{
|
||||
RefreshTreeContents();
|
||||
}
|
||||
|
||||
void SceneGraphDlg::OnZoomTo( wxCommandEvent &event )
|
||||
{
|
||||
if (m_pSelectedNode)
|
||||
wxGetApp().ZoomTo(m_pSelectedNode);
|
||||
}
|
||||
|
||||
void SceneGraphDlg::OnTreeSelChanged( wxTreeEvent &event )
|
||||
{
|
||||
wxTreeItemId item = event.GetItem();
|
||||
MyTreeItemData *data = (MyTreeItemData *)m_pTree->GetItemData(item);
|
||||
|
||||
m_pSelectedNode = NULL;
|
||||
|
||||
if (data && data->m_pNode)
|
||||
{
|
||||
m_pSelectedNode = data->m_pNode;
|
||||
m_pZoomTo->Enable(true);
|
||||
}
|
||||
else
|
||||
m_pZoomTo->Enable(false);
|
||||
}
|
||||
|
||||
void SceneGraphDlg::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
RefreshTreeContents();
|
||||
|
||||
wxWindow::OnInitDialog(event);
|
||||
}
|
||||
|
||||
65
src/Demos/wxsgv/SceneGraphDlg.h
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Name: SceneGraphDlg.h
|
||||
// Author: Ben Discoe, ben@washedashore.com
|
||||
//
|
||||
|
||||
#ifndef __SceneGraphDlg_H__
|
||||
#define __SceneGraphDlg_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "SceneGraphDlg.cpp"
|
||||
#endif
|
||||
|
||||
#include "wx/imaglist.h"
|
||||
#include "wxsgv_wdr.h"
|
||||
|
||||
// WDR: class declarations
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// SceneGraphDlg
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class SceneGraphDlg: public wxDialog
|
||||
{
|
||||
public:
|
||||
// constructors and destructors
|
||||
SceneGraphDlg( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE );
|
||||
~SceneGraphDlg();
|
||||
|
||||
void OnInitDialog(wxInitDialogEvent& event);
|
||||
wxButton *m_pZoomTo;
|
||||
wxCheckBox *m_pEnabled;
|
||||
wxTreeCtrl *m_pTree;
|
||||
|
||||
osg::Node *m_pSelectedNode;
|
||||
|
||||
void CreateImageList(int size = 16);
|
||||
void RefreshTreeContents();
|
||||
void AddNodeItemsRecursively(wxTreeItemId hParentItem,
|
||||
osg::Node *pNode, int depth);
|
||||
|
||||
// WDR: method declarations for SceneGraphDlg
|
||||
wxButton* GetZoomto() { return (wxButton*) FindWindow( ID_ZOOMTO ); }
|
||||
wxTreeCtrl* GetScenetree() { return (wxTreeCtrl*) FindWindow( ID_SCENETREE ); }
|
||||
|
||||
private:
|
||||
// WDR: member variable declarations for SceneGraphDlg
|
||||
wxImageList *m_imageListNormal;
|
||||
|
||||
private:
|
||||
// WDR: handler declarations for SceneGraphDlg
|
||||
void OnRefresh( wxCommandEvent &event );
|
||||
void OnZoomTo( wxCommandEvent &event );
|
||||
void OnTreeSelChanged( wxTreeEvent &event );
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
110
src/Demos/wxsgv/app.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Name: app.cpp
|
||||
// Purpose: The application class for a wxWindows application.
|
||||
// Author: Ben Discoe, ben@washedashore.com
|
||||
//
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <osgUtil/SceneView>
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgWX/WXEventAdapter>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgWX;
|
||||
|
||||
#include "app.h"
|
||||
#include "frame.h"
|
||||
|
||||
IMPLEMENT_APP(wxosgApp)
|
||||
|
||||
wxosgApp::wxosgApp()
|
||||
{
|
||||
m_bInitialized = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the app object
|
||||
//
|
||||
bool wxosgApp::OnInit()
|
||||
{
|
||||
// Create the main frame window
|
||||
wxString title = "wxsgv Demo Viewer";
|
||||
wxosgFrame *frame = new wxosgFrame(NULL, title,
|
||||
wxPoint(50, 50), wxSize(800, 600));
|
||||
|
||||
//
|
||||
// Create the 3d scene
|
||||
//
|
||||
m_pSceneView = new osgUtil::SceneView();
|
||||
m_pSceneView->setDefaults();
|
||||
Camera *pCam = new Camera();
|
||||
m_pSceneView->setCamera(pCam);
|
||||
|
||||
m_pCameraManipulator = new osgUtil::TrackballManipulator();
|
||||
m_pCameraManipulator->setCamera(pCam);
|
||||
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
m_pCameraManipulator->init(*ea, *this);
|
||||
|
||||
m_bInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxosgApp::DoUpdate()
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
m_pSceneView->setViewport(0, 0, m_winx, m_winy);
|
||||
m_pSceneView->cull();
|
||||
m_pSceneView->draw();
|
||||
}
|
||||
|
||||
void wxosgApp::SetWindowSize(int x, int y)
|
||||
{
|
||||
m_winx = x;
|
||||
m_winy = y;
|
||||
}
|
||||
|
||||
void wxosgApp::LoadFile(const char *filename)
|
||||
{
|
||||
Node *node = osgDB::readNodeFile(filename);
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
m_pSceneView->setSceneData(node);
|
||||
m_pCameraManipulator->setNode(node);
|
||||
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
m_pCameraManipulator->home(*ea, *this);
|
||||
}
|
||||
|
||||
osg::Node *wxosgApp::Root()
|
||||
{
|
||||
return m_pSceneView->getSceneData();
|
||||
}
|
||||
|
||||
void wxosgApp::ZoomTo(Node *node)
|
||||
{
|
||||
m_pCameraManipulator->setNode(node);
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
m_pCameraManipulator->home(*ea, *this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
src/Demos/wxsgv/app.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright (c) 2001 Virtual Terrain Project
|
||||
// Free for all uses, see license.txt for details.
|
||||
//
|
||||
|
||||
// forward declaration
|
||||
namespace osgUtil {
|
||||
class SceneView;
|
||||
class CameraManipulator;
|
||||
}
|
||||
|
||||
#include <wx/app.h>
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osgUtil/GUIActionAdapter>
|
||||
|
||||
// Define a new application type
|
||||
class wxosgApp: public wxApp, public osgUtil::GUIActionAdapter
|
||||
{
|
||||
public:
|
||||
wxosgApp();
|
||||
bool OnInit();
|
||||
void DoUpdate();
|
||||
void SetWindowSize(int x, int y);
|
||||
void LoadFile(const char *filename);
|
||||
void ZoomTo(osg::Node *node);
|
||||
|
||||
osgUtil::CameraManipulator *Manip() { return m_pCameraManipulator.get(); }
|
||||
osg::Node *Root();
|
||||
|
||||
virtual void requestRedraw() {}
|
||||
virtual void requestContinuousUpdate(bool needed=true) {}
|
||||
virtual void requestWarpPointer(int x,int y) {}
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osgUtil::SceneView> m_pSceneView;
|
||||
osg::ref_ptr<osgUtil::CameraManipulator> m_pCameraManipulator;
|
||||
int m_winx, m_winy; // Window size
|
||||
bool m_bInitialized;
|
||||
};
|
||||
|
||||
188
src/Demos/wxsgv/canvas.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// Name: canvas.cpp
|
||||
// Purpose: Implements the canvas class for a wxWindows application.
|
||||
// Author: Ben Discoe, ben@washedashore.com
|
||||
//
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <osgWX/WXEventAdapter>
|
||||
#include <osgUtil/CameraManipulator>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgWX;
|
||||
|
||||
#include "canvas.h"
|
||||
#include "frame.h"
|
||||
#include "app.h"
|
||||
|
||||
DECLARE_APP(wxosgApp)
|
||||
|
||||
/*
|
||||
* wxosgGLCanvas implementation
|
||||
*/
|
||||
BEGIN_EVENT_TABLE(wxosgGLCanvas, wxGLCanvas)
|
||||
EVT_CLOSE(wxosgGLCanvas::OnClose)
|
||||
EVT_SIZE(wxosgGLCanvas::OnSize)
|
||||
EVT_PAINT(wxosgGLCanvas::OnPaint)
|
||||
EVT_CHAR(wxosgGLCanvas::OnChar)
|
||||
EVT_MOUSE_EVENTS(wxosgGLCanvas::OnMouseEvent)
|
||||
EVT_ERASE_BACKGROUND(wxosgGLCanvas::OnEraseBackground)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxosgGLCanvas::wxosgGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int* gl_attrib):
|
||||
wxGLCanvas(parent, id, pos, size, style, name, gl_attrib)
|
||||
{
|
||||
parent->Show(TRUE);
|
||||
SetCurrent();
|
||||
|
||||
m_bPainting = false;
|
||||
m_bRunning = true;
|
||||
QueueRefresh(FALSE);
|
||||
|
||||
m_initialTick = m_timer.tick();
|
||||
}
|
||||
|
||||
|
||||
wxosgGLCanvas::~wxosgGLCanvas(void)
|
||||
{
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::QueueRefresh(bool eraseBackground)
|
||||
// A Refresh routine we can call from inside OnPaint.
|
||||
// (queues the events rather than dispatching them immediately).
|
||||
{
|
||||
// With wxGTK, you can't do a Refresh() in OnPaint because it doesn't
|
||||
// queue (post) a Refresh event for later. Rather it dispatches
|
||||
// (processes) the underlying events immediately via ProcessEvent
|
||||
// (read, recursive call). See the wxPostEvent docs and Refresh code
|
||||
// for more details.
|
||||
if ( eraseBackground )
|
||||
{
|
||||
wxEraseEvent eevent( GetId() );
|
||||
eevent.SetEventObject( this );
|
||||
wxPostEvent( GetEventHandler(), eevent );
|
||||
}
|
||||
|
||||
wxPaintEvent event( GetId() );
|
||||
event.SetEventObject( this );
|
||||
wxPostEvent( GetEventHandler(), event );
|
||||
}
|
||||
|
||||
|
||||
void wxosgGLCanvas::OnPaint( wxPaintEvent& event )
|
||||
{
|
||||
// place the dc inside a scope, to delete it before the end of function
|
||||
if (1)
|
||||
{
|
||||
// This is a dummy, to avoid an endless succession of paint messages.
|
||||
// OnPaint handlers must always create a wxPaintDC.
|
||||
wxPaintDC dc(this);
|
||||
#ifdef __WXMSW__
|
||||
if (!GetContext()) return;
|
||||
#endif
|
||||
|
||||
if (m_bPainting || !m_bRunning) return;
|
||||
|
||||
m_bPainting = true;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// update the camera manipulator.
|
||||
if (wxGetApp().Manip())
|
||||
{
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
ea->adaptFrame(clockSeconds());
|
||||
wxGetApp().Manip()->handle(*ea, wxGetApp());
|
||||
}
|
||||
|
||||
// Render the OSG scene
|
||||
wxGetApp().DoUpdate();
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
#ifdef WIN32
|
||||
// Call Refresh again for continuous rendering,
|
||||
if (m_bRunning)
|
||||
Refresh(FALSE);
|
||||
#else
|
||||
// Queue another refresh for continuous rendering.
|
||||
// (Yield first so we don't starve out keyboard & mouse events.)
|
||||
//
|
||||
// FIXME: We may want to use a frame timer instead of immediate-
|
||||
// redraw so we don't eat so much CPU on machines that can
|
||||
// easily handle the frame rate.
|
||||
wxYield();
|
||||
QueueRefresh(FALSE);
|
||||
#endif
|
||||
|
||||
m_bPainting = false;
|
||||
}
|
||||
|
||||
// Must allow some idle processing to occur - or the toolbars will not
|
||||
// update, and the close box will not respond!
|
||||
wxGetApp().ProcessIdle();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
m_bRunning = false;
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
// Presumably this is a wxMSWism.
|
||||
// For wxGTK & wxMotif, all canvas resize events occur before the context
|
||||
// is set. So ignore this context check and grab the window width/height
|
||||
// when we get it so it (and derived values such as aspect ratio and
|
||||
// viewport parms) are computed correctly.
|
||||
#ifdef __WXMSW__
|
||||
if (!GetContext()) return;
|
||||
#endif
|
||||
|
||||
SetCurrent();
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
Reshape(width, height);
|
||||
|
||||
if (wxGetApp().Manip())
|
||||
{
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
ea->adaptResize(clockSeconds(), 0, 0, width, height);
|
||||
wxGetApp().Manip()->handle(*ea, wxGetApp());
|
||||
}
|
||||
|
||||
wxGetApp().SetWindowSize(width, height);
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
ea->adaptKeyboard(clockSeconds(), event.KeyCode(), event.GetX(), event.GetY());
|
||||
wxGetApp().Manip()->handle(*ea, wxGetApp());
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
// turn WX mouse event into a OSG mouse event
|
||||
ref_ptr<WXEventAdapter> ea = new WXEventAdapter;
|
||||
ea->adaptMouse(clockSeconds(), &event);
|
||||
wxGetApp().Manip()->handle(*ea, wxGetApp());
|
||||
}
|
||||
|
||||
void wxosgGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
// Do nothing, to avoid flashing.
|
||||
}
|
||||
|
||||
50
src/Demos/wxsgv/canvas.h
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Name: canvas.h
|
||||
//
|
||||
// Copyright (c) 2001 Virtual Terrain Project
|
||||
// Free for all uses, see license.txt for details.
|
||||
//
|
||||
|
||||
#ifndef CANVASH
|
||||
#define CANVASH
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
#include "wx/glcanvas.h"
|
||||
|
||||
#include <osg/Timer>
|
||||
|
||||
//
|
||||
// A Canvas for the main view area.
|
||||
//
|
||||
class wxosgGLCanvas: public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
wxosgGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "wxosgGLCanvas",
|
||||
int* gl_attrib = NULL);
|
||||
~wxosgGLCanvas(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void QueueRefresh(bool eraseBackground);
|
||||
|
||||
bool m_bPainting;
|
||||
bool m_bRunning;
|
||||
|
||||
// time since initClock() in seconds.
|
||||
float clockSeconds() { return m_timer.delta_s(m_initialTick, m_timer.tick()); }
|
||||
osg::Timer m_timer;
|
||||
osg::Timer_t clockTick() { return m_timer.tick(); }
|
||||
osg::Timer_t m_initialTick;
|
||||
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
111
src/Demos/wxsgv/frame.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// Name: frame.cpp
|
||||
// Purpose: The frame class for a wxWindows application.
|
||||
// Author: Ben Discoe, ben@washedashore.com
|
||||
//
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "app.h"
|
||||
#include "frame.h"
|
||||
#include "canvas.h"
|
||||
|
||||
// IDs for the menu commands
|
||||
enum
|
||||
{
|
||||
ID_FILE_OPEN,
|
||||
ID_SCENE_BROWSE
|
||||
};
|
||||
|
||||
DECLARE_APP(wxosgApp)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxosgFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, wxosgFrame::OnExit)
|
||||
EVT_MENU(ID_FILE_OPEN, wxosgFrame::OnOpen)
|
||||
EVT_MENU(ID_SCENE_BROWSE, wxosgFrame::OnSceneBrowse)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// My frame constructor
|
||||
wxosgFrame::wxosgFrame(wxFrame *parent, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxFrame(parent, -1, title, pos, size, style)
|
||||
{
|
||||
// Make a wxosgGLCanvas
|
||||
// FIXME: Can remove this special case once wxMotif 2.3 is released
|
||||
#ifdef __WXMOTIF__
|
||||
int gl_attrib[20] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, None };
|
||||
#else
|
||||
int *gl_attrib = NULL;
|
||||
#endif
|
||||
|
||||
m_canvas = new wxosgGLCanvas(this, -1, wxPoint(0, 0), wxSize(-1, -1), 0,
|
||||
"wxosgGLCanvas", gl_attrib);
|
||||
|
||||
// File (project) menu
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
fileMenu->Append(ID_FILE_OPEN, "&Open\tCtrl+O", "Open OSG File");
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Append(wxID_EXIT, "&Exit\tEsc", "Exit Viewer");
|
||||
|
||||
// Scene menu
|
||||
wxMenu *sceneMenu = new wxMenu;
|
||||
sceneMenu->Append(ID_SCENE_BROWSE, "&Browse Scene Graph\tCtrl+G", "Browse Scene Graph");
|
||||
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(fileMenu, "&Project");
|
||||
menuBar->Append(sceneMenu, "&Scene");
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
// Show the frame
|
||||
Show(TRUE);
|
||||
|
||||
#if 1
|
||||
m_pSceneGraphDlg = new SceneGraphDlg(this, -1, "Scene Graph",
|
||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||
m_pSceneGraphDlg->SetSize(250, 350);
|
||||
#endif
|
||||
|
||||
m_canvas->SetCurrent();
|
||||
}
|
||||
|
||||
wxosgFrame::~wxosgFrame()
|
||||
{
|
||||
delete m_canvas;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Handle menu commands
|
||||
//
|
||||
|
||||
void wxosgFrame::OnExit(wxCommandEvent& event)
|
||||
{
|
||||
m_canvas->m_bRunning = false;
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void wxosgFrame::OnOpen(wxCommandEvent& event)
|
||||
{
|
||||
wxFileDialog loadFile(NULL, "Load Project", "", "",
|
||||
"OSG Files (*.osg)|*.osg|", wxOPEN);
|
||||
if (loadFile.ShowModal() == wxID_OK)
|
||||
wxGetApp().LoadFile(loadFile.GetPath());
|
||||
}
|
||||
|
||||
void wxosgFrame::OnSceneBrowse(wxCommandEvent& event)
|
||||
{
|
||||
m_pSceneGraphDlg->Show(TRUE);
|
||||
}
|
||||
|
||||
35
src/Demos/wxsgv/frame.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Name: frame.h
|
||||
//
|
||||
// Copyright (c) 2001 Virtual Terrain Project
|
||||
// Free for all uses, see license.txt for details.
|
||||
//
|
||||
|
||||
#ifndef FRAMEH
|
||||
#define FRAMEH
|
||||
|
||||
#include "SceneGraphDlg.h"
|
||||
|
||||
class wxosgFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
wxosgFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
|
||||
~wxosgFrame();
|
||||
|
||||
// command handlers
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnOpen(wxCommandEvent& event);
|
||||
void OnSceneBrowse(wxCommandEvent& event);
|
||||
|
||||
public:
|
||||
class wxosgGLCanvas *m_canvas;
|
||||
SceneGraphDlg *m_pSceneGraphDlg;
|
||||
|
||||
protected:
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
BIN
src/Demos/wxsgv/icons/camera.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/engine.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/geom.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/group.ico
Normal file
|
After Width: | Height: | Size: 318 B |
29
src/Demos/wxsgv/icons/icon1.xpm
Normal file
@@ -0,0 +1,29 @@
|
||||
/* XPM */
|
||||
static char *icon1_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 6 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #C0C0C0",
|
||||
"b c #FF0000",
|
||||
"c c #FFFFFF",
|
||||
"d c #FFFF00",
|
||||
"e c #808000",
|
||||
/* pixels */
|
||||
"cccccccccccccccc",
|
||||
"cccccccccceddecc",
|
||||
"ccccccccceddddec",
|
||||
"ccbbbcccceddddec",
|
||||
"cc```cccceddddec",
|
||||
"a`````````edde`a",
|
||||
"``````accca`````",
|
||||
"``aaa`ccccc`````",
|
||||
"`````ccccccc````",
|
||||
"``````ccccc`````",
|
||||
"``````accca`````",
|
||||
"a``````````````a",
|
||||
"ca````````````ac",
|
||||
"cccccccccccccccc",
|
||||
"cccccccccccccccc",
|
||||
"cccccccccccccccc"
|
||||
};
|
||||
28
src/Demos/wxsgv/icons/icon10.xpm
Normal file
@@ -0,0 +1,28 @@
|
||||
/* XPM */
|
||||
static char *icon10_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 5 1",
|
||||
/* colors */
|
||||
"` c #00FF00",
|
||||
"a c #FF0000",
|
||||
"b c #FFFFFF",
|
||||
"c c #808000",
|
||||
"d c #0000FF",
|
||||
/* pixels */
|
||||
"bbbbbbbbbbbbbbbb",
|
||||
"bbbbbbbbbbbbbbbb",
|
||||
"bbb``bbbbbbbbbbb",
|
||||
"bb````bbbbdddbbb",
|
||||
"bbb``bbbbbdddbbb",
|
||||
"bbb``bbbbddddbbb",
|
||||
"bbb``bbbdddbbbbb",
|
||||
"bbb``bbdddbbbbbb",
|
||||
"bbb``bdddbbbbbbb",
|
||||
"bbb``dddbbbbbbbb",
|
||||
"bbb``ddbbbbbabbb",
|
||||
"bbb`caaaaaaaaabb",
|
||||
"bbbcaaaaaaaaaabb",
|
||||
"bbbbbbbbbbbbabbb",
|
||||
"bbbbbbbbbbbbbbbb",
|
||||
"bbbbbbbbbbbbbbbb"
|
||||
};
|
||||
27
src/Demos/wxsgv/icons/icon2.xpm
Normal file
@@ -0,0 +1,27 @@
|
||||
/* XPM */
|
||||
static char *icon2_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 4 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #C0C0C0",
|
||||
"b c #808080",
|
||||
"c c #FFFFFF",
|
||||
/* pixels */
|
||||
"cccccccccccccccc",
|
||||
"ccccb`bccb`bcccc",
|
||||
"cccca``cc``acccc",
|
||||
"ccccc``bb``ccccc",
|
||||
"ca`ccb````bcc`ac",
|
||||
"c```b``````b```c",
|
||||
"ca`````bb`````ac",
|
||||
"cccb``bccb``bccc",
|
||||
"cccb``bccb``bccc",
|
||||
"ca`````bb`````ac",
|
||||
"c```b``````b```c",
|
||||
"ca`ccb````bcc`ac",
|
||||
"ccccc``bb``ccccc",
|
||||
"cccca``cc``acccc",
|
||||
"ccccb`bccb`bcccc",
|
||||
"cccccccccccccccc"
|
||||
};
|
||||
30
src/Demos/wxsgv/icons/icon3.xpm
Normal file
@@ -0,0 +1,30 @@
|
||||
/* XPM */
|
||||
static char *icon3_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 7 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #00FF00",
|
||||
"b c #C0C0C0",
|
||||
"c c #000080",
|
||||
"d c #FFFFFF",
|
||||
"e c #008000",
|
||||
"f c #0000FF",
|
||||
/* pixels */
|
||||
"ddddddd`dddddddd",
|
||||
"dddddd```ddddddd",
|
||||
"ddddd`a``bdddddd",
|
||||
"dddd`aa`f`dddddd",
|
||||
"ddd`aaa`ff`ddddd",
|
||||
"dd`aaaa`fff`dddd",
|
||||
"d`aaaaacfff`bddd",
|
||||
"`aaaaaecffff`ddd",
|
||||
"b`aaaaecfffff`dd",
|
||||
"d`aaaa`fffffff`d",
|
||||
"dd`aaa`fffffff`b",
|
||||
"ddd`aa`fffffff``",
|
||||
"dddb`a`fff````bd",
|
||||
"dddd`a````bddddd",
|
||||
"ddddd``bdddddddd",
|
||||
"dddddddddddddddd"
|
||||
};
|
||||
27
src/Demos/wxsgv/icons/icon4.xpm
Normal file
@@ -0,0 +1,27 @@
|
||||
/* XPM */
|
||||
static char *icon4_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 4 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #FFFFFF",
|
||||
"b c #FFFF00",
|
||||
"c c #808000",
|
||||
/* pixels */
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaac````caaaaa",
|
||||
"aaac`bbbbbb`caaa",
|
||||
"aac`bbbbbbbb`caa",
|
||||
"aa`bbbc``cbbb`aa",
|
||||
"accbb`caac`bbcca",
|
||||
"a`bbccaaaaccbbca",
|
||||
"a`bb`aaaaaa`bb`a",
|
||||
"a`bb`aaaaaa`bb`a",
|
||||
"a`bbccaaaaccbbca",
|
||||
"accbb`caac`bbcca",
|
||||
"aa`bbbc``cbbb`aa",
|
||||
"aaa`bbbbbbbb`aaa",
|
||||
"aaaa`bbbbbb`aaaa",
|
||||
"aaaaac````caaaaa",
|
||||
"aaaaaaaaaaaaaaaa"
|
||||
};
|
||||
28
src/Demos/wxsgv/icons/icon5.xpm
Normal file
@@ -0,0 +1,28 @@
|
||||
/* XPM */
|
||||
static char *icon5_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 5 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #C0C0C0",
|
||||
"b c #FFFFFF",
|
||||
"c c #FFFF00",
|
||||
"d c #808000",
|
||||
/* pixels */
|
||||
"bbbbbbbbbbbbbbbb",
|
||||
"bbbbdbbbbbbbdbbb",
|
||||
"dbbbbd````bdbbbb",
|
||||
"bdbbb`bbcb`bbbbb",
|
||||
"bbdd`bbcccb`bbbb",
|
||||
"bbbb`bcbcbc`dddd",
|
||||
"bbbb`cccbcb`bbbb",
|
||||
"bbdd`ccccbc`dbbb",
|
||||
"ddbb`bccccc`bddb",
|
||||
"bbbbb`bccb`bbbbd",
|
||||
"bbbbdb````bbdbbb",
|
||||
"bbbdbb````bbbdbb",
|
||||
"bbbdbb````bbbdbb",
|
||||
"bbdbbb````bbbbdb",
|
||||
"bbbbbba``abbbbbb",
|
||||
"bbbbbbbbbbbbbbbb"
|
||||
};
|
||||
29
src/Demos/wxsgv/icons/icon6.xpm
Normal file
@@ -0,0 +1,29 @@
|
||||
/* XPM */
|
||||
static char *icon6_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 6 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #C0C0C0",
|
||||
"b c #808080",
|
||||
"c c #FFFFFF",
|
||||
"d c #FFFF00",
|
||||
"e c #808000",
|
||||
/* pixels */
|
||||
"cccccccccccccccc",
|
||||
"cabbbbbbbbaccccc",
|
||||
"cb````````bccccc",
|
||||
"cb`dddddd`bccccc",
|
||||
"cb`dddddd`bbaccc",
|
||||
"cb`dddddd```bacc",
|
||||
"cb`dddddd`dd`bcc",
|
||||
"cb`dddddd`dd`bac",
|
||||
"cb`dddddd`ddd`bc",
|
||||
"cb````````ddd`bc",
|
||||
"cabbb`ddddddebac",
|
||||
"cccab`dddddd`bcc",
|
||||
"ccccab``dde`bacc",
|
||||
"cccccabb``bbaccc",
|
||||
"cccccccabbaccccc",
|
||||
"cccccccccccccccc"
|
||||
};
|
||||
29
src/Demos/wxsgv/icons/icon7.xpm
Normal file
@@ -0,0 +1,29 @@
|
||||
/* XPM */
|
||||
static char *icon7_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 6 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #00FF00",
|
||||
"b c #C0C0C0",
|
||||
"c c #808080",
|
||||
"d c #FFFFFF",
|
||||
"e c #008000",
|
||||
/* pixels */
|
||||
"dddddddddddddddd",
|
||||
"dddddddddddddddd",
|
||||
"ddddddd`dddddddd",
|
||||
"ddddddbe`ddddddd",
|
||||
"dddddd`aebdddddd",
|
||||
"dddddbeaa`dddddd",
|
||||
"ddddd`aaaebddddd",
|
||||
"ddddbeaaaa`ddddd",
|
||||
"dddd`aaaaaaedddd",
|
||||
"ddddeaaaaaa`dddd",
|
||||
"dddeaaaaaaaa`ddd",
|
||||
"ddd`aaaaaaaaebdd",
|
||||
"ddbeaaaaaaaaa`dd",
|
||||
"dd`aaaaaaaaaaacd",
|
||||
"dd`````````````d",
|
||||
"dddddddddddddddd"
|
||||
};
|
||||
26
src/Demos/wxsgv/icons/icon8.xpm
Normal file
@@ -0,0 +1,26 @@
|
||||
/* XPM */
|
||||
static char *icon8_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 3 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #FFFFFF",
|
||||
"b c #0000FF",
|
||||
/* pixels */
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaaaaa`aaaaaaa",
|
||||
"aaaaaaaa``aaaaaa",
|
||||
"aaaaaaaa`b`aaaaa",
|
||||
"aaaaaaaa`bb`aaaa",
|
||||
"aaaaaaaa`bbb`aaa",
|
||||
"a````````bbbb`aa",
|
||||
"a`bbbbbbbbbbbb`a",
|
||||
"a`bbbbbbbbbbbb`a",
|
||||
"a````````bbbb`aa",
|
||||
"aaaaaaaa`bbb`aaa",
|
||||
"aaaaaaaa`bb`aaaa",
|
||||
"aaaaaaaa`b`aaaaa",
|
||||
"aaaaaaaa``aaaaaa",
|
||||
"aaaaaaaa`aaaaaaa",
|
||||
"aaaaaaaaaaaaaaaa"
|
||||
};
|
||||
28
src/Demos/wxsgv/icons/icon9.xpm
Normal file
@@ -0,0 +1,28 @@
|
||||
/* XPM */
|
||||
static char *icon9_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 5 1",
|
||||
/* colors */
|
||||
"` c #000000",
|
||||
"a c #C0C0C0",
|
||||
"b c #808080",
|
||||
"c c #000080",
|
||||
"d c #FFFFFF",
|
||||
/* pixels */
|
||||
"dddddddddddddddd",
|
||||
"dddddacccccadddd",
|
||||
"ddddacccccccaddd",
|
||||
"dddacccbdacccddd",
|
||||
"dddacccddacccddd",
|
||||
"dddabcbddacccddd",
|
||||
"ddddddddacccaddd",
|
||||
"dddddddacccaaddd",
|
||||
"ddddddaacccadddd",
|
||||
"ddddddacccaddddd",
|
||||
"ddddddabcbaddddd",
|
||||
"dddddddddddddddd",
|
||||
"dddddddb`bdddddd",
|
||||
"ddddddacccaddddd",
|
||||
"dddddddbcbdddddd",
|
||||
"dddddddddddddddd"
|
||||
};
|
||||
BIN
src/Demos/wxsgv/icons/light.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/lod.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/mesh.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/top.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/unknown.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
src/Demos/wxsgv/icons/wxsgv.ico
Normal file
|
After Width: | Height: | Size: 766 B |
48
src/Demos/wxsgv/icons/wxsgv.xpm
Normal file
@@ -0,0 +1,48 @@
|
||||
/* XPM */
|
||||
static char *wxsgv[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 32 32 9 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #000080",
|
||||
"a c #0000ff",
|
||||
"b c #008000",
|
||||
"c c #00ff00",
|
||||
"d c #808000",
|
||||
"e c #808080",
|
||||
"f c #ffff00",
|
||||
"g c #ffffff",
|
||||
/* pixels */
|
||||
"gggggggggggggggggggggggggggggggg",
|
||||
"ggggd....dgggggggggggggggggggggg",
|
||||
"ggd.ffffffddgggggggggggggggggggg",
|
||||
"gd.ffffffffddggggggggggggggggggg",
|
||||
"g.fffd..dfffdggggggggggggggggggg",
|
||||
"ddffddggdddfddgggggggggggggggggg",
|
||||
".ffddggggddffdgggggggggggggggggg",
|
||||
".ff.gggggg.dfdgggggggggggggggggg",
|
||||
".ff.gggggg.dfdgggggggggggggggggg",
|
||||
".ffddgggg.ddfdgggggggggggggggggg",
|
||||
"ddffddgg..dffdgggggggggggggggggg",
|
||||
"g.ffdd..ddffdggggggggggggggggggg",
|
||||
"ggdfffdddffdgggggggggggggggggggg",
|
||||
"gggdffffffdggggggggggggggggggggg",
|
||||
"ggggddddddgggggggggggggggggggggg",
|
||||
"gggggggggggggggggggggggggggggggg",
|
||||
"gggggggeggggggggggggggg.gggggggg",
|
||||
"gggggggggggggggggggggg...ggggggg",
|
||||
"gggggggeggggggggggggg.b..egggggg",
|
||||
"gggggggggggggggggggg.cc.##gggggg",
|
||||
"gggeeeeeeeeeggggggg.ccc.#a#ggggg",
|
||||
"gggegggggggegggggg.cccc.#aa#gggg",
|
||||
"gggeggg.gggeggggg.ccccc#aaa#eggg",
|
||||
"gggeggg.gggegggg.bccccb#aaaa#ggg",
|
||||
"gggeg.....gegegeebccccb#aaaaa#gg",
|
||||
"gggeggg.gggeggggg.ccccb#aaaaaa#g",
|
||||
"gggeggg.gggeggggggbccc.aaaaaaa#e",
|
||||
"gggegggggggegggggggbcc.aaaaaaa#.",
|
||||
"gggeeeeeeeeegggggggebc.aaa#####g",
|
||||
"gggggggggggggggggggg.c.###eggggg",
|
||||
"gggggggggggggggggggggb.egggggggg",
|
||||
"gggggggggggggggggggggggggggggggg"
|
||||
};
|
||||
BIN
src/Demos/wxsgv/icons/xform.ico
Normal file
|
After Width: | Height: | Size: 318 B |
14
src/Demos/wxsgv/wxsgv.rc
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
application ICON "wxsgv.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
||||
icon1 ICON "icons/camera.ico"
|
||||
icon2 ICON "icons/engine.ico"
|
||||
icon3 ICON "icons/geom.ico"
|
||||
icon4 ICON "icons/group.ico"
|
||||
icon5 ICON "icons/light.ico"
|
||||
icon6 ICON "icons/lod.ico"
|
||||
icon7 ICON "icons/mesh.ico"
|
||||
icon8 ICON "icons/top.ico"
|
||||
icon9 ICON "icons/unknown.ico"
|
||||
icon10 ICON "icons/xform.ico"
|
||||
BIN
src/Demos/wxsgv/wxsgv.wdr
Normal file
125
src/Demos/wxsgv/wxsgv_wdr.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Source code generated by wxDesigner from file: wxsgv.wdr
|
||||
// Do not modify this file, all changes will be lost!
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "wxsgv_wdr.cpp"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// Include private header
|
||||
#include "wxsgv_wdr.h"
|
||||
|
||||
|
||||
// Implement window functions
|
||||
|
||||
void SceneGraphFunc( wxPanel *parent, bool call_fit )
|
||||
{
|
||||
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxTreeCtrl *item1 = new wxTreeCtrl( parent, ID_SCENETREE, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxSUNKEN_BORDER );
|
||||
item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
wxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxButton *item3 = new wxButton( parent, ID_ZOOMTO, "Zoom To", wxDefaultPosition, wxSize(60,-1), 0 );
|
||||
item2->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
wxButton *item4 = new wxButton( parent, ID_REFRESH, "Refresh", wxDefaultPosition, wxSize(55,-1), 0 );
|
||||
item2->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
item0->Add( item2, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
parent->SetAutoLayout( TRUE );
|
||||
parent->SetSizer( item0 );
|
||||
if (call_fit)
|
||||
{
|
||||
item0->Fit( parent );
|
||||
item0->SetSizeHints( parent );
|
||||
}
|
||||
}
|
||||
|
||||
void CameraDialogFunc( wxPanel *parent, bool call_fit )
|
||||
{
|
||||
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, "Horizontal FOV (degrees)", wxDefaultPosition, wxDefaultSize, 0 );
|
||||
item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
wxTextCtrl *item3 = new wxTextCtrl( parent, ID_FOV, "", wxDefaultPosition, wxSize(60,-1), 0 );
|
||||
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
wxSlider *item4 = new wxSlider( parent, ID_FOVSLIDER, 0, 0, 100, wxDefaultPosition, wxSize(100,-1), 0 );
|
||||
item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
|
||||
|
||||
wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticText *item6 = new wxStaticText( parent, ID_TEXT, "Near Clipping Plane (meters):", wxDefaultPosition, wxDefaultSize, 0 );
|
||||
item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
wxTextCtrl *item7 = new wxTextCtrl( parent, ID_NEAR, "", wxDefaultPosition, wxSize(60,-1), 0 );
|
||||
item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
wxSlider *item8 = new wxSlider( parent, ID_NEARSLIDER, 0, 0, 100, wxDefaultPosition, wxSize(100,-1), 0 );
|
||||
item5->Add( item8, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
item0->Add( item5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
|
||||
|
||||
wxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticText *item10 = new wxStaticText( parent, ID_TEXT, "Far Clipping Plane (meters):", wxDefaultPosition, wxDefaultSize, 0 );
|
||||
item9->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
wxTextCtrl *item11 = new wxTextCtrl( parent, ID_FAR, "", wxDefaultPosition, wxSize(60,-1), 0 );
|
||||
item9->Add( item11, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
wxSlider *item12 = new wxSlider( parent, ID_FARSLIDER, 0, 0, 100, wxDefaultPosition, wxSize(100,-1), 0 );
|
||||
item9->Add( item12, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
item0->Add( item9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
|
||||
|
||||
wxStaticLine *item13 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
|
||||
item0->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
wxSizer *item14 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticText *item15 = new wxStaticText( parent, ID_TEXT, "Navigation Speed (m/frame):", wxDefaultPosition, wxDefaultSize, 0 );
|
||||
item14->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
wxTextCtrl *item16 = new wxTextCtrl( parent, ID_SPEED, "", wxDefaultPosition, wxSize(60,-1), 0 );
|
||||
item14->Add( item16, 0, wxALIGN_CENTRE|wxALL, 0 );
|
||||
|
||||
wxSlider *item17 = new wxSlider( parent, ID_SPEEDSLIDER, 0, 0, 100, wxDefaultPosition, wxSize(100,-1), 0 );
|
||||
item14->Add( item17, 0, wxALIGN_CENTRE, 0 );
|
||||
|
||||
item0->Add( item14, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
|
||||
|
||||
parent->SetAutoLayout( TRUE );
|
||||
parent->SetSizer( item0 );
|
||||
if (call_fit)
|
||||
{
|
||||
item0->Fit( parent );
|
||||
item0->SetSizeHints( parent );
|
||||
}
|
||||
}
|
||||
|
||||
// Implement bitmap functions
|
||||
|
||||
wxBitmap MyBitmapsFunc( size_t index )
|
||||
{
|
||||
return wxNullBitmap;
|
||||
}
|
||||
|
||||
|
||||
// End of generated file
|
||||
53
src/Demos/wxsgv/wxsgv_wdr.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Header generated by wxDesigner from file: wxsgv.wdr
|
||||
// Do not modify this file, all changes will be lost!
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WDR_wxsgv_H__
|
||||
#define __WDR_wxsgv_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "wxsgv_wdr.cpp"
|
||||
#endif
|
||||
|
||||
// Include wxWindows' headers
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/image.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/spinbutt.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/splitter.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
// Declare window functions
|
||||
|
||||
#define ID_SCENETREE 10000
|
||||
#define ID_ZOOMTO 10001
|
||||
#define ID_REFRESH 10002
|
||||
void SceneGraphFunc( wxPanel *parent, bool call_fit = TRUE );
|
||||
|
||||
#define ID_TEXT 10003
|
||||
#define ID_FOV 10004
|
||||
#define ID_FOVSLIDER 10005
|
||||
#define ID_NEAR 10006
|
||||
#define ID_NEARSLIDER 10007
|
||||
#define ID_FAR 10008
|
||||
#define ID_FARSLIDER 10009
|
||||
#define ID_LINE 10010
|
||||
#define ID_SPEED 10011
|
||||
#define ID_SPEEDSLIDER 10012
|
||||
void CameraDialogFunc( wxPanel *parent, bool call_fit = TRUE );
|
||||
|
||||
// Declare bitmap functions
|
||||
|
||||
wxBitmap MyBitmapsFunc( size_t index );
|
||||
|
||||
#endif
|
||||
|
||||
// End of generated file
|
||||