Added new osgstereoimage demo which loads two stero paired images to create
a 3D via of photographed scene.
This commit is contained in:
@@ -648,6 +648,30 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgtexture"=".\Demos\osgstereo\osgstereo.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name osg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name osgUtil
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name osgDB
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name osgGLUT
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "tga"=".\osgPlugins\tga\tga.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!gmake
|
||||
SHELL=/bin/sh
|
||||
|
||||
DIRS = sgv osgconv osgcube osgscribe osgreflect osgtexture osgimpostor osgviews osgcopy osgbillboard hangglide
|
||||
DIRS = sgv osgconv osgcube osgscribe osgreflect osgtexture osgimpostor osgviews osgcopy osgbillboard osgstereoimage hangglide
|
||||
|
||||
# comment out if you don't have the freetype and GLU1.3 library installed.
|
||||
DIRS += osgtext
|
||||
|
||||
27
src/Demos/osgstereoimage/Makefile
Normal file
27
src/Demos/osgstereoimage/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
#!gmake
|
||||
include $(OSGHOME)/Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
osgstereoimage.cpp
|
||||
|
||||
TARGET = $(OSGHOME)/bin/osgstereoimage
|
||||
|
||||
TARGET_BIN_FILES = osgstereoimage
|
||||
|
||||
#note, use this library list when using the Performer osgPlugin.
|
||||
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||
|
||||
#note, standard library list.
|
||||
LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS)
|
||||
|
||||
#under Darwin we have to use the framework stuff to get GLUT OpenGL etc.
|
||||
MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc
|
||||
|
||||
|
||||
C++FLAGS += -I$(OSGHOME)/include
|
||||
LDFLAGS += -L$(OSGHOME)/lib
|
||||
|
||||
include $(OSGHOME)/Make/makerules
|
||||
|
||||
test :
|
||||
osgstereoimage Images/dog_left_eye.jpg Images/dog_right_eye.jpg
|
||||
140
src/Demos/osgstereoimage/osgstereoimage.cpp
Normal file
140
src/Demos/osgstereoimage/osgstereoimage.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Transform>
|
||||
#include <osg/Texture>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgUtil/FlightManipulator>
|
||||
#include <osgUtil/DriveManipulator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgGLUT/glut>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
|
||||
|
||||
|
||||
void write_usage(std::ostream& out,const std::string& name)
|
||||
{
|
||||
out << std::endl;
|
||||
out <<"usage:"<< std::endl;
|
||||
out <<" "<<name<<" [options] image_left_eye image_right_eye"<< std::endl;
|
||||
out << std::endl;
|
||||
out <<"options:"<< std::endl;
|
||||
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
|
||||
out <<" i.e. -l osgdb_pfb"<< std::endl;
|
||||
out <<" Useful for loading reader/writers which can load"<< std::endl;
|
||||
out <<" other file formats in addition to its extension."<< std::endl;
|
||||
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
|
||||
out <<" i.e. -e pfb"<< std::endl;
|
||||
out <<" Useful short hand for specifying full library name as"<< std::endl;
|
||||
out <<" done with -l above, as it automatically expands to"<< std::endl;
|
||||
out <<" the full library name appropriate for each platform."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
|
||||
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
|
||||
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
|
||||
out <<" further details on setting up accurate stereo "<< std::endl;
|
||||
out <<" for your system. "<< std::endl;
|
||||
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
|
||||
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
|
||||
out <<" also allows the depth complexity statistics mode"<< std::endl;
|
||||
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
|
||||
out << std::endl;
|
||||
out<<"example:"<<std::endl;
|
||||
out<<" Images/dog_left_eye.jpg Images/dog_right_eye.jpg"<<std::endl;
|
||||
out<<std::endl;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
write_usage(osg::notify(osg::NOTICE),argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create the commandline args.
|
||||
std::vector<std::string> commandLine;
|
||||
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
|
||||
|
||||
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.setWindowTitle(argv[0]);
|
||||
|
||||
|
||||
// default to enabling stereo.
|
||||
viewer.getDisplaySettings()->setStereo(true);
|
||||
|
||||
// configure the viewer from the commandline arguments, and eat any
|
||||
// parameters that have been matched.
|
||||
viewer.readCommandLine(commandLine);
|
||||
|
||||
// configure the plugin registry from the commandline arguments, and
|
||||
// eat any parameters that have been matched.
|
||||
osgDB::readCommandLine(commandLine);
|
||||
|
||||
|
||||
if (commandLine.size()<2)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "Please specify two images required for stereo imaging."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
osg::Image* imageLeft = osgDB::readImageFile(commandLine[0]);
|
||||
osg::Image* imageRight = osgDB::readImageFile(commandLine[1]);
|
||||
|
||||
|
||||
if (imageLeft && imageRight)
|
||||
{
|
||||
|
||||
float average_s = (imageLeft->s()+imageRight->s())*0.5f;
|
||||
float average_t = (imageLeft->t()+imageRight->t())*0.5f;
|
||||
|
||||
osg::Geode* geodeLeft = osg::createGeodeForImage(imageLeft,average_s,average_t);
|
||||
geodeLeft->setNodeMask(0x01);
|
||||
|
||||
osg::Geode* geodeRight = osg::createGeodeForImage(imageRight,average_s,average_t);
|
||||
geodeRight->setNodeMask(0x02);
|
||||
|
||||
|
||||
osg::Group* rootNode = new osg::Group;
|
||||
rootNode->addChild(geodeLeft);
|
||||
rootNode->addChild(geodeRight);
|
||||
|
||||
|
||||
// add model to viewer.
|
||||
osgUtil::SceneView* sceneview = new osgUtil::SceneView;
|
||||
sceneview->setDisplaySettings(viewer.getDisplaySettings());
|
||||
sceneview->setDefaults();
|
||||
sceneview->setCullMask(0xffffffff);
|
||||
sceneview->setCullMaskLeft(0x00000001);
|
||||
sceneview->setCullMaskRight(0x00000002);
|
||||
sceneview->setSceneData(rootNode);
|
||||
viewer.addViewport( sceneview );
|
||||
|
||||
// register trackball.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
|
||||
viewer.open();
|
||||
|
||||
viewer.run();
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "Unable to load two images required for stereo imaging."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -157,8 +157,11 @@ void Image::ensureDimensionsArePowerOfTwo()
|
||||
{
|
||||
init = false;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&max_size);
|
||||
std::cout<<"Max texture size "<<max_size<<std::endl;
|
||||
notify(INFO) << "Max texture size "<<max_size<<std::endl;
|
||||
}
|
||||
|
||||
//max_size = 64;
|
||||
|
||||
if (new_s>max_size) new_s = max_size;
|
||||
if (new_t>max_size) new_t = max_size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user