コード例 #1
0
void ToNukeGeometryConverter::convert( GeometryList &geoList ) const
{
	int objIndex = m_objIndexParameter->getNumericValue();
	if ( objIndex == -1 )
	{
		objIndex = (int)geoList.objects();
	}
	geoList.add_object(objIndex);

	ConstCompoundObjectPtr operands = parameters()->getTypedValidatedValue<CompoundObject>();
	doConversion( srcParameter()->getValidatedValue(), geoList, objIndex, operands.get() );
}
コード例 #2
0
ファイル: ABCReadGeo.cpp プロジェクト: dbr/ABCNuke
/*virtual*/
void ABCReadGeo::create_geometry(Scene& scene, GeometryList& out)
{

	if (filename()[0] == '\0') {
		out.delete_objects();
		return;
	}

	IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
			filename(),//archiveName,
			Abc::ErrorHandler::kQuietNoopPolicy );

	if (!archive.valid()) {
		std::cout << "error reading archive" << std::endl;
		error("Unable to read file");
		return;
	}

	IObject archiveTop = archive.getTop();

	std::vector<Alembic::AbcGeom::IObject>  _objs;
	getABCGeos(archiveTop, _objs);

	// current Time to sample from
	chrono_t curTime = m_sampleFrame  / _FPS;

	if ( rebuild(Mask_Primitives)) {
		out.delete_objects();
	}

	int obj = 0;
	for( std::vector<Alembic::AbcGeom::IObject>::const_iterator iObj( _objs.begin() ); iObj != _objs.end(); ++iObj ) {


		// Leave an empty obj if knob is unchecked
		if (!active_objs[obj] ) {
			out.add_object(obj);
			PointList& points = *out.writable_points(obj);
			points.resize(0);
			out[obj].delete_group_attribute(Group_Vertices,kUVAttrName, VECTOR4_ATTRIB);
			obj++;
			continue;
		}


		if ( rebuild(Mask_Primitives)) {

			out.add_object(obj);

			if (bbox_objs[obj]) { //(bbox_mode) {
				buildBboxPrimitives(out, obj);
			}
			else {
				buildABCPrimitives(out, obj, *iObj, curTime);
			}
		}


		if ( rebuild(Mask_Points)) {

			PointList& points = *out.writable_points(obj);

			if (bbox_objs[obj]) { //(bbox_mode) {
				Imath::Box3d bbox = getBounds(*iObj, curTime);

				points.resize(8);

				IObject iObj_copy(*iObj);
				Matrix4 xf = getConcatMatrix(iObj_copy,curTime, interpolate !=0); // for some reason getParent() won't take a const IObject, hence the copy...

				// Add bbox corners
				for (unsigned i = 0; i < 8; i++) {
					Vector3 pt((i&4)>>2 ? bbox.max.x : bbox.min.x, (i&2)>>1 ? bbox.max.y : bbox.min.y, (i%2) ? bbox.max.z : bbox.min.z );
					points[i] = xf.transform(pt);
				}
			}

			else{
				writePoints(*iObj, points, curTime, interpolate !=0);
			}

		}



		if ( rebuild(Mask_Attributes)) {

			if (bbox_objs[obj]) { //(bbox_mode)
				out[obj].delete_group_attribute(Group_Vertices,kUVAttrName, VECTOR4_ATTRIB);
			}
			else {
				// set UVs
				Attribute* UV = out.writable_attribute(obj, Group_Vertices, kUVAttrName, VECTOR4_ATTRIB);
				IV2fGeomParam uvParam = getUVsParam(*iObj);
				setUVs(out[obj], uvParam, UV, curTime);

				// set Normals
				IN3fGeomParam nParam = getNsParam(*iObj);
				if (nParam.valid()) {
					Attribute* N = out.writable_attribute(obj, Group_Vertices, kNormalAttrName, NORMAL_ATTRIB);
					setNormals(out[obj], nParam, N, curTime);
				}
			}
		}

		obj++;
	}