// Set the value of one of the node fields. void VrmlNodeGroup::setField(const char *fieldName, const VrmlField &fieldValue) { if TRY_FIELD(bboxCenter, SFVec3f) else if TRY_FIELD(bboxSize, SFVec3f) else if (!strcmp(fieldName, "children")) { if (fieldValue.toMFNode()) { for (int i = 0; i < d_children.size(); i++) { if (d_children[i]) { d_children[i]->decreaseTraversalForce(); d_children[i]->parentList.remove(this); } else { cerr << "VrmlNodeGroup::setField(children): had NULL child" << endl; } } d_children = (VrmlMFNode &)fieldValue; for (int i = 0; i < d_children.size(); i++) { VrmlNode *child = d_children[i]; if (child == NULL) { continue; } child->parentList.push_back(this); if (child->getTraversalForce() > 0) { forceTraversal(false, child->getTraversalForce()); } } } else System::the->error("Invalid type (%s) for %s field of %s node (expected %s).\n", fieldValue.fieldTypeName(), "children", nodeType()->getName(), "MFNode"); } else VrmlNodeChild::setField(fieldName, fieldValue); }
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(); } }