how to get local axis vector (C++)

Discussions concerning programming of SOFTIMAGE©
Post Reply
wesserbro
Posts: 160
Joined: 27 Oct 2012, 18:05

how to get local axis vector (C++)

Post by wesserbro » 24 Dec 2016, 10:52

Hi All! :)
On an old hdd I've found a little plugin for tweak-manipulating objects, which intended for fast bones manipulations (but I never finished it)
Its my modification of a plugin of someone else, which did i dont remember what :)

Here is a piece of code which obviously rotates object around viewplane normal on mousedrag:

Code: Select all

CStatus MouseDrag( ToolContext& in_ctxt )
	{
		LONG x, y;
		in_ctxt.GetMousePosition( x, y );
		if ( in_ctxt.IsLeftButtonDown() ) 
		{
			X3DObject x3dobj(sel.GetItem(0));
	
				CPlane vp;
				CVector3 vn;
				in_ctxt.GetViewPlane(vp);
				vn = vp.GetNormal();

				CTransformation t = x3dobj.GetKinematics().GetGlobal().GetTransform();
				CRotation r = x3dobj.GetKinematics().GetGlobal().GetTransform().GetRotation();
				CRotation r2;
				CTransformation t2;
				KinematicState lightKine = x3dobj.GetKinematics().GetGlobal();
				r2.SetFromAxisAngle (vn, 0.017);

				CMatrix3 mtr1 = r.GetMatrix();
				CMatrix3 mtr2 = r2.GetMatrix();
				mtr1 *= mtr2;

				r.SetFromMatrix(mtr1);
				t.SetRotation(r);

				in_ctxt.UpdateKinematicState(lightKine, t);


		}
	return CStatus::OK;

	}
I need rotation to happen around local axis of an object (x for example). How can i get this axis vector? (maybe from rotation matrix...)
Thanks for your time!

wesserbro
Posts: 160
Joined: 27 Oct 2012, 18:05

Re: how to get local axis vector (C++)

Post by wesserbro » 24 Dec 2016, 12:53

well, it struck me, local axis is just global rotation
who could know, who could know... )))

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest