Page 1 of 1

how to get local axis vector (C++)

Posted: 24 Dec 2016, 10:52
by wesserbro
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;
				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;


				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!

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

Posted: 24 Dec 2016, 12:53
by wesserbro
well, it struck me, local axis is just global rotation
who could know, who could know... )))