From Roland Smeenk, "Overview of the Collada/dae plugin changes
New features +Read and write of osg::LOD, osg::Switch, osgSim::Sequence, osgim::MultiSwitch and osgSim::DOFTransform data in <extra> +Read and write of osg::Node description data in <extra> +Plugin option "NoExtras" to prevent writing of <extra> data and only traverse the active children when saving Changes/additions +instanced_geometry and instanced_controller are now loaded in a single Geode with multiple Geometries instead of multiple geodes with a single Geometry +Changed all calls to the deprecated createAndPlace() to the new add() methods +All transformation elements <scale>, <rotate>, <translate>, <lookat>, <matrix>, <skew> are now concatenated properly in to a single MatrixTransform. Previously this was not done in order as required by Collada and and not all elements were included. +Complete skew matrix creation +Automatically add GL_RESCALE_NORMAL if scale is non-identity +Blinn shininess remapping to [0,128] when in range [0,1] +Changes to CMake file to make it compile on Windows +Coding style and code documentation Bug fixes +Transparent texture writing fixed +Fixed bug in using osg node name as collada node ID +Fixed usage of double sided faces in GOOGLEEARTH extra +Not adding blendfunc and blendcolor when opaque TODO/Wishlist -solve differences in drawables, DAE reader should place multiple collation elements into multiple primitivesets in a single geometry where possible (only when same material) -solve differences in matrices -multitexture support -skinned mesh and generic animations using osgAnimation -profile_GLSL based on COLLADA OpenGL Effects Viewer http://ati.amd.com/developer/rendermonkey/downloads.html -handling more <extra> to more closely mimic the intended lighting"
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
|
||||
#include <dom/domNode.h>
|
||||
#include <dom/domConstants.h>
|
||||
#include <dae/domAny.h>
|
||||
|
||||
#include <osgSim/DOFTransform>
|
||||
|
||||
using namespace osgdae;
|
||||
|
||||
@@ -34,10 +37,10 @@ void daeWriter::apply( osg::MatrixTransform &node )
|
||||
lastDepth--;
|
||||
}
|
||||
|
||||
currentNode = daeSafeCast< domNode >(currentNode->createAndPlace( COLLADA_ELEMENT_NODE ) );
|
||||
currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
|
||||
currentNode->setId(getNodeName(node,"matrixTransform").c_str());
|
||||
|
||||
domMatrix *mat = daeSafeCast< domMatrix >(currentNode->createAndPlace( COLLADA_ELEMENT_MATRIX ) );
|
||||
domMatrix *mat = daeSafeCast< domMatrix >(currentNode->add( COLLADA_ELEMENT_MATRIX ) );
|
||||
const osg::Matrix::value_type *mat_vals = node.getMatrix().ptr();
|
||||
//for ( int i = 0; i < 16; i++ )
|
||||
//{
|
||||
@@ -60,9 +63,10 @@ void daeWriter::apply( osg::MatrixTransform &node )
|
||||
mat->getValue().append( mat_vals[11] );
|
||||
mat->getValue().append( mat_vals[15] );
|
||||
|
||||
lastVisited = MATRIX;
|
||||
lastDepth = _nodePath.size();
|
||||
|
||||
writeNodeExtra(node);
|
||||
|
||||
traverse( node );
|
||||
}
|
||||
|
||||
@@ -79,7 +83,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
currentNode = daeSafeCast< domNode >( currentNode->getParentElement() );
|
||||
lastDepth--;
|
||||
}
|
||||
currentNode = daeSafeCast< domNode >(currentNode->createAndPlace( COLLADA_ELEMENT_NODE ) );
|
||||
currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
|
||||
currentNode->setId(getNodeName(node,"positionAttitudeTransform").c_str());
|
||||
|
||||
const osg::Vec3 &pos = node.getPosition();
|
||||
@@ -89,7 +93,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
if ( s.x() != 1 || s.y() != 1 || s.z() != 1 )
|
||||
{
|
||||
//make a scale
|
||||
domScale *scale = daeSafeCast< domScale >( currentNode->createAndPlace( COLLADA_ELEMENT_SCALE ) );
|
||||
domScale *scale = daeSafeCast< domScale >( currentNode->add( COLLADA_ELEMENT_SCALE ) );
|
||||
scale->getValue().append( s.x() );
|
||||
scale->getValue().append( s.y() );
|
||||
scale->getValue().append( s.z() );
|
||||
@@ -101,7 +105,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
if ( angle != 0 )
|
||||
{
|
||||
//make a rotate
|
||||
domRotate *rot = daeSafeCast< domRotate >( currentNode->createAndPlace( COLLADA_ELEMENT_ROTATE ) );
|
||||
domRotate *rot = daeSafeCast< domRotate >( currentNode->add( COLLADA_ELEMENT_ROTATE ) );
|
||||
rot->getValue().append( axis.x() );
|
||||
rot->getValue().append( axis.y() );
|
||||
rot->getValue().append( axis.z() );
|
||||
@@ -111,13 +115,14 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
if ( pos.x() != 0 || pos.y() != 0 || pos.z() != 0 )
|
||||
{
|
||||
//make a translate
|
||||
domTranslate *trans = daeSafeCast< domTranslate >( currentNode->createAndPlace( COLLADA_ELEMENT_TRANSLATE ) );
|
||||
domTranslate *trans = daeSafeCast< domTranslate >( currentNode->add( COLLADA_ELEMENT_TRANSLATE ) );
|
||||
trans->getValue().append( pos.x() );
|
||||
trans->getValue().append( pos.y() );
|
||||
trans->getValue().append( pos.z() );
|
||||
}
|
||||
|
||||
lastVisited = POSATT;
|
||||
writeNodeExtra(node);
|
||||
|
||||
lastDepth = _nodePath.size();
|
||||
|
||||
traverse( node );
|
||||
@@ -125,10 +130,117 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
|
||||
void daeWriter::apply( osg::Transform &node )
|
||||
{
|
||||
osg::notify( osg::WARN ) << "some other transform type. Missing " << node.getNumChildren() << " children\n";
|
||||
debugPrint( node );
|
||||
|
||||
while ( lastDepth >= _nodePath.size() )
|
||||
{
|
||||
// We are not a child of previous node
|
||||
currentNode = daeSafeCast< domNode >( currentNode->getParentElement() );
|
||||
lastDepth--;
|
||||
}
|
||||
currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
|
||||
|
||||
// If a DOFTransform node store it's data as extra "DOFTransform" data in the "OpenSceneGraph" technique
|
||||
osgSim::DOFTransform* dof = dynamic_cast<osgSim::DOFTransform*>(&node);
|
||||
if (writeExtras && dof)
|
||||
{
|
||||
// Adds the following to a node
|
||||
|
||||
//<extra type="DOFTransform">
|
||||
// <technique profile="OpenSceneGraph">
|
||||
// <MinHPR>0 -0.174533 0</MinHPR>
|
||||
// <MaxHPR>0 0.872665 0</MaxHPR>
|
||||
// <IncrementHPR>0 0.0174533 0</IncrementHPR>
|
||||
// <CurrentHPR>0 0 0</CurrentHPR>
|
||||
// <MinTranslate>0 0 0</MinTranslate>
|
||||
// <MaxTranslate>0 0 0</MaxTranslate>
|
||||
// <IncrementTranslate>0 0 0</IncrementTranslate>
|
||||
// <CurrentTranslate>0 0 0</CurrentTranslate>
|
||||
// <MinScale>0 0 0</MinScale>
|
||||
// <MaxScale>1 1 1</MaxScale>
|
||||
// <IncrementScale>0 0 0</IncrementScale>
|
||||
// <CurrentScale>1 1 1</CurrentScale>
|
||||
// <MultOrder>0</MultOrder>
|
||||
// <LimitationFlags>269964960</LimitationFlags>
|
||||
// <AnimationOn>0</AnimationOn>
|
||||
// <PutMatrix>
|
||||
// 1 0 0 0
|
||||
// 0 1 0 0
|
||||
// 0 0 1 0
|
||||
// 0 0 0 1
|
||||
// </PutMatrix>
|
||||
// </technique>
|
||||
//</extra>
|
||||
|
||||
domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
|
||||
extra->setType("DOFTransform");
|
||||
domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
|
||||
teq->setProfile( "OpenSceneGraph" );
|
||||
|
||||
domAny *minHPR = (domAny*)teq->add("MinHPR" );
|
||||
minHPR->setValue(toString(dof->getMinHPR()).c_str());
|
||||
|
||||
domAny *maxHPR = (domAny*)teq->add("MaxHPR" );
|
||||
maxHPR->setValue(toString(dof->getMaxHPR()).c_str());
|
||||
|
||||
domAny *incrementHPR = (domAny*)teq->add("IncrementHPR" );
|
||||
incrementHPR->setValue(toString(dof->getIncrementHPR()).c_str());
|
||||
|
||||
domAny *currentHPR = (domAny*)teq->add("CurrentHPR" );
|
||||
currentHPR->setValue(toString(dof->getCurrentHPR()).c_str());
|
||||
|
||||
domAny *minTranslate = (domAny*)teq->add("MinTranslate" );
|
||||
minTranslate->setValue(toString(dof->getMinTranslate()).c_str());
|
||||
|
||||
domAny *maxTranslate = (domAny*)teq->add("MaxTranslate" );
|
||||
maxTranslate->setValue(toString(dof->getMaxTranslate()).c_str());
|
||||
|
||||
domAny *incrementTranslate = (domAny*)teq->add("IncrementTranslate" );
|
||||
incrementTranslate->setValue(toString(dof->getIncrementTranslate()).c_str());
|
||||
|
||||
domAny *currentTranslate = (domAny*)teq->add("CurrentTranslate" );
|
||||
currentTranslate->setValue(toString(dof->getCurrentTranslate()).c_str());
|
||||
|
||||
domAny *minScale = (domAny*)teq->add("MinScale" );
|
||||
minScale->setValue(toString(dof->getMinScale()).c_str());
|
||||
|
||||
domAny *maxScale = (domAny*)teq->add("MaxScale" );
|
||||
maxScale->setValue(toString(dof->getMaxScale()).c_str());
|
||||
|
||||
domAny *incrementScale = (domAny*)teq->add("IncrementScale" );
|
||||
incrementScale->setValue(toString(dof->getIncrementScale()).c_str());
|
||||
|
||||
domAny *currentScale = (domAny*)teq->add("CurrentScale" );
|
||||
currentScale->setValue(toString(dof->getCurrentScale()).c_str());
|
||||
|
||||
domAny *multOrder = (domAny*)teq->add("MultOrder" );
|
||||
multOrder->setValue(toString<int>(dof->getHPRMultOrder()).c_str());
|
||||
|
||||
domAny *limitationFlags = (domAny*)teq->add("LimitationFlags" );
|
||||
limitationFlags->setValue(toString<unsigned long>(dof->getLimitationFlags()).c_str());
|
||||
|
||||
domAny *animationOn = (domAny*)teq->add("AnimationOn" );
|
||||
animationOn->setValue(toString<bool>(dof->getAnimationOn()).c_str());
|
||||
|
||||
domAny *putMatrix = (domAny*)teq->add("PutMatrix" );
|
||||
putMatrix->setValue(toString(dof->getPutMatrix()).c_str());
|
||||
|
||||
currentNode->setId(getNodeName(node, "doftransform").c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
currentNode->setId(getNodeName(node, "transform").c_str());
|
||||
osg::notify( osg::WARN ) << "some other transform type. Missing " << node.getNumChildren() << " children" << std::endl;
|
||||
}
|
||||
|
||||
writeNodeExtra(node);
|
||||
|
||||
lastDepth = _nodePath.size();
|
||||
|
||||
traverse( node );
|
||||
}
|
||||
|
||||
void daeWriter::apply( osg::CoordinateSystemNode &node )
|
||||
{
|
||||
osg::notify( osg::WARN ) << "CoordinateSystemNode. Missing " << node.getNumChildren() << " children\n";
|
||||
osg::notify( osg::WARN ) << "CoordinateSystemNode. Missing " << node.getNumChildren() << " children" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user