Notifications
Clear all
[Closed] c++ Spline Detaching
Jul 31, 2015 11:24 am
Hi, I am trying to create a Spline Detach by using shape and segments. I am able to detach by shapes, but am unable to delete the original node without it losing the new spline. Is there a better way of doing this ? I also am unable to find anything on detaching by segments, but I take it I would have to redraw each segment ? is that correct or is there a faster way ? My detach by shapes code is below.
void PolyTools::GetSplinesDetach(){
ip = GetCOREInterface();
t = GetCOREInterface()->GetTime();
for (int i=0; i < ip->GetSelNodeCount(); i){
INode *node = ip->GetSelNode(i);
DetachSplinesByShape(node);
node->DeleteThis();
}
ip->FlushUndoBuffer();
ip->RedrawViews(ip->GetTime());
}
void PolyTools::DetachSplinesByShape(INode *node){
ip = GetCOREInterface();
t = GetCOREInterface()->GetTime();
ObjectState os = node->EvalWorldState(t);
if (os.obj){
Object* ob = os.obj;
BezierShape* bs = &((SplineShape*)ob)->shape;
if(bs->SplineCount() > 1){
for(int j = 0; j < bs->SplineCount(); j++){
SplineShape *shape = (SplineShape*)GetSplineShapeDescriptor()->Create(0);
Spline3D* OldSpline = bs->GetSpline(j);
shape->shape.AddSpline(OldSpline);
shape->shape.UpdateSels();
INode *Splinenode = ip->CreateObjectNode (shape);
Splinenode->SetNodeTM(t, node->GetNodeTM(t));
Splinenode->SetObjOffsetPos(node->GetObjOffsetPos());
Splinenode->SetObjOffsetRot(node->GetObjOffsetRot());
Splinenode->SetObjOffsetScale(node->GetObjOffsetScale());
Splinenode->CenterPivot(ip->GetTime(), FALSE);
int R = rand() % 256;
int G = rand() % 256;
int B = rand() % 256;
Splinenode->SetWireColor(RGB(R, G, B));
TSTR name(_T("Just_Obj"));
ip->MakeNameUnique(name);
Splinenode->SetName(name);
}
}
}
}