From Michael Platings, "Here's the all-new, all-dancing DAE plugin, with support for reading
osgAnimation. It's been tested with the majority of the samples in the COLLADA test repository and works with all of them either as well as, or better than, the version of the plugin currently in SVN. Known issue: vertex animation (AKA morphing) doesn't work at present, but that's a relatively unpopular method of animating so it's not high on my priority list." Follow up email: "I've been informed that the previous DAE submission didn't build on unix, so here's the submission again with the fixes. Thanks to Gregory Potdevin and Benjamin Bozou. Also, my apologies to Roland for not crediting his part in making DAE animation happen, my work was indeed built on top of his work. Thanks also to Marius Heise and of course Cedric Pinson." Changes by Robert Osfield, fixed compile issues when compile without C* automatic conversion enabled in ref_ptr<> and constructor initialization fixes to address some warnings under gcc.
This commit is contained in:
@@ -21,16 +21,9 @@
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace osgdae {
|
||||
namespace osgDAE {
|
||||
|
||||
std::string toString(osg::Vec3f value)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << value.x() << " " << value.y() << " " << value.z();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string toString(osg::Vec3d value)
|
||||
std::string toString(osg::Vec3 value)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << value.x() << " " << value.y() << " " << value.z();
|
||||
@@ -50,11 +43,11 @@ std::string toString(osg::Matrix value)
|
||||
|
||||
daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons, bool GoogleMode, TraversalMode tm, bool _writeExtras) : osg::NodeVisitor( tm ),
|
||||
dae(dae_),
|
||||
_domLibraryAnimations(NULL),
|
||||
writeExtras(_writeExtras),
|
||||
rootName(*dae_),
|
||||
usePolygons (_usePolygons),
|
||||
m_GoogleMode(GoogleMode),
|
||||
m_CurrentRenderingHint(osg::StateSet::DEFAULT_BIN)
|
||||
m_GoogleMode(GoogleMode)
|
||||
{
|
||||
success = true;
|
||||
|
||||
@@ -64,12 +57,12 @@ daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons,
|
||||
dae->getDatabase()->createDocument( fileURI.c_str(), &doc );
|
||||
dom = (domCOLLADA*)doc->getDomRoot();
|
||||
//create scene and instance visual scene
|
||||
domCOLLADA::domScene *scene = daeSafeCast< domCOLLADA::domScene >( dom->add(COLLADA_ELEMENT_SCENE));
|
||||
domInstanceWithExtra *ivs = daeSafeCast< domInstanceWithExtra >( scene->add(COLLADA_ELEMENT_INSTANCE_VISUAL_SCENE));
|
||||
domCOLLADA::domScene *scene = daeSafeCast< domCOLLADA::domScene >( dom->add( COLLADA_ELEMENT_SCENE ) );
|
||||
domInstanceWithExtra *ivs = daeSafeCast< domInstanceWithExtra >( scene->add( COLLADA_ELEMENT_INSTANCE_VISUAL_SCENE ) );
|
||||
ivs->setUrl( "#defaultScene" );
|
||||
//create library visual scenes and a visual scene and the root node
|
||||
lib_vis_scenes = daeSafeCast<domLibrary_visual_scenes>( dom->add(COLLADA_ELEMENT_LIBRARY_VISUAL_SCENES));
|
||||
vs = daeSafeCast< domVisual_scene >( lib_vis_scenes->add(COLLADA_ELEMENT_VISUAL_SCENE));
|
||||
lib_vis_scenes = daeSafeCast<domLibrary_visual_scenes>( dom->add( COLLADA_ELEMENT_LIBRARY_VISUAL_SCENES ) );
|
||||
vs = daeSafeCast< domVisual_scene >( lib_vis_scenes->add( COLLADA_ELEMENT_VISUAL_SCENE ) );
|
||||
vs->setId( "defaultScene" );
|
||||
currentNode = daeSafeCast< domNode >( vs->add( COLLADA_ELEMENT_NODE ) );
|
||||
currentNode->setId( "sceneRoot" );
|
||||
@@ -79,12 +72,16 @@ daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons,
|
||||
|
||||
lib_cameras = NULL;
|
||||
lib_effects = NULL;
|
||||
lib_controllers = NULL;
|
||||
lib_geoms = NULL;
|
||||
lib_lights = NULL;
|
||||
lib_mats = NULL;
|
||||
|
||||
lastDepth = 0;
|
||||
|
||||
// Clean up caches
|
||||
uniqueNames.clear();
|
||||
|
||||
currentStateSet = new osg::StateSet();
|
||||
}
|
||||
|
||||
@@ -104,20 +101,12 @@ void daeWriter::debugPrint( osg::Node &node )
|
||||
#endif
|
||||
}
|
||||
|
||||
bool daeWriter::writeFile()
|
||||
{
|
||||
if ( dae->save( (daeUInt)0 ) != DAE_OK )
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void daeWriter::setRootNode( const osg::Node &node )
|
||||
{
|
||||
std::string fname = osgDB::findDataFile( node.getName() );
|
||||
//rootName = fname.c_str();
|
||||
//rootName.validate();
|
||||
|
||||
const_cast<osg::Node*>(&node)->accept( _animatedNodeCollector );
|
||||
}
|
||||
|
||||
//### provide a name to node
|
||||
@@ -166,6 +155,8 @@ void daeWriter::createAssetTag()
|
||||
domAsset::domCreated *c = daeSafeCast< domAsset::domCreated >(asset->add(COLLADA_ELEMENT_CREATED));
|
||||
domAsset::domModified *m = daeSafeCast< domAsset::domModified >(asset->add(COLLADA_ELEMENT_MODIFIED));
|
||||
domAsset::domUnit *u = daeSafeCast< domAsset::domUnit >(asset->add(COLLADA_ELEMENT_UNIT));
|
||||
domAsset::domUp_axis *up = daeSafeCast< domAsset::domUp_axis >(asset->add(COLLADA_ELEMENT_UP_AXIS));
|
||||
up->setValue(UPAXISTYPE_Z_UP);
|
||||
|
||||
//TODO : set date and time
|
||||
c->setValue( "2006-07-25T00:00:00Z" );
|
||||
|
||||
Reference in New Issue
Block a user