Exemple #1
0
void VrmlNodeGroup::checkAndRemoveNodes(Viewer *viewer)
{
    if (d_childrenToRemove.size())
    {
        viewer->beginObject(name(), 0, this);
        int i, n = d_childrenToRemove.size();
        for (i = 0; i < n; i++)
        {
            Viewer::Object child_viewerObject = 0;
            VrmlNode *kid = d_childrenToRemove[i];
            if (kid->toGeometry())
                child_viewerObject = kid->toGeometry()->getViewerObject();
            else if (kid->toGroup())
                child_viewerObject = kid->toGroup()->d_viewerObject;
            else if (kid->toProto())
                child_viewerObject = kid->toProto()->getViewerObject();
            else if (kid->toShape())
                child_viewerObject = kid->toShape()->getViewerObject();
            if (child_viewerObject)
                viewer->removeChild(child_viewerObject);
        }
        viewer->endObject();
    }
    while (d_childrenToRemove.size())
    {
        d_childrenToRemove.removeNode(d_childrenToRemove[0]);
    }
}
Exemple #2
0
void VrmlNodeGroup::addChildren(const VrmlMFNode &children)
{
    int nNow = d_children.size();
    int n = children.size();

    for (int i = 0; i < n; ++i)
    {
        VrmlNode *child = children[i];
        if (child == NULL)
        {
            continue;
        }

        child->parentList.push_back(this);
        if (child->getTraversalForce() > 0)
        {
            forceTraversal(false, child->getTraversalForce());
        }

        VrmlNodeProto *p = 0;

        // Add legal children and un-instantiated EXTERNPROTOs
        // Is it legal to add null children nodes?
        if (child == 0 || child->toChild() || ((p = child->toProto()) != 0 && p->size() == 0))
        {
            d_children.addNode(child);
            if (child)
            {
                child->addToScene(d_scene, d_relative.get());
                child->accumulateTransform(d_parentTransform);
            }
        }
        else
            System::the->error("Error: Attempt to add a %s node as a child of a %s node.\n",
                               child->nodeType()->getName(), nodeType()->getName());
    }

    if (nNow != d_children.size())
    {
        //??eventOut( d_scene->timeNow(), "children_changed", d_children );
        setModified();
    }
}