Exemplo n.º 1
0
void
FltExportVisitor::apply( osg::ProxyNode& node )
{
    _firstNode = false;
    ScopedStatePushPop guard( this, node.getStateSet() );

    writeExternalReference( node );
    writeMatrix( node.getUserData() );
    writeComment( node );
}
void
FltExportVisitor::writeExternalReference(const osg::ProxyNode &proxy)
{
    uint16 length(216);

    // Set sane defaults for the override flags
    unsigned long flags = COLOR_PALETTE_OVERRIDE |
                          MATERIAL_PALETTE_OVERRIDE |
                          TEXTURE_PALETTE_OVERRIDE |
                          LIGHT_POINT_PALETTE_OVERRIDE |
                          SHADER_PALETTE_OVERRIDE;

    // Selectively turn off overrides for resources we don't need
    const ParentPools *pp = dynamic_cast<const ParentPools*>(proxy.getUserData());

    if (pp && pp->getColorPool())
        flags &= ~COLOR_PALETTE_OVERRIDE;

    if (pp && pp->getMaterialPool())
        flags &= ~MATERIAL_PALETTE_OVERRIDE;

    if (pp && pp->getTexturePool())
        flags &= ~TEXTURE_PALETTE_OVERRIDE;

    if (pp && pp->getLightSourcePool())
        flags &= ~LIGHT_SOURCE_PALETTE_OVERRIDE;

    if (pp && pp->getLPAppearancePool())
        flags &= ~LIGHT_POINT_PALETTE_OVERRIDE;

    if (pp && pp->getShaderPool())
        flags &= ~SHADER_PALETTE_OVERRIDE;

    _records->writeInt16((int16) EXTERNAL_REFERENCE_OP);
    _records->writeInt16(length);
    _records->writeString(proxy.getFileName(0), 200);
    _records->writeInt32(0);   // Reserved
    _records->writeInt32(flags);
    _records->writeInt16(0);   // ViewAsBoundingBox flag
    _records->writeInt16(0);   // Reserved
}