Пример #1
0
osg::Object *RefosgBillboard::getChildObject(unsigned i) {
	if (i < 1) {
		return _object->getUpdateCallback();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getStateSet();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getEventCallback();
	} else {
		i -= 1;
	}
	if (i < _object->getNumDrawables()) {
		return _object->getDrawable(i);
	} else {
		i -= _object->getNumDrawables();
	}
	if (i < 1) {
		return _object->getCullCallback();
	} else {
		i -= 1;
	}
	throw std::out_of_range("child");
}
Пример #2
0
unsigned RefosgBillboard::getNumChildren() {
	unsigned cnt = 0;
	cnt++;
	cnt++;
	cnt++;
	cnt+= _object->getNumDrawables();
	cnt++;
	return cnt;
}
Пример #3
0
osg::ref_ptr<osg::Geode> VTKActorToOSG(vtkActor *actor, osg::ref_ptr<osg::Geode> geode, int verbose)
{
	// make actor current
	actor->GetMapper()->Update();

	// this could possibly be any type of DataSet, VTKActorToOSG assumes polyData
	if (strcmp(actor->GetMapper()->GetInput()->GetClassName(), "vtkPolyData"))
	{
		std::cerr << "ERROR! Actor must use a vtkPolyDataMapper." << std::endl;
		std::cerr << "If you are using a vtkDataSetMapper, use vtkGeometryFilter instead." << std::endl;
		return NULL;
	}

	// if geode doesn't exist, then create a new one
	if (!geode.valid())
		geode = new osg::Geode();

	// get poly data
	vtkPolyData *polyData = (vtkPolyData *) actor->GetMapper()->GetInput();

	// get primitive arrays
	osg::ref_ptr<osg::Geometry> points, lines, polys, strips;

	// create new Geometry for the Geode
	points = processPrimitive(actor, polyData->GetVerts(), osg::PrimitiveSet::POINTS, verbose);
	lines = processPrimitive(actor, polyData->GetLines(), osg::PrimitiveSet::LINE_STRIP, verbose);
	polys = processPrimitive(actor, polyData->GetPolys(), osg::PrimitiveSet::POLYGON, verbose);
	strips = processPrimitive(actor, polyData->GetStrips(), osg::PrimitiveSet::TRIANGLE_STRIP, verbose);

	// remove old gsets and delete them
	geode->removeDrawables(0, geode->getNumDrawables());

	if (points.valid())
		geode->addDrawable(points.get());
	if (lines.valid())
		geode->addDrawable(lines.get());
	if (polys.valid())
		geode->addDrawable(polys.get());
	if (strips.valid())
		geode->addDrawable(strips.get());

	return geode;
}