View Full Version : C.O.F.F.E.E | Offset by using Matrix?

 tcastudios11 November 2005, 12:42 AMI'm at it again..stumbling on the basics..but then I usually get off with a little push of help:) In short. I need to place an object using COFFEE in the same manner as if it was a child in the OM. That is, if I place an object under a Null and offset it by for example 100 units in the z direction and then rotate the Null(parent) the object will then "orbit" around the Null. In my tries I use the tutorial in the SDK "Using Matrices". However that tut assumes that you have a object to "take" the values from and transfere it to the target. What I have is no object, "only" the rotation value and a position. I get to the point where I make a new Matrix and place the target. I can also tranfer the rotation -but- only around the target "itself". Not around the initial position. I assume it should be fairly simple in the end but getting into using Matrixes for "real" it is new ground for me. So far I have got by by only using "V0" of objects/positions and calculated the angle between them. I'll put up my tries as soon as a get a little closer to something that looks like I'm on the right track. Thanks and Cheers Lennart
Thalaxis
11 November 2005, 04:58 PM
I just discovered that I can't download the COFFEE SDK docs (it seems like an error on the FTP server, but I'm not sure), and I'm not entirely certain that I understand what you're trying to accomplish.

It sounds like the only difference between what you're trying to do and what you're getting is that you're using a local transform matrix rather than a global one. I'll have to recheck this when I get home, but I think all you need to do is combine the rotation and translation into a single transform matrix before applying the transforms to the object. To do that, all you have to do is multiply them (they should both be 4x4 matrices). So it should go something like:
EndPositionMatrix = RotationMatrix X TranslationMatrix X ObjectStartPositionMatrix

I'm going by memory on that... the operations are not necessarily commutative, so the order of operations does matter. I hope that helps, but I'll do a bit more research this evening if necessary.

tcastudios
11 November 2005, 07:01 PM
Thanks, Thalaxis. I'm still at it but haven't got it working yet .And, yes, I think it's the global<>local matters that I cant master,as it seems, when it comes to complete matrices.

The closest I've got is to use "SetTrans". I can then move the "child" in that direction but it still rotate around itself instead of the "parent" axis.
Both "parent" and "Child" are only values, not actual objects.
I then hook an object of choise to the "child" position.