from the SDK (editspl.cpp)
static void DoAttach(BezierShape *shape, BezierShape *attShape, int mtlOffset) {
int boff = shape->splineCount;
for(int i = 0; i < attShape->splineCount; ++i) {
int index = shape->splineCount;
Spline3D *spline = shape->NewSpline();
*spline = *(attShape->splines[i]);
for(int seg = 0; seg < spline->Segments(); ++seg)
spline->SetMatID(seg, spline->GetMatID(seg) + mtlOffset);
shape->vertSel.Insert(shape->splineCount-1,spline->Verts());
shape->segSel.Insert(shape->splineCount-1,spline->Segments());
shape->polySel.Insert(shape->splineCount-1);
shape->vertSel[index] = attShape->vertSel[i];
shape->segSel[index] = attShape->segSel[i];
shape->polySel.Set(index, attShape->polySel[i]);
// Flush all aux data in attached spline (prevents ResolveTopoChanges problems)
for(int j = 0; j < spline->KnotCount(); ++j)
spline->SetAux2(j, -1);
}
//copy over binds + offset
for (int i = 0; i < attShape->bindList.length();i++)
{
attShape->bindList[i].pointSplineIndex += boff;
attShape->bindList[i].segSplineIndex += boff;
shape->bindList.append(attShape->bindList[i]);
}
for (int i = 0; i < shape->bindList.length();i++)
{
int index = 0;
int spindex = shape->bindList[i].pointSplineIndex;
if (shape->bindList[i].isEnd)
index = shape->splines[spindex]->KnotCount()-1;
shape->bindList[i].bindPoint = shape->splines[spindex]->GetKnotPoint(index);
shape->bindList[i].segPoint = shape->splines[spindex]->GetKnotPoint(index);
}
}
this is what you have to do to attach a BezierShape
DoAttach is a generic method for all node attachment types. It is responsible for the “node” related (material, transform, etc.) attachment tasks, and usually doesn’t do anything related to the “object things” (geometry, topology, etc.).