From Mike Weiblen, added new rot, scale and trans pseudo loaders.

This commit is contained in:
Robert Osfield
2004-05-07 15:18:59 +00:00
parent a196ea1d5d
commit bdeb391a00
14 changed files with 678 additions and 8 deletions

View File

@@ -57,6 +57,10 @@ PLUGIN_DIRS = \
zip\
3dc\
ive\
rot\
scale\
trans\
ifeq ($(GDAL_INSTALLED),yes)
PLUGIN_DIRS += gdal

View File

@@ -2424,6 +2424,60 @@ Package=<4>
###############################################################################
Project: "osgPlugin scale"=.\osgPlugins\scale\scale.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Core osg
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgDB
End Project Dependency
}}}
###############################################################################
Project: "osgPlugin trans"=.\osgPlugins\trans\trans.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Core osg
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgDB
End Project Dependency
}}}
###############################################################################
Project: "osgPlugin scale"=.\osgPlugins\scale\scale.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Core osg
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgDB
End Project Dependency
}}}
###############################################################################
Project: "osgPlugin tga"=.\osgPlugins\tga\tga.dsp - Package Owner=<4>
Package=<5>

View File

@@ -0,0 +1,109 @@
# Microsoft Developer Studio Project File - Name="osgPlugin rot" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=osgPlugin rot - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "rot.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "rot.mak" CFG="osgPlugin rot - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "osgPlugin rot - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "osgPlugin rot - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "osgPlugin rot - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../lib"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_rot.dll" /libpath:"../../../lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgPlugin rot - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../lib"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_rotd.dll" /pdbtype:sept /libpath:"../../../lib"
# SUBTRACT LINK32 /nodefaultlib
!ENDIF
# Begin Target
# Name "osgPlugin rot - Win32 Release"
# Name "osgPlugin rot - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\rot\ReaderWriterROT.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,109 @@
# Microsoft Developer Studio Project File - Name="osgPlugin scale" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=osgPlugin scale - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "scale.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "scale.mak" CFG="osgPlugin scale - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "osgPlugin scale - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "osgPlugin scale - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "osgPlugin scale - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../lib"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_scale.dll" /libpath:"../../../lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgPlugin scale - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../lib"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_scaled.dll" /pdbtype:sept /libpath:"../../../lib"
# SUBTRACT LINK32 /nodefaultlib
!ENDIF
# Begin Target
# Name "osgPlugin scale - Win32 Release"
# Name "osgPlugin scale - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\scale\ReaderWriterSCALE.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -24,6 +24,7 @@ extern OSGDB_EXPORT std::string getFilePath(const std::string& filename);
extern OSGDB_EXPORT std::string getFileExtension(const std::string& filename);
extern OSGDB_EXPORT std::string getLowerCaseFileExtension(const std::string& filename);
extern OSGDB_EXPORT std::string getSimpleFileName(const std::string& fileName);
extern OSGDB_EXPORT std::string getNameLessExtension(const std::string& fileName);
extern OSGDB_EXPORT std::string getStrippedName(const std::string& fileName);
extern OSGDB_EXPORT bool equalCaseInsensitive(const std::string& lhs,const std::string& rhs);

View File

@@ -71,12 +71,19 @@ std::string osgDB::getLowerCaseFileExtension(const std::string& filename)
}
// strip one level of extension from the filename.
std::string osgDB::getNameLessExtension(const std::string& fileName)
{
std::string::size_type dot = fileName.find_last_of('.');
if (dot==std::string::npos) return fileName;
return std::string(fileName.begin(),fileName.begin()+dot);
}
std::string osgDB::getStrippedName(const std::string& fileName)
{
std::string simpleName = getSimpleFileName(fileName);
std::string::size_type dot = simpleName.find_last_of('.');
if (dot==std::string::npos) return simpleName;
return std::string(simpleName.begin(),simpleName.begin()+dot);
return getNameLessExtension( simpleName );
}

View File

@@ -12,7 +12,7 @@
*/
/* file: src/osgGL2/ProgramObject.cpp
* author: Mike Weiblen 2003-12-27
* author: Mike Weiblen 2004-02-04
*
* See http://www.3dlabs.com/opengl2/ for more information regarding
* the OpenGL Shading Language.
@@ -56,7 +56,10 @@ public:
}
}
const std::string& operator()() { return _text; }
friend std::ostream& operator<< ( std::ostream& o, const InfoLog& log )
{
return o << log._text;
}
private:
InfoLog();
@@ -338,7 +341,7 @@ void ProgramObject::PerContextProgObj::build()
if( _dirty )
{
InfoLog log( _extensions.get(), _glProgObjHandle );
osg::notify(osg::WARN) << "glLinkProgram FAILED:\n" << log() << std::endl;
osg::notify(osg::WARN) << "glLinkProgram FAILED:\n" << log << std::endl;
}
}
@@ -533,7 +536,7 @@ void ShaderObject::PerContextShaderObj::build()
{
InfoLog log( _extensions.get(), _glShaderObjHandle );
osg::notify(osg::WARN) << _shadObj->getTypename() <<
" glCompileShader FAILED:\n" << log() << std::endl;
" glCompileShader FAILED:\n" << log << std::endl;
}
}

View File

@@ -0,0 +1,13 @@
TOPDIR = ../../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
ReaderWriterROT.cpp\
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
TARGET_BASENAME = rot
include $(TOPDIR)/Make/cygwin_plugin_def
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
include $(TOPDIR)/Make/makerules

View File

@@ -0,0 +1,112 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial
* applications, as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
/* file: src/osgPlugins/rot/ReaderWriterROT.cpp
* author: Mike Weiblen http://mew.cx/ 2004-04-25
* copyright: (C) 2004 Michael Weiblen
* license: OpenSceneGraph Public License (OSGPL)
*/
#include <osg/Notify>
#include <osg/Matrix>
#include <osg/MatrixTransform>
#include <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <stdio.h>
#define EXTENSION_NAME "rot"
///////////////////////////////////////////////////////////////////////////
/**
* An OSG reader plugin for the rotation pseudo-loader.
*/
class ReaderWriterROT : public osgDB::ReaderWriter
{
public:
ReaderWriterROT() { }
virtual const char* className() { return "rotation pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension)
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
virtual ReadResult readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* /*options*/)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if( !acceptsExtension(ext) )
return ReadResult::FILE_NOT_HANDLED;
osg::notify(osg::INFO) << "ReaderWriterROT( \"" << fileName << "\" )" << std::endl;
// strip the pseudo-loader extension
std::string tmpName = osgDB::getNameLessExtension( fileName );
// get the next "extension", which actually contains the pseudo-loader parameters
std::string params = osgDB::getFileExtension( tmpName );
if( params.empty() )
{
osg::notify(osg::WARN) << "Missing parameters for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// strip the "params extension", which must leave a sub-filename.
std::string subFileName = osgDB::getNameLessExtension( tmpName );
if( subFileName == tmpName )
{
osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::notify(osg::INFO) << EXTENSION_NAME " params = \"" << params << "\"" << std::endl;
int h, p, r;
int count = sscanf( params.c_str(), "%d,%d,%d", &h, &p, &r );
if( count != 3 )
{
osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName );
if( !node )
{
// propagate the read failure upwards
osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::rotate(
osg::DegreesToRadians( static_cast<float>(r) ), osg::Vec3( 0, 1, 0 ),
osg::DegreesToRadians( static_cast<float>(p) ), osg::Vec3( 1, 0, 0 ),
osg::DegreesToRadians( static_cast<float>(h) ), osg::Vec3( 0, 0, 1 ) ));
xform->addChild( node );
return xform;
}
};
// Add ourself to the Registry to instantiate the reader/writer.
osgDB::RegisterReaderWriterProxy<ReaderWriterROT> g_readerWriter_ROT_Proxy;
/*EOF*/

View File

@@ -0,0 +1,13 @@
TOPDIR = ../../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
ReaderWriterSCALE.cpp\
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
TARGET_BASENAME = scale
include $(TOPDIR)/Make/cygwin_plugin_def
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
include $(TOPDIR)/Make/makerules

View File

@@ -0,0 +1,123 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial
* applications, as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
/* file: src/osgPlugins/scale/ReaderWriterSCALE.cpp
* author: Mike Weiblen http://mew.cx/ 2004-04-25
* copyright: (C) 2004 Michael Weiblen
* license: OpenSceneGraph Public License (OSGPL)
*/
#include <osg/Notify>
#include <osg/Matrix>
#include <osg/MatrixTransform>
#include <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <stdio.h>
#define EXTENSION_NAME "scale"
///////////////////////////////////////////////////////////////////////////
/**
* An OSG reader plugin for the scaling pseudo-loader.
*/
class ReaderWriterSCALE : public osgDB::ReaderWriter
{
public:
ReaderWriterSCALE() { }
virtual const char* className() { return "scaling pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension)
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
virtual ReadResult readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* /*options*/)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if( !acceptsExtension(ext) )
return ReadResult::FILE_NOT_HANDLED;
osg::notify(osg::INFO) << "ReaderWriterSCALE( \"" << fileName << "\" )" << std::endl;
// strip the pseudo-loader extension
std::string tmpName = osgDB::getNameLessExtension( fileName );
// get the next "extension", which actually contains the pseudo-loader parameters
std::string params = osgDB::getFileExtension( tmpName );
if( params.empty() )
{
osg::notify(osg::WARN) << "Missing parameters for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// strip the "params extension", which must leave a sub-filename.
std::string subFileName = osgDB::getNameLessExtension( tmpName );
if( subFileName == tmpName )
{
osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::notify(osg::INFO) << EXTENSION_NAME " params = \"" << params << "\"" << std::endl;
int sx, sy, sz;
int count = sscanf( params.c_str(), "%d,%d,%d", &sx, &sy, &sz );
if( count == 1 )
{
// if only one value supplied, apply uniform scaling
sy = sx;
sz = sx;
}
else if( count != 3 )
{
osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName );
if( !node )
{
// propagate the read failure upwards
osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::scale( sx, sy, sz ) );
xform->addChild( node );
// TODO: should we force GL_NORMALIZE on?
// osg::StateSet* ss = xform->getOrCreateStateSet();
// ss->setMode( GL_NORMALIZE, osg::StateAttribute::ON );
// Or since the scale is static, perhaps renormalization
// would be better performed once at loadtime with a
// .normalize pseudo-loader?
return xform;
}
};
// Add ourself to the Registry to instantiate the reader/writer.
osgDB::RegisterReaderWriterProxy<ReaderWriterSCALE> g_readerWriter_SCALE_Proxy;
/*EOF*/

View File

@@ -0,0 +1,13 @@
TOPDIR = ../../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
ReaderWriterTRANS.cpp\
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
TARGET_BASENAME = trans
include $(TOPDIR)/Make/cygwin_plugin_def
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
include $(TOPDIR)/Make/makerules

View File

@@ -0,0 +1,109 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial
* applications, as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
/* file: src/osgPlugins/trans/ReaderWriterTRANS.cpp
* author: Mike Weiblen http://mew.cx/ 2004-04-25
* copyright: (C) 2004 Michael Weiblen
* license: OpenSceneGraph Public License (OSGPL)
*/
#include <osg/Notify>
#include <osg/Matrix>
#include <osg/MatrixTransform>
#include <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <stdio.h>
#define EXTENSION_NAME "trans"
///////////////////////////////////////////////////////////////////////////
/**
* An OSG reader plugin for the translation pseudo-loader.
*/
class ReaderWriterTRANS : public osgDB::ReaderWriter
{
public:
ReaderWriterTRANS() { }
virtual const char* className() { return "translation pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension)
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
virtual ReadResult readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* /*options*/)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if( !acceptsExtension(ext) )
return ReadResult::FILE_NOT_HANDLED;
osg::notify(osg::INFO) << "ReaderWriterTRANS( \"" << fileName << "\" )" << std::endl;
// strip the pseudo-loader extension
std::string tmpName = osgDB::getNameLessExtension( fileName );
// get the next "extension", which actually contains the pseudo-loader parameters
std::string params = osgDB::getFileExtension( tmpName );
if( params.empty() )
{
osg::notify(osg::WARN) << "Missing parameters for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// strip the "params extension", which must leave a sub-filename.
std::string subFileName = osgDB::getNameLessExtension( tmpName );
if( subFileName == tmpName )
{
osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::notify(osg::INFO) << EXTENSION_NAME " params = \"" << params << "\"" << std::endl;
int tx, ty, tz;
int count = sscanf( params.c_str(), "%d,%d,%d", &tx, &ty, &tz );
if( count != 3 )
{
osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName );
if( !node )
{
// propagate the read failure upwards
osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl;
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::translate( tx, ty, tz ) );
xform->addChild( node );
return xform;
}
};
// Add ourself to the Registry to instantiate the reader/writer.
osgDB::RegisterReaderWriterProxy<ReaderWriterTRANS> g_readerWriter_TRANS_Proxy;
/*EOF*/

View File

@@ -165,7 +165,7 @@ void MultiSwitch::expandToEncompassSwitchSet(unsigned int switchSet)
_values.resize(switchSet+1);
for(unsigned int i=originalSize;i<=switchSet;++i)
{
ValueList& values = _values[switchSet];
ValueList& values = _values[i];
values.resize(_children.size(),_newChildDefaultValue);
}
}