Notifications
Clear all
[Closed] How to transform local space into world space in SDK
May 15, 2009 3:17 pm
I was quite familiar with this task in maxscript .I really knew the math . I was quite confused by this problem in SDK because I just can not find the right method of how to get the proper TMs out. T.T
3 Replies
May 15, 2009 3:17 pm
Plus,
mat.SetTrans(p0); anyone has SDK samples and may know this
line in the porc of WidgetCreateCallBack . Did it make any sense to my problem ?
any help ?
May 15, 2009 3:17 pm
Hi,
here is a code reference to convert coordinates from local to world space and viceversa.
From Local to World
// get first Node from current selection
// INode* Interface::GetSelNode(int i)
INode* node = GetCOREInterface()->getSelNode(0);
// get Node Transform Matrix
// Matrix3 GetNodeTM (TimeValue t, Interval* valid=NULL)
Matrix3 nodeTM = node->GetNodeTM(GetCOREInterface()->GetTime());
// sample Point in Local Space
Point3 localPos(10.0f, 20.0f, 30.0f);
// sample Vector in Local Space
Point3 localVec(0.57735f, 0.57735f, 0.57735f);
// from Local to World for Positions
Point3 worldPos = nodeTM.PointTransform(localPos);
// from Local to World for Vectors
Point3 worldVec = nodeTM.VectorTransform(localVec);
From World to Local
// get first Node from current selection
// INode* Interface::GetSelNode(int i)
INode* node = GetCOREInterface()->getSelNode(0);
// get Node Transform Matrix
// Matrix3 GetNodeTM (TimeValue t, Interval* valid=NULL)
Matrix3 nodeTM = node->GetNodeTM(GetCOREInterface()->GetTime());
// inverse Node Transform Matrix
Matrix3 invNodeTM = Inverse(nodeTM);
// sample Point in World Space
Point3 worldPos(10.0f, 20.0f, 30.0f);
// sample Vector in World Space
Point3 worldVec(0.57735f, 0.57735f, 0.57735f);
// from World to Local for Positions
Point3 localPos = invNodeTM.PointTransform(worldPos);
// from World to Local for Vectors
Point3 localVec = invNodeTM.VectorTransform(worldVec);
- Enrico