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(); } }
// // The update method is where the events are processed. It should be // called after each frame is rendered. // bool VrmlScene::update( double timeStamp ) { if (timeStamp <= 0.0) timeStamp = theSystem->time(); VrmlSFTime now( timeStamp ); d_deltaTime = DEFAULT_DELTA; // Update each of the timers. VrmlNodeList::iterator i, end = d_timers->end(); for (i = d_timers->begin(); i != end; ++i) { VrmlNodeTimeSensor *t = (*i)->toTimeSensor(); if (t) t->update( now ); } // Update each of the clips. end = d_audioClips->end(); for (i = d_audioClips->begin(); i != end; ++i) { VrmlNodeAudioClip *c = (*i)->toAudioClip(); if (c) c->update( now ); } // Update each of the scripts. end = d_scripts->end(); for (i = d_scripts->begin(); i != end; ++i) { VrmlNodeScript *s = (*i)->toScript(); if (s) s->update( now ); } // Update each of the movies. end = d_movies->end(); for (i = d_movies->begin(); i != end; ++i) { VrmlNodeMovieTexture *m = (*i)->toMovieTexture(); if (m) m->update( now ); } // Pass along events to their destinations while (d_firstEvent != d_lastEvent && ! d_pendingUrl && ! d_pendingNodes) { Event *e = &d_eventMem[d_firstEvent]; d_firstEvent = (d_firstEvent+1) % MAXEVENTS; // Ensure that the node is in the scene graph VrmlNode *n = e->toNode; if (this != n->scene()) { theSystem->debug("VrmlScene::update: %s::%s is not in the scene graph yet.\n", n->nodeType()->getName(), n->name()); n->addToScene((VrmlScene*)this, urlDoc()->url() ); } n->eventIn(e->timeStamp, e->toEventIn, e->value); // this needs to change if event values are shared... delete e->value; } if (d_pendingNodes) { replaceWorld( *d_pendingNodes, d_pendingScope ); delete d_pendingNodes; d_pendingNodes = 0; d_pendingScope = 0; } else if (d_pendingUrl) { (void) loadUrl( d_pendingUrl, d_pendingParameters ); delete d_pendingUrl; delete d_pendingParameters; d_pendingUrl = 0; d_pendingParameters = 0; } // Signal a redisplay if necessary return isModified(); }