void VrmlNodeGroup::render(Viewer *viewer) { if (!haveToRender()) { return; } if (d_viewerObject && isModified()) { viewer->removeObject(d_viewerObject); d_viewerObject = 0; } checkAndRemoveNodes(viewer); if (d_viewerObject) viewer->insertReference(d_viewerObject); else if (d_children.size() > 0) { int i, n = d_children.size(); int nSensors = 0; d_viewerObject = viewer->beginObject(name(), 0, this); // Draw nodes that impact their siblings (DirectionalLights, // TouchSensors, any others? ...) for (i = 0; i < n; ++i) { VrmlNode *kid = d_children[i]; //if ( kid->toLight() ) && ! (kid->toPointLight() || kid->toSpotLight()) ) // kid->render(viewer); //else if (kid && ((kid->toTouchSensor() && kid->toTouchSensor()->isEnabled()) || (kid->toPlaneSensor() && kid->toPlaneSensor()->isEnabled()) || (kid->toCylinderSensor() && kid->toCylinderSensor()->isEnabled()) || (kid->toSphereSensor() && kid->toSphereSensor()->isEnabled()) || (kid->toSpaceSensor() && kid->toSpaceSensor()->isEnabled()))) { if (++nSensors == 1) viewer->setSensitive(this); } } // Do the rest of the children (except the scene-level lights) for (i = 0; i < n; ++i) { if (d_children[i]) { if (!(/*d_children[i]->toLight() ||*/ d_children[i]->toPlaneSensor() || d_children[i]->toCylinderSensor() || d_children[i]->toSpaceSensor() || d_children[i]->toTouchSensor())) d_children[i]->render(viewer); } } // Turn off sensitivity if (nSensors > 0) viewer->setSensitive(0); viewer->endObject(); } clearModified(); }
void VrmlNodeGroup::activate(double time, bool isOver, bool isActive, double *p, double *M) { int i, n = d_children.size(); for (i = 0; i < n; ++i) { VrmlNode *kid = d_children[i]; if (kid == NULL) continue; if (kid->toTouchSensor() && kid->toTouchSensor()->isEnabled()) { kid->toTouchSensor()->activate(time, isOver, isActive, p); break; } else if (kid->toPlaneSensor() && kid->toPlaneSensor()->isEnabled()) { kid->toPlaneSensor()->activate(time, isActive, p); break; } else if (kid->toSpaceSensor() && kid->toSpaceSensor()->isEnabled()) { kid->toSpaceSensor()->activate(time, isActive, p, M); break; } else if (kid->toSphereSensor() && kid->toSphereSensor()->isEnabled()) { kid->toSphereSensor()->activate(time, isActive, p); break; } else if (kid->toCylinderSensor() && kid->toCylinderSensor()->isEnabled()) { kid->toCylinderSensor()->activate(time, isActive, p); break; } } }