Hi Victor,

I'm not sure if this can help you, but have a look in your global options if the OSG export setting includeExternalReferences might be set, it forces proxy nodes to be represented inline. Or of you're not 100% sure that the scene graph is okay before writing, the FLT import setting keepExternalReferences might be missing when loading the original model.

Regards,
Andreas


On 2022-09-30 15:27, [email protected] wrote:
Hello

I am trying to move the tiles of my database creating a MatrixTransform, converting the external files (airports and buildings) to osgb and setting the path of the ProxyNode object to refer these external models, to avoid imprecision float flicks. I am loading this models, visiting all nodes and moving the drawable vertex to origin ( 0, 0, 0 ), then, when i add the ProxyNode as child of the MatrixTransform obj and write the file, the osg::MatrixTransform cast to an osg::Group writing the external model in the tile model. When i debug this Node, the hierarchy is correctly, but when i save it, the problem appears.
Can someone help me with that?

This is what i expected:
osg::MatrixTransform {
    UniqueID 8854
    DataVariance STATIC
    Children 1 {
    osg::ProxyNode {
        UniqueID 8855
        UserDataContainer TRUE {
        osg::DefaultUserDataContainer {
            UniqueID 8856
            UDC_Descriptions 1 {
            "VBS2AttrHdl:1190864"
            }
        }
        }
        FileNames 1 {
        "gerador.FLT"
        }
    }
    }
    Matrix {
    0.581112 0.813823 3.92761e-07 0
    0.0764085 -0.0545602 0.995583 0
    0.810226 -0.578549 -0.0938889 0
    5.16795e+06 -3.69022e+06 -594853 1
    }

}

===========================

This is what osg wrote:
osg::Group {
    UniqueID 8882
    Name "external__file"
    DataVariance STATIC
    Children 1 {
    osg::Group {
        UniqueID 8883
        UserDataContainer TRUE {
        osg::DefaultUserDataContainer {
            UniqueID 8884
            UDC_Descriptions 1 {
            "VBS2AttrHdl:1190864"
            }
        }
        }
        Children 1 {
        osg::Group {
            UniqueID 8885
            Name "db"
            UserDataContainer TRUE {
            osg::DefaultUserDataContainer {
                UniqueID 8886
            }
            }
            .....................

===========================

This is the code:

osg::ProxyNode*externalPointerNode=dynamic_cast<osg::ProxyNode*>(n);
if( externalPointerNode )
{
    osg::Group* parent = ( externalPointerNode->getParent( 0 ) );
    osg::MatrixTransform* parentMt = dynamic_cast< osg::MatrixTransform* >( parent );
    if( !parentMt )
    {

        //create a copy to add in matrix
//                            osg::ProxyNode* externalPointerNodeCopy = new osg::ProxyNode(); //                            osg::ref_ptr< osg::ProxyNode > externalPointerNodeCopy = osg::clone( externalPointerNode, osg::CopyOp::DEEP_COPY_NODES );         osg::ref_ptr< osg::ProxyNode > externalPointerNodeCopy = osg::clone( externalPointerNode );

        GeodeFinder parentFinder;

        //File names
        std::string originalFileName = externalPointerNode->getFileName(0);
        std::string oldFilePath = mainPath + originalFileName;
        std::string newFilePath = oldFilePath;
        myReplace( newFilePath, ".flt", ".osgb" );
        myReplace( newFilePath, ".FLT", ".osgb" );
        myReplace( newFilePath, "\\", "/" );

        //remove old pointer to airport file
        parent->removeChild( externalPointerNode );

        //load airport
        osg::ref_ptr< osg::Node > loadedNode = osgDB::readNodeFile( oldFilePath );

        //airport bounding sphere
        auto bb = loadedNode->getBound();

        //Creating new matrix that will hold the external pointer
        osg::MatrixTransform* newMt = new osg::MatrixTransform;
        newMt->setName( "external__file" );
        newMt->setMatrix( osg::Matrixd::translate( bb.center() ) );
        newMt->setDataVariance( osg::Object::DataVariance::STATIC );

        newMt->addChild( externalPointerNodeCopy );
        //add the matrix to old parent of pointer node
        parent->addChild( newMt );

        //find all geode node
        parentFinder.find( loadedNode );

        //Move nodes of external airport
        moveAllVertex( parentFinder.getNodeList(), bb.center() );

        //set file path
        externalPointerNodeCopy->setFileName( 0, newFilePath );

        //save converted model
        osgDB::writeNodeFile( *loadedNode, newFilePath );
        std::cout << "File saved " << newFilePath << std::endl;

    }
}

Regaards,

Victor.

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/0aa51655-2585-409b-af10-9a3e96213e52n%40googlegroups.com <https://groups.google.com/d/msgid/osg-users/0aa51655-2585-409b-af10-9a3e96213e52n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/fb54df7f-7b34-d3f6-f99f-80e779266478%40remograph.com.

Reply via email to