Show
Ignore:
Timestamp:
11/24/08 15:26:04 (3 years ago)
Author:
robert
Message:

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"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/dae/daeWTransforms.cpp

    r9045 r9228  
    1818#include <dom/domNode.h> 
    1919#include <dom/domConstants.h> 
     20#include <dae/domAny.h> 
     21 
     22#include <osgSim/DOFTransform> 
    2023 
    2124using namespace osgdae; 
     
    3538    } 
    3639 
    37     currentNode = daeSafeCast< domNode >(currentNode->createAndPlace( COLLADA_ELEMENT_NODE ) ); 
     40    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) ); 
    3841    currentNode->setId(getNodeName(node,"matrixTransform").c_str()); 
    3942     
    40     domMatrix *mat = daeSafeCast< domMatrix >(currentNode->createAndPlace( COLLADA_ELEMENT_MATRIX ) ); 
     43    domMatrix *mat = daeSafeCast< domMatrix >(currentNode->add( COLLADA_ELEMENT_MATRIX ) ); 
    4144    const osg::Matrix::value_type *mat_vals = node.getMatrix().ptr(); 
    4245    //for ( int i = 0; i < 16; i++ ) 
     
    6164    mat->getValue().append( mat_vals[15] ); 
    6265 
    63     lastVisited = MATRIX; 
    6466    lastDepth = _nodePath.size(); 
     67 
     68    writeNodeExtra(node); 
    6569 
    6670    traverse( node ); 
     
    8084        lastDepth--; 
    8185    } 
    82     currentNode = daeSafeCast< domNode >(currentNode->createAndPlace( COLLADA_ELEMENT_NODE ) ); 
     86    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) ); 
    8387    currentNode->setId(getNodeName(node,"positionAttitudeTransform").c_str()); 
    8488     
     
    9094    { 
    9195        //make a scale 
    92         domScale *scale = daeSafeCast< domScale >( currentNode->createAndPlace( COLLADA_ELEMENT_SCALE ) ); 
     96        domScale *scale = daeSafeCast< domScale >( currentNode->add( COLLADA_ELEMENT_SCALE ) ); 
    9397        scale->getValue().append( s.x() ); 
    9498        scale->getValue().append( s.y() ); 
     
    102106    { 
    103107        //make a rotate 
    104         domRotate *rot = daeSafeCast< domRotate >( currentNode->createAndPlace( COLLADA_ELEMENT_ROTATE ) ); 
     108        domRotate *rot = daeSafeCast< domRotate >( currentNode->add( COLLADA_ELEMENT_ROTATE ) ); 
    105109        rot->getValue().append( axis.x() ); 
    106110        rot->getValue().append( axis.y() ); 
     
    112116    { 
    113117        //make a translate 
    114         domTranslate *trans = daeSafeCast< domTranslate >( currentNode->createAndPlace( COLLADA_ELEMENT_TRANSLATE ) ); 
     118        domTranslate *trans = daeSafeCast< domTranslate >( currentNode->add( COLLADA_ELEMENT_TRANSLATE ) ); 
    115119        trans->getValue().append( pos.x() ); 
    116120        trans->getValue().append( pos.y() ); 
     
    118122    } 
    119123 
    120     lastVisited = POSATT; 
     124    writeNodeExtra(node); 
     125 
    121126    lastDepth = _nodePath.size(); 
    122127 
     
    126131void daeWriter::apply( osg::Transform &node )  
    127132{ 
    128     osg::notify( osg::WARN ) << "some other transform type. Missing " << node.getNumChildren() << " children\n"; 
     133    debugPrint( node ); 
     134 
     135    while ( lastDepth >= _nodePath.size() ) 
     136    { 
     137        // We are not a child of previous node 
     138        currentNode = daeSafeCast< domNode >( currentNode->getParentElement() ); 
     139        lastDepth--; 
     140    } 
     141    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) ); 
     142     
     143    // If a DOFTransform node store it's data as extra "DOFTransform" data in the "OpenSceneGraph" technique 
     144    osgSim::DOFTransform* dof = dynamic_cast<osgSim::DOFTransform*>(&node); 
     145    if (writeExtras && dof) 
     146    { 
     147        // Adds the following to a node 
     148 
     149        //<extra type="DOFTransform"> 
     150        //    <technique profile="OpenSceneGraph"> 
     151        //        <MinHPR>0 -0.174533 0</MinHPR> 
     152        //        <MaxHPR>0 0.872665 0</MaxHPR> 
     153        //        <IncrementHPR>0 0.0174533 0</IncrementHPR> 
     154        //        <CurrentHPR>0 0 0</CurrentHPR> 
     155        //        <MinTranslate>0 0 0</MinTranslate> 
     156        //        <MaxTranslate>0 0 0</MaxTranslate> 
     157        //        <IncrementTranslate>0 0 0</IncrementTranslate> 
     158        //        <CurrentTranslate>0 0 0</CurrentTranslate> 
     159        //        <MinScale>0 0 0</MinScale> 
     160        //        <MaxScale>1 1 1</MaxScale> 
     161        //        <IncrementScale>0 0 0</IncrementScale> 
     162        //        <CurrentScale>1 1 1</CurrentScale> 
     163        //        <MultOrder>0</MultOrder> 
     164        //        <LimitationFlags>269964960</LimitationFlags> 
     165        //        <AnimationOn>0</AnimationOn> 
     166        //        <PutMatrix> 
     167        //            1 0 0 0 
     168        //            0 1 0 0 
     169        //            0 0 1 0 
     170        //            0 0 0 1 
     171        //        </PutMatrix> 
     172        //    </technique> 
     173        //</extra> 
     174 
     175        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA )); 
     176        extra->setType("DOFTransform"); 
     177        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) ); 
     178        teq->setProfile( "OpenSceneGraph" ); 
     179 
     180        domAny *minHPR = (domAny*)teq->add("MinHPR" ); 
     181        minHPR->setValue(toString(dof->getMinHPR()).c_str()); 
     182 
     183        domAny *maxHPR = (domAny*)teq->add("MaxHPR" ); 
     184        maxHPR->setValue(toString(dof->getMaxHPR()).c_str()); 
     185 
     186        domAny *incrementHPR = (domAny*)teq->add("IncrementHPR" ); 
     187        incrementHPR->setValue(toString(dof->getIncrementHPR()).c_str()); 
     188 
     189        domAny *currentHPR = (domAny*)teq->add("CurrentHPR" ); 
     190        currentHPR->setValue(toString(dof->getCurrentHPR()).c_str()); 
     191 
     192        domAny *minTranslate = (domAny*)teq->add("MinTranslate" ); 
     193        minTranslate->setValue(toString(dof->getMinTranslate()).c_str()); 
     194 
     195        domAny *maxTranslate = (domAny*)teq->add("MaxTranslate" ); 
     196        maxTranslate->setValue(toString(dof->getMaxTranslate()).c_str()); 
     197 
     198        domAny *incrementTranslate = (domAny*)teq->add("IncrementTranslate" ); 
     199        incrementTranslate->setValue(toString(dof->getIncrementTranslate()).c_str()); 
     200 
     201        domAny *currentTranslate = (domAny*)teq->add("CurrentTranslate" ); 
     202        currentTranslate->setValue(toString(dof->getCurrentTranslate()).c_str()); 
     203 
     204        domAny *minScale = (domAny*)teq->add("MinScale" ); 
     205        minScale->setValue(toString(dof->getMinScale()).c_str()); 
     206 
     207        domAny *maxScale = (domAny*)teq->add("MaxScale" ); 
     208        maxScale->setValue(toString(dof->getMaxScale()).c_str()); 
     209 
     210        domAny *incrementScale = (domAny*)teq->add("IncrementScale" ); 
     211        incrementScale->setValue(toString(dof->getIncrementScale()).c_str()); 
     212 
     213        domAny *currentScale = (domAny*)teq->add("CurrentScale" ); 
     214        currentScale->setValue(toString(dof->getCurrentScale()).c_str()); 
     215 
     216        domAny *multOrder = (domAny*)teq->add("MultOrder" ); 
     217        multOrder->setValue(toString<int>(dof->getHPRMultOrder()).c_str()); 
     218 
     219        domAny *limitationFlags = (domAny*)teq->add("LimitationFlags" ); 
     220        limitationFlags->setValue(toString<unsigned long>(dof->getLimitationFlags()).c_str()); 
     221 
     222        domAny *animationOn = (domAny*)teq->add("AnimationOn" ); 
     223        animationOn->setValue(toString<bool>(dof->getAnimationOn()).c_str()); 
     224 
     225        domAny *putMatrix = (domAny*)teq->add("PutMatrix" ); 
     226        putMatrix->setValue(toString(dof->getPutMatrix()).c_str());         
     227 
     228        currentNode->setId(getNodeName(node, "doftransform").c_str()); 
     229    } 
     230    else 
     231    { 
     232        currentNode->setId(getNodeName(node, "transform").c_str()); 
     233        osg::notify( osg::WARN ) << "some other transform type. Missing " << node.getNumChildren() << " children" << std::endl; 
     234    } 
     235 
     236    writeNodeExtra(node); 
     237 
     238    lastDepth = _nodePath.size(); 
     239 
     240    traverse( node ); 
    129241} 
    130242 
    131243void daeWriter::apply( osg::CoordinateSystemNode &node )  
    132244{ 
    133     osg::notify( osg::WARN ) << "CoordinateSystemNode. Missing " << node.getNumChildren() << " children\n"; 
    134 } 
     245    osg::notify( osg::WARN ) << "CoordinateSystemNode. Missing " << node.getNumChildren() << " children" << std::endl; 
     246}