From Garrett Potts and Robert Osfield, changes to build against Collada DOM 2.x
This commit is contained in:
parent
38133f8772
commit
973f104704
@ -18,7 +18,9 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/usr/local/include/colladadom
|
||||
/usr/include/
|
||||
/usr/include/colladadom
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
@ -28,7 +30,7 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_LIBRARY
|
||||
NAMES collada_dom
|
||||
NAMES collada_dom collada14dom
|
||||
PATHS
|
||||
$ENV{COLLADA_DIR}/lib
|
||||
$ENV{COLLADA_DIR}/lib-dbg
|
||||
@ -39,7 +41,9 @@ FIND_LIBRARY(COLLADA_LIBRARY
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
|
@ -45,9 +45,9 @@ ELSE (WIN32)
|
||||
#
|
||||
# ...so what we need is a conditional way to properly SET() the right one.
|
||||
IF(COLLADA_USE_STATIC)
|
||||
SET(TARGET_EXTERNAL_LIBRARIES collada_dom collada_dae xml2 pcrecpp)
|
||||
SET(TARGET_EXTERNAL_LIBRARIES collada14dom xml2 pcrecpp)
|
||||
ELSE(COLLADA_USE_STATIC)
|
||||
SET(TARGET_EXTERNAL_LIBRARIES collada_dom_shared collada_dae_shared xml2)
|
||||
SET(TARGET_EXTERNAL_LIBRARIES collada14dom xml2)
|
||||
ENDIF(COLLADA_USE_STATIC)
|
||||
|
||||
ENDIF(WIN32)
|
||||
|
@ -311,7 +311,8 @@ osg::Node* daeReader::processPolylist( domPolylist *group, SourceMap &sources )
|
||||
|
||||
osg::DrawArrayLengths* dal = new osg::DrawArrayLengths( GL_POLYGON );
|
||||
|
||||
domPRef p = (domP*)(daeElement*)domP::_Meta->create(); //I don't condone creating elements like this but I don't care
|
||||
//domPRef p = (domP*)(daeElement*)domP::_Meta->create(); //I don't condone creating elements like this but I don't care
|
||||
domPRef p = (domP*)domP::registerElement(*dae)->create().cast();
|
||||
//if it created properly because I never want it as part of the document. Its just a temporary
|
||||
//element to trick the importer into loading polylists easier.
|
||||
unsigned int maxOffset = 0;
|
||||
|
@ -615,43 +615,39 @@ osg::StateAttribute *daeReader::processTexture( domCommon_color_or_texture_type_
|
||||
osg::Image *img = NULL;
|
||||
if ( dImg->getInit_from() != NULL )
|
||||
{
|
||||
// daeURI uri = dImg->getInit_from()->getValue();
|
||||
dImg->getInit_from()->getValue().validate();
|
||||
|
||||
if ( std::string( dImg->getInit_from()->getValue().getProtocol() ) == std::string( "file" ) )
|
||||
{
|
||||
unsigned int bufSize = 1; //for the null char
|
||||
if ( dImg->getInit_from()->getValue().getFilepath() != NULL )
|
||||
{
|
||||
bufSize += strlen( dImg->getInit_from()->getValue().getFilepath() );
|
||||
}
|
||||
if ( dImg->getInit_from()->getValue().getFile() != NULL )
|
||||
{
|
||||
bufSize += strlen( dImg->getInit_from()->getValue().getFile() );
|
||||
}
|
||||
char *path = new char[bufSize+1];
|
||||
if ( !dImg->getInit_from()->getValue().getPath( path, bufSize ) )
|
||||
{
|
||||
osg::notify( osg::WARN ) << "Unable to get path from URI." << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//unsigned int bufSize = 1; //for the null char
|
||||
//bufSize += dImg->getInit_from()->getValue().pathDir().size();
|
||||
//bufSize += dImg->getInit_from()->getValue().pathFile().size();
|
||||
std::string path = dImg->getInit_from()->getValue().pathDir()+
|
||||
dImg->getInit_from()->getValue().pathFile();
|
||||
// remove space encodings
|
||||
//
|
||||
path = cdom::uriToNativePath(path);
|
||||
if(path.empty())
|
||||
{
|
||||
osg::notify( osg::WARN ) << "Unable to get path from URI." << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef WIN32
|
||||
// If the path has a drive specifier or a UNC name then strip the leading /
|
||||
char* filename;
|
||||
const char* filename =path.c_str();
|
||||
if ((path[2] == ':') || ((path[1] == '/') && (path[2] == '/')))
|
||||
filename = path+1;
|
||||
else
|
||||
filename = path;
|
||||
++filename;// = path+1;
|
||||
// else
|
||||
// filename = path;
|
||||
#else
|
||||
char* filename = path;
|
||||
const char* filename = path.c_str();
|
||||
#endif
|
||||
|
||||
img = osgDB::readImageFile( filename );
|
||||
|
||||
osg::notify(osg::INFO)<<" processTexture(..) - readImage("<<filename<<")"<<std::endl;
|
||||
|
||||
//Moved this below the osg::notify - Parag, 24/7/2007
|
||||
delete [] path;
|
||||
//delete [] path;
|
||||
|
||||
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void daeWriter::processMaterial( osg::StateSet *ss, domInstance_geometry *ig, co
|
||||
osg::Image *osgimg = tex->getImage( 0 );
|
||||
domImage::domInit_from *imgif = daeSafeCast< domImage::domInit_from >( img->createAndPlace( "init_from" ) );
|
||||
std::string fileURI = ReaderWriterDAE::ConvertFilePathToColladaCompatibleURI(osgDB::findDataFile(osgimg->getFileName()));
|
||||
daeURI dd( fileURI.c_str() );
|
||||
daeURI dd(*dae, fileURI);//fileURI.c_str() );
|
||||
imgif->setValue( dd );
|
||||
// The document URI should contain the canonical path it was created with
|
||||
imgif->getValue().makeRelativeTo(doc->getDocumentURI());
|
||||
|
@ -24,6 +24,7 @@ using namespace osgdae;
|
||||
|
||||
daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons, bool GoogleMode ) : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN ),
|
||||
dae(dae_),
|
||||
rootName(*dae_),
|
||||
usePolygons (_usePolygons),
|
||||
m_GoogleMode(GoogleMode)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user