c++ pivot problems

c++ pivot problems

Anonymous
Not applicable
753 Views
3 Replies
Message 1 of 4

c++ pivot problems

Anonymous
Not applicable

I thought I might if had this working. But no -sigh

It looks to me moving my pivot sometimes if the object is not scaled. Then its a mess.

I'm I doing this right?

 

ip = GetCOREInterface();
ip7 = GetCOREInterface7();
// switch to pivotCenter from max script -- couldn't find in SDK
ExecuteMAXScriptScript(_T("toolMode.pivotCenter()"), 0, 0); 
Box3 bb;
ViewExp& vpt = ip->GetViewExp(NULL);
for( auto i = 0; i < ip->GetSelNodeCount(); i++){
	INode *newnode = ip->GetSelNode(i);
	Object *obj = newnode->GetObjectRef();
	obj->GetLocalBoundBox(ip->GetTime(), newnode, vpt.ToPointer(), bb);
	Point3 theBox(bb.Center().x, bb.pmax.y, bb.pmin.z );
	Matrix3 mat(1);
	newnode->ResetPivot(ip->GetTime());
	newnode->Move(ip->GetTime(), mat, theBox, TRUE, FALSE, PIV_PIVOT_ONLY, FALSE);
	newnode = NULL;
}
ip->RedrawViews(ip->GetTime());

I guess what I'm after is the c++ way to ....
obj.pivot = [obj.min.x, obj.center.y, obj.center.z]

thanks for any thoughts on this

754 Views
3 Replies
Replies (3)
Message 2 of 4

haw
Enthusiast
Enthusiast

Did you find an answer to this? I'm doing C# but have the same question....

0 Likes
Message 3 of 4

haw
Enthusiast
Enthusiast

I think I got it to work... this is c# but simple enough to translate...

node.CenterPivot(intfc.Time, false); //The missing call you didn't have access to?
IMatrix3 tm2 = global.Matrix3.Create();
tm2.IdentityMatrix();

IBox3 bb = objOriginal.GetLocalBoundBox(intfc.Time, node, intfc.GetViewExp(IntPtr.Zero));

IPoint3 pnt = global.Point3.Create();
pnt.X = bb.Center.X;
pnt.Y = bb.Center.Y;
pnt.Z = bb.Min.Z;

node.Move(intfc.Time, tm2, pnt, true, false, (int)Autodesk.Max.PivotMode.PivotOnly,false);

0 Likes
Message 4 of 4

istan
Advisor
Advisor