On 08/01/2014 at 16:18, xxxxxxxx wrote:
Cinema 4D Version: 13,14,15
Platform: Windows ;
Language(s) : C++ ;
Hi, I am trying to build up a repertoire of code for moving object in the global 3D space.
I do this partly because I need it, and also because it helps me understand what really goes on inside C4D.
I found out that I can use this, in order to position one object between two other objects, in 3D space.
Matrix mA = cubeA->GetMg(); Matrix mB = cubeB->GetMg(); Matrix mMid = cubeMid->GetMg(); Vector vMidPos = (mA.off + mB.off) / 2; mMid.off = vMidPos; cubeMid->SetMg(mMid);
Anyone seeing any flaws int this code, please correct it!
Now, as I said, I want to make a whole library of such related functions, so I have two questions now:
- Does such a collection / library of these kind of functions exist?
- One actual function I need:
How do I position objectB in global space when objectA is moved / rotated in global space? As if objectB was a child of objectA (but it is not). I would really like a piece of code for this particular case.
I have experimented with matrices and added, subtracted, multiplied and inverted them, but it is more of pure luck that my code works, that of knowledge about what really goes on. And I am familiar with Quaternions, I love them, so to say.