Merge branch 'OpenSceneGraph-3.4' of https://github.com/openscenegraph/OpenSceneGraph into OpenSceneGraph-3.4

This commit is contained in:
Robert Osfield 2018-03-07 09:38:08 +00:00
commit a9f5ce5d91
14 changed files with 223 additions and 207 deletions

View File

@ -24,9 +24,9 @@ matrix:
#- clang-3.8 #- clang-3.8
- g++ - g++
- cmake - cmake
# OSX build # # OSX build
- os: osx # - os: osx
language: cpp # language: cpp
script: script:
- mkdir build - mkdir build

View File

@ -16,7 +16,7 @@ FIND_PATH(NVTT_INCLUDE_DIR nvtt/nvtt.h
) )
# NVTT # NVTT
FIND_LIBRARY(NVTT_LIBRARY FIND_LIBRARY(NVTT_LIBRARY_RELEASE
NAMES nvtt NAMES nvtt
PATHS PATHS
/usr/local /usr/local
@ -37,7 +37,7 @@ FIND_LIBRARY(NVTT_LIBRARY_DEBUG
) )
# NVIMAGE # NVIMAGE
FIND_LIBRARY(NVIMAGE_LIBRARY FIND_LIBRARY(NVIMAGE_LIBRARY_RELEASE
NAMES nvimage NAMES nvimage
PATHS PATHS
/usr/local /usr/local
@ -58,7 +58,7 @@ FIND_LIBRARY(NVIMAGE_LIBRARY_DEBUG
) )
# NVMATH # NVMATH
FIND_LIBRARY(NVMATH_LIBRARY FIND_LIBRARY(NVMATH_LIBRARY_RELEASE
NAMES nvmath NAMES nvmath
PATHS PATHS
/usr/local /usr/local
@ -79,7 +79,7 @@ FIND_LIBRARY(NVMATH_LIBRARY_DEBUG
) )
# NVCORE # NVCORE
FIND_LIBRARY(NVCORE_LIBRARY FIND_LIBRARY(NVCORE_LIBRARY_RELEASE
NAMES nvcore NAMES nvcore
PATHS PATHS
/usr/local /usr/local
@ -99,7 +99,7 @@ FIND_LIBRARY(NVCORE_LIBRARY_DEBUG
) )
# NVTHREAD # NVTHREAD
FIND_LIBRARY(NVTHREAD_LIBRARY FIND_LIBRARY(NVTHREAD_LIBRARY_RELEASE
NAMES nvthread NAMES nvthread
PATHS PATHS
/usr/local /usr/local
@ -119,7 +119,7 @@ FIND_LIBRARY(NVTHREAD_LIBRARY_DEBUG
) )
# SQUISH # SQUISH
FIND_LIBRARY(NVSQUISH_LIBRARY FIND_LIBRARY(NVSQUISH_LIBRARY_RELEASE
NAMES squish NAMES squish
PATHS PATHS
/usr/local /usr/local
@ -139,7 +139,7 @@ FIND_LIBRARY(NVSQUISH_LIBRARY_DEBUG
) )
# BC6H # BC6H
FIND_LIBRARY(NVBC6H_LIBRARY FIND_LIBRARY(NVBC6H_LIBRARY_RELEASE
NAMES bc6h NAMES bc6h
PATHS PATHS
/usr/local /usr/local
@ -159,7 +159,7 @@ FIND_LIBRARY(NVBC6H_LIBRARY_DEBUG
) )
# BC7 # BC7
FIND_LIBRARY(NVBC7_LIBRARY FIND_LIBRARY(NVBC7_LIBRARY_RELEASE
NAMES bc7 NAMES bc7
PATHS PATHS
/usr/local /usr/local
@ -178,9 +178,34 @@ FIND_LIBRARY(NVBC7_LIBRARY_DEBUG
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
) )
IF (WIN32)
SET(LIBS_TO_SETUP "NVTT" "NVCORE" "NVMATH" "NVIMAGE" "NVTHREAD" "NVBC7" "NVBC6H" "NVSQUISH")
ELSE()
SET(LIBS_TO_SETUP "NVTT" "NVCORE" "NVMATH" "NVIMAGE")
ENDIF()
FOREACH(LIB ${LIBS_TO_SETUP})
IF(${LIB}_LIBRARY_DEBUG)
SET(${LIB}_LIBRARIES optimized ${${LIB}_LIBRARY_RELEASE} debug ${${LIB}_LIBRARY_DEBUG})
ELSE(${LIB}_LIBRARY_DEBUG)
SET(${LIB}_LIBRARY_DEBUG ${${LIB}_LIBRARY_RELEASE})
SET(${LIB}_LIBRARIES optimized ${${LIB}_LIBRARY_RELEASE} debug ${${LIB}_LIBRARY_DEBUG})
ENDIF(${LIB}_LIBRARY_DEBUG)
ENDFOREACH(LIB ${LIBS_TO_SETUP})
SET(NVTT_LIBRARIES
${NVTT_LIBRARIES}
${NVCORE_LIBRARIES}
${NVMATH_LIBRARIES}
${NVIMAGE_LIBRARIES}
${NVTHREAD_LIBRARIES}
${NVBC7_LIBRARIES}
${NVBC6H_LIBRARIES}
${NVSQUISH_LIBRARIES}
)
SET(NVTT_FOUND "NO") SET(NVTT_FOUND "NO")
IF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR) IF(NVTT_LIBRARY_RELEASE AND NVTT_INCLUDE_DIR)
SET(NVTT_FOUND "YES") SET(NVTT_FOUND "YES" )
ENDIF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR) ENDIF(NVTT_LIBRARY_RELEASE AND NVTT_INCLUDE_DIR)

View File

@ -200,15 +200,10 @@ public:
ComputeNode() ComputeNode()
{ {
const char* envOsgFilePath = getenv("OSG_FILE_PATH"); _computeShaderSourcePath = "shaders/osgssboComputeShader.cs";
std::stringstream computeshaderpath; computeshaderpath << envOsgFilePath << "/shaders/osgssboComputeShader.cs"; _vertexShaderSourcePath = "shaders/osgssboVertexShader.vs";
_computeShaderSourcePath = computeshaderpath.str(); _geometryShaderSourcePath = "shaders/osgssboGeometryShader.gs";
std::stringstream vertexshaderpath; vertexshaderpath << envOsgFilePath << "/shaders/osgssboVertexShader.vs"; _fragmentShaderSourcePath = "shaders/osgssboFragmentShader.fs";
_vertexShaderSourcePath = vertexshaderpath.str();
std::stringstream geometryshaderpath; geometryshaderpath << envOsgFilePath << "/shaders/osgssboGeometryShader.gs";
_geometryShaderSourcePath = geometryshaderpath.str();
std::stringstream fragmentshaderpath; fragmentshaderpath << envOsgFilePath << "/shaders/osgssboFragmentShader.fs";
_fragmentShaderSourcePath = fragmentshaderpath.str();
} }
}; };
@ -243,7 +238,7 @@ public:
if (_computeNode->_computeShader.valid()) if (_computeNode->_computeShader.valid())
{ {
runningSource = _computeNode->_computeShader->getShaderSource(); runningSource = _computeNode->_computeShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath); reloadedshader = osgDB::readRefShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource(); reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str())) if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
@ -258,7 +253,7 @@ public:
{ {
runningSource = _computeNode->_vertexShader->getShaderSource(); runningSource = _computeNode->_vertexShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath); reloadedshader = osgDB::readRefShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource(); reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str())) if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
@ -274,7 +269,7 @@ public:
if (_computeNode->_geometryShader.valid()) if (_computeNode->_geometryShader.valid())
{ {
runningSource = _computeNode->_geometryShader->getShaderSource(); runningSource = _computeNode->_geometryShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath); reloadedshader = osgDB::readRefShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource(); reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str())) if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
@ -288,7 +283,7 @@ public:
if (_computeNode->_fragmentShader.valid()) if (_computeNode->_fragmentShader.valid())
{ {
runningSource = _computeNode->_fragmentShader->getShaderSource(); runningSource = _computeNode->_fragmentShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath); reloadedshader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource(); reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str())) if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
@ -518,13 +513,13 @@ void ComputeNode::addComputationResultsRenderTree()
_computationResultsRenderProgram = new osg::Program; _computationResultsRenderProgram = new osg::Program;
_vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _vertexShaderSourcePath); _vertexShader = osgDB::readRefShaderFile(osg::Shader::VERTEX, _vertexShaderSourcePath);
_computationResultsRenderProgram->addShader(_vertexShader.get()); _computationResultsRenderProgram->addShader(_vertexShader.get());
_geometryShader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _geometryShaderSourcePath); _geometryShader = osgDB::readRefShaderFile(osg::Shader::GEOMETRY, _geometryShaderSourcePath);
_computationResultsRenderProgram->addShader(_geometryShader.get()); _computationResultsRenderProgram->addShader(_geometryShader.get());
_fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _fragmentShaderSourcePath); _fragmentShader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, _fragmentShaderSourcePath);
_computationResultsRenderProgram->addShader(_fragmentShader.get()); _computationResultsRenderProgram->addShader(_fragmentShader.get());
@ -629,7 +624,7 @@ void ComputeNode::initComputingSetup()
_computeProgram = new osg::Program; _computeProgram = new osg::Program;
_computeProgram->setComputeGroups((NUM_ELEMENTS_X / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_X / WORK_GROUP_SIZE), (NUM_ELEMENTS_Y / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_Y / WORK_GROUP_SIZE), 1); _computeProgram->setComputeGroups((NUM_ELEMENTS_X / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_X / WORK_GROUP_SIZE), (NUM_ELEMENTS_Y / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_Y / WORK_GROUP_SIZE), 1);
_computeShader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeShaderSourcePath); _computeShader = osgDB::readRefShaderFile(osg::Shader::COMPUTE, _computeShaderSourcePath);
_computeProgram->addShader(_computeShader.get()); _computeProgram->addShader(_computeShader.get());
setDataVariance(osg::Object::DYNAMIC); setDataVariance(osg::Object::DYNAMIC);

View File

@ -41,43 +41,14 @@ using namespace osg;
using namespace osgGA; using namespace osgGA;
class SwitchDOFVisitor : public osg::NodeVisitor, public osgGA::GUIEventHandler class SwitchDOFHandler : public osgGA::GUIEventHandler
{ {
public: public:
SwitchDOFVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) SwitchDOFHandler()
{ {
} }
SwitchDOFVisitor(const SwitchDOFVisitor& sdfv, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
META_Object(osg, SwitchDOFVisitor)
virtual void apply(Group& node)
{
osgSim::MultiSwitch* pMSwitch = dynamic_cast<osgSim::MultiSwitch*>(&node);
if (pMSwitch)
{
mSwitches.push_back(pMSwitch);
}
osg::NodeVisitor::apply(node);
}
virtual void apply(Transform& node)
{
osgSim::DOFTransform* pDof = dynamic_cast<osgSim::DOFTransform*>(&node);
if (pDof)
{
mDofs.push_back(pDof);
pDof->setAnimationOn(true);
}
osg::NodeVisitor::apply(node);
}
void nextSwitch() void nextSwitch()
{ {
for (size_t i=0; i < mSwitches.size(); i++) for (size_t i=0; i < mSwitches.size(); i++)
@ -151,9 +122,53 @@ public:
return false; return false;
} }
void collectNodesOfInterest(osg::Node* node)
{
CollectNodes cn(this);
node->accept(cn);
}
private: private:
std::vector<osgSim::MultiSwitch*> mSwitches;
std::vector<osgSim::DOFTransform*> mDofs; friend class CollectNodes;
class CollectNodes : public osg::NodeVisitor
{
public:
SwitchDOFHandler* _parent;
CollectNodes(SwitchDOFHandler* parent):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_parent(parent)
{
}
virtual void apply(Group& node)
{
osgSim::MultiSwitch* pMSwitch = dynamic_cast<osgSim::MultiSwitch*>(&node);
if (pMSwitch)
{
_parent->mSwitches.push_back(pMSwitch);
}
traverse(node);
}
virtual void apply(Transform& node)
{
osgSim::DOFTransform* pDof = dynamic_cast<osgSim::DOFTransform*>(&node);
if (pDof)
{
_parent->mDofs.push_back(pDof);
pDof->setAnimationOn(true);
}
traverse(node);
}
};
std::vector< osg::ref_ptr<osgSim::MultiSwitch> > mSwitches;
std::vector< osg::ref_ptr<osgSim::DOFTransform> > mDofs;
}; };
void singleWindowSideBySideCameras(osgViewer::Viewer& viewer) void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
@ -262,8 +277,8 @@ int main( int argc, char **argv )
viewer.addEventHandler(new osgViewer::LODScaleHandler()); viewer.addEventHandler(new osgViewer::LODScaleHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator()); viewer.addEventHandler(new osgGA::StateSetManipulator());
SwitchDOFVisitor* visit = new SwitchDOFVisitor; SwitchDOFHandler* switchOFHandler = new SwitchDOFHandler;
viewer.addEventHandler(visit); viewer.addEventHandler(switchOFHandler);
// load the scene. // load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
@ -289,13 +304,12 @@ int main( int argc, char **argv )
group2->addChild(convertedModel.get()); group2->addChild(convertedModel.get());
group2->setNodeMask(2); group2->setNodeMask(2);
// Activate DOF animations and collect switches
loadedModel->accept(*visit);
convertedModel->accept(*visit);
group->addChild(group1); group->addChild(group1);
group->addChild(group2); group->addChild(group2);
// Activate DOF animations and collect switches
switchOFHandler->collectNodesOfInterest(group);
viewer.setSceneData(group); viewer.setSceneData(group);
viewer.setThreadingModel(osgViewer::Viewer::DrawThreadPerContext); viewer.setThreadingModel(osgViewer::Viewer::DrawThreadPerContext);

View File

@ -307,6 +307,13 @@ Registry::Registry()
addFileExtensionAlias("vert", "glsl"); addFileExtensionAlias("vert", "glsl");
addFileExtensionAlias("frag", "glsl"); addFileExtensionAlias("frag", "glsl");
addFileExtensionAlias("geom", "glsl"); addFileExtensionAlias("geom", "glsl");
addFileExtensionAlias("compute", "glsl");
addFileExtensionAlias("vs", "glsl");
addFileExtensionAlias("fs", "glsl");
addFileExtensionAlias("gs", "glsl");
addFileExtensionAlias("cs", "glsl");
addFileExtensionAlias("tctrl", "glsl");
addFileExtensionAlias("teval", "glsl");
addFileExtensionAlias("js", "V8"); addFileExtensionAlias("js", "V8");

View File

@ -85,7 +85,7 @@ bool readerText::success(bool inSuccess, string type)
bool readerText::getTrimmedLine(std::ifstream& f) bool readerText::getTrimmedLine(std::ifstream& f)
{ {
static string line = ""; std::string line;
if (getline(f, line, _delim)) { if (getline(f, line, _delim)) {
++_lineCount; ++_lineCount;
_str.clear(); _str.clear();

View File

@ -256,7 +256,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
int internalFormat = GL_LUMINANCE; int internalFormat = GL_LUMINANCE;
unsigned int pixelFormat = GL_LUMINANCE; unsigned int pixelFormat = GL_LUMINANCE;
unsigned int dataType = 0; unsigned int dataType = 0;
unsigned int numBytesPerPixel = 0; unsigned int numBytesPerComponent = 0;
GDALDataType targetGDALType = GDT_Byte; GDALDataType targetGDALType = GDT_Byte;
@ -327,14 +327,14 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
targetGDALType = band->GetRasterDataType(); targetGDALType = band->GetRasterDataType();
switch(band->GetRasterDataType()) switch(band->GetRasterDataType())
{ {
case(GDT_Byte): dataType = GL_UNSIGNED_BYTE; numBytesPerPixel = 1; break; case(GDT_Byte): dataType = GL_UNSIGNED_BYTE; numBytesPerComponent = 1; break;
case(GDT_UInt16): dataType = GL_UNSIGNED_SHORT; numBytesPerPixel = 2; break; case(GDT_UInt16): dataType = GL_UNSIGNED_SHORT; numBytesPerComponent = 2; break;
case(GDT_Int16): dataType = GL_SHORT; numBytesPerPixel = 2; break; case(GDT_Int16): dataType = GL_SHORT; numBytesPerComponent = 2; break;
case(GDT_UInt32): dataType = GL_UNSIGNED_INT; numBytesPerPixel = 4; break; case(GDT_UInt32): dataType = GL_UNSIGNED_INT; numBytesPerComponent = 4; break;
case(GDT_Int32): dataType = GL_INT; numBytesPerPixel = 4; break; case(GDT_Int32): dataType = GL_INT; numBytesPerComponent = 4; break;
case(GDT_Float32): dataType = GL_FLOAT; numBytesPerPixel = 4; break; case(GDT_Float32): dataType = GL_FLOAT; numBytesPerComponent = 4; break;
case(GDT_Float64): dataType = GL_DOUBLE; numBytesPerPixel = 8; break; // not handled case(GDT_Float64): dataType = GL_DOUBLE; numBytesPerComponent = 8; break; // not handled
default: dataType = 0; numBytesPerPixel = 0; break; // not handled default: dataType = 0; numBytesPerComponent = 0; break; // not handled
} }
} }
} }
@ -348,7 +348,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
if (dataType==0) if (dataType==0)
{ {
dataType = GL_UNSIGNED_BYTE; dataType = GL_UNSIGNED_BYTE;
numBytesPerPixel = 1; numBytesPerComponent = 1;
targetGDALType = GDT_Byte; targetGDALType = GDT_Byte;
} }
@ -360,7 +360,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
{ {
// RGBA // RGBA
int pixelSpace=4*numBytesPerPixel; int pixelSpace=4*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
imageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * pixelSpace];
@ -370,16 +370,16 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
OSG_INFO << "reading RGBA"<<std::endl; OSG_INFO << "reading RGBA"<<std::endl;
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1*numBytesPerComponent),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2*numBytesPerComponent),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+3),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+3*numBytesPerComponent),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
} }
else else
{ {
// RGB // RGB
int pixelSpace=3*numBytesPerPixel; int pixelSpace=3*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
imageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * pixelSpace];
@ -389,8 +389,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
OSG_INFO << "reading RGB"<<std::endl; OSG_INFO << "reading RGB"<<std::endl;
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1*numBytesPerComponent),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2*numBytesPerComponent),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
} }
} }
@ -399,7 +399,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
if (bandAlpha) if (bandAlpha)
{ {
// Luminance alpha // Luminance alpha
int pixelSpace=2*numBytesPerPixel; int pixelSpace=2*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
imageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * pixelSpace];
@ -414,7 +414,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
else else
{ {
// Luminance map // Luminance map
int pixelSpace=1*numBytesPerPixel; int pixelSpace=1*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
imageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * pixelSpace];
@ -429,7 +429,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
else if (bandAlpha) else if (bandAlpha)
{ {
// alpha map // alpha map
int pixelSpace=1*numBytesPerPixel; int pixelSpace=1*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
imageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * pixelSpace];
@ -444,7 +444,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
else if (bandPalette) else if (bandPalette)
{ {
// Paletted map // Paletted map
int pixelSpace=1*numBytesPerPixel; int pixelSpace=1*numBytesPerComponent;
int lineSpace=destWidth * pixelSpace; int lineSpace=destWidth * pixelSpace;
unsigned char *rawImageData; unsigned char *rawImageData;
@ -454,7 +454,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
internalFormat = GL_RGBA; internalFormat = GL_RGBA;
OSG_INFO << "reading palette"<<std::endl; OSG_INFO << "reading palette"<<std::endl;
OSG_INFO << "numBytesPerPixel: " << numBytesPerPixel << std::endl; OSG_INFO << "numBytesPerComponent: " << numBytesPerComponent << std::endl;
bandPalette->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(rawImageData),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); bandPalette->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(rawImageData),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);

View File

@ -18,12 +18,16 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
{ {
supportsExtension("gl","OpenGL Shader Language format"); supportsExtension("gl","OpenGL Shader Language format");
supportsExtension("frag","OpenGL Shader Language format"); supportsExtension("frag","OpenGL Shader Language format");
supportsExtension("fs","OpenGL Shader Language format");
supportsExtension("vert","OpenGL Shader Language format"); supportsExtension("vert","OpenGL Shader Language format");
supportsExtension("vs","OpenGL Shader Language format");
supportsExtension("geom","OpenGL Shader Language format"); supportsExtension("geom","OpenGL Shader Language format");
supportsExtension("gs","OpenGL Shader Language format");
supportsExtension("glsl","OpenGL Shader Language format"); supportsExtension("glsl","OpenGL Shader Language format");
supportsExtension("tctrl","OpenGL Shader Language format"); supportsExtension("tctrl","OpenGL Shader Language format");
supportsExtension("teval","OpenGL Shader Language format"); supportsExtension("teval","OpenGL Shader Language format");
supportsExtension("compute","OpenGL Shader Language format"); supportsExtension("compute","OpenGL Shader Language format");
supportsExtension("cs","OpenGL Shader Language format");
} }
virtual const char* className() const { return "GLSL Shader Reader"; } virtual const char* className() const { return "GLSL Shader Reader"; }
@ -126,12 +130,12 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
if (shader->getType() == osg::Shader::UNDEFINED) if (shader->getType() == osg::Shader::UNDEFINED)
{ {
// set type based on filename extension, where possible // set type based on filename extension, where possible
if (ext == "frag") shader->setType(osg::Shader::FRAGMENT); if (ext == "frag" || ext == "fs") shader->setType(osg::Shader::FRAGMENT);
if (ext == "vert") shader->setType(osg::Shader::VERTEX); if (ext == "vert" || ext == "vs" ) shader->setType(osg::Shader::VERTEX);
if (ext == "geom") shader->setType(osg::Shader::GEOMETRY); if (ext == "geom" || ext == "geom") shader->setType(osg::Shader::GEOMETRY);
if (ext == "tctrl") shader->setType(osg::Shader::TESSCONTROL); if (ext == "tctrl") shader->setType(osg::Shader::TESSCONTROL);
if (ext == "teval") shader->setType(osg::Shader::TESSEVALUATION); if (ext == "teval") shader->setType(osg::Shader::TESSEVALUATION);
if (ext == "compute") shader->setType(osg::Shader::COMPUTE); if (ext == "compute" || ext == "cs") shader->setType(osg::Shader::COMPUTE);
} }
} }
return rr; return rr;

View File

@ -321,7 +321,7 @@ class LOGOReaderWriter : public osgDB::ReaderWriter
if( ld->hasLogos() ) if( ld->hasLogos() )
geode->addDrawable( ld ); geode->addDrawable( ld );
geode->setCullingActive(false); ld->setCullingActive(false);
return geode; return geode;
} }
}; };

View File

@ -5,7 +5,7 @@ SET(TARGET_SRC
NVTTImageProcessor.cpp NVTTImageProcessor.cpp
) )
SET(TARGET_LIBRARIES_VARS NVTT_LIBRARY) SET(TARGET_EXTERNAL_LIBRARIES ${TARGET_EXTERNAL_LIBRARIES} ${NVTT_LIBRARIES})
#### end var setup ### #### end var setup ###
SETUP_PLUGIN(nvtt) SETUP_PLUGIN(nvtt)

View File

@ -491,16 +491,17 @@ class ReaderWriterTGA : public osgDB::ReaderWriter
int t = height_ret; int t = height_ret;
int r = 1; int r = 1;
int internalFormat = numComponents_ret;
unsigned int pixelFormat = unsigned int pixelFormat =
numComponents_ret == 1 ? GL_LUMINANCE : numComponents_ret == 1 ? GL_LUMINANCE :
numComponents_ret == 2 ? GL_LUMINANCE_ALPHA : numComponents_ret == 2 ? GL_LUMINANCE_ALPHA :
numComponents_ret == 3 ? GL_RGB : numComponents_ret == 3 ? GL_RGB :
numComponents_ret == 4 ? GL_RGBA : (GLenum)-1; numComponents_ret == 4 ? GL_RGBA : (GLenum)-1;
int internalFormat = pixelFormat;
unsigned int dataType = GL_UNSIGNED_BYTE; unsigned int dataType = GL_UNSIGNED_BYTE;
osg::Image* pOsgImage = new osg::Image; osg::Image* pOsgImage = new osg::Image;
pOsgImage->setImage(s,t,r, pOsgImage->setImage(s,t,r,
internalFormat, internalFormat,

View File

@ -121,11 +121,11 @@ bool ZipArchive::open(const std::string& file, ArchiveStatus status, const osgDB
if ( !_zipLoaded ) // double-check avoids race condition if ( !_zipLoaded ) // double-check avoids race condition
{ {
std::string ext = osgDB::getLowerCaseFileExtension(file); std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return osgDB::ReaderWriter::ReadResult::FILE_NOT_HANDLED; if (!acceptsExtension(ext)) return false;
// save the filename + password so other threads can open the file // save the filename + password so other threads can open the file
_filename = osgDB::findDataFile( file, options ); _filename = osgDB::findDataFile( file, options );
if (_filename.empty()) return osgDB::ReaderWriter::ReadResult::FILE_NOT_FOUND; if (_filename.empty()) return false;
_password = ReadPassword(options); _password = ReadPassword(options);

View File

@ -135,11 +135,13 @@ int ShapeAttribute::compare(const osgSim::ShapeAttribute& sa) const
{ {
if (_string<sa._string) return -1; if (_string<sa._string) return -1;
if (sa._string<_string) return 1; if (sa._string<_string) return 1;
return 0;
} }
case DOUBLE: case DOUBLE:
{ {
if (_double<sa._double) return -1; if (_double<sa._double) return -1;
if (sa._double<_double) return 1; if (sa._double<_double) return 1;
return 0;
} }
case INTEGER: case INTEGER:
case UNKNOWN: case UNKNOWN:
@ -147,6 +149,7 @@ int ShapeAttribute::compare(const osgSim::ShapeAttribute& sa) const
{ {
if (_integer<sa._integer) return -1; if (_integer<sa._integer) return -1;
if (sa._integer<_integer) return 1; if (sa._integer<_integer) return 1;
return 0;
} }
} }
return 0; return 0;

View File

@ -12,8 +12,8 @@ TangentSpaceGenerator::TangentSpaceGenerator()
N_(new osg::Vec4Array) N_(new osg::Vec4Array)
{ {
T_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); T_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false);
B_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); B_->setBinding(osg::Array::BIND_PER_VERTEX); B_->setNormalize(false);
N_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); N_->setBinding(osg::Array::BIND_PER_VERTEX); N_->setNormalize(false);
} }
TangentSpaceGenerator::TangentSpaceGenerator(const TangentSpaceGenerator &copy, const osg::CopyOp &copyop) TangentSpaceGenerator::TangentSpaceGenerator(const TangentSpaceGenerator &copy, const osg::CopyOp &copyop)
@ -281,9 +281,15 @@ void TangentSpaceGenerator::compute(osg::PrimitiveSet *pset,
OSG_WARN << "Warning: TangentSpaceGenerator: texture coord array must be Vec2Array, Vec3Array or Vec4Array" << std::endl; OSG_WARN << "Warning: TangentSpaceGenerator: texture coord array must be Vec2Array, Vec3Array or Vec4Array" << std::endl;
} }
if(nx){
osg::Vec3 V, T1, T2, T3, B1, B2, B3; osg::Vec3 V, T1, T2, T3, B1, B2, B3;
// no normal per vertex use the one by face
if (!nx) {
N1 = (P2 - P1) ^ (P3 - P1);
N2 = N1;
N3 = N1;
}
V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^ V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y()); osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) { if (V.x() != 0) {
@ -321,67 +327,28 @@ void TangentSpaceGenerator::compute(osg::PrimitiveSet *pset,
} }
osg::Vec3 tempvec; osg::Vec3 tempvec;
tempvec = N1 ^ T1; tempvec = N1 ^ T1;
(*T_)[iA] = osg::Vec4(tempvec ^ N1, 0); (*T_)[iA] += osg::Vec4(tempvec ^ N1, 0);
tempvec = B1 ^ N1; tempvec = B1 ^ N1;
(*B_)[iA] = osg::Vec4(N1 ^ tempvec, 0); (*B_)[iA] += osg::Vec4(N1 ^ tempvec, 0);
tempvec = N2 ^ T2; tempvec = N2 ^ T2;
(*T_)[iB] = osg::Vec4(tempvec ^ N2, 0); (*T_)[iB] += osg::Vec4(tempvec ^ N2, 0);
tempvec = B2 ^ N2; tempvec = B2 ^ N2;
(*B_)[iB] = osg::Vec4(N2 ^ tempvec, 0); (*B_)[iB] += osg::Vec4(N2 ^ tempvec, 0);
tempvec = N3 ^ T3; tempvec = N3 ^ T3;
(*T_)[iC] = osg::Vec4(tempvec ^ N3, 0); (*T_)[iC] += osg::Vec4(tempvec ^ N3, 0);
tempvec = B3 ^ N3; tempvec = B3 ^ N3;
(*B_)[iC] = osg::Vec4(N3 ^ tempvec, 0); (*B_)[iC] += osg::Vec4(N3 ^ tempvec, 0);
(*N_)[iA] += osg::Vec4(N1, 0); (*N_)[iA] += osg::Vec4(N1, 0);
(*N_)[iB] += osg::Vec4(N2, 0); (*N_)[iB] += osg::Vec4(N2, 0);
(*N_)[iC] += osg::Vec4(N3, 0); (*N_)[iC] += osg::Vec4(N3, 0);
}
else{
osg::Vec3 face_normal = (P2 - P1) ^ (P3 - P1);
osg::Vec3 V;
V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].x() += -V.y() / V.x();
(*B_)[iA].x() += -V.z() / V.x();
(*T_)[iB].x() += -V.y() / V.x();
(*B_)[iB].x() += -V.z() / V.x();
(*T_)[iC].x() += -V.y() / V.x();
(*B_)[iC].x() += -V.z() / V.x();
}
V = osg::Vec3(P2.y() - P1.y(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.y() - P1.y(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].y() += -V.y() / V.x();
(*B_)[iA].y() += -V.z() / V.x();
(*T_)[iB].y() += -V.y() / V.x();
(*B_)[iB].y() += -V.z() / V.x();
(*T_)[iC].y() += -V.y() / V.x();
(*B_)[iC].y() += -V.z() / V.x();
}
V = osg::Vec3(P2.z() - P1.z(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.z() - P1.z(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].z() += -V.y() / V.x();
(*B_)[iA].z() += -V.z() / V.x();
(*T_)[iB].z() += -V.y() / V.x();
(*B_)[iB].z() += -V.z() / V.x();
(*T_)[iC].z() += -V.y() / V.x();
(*B_)[iC].z() += -V.z() / V.x();
}
(*N_)[iA] += osg::Vec4(face_normal, 0);
(*N_)[iB] += osg::Vec4(face_normal, 0);
(*N_)[iC] += osg::Vec4(face_normal, 0);
}
} }