View Full Version : How to transform local space into world space in SDK
HuaMuLan 05-15-2009, 03: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
|
|
HuaMuLan
05-15-2009, 03:46 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 ?
SyncViewS
05-15-2009, 05: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
HuaMuLan
05-15-2009, 07:54 PM
wa...What I may say,,,You're just wonderful-SyncViewS . Super...
Thanx.
CGTalk Moderation
05-15-2009, 07:54 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.