예제 #1
0
bool HesperisIO::CreateCurveGroup(MDagPathArray & paths, CurveGroup * dst)
{
    MStatus stat;
	const unsigned n = paths.length();
	unsigned i, j;
	int numCvs = 0;
	unsigned numNodes = 0;
    
    for(i=0; i< n; i++) {
		if(!IsCurveValid(paths[i])) continue;
		MFnNurbsCurve fcurve(paths[i].node());
		numCvs += fcurve.numCVs();
		numNodes++;
	}
    
    if(numCvs < 4) {
		MGlobal::displayInfo(" too fews cvs!");
		return false;
	}
    
    dst->create(numNodes, numCvs);
    Vector3F * pnts = dst->points();
	unsigned * counts = dst->counts();
    
    unsigned inode = 0;
	unsigned icv = 0;
	unsigned nj;
	MPoint wp;
	MMatrix worldTm;
	for(i=0; i< n; i++) {
		if(!IsCurveValid(paths[i])) continue;
		
		worldTm = GetWorldTransform(paths[i]);
		
		MFnNurbsCurve fcurve(paths[i].node());
		nj = fcurve.numCVs();
		MPointArray ps;
		fcurve.getCVs(ps, MSpace::kWorld);
		
		counts[inode] = nj;
		inode++;
		
		for(j=0; j<nj; j++) {
			wp = ps[j] * worldTm;
			pnts[icv].set((float)wp.x, (float)wp.y, (float)wp.z);
			icv++;
		}
	}
    return true;
}
예제 #2
0
bool HesperisCurveCreator::CheckExistingCurves(CurveGroup * geos, MObject &target)
{
	MDagPath root;
    MDagPath::getAPathTo(target, root);
	
	std::map<std::string, MDagPath > existing;
	ASearchHelper::AllTypedPaths(existing, root, MFn::kNurbsCurve);
	
    const unsigned ne = existing.size();
    if(ne < 1) return false;
    if(ne != geos->numCurves()) return false;
    
    unsigned n = 0;
    std::map<std::string, MDagPath >::const_iterator it = existing.begin();
    for(;it!=existing.end();++it) {
        MFnNurbsCurve fcurve(it->second.node());
		n += fcurve.numCVs();
    }
	
    if(n!=geos->numPoints()) {
		AHelper::Info<MString>("existing curves nv don't match cached data ", root.fullPathName());
		return false;
	}
    
    MGlobal::displayInfo(" existing curves matched");
    
    return true;
}
예제 #3
0
bool HesperisIO::IsCurveValid(const MDagPath & path)
{
	MStatus stat;
	MFnNurbsCurve fcurve(path.node(), &stat);
	if(!stat) {
		// MGlobal::displayInfo(path.fullPathName() + " is not a curve!");
		return false;
	}
	if(fcurve.numCVs() < 4) {
		MGlobal::displayInfo(path.fullPathName() + " has less than 4 cvs!");
		return false;
	}
	return true;
}
예제 #4
0
bool HesperisIO::CheckExistingCurves(CurveGroup * geos, MObject &target)
{
    MDagPathArray existing;
    MDagPath root;
    MDagPath::getAPathTo(target, root);
    if(!GetCurves(root, existing)) return false;
    
    const unsigned ne = existing.length();
    if(ne != geos->numCurves()) return false;
    
    unsigned n = 0;
    unsigned i=0;
    for(;i<ne;i++) {
        MFnNurbsCurve fcurve(existing[i].node());
		n += fcurve.numCVs();
    }
    if(n!=geos->numPoints()) return false;
    
    MGlobal::displayInfo(" existing curves matched");
    
    return true;
}