Introduced CMake option OSG_PROVIDE_READFILE option that defaults to ON, but when switched to OFF disables the building of the osgDB::read*File() methods,
forcing users to use osgDB::readRef*File() methods. The later is preferable as it closes a potential threading bug when using paging databases in conjunction with the osgDB::Registry Object Cache. This threading bug occurs when one thread gets an object from the Cache via an osgDB::read*File() call where only a pointer to the object is passed back, so taking a reference to the object is delayed till it gets reassigned to a ref_ptr<>, but at the same time another thread calls a flush of the Object Cache deleting this object as it's referenceCount is now zero. Using osgDB::readREf*File() makes sure the a ref_ptr<> is passed back and the referenceCount never goes to zero. To ensure the OSG builds when OSG_PROVIDE_READFILE is to OFF the many cases of osgDB::read*File() usage had to be replaced with a ref_ptr<> osgDB::readRef*File() usage. The avoid this change causing lots of other client code to be rewritten to handle the use of ref_ptr<> in place of C pointer I introduced a serious of templte methods in various class to adapt ref_ptr<> to the underly C pointer to be passed to old OSG API's, example of this is found in include/osg/Group: bool addChild(Node* child); // old method which can only be used with a Node* tempalte<class T> bool addChild(const osg::ref_ptr<T>& child) { return addChild(child.get()); } // adapter template method These changes together cover 149 modified files, so it's a large submission. This extent of changes are warrent to make use of the Object Cache and multi-threaded loaded more robust. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.4@15165 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
74f1838960
commit
6a67be2e32
@ -398,6 +398,7 @@ ENDIF()
|
|||||||
OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC warnings generated by OSG headers." ON)
|
OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC warnings generated by OSG headers." ON)
|
||||||
MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
|
MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
|
||||||
|
|
||||||
|
OPTION(OSG_PROVIDE_READFILE "Set to ON for include/osgDB/ReadFile to provide the osgDB::read*File(() methods. " ON)
|
||||||
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
|
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ int main( int argc, char **argv )
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
std::cout<<"reading "<<*itr<<std::endl;
|
std::cout<<"reading "<<*itr<<std::endl;
|
||||||
osg::ref_ptr<osg::Object> obj = osgDB::readObjectFile(*itr);
|
osg::ref_ptr<osg::Object> obj = osgDB::readRefObjectFile(*itr);
|
||||||
if (obj.valid())
|
if (obj.valid())
|
||||||
{
|
{
|
||||||
std::cout<<" write to archive "<<*itr<<std::endl;
|
std::cout<<" write to archive "<<*itr<<std::endl;
|
||||||
|
@ -772,7 +772,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
osg::Timer_t startTick = osg::Timer::instance()->tick();
|
osg::Timer_t startTick = osg::Timer::instance()->tick();
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles(fileNames);
|
osg::ref_ptr<osg::Node> root = osgDB::readRefNodeFiles(fileNames);
|
||||||
|
|
||||||
if (root.valid())
|
if (root.valid())
|
||||||
{
|
{
|
||||||
|
@ -272,9 +272,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* readNodeFileAndWriteToCache(const std::string& filename)
|
osg::ref_ptr<osg::Node> readNodeFileAndWriteToCache(const std::string& filename)
|
||||||
{
|
{
|
||||||
osg::Node* node = 0;
|
osg::ref_ptr<osg::Node> node = 0;
|
||||||
if (_fileCache.valid() )
|
if (_fileCache.valid() )
|
||||||
{
|
{
|
||||||
if (_fileCache->existsInCache(filename))
|
if (_fileCache->existsInCache(filename))
|
||||||
@ -286,7 +286,7 @@ public:
|
|||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
|
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
|
||||||
|
|
||||||
node = osgDB::readNodeFile(filename);
|
node = osgDB::readRefNodeFile(filename);
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"write to FileCache : "<<filename<<std::endl;
|
osg::notify(osg::NOTICE)<<"write to FileCache : "<<filename<<std::endl;
|
||||||
@ -298,7 +298,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
|
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
|
||||||
node = osgDB::readNodeFile(filename);
|
node = osgDB::readRefNodeFile(filename);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,10 @@ int main(int argc, char** argv)
|
|||||||
std::string device;
|
std::string device;
|
||||||
while(arguments.read("--device", device))
|
while(arguments.read("--device", device))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device);
|
osg::ref_ptr<osgGA::Device> dev = osgDB::readRefFile<osgGA::Device>(device);
|
||||||
if (dev.valid())
|
if (dev.valid())
|
||||||
{
|
{
|
||||||
viewer.addDevice(dev.get());
|
viewer.addDevice(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ int main(int argc, char** argv)
|
|||||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
@ -172,9 +172,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// optimize the scene graph, remove redundant nodes and state etc.
|
// optimize the scene graph, remove redundant nodes and state etc.
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(loadedModel.get());
|
optimizer.optimize(loadedModel);
|
||||||
|
|
||||||
viewer.setSceneData( loadedModel.get() );
|
viewer.setSceneData(loadedModel);
|
||||||
|
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
|
||||||
|
@ -215,24 +215,24 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
|
|||||||
std::string filename;
|
std::string filename;
|
||||||
while (arguments.read("--image",filename))
|
while (arguments.read("--image",filename))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get());
|
osg::ref_ptr<osg::Image> image = readRefImageFile(filename.c_str(), local_options.get());
|
||||||
if (image.valid()) nodeList.push_back(osg::createGeodeForImage(image.get()));
|
if (image.valid()) nodeList.push_back(osg::createGeodeForImage(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (arguments.read("--movie",filename))
|
while (arguments.read("--movie",filename))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get());
|
osg::ref_ptr<osg::Image> image = readRefImageFile(filename.c_str(), local_options.get());
|
||||||
osg::ref_ptr<osg::ImageStream> imageStream = dynamic_cast<osg::ImageStream*>(image.get());
|
osg::ref_ptr<osg::ImageStream> imageStream = dynamic_cast<osg::ImageStream*>(image.get());
|
||||||
if (image.valid())
|
if (image.valid())
|
||||||
{
|
{
|
||||||
imageStream->play();
|
imageStream->play();
|
||||||
nodeList.push_back(osg::createGeodeForImage(imageStream.get()));
|
nodeList.push_back(osg::createGeodeForImage(imageStream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (arguments.read("--dem",filename))
|
while (arguments.read("--dem",filename))
|
||||||
{
|
{
|
||||||
osg::HeightField* hf = readHeightFieldFile(filename.c_str(), local_options.get());
|
osg::ref_ptr<osg::HeightField> hf = readRefHeightFieldFile(filename.c_str(), local_options.get());
|
||||||
if (hf)
|
if (hf)
|
||||||
{
|
{
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::Geode* geode = new osg::Geode;
|
||||||
@ -247,7 +247,7 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
|
|||||||
if (!arguments.isOption(pos))
|
if (!arguments.isOption(pos))
|
||||||
{
|
{
|
||||||
// not an option so assume string is a filename.
|
// not an option so assume string is a filename.
|
||||||
osg::Node *node = osgDB::readNodeFile( arguments[pos], local_options.get());
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( arguments[pos], local_options.get());
|
||||||
|
|
||||||
if(node)
|
if(node)
|
||||||
{
|
{
|
||||||
|
@ -266,7 +266,7 @@ void processLoadedModel(osg::ref_ptr<osg::Node>& loadedModel, int optimizer_opti
|
|||||||
|
|
||||||
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name, bool forward_mouse_events)
|
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name, bool forward_mouse_events)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device_name);
|
osg::ref_ptr<osgGA::Device> dev = osgDB::readRefFile<osgGA::Device>(device_name);
|
||||||
if (dev.valid())
|
if (dev.valid())
|
||||||
{
|
{
|
||||||
OSG_INFO << "Adding Device : " << device_name << std::endl;
|
OSG_INFO << "Adding Device : " << device_name << std::endl;
|
||||||
@ -317,7 +317,7 @@ int main( int argc, char **argv )
|
|||||||
if (arguments.read("-devices") || arguments.read("--devices"))
|
if (arguments.read("-devices") || arguments.read("--devices"))
|
||||||
{
|
{
|
||||||
// Force load QuickTime plugin, probe video capability, exit
|
// Force load QuickTime plugin, probe video capability, exit
|
||||||
osgDB::readImageFile("devices.live");
|
osgDB::readRefImageFile("devices.live");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
osg::ref_ptr<osgDB::Options> device_options = new osgDB::Options("documentRegisteredHandlers");
|
osg::ref_ptr<osgDB::Options> device_options = new osgDB::Options("documentRegisteredHandlers");
|
||||||
|
|
||||||
osg::ref_ptr<osgGA::Device> rest_http_device = osgDB::readFile<osgGA::Device>(server_address+":"+server_port+"/"+document_root+".resthttp", device_options.get());
|
osg::ref_ptr<osgGA::Device> rest_http_device = osgDB::readRefFile<osgGA::Device>(server_address+":"+server_port+"/"+document_root+".resthttp", device_options.get());
|
||||||
if (rest_http_device.valid())
|
if (rest_http_device.valid())
|
||||||
{
|
{
|
||||||
viewer.addDevice(rest_http_device.get());
|
viewer.addDevice(rest_http_device.get());
|
||||||
|
@ -85,7 +85,7 @@ int main( int argc, char **argv )
|
|||||||
std::string filename;
|
std::string filename;
|
||||||
if (arguments.read("--shader",filename))
|
if (arguments.read("--shader",filename))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Shader> shader = osgDB::readShaderFile(filename);
|
osg::ref_ptr<osg::Shader> shader = osgDB::readRefShaderFile(filename);
|
||||||
if (shader.valid())
|
if (shader.valid())
|
||||||
{
|
{
|
||||||
std::string name = osgDB::getStrippedName(filename);
|
std::string name = osgDB::getStrippedName(filename);
|
||||||
|
@ -311,7 +311,7 @@ public:
|
|||||||
//set OSG_FILE_PATH for loading axes.osgt
|
//set OSG_FILE_PATH for loading axes.osgt
|
||||||
void ComputeNode::addHelperGeometry()
|
void ComputeNode::addHelperGeometry()
|
||||||
{
|
{
|
||||||
_helperNode = osgDB::readNodeFile("axes.osgt");
|
_helperNode = osgDB::readRefNodeFile("axes.osgt");
|
||||||
|
|
||||||
if (_helperNode.valid())
|
if (_helperNode.valid())
|
||||||
{
|
{
|
||||||
@ -464,8 +464,8 @@ void ComputeNode::addDataMonitor(osg::Vec3 placement, osg::Vec3 relativePlacemen
|
|||||||
ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
|
||||||
//add a label
|
//add a label
|
||||||
osgText::Text* text = new osgText::Text;
|
osg::ref_ptr<osgText::Text> text = new osgText::Text;
|
||||||
osgText::Font* font = osgText::readFontFile("fonts/arial.ttf");
|
osg::ref_ptr<osgText::Font> font = osgText::readRefFontFile("fonts/arial.ttf");
|
||||||
text->setFont(font);
|
text->setFont(font);
|
||||||
text->setColor(osg::Vec4(1, 1, 1, 1));
|
text->setColor(osg::Vec4(1, 1, 1, 1));
|
||||||
text->setCharacterSize(0.1*scale);
|
text->setCharacterSize(0.1*scale);
|
||||||
|
@ -555,7 +555,7 @@ public:
|
|||||||
osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
|
osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
|
||||||
|
|
||||||
_modelReadyToMerge = false;
|
_modelReadyToMerge = false;
|
||||||
_loadedModel = osgDB::readNodeFile(_filename);
|
_loadedModel = osgDB::readRefNodeFile(_filename);
|
||||||
|
|
||||||
if (_loadedModel.valid())
|
if (_loadedModel.valid())
|
||||||
{
|
{
|
||||||
|
@ -136,9 +136,9 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
|
|
||||||
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
|
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
|
||||||
|
|
||||||
osg::Group* model = new osg::Group;
|
osg::ref_ptr<osg::Group> model = new osg::Group;
|
||||||
|
|
||||||
osg::Node* glider = osgDB::readNodeFile("glider.osgt");
|
osg::ref_ptr<osg::Node> glider = osgDB::readRefNodeFile("glider.osgt");
|
||||||
if (glider)
|
if (glider)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = glider->getBound();
|
const osg::BoundingSphere& bs = glider->getBound();
|
||||||
@ -159,7 +159,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osgt");
|
osg::ref_ptr<osg::Node> cessna = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
if (cessna)
|
if (cessna)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = cessna->getBound();
|
const osg::BoundingSphere& bs = cessna->getBound();
|
||||||
@ -173,26 +173,26 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
|
|
||||||
positioned->addChild(cessna);
|
positioned->addChild(cessna);
|
||||||
|
|
||||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
osg::ref_ptr<osg::MatrixTransform> xform = new osg::MatrixTransform;
|
||||||
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0));
|
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0));
|
||||||
xform->addChild(positioned);
|
xform->addChild(positioned);
|
||||||
|
|
||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique technique)
|
osg::ref_ptr<osg::Group> createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique technique)
|
||||||
{
|
{
|
||||||
osg::Vec3 center(0.0f,0.0f,0.0f);
|
osg::Vec3 center(0.0f,0.0f,0.0f);
|
||||||
float radius = 100.0f;
|
float radius = 100.0f;
|
||||||
|
|
||||||
osg::Group* root = new osg::Group;
|
osg::ref_ptr<osg::Group> root = new osg::Group;
|
||||||
|
|
||||||
float baseHeight = center.z()-radius*0.5;
|
float baseHeight = center.z()-radius*0.5;
|
||||||
osg::Node* baseModel = createBase(osg::Vec3(center.x(), center.y(), baseHeight),radius);
|
osg::ref_ptr<osg::Node> baseModel = createBase(osg::Vec3(center.x(), center.y(), baseHeight),radius);
|
||||||
osg::Node* movingModel = createMovingModel(center,radius*0.8f);
|
osg::ref_ptr<osg::Node> movingModel = createMovingModel(center,radius*0.8f);
|
||||||
|
|
||||||
if (overlay)
|
if (overlay)
|
||||||
{
|
{
|
||||||
@ -232,14 +232,14 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* model = createModel(overlay, technique);
|
osg::ref_ptr<osg::Group> model = createModel(overlay, technique);
|
||||||
if (!model)
|
if (!model)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tilt the scene so the default eye position is looking down on the model.
|
// tilt the scene so the default eye position is looking down on the model.
|
||||||
osg::MatrixTransform* rootnode = new osg::MatrixTransform;
|
osg::ref_ptr<osg::MatrixTransform> rootnode = new osg::MatrixTransform;
|
||||||
rootnode->setMatrix(osg::Matrix::rotate(osg::inDegrees(30.0f),1.0f,0.0f,0.0f));
|
rootnode->setMatrix(osg::Matrix::rotate(osg::inDegrees(30.0f),1.0f,0.0f,0.0f));
|
||||||
rootnode->addChild(model);
|
rootnode->addChild(model);
|
||||||
|
|
||||||
|
@ -196,8 +196,8 @@ int main (int argc, char* argv[])
|
|||||||
while (psr.read("--software")) { hardware = false; }
|
while (psr.read("--software")) { hardware = false; }
|
||||||
while (psr.read("--number", maxChar)) {}
|
while (psr.read("--number", maxChar)) {}
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFiles(psr);
|
||||||
osg::ref_ptr<osg::Group> root = dynamic_cast<osg::Group*>(osgDB::readNodeFiles(psr));
|
osg::ref_ptr<osg::Group> root = dynamic_cast<osg::Group*>(node.get());
|
||||||
if (!root)
|
if (!root)
|
||||||
{
|
{
|
||||||
std::cout << psr.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << psr.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -50,7 +50,7 @@ struct GeometryFinder : public osg::NodeVisitor
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> getShape(const std::string& name)
|
osg::ref_ptr<osg::Geometry> getShape(const std::string& name)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> shape0 = osgDB::readNodeFile(name);
|
osg::ref_ptr<osg::Node> shape0 = osgDB::readRefNodeFile(name);
|
||||||
if (shape0)
|
if (shape0)
|
||||||
{
|
{
|
||||||
GeometryFinder finder;
|
GeometryFinder finder;
|
||||||
|
@ -163,7 +163,8 @@ int main (int argc, char* argv[])
|
|||||||
file = psr[1];
|
file = psr[1];
|
||||||
|
|
||||||
// replace the manager
|
// replace the manager
|
||||||
osg::Group* root = dynamic_cast<osg::Group*>(osgDB::readNodeFile(file));
|
osg::ref_ptr<osg::Node> loadedmodel = osgDB::readRefNodeFile(file);
|
||||||
|
osg::Group* root = dynamic_cast<osg::Group*>(loadedmodel.get());
|
||||||
if (!root) {
|
if (!root) {
|
||||||
osg::notify(osg::FATAL) << "can't read file " << file << std::endl;
|
osg::notify(osg::FATAL) << "can't read file " << file << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -127,7 +127,8 @@ int main(int argc, char** argv)
|
|||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group();
|
osg::ref_ptr<osg::Group> group = new osg::Group();
|
||||||
|
|
||||||
osg::Group* node = dynamic_cast<osg::Group*>(osgDB::readNodeFiles(arguments)); //dynamic_cast<osgAnimation::AnimationManager*>(osgDB::readNodeFile(psr[1]));
|
osg::ref_ptr<osg::Node> loadedmodel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
osg::Group* node = dynamic_cast<osg::Group*>(loadedmodel.get());
|
||||||
if(!node)
|
if(!node)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -165,7 +165,7 @@ int main(int argc, char** argv)
|
|||||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
osg::Geometry * quad = osg::createTexturedQuadGeometry(osg::Vec3f(-2.0f, 0.0f, -2.0f),
|
osg::Geometry * quad = osg::createTexturedQuadGeometry(osg::Vec3f(-2.0f, 0.0f, -2.0f),
|
||||||
|
@ -287,7 +287,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -42,10 +42,10 @@
|
|||||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageList;
|
typedef std::vector< osg::ref_ptr<osg::Image> > ImageList;
|
||||||
|
|
||||||
/** create quad at specified position. */
|
/** create quad at specified position. */
|
||||||
osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const osg::Vec3& height, osg::Image* image=NULL)
|
osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const osg::Vec3& height, osg::ref_ptr<osg::Image> image)
|
||||||
{
|
{
|
||||||
// set up the Geometry.
|
// set up the Geometry.
|
||||||
osg::Geometry* geom = new osg::Geometry;
|
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||||
|
|
||||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||||
(*coords)[0] = corner;
|
(*coords)[0] = corner;
|
||||||
@ -80,13 +80,13 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
|
|||||||
geom->setStateSet(stateset);
|
geom->setStateSet(stateset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return geom;
|
return geom.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const osg::Vec3& ydir,const osg::Vec3& zdir)
|
osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const osg::Vec3& ydir,const osg::Vec3& zdir)
|
||||||
{
|
{
|
||||||
// set up the Geometry.
|
// set up the Geometry.
|
||||||
osg::Geometry* geom = new osg::Geometry;
|
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||||
|
|
||||||
osg::Vec3Array* coords = new osg::Vec3Array(6);
|
osg::Vec3Array* coords = new osg::Vec3Array(6);
|
||||||
(*coords)[0] = corner;
|
(*coords)[0] = corner;
|
||||||
@ -121,20 +121,20 @@ osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const os
|
|||||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||||
geom->setStateSet(stateset);
|
geom->setStateSet(stateset);
|
||||||
|
|
||||||
return geom;
|
return geom.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* createModel()
|
osg::ref_ptr<osg::Node> createModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
// create the root node which will hold the model.
|
// create the root node which will hold the model.
|
||||||
osg::Group* root = new osg::Group();
|
osg::ref_ptr<osg::Group> root = new osg::Group();
|
||||||
|
|
||||||
// add the drawable into a single geode to be shared...
|
// add the drawable into a single geode to be shared...
|
||||||
osg::Billboard* center = new osg::Billboard();
|
osg::Billboard* center = new osg::Billboard();
|
||||||
center->setMode(osg::Billboard::POINT_ROT_EYE);
|
center->setMode(osg::Billboard::POINT_ROT_EYE);
|
||||||
center->addDrawable(
|
center->addDrawable(
|
||||||
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Images/reflect.rgb")),
|
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readRefImageFile("Images/reflect.rgb")),
|
||||||
osg::Vec3(0.0f,0.0f,0.0f));
|
osg::Vec3(0.0f,0.0f,0.0f));
|
||||||
|
|
||||||
osg::Billboard* x_arrow = new osg::Billboard();
|
osg::Billboard* x_arrow = new osg::Billboard();
|
||||||
@ -142,7 +142,7 @@ osg::Node* createModel()
|
|||||||
x_arrow->setAxis(osg::Vec3(1.0f,0.0f,0.0f));
|
x_arrow->setAxis(osg::Vec3(1.0f,0.0f,0.0f));
|
||||||
x_arrow->setNormal(osg::Vec3(0.0f,-1.0f,0.0f));
|
x_arrow->setNormal(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
x_arrow->addDrawable(
|
x_arrow->addDrawable(
|
||||||
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Cubemap_axis/posx.png")),
|
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readRefImageFile("Cubemap_axis/posx.png")),
|
||||||
osg::Vec3(5.0f,0.0f,0.0f));
|
osg::Vec3(5.0f,0.0f,0.0f));
|
||||||
|
|
||||||
osg::Billboard* y_arrow = new osg::Billboard();
|
osg::Billboard* y_arrow = new osg::Billboard();
|
||||||
@ -150,7 +150,7 @@ osg::Node* createModel()
|
|||||||
y_arrow->setAxis(osg::Vec3(0.0f,1.0f,0.0f));
|
y_arrow->setAxis(osg::Vec3(0.0f,1.0f,0.0f));
|
||||||
y_arrow->setNormal(osg::Vec3(1.0f,0.0f,0.0f));
|
y_arrow->setNormal(osg::Vec3(1.0f,0.0f,0.0f));
|
||||||
y_arrow->addDrawable(
|
y_arrow->addDrawable(
|
||||||
createSquare(osg::Vec3(0.0f,-0.5f,-0.5f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Cubemap_axis/posy.png")),
|
createSquare(osg::Vec3(0.0f,-0.5f,-0.5f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readRefImageFile("Cubemap_axis/posy.png")),
|
||||||
osg::Vec3(0.0f,5.0f,0.0f));
|
osg::Vec3(0.0f,5.0f,0.0f));
|
||||||
|
|
||||||
osg::Billboard* z_arrow = new osg::Billboard();
|
osg::Billboard* z_arrow = new osg::Billboard();
|
||||||
@ -158,7 +158,7 @@ osg::Node* createModel()
|
|||||||
z_arrow->setAxis(osg::Vec3(0.0f,0.0f,1.0f));
|
z_arrow->setAxis(osg::Vec3(0.0f,0.0f,1.0f));
|
||||||
z_arrow->setNormal(osg::Vec3(0.0f,-1.0f,0.0f));
|
z_arrow->setNormal(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
z_arrow->addDrawable(
|
z_arrow->addDrawable(
|
||||||
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Cubemap_axis/posz.png")),
|
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readRefImageFile("Cubemap_axis/posz.png")),
|
||||||
osg::Vec3(0.0f,0.0f,5.0f));
|
osg::Vec3(0.0f,0.0f,5.0f));
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,9 +71,17 @@ int main( int argc, char **argv )
|
|||||||
bool useGlobalBlending = false;
|
bool useGlobalBlending = false;
|
||||||
if ( arguments.read("--no-draw-buffers") ) useGlobalBlending = true;
|
if ( arguments.read("--no-draw-buffers") ) useGlobalBlending = true;
|
||||||
|
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Node> cessna = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
|
if (!cessna)
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Cannot not find model 'cessna.osg' to render"<<std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a camera to output multi-rendering-targets (MRT)
|
// Create a camera to output multi-rendering-targets (MRT)
|
||||||
osg::Camera* mrtCam = createMRTCamera( textures );
|
osg::ref_ptr<osg::Camera> mrtCam = createMRTCamera( textures );
|
||||||
mrtCam->addChild( osgDB::readNodeFile("cessna.osgt") );
|
mrtCam->addChild( cessna );
|
||||||
|
|
||||||
// Create shader program to be used
|
// Create shader program to be used
|
||||||
const char* mrtFragmentCode = {
|
const char* mrtFragmentCode = {
|
||||||
@ -87,8 +95,8 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Program> program = new osg::Program;
|
osg::ref_ptr<osg::Program> program = new osg::Program;
|
||||||
program->addShader( new osg::Shader(osg::Shader::FRAGMENT, mrtFragmentCode) );
|
program->addShader( new osg::Shader(osg::Shader::FRAGMENT, mrtFragmentCode) );
|
||||||
|
|
||||||
osg::StateSet* ss = mrtCam->getOrCreateStateSet();
|
osg::ref_ptr<osg::StateSet> ss = mrtCam->getOrCreateStateSet();
|
||||||
ss->setAttributeAndModes( program.get() );
|
ss->setAttributeAndModes( program );
|
||||||
|
|
||||||
// Apply blending to the original scene in MRT
|
// Apply blending to the original scene in MRT
|
||||||
if ( !useGlobalBlending )
|
if ( !useGlobalBlending )
|
||||||
@ -103,8 +111,8 @@ int main( int argc, char **argv )
|
|||||||
// Accept different blend/colormask attributes on multiple render targets
|
// Accept different blend/colormask attributes on multiple render targets
|
||||||
osg::ref_ptr<osg::BlendFunci> blend0 = new osg::BlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
osg::ref_ptr<osg::BlendFunci> blend0 = new osg::BlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
osg::ref_ptr<osg::ColorMaski> colormask3 = new osg::ColorMaski(3, false, true, false, true);
|
osg::ref_ptr<osg::ColorMaski> colormask3 = new osg::ColorMaski(3, false, true, false, true);
|
||||||
ss->setAttribute( blend0.get() );
|
ss->setAttribute( blend0 );
|
||||||
ss->setAttributeAndModes( colormask3.get() );
|
ss->setAttributeAndModes( colormask3 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -139,10 +139,10 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cessnafire.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cessnafire.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -150,11 +150,11 @@ int main( int argc, char **argv )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Group* root = new osg::Group;
|
osg::ref_ptr<osg::Group> root = new osg::Group;
|
||||||
root->addChild(loadedModel);
|
root->addChild(loadedModel);
|
||||||
|
|
||||||
|
|
||||||
osg::StateSet* stateset = new osg::StateSet;
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||||
stateset->setDataVariance(osg::Object::DYNAMIC);
|
stateset->setDataVariance(osg::Object::DYNAMIC);
|
||||||
|
|
||||||
osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD);
|
osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD);
|
||||||
|
@ -239,10 +239,10 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rootnode = osgDB::readNodeFiles(arguments);
|
rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!rootnode) rootnode = osgDB::readNodeFile("cow.osgt");
|
if (!rootnode) rootnode = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
if (!rootnode)
|
if (!rootnode)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (ea.getKey()=='l')
|
if (ea.getKey()=='l')
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile( _filenames[_position] );
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile( _filenames[_position] );
|
||||||
++_position;
|
++_position;
|
||||||
if (_position>=_filenames.size()) _position = 0;
|
if (_position>=_filenames.size()) _position = 0;
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Node> model;
|
osg::ref_ptr<osg::Node> model;
|
||||||
if (sharedModel)
|
if (sharedModel)
|
||||||
{
|
{
|
||||||
model = osgDB::readNodeFiles(arguments);
|
model = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!model) return 0;
|
if (!model) return 0;
|
||||||
|
|
||||||
if (enableVBO)
|
if (enableVBO)
|
||||||
@ -242,7 +242,7 @@ int main( int argc, char **argv )
|
|||||||
if (sharedModel) viewer.setSceneData(model.get());
|
if (sharedModel) viewer.setSceneData(model.get());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
if (enableVBO)
|
if (enableVBO)
|
||||||
@ -300,7 +300,7 @@ int main( int argc, char **argv )
|
|||||||
while (arguments.read("--config", configfile))
|
while (arguments.read("--config", configfile))
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"Trying to read config file "<<configfile<<std::endl;
|
osg::notify(osg::NOTICE)<<"Trying to read config file "<<configfile<<std::endl;
|
||||||
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(configfile);
|
osg::ref_ptr<osg::Object> object = osgDB::readRefObjectFile(configfile);
|
||||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(object.get());
|
osgViewer::View* view = dynamic_cast<osgViewer::View*>(object.get());
|
||||||
if (view)
|
if (view)
|
||||||
{
|
{
|
||||||
@ -329,9 +329,9 @@ int main( int argc, char **argv )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// load the scene.
|
// load the scene.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ int main( int argc, char **argv )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.setSceneData(loadedModel.get());
|
viewer.setSceneData(loadedModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
@ -117,7 +117,7 @@ void Character::setCharacter(const std::string& filename, const std::string& nam
|
|||||||
|
|
||||||
float _characterSize = _width.length()*0.2f;
|
float _characterSize = _width.length()*0.2f;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile(filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Vec3 pos(-0.5f*_characterSize,0.0f,0.0f);
|
osg::Vec3 pos(-0.5f*_characterSize,0.0f,0.0f);
|
||||||
@ -153,7 +153,7 @@ void Character::setLives(const std::string& filename, const osg::Vec3& origin, c
|
|||||||
_numLives = numLives;
|
_numLives = numLives;
|
||||||
_livesSwitch = new osg::Switch;
|
_livesSwitch = new osg::Switch;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile(filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::StateSet* stateset = _livesSwitch->getOrCreateStateSet();
|
osg::StateSet* stateset = _livesSwitch->getOrCreateStateSet();
|
||||||
@ -186,7 +186,7 @@ void Character::setCatches(const std::string& filename, const osg::Vec3& origin,
|
|||||||
_numCatches = 0;
|
_numCatches = 0;
|
||||||
_catchSwitch = new osg::Switch;
|
_catchSwitch = new osg::Switch;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile(filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::StateSet* stateset = _catchSwitch->getOrCreateStateSet();
|
osg::StateSet* stateset = _catchSwitch->getOrCreateStateSet();
|
||||||
@ -349,7 +349,7 @@ class CatchableObject : public osg::Referenced
|
|||||||
*/
|
*/
|
||||||
inline void setToGravity(float scale = 1.0f) { _acceleration.set(0, 0, -9.81f*scale); }
|
inline void setToGravity(float scale = 1.0f) { _acceleration.set(0, 0, -9.81f*scale); }
|
||||||
|
|
||||||
/// Set the fluid parameters as for air (20°C temperature).
|
/// Set the fluid parameters as for air (20C temperature).
|
||||||
inline void setFluidToAir()
|
inline void setFluidToAir()
|
||||||
{
|
{
|
||||||
setToGravity(1.0f);
|
setToGravity(1.0f);
|
||||||
@ -357,7 +357,7 @@ class CatchableObject : public osg::Referenced
|
|||||||
setFluidViscosity(1.8e-5f);
|
setFluidViscosity(1.8e-5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the fluid parameters as for pure water (20°C temperature).
|
/// Set the fluid parameters as for pure water (20C temperature).
|
||||||
inline void setFluidToWater()
|
inline void setFluidToWater()
|
||||||
{
|
{
|
||||||
setToGravity(1.0f);
|
setToGravity(1.0f);
|
||||||
@ -395,7 +395,7 @@ void CatchableObject::setUpCatchablesMap(const FileList& fileList)
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
const std::string& filename = *itr;
|
const std::string& filename = *itr;
|
||||||
osg::Image* image = osgDB::readImageFile(filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet();
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet();
|
||||||
@ -1045,10 +1045,10 @@ osg::Node* GameEventHandler::createScene()
|
|||||||
|
|
||||||
// set up welcome subgraph
|
// set up welcome subgraph
|
||||||
{
|
{
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||||
|
|
||||||
// set up the background
|
// set up the background
|
||||||
osg::Image* image = osgDB::readImageFile("Catch/Welcome.jpg");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Catch/Welcome.jpg");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
||||||
@ -1121,9 +1121,9 @@ osg::Node* GameEventHandler::createScene()
|
|||||||
|
|
||||||
// set up you've lost subgraph
|
// set up you've lost subgraph
|
||||||
{
|
{
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Catch/YouLost.jpg");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Catch/YouLost.jpg");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
||||||
@ -1184,9 +1184,9 @@ osg::Node* GameEventHandler::createScene()
|
|||||||
|
|
||||||
// set up you've won subgraph
|
// set up you've won subgraph
|
||||||
{
|
{
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Catch/YouWon.jpg");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Catch/YouWon.jpg");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
||||||
@ -1269,7 +1269,7 @@ osg::Node* GameEventHandler::createScene()
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile(*itr);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(*itr);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
osg::Geometry* geometry = osg::createTexturedQuadGeometry(_origin,_width,_height);
|
||||||
|
@ -40,10 +40,9 @@
|
|||||||
#include <osgUtil/Optimizer>
|
#include <osgUtil/Optimizer>
|
||||||
|
|
||||||
|
|
||||||
osg::Node* decorate_with_clip_node(osg::Node* subgraph)
|
osg::ref_ptr<osg::Node> decorate_with_clip_node(const osg::ref_ptr<osg::Node>& subgraph)
|
||||||
{
|
{
|
||||||
osg::Group* rootnode = new osg::Group;
|
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
|
||||||
|
|
||||||
|
|
||||||
// create wireframe view of the model so the user can see
|
// create wireframe view of the model so the user can see
|
||||||
// what parts are being culled away.
|
// what parts are being culled away.
|
||||||
@ -117,11 +116,11 @@ int main( int argc, char **argv )
|
|||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
@ -131,7 +130,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decorate the scenegraph with a clip node.
|
// decorate the scenegraph with a clip node.
|
||||||
osg::Node* rootnode = decorate_with_clip_node(loadedModel);
|
osg::ref_ptr<osg::Node> rootnode = decorate_with_clip_node(loadedModel);
|
||||||
|
|
||||||
// run optimization over the scene graph
|
// run optimization over the scene graph
|
||||||
osgUtil::Optimizer optimzer;
|
osgUtil::Optimizer optimzer;
|
||||||
|
@ -505,7 +505,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load model.
|
// load model.
|
||||||
osg::ref_ptr<osg::Node> rootnode = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// set the scene to render
|
// set the scene to render
|
||||||
viewer.setSceneData(rootnode.get());
|
viewer.setSceneData(rootnode.get());
|
||||||
|
@ -133,7 +133,7 @@ int main( int argc, char **argv )
|
|||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ int main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
osgViewer::View* view = new osgViewer::View;
|
osgViewer::View* view = new osgViewer::View;
|
||||||
view->setName("Single view");
|
view->setName("Single view");
|
||||||
view->setSceneData(osgDB::readNodeFile("fountain.osgt"));
|
view->setSceneData(osgDB::readRefNodeFile("fountain.osgt"));
|
||||||
|
|
||||||
view->addEventHandler( new osgViewer::StatsHandler );
|
view->addEventHandler( new osgViewer::StatsHandler );
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ int main( int argc, char **argv )
|
|||||||
view->setName("View three");
|
view->setName("View three");
|
||||||
viewer.addView(view);
|
viewer.addView(view);
|
||||||
|
|
||||||
view->setSceneData(osgDB::readNodeFile("cessnafire.osgt"));
|
view->setSceneData(osgDB::readRefNodeFile("cessnafire.osgt"));
|
||||||
|
|
||||||
view->getCamera()->setName("Cam three");
|
view->getCamera()->setName("Cam three");
|
||||||
view->getCamera()->setProjectionMatrixAsPerspective(30.0, double(traits->width) / double(traits->height/2), 1.0, 1000.0);
|
view->getCamera()->setProjectionMatrixAsPerspective(30.0, double(traits->width) / double(traits->height/2), 1.0, 1000.0);
|
||||||
|
@ -63,7 +63,7 @@ int main( int argc, char** argv )
|
|||||||
// Create a node for outputting to the texture.
|
// Create a node for outputting to the texture.
|
||||||
// It is OK to have just an empty node here, but seems inbuilt uniforms like osg_FrameTime won't work then.
|
// It is OK to have just an empty node here, but seems inbuilt uniforms like osg_FrameTime won't work then.
|
||||||
// TODO: maybe we can have a custom drawable which also will implement glMemoryBarrier?
|
// TODO: maybe we can have a custom drawable which also will implement glMemoryBarrier?
|
||||||
osg::Node* sourceNode = osgDB::readNodeFile("axes.osgt");
|
osg::ref_ptr<osg::Node> sourceNode = osgDB::readRefNodeFile("axes.osgt");
|
||||||
if ( !sourceNode ) sourceNode = new osg::Node;
|
if ( !sourceNode ) sourceNode = new osg::Node;
|
||||||
sourceNode->setDataVariance( osg::Object::DYNAMIC );
|
sourceNode->setDataVariance( osg::Object::DYNAMIC );
|
||||||
sourceNode->getOrCreateStateSet()->setAttributeAndModes( computeProg.get() );
|
sourceNode->getOrCreateStateSet()->setAttributeAndModes( computeProg.get() );
|
||||||
|
@ -198,7 +198,7 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!rootnode)
|
if (!rootnode)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl;
|
osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl;
|
||||||
|
@ -95,10 +95,10 @@ int main(int argc, char *argv[])
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!rootnode) rootnode = osgDB::readNodeFile("cessna.osgt");
|
if (!rootnode) rootnode = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
|
|
||||||
if (!rootnode)
|
if (!rootnode)
|
||||||
{
|
{
|
||||||
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create specular highlights
|
// create specular highlights
|
||||||
create_specular_highlights(rootnode);
|
create_specular_highlights(rootnode.get());
|
||||||
|
|
||||||
// run optimization over the scene graph
|
// run optimization over the scene graph
|
||||||
osgUtil::Optimizer optimzer;
|
osgUtil::Optimizer optimzer;
|
||||||
|
@ -129,7 +129,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(file);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(file);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -224,7 +224,7 @@ public:
|
|||||||
osg::StateSet *dstate= gm->getOrCreateStateSet( );
|
osg::StateSet *dstate= gm->getOrCreateStateSet( );
|
||||||
dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON );
|
dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON );
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/Brick-Std-Orange.TGA");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/Brick-Std-Orange.TGA");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* txt = new osg::Texture2D;
|
osg::Texture2D* txt = new osg::Texture2D;
|
||||||
@ -354,7 +354,7 @@ osg::Group *makedelaunay(const int ndcs)
|
|||||||
|
|
||||||
osg::Vec3Array *points=new osg::Vec3Array;
|
osg::Vec3Array *points=new osg::Vec3Array;
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/blueFlowers.png");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/blueFlowers.png");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
@ -817,7 +817,7 @@ osg::Geometry *WallConstraint::makeWallGeometry() const
|
|||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the wall
|
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the wall
|
||||||
if (texture!="") {
|
if (texture!="") {
|
||||||
osg::Image* image = osgDB::readImageFile(texture.c_str());
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(texture.c_str());
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* txt = new osg::Texture2D;
|
osg::Texture2D* txt = new osg::Texture2D;
|
||||||
@ -1005,7 +1005,7 @@ deprecated_osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
|
|||||||
tscx->retessellatePolygons(*(edges)); // find all edges
|
tscx->retessellatePolygons(*(edges)); // find all edges
|
||||||
|
|
||||||
if (walltexture!="") {
|
if (walltexture!="") {
|
||||||
osg::Image* image = osgDB::readImageFile(walltexture.c_str());
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(walltexture.c_str());
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* txt = new osg::Texture2D;
|
osg::Texture2D* txt = new osg::Texture2D;
|
||||||
@ -1062,7 +1062,7 @@ deprecated_osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
|
|||||||
gm->setNormalArray(getCanopyNormals(points));
|
gm->setNormalArray(getCanopyNormals(points));
|
||||||
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||||
gm->setTexCoordArray(0,getCanopyTexcoords(points));
|
gm->setTexCoordArray(0,getCanopyTexcoords(points));
|
||||||
osg::Image* image = osgDB::readImageFile(texture);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(texture);
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* txt = new osg::Texture2D;
|
osg::Texture2D* txt = new osg::Texture2D;
|
||||||
@ -1238,7 +1238,7 @@ deprecated_osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *
|
|||||||
if (_midline->size()>0) {
|
if (_midline->size()>0) {
|
||||||
osg::ref_ptr<osg::Vec3Array> locpts=getPoints(points);
|
osg::ref_ptr<osg::Vec3Array> locpts=getPoints(points);
|
||||||
if (texture!="") {
|
if (texture!="") {
|
||||||
osg::Image* image = osgDB::readImageFile(texture.c_str());
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(texture.c_str());
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* txt = new osg::Texture2D;
|
osg::Texture2D* txt = new osg::Texture2D;
|
||||||
|
@ -139,7 +139,7 @@ int main( int argc, char **argv )
|
|||||||
bool needToSetHomePosition = false;
|
bool needToSetHomePosition = false;
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if one hasn't been loaded create an earth and sun test model.
|
// if one hasn't been loaded create an earth and sun test model.
|
||||||
if (!scene)
|
if (!scene)
|
||||||
|
@ -232,7 +232,7 @@ int main( int argc, char **argv )
|
|||||||
viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||||
|
|
||||||
// read the model to do depth peeling with
|
// read the model to do depth peeling with
|
||||||
osg::Node* loadedModel = osgDB::readNodeFile(arguments.argv()[1]);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(arguments.argv()[1]);
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -703,10 +703,10 @@ int main(int argc, char** argv)
|
|||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -731,7 +731,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::Node* distortionNode = createDistortionSubgraph( options, loadedModel, viewer.getCamera()->getClearColor());
|
osg::Node* distortionNode = createDistortionSubgraph( options, loadedModel.get(), viewer.getCamera()->getClearColor());
|
||||||
viewer.setSceneData( distortionNode );
|
viewer.setSceneData( distortionNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ createStateSet()
|
|||||||
ss->setAttribute( program.get(),
|
ss->setAttribute( program.get(),
|
||||||
osg::StateAttribute::ON | osg::StateAttribute::PROTECTED );
|
osg::StateAttribute::ON | osg::StateAttribute::PROTECTED );
|
||||||
|
|
||||||
osg::ref_ptr< osg::Image> iLogo = osgDB::readImageFile( "Images/osg128.png" );
|
osg::ref_ptr< osg::Image> iLogo = osgDB::readRefImageFile( "Images/osg128.png" );
|
||||||
if( !iLogo.valid() )
|
if( !iLogo.valid() )
|
||||||
{
|
{
|
||||||
osg::notify( osg::ALWAYS ) << "Can't open image file osg128.png" << std::endl;
|
osg::notify( osg::ALWAYS ) << "Can't open image file osg128.png" << std::endl;
|
||||||
|
@ -51,7 +51,7 @@ osg::Node* createEarth()
|
|||||||
geode->addDrawable(sd);
|
geode->addDrawable(sd);
|
||||||
|
|
||||||
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
||||||
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename)));
|
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readRefImageFile(filename)));
|
||||||
|
|
||||||
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
|
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
|
||||||
csn->setEllipsoidModel(new osg::EllipsoidModel());
|
csn->setEllipsoidModel(new osg::EllipsoidModel());
|
||||||
|
@ -62,7 +62,7 @@ osgText::Text* createLabel(const std::string& l, const char* f, unsigned int siz
|
|||||||
static osg::Vec3 pos(10.0f, 10.0f, 0.0f);
|
static osg::Vec3 pos(10.0f, 10.0f, 0.0f);
|
||||||
|
|
||||||
osgText::Text* label = new osgText::Text();
|
osgText::Text* label = new osgText::Text();
|
||||||
osgText::Font* font = osgText::readFontFile(f);
|
osg::ref_ptr<osgText::Font> font = osgText::readRefFontFile(f);
|
||||||
|
|
||||||
label->setFont(font);
|
label->setFont(font);
|
||||||
label->setCharacterSize(size);
|
label->setCharacterSize(size);
|
||||||
|
@ -388,7 +388,7 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
|||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
osg::StateSet* stateset = new osg::StateSet();
|
osg::StateSet* stateset = new osg::StateSet();
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/lz.rgb");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
@ -1182,7 +1182,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
|
|||||||
osg::Texture2D *tex = new osg::Texture2D;
|
osg::Texture2D *tex = new osg::Texture2D;
|
||||||
tex->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP );
|
tex->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP );
|
||||||
tex->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP );
|
tex->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP );
|
||||||
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
|
tex->setImage(osgDB::readRefImageFile("Images/tree0.rgba"));
|
||||||
|
|
||||||
osg::StateSet *dstate = new osg::StateSet;
|
osg::StateSet *dstate = new osg::StateSet;
|
||||||
{
|
{
|
||||||
|
@ -963,7 +963,7 @@ int main(int argc, char **argv)
|
|||||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ref_ptr<Node> loadedModel = osgDB::readNodeFiles(arguments);
|
ref_ptr<Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel) {
|
if (!loadedModel) {
|
||||||
cerr << "couldn't load " << argv[1] << "\n";
|
cerr << "couldn't load " << argv[1] << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -175,10 +175,10 @@ protected:
|
|||||||
float zPos = -0.1; // note from Robert, was 0.1f, but now must be -0.1f to keep text visible??#!? due
|
float zPos = -0.1; // note from Robert, was 0.1f, but now must be -0.1f to keep text visible??#!? due
|
||||||
// to some other change in the OSG not tracked down yet...
|
// to some other change in the OSG not tracked down yet...
|
||||||
|
|
||||||
osg::ref_ptr<osgText::Font> arial = osgText::readFontFile("fonts/arial.ttf");
|
osg::ref_ptr<osgText::Font> arial = osgText::readRefFontFile("fonts/arial.ttf");
|
||||||
|
|
||||||
osg::ref_ptr<osgText::Text> hints = new osgText::Text;
|
osg::ref_ptr<osgText::Text> hints = new osgText::Text;
|
||||||
hints->setFont(arial.get());
|
hints->setFont(arial);
|
||||||
hints->setColor(_hints_color);
|
hints->setColor(_hints_color);
|
||||||
hints->setAlignment(osgText::Text::CENTER_BOTTOM);
|
hints->setAlignment(osgText::Text::CENTER_BOTTOM);
|
||||||
hints->setCharacterSize(13);
|
hints->setCharacterSize(13);
|
||||||
@ -336,10 +336,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("dumptruck.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("dumptruck.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
|
@ -117,14 +117,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the image
|
// load the image
|
||||||
osg::ref_ptr<osg::Image> startIm = osgDB::readImageFile(startName);
|
osg::ref_ptr<osg::Image> startIm = osgDB::readRefImageFile(startName);
|
||||||
|
|
||||||
if (!startIm) {
|
if (!startIm) {
|
||||||
std::cout << "Could not load start image.\n";
|
std::cout << "Could not load start image.\n";
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* scene = createScene(startIm.get());
|
osg::ref_ptr<osg::Node> scene = createScene(startIm.get());
|
||||||
|
|
||||||
// construct the viewer.
|
// construct the viewer.
|
||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
@ -550,7 +550,7 @@ osg::Node* createBackground()
|
|||||||
{
|
{
|
||||||
|
|
||||||
// we'll create a texture mapped quad to sit behind the Geometry
|
// we'll create a texture mapped quad to sit behind the Geometry
|
||||||
osg::Image* image = osgDB::readImageFile("Images/primitives.gif");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/primitives.gif");
|
||||||
if (!image) return NULL;
|
if (!image) return NULL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,8 +434,8 @@ int main(int argv, char **argc)
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (loadedModel.valid()) group->addChild(loadedModel.get());
|
if (loadedModel.valid()) group->addChild(loadedModel);
|
||||||
|
|
||||||
for(Tracks::iterator itr = tracks.begin();
|
for(Tracks::iterator itr = tracks.begin();
|
||||||
itr != tracks.end();
|
itr != tracks.end();
|
||||||
|
@ -52,12 +52,12 @@ int main(int argc, char** argv)
|
|||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
osg::ref_ptr<osg::GraphicsCostEstimator> gce = new osg::GraphicsCostEstimator;
|
osg::ref_ptr<osg::GraphicsCostEstimator> gce = new osg::GraphicsCostEstimator;
|
||||||
|
|
||||||
viewer.setSceneData(node.get());
|
viewer.setSceneData(node);
|
||||||
|
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ Node *makeBase( void )
|
|||||||
|
|
||||||
Texture2D *tex = new Texture2D;
|
Texture2D *tex = new Texture2D;
|
||||||
|
|
||||||
tex->setImage(osgDB::readImageFile("Images/water.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/water.rgb"));
|
||||||
tex->setWrap( Texture2D::WRAP_S, Texture2D::REPEAT );
|
tex->setWrap( Texture2D::WRAP_S, Texture2D::REPEAT );
|
||||||
tex->setWrap( Texture2D::WRAP_T, Texture2D::REPEAT );
|
tex->setWrap( Texture2D::WRAP_T, Texture2D::REPEAT );
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ Node *makeSky( void )
|
|||||||
|
|
||||||
|
|
||||||
Texture2D *tex = new Texture2D;
|
Texture2D *tex = new Texture2D;
|
||||||
tex->setImage(osgDB::readImageFile("Images/white.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/white.rgb"));
|
||||||
|
|
||||||
StateSet *dstate = new StateSet;
|
StateSet *dstate = new StateSet;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ Node *makeTank( void )
|
|||||||
|
|
||||||
tex->setWrap( Texture2D::WRAP_S, Texture2D::REPEAT );
|
tex->setWrap( Texture2D::WRAP_S, Texture2D::REPEAT );
|
||||||
tex->setWrap( Texture2D::WRAP_T, Texture2D::REPEAT );
|
tex->setWrap( Texture2D::WRAP_T, Texture2D::REPEAT );
|
||||||
tex->setImage(osgDB::readImageFile("Images/tank.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/tank.rgb"));
|
||||||
|
|
||||||
StateSet *dstate = new StateSet;
|
StateSet *dstate = new StateSet;
|
||||||
dstate->setTextureAttributeAndModes(0, tex, StateAttribute::ON );
|
dstate->setTextureAttributeAndModes(0, tex, StateAttribute::ON );
|
||||||
|
@ -131,7 +131,7 @@ Node *makeTerrain( void )
|
|||||||
|
|
||||||
Texture2D *tex = new Texture2D;
|
Texture2D *tex = new Texture2D;
|
||||||
|
|
||||||
tex->setImage(osgDB::readImageFile("Images/lz.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/lz.rgb"));
|
||||||
|
|
||||||
StateSet *dstate = new StateSet;
|
StateSet *dstate = new StateSet;
|
||||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||||
|
@ -234,7 +234,7 @@ Node *makeTrees( void )
|
|||||||
struct _tree *t;
|
struct _tree *t;
|
||||||
|
|
||||||
Texture2D *tex = new Texture2D;
|
Texture2D *tex = new Texture2D;
|
||||||
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
|
tex->setImage(osgDB::readRefImageFile("Images/tree0.rgba"));
|
||||||
|
|
||||||
StateSet *dstate = new StateSet;
|
StateSet *dstate = new StateSet;
|
||||||
|
|
||||||
|
@ -284,10 +284,10 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default model instead.
|
// if not loaded assume no arguments passed in, try use default model instead.
|
||||||
if (!scene) scene = osgDB::readNodeFile("dumptruck.osgt");
|
if (!scene) scene = osgDB::readRefNodeFile("dumptruck.osgt");
|
||||||
|
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
@ -320,7 +320,7 @@ int main( int argc, char **argv )
|
|||||||
viewer.addSlave(hudCamera, false);
|
viewer.addSlave(hudCamera, false);
|
||||||
|
|
||||||
// set the scene to render
|
// set the scene to render
|
||||||
viewer.setSceneData(scene.get());
|
viewer.setSceneData(scene);
|
||||||
|
|
||||||
return viewer.run();
|
return viewer.run();
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::View* view = new osgViewer::View;
|
osgViewer::View* view = new osgViewer::View;
|
||||||
viewer.addView(view);
|
viewer.addView(view);
|
||||||
|
|
||||||
view->setSceneData(scene.get());
|
view->setSceneData(scene);
|
||||||
view->setUpViewAcrossAllScreens();;
|
view->setUpViewAcrossAllScreens();;
|
||||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||||
|
|
||||||
@ -375,11 +375,11 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
|
|
||||||
// add the HUD subgraph.
|
// add the HUD subgraph.
|
||||||
if (scene.valid()) group->addChild(scene.get());
|
if (scene.valid()) group->addChild(scene);
|
||||||
group->addChild(createHUD());
|
group->addChild(createHUD());
|
||||||
|
|
||||||
// set the scene to render
|
// set the scene to render
|
||||||
viewer.setSceneData(group.get());
|
viewer.setSceneData(group);
|
||||||
|
|
||||||
return viewer.run();
|
return viewer.run();
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
|
|||||||
const std::string& filename = *itr;
|
const std::string& filename = *itr;
|
||||||
if (preLoad)
|
if (preLoad)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
|
||||||
if (image.valid())
|
if (image.valid())
|
||||||
{
|
{
|
||||||
imageSequence->addImage(image.get());
|
imageSequence->addImage(image.get());
|
||||||
@ -144,12 +144,12 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
|
|||||||
{
|
{
|
||||||
imageSequence->setLength(4.0);
|
imageSequence->setLength(4.0);
|
||||||
}
|
}
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/posx.png"));
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/negx.png"));
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/posy.png"));
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/negy.png"));
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/posz.png"));
|
||||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png"));
|
imageSequence->addImage(osgDB::readRefImageFile("Cubemap_axis/negz.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the image sequence playing
|
// start the image sequence playing
|
||||||
|
@ -244,7 +244,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFiles(arguments);
|
||||||
if (model)
|
if (model)
|
||||||
{
|
{
|
||||||
// the osgSim::InsertImpostorsVisitor used lower down to insert impostors
|
// the osgSim::InsertImpostorsVisitor used lower down to insert impostors
|
||||||
@ -280,7 +280,7 @@ int main( int argc, char **argv )
|
|||||||
// on it right now as it requires a getRoots() method to be added to
|
// 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::Node, and we're about to make a release so no new features!
|
||||||
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
|
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
|
||||||
rootnode->addChild(model.get());
|
rootnode->addChild(model);
|
||||||
|
|
||||||
|
|
||||||
// now insert impostors in the model using the InsertImpostorsVisitor.
|
// now insert impostors in the model using the InsertImpostorsVisitor.
|
||||||
@ -304,7 +304,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add model to viewer.
|
// add model to viewer.
|
||||||
viewer.setSceneData(model.get());
|
viewer.setSceneData(model);
|
||||||
|
|
||||||
return viewer.run();
|
return viewer.run();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ struct MyReadCallback : public osgUtil::IntersectionVisitor::ReadCallback
|
|||||||
{
|
{
|
||||||
virtual osg::Node* readNodeFile(const std::string& filename)
|
virtual osg::Node* readNodeFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
return osgDB::readNodeFile(filename);
|
return osgDB::readRefNodeFile(filename).release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ int main(int argc, char **argv)
|
|||||||
// use an ArgumentParser object to manage the program arguments.
|
// use an ArgumentParser object to manage the program arguments.
|
||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
|
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
@ -65,6 +65,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
viewer.setSceneData(scene.get());
|
viewer.setSceneData(scene);
|
||||||
return viewer.run();
|
return viewer.run();
|
||||||
}
|
}
|
||||||
|
@ -341,10 +341,10 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Node> loadedModel;
|
osg::ref_ptr<osg::Node> loadedModel;
|
||||||
|
|
||||||
// load the scene.
|
// load the scene.
|
||||||
if (argc>1) loadedModel = osgDB::readNodeFile(argv[1]);
|
if (argc>1) loadedModel = osgDB::readRefNodeFile(argv[1]);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("dumptruck.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("dumptruck.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -374,7 +374,7 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
viewer.getCamera()->setGraphicsContext(gc.get());
|
viewer.getCamera()->setGraphicsContext(gc.get());
|
||||||
viewer.getCamera()->setViewport(0,0,800,600);
|
viewer.getCamera()->setViewport(0,0,800,600);
|
||||||
viewer.setSceneData(loadedModel.get());
|
viewer.setSceneData(loadedModel);
|
||||||
|
|
||||||
// create a tracball manipulator to move the camera around in response to keyboard/mouse events
|
// create a tracball manipulator to move the camera around in response to keyboard/mouse events
|
||||||
viewer.setCameraManipulator( new osgGA::TrackballManipulator );
|
viewer.setCameraManipulator( new osgGA::TrackballManipulator );
|
||||||
|
@ -45,7 +45,7 @@ int main( int argc, char **argv )
|
|||||||
osg::DisplaySettings* ds = viewer.getDisplaySettings() ? viewer.getDisplaySettings() : osg::DisplaySettings::instance().get();
|
osg::DisplaySettings* ds = viewer.getDisplaySettings() ? viewer.getDisplaySettings() : osg::DisplaySettings::instance().get();
|
||||||
ds->readCommandLine(arguments);
|
ds->readCommandLine(arguments);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!model)
|
if (!model)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ int main( int argc, char **argv )
|
|||||||
OSG_NOTICE<<"Stereo "<<ds->getStereo()<<std::endl;
|
OSG_NOTICE<<"Stereo "<<ds->getStereo()<<std::endl;
|
||||||
OSG_NOTICE<<"StereoMode "<<ds->getStereoMode()<<std::endl;
|
OSG_NOTICE<<"StereoMode "<<ds->getStereoMode()<<std::endl;
|
||||||
|
|
||||||
viewer.setSceneData(model.get());
|
viewer.setSceneData(model);
|
||||||
|
|
||||||
// add the state manipulator
|
// add the state manipulator
|
||||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||||
|
@ -291,7 +291,7 @@ void SetObjectTextureState(osg::Geode *geodeCurrent, std::string texture)
|
|||||||
osg::StateSet* stateTexture = geodeCurrent->getOrCreateStateSet();
|
osg::StateSet* stateTexture = geodeCurrent->getOrCreateStateSet();
|
||||||
|
|
||||||
// load texture.jpg as an image
|
// load texture.jpg as an image
|
||||||
osg::Image* imgTexture = osgDB::readImageFile( texture );
|
osg::ref_ptr<osg::Image> imgTexture = osgDB::readRefImageFile( texture );
|
||||||
|
|
||||||
// if the image is successfully loaded
|
// if the image is successfully loaded
|
||||||
if (imgTexture)
|
if (imgTexture)
|
||||||
|
@ -226,7 +226,7 @@ osg::Geometry* createWall(const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
osg::Node* createRoom(osg::Node* loadedModel)
|
osg::ref_ptr<osg::Node> createRoom(const osg::ref_ptr<osg::Node>& loadedModel)
|
||||||
{
|
{
|
||||||
// default scale for this model.
|
// default scale for this model.
|
||||||
osg::BoundingSphere bs(osg::Vec3(0.0f,0.0f,0.0f),1.0f);
|
osg::BoundingSphere bs(osg::Vec3(0.0f,0.0f,0.0f),1.0f);
|
||||||
@ -323,20 +323,20 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("glider.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("glider.osgt");
|
||||||
|
|
||||||
// create a room made of foor walls, a floor, a roof, and swinging light fitting.
|
// create a room made of foor walls, a floor, a roof, and swinging light fitting.
|
||||||
osg::Node* rootnode = createRoom(loadedModel);
|
osg::ref_ptr<osg::Node> rootnode = createRoom(loadedModel);
|
||||||
|
|
||||||
// run optimization over the scene graph
|
// run optimization over the scene graph
|
||||||
osgUtil::Optimizer optimzer;
|
osgUtil::Optimizer optimzer;
|
||||||
optimzer.optimize(rootnode);
|
optimzer.optimize(rootnode);
|
||||||
|
|
||||||
// add a viewport to the viewer and attach the scene graph.
|
// add a viewport to the viewer and attach the scene graph.
|
||||||
viewer.setSceneData( rootnode );
|
viewer.setSceneData(rootnode);
|
||||||
|
|
||||||
|
|
||||||
// create the windows and run the threads.
|
// create the windows and run the threads.
|
||||||
|
@ -129,7 +129,7 @@ osg::Node* createLightPointsDatabase()
|
|||||||
|
|
||||||
// Set point sprite texture in LightPointNode StateSet.
|
// Set point sprite texture in LightPointNode StateSet.
|
||||||
osg::Texture2D *tex = new osg::Texture2D();
|
osg::Texture2D *tex = new osg::Texture2D();
|
||||||
tex->setImage(osgDB::readImageFile("Images/particle.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/particle.rgb"));
|
||||||
set->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
set->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ int main( int argc, char **argv )
|
|||||||
osg::Group* rootnode = new osg::Group;
|
osg::Group* rootnode = new osg::Group;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
rootnode->addChild(osgDB::readNodeFiles(arguments));
|
rootnode->addChild(osgDB::readRefNodeFiles(arguments));
|
||||||
rootnode->addChild(createLightPointsDatabase());
|
rootnode->addChild(createLightPointsDatabase());
|
||||||
rootnode->addChild(CreateBlinkSequenceLightNode());
|
rootnode->addChild(CreateBlinkSequenceLightNode());
|
||||||
|
|
||||||
|
@ -142,10 +142,10 @@ int main( int argc, char **argv )
|
|||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("glider.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("glider.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -153,11 +153,11 @@ int main( int argc, char **argv )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Group* root = new osg::Group;
|
osg::ref_ptr<osg::Group> root = new osg::Group;
|
||||||
root->addChild(loadedModel);
|
root->addChild(loadedModel);
|
||||||
|
|
||||||
osg::StateSet* stateset = new osg::StateSet;
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||||
osg::LogicOp* logicOp = new osg::LogicOp(osg::LogicOp::OR_INVERTED);
|
osg::ref_ptr<osg::LogicOp> logicOp = new osg::LogicOp(osg::LogicOp::OR_INVERTED);
|
||||||
|
|
||||||
stateset->setAttributeAndModes(logicOp,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(logicOp,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ int main( int argc, char **argv )
|
|||||||
// construct the viewer.
|
// construct the viewer.
|
||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
viewer.addEventHandler(new TechniqueEventHandler(logicOp));
|
viewer.addEventHandler(new TechniqueEventHandler(logicOp.get()));
|
||||||
|
|
||||||
// run optimization over the scene graph
|
// run optimization over the scene graph
|
||||||
osgUtil::Optimizer optimzer;
|
osgUtil::Optimizer optimzer;
|
||||||
|
@ -234,7 +234,7 @@ osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio, const std::strin
|
|||||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
||||||
xform->setUpdateCallback(new osg::AnimationPathCallback(bb.center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(10.0f)));
|
xform->setUpdateCallback(new osg::AnimationPathCallback(bb.center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(10.0f)));
|
||||||
|
|
||||||
osg::Node* bluemarble = filename.empty() ? 0 : osgDB::readNodeFile(filename.c_str());
|
osg::ref_ptr<osg::Node> bluemarble = filename.empty() ? 0 : osgDB::readRefNodeFile(filename.c_str());
|
||||||
if (bluemarble)
|
if (bluemarble)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = bluemarble->getBound();
|
const osg::BoundingSphere& bs = bluemarble->getBound();
|
||||||
@ -252,7 +252,7 @@ osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio, const std::strin
|
|||||||
|
|
||||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/land_shallow_topo_2048.jpg");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/land_shallow_topo_2048.jpg");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
|
@ -453,7 +453,7 @@ int main( int argc, char **argv )
|
|||||||
osg::Timer_t start_tick = osg::Timer::instance()->tick();
|
osg::Timer_t start_tick = osg::Timer::instance()->tick();
|
||||||
|
|
||||||
// read the scene from the list of file specified command line args.
|
// read the scene from the list of file specified command line args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
bool tragger2Scene(true);
|
bool tragger2Scene(true);
|
||||||
@ -481,14 +481,14 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
// optimize the scene graph, remove redundant nodes and state etc.
|
// optimize the scene graph, remove redundant nodes and state etc.
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(loadedModel.get());
|
optimizer.optimize(loadedModel);
|
||||||
|
|
||||||
|
|
||||||
// pass the loaded scene graph to the viewer.
|
// pass the loaded scene graph to the viewer.
|
||||||
if ( tragger2Scene ) {
|
if ( tragger2Scene ) {
|
||||||
viewer.setSceneData(addDraggerToScene(loadedModel.get(), dragger_name, fixedSizeInScreen));
|
viewer.setSceneData(addDraggerToScene(loadedModel.get(), dragger_name, fixedSizeInScreen));
|
||||||
} else {
|
} else {
|
||||||
viewer.setSceneData(loadedModel.get());
|
viewer.setSceneData(loadedModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,10 +96,10 @@ int main( int argc, char **argv )
|
|||||||
arguments.read("-P", persistence) || arguments.read("--persistence", persistence);
|
arguments.read("-P", persistence) || arguments.read("--persistence", persistence);
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
|
@ -520,8 +520,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
if (arguments.isString(i))
|
if (arguments.isString(i))
|
||||||
{
|
{
|
||||||
osg::Image* image = osgDB::readImageFile(arguments[i]);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(arguments[i]);
|
||||||
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
|
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image.get());
|
||||||
if (imagestream)
|
if (imagestream)
|
||||||
{
|
{
|
||||||
osg::ImageStream::AudioStreams& audioStreams = imagestream->getAudioStreams();
|
osg::ImageStream::AudioStreams& audioStreams = imagestream->getAudioStreams();
|
||||||
@ -550,7 +550,7 @@ int main(int argc, char** argv)
|
|||||||
float width = image->s() * image->getPixelAspectRatio();
|
float width = image->s() * image->getPixelAspectRatio();
|
||||||
float height = image->t();
|
float height = image->t();
|
||||||
|
|
||||||
osg::ref_ptr<osg::Drawable> drawable = myCreateTexturedQuadGeometry(pos, width, height,image, useTextureRectangle, xyPlane, flip);
|
osg::ref_ptr<osg::Drawable> drawable = myCreateTexturedQuadGeometry(pos, width, height, image.get(), useTextureRectangle, xyPlane, flip);
|
||||||
|
|
||||||
if (image->isImageTranslucent())
|
if (image->isImageTranslucent())
|
||||||
{
|
{
|
||||||
|
@ -362,7 +362,7 @@ private:
|
|||||||
|
|
||||||
static osg::Node* readImageStream(const std::string& file_name, osg::Vec3& p, float desired_height, osgDB::Options* options)
|
static osg::Node* readImageStream(const std::string& file_name, osg::Vec3& p, float desired_height, osgDB::Options* options)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Object> obj = osgDB::readObjectFile(file_name, options);
|
osg::ref_ptr<osg::Object> obj = osgDB::readRefObjectFile(file_name, options);
|
||||||
osg::ref_ptr<osg::Texture> tex = dynamic_cast<osg::Texture*>(obj.get());
|
osg::ref_ptr<osg::Texture> tex = dynamic_cast<osg::Texture*>(obj.get());
|
||||||
osg::Geometry* geo(NULL);
|
osg::Geometry* geo(NULL);
|
||||||
float w(0);
|
float w(0);
|
||||||
@ -374,7 +374,7 @@ static osg::Node* readImageStream(const std::string& file_name, osg::Vec3& p, fl
|
|||||||
// try readImageFile if readObjectFile failed
|
// try readImageFile if readObjectFile failed
|
||||||
if (!img_stream)
|
if (!img_stream)
|
||||||
{
|
{
|
||||||
img_stream = dynamic_cast<osg::ImageStream*>(osgDB::readImageFile(file_name, options));
|
img_stream = osgDB::readRefFile<osg::ImageStream>(file_name, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img_stream)
|
if (img_stream)
|
||||||
@ -531,7 +531,9 @@ private:
|
|||||||
if (!tex) {
|
if (!tex) {
|
||||||
osg::ref_ptr<osg::ImageStream> stream = dynamic_cast<osg::ImageStream*>(obj.get());
|
osg::ref_ptr<osg::ImageStream> stream = dynamic_cast<osg::ImageStream*>(obj.get());
|
||||||
if (!stream)
|
if (!stream)
|
||||||
stream = dynamic_cast<osg::ImageStream*>(osgDB::readImageFile(_files[_currentFile], _options.get()));
|
{
|
||||||
|
stream = osgDB::readRefFile<osg::ImageStream>(_files[_currentFile], _options.get());
|
||||||
|
}
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
|
@ -44,10 +44,10 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!rootnode) rootnode = osgDB::readNodeFile("cessnafire.osgt");
|
if (!rootnode) rootnode = osgDB::readRefNodeFile("cessnafire.osgt");
|
||||||
|
|
||||||
if (!rootnode)
|
if (!rootnode)
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ int main( int argc, char **argv )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/reflect.rgb");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/reflect.rgb");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
|
@ -72,8 +72,8 @@ public:
|
|||||||
T* _foundNode;
|
T* _foundNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T, class R>
|
||||||
T* findTopMostNodeOfType(osg::Node* node)
|
T* findTopMostNodeOfType(R node)
|
||||||
{
|
{
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ int main( int argc, char **argv )
|
|||||||
// set up the scene graph
|
// set up the scene graph
|
||||||
{
|
{
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> rootnode = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!rootnode)
|
if (!rootnode)
|
||||||
{
|
{
|
||||||
|
@ -284,10 +284,10 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default model instead.
|
// if not loaded assume no arguments passed in, try use default model instead.
|
||||||
if (!scene) scene = osgDB::readNodeFile("dumptruck.osgt");
|
if (!scene) scene = osgDB::readRefNodeFile("dumptruck.osgt");
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
@ -307,10 +307,10 @@ int main( int argc, char **argv )
|
|||||||
std::string device;
|
std::string device;
|
||||||
while(arguments.read("--device", device))
|
while(arguments.read("--device", device))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device);
|
osg::ref_ptr<osgGA::Device> dev = osgDB::readRefFile<osgGA::Device>(device);
|
||||||
if (dev.valid())
|
if (dev.valid())
|
||||||
{
|
{
|
||||||
viewer.addDevice(dev.get());
|
viewer.addDevice(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
|
|
||||||
// add the HUD subgraph.
|
// add the HUD subgraph.
|
||||||
if (scene.valid()) group->addChild(scene.get());
|
if (scene) group->addChild(scene);
|
||||||
|
|
||||||
viewer.setCameraManipulator(new osgGA::MultiTouchTrackballManipulator());
|
viewer.setCameraManipulator(new osgGA::MultiTouchTrackballManipulator());
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
@ -64,11 +64,11 @@ int main( int argc, char **argv )
|
|||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
scene = osgDB::readNodeFile("http://www.openscenegraph.org/data/earth_bayarea/earth.ive");
|
scene = osgDB::readRefNodeFile("http://www.openscenegraph.org/data/earth_bayarea/earth.ive");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
@ -123,7 +123,7 @@ int main( int argc, char **argv )
|
|||||||
view->setName("View one");
|
view->setName("View one");
|
||||||
viewer.addView(view);
|
viewer.addView(view);
|
||||||
|
|
||||||
view->setSceneData(scene.get());
|
view->setSceneData(scene);
|
||||||
view->getCamera()->setName("Cam one");
|
view->getCamera()->setName("Cam one");
|
||||||
view->getCamera()->setViewport(new osg::Viewport(0,0, traits->width/2, traits->height/2));
|
view->getCamera()->setViewport(new osg::Viewport(0,0, traits->width/2, traits->height/2));
|
||||||
view->getCamera()->setGraphicsContext(gc.get());
|
view->getCamera()->setGraphicsContext(gc.get());
|
||||||
@ -148,7 +148,7 @@ int main( int argc, char **argv )
|
|||||||
view->setName("View two");
|
view->setName("View two");
|
||||||
viewer.addView(view);
|
viewer.addView(view);
|
||||||
|
|
||||||
view->setSceneData(scene.get());
|
view->setSceneData(scene);
|
||||||
view->getCamera()->setName("Cam two");
|
view->getCamera()->setName("Cam two");
|
||||||
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, traits->width/2, traits->height/2));
|
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, traits->width/2, traits->height/2));
|
||||||
view->getCamera()->setGraphicsContext(gc.get());
|
view->getCamera()->setGraphicsContext(gc.get());
|
||||||
@ -162,7 +162,7 @@ int main( int argc, char **argv )
|
|||||||
view->setName("View three");
|
view->setName("View three");
|
||||||
viewer.addView(view);
|
viewer.addView(view);
|
||||||
|
|
||||||
view->setSceneData(scene.get());
|
view->setSceneData(scene);
|
||||||
|
|
||||||
view->getCamera()->setName("Cam three");
|
view->getCamera()->setName("Cam three");
|
||||||
view->getCamera()->setProjectionMatrixAsPerspective(30.0, double(traits->width) / double(traits->height/2), 1.0, 1000.0);
|
view->getCamera()->setProjectionMatrixAsPerspective(30.0, double(traits->width) / double(traits->height/2), 1.0, 1000.0);
|
||||||
|
@ -311,10 +311,10 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedmodel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedmodel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try using default mode instead.
|
// if not loaded assume no arguments passed in, try using default mode instead.
|
||||||
if (!loadedmodel) loadedmodel = osgDB::readNodeFile("glider.osgt");
|
if (!loadedmodel) loadedmodel = osgDB::readRefNodeFile("glider.osgt");
|
||||||
|
|
||||||
if (!loadedmodel)
|
if (!loadedmodel)
|
||||||
{
|
{
|
||||||
@ -336,12 +336,12 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rootnode = createOccludersAroundModel(loadedmodel);
|
rootnode = createOccludersAroundModel(loadedmodel.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// add a viewport to the viewer and attach the scene graph.
|
// add a viewport to the viewer and attach the scene graph.
|
||||||
viewer.setSceneData( rootnode.get() );
|
viewer.setSceneData( rootnode );
|
||||||
|
|
||||||
return viewer.run();
|
return viewer.run();
|
||||||
}
|
}
|
||||||
|
@ -749,8 +749,8 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
if (arguments.argc()>1)
|
if (arguments.argc()>1)
|
||||||
{
|
{
|
||||||
root = osgDB::readNodeFiles( arguments );
|
root = osgDB::readRefNodeFiles( arguments );
|
||||||
if (root.valid())
|
if (root)
|
||||||
{
|
{
|
||||||
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
|
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
|
||||||
OcclusionQueryVisitor oqv;
|
OcclusionQueryVisitor oqv;
|
||||||
@ -787,10 +787,10 @@ int main(int argc, char** argv)
|
|||||||
if (optimize)
|
if (optimize)
|
||||||
{
|
{
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize( root.get() );
|
optimizer.optimize( root );
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.setSceneData( root.get() );
|
viewer.setSceneData( root );
|
||||||
|
|
||||||
KeyHandler* kh = new KeyHandler( *root );
|
KeyHandler* kh = new KeyHandler( *root );
|
||||||
viewer.addEventHandler( kh );
|
viewer.addEventHandler( kh );
|
||||||
|
@ -66,12 +66,12 @@ int main(int argc, char** argv)
|
|||||||
arguments.reportRemainingOptionsAsUnrecognized();
|
arguments.reportRemainingOptionsAsUnrecognized();
|
||||||
|
|
||||||
// read the dump truck, we will need it twice
|
// read the dump truck, we will need it twice
|
||||||
osg::ref_ptr<osg::Node> dt = osgDB::readNodeFile("dumptruck.osg");
|
osg::ref_ptr<osg::Node> dt = osgDB::readRefNodeFile("dumptruck.osg");
|
||||||
|
|
||||||
// display a solid version of the dump truck
|
// display a solid version of the dump truck
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> solidModel = new osg::PositionAttitudeTransform;
|
osg::ref_ptr<osg::PositionAttitudeTransform> solidModel = new osg::PositionAttitudeTransform;
|
||||||
solidModel->setPosition(osg::Vec3f(7.0f, -2.0f, 7.0f));
|
solidModel->setPosition(osg::Vec3f(7.0f, -2.0f, 7.0f));
|
||||||
solidModel->addChild(dt.get());
|
solidModel->addChild(dt);
|
||||||
|
|
||||||
// generate the 3D heatmap surface to display
|
// generate the 3D heatmap surface to display
|
||||||
osg::ref_ptr<Heatmap> hm = new Heatmap(30, 30, 10, 30, 30, 1.0, 0.25);
|
osg::ref_ptr<Heatmap> hm = new Heatmap(30, 30, 10, 30, 30, 1.0, 0.25);
|
||||||
|
@ -377,7 +377,7 @@ public:
|
|||||||
|
|
||||||
std::ostringstream ss ;
|
std::ostringstream ss ;
|
||||||
ss << host << ":" << port << ".sender.osc";
|
ss << host << ":" << port << ".sender.osc";
|
||||||
_device = osgDB::readFile<osgGA::Device>(ss.str());
|
_device = osgDB::readRefFile<osgGA::Device>(ss.str());
|
||||||
|
|
||||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||||
osgViewer::View* view = ev ? dynamic_cast<osgViewer::View*>(ev->getActionAdapter()) : NULL;
|
osgViewer::View* view = ev ? dynamic_cast<osgViewer::View*>(ev->getActionAdapter()) : NULL;
|
||||||
@ -403,7 +403,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
@ -463,15 +463,15 @@ int main( int argc, char **argv )
|
|||||||
view->addEventHandler( new osgViewer::StatsHandler );
|
view->addEventHandler( new osgViewer::StatsHandler );
|
||||||
view->addEventHandler( new UserEventHandler(text) );
|
view->addEventHandler( new UserEventHandler(text) );
|
||||||
|
|
||||||
osg::ref_ptr<osgGA::Device> device = osgDB::readFile<osgGA::Device>("0.0.0.0:9000.receiver.osc");
|
osg::ref_ptr<osgGA::Device> device = osgDB::readRefFile<osgGA::Device>("0.0.0.0:9000.receiver.osc");
|
||||||
if (device.valid() && (device->getCapabilities() & osgGA::Device::RECEIVE_EVENTS))
|
if (device.valid() && (device->getCapabilities() & osgGA::Device::RECEIVE_EVENTS))
|
||||||
{
|
{
|
||||||
view->addDevice(device.get());
|
view->addDevice(device);
|
||||||
|
|
||||||
// add a zeroconf device, advertising the osc-device
|
// add a zeroconf device, advertising the osc-device
|
||||||
if(use_zeroconf)
|
if(use_zeroconf)
|
||||||
{
|
{
|
||||||
osgGA::Device* zeroconf_device = osgDB::readFile<osgGA::Device>("_osc._udp:9000.advertise.zeroconf");
|
osg::ref_ptr<osgGA::Device> zeroconf_device = osgDB::readRefFile<osgGA::Device>("_osc._udp:9000.advertise.zeroconf");
|
||||||
if (zeroconf_device)
|
if (zeroconf_device)
|
||||||
{
|
{
|
||||||
view->addDevice(zeroconf_device);
|
view->addDevice(zeroconf_device);
|
||||||
@ -527,7 +527,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
if (use_zeroconf)
|
if (use_zeroconf)
|
||||||
{
|
{
|
||||||
osgGA::Device* zeroconf_device = osgDB::readFile<osgGA::Device>("_osc._udp.discover.zeroconf");
|
osg::ref_ptr<osgGA::Device> zeroconf_device = osgDB::readRefFile<osgGA::Device>("_osc._udp.discover.zeroconf");
|
||||||
if(zeroconf_device) {
|
if(zeroconf_device) {
|
||||||
view->addDevice(zeroconf_device);
|
view->addDevice(zeroconf_device);
|
||||||
view->getEventHandlers().push_front(new OscServiceDiscoveredEventHandler());
|
view->getEventHandlers().push_front(new OscServiceDiscoveredEventHandler());
|
||||||
@ -536,7 +536,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgGA::Device> device = osgDB::readFile<osgGA::Device>("localhost:9000.sender.osc");
|
osg::ref_ptr<osgGA::Device> device = osgDB::readRefFile<osgGA::Device>("localhost:9000.sender.osc");
|
||||||
if (device.valid() && (device->getCapabilities() & osgGA::Device::SEND_EVENTS))
|
if (device.valid() && (device->getCapabilities() & osgGA::Device::SEND_EVENTS))
|
||||||
{
|
{
|
||||||
// add as first event handler, so it gets ALL events ...
|
// add as first event handler, so it gets ALL events ...
|
||||||
|
@ -25,7 +25,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// load outlined object
|
// load outlined object
|
||||||
std::string modelFilename = arguments.argc() > 1 ? arguments[1] : "dumptruck.osgt";
|
std::string modelFilename = arguments.argc() > 1 ? arguments[1] : "dumptruck.osgt";
|
||||||
osg::ref_ptr<osg::Node> outlineModel = osgDB::readNodeFile(modelFilename);
|
osg::ref_ptr<osg::Node> outlineModel = osgDB::readRefNodeFile(modelFilename);
|
||||||
if (!outlineModel)
|
if (!outlineModel)
|
||||||
{
|
{
|
||||||
osg::notify(osg::FATAL) << "Unable to load model '" << modelFilename << "'\n";
|
osg::notify(osg::FATAL) << "Unable to load model '" << modelFilename << "'\n";
|
||||||
@ -38,18 +38,18 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
// create outline effect
|
// create outline effect
|
||||||
osg::ref_ptr<osgFX::Outline> outline = new osgFX::Outline;
|
osg::ref_ptr<osgFX::Outline> outline = new osgFX::Outline;
|
||||||
root->addChild(outline.get());
|
root->addChild(outline);
|
||||||
|
|
||||||
outline->setWidth(8);
|
outline->setWidth(8);
|
||||||
outline->setColor(osg::Vec4(1,1,0,1));
|
outline->setColor(osg::Vec4(1,1,0,1));
|
||||||
outline->addChild(outlineModel.get());
|
outline->addChild(outlineModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testOcclusion)
|
if (testOcclusion)
|
||||||
{
|
{
|
||||||
// load occluder
|
// load occluder
|
||||||
std::string occludedModelFilename = "cow.osgt";
|
std::string occludedModelFilename = "cow.osgt";
|
||||||
osg::ref_ptr<osg::Node> occludedModel = osgDB::readNodeFile(occludedModelFilename);
|
osg::ref_ptr<osg::Node> occludedModel = osgDB::readRefNodeFile(occludedModelFilename);
|
||||||
if (!occludedModel)
|
if (!occludedModel)
|
||||||
{
|
{
|
||||||
osg::notify(osg::FATAL) << "Unable to load model '" << occludedModelFilename << "'\n";
|
osg::notify(osg::FATAL) << "Unable to load model '" << occludedModelFilename << "'\n";
|
||||||
@ -63,14 +63,14 @@ int main(int argc, char** argv)
|
|||||||
// occluder behind outlined model
|
// occluder behind outlined model
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> modelTransform0 = new osg::PositionAttitudeTransform;
|
osg::ref_ptr<osg::PositionAttitudeTransform> modelTransform0 = new osg::PositionAttitudeTransform;
|
||||||
modelTransform0->setPosition(bsphere.center() + occluderOffset);
|
modelTransform0->setPosition(bsphere.center() + occluderOffset);
|
||||||
modelTransform0->addChild(occludedModel.get());
|
modelTransform0->addChild(occludedModel);
|
||||||
root->addChild(modelTransform0.get());
|
root->addChild(modelTransform0);
|
||||||
|
|
||||||
// occluder in front of outlined model
|
// occluder in front of outlined model
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> modelTransform1 = new osg::PositionAttitudeTransform;
|
osg::ref_ptr<osg::PositionAttitudeTransform> modelTransform1 = new osg::PositionAttitudeTransform;
|
||||||
modelTransform1->setPosition(bsphere.center() - occluderOffset);
|
modelTransform1->setPosition(bsphere.center() - occluderOffset);
|
||||||
modelTransform1->addChild(occludedModel.get());
|
modelTransform1->addChild(occludedModel);
|
||||||
root->addChild(modelTransform1.get());
|
root->addChild(modelTransform1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// must have stencil buffer...
|
// must have stencil buffer...
|
||||||
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// construct the viewer
|
// construct the viewer
|
||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
viewer.setSceneData(root.get());
|
viewer.setSceneData(root);
|
||||||
|
|
||||||
// must clear stencil buffer...
|
// must clear stencil buffer...
|
||||||
unsigned int clearMask = viewer.getCamera()->getClearMask();
|
unsigned int clearMask = viewer.getCamera()->getClearMask();
|
||||||
|
@ -254,7 +254,7 @@ int main( int argc, char **argv )
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!model)
|
if (!model)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile
|
|||||||
osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource_texture);
|
osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource_texture);
|
||||||
program->addShader(vertex_shader);
|
program->addShader(vertex_shader);
|
||||||
|
|
||||||
osg::Image* image = 0;
|
osg::ref_ptr<osg::Image> image;
|
||||||
|
|
||||||
if (terrainFileName.empty())
|
if (terrainFileName.empty())
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = osgDB::readImageFile(terrainFileName);
|
image = osgDB::readRefImageFile(terrainFileName);
|
||||||
|
|
||||||
num_x = image->s();
|
num_x = image->s();
|
||||||
num_y = image->t();
|
num_y = image->t();
|
||||||
@ -206,7 +206,7 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile
|
|||||||
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
|
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
|
||||||
program->addShader(fragment_shader);
|
program->addShader(fragment_shader);
|
||||||
|
|
||||||
osg::Texture2D* texture = new osg::Texture2D(osgDB::readImageFile(textureFileName));
|
osg::Texture2D* texture = new osg::Texture2D(osgDB::readRefImageFile(textureFileName));
|
||||||
stateset->setTextureAttributeAndModes(0,texture);
|
stateset->setTextureAttributeAndModes(0,texture);
|
||||||
|
|
||||||
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
|
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
|
||||||
|
@ -77,9 +77,9 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
|
|
||||||
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
|
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
|
||||||
|
|
||||||
osg::Group* model = new osg::Group;
|
osg::ref_ptr<osg::Group> model = new osg::Group;
|
||||||
|
|
||||||
osg::Node* glider = osgDB::readNodeFile("glider.osgt");
|
osg::ref_ptr<osg::Node> glider = osgDB::readRefNodeFile("glider.osgt");
|
||||||
if (glider)
|
if (glider)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = glider->getBound();
|
const osg::BoundingSphere& bs = glider->getBound();
|
||||||
@ -102,7 +102,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osgt");
|
osg::ref_ptr<osg::Node> cessna = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
if (cessna)
|
if (cessna)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = cessna->getBound();
|
const osg::BoundingSphere& bs = cessna->getBound();
|
||||||
@ -126,7 +126,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,8 +162,8 @@ void build_world(osg::Group *root)
|
|||||||
osg::Geode* terrainGeode = new osg::Geode;
|
osg::Geode* terrainGeode = new osg::Geode;
|
||||||
// create terrain
|
// create terrain
|
||||||
{
|
{
|
||||||
osg::StateSet* stateset = new osg::StateSet();
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet();
|
||||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/lz.rgb");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
|
@ -75,21 +75,20 @@ std::string ImageReaderWriter::local_insertReference(const std::string& fileName
|
|||||||
return myReference;
|
return myReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Image* ImageReaderWriter::readImage_Archive(DataReference& dr, float& s,float& t)
|
osg::ref_ptr<osg::Image> ImageReaderWriter::readImage_Archive(DataReference& dr, float& s,float& t)
|
||||||
{
|
{
|
||||||
for(PhotoArchiveList::iterator itr=_photoArchiveList.begin();
|
for(PhotoArchiveList::iterator itr=_photoArchiveList.begin();
|
||||||
itr!=_photoArchiveList.end();
|
itr!=_photoArchiveList.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
osg::Image* image = (*itr)->readImage(dr._fileName,dr._resolutionX,dr._resolutionY,s,t);
|
osg::ref_ptr<osg::Image> image = (*itr)->readImage(dr._fileName,dr._resolutionX,dr._resolutionY,s,t);
|
||||||
if (image) return image;
|
if (image) return image;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Image* ImageReaderWriter::readImage_DynamicSampling(DataReference& dr, float& s,float& t)
|
osg::ref_ptr<osg::Image> ImageReaderWriter::readImage_DynamicSampling(DataReference& dr, float& s,float& t)
|
||||||
{
|
{
|
||||||
|
|
||||||
// record previous options.
|
// record previous options.
|
||||||
osg::ref_ptr<osgDB::ReaderWriter::Options> previousOptions = osgDB::Registry::instance()->getOptions();
|
osg::ref_ptr<osgDB::ReaderWriter::Options> previousOptions = osgDB::Registry::instance()->getOptions();
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ osg::Image* ImageReaderWriter::readImage_DynamicSampling(DataReference& dr, floa
|
|||||||
|
|
||||||
osgDB::Registry::instance()->setOptions(options.get());
|
osgDB::Registry::instance()->setOptions(options.get());
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile(dr._fileName);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(dr._fileName);
|
||||||
|
|
||||||
// restore previous options.
|
// restore previous options.
|
||||||
osgDB::Registry::instance()->setOptions(previousOptions.get());
|
osgDB::Registry::instance()->setOptions(previousOptions.get());
|
||||||
@ -119,7 +118,7 @@ osgDB::ReaderWriter::ReadResult ImageReaderWriter::local_readNode(const std::str
|
|||||||
|
|
||||||
DataReference& dr = itr->second;
|
DataReference& dr = itr->second;
|
||||||
|
|
||||||
osg::Image* image = 0;
|
osg::ref_ptr<osg::Image> image;
|
||||||
float s=1.0f,t=1.0f;
|
float s=1.0f,t=1.0f;
|
||||||
|
|
||||||
// try to load photo from any loaded PhotoArchives
|
// try to load photo from any loaded PhotoArchives
|
||||||
|
@ -80,9 +80,9 @@ class ImageReaderWriter : public osgDB::ReaderWriter
|
|||||||
bool _backPage;
|
bool _backPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
osg::Image* readImage_Archive(DataReference& dr, float& s,float& t);
|
osg::ref_ptr<osg::Image> readImage_Archive(DataReference& dr, float& s,float& t);
|
||||||
|
|
||||||
osg::Image* readImage_DynamicSampling(DataReference& dr, float& s,float& t);
|
osg::ref_ptr<osg::Image> readImage_DynamicSampling(DataReference& dr, float& s,float& t);
|
||||||
|
|
||||||
typedef std::map< std::string,DataReference > DataReferenceMap;
|
typedef std::map< std::string,DataReference > DataReferenceMap;
|
||||||
typedef std::vector< osg::ref_ptr<PhotoArchive> > PhotoArchiveList;
|
typedef std::vector< osg::ref_ptr<PhotoArchive> > PhotoArchiveList;
|
||||||
|
@ -72,7 +72,7 @@ void PhotoArchive::getImageFileNameList(FileNameList& filenameList)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Image* PhotoArchive::readImage(const std::string& filename,
|
osg::ref_ptr<osg::Image> PhotoArchive::readImage(const std::string& filename,
|
||||||
unsigned int target_s, unsigned target_t,
|
unsigned int target_s, unsigned target_t,
|
||||||
float& original_s, float& original_t)
|
float& original_s, float& original_t)
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ osg::Image* PhotoArchive::readImage(const std::string& filename,
|
|||||||
unsigned char* data = new unsigned char[imageHeader.size];
|
unsigned char* data = new unsigned char[imageHeader.size];
|
||||||
in.read((char*)data,imageHeader.size);
|
in.read((char*)data,imageHeader.size);
|
||||||
|
|
||||||
osg::Image* image = new osg::Image;
|
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||||
image->setImage(photoHeader.thumbnail_s,photoHeader.thumbnail_t,1,
|
image->setImage(photoHeader.thumbnail_s,photoHeader.thumbnail_t,1,
|
||||||
imageHeader.pixelFormat,imageHeader.pixelFormat,imageHeader.type,
|
imageHeader.pixelFormat,imageHeader.pixelFormat,imageHeader.type,
|
||||||
data,osg::Image::USE_NEW_DELETE);
|
data,osg::Image::USE_NEW_DELETE);
|
||||||
@ -125,7 +125,7 @@ osg::Image* PhotoArchive::readImage(const std::string& filename,
|
|||||||
unsigned char* data = new unsigned char[imageHeader.size];
|
unsigned char* data = new unsigned char[imageHeader.size];
|
||||||
in.read((char*)data,imageHeader.size);
|
in.read((char*)data,imageHeader.size);
|
||||||
|
|
||||||
osg::Image* image = new osg::Image;
|
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||||
image->setImage(photoHeader.fullsize_s,photoHeader.fullsize_t,1,
|
image->setImage(photoHeader.fullsize_s,photoHeader.fullsize_t,1,
|
||||||
imageHeader.pixelFormat,imageHeader.pixelFormat,imageHeader.type,
|
imageHeader.pixelFormat,imageHeader.pixelFormat,imageHeader.type,
|
||||||
data,osg::Image::USE_NEW_DELETE);
|
data,osg::Image::USE_NEW_DELETE);
|
||||||
@ -196,7 +196,7 @@ void PhotoArchive::buildArchive(const std::string& filename, const FileNameList&
|
|||||||
std::cout<<"Processing image "<<photoCount<<" of "<< photoIndex.size()<<" filename="<< photoHeader.filename << std::endl;
|
std::cout<<"Processing image "<<photoCount<<" of "<< photoIndex.size()<<" filename="<< photoHeader.filename << std::endl;
|
||||||
std::cout<<" reading image...";std::cout.flush();
|
std::cout<<" reading image...";std::cout.flush();
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(photoHeader.filename);
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(photoHeader.filename);
|
||||||
|
|
||||||
std::cout<<"done."<< std::endl;
|
std::cout<<"done."<< std::endl;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
static void buildArchive(const std::string& filename, const FileNameList& imageList, unsigned int thumbnailSize=256, unsigned int maximumSize=1024, bool compressed=true);
|
static void buildArchive(const std::string& filename, const FileNameList& imageList, unsigned int thumbnailSize=256, unsigned int maximumSize=1024, bool compressed=true);
|
||||||
|
|
||||||
osg::Image* readImage(const std::string& filename,
|
osg::ref_ptr<osg::Image> readImage(const std::string& filename,
|
||||||
unsigned int target_s, unsigned target_t,
|
unsigned int target_s, unsigned target_t,
|
||||||
float& original_s, float& original_t);
|
float& original_s, float& original_t);
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ int main( int argc, char **argv )
|
|||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!scene && arguments.read("--relative-camera-scene"))
|
if (!scene && arguments.read("--relative-camera-scene"))
|
||||||
{
|
{
|
||||||
@ -271,7 +271,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!scene) scene = osgDB::readNodeFile("fountain.osgt");
|
if (!scene) scene = osgDB::readRefNodeFile("fountain.osgt");
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = dynamic_cast<osg::Group*>(scene.get());
|
osg::ref_ptr<osg::Group> group = dynamic_cast<osg::Group*>(scene.get());
|
||||||
if (!group)
|
if (!group)
|
||||||
|
@ -366,7 +366,7 @@ osg::Geode* SolarSystem::createSpace( const std::string& name, const std::string
|
|||||||
|
|
||||||
if( !textureName.empty() )
|
if( !textureName.empty() )
|
||||||
{
|
{
|
||||||
osg::Image* image = osgDB::readImageFile( textureName );
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile( textureName );
|
||||||
if ( image )
|
if ( image )
|
||||||
{
|
{
|
||||||
sSpaceSphere->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D( image ), osg::StateAttribute::ON );
|
sSpaceSphere->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D( image ), osg::StateAttribute::ON );
|
||||||
@ -467,7 +467,7 @@ osg::Geode* SolarSystem::createPlanet( double radius, const std::string& name, c
|
|||||||
|
|
||||||
if( !textureName.empty() )
|
if( !textureName.empty() )
|
||||||
{
|
{
|
||||||
osg::Image* image = osgDB::readImageFile( textureName );
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile( textureName );
|
||||||
if ( image )
|
if ( image )
|
||||||
{
|
{
|
||||||
osg::Texture2D* tex2d = new osg::Texture2D( image );
|
osg::Texture2D* tex2d = new osg::Texture2D( image );
|
||||||
@ -493,7 +493,7 @@ osg::Geode* SolarSystem::createPlanet( double radius, const std::string& name, c
|
|||||||
|
|
||||||
if( !textureName2.empty() )
|
if( !textureName2.empty() )
|
||||||
{
|
{
|
||||||
osg::Image* image = osgDB::readImageFile( textureName2 );
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile( textureName2 );
|
||||||
if ( image )
|
if ( image )
|
||||||
{
|
{
|
||||||
osg::StateSet* stateset = geodePlanet->getOrCreateStateSet();
|
osg::StateSet* stateset = geodePlanet->getOrCreateStateSet();
|
||||||
|
@ -145,7 +145,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
@ -176,7 +176,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
/// The texture for the sprites
|
/// The texture for the sprites
|
||||||
osg::Texture2D *tex = new osg::Texture2D();
|
osg::Texture2D *tex = new osg::Texture2D();
|
||||||
tex->setImage(osgDB::readImageFile("Images/particle.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/particle.rgb"));
|
||||||
stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ osg::StateSet* makeStateSet(float size)
|
|||||||
|
|
||||||
/// The texture for the sprites
|
/// The texture for the sprites
|
||||||
osg::Texture2D *tex = new osg::Texture2D();
|
osg::Texture2D *tex = new osg::Texture2D();
|
||||||
tex->setImage(osgDB::readImageFile("Images/particle.rgb"));
|
tex->setImage(osgDB::readRefImageFile("Images/particle.rgb"));
|
||||||
set->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
set->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
|
@ -11,7 +11,7 @@ struct PagedLoadingCallback : public osgUtil::IntersectionVisitor::ReadCallback
|
|||||||
{
|
{
|
||||||
virtual osg::Node* readNodeFile( const std::string& filename )
|
virtual osg::Node* readNodeFile( const std::string& filename )
|
||||||
{
|
{
|
||||||
return osgDB::readNodeFile( filename );
|
return osgDB::readRefNodeFile( filename ).release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static osg::ref_ptr<PagedLoadingCallback> g_pagedLoadingCallback = new PagedLoadingCallback;
|
static osg::ref_ptr<PagedLoadingCallback> g_pagedLoadingCallback = new PagedLoadingCallback;
|
||||||
|
@ -298,8 +298,8 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct scene graph
|
// Construct scene graph
|
||||||
osg::Node* scene = osgDB::readNodeFiles( arguments );
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles( arguments );
|
||||||
if ( !scene ) scene = osgDB::readNodeFile( "cow.osgt" );
|
if ( !scene ) scene = osgDB::readRefNodeFile( "cow.osgt" );
|
||||||
if ( !scene )
|
if ( !scene )
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
@ -373,7 +373,7 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
osg::Camera* camera = viewer.getCamera();
|
osg::Camera* camera = viewer.getCamera();
|
||||||
if ( !useLatLongHeight ) computeViewMatrix( camera, eye, hpr );
|
if ( !useLatLongHeight ) computeViewMatrix( camera, eye, hpr );
|
||||||
else computeViewMatrixOnEarth( camera, scene, latLongHeight, hpr );
|
else computeViewMatrixOnEarth( camera, scene.get(), latLongHeight, hpr );
|
||||||
|
|
||||||
osg::ref_ptr<CustomRenderer> renderer = new CustomRenderer( camera );
|
osg::ref_ptr<CustomRenderer> renderer = new CustomRenderer( camera );
|
||||||
camera->setRenderer( renderer.get() );
|
camera->setRenderer( renderer.get() );
|
||||||
|
@ -175,7 +175,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -463,10 +463,10 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cessna.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ osg::StateSet* createMirrorTexturedState(const std::string& filename)
|
|||||||
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED);
|
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED);
|
||||||
|
|
||||||
// set up the texture.
|
// set up the texture.
|
||||||
osg::Image* image = osgDB::readImageFile(filename.c_str());
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename.c_str());
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
@ -335,10 +335,10 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// read the scene from the list of file specified commandline args.
|
// read the scene from the list of file specified commandline args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cessna.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
@ -350,11 +350,11 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
// optimize the scene graph, remove redundant nodes and state etc.
|
// optimize the scene graph, remove redundant nodes and state etc.
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(loadedModel.get());
|
optimizer.optimize(loadedModel);
|
||||||
|
|
||||||
// add a transform with a callback to animate the loaded model.
|
// add a transform with a callback to animate the loaded model.
|
||||||
osg::ref_ptr<osg::MatrixTransform> loadedModelTransform = new osg::MatrixTransform;
|
osg::ref_ptr<osg::MatrixTransform> loadedModelTransform = new osg::MatrixTransform;
|
||||||
loadedModelTransform->addChild(loadedModel.get());
|
loadedModelTransform->addChild(loadedModel);
|
||||||
|
|
||||||
osg::ref_ptr<osg::NodeCallback> nc = new osg::AnimationPathCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
osg::ref_ptr<osg::NodeCallback> nc = new osg::AnimationPathCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||||
loadedModelTransform->setUpdateCallback(nc.get());
|
loadedModelTransform->setUpdateCallback(nc.get());
|
||||||
@ -364,7 +364,7 @@ int main( int argc, char **argv )
|
|||||||
osg::ref_ptr<osg::Node> rootNode = createMirroredScene(loadedModelTransform.get());
|
osg::ref_ptr<osg::Node> rootNode = createMirroredScene(loadedModelTransform.get());
|
||||||
|
|
||||||
// set the scene to render
|
// set the scene to render
|
||||||
viewer.setSceneData(rootNode.get());
|
viewer.setSceneData(rootNode);
|
||||||
|
|
||||||
// hint to tell viewer to request stencil buffer when setting up windows
|
// hint to tell viewer to request stencil buffer when setting up windows
|
||||||
osg::DisplaySettings::instance()->setMinimumNumStencilBits(8);
|
osg::DisplaySettings::instance()->setMinimumNumStencilBits(8);
|
||||||
|
@ -726,7 +726,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
@ -746,9 +746,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// optimize the scene graph, remove redundant nodes and state etc.
|
// optimize the scene graph, remove redundant nodes and state etc.
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(loadedModel.get());
|
optimizer.optimize(loadedModel);
|
||||||
|
|
||||||
viewer.setSceneData( loadedModel.get() );
|
viewer.setSceneData(loadedModel);
|
||||||
|
|
||||||
|
|
||||||
if (pbuffer.valid())
|
if (pbuffer.valid())
|
||||||
|
@ -40,10 +40,10 @@ int main( int argc, char **argv )
|
|||||||
osgViewer::Viewer viewer;
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// load the nodes from the commandline arguments.
|
// load the nodes from the commandline arguments.
|
||||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
if (!loadedModel) loadedModel = osgDB::readRefNodeFile("cow.osgt");
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
@ -56,9 +56,9 @@ int main( int argc, char **argv )
|
|||||||
// but overrides various state attributes, so that the second instance
|
// but overrides various state attributes, so that the second instance
|
||||||
// is rendered as wireframe.
|
// is rendered as wireframe.
|
||||||
|
|
||||||
osg::Group* rootnode = new osg::Group;
|
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
|
||||||
|
|
||||||
osg::Group* decorator = new osg::Group;
|
osg::ref_ptr<osg::Group> decorator = new osg::Group;
|
||||||
|
|
||||||
rootnode->addChild(loadedModel);
|
rootnode->addChild(loadedModel);
|
||||||
|
|
||||||
@ -71,17 +71,17 @@ int main( int argc, char **argv )
|
|||||||
// and that the drawing mode is changed to wireframe, and a polygon offset
|
// and that the drawing mode is changed to wireframe, and a polygon offset
|
||||||
// is added to ensure that we see the wireframe itself, and turn off
|
// is added to ensure that we see the wireframe itself, and turn off
|
||||||
// so texturing too.
|
// so texturing too.
|
||||||
osg::StateSet* stateset = new osg::StateSet;
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||||
osg::PolygonOffset* polyoffset = new osg::PolygonOffset;
|
osg::ref_ptr<osg::PolygonOffset> polyoffset = new osg::PolygonOffset;
|
||||||
polyoffset->setFactor(-1.0f);
|
polyoffset->setFactor(-1.0f);
|
||||||
polyoffset->setUnits(-1.0f);
|
polyoffset->setUnits(-1.0f);
|
||||||
osg::PolygonMode* polymode = new osg::PolygonMode;
|
osg::ref_ptr<osg::PolygonMode> polymode = new osg::PolygonMode;
|
||||||
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
|
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
|
||||||
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||||
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
osg::Material* material = new osg::Material;
|
osg::ref_ptr<osg::Material> material = new osg::Material;
|
||||||
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
|
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
|
||||||
#else
|
#else
|
||||||
|
@ -145,11 +145,11 @@ osg::Sequence* createSequence(osg::ArgumentParser& arguments)
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
// load model
|
// load model
|
||||||
osg::Node* node = osgDB::readNodeFile(*itr);
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(*itr);
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
seq->addChild(createScaledNode(node, 100.0f));
|
seq->addChild(createScaledNode(node.get(), 100.0f));
|
||||||
seq->setTime(seq->getNumChildren()-1, 1.0f);
|
seq->setTime(seq->getNumChildren()-1, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
osg::Node* createOldShaderCompositionScene(osg::ArgumentParser& arguments)
|
osg::Node* createOldShaderCompositionScene(osg::ArgumentParser& arguments)
|
||||||
{
|
{
|
||||||
osg::Node* node = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
osg::Group* group = new osg::Group;
|
osg::Group* group = new osg::Group;
|
||||||
|
@ -25,7 +25,7 @@ extern osg::Node* createOldShaderCompositionScene(osg::ArgumentParser& arguments
|
|||||||
|
|
||||||
osg::Node* createNewShaderCompositionScene(osg::ArgumentParser& arguments)
|
osg::Node* createNewShaderCompositionScene(osg::ArgumentParser& arguments)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
@ -34,21 +34,21 @@ osg::Node* createNewShaderCompositionScene(osg::ArgumentParser& arguments)
|
|||||||
osg::ref_ptr<osg::Program> program = new osg::Program;
|
osg::ref_ptr<osg::Program> program = new osg::Program;
|
||||||
stateset->setAttribute(program.get());
|
stateset->setAttribute(program.get());
|
||||||
|
|
||||||
osg::ref_ptr<osg::Shader> lighting_shader = osgDB::readShaderFile("shaders/lighting.vert");
|
osg::ref_ptr<osg::Shader> lighting_shader = osgDB::readRefShaderFile("shaders/lighting.vert");
|
||||||
if (lighting_shader.valid())
|
if (lighting_shader.valid())
|
||||||
{
|
{
|
||||||
program->addShader(lighting_shader.get());
|
program->addShader(lighting_shader.get());
|
||||||
OSG_NOTICE<<"Adding lighting shader"<<std::endl;
|
OSG_NOTICE<<"Adding lighting shader"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Shader> vertex_shader = osgDB::readShaderFile("shaders/osgshadercomposition.vert");
|
osg::ref_ptr<osg::Shader> vertex_shader = osgDB::readRefShaderFile("shaders/osgshadercomposition.vert");
|
||||||
if (vertex_shader.valid())
|
if (vertex_shader.valid())
|
||||||
{
|
{
|
||||||
program->addShader(vertex_shader.get());
|
program->addShader(vertex_shader.get());
|
||||||
OSG_NOTICE<<"Adding vertex shader"<<std::endl;
|
OSG_NOTICE<<"Adding vertex shader"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Shader> fragment_shader = osgDB::readShaderFile("shaders/osgshadercomposition.frag");
|
osg::ref_ptr<osg::Shader> fragment_shader = osgDB::readRefShaderFile("shaders/osgshadercomposition.frag");
|
||||||
if (fragment_shader.valid())
|
if (fragment_shader.valid())
|
||||||
{
|
{
|
||||||
program->addShader(fragment_shader.get());
|
program->addShader(fragment_shader.get());
|
||||||
|
@ -141,7 +141,7 @@ int main(int argc, char** argv)
|
|||||||
osgDB::Registry::instance()->setReadFileCallback(readFileCallback);
|
osgDB::Registry::instance()->setReadFileCallback(readFileCallback);
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
@ -121,7 +121,7 @@ osg::Node* createScene()
|
|||||||
stateset->setTextureAttributeAndModes(0,terrainTexture,osg::StateAttribute::ON);
|
stateset->setTextureAttributeAndModes(0,terrainTexture,osg::StateAttribute::ON);
|
||||||
|
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/lz.rgb");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
|
@ -390,7 +390,7 @@ namespace ModelTwo
|
|||||||
|
|
||||||
// set up the texture of the base.
|
// set up the texture of the base.
|
||||||
osg::StateSet* stateset = new osg::StateSet();
|
osg::StateSet* stateset = new osg::StateSet();
|
||||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("Images/lz.rgb");
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
@ -451,7 +451,7 @@ namespace ModelTwo
|
|||||||
|
|
||||||
osg::Group* model = new osg::Group;
|
osg::Group* model = new osg::Group;
|
||||||
|
|
||||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osgt");
|
osg::ref_ptr<osg::Node> cessna = osgDB::readRefNodeFile("cessna.osgt");
|
||||||
if (cessna)
|
if (cessna)
|
||||||
{
|
{
|
||||||
const osg::BoundingSphere& bs = cessna->getBound();
|
const osg::BoundingSphere& bs = cessna->getBound();
|
||||||
@ -571,7 +571,7 @@ namespace ModelThree
|
|||||||
|
|
||||||
if (withBaseTexture)
|
if (withBaseTexture)
|
||||||
{
|
{
|
||||||
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
|
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readRefImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
@ -626,13 +626,13 @@ namespace ModelFive
|
|||||||
{
|
{
|
||||||
// Set the ground (only receives shadow)
|
// Set the ground (only receives shadow)
|
||||||
osg::ref_ptr<osg::MatrixTransform> groundNode = new osg::MatrixTransform;
|
osg::ref_ptr<osg::MatrixTransform> groundNode = new osg::MatrixTransform;
|
||||||
groundNode->addChild( osgDB::readNodeFile("lz.osg") );
|
groundNode->addChild( osgDB::readRefNodeFile("lz.osg") );
|
||||||
groundNode->setMatrix( osg::Matrix::translate(200.0f, 200.0f,-200.0f) );
|
groundNode->setMatrix( osg::Matrix::translate(200.0f, 200.0f,-200.0f) );
|
||||||
groundNode->setNodeMask( ReceivesShadowTraversalMask );
|
groundNode->setNodeMask( ReceivesShadowTraversalMask );
|
||||||
|
|
||||||
// Set the cessna (only casts shadow)
|
// Set the cessna (only casts shadow)
|
||||||
osg::ref_ptr<osg::MatrixTransform> cessnaNode = new osg::MatrixTransform;
|
osg::ref_ptr<osg::MatrixTransform> cessnaNode = new osg::MatrixTransform;
|
||||||
cessnaNode->addChild( osgDB::readNodeFile("cessna.osg.0,0,90.rot") );
|
cessnaNode->addChild( osgDB::readRefNodeFile("cessna.osg.0,0,90.rot") );
|
||||||
cessnaNode->addUpdateCallback( createAnimationPathCallback(50.0f, 6.0f) );
|
cessnaNode->addUpdateCallback( createAnimationPathCallback(50.0f, 6.0f) );
|
||||||
cessnaNode->setNodeMask( CastsShadowTraversalMask );
|
cessnaNode->setNodeMask( CastsShadowTraversalMask );
|
||||||
|
|
||||||
@ -1025,7 +1025,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
OSG_INFO<<"shadowedScene->getShadowTechnique()="<<shadowedScene->getShadowTechnique()<<std::endl;
|
OSG_INFO<<"shadowedScene->getShadowTechnique()="<<shadowedScene->getShadowTechnique()<<std::endl;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFiles(arguments);
|
||||||
if (model.valid())
|
if (model.valid())
|
||||||
{
|
{
|
||||||
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
|
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
|
||||||
@ -1061,7 +1061,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
geode->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
|
geode->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
|
||||||
|
|
||||||
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")));
|
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readRefImageFile("Images/lz.rgb")));
|
||||||
|
|
||||||
shadowedScene->addChild(geode);
|
shadowedScene->addChild(geode);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ osg::Geode* createShapes()
|
|||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
osg::StateSet* stateset = new osg::StateSet();
|
osg::StateSet* stateset = new osg::StateSet();
|
||||||
|
|
||||||
osg::Image* image = osgDB::readImageFile( "Images/lz.rgb" );
|
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile( "Images/lz.rgb" );
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
osg::Texture2D* texture = new osg::Texture2D;
|
osg::Texture2D* texture = new osg::Texture2D;
|
||||||
|
@ -265,10 +265,8 @@ int main( int argc, char **argv )
|
|||||||
SwitchDOFVisitor* visit = new SwitchDOFVisitor;
|
SwitchDOFVisitor* visit = new SwitchDOFVisitor;
|
||||||
viewer.addEventHandler(visit);
|
viewer.addEventHandler(visit);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> loadedModel;
|
|
||||||
// load the scene.
|
// load the scene.
|
||||||
loadedModel = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
|
||||||
|
|
||||||
if (!loadedModel)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
std::cout << argv[0] <<": No data loaded." << std::endl;
|
std::cout << argv[0] <<": No data loaded." << std::endl;
|
||||||
@ -278,16 +276,14 @@ int main( int argc, char **argv )
|
|||||||
osg::Group* group = new osg::Group;
|
osg::Group* group = new osg::Group;
|
||||||
|
|
||||||
osg::Group* group1 = new osg::Group;
|
osg::Group* group1 = new osg::Group;
|
||||||
group1->addChild(loadedModel.get());
|
group1->addChild(loadedModel);
|
||||||
group1->setNodeMask(1);
|
group1->setNodeMask(1);
|
||||||
|
|
||||||
// Uncomment these lines if you like to compare the loaded model to the resulting model in a merge/diff tool
|
// Uncomment these lines if you like to compare the loaded model to the resulting model in a merge/diff tool
|
||||||
//osgDB::writeNodeFile(*loadedModel.get(), "dummy1.osgt");
|
//osgDB::writeNodeFile(*loadedModel.get(), "dummy1.osgt");
|
||||||
|
|
||||||
osgDB::writeNodeFile(*loadedModel.get(), outputfile);
|
osgDB::writeNodeFile(*loadedModel, outputfile);
|
||||||
osg::ref_ptr<osg::Node> convertedModel = osgDB::readNodeFile(outputfile);
|
osg::ref_ptr<osg::Node> convertedModel = osgDB::readRefNodeFile(outputfile);
|
||||||
|
|
||||||
//osgDB::writeNodeFile(*convertedModel.get(), "dummy2.osgt");
|
|
||||||
|
|
||||||
osg::Group* group2 = new osg::Group;
|
osg::Group* group2 = new osg::Group;
|
||||||
group2->addChild(convertedModel.get());
|
group2->addChild(convertedModel.get());
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user