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
- g++
- cmake
# OSX build
- os: osx
language: cpp
# # OSX build
# - os: osx
# language: cpp
script:
- mkdir build

View File

@ -16,7 +16,7 @@ FIND_PATH(NVTT_INCLUDE_DIR nvtt/nvtt.h
)
# NVTT
FIND_LIBRARY(NVTT_LIBRARY
FIND_LIBRARY(NVTT_LIBRARY_RELEASE
NAMES nvtt
PATHS
/usr/local
@ -37,7 +37,7 @@ FIND_LIBRARY(NVTT_LIBRARY_DEBUG
)
# NVIMAGE
FIND_LIBRARY(NVIMAGE_LIBRARY
FIND_LIBRARY(NVIMAGE_LIBRARY_RELEASE
NAMES nvimage
PATHS
/usr/local
@ -58,7 +58,7 @@ FIND_LIBRARY(NVIMAGE_LIBRARY_DEBUG
)
# NVMATH
FIND_LIBRARY(NVMATH_LIBRARY
FIND_LIBRARY(NVMATH_LIBRARY_RELEASE
NAMES nvmath
PATHS
/usr/local
@ -79,7 +79,7 @@ FIND_LIBRARY(NVMATH_LIBRARY_DEBUG
)
# NVCORE
FIND_LIBRARY(NVCORE_LIBRARY
FIND_LIBRARY(NVCORE_LIBRARY_RELEASE
NAMES nvcore
PATHS
/usr/local
@ -99,7 +99,7 @@ FIND_LIBRARY(NVCORE_LIBRARY_DEBUG
)
# NVTHREAD
FIND_LIBRARY(NVTHREAD_LIBRARY
FIND_LIBRARY(NVTHREAD_LIBRARY_RELEASE
NAMES nvthread
PATHS
/usr/local
@ -119,7 +119,7 @@ FIND_LIBRARY(NVTHREAD_LIBRARY_DEBUG
)
# SQUISH
FIND_LIBRARY(NVSQUISH_LIBRARY
FIND_LIBRARY(NVSQUISH_LIBRARY_RELEASE
NAMES squish
PATHS
/usr/local
@ -139,7 +139,7 @@ FIND_LIBRARY(NVSQUISH_LIBRARY_DEBUG
)
# BC6H
FIND_LIBRARY(NVBC6H_LIBRARY
FIND_LIBRARY(NVBC6H_LIBRARY_RELEASE
NAMES bc6h
PATHS
/usr/local
@ -159,7 +159,7 @@ FIND_LIBRARY(NVBC6H_LIBRARY_DEBUG
)
# BC7
FIND_LIBRARY(NVBC7_LIBRARY
FIND_LIBRARY(NVBC7_LIBRARY_RELEASE
NAMES bc7
PATHS
/usr/local
@ -178,9 +178,34 @@ FIND_LIBRARY(NVBC7_LIBRARY_DEBUG
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")
IF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR)
SET(NVTT_FOUND "YES")
ENDIF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR)
IF(NVTT_LIBRARY_RELEASE AND NVTT_INCLUDE_DIR)
SET(NVTT_FOUND "YES" )
ENDIF(NVTT_LIBRARY_RELEASE AND NVTT_INCLUDE_DIR)

View File

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

View File

@ -41,43 +41,14 @@ using namespace osg;
using namespace osgGA;
class SwitchDOFVisitor : public osg::NodeVisitor, public osgGA::GUIEventHandler
class SwitchDOFHandler : public osgGA::GUIEventHandler
{
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()
{
for (size_t i=0; i < mSwitches.size(); i++)
@ -151,9 +122,53 @@ public:
return false;
}
void collectNodesOfInterest(osg::Node* node)
{
CollectNodes cn(this);
node->accept(cn);
}
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)
@ -262,8 +277,8 @@ int main( int argc, char **argv )
viewer.addEventHandler(new osgViewer::LODScaleHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator());
SwitchDOFVisitor* visit = new SwitchDOFVisitor;
viewer.addEventHandler(visit);
SwitchDOFHandler* switchOFHandler = new SwitchDOFHandler;
viewer.addEventHandler(switchOFHandler);
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
@ -289,13 +304,12 @@ int main( int argc, char **argv )
group2->addChild(convertedModel.get());
group2->setNodeMask(2);
// Activate DOF animations and collect switches
loadedModel->accept(*visit);
convertedModel->accept(*visit);
group->addChild(group1);
group->addChild(group2);
// Activate DOF animations and collect switches
switchOFHandler->collectNodesOfInterest(group);
viewer.setSceneData(group);
viewer.setThreadingModel(osgViewer::Viewer::DrawThreadPerContext);

View File

@ -307,6 +307,13 @@ Registry::Registry()
addFileExtensionAlias("vert", "glsl");
addFileExtensionAlias("frag", "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");

View File

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

View File

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

View File

@ -18,12 +18,16 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
{
supportsExtension("gl","OpenGL Shader Language format");
supportsExtension("frag","OpenGL Shader Language format");
supportsExtension("fs","OpenGL Shader Language format");
supportsExtension("vert","OpenGL Shader Language format");
supportsExtension("vs","OpenGL Shader Language format");
supportsExtension("geom","OpenGL Shader Language format");
supportsExtension("gs","OpenGL Shader Language format");
supportsExtension("glsl","OpenGL Shader Language format");
supportsExtension("tctrl","OpenGL Shader Language format");
supportsExtension("teval","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"; }
@ -126,12 +130,12 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
if (shader->getType() == osg::Shader::UNDEFINED)
{
// set type based on filename extension, where possible
if (ext == "frag") shader->setType(osg::Shader::FRAGMENT);
if (ext == "vert") shader->setType(osg::Shader::VERTEX);
if (ext == "geom") shader->setType(osg::Shader::GEOMETRY);
if (ext == "frag" || ext == "fs") shader->setType(osg::Shader::FRAGMENT);
if (ext == "vert" || ext == "vs" ) shader->setType(osg::Shader::VERTEX);
if (ext == "geom" || ext == "geom") shader->setType(osg::Shader::GEOMETRY);
if (ext == "tctrl") shader->setType(osg::Shader::TESSCONTROL);
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;

View File

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

View File

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

View File

@ -491,16 +491,17 @@ class ReaderWriterTGA : public osgDB::ReaderWriter
int t = height_ret;
int r = 1;
int internalFormat = numComponents_ret;
unsigned int pixelFormat =
numComponents_ret == 1 ? GL_LUMINANCE :
numComponents_ret == 2 ? GL_LUMINANCE_ALPHA :
numComponents_ret == 3 ? GL_RGB :
numComponents_ret == 4 ? GL_RGBA : (GLenum)-1;
numComponents_ret == 2 ? GL_LUMINANCE_ALPHA :
numComponents_ret == 3 ? GL_RGB :
numComponents_ret == 4 ? GL_RGBA : (GLenum)-1;
int internalFormat = pixelFormat;
unsigned int dataType = GL_UNSIGNED_BYTE;
osg::Image* pOsgImage = new osg::Image;
pOsgImage->setImage(s,t,r,
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
{
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
_filename = osgDB::findDataFile( file, options );
if (_filename.empty()) return osgDB::ReaderWriter::ReadResult::FILE_NOT_FOUND;
if (_filename.empty()) return false;
_password = ReadPassword(options);

View File

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

View File

@ -12,8 +12,8 @@ TangentSpaceGenerator::TangentSpaceGenerator()
N_(new osg::Vec4Array)
{
T_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false);
B_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false);
N_->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); N_->setNormalize(false);
}
TangentSpaceGenerator::TangentSpaceGenerator(const TangentSpaceGenerator &copy, const osg::CopyOp &copyop)
@ -281,107 +281,74 @@ void TangentSpaceGenerator::compute(osg::PrimitiveSet *pset,
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;
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();
T1.x() += -V.y() / V.x();
B1.x() += -V.z() / V.x();
T2.x() += -V.y() / V.x();
B2.x() += -V.z() / V.x();
T3.x() += -V.y() / V.x();
B3.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();
T1.y() += -V.y() / V.x();
B1.y() += -V.z() / V.x();
T2.y() += -V.y() / V.x();
B2.y() += -V.z() / V.x();
T3.y() += -V.y() / V.x();
B3.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();
T1.z() += -V.y() / V.x();
B1.z() += -V.z() / V.x();
T2.z() += -V.y() / V.x();
B2.z() += -V.z() / V.x();
T3.z() += -V.y() / V.x();
B3.z() += -V.z() / V.x();
}
osg::Vec3 tempvec;
tempvec = N1 ^ T1;
(*T_)[iA] = osg::Vec4(tempvec ^ N1, 0);
tempvec = B1 ^ N1;
(*B_)[iA] = osg::Vec4(N1 ^ tempvec, 0);
tempvec = N2 ^ T2;
(*T_)[iB] = osg::Vec4(tempvec ^ N2, 0);
tempvec = B2 ^ N2;
(*B_)[iB] = osg::Vec4(N2 ^ tempvec, 0);
tempvec = N3 ^ T3;
(*T_)[iC] = osg::Vec4(tempvec ^ N3, 0);
tempvec = B3 ^ N3;
(*B_)[iC] = osg::Vec4(N3 ^ tempvec, 0);
(*N_)[iA] += osg::Vec4(N1, 0);
(*N_)[iB] += osg::Vec4(N2, 0);
(*N_)[iC] += osg::Vec4(N3, 0);
// no normal per vertex use the one by face
if (!nx) {
N1 = (P2 - P1) ^ (P3 - P1);
N2 = N1;
N3 = N1;
}
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);
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();
T1.x() += -V.y() / V.x();
B1.x() += -V.z() / V.x();
T2.x() += -V.y() / V.x();
B2.x() += -V.z() / V.x();
T3.x() += -V.y() / V.x();
B3.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();
T1.y() += -V.y() / V.x();
B1.y() += -V.z() / V.x();
T2.y() += -V.y() / V.x();
B2.y() += -V.z() / V.x();
T3.y() += -V.y() / V.x();
B3.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();
T1.z() += -V.y() / V.x();
B1.z() += -V.z() / V.x();
T2.z() += -V.y() / V.x();
B2.z() += -V.z() / V.x();
T3.z() += -V.y() / V.x();
B3.z() += -V.z() / V.x();
}
osg::Vec3 tempvec;
tempvec = N1 ^ T1;
(*T_)[iA] += osg::Vec4(tempvec ^ N1, 0);
tempvec = B1 ^ N1;
(*B_)[iA] += osg::Vec4(N1 ^ tempvec, 0);
tempvec = N2 ^ T2;
(*T_)[iB] += osg::Vec4(tempvec ^ N2, 0);
tempvec = B2 ^ N2;
(*B_)[iB] += osg::Vec4(N2 ^ tempvec, 0);
tempvec = N3 ^ T3;
(*T_)[iC] += osg::Vec4(tempvec ^ N3, 0);
tempvec = B3 ^ N3;
(*B_)[iC] += osg::Vec4(N3 ^ tempvec, 0);
(*N_)[iA] += osg::Vec4(N1, 0);
(*N_)[iB] += osg::Vec4(N2, 0);
(*N_)[iC] += osg::Vec4(N3, 0);
}