Example #1
0
Node *
ColladaInstanceNode::process(ColladaElement *parent)
{
    ColladaNodeRefPtr colNode = getTargetElem();

    return colNode->createInstance(this);
}
Node *
ColladaVisualScene::createInstance(ColladaInstanceElement *colInstElem)
{
    OSG_COLLADA_LOG(("ColladaVisualScene::createInstance\n"));

    ColladaInstanceVisualSceneRefPtr colInstVisScene =
        dynamic_cast<ColladaInstanceVisualScene *>(colInstElem);

    domVisual_sceneRef   visScene = getDOMElementAs<domVisual_scene>();
    const domNode_Array &nodes    = visScene->getNode_array         ();

    for(UInt32 i = 0; i < nodes.getCount(); ++i)
    {
        ColladaNodeRefPtr colNode = getUserDataAs<ColladaNode>(nodes[i]);

        if(colNode == NULL)
        {
            colNode = dynamic_pointer_cast<ColladaNode>(
                ColladaElementFactory::the()->create(nodes[i], getGlobal()));

            colNode->setVisualScene(this);
            colNode->read();
        }

        if(nodes.getCount() > 1)
        {
            if(_RootN == NULL)
            {
                GroupUnrecPtr group = Group::create();
                _RootN = makeNodeFor(group);
            }

            Node *childN = colNode->getTopNode();

            if(childN->getParent() != NULL)
            {
                SWARNING << "ColladaVisualScene::createInstance: <node> [" << i
                         << "] already has a parent." << std::endl;
            }

            _RootN->addChild(childN);
        }
        else
        {
            Node *childN = colNode->getTopNode();

            if(childN->getParent() != NULL)
            {
                SWARNING << "ColladaVisualScene::createInstance: <node> [" << i
                         << "] already has a parent." << std::endl;
            }

            _RootN = childN;
        }
    }

    editInstStore().push_back(_RootN);

    return _RootN;
}
void
ColladaNode::handleNode(domNode  *child,
                        InstData &instData)
{
    ColladaNodeRefPtr     colNodeChild = getUserDataAs<ColladaNode>(child);
    ColladaInstInfoRefPtr colInstInfo  =
        ColladaNodeInstInfo::create(this, NULL, instData._bottomN);

    Node *childN = colNodeChild->createInstance(colInstInfo);

    appendChild(child, childN, instData);
}
void
ColladaNode::readNode(domNode *child)
{
    ColladaNodeRefPtr colNodeChild = getUserDataAs<ColladaNode>(child);

    if(colNodeChild == NULL)
    {
        colNodeChild = dynamic_pointer_cast<ColladaNode>(
            ColladaElementFactory::the()->create(child, getGlobal()));

        colNodeChild->read(this);
    }
}
Example #5
0
void
ColladaInstanceNode::read(void)
{
    OSG_COLLADA_LOG(("ColladaInstanceNode::read\n"));

    ColladaNodeRefPtr colNode = getTargetElem();

    if(colNode == NULL)
    {
        colNode = dynamic_pointer_cast<ColladaNode>(
            ColladaElementFactory::the()->create(
                getTargetDOMElem(), getGlobal()));

        colNode->read();
    }
}
void
ColladaNode::handleNode(domNode *node)
{
    ColladaNodeRefPtr colNode = getUserDataAs<ColladaNode>(node);

    if(colNode == NULL)
    {
        colNode = dynamic_pointer_cast<ColladaNode>(
            ColladaElementFactory::the()->create(node, getGlobal()));

        colNode->setVisualScene(_visualScene);
        colNode->read();
    }

    Node *childN = colNode->getTopNode();

    if(childN->getParent() != NULL)
    {
        SWARNING << "ColladaNode::handleNode: Node already has a parent."
                 << std::endl;
    }

    appendChild(childN);
}