THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2007 at 12:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.603
Platform: Windows ;
Language(s) : C.O.F.F.E.E ; XPRESSO ;
---------
Hi Guys,
I'm using the Target node within Xpresso to have objects look at a specific object. The problem I'm running into is gimbal lock, which is to be expected. I have looked on numerous math and game developer sites to try and find a way to calculate an Up Vector for this target expression node. The COFFEE code is as follows:
var mobj = Object->GetMg();
var tobj = Target->GetMg();
var p1 = mobj->GetV0();
var p2 = tobj->GetV0();
var m = new(Matrix);
m->SetV0(p1);
m->SetV3(vnorm(p2 - p1));
m->SetV2(vnorm(vcross(p2-p1, vector(0,1,0))));
m->SetV1(vnorm(vcross(p2-p1, vector(0,0,1))));
Rotation=m->GetHPB();
var orot=mobj->GetHPB();
Rotation.z=orot.z;
So, does anyone here know how to calculate the up vector for this expression? Or even able to provide some links for calculating an up vector? As always any help is much appreciated.
Josh