2004-11-30 02:59:36 +08:00
|
|
|
#ifdef WIN32
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Disable unavoidable warning messages:
|
|
|
|
|
|
|
|
// 4103: used #pragma pack to change alignment
|
|
|
|
// 4114: same type qualifier used more than once
|
|
|
|
// 4201: nonstandard extension used : nameless struct/union
|
|
|
|
// 4237: "keyword" reserved for future use
|
|
|
|
// 4251: class needs to have dll-interface to export class
|
|
|
|
// 4275: non DLL-interface class used as base for DLL-interface class
|
|
|
|
// 4290: C++ Exception Specification ignored
|
|
|
|
// 4503: decorated name length exceeded, name was truncated
|
|
|
|
// 4786: string too long - truncated to 255 characters
|
|
|
|
|
|
|
|
#pragma warning(disable : 4103 4114 4201 4237 4251 4275 4290 4503 4335 4786)
|
|
|
|
|
|
|
|
#endif // WIN32
|
|
|
|
|
2003-09-01 17:36:03 +08:00
|
|
|
#include <osgProducer/Viewer>
|
|
|
|
|
2004-05-14 06:09:23 +08:00
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/Geode>
|
2004-05-20 18:15:48 +08:00
|
|
|
#include <osg/ShapeDrawable>
|
|
|
|
#include <osg/Texture2D>
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
2004-07-01 03:07:05 +08:00
|
|
|
#include <osg/MatrixTransform>
|
2004-09-13 21:53:45 +08:00
|
|
|
#include <osg/CoordinateSystemNode>
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
#include <osgDB/FileUtils>
|
2004-05-20 18:15:48 +08:00
|
|
|
#include <osgDB/ReadFile>
|
2003-09-01 17:36:03 +08:00
|
|
|
|
2004-07-01 03:07:05 +08:00
|
|
|
#include <osgText/Text>
|
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
#include <osgTerrain/DataSet>
|
2003-09-01 17:36:03 +08:00
|
|
|
|
2005-08-31 23:04:27 +08:00
|
|
|
#include <osgSim/OverlayNode>
|
2006-06-08 19:18:27 +08:00
|
|
|
#include <osgSim/SphereSegment>
|
2005-08-31 23:04:27 +08:00
|
|
|
|
2004-08-30 18:03:18 +08:00
|
|
|
#include <osgGA/NodeTrackerManipulator>
|
2004-07-30 23:44:59 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
class GraphicsContext {
|
|
|
|
public:
|
|
|
|
GraphicsContext()
|
|
|
|
{
|
|
|
|
rs = new Producer::RenderSurface;
|
|
|
|
rs->setWindowRectangle(0,0,1,1);
|
|
|
|
rs->useBorder(false);
|
|
|
|
rs->useConfigEventThread(false);
|
|
|
|
rs->realize();
|
|
|
|
}
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
virtual ~GraphicsContext()
|
|
|
|
{
|
|
|
|
}
|
2004-07-01 03:07:05 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
private:
|
|
|
|
Producer::ref_ptr<Producer::RenderSurface> rs;
|
|
|
|
};
|
2004-07-01 03:07:05 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
osg::Node* createEarth()
|
2004-07-01 03:07:05 +08:00
|
|
|
{
|
2004-09-13 21:53:45 +08:00
|
|
|
osg::ref_ptr<osg::Node> scene;
|
2004-07-01 03:07:05 +08:00
|
|
|
|
|
|
|
{
|
2004-09-13 21:53:45 +08:00
|
|
|
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
2004-07-01 03:07:05 +08:00
|
|
|
|
2004-10-05 23:08:54 +08:00
|
|
|
// make osgTerrain::DataSet quieter..
|
|
|
|
osgTerrain::DataSet::setNotifyOffset(1);
|
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
osg::ref_ptr<osgTerrain::DataSet> dataSet = new osgTerrain::DataSet;
|
2004-07-01 03:07:05 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
// register the source imagery
|
2004-05-20 18:15:48 +08:00
|
|
|
{
|
2004-09-13 21:53:45 +08:00
|
|
|
osgTerrain::DataSet::Source* source = new osgTerrain::DataSet::Source(osgTerrain::DataSet::Source::IMAGE, filename);
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2005-11-18 04:22:55 +08:00
|
|
|
source->setCoordinateSystemPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS);
|
2004-09-13 21:53:45 +08:00
|
|
|
source->setCoordinateSystem(osgTerrain::DataSet::coordinateSystemStringToWTK("WGS84"));
|
2003-09-01 17:36:03 +08:00
|
|
|
|
2005-11-18 04:22:55 +08:00
|
|
|
source->setGeoTransformPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION);
|
2004-09-13 21:53:45 +08:00
|
|
|
source->setGeoTransformFromRange(-180.0, 180.0, -90.0, 90.0);
|
2003-09-01 17:36:03 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
dataSet->addSource(source);
|
2004-05-20 18:15:48 +08:00
|
|
|
}
|
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
// set up destination database paramters.
|
|
|
|
dataSet->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE);
|
|
|
|
dataSet->setConvertFromGeographicToGeocentric(true);
|
|
|
|
dataSet->setDestinationName("test.osg");
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
// load the source data and record sizes.
|
|
|
|
dataSet->loadSources();
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
GraphicsContext context;
|
|
|
|
dataSet->createDestination(30);
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
if (dataSet->getDatabaseType()==osgTerrain::DataSet::LOD_DATABASE) dataSet->buildDestination();
|
|
|
|
else dataSet->writeDestination();
|
2004-05-20 18:15:48 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
scene = dataSet->getDestinationRootNode();
|
2005-11-10 04:26:34 +08:00
|
|
|
|
|
|
|
// now we must get rid of all the old OpenGL objects before we start using the scene graph again
|
|
|
|
// otherwise it'll end up in an inconsistent state.
|
|
|
|
scene->releaseGLObjects(dataSet->getState());
|
|
|
|
osg::Texture::flushAllDeletedTextureObjects(0);
|
|
|
|
osg::Drawable::flushAllDeletedDisplayLists(0);
|
2004-06-07 20:53:09 +08:00
|
|
|
}
|
2004-09-13 21:53:45 +08:00
|
|
|
|
|
|
|
return scene.release();
|
2004-07-01 03:07:05 +08:00
|
|
|
|
2003-09-01 17:36:03 +08:00
|
|
|
}
|
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
|
2004-09-22 05:33:52 +08:00
|
|
|
class ModelPositionCallback : public osg::NodeCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ModelPositionCallback():
|
|
|
|
_latitude(0.0),
|
|
|
|
_longitude(0.0),
|
2004-10-13 21:39:27 +08:00
|
|
|
_height(100000.0)
|
2005-03-22 20:04:03 +08:00
|
|
|
{
|
|
|
|
_rotation.makeRotate(osg::DegreesToRadians(90.0),0.0,0.0,1.0);
|
|
|
|
}
|
|
|
|
|
2004-09-22 05:33:52 +08:00
|
|
|
void updateParameters()
|
|
|
|
{
|
2005-03-22 20:04:03 +08:00
|
|
|
_longitude += ((2.0*osg::PI)/360.0)/20.0;
|
2004-09-22 05:33:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
|
|
|
{
|
|
|
|
updateParameters();
|
|
|
|
|
|
|
|
osg::NodePath nodePath = nv->getNodePath();
|
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
osg::MatrixTransform* mt = nodePath.empty() ? 0 : dynamic_cast<osg::MatrixTransform*>(nodePath.back());
|
2004-09-22 05:33:52 +08:00
|
|
|
if (mt)
|
|
|
|
{
|
|
|
|
osg::CoordinateSystemNode* csn = 0;
|
|
|
|
|
|
|
|
// find coordinate system node from our parental chain
|
|
|
|
unsigned int i;
|
|
|
|
for(i=0; i<nodePath.size() && csn==0; ++i)
|
|
|
|
{
|
|
|
|
csn = dynamic_cast<osg::CoordinateSystemNode*>(nodePath[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (csn)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
osg::EllipsoidModel* ellipsoid = csn->getEllipsoidModel();
|
|
|
|
if (ellipsoid)
|
|
|
|
{
|
2005-11-17 17:57:40 +08:00
|
|
|
osg::Matrix inheritedMatrix;
|
2004-09-22 05:33:52 +08:00
|
|
|
for(i+=1; i<nodePath.size()-1; ++i)
|
|
|
|
{
|
|
|
|
osg::Transform* transform = nodePath[i]->asTransform();
|
2005-11-17 17:57:40 +08:00
|
|
|
if (transform) transform->computeLocalToWorldMatrix(inheritedMatrix, nv);
|
2004-09-22 05:33:52 +08:00
|
|
|
}
|
2005-11-17 17:57:40 +08:00
|
|
|
|
|
|
|
osg::Matrixd matrix(inheritedMatrix);
|
2004-09-22 05:33:52 +08:00
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
//osg::Matrixd matrix;
|
2004-09-22 05:33:52 +08:00
|
|
|
ellipsoid->computeLocalToWorldTransformFromLatLongHeight(_latitude,_longitude,_height,matrix);
|
2005-11-17 17:57:40 +08:00
|
|
|
matrix.preMult(osg::Matrix::rotate(_rotation));
|
2004-09-22 05:33:52 +08:00
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
mt->setMatrix(matrix);
|
2004-09-22 05:33:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
traverse(node,nv);
|
|
|
|
}
|
|
|
|
|
|
|
|
double _latitude;
|
|
|
|
double _longitude;
|
|
|
|
double _height;
|
|
|
|
osg::Quat _rotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-07-30 23:44:59 +08:00
|
|
|
class FindNamedNodeVisitor : public osg::NodeVisitor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindNamedNodeVisitor(const std::string& name):
|
|
|
|
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
|
|
|
_name(name) {}
|
|
|
|
|
|
|
|
virtual void apply(osg::Node& node)
|
|
|
|
{
|
|
|
|
if (node.getName()==_name)
|
|
|
|
{
|
|
|
|
_foundNodes.push_back(&node);
|
|
|
|
}
|
|
|
|
traverse(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::vector< osg::ref_ptr<osg::Node> > NodeList;
|
|
|
|
|
|
|
|
std::string _name;
|
|
|
|
NodeList _foundNodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-05-14 06:09:23 +08:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2003-09-01 17:36:03 +08:00
|
|
|
// use an ArgumentParser object to manage the program arguments.
|
|
|
|
osg::ArgumentParser arguments(&argc,argv);
|
|
|
|
|
|
|
|
// set up the usage document, in case we need to print out how to use this program.
|
2004-05-14 06:09:23 +08:00
|
|
|
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of particle systems.");
|
|
|
|
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye");
|
2003-09-01 17:36:03 +08:00
|
|
|
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
|
|
|
|
|
|
|
|
|
|
|
// construct the viewer.
|
|
|
|
osgProducer::Viewer viewer(arguments);
|
|
|
|
|
|
|
|
// set up the value with sensible default event handlers.
|
|
|
|
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
|
|
|
|
|
2004-10-06 03:12:46 +08:00
|
|
|
viewer.getCullSettings().setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
|
2005-04-08 17:55:52 +08:00
|
|
|
viewer.getCullSettings().setNearFarRatio(0.00001f);
|
2004-07-30 23:44:59 +08:00
|
|
|
|
2003-09-01 17:36:03 +08:00
|
|
|
// get details on keyboard and mouse bindings used by the viewer.
|
|
|
|
viewer.getUsage(*arguments.getApplicationUsage());
|
|
|
|
|
2004-10-14 18:38:29 +08:00
|
|
|
osg::Quat rotation;
|
|
|
|
osg::Vec4 vec4;
|
|
|
|
while (arguments.read("--rotate-model",vec4[0],vec4[1],vec4[2],vec4[3]))
|
|
|
|
{
|
|
|
|
osg::Quat local_rotate;
|
|
|
|
local_rotate.makeRotate(osg::DegreesToRadians(vec4[0]),vec4[1],vec4[2],vec4[3]);
|
|
|
|
|
|
|
|
rotation = rotation * local_rotate;
|
|
|
|
}
|
|
|
|
|
|
|
|
osg::NodeCallback* nc = 0;
|
|
|
|
std::string flightpath_filename;
|
|
|
|
while (arguments.read("--flight-path",flightpath_filename))
|
|
|
|
{
|
2004-10-15 17:53:18 +08:00
|
|
|
std::ifstream fin(flightpath_filename.c_str());
|
2004-10-14 18:38:29 +08:00
|
|
|
if (fin)
|
|
|
|
{
|
|
|
|
osg::AnimationPath* path = new osg::AnimationPath;
|
|
|
|
path->read(fin);
|
|
|
|
nc = new osg::AnimationPathCallback(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION;
|
|
|
|
std::string mode;
|
|
|
|
while (arguments.read("--tracker-mode",mode))
|
|
|
|
{
|
|
|
|
if (mode=="NODE_CENTER_AND_ROTATION") trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION;
|
|
|
|
else if (mode=="NODE_CENTER_AND_AZIM") trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM;
|
|
|
|
else if (mode=="NODE_CENTER") trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cout<<"Unrecognized --tracker-mode option "<<mode<<", valid options are:"<<std::endl;
|
|
|
|
std::cout<<" NODE_CENTER_AND_ROTATION"<<std::endl;
|
|
|
|
std::cout<<" NODE_CENTER_AND_AZIM"<<std::endl;
|
|
|
|
std::cout<<" NODE_CENTER"<<std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::TRACKBALL;
|
|
|
|
while (arguments.read("--rotation-mode",mode))
|
|
|
|
{
|
|
|
|
if (mode=="TRACKBALL") rotationMode = osgGA::NodeTrackerManipulator::TRACKBALL;
|
|
|
|
else if (mode=="ELEVATION_AZIM") rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cout<<"Unrecognized --rotation-mode option "<<mode<<", valid options are:"<<std::endl;
|
|
|
|
std::cout<<" TRACKBALL"<<std::endl;
|
|
|
|
std::cout<<" ELEVATION_AZIM"<<std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-01 17:36:03 +08:00
|
|
|
// if user request help write it out to cout.
|
|
|
|
if (arguments.read("-h") || arguments.read("--help"))
|
|
|
|
{
|
|
|
|
arguments.getApplicationUsage()->write(std::cout);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// any option left unread are converted into errors to write out later.
|
|
|
|
arguments.reportRemainingOptionsAsUnrecognized();
|
|
|
|
|
|
|
|
// report any errors if they have occured when parsing the program aguments.
|
|
|
|
if (arguments.errors())
|
|
|
|
{
|
|
|
|
arguments.writeErrorMessages(std::cout);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-08-31 23:04:27 +08:00
|
|
|
// read the scene from the list of file specified commandline args.
|
|
|
|
osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles(arguments);
|
|
|
|
|
|
|
|
if (!root) root = createEarth();
|
2004-10-06 03:12:46 +08:00
|
|
|
|
2004-09-13 21:53:45 +08:00
|
|
|
if (!root) return 0;
|
2004-10-06 03:12:46 +08:00
|
|
|
|
2004-05-14 06:09:23 +08:00
|
|
|
// add a viewport to the viewer and attach the scene graph.
|
2005-04-08 17:55:52 +08:00
|
|
|
viewer.setSceneData(root.get());
|
2004-10-06 03:12:46 +08:00
|
|
|
|
|
|
|
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(root.get());
|
2005-04-08 17:55:52 +08:00
|
|
|
if (csn)
|
|
|
|
{
|
2005-08-31 23:04:27 +08:00
|
|
|
|
|
|
|
bool insertOverlayNode = true;
|
|
|
|
osg::ref_ptr<osgSim::OverlayNode> overlayNode;
|
|
|
|
if (insertOverlayNode)
|
|
|
|
{
|
2005-09-07 03:54:29 +08:00
|
|
|
|
2005-08-31 23:04:27 +08:00
|
|
|
overlayNode = new osgSim::OverlayNode;
|
2005-09-07 03:54:29 +08:00
|
|
|
|
|
|
|
// insert the OverlayNode between the coordinate system node and its children.
|
2005-08-31 23:04:27 +08:00
|
|
|
for(unsigned int i=0; i<csn->getNumChildren(); ++i)
|
|
|
|
{
|
|
|
|
overlayNode->addChild( csn->getChild(i) );
|
|
|
|
}
|
2006-04-05 23:13:17 +08:00
|
|
|
|
2006-05-02 17:45:31 +08:00
|
|
|
csn->removeChildren(0, csn->getNumChildren());
|
|
|
|
csn->addChild(overlayNode.get());
|
2005-09-07 03:54:29 +08:00
|
|
|
|
|
|
|
// tell the overlay node to continously update its overlay texture
|
|
|
|
// as we know we'll be tracking a moving target.
|
2006-02-23 20:39:31 +08:00
|
|
|
overlayNode->setContinuousUpdate(true);
|
2005-08-31 23:04:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-02 17:45:31 +08:00
|
|
|
osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
|
2005-04-08 17:55:52 +08:00
|
|
|
if (cessna)
|
|
|
|
{
|
2006-05-02 17:45:31 +08:00
|
|
|
double s = 200000.0 / cessna->getBound().radius();
|
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
osg::MatrixTransform* scaler = new osg::MatrixTransform;
|
|
|
|
scaler->addChild(cessna);
|
|
|
|
scaler->setMatrix(osg::Matrixd::scale(s,s,s)*osg::Matrixd::rotate(rotation));
|
|
|
|
scaler->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON);
|
|
|
|
|
2006-06-08 19:18:27 +08:00
|
|
|
if (false)
|
|
|
|
{
|
|
|
|
osgSim::SphereSegment* ss = new osgSim::SphereSegment(
|
|
|
|
osg::Vec3(0.0f,0.0f,0.0f), // center
|
|
|
|
19.9f, // radius
|
|
|
|
osg::DegreesToRadians(135.0f),
|
|
|
|
osg::DegreesToRadians(240.0f),
|
|
|
|
osg::DegreesToRadians(-10.0f),
|
|
|
|
osg::DegreesToRadians(30.0f),
|
|
|
|
60);
|
|
|
|
|
|
|
|
scaler->addChild(ss);
|
|
|
|
}
|
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
osg::MatrixTransform* mt = new osg::MatrixTransform;
|
|
|
|
mt->addChild(scaler);
|
|
|
|
|
2006-05-02 17:45:31 +08:00
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
if (!nc) nc = new ModelPositionCallback;
|
2004-10-06 03:12:46 +08:00
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
mt->setUpdateCallback(nc);
|
|
|
|
|
|
|
|
csn->addChild(mt);
|
2005-08-31 23:04:27 +08:00
|
|
|
|
|
|
|
// if we are using an overaly node, use the cessna subgraph as the overlay subgraph
|
2006-05-02 17:45:31 +08:00
|
|
|
if (overlayNode.valid())
|
|
|
|
{
|
|
|
|
overlayNode->setOverlaySubgraph(mt);
|
|
|
|
}
|
2005-04-08 17:55:52 +08:00
|
|
|
|
|
|
|
osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator;
|
|
|
|
tm->setTrackerMode(trackerMode);
|
|
|
|
tm->setRotationMode(rotationMode);
|
|
|
|
tm->setTrackNode(scaler);
|
|
|
|
|
|
|
|
unsigned int num = viewer.addCameraManipulator(tm);
|
|
|
|
viewer.selectCameraManipulator(num);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cout<<"Failed to read cessna.osg"<<std::endl;
|
|
|
|
}
|
2005-08-31 23:04:27 +08:00
|
|
|
|
2005-04-08 17:55:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-30 23:44:59 +08:00
|
|
|
|
2003-09-01 17:36:03 +08:00
|
|
|
// create the windows and run the threads.
|
|
|
|
viewer.realize();
|
|
|
|
|
|
|
|
while( !viewer.done() )
|
|
|
|
{
|
|
|
|
// wait for all cull and draw threads to complete.
|
|
|
|
viewer.sync();
|
|
|
|
|
|
|
|
// update the scene by traversing it with the the update visitor which will
|
|
|
|
// call all node update callbacks and animations.
|
|
|
|
viewer.update();
|
|
|
|
|
|
|
|
// fire off the cull and draw traversals of the scene.
|
|
|
|
viewer.frame();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait for all cull and draw threads to complete before exit.
|
|
|
|
viewer.sync();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|