Exemple #1
0
void WriterNodeVisitor::apply(osg::MatrixTransform &node)
{
    pushStateSet(node.getStateSet());
    Lib3dsMeshInstanceNode * parent = _cur3dsNode;
#if DISABLE_3DS_ANIMATION
    osg::Matrix mat( osg::computeLocalToWorld(getNodePath()) );
#else
    osg::Matrix mat( node.getMatrix() );
#endif
    apply3DSMatrixNode(node, &mat, "mtx");
    if (succeeded())
        traverse(node);
    _cur3dsNode = parent;
    popStateSet(node.getStateSet());
}
void
CountsVisitor::apply(osg::MatrixTransform& node)
{
    pushStateSet(node.getStateSet());

    _matrixTransforms++;
    osg::ref_ptr<osg::Object> rp = (osg::Object*)&node;
    _uMatrixTransforms.insert(rp);
    _totalChildren += node.getNumChildren();
    apply(node.getStateSet());

    if (++_depth > _maxDepth)
        _maxDepth = _depth;
    traverse((osg::Node&)node);
    _depth--;

    popStateSet();
}
void
FltExportVisitor::apply( osg::MatrixTransform& node )
{
    // Importer reads a Matrix record and inserts a MatrixTransform above
    //   the current node. We need to do the opposite: Write a Matrix record
    //   as an ancillary record for each child. We do that by storing the
    //   MatrixTransform in each child's UserData. Each child then checks
    //   UserData and writes a Matrix record if UserData is a MatrixTransform.

    _firstNode = false;
    ScopedStatePushPop guard( this, node.getStateSet() );

    osg::ref_ptr< osg::RefMatrix > m = new osg::RefMatrix;
    m->set( node.getMatrix() );
    if (node.getUserData())
    {
        const osg::RefMatrix* rm = dynamic_cast<const osg::RefMatrix*>( node.getUserData() );
        if (rm)
            (*m) *= *rm;
    }

    typedef std::vector< osg::ref_ptr< osg::Referenced > > UserDataList;
    
    UserDataList saveUserDataList( node.getNumChildren() );

    unsigned int idx;
    for( idx=0; idx<node.getNumChildren(); ++idx )
    {
        saveUserDataList[ idx ] = node.getChild( idx )->getUserData();
        node.getChild( idx )->setUserData( m.get() );
    }

    traverse( (osg::Node&)node );

    // Restore saved UserData.
    for( idx=0; idx< node.getNumChildren(); ++idx )
    {
      node.getChild( idx )->setUserData( saveUserDataList[ idx ].get() );
    }
}
 void                            apply( osg::MatrixTransform& node )
                                 {
                                     ++_numVisited;
                                     compileResource( node.getStateSet() );
                                     traverse( node );
                                 }