osg::Object *RefosgLOD::getChildObject(unsigned i) { if (i < 1) { return _object->getStateSet(); } else { i -= 1; } if (i < 1) { return _object->getCullCallback(); } else { i -= 1; } if (i < 1) { return _object->getUpdateCallback(); } else { i -= 1; } if (i < 1) { return _object->getEventCallback(); } else { i -= 1; } if (i < _object->getNumChildren()) { return _object->getChild(i); } else { i -= _object->getNumChildren(); } throw std::out_of_range("child"); }
const ClassReflection::PropertyNames RefosgLOD::getTablePropertyRowTitles(const std::string &name) { PropertyNames titles; if (name == "_ranges") { for (unsigned i=0; i < _object->getNumChildren(); i++) { titles.push_back(_object->getChild(i)->getName()); } } return titles; }
void UpdateTriangleNode(osg::ref_ptr<osg::Group> const &gp, osg::Vec4 const &color) { // Change the color of the triangle if // its currently intersecting the view frustum osg::Geode * gd = static_cast<osg::Geode*>(gp->getChild(0)); osg::Geometry * gm = static_cast<osg::Geometry*>(gd->getDrawable(0)); osg::ref_ptr<osg::Vec4Array> list_cx = new osg::Vec4Array; list_cx->push_back(color); gm->setColorArray(list_cx,osg::Array::BIND_OVERALL); }
void SlideEventHandler::previousSlide() { if (_switch->getNumChildren()==0) return; if (_fileList.size()>0) { if (_activeSlide==0) _activeSlide = _fileList.size()/2-1; else --_activeSlide; osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length); if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get()); } else { if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1; else --_activeSlide; _switch->setSingleChildOn(_activeSlide); } }
// insert a sphere in the scene with desired position, radius and reflectance properties void addSimpleObject(osg::ref_ptr<osg::Group> root, osg::Vec3 position, float radius, float reflectance) { // create the drawable osg::ref_ptr<osg::Drawable> drawable = new osg::ShapeDrawable(new osg::Sphere(position, radius)); // create the stateset and add the uniform osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet(); stateset->addUniform(new osg::Uniform("reflectance", reflectance)); // add the stateset to the drawable drawable->setStateSet(stateset); if(!root->getNumChildren()) { osg::ref_ptr<osg::Geode> geode = new osg::Geode(); root->addChild(geode); } root->getChild(0)->asGeode()->addDrawable(drawable); }