I've seen a few Open Source project with documentation worse, than jMonkey, but I was lucky - I actually knew something about those projects subject matter, so I could make sense out of them! With jMonkey even core developers seem to have a problem. One way or another, I was finally able to come up with a working tree. Well, working as in "it looks ok". It hasn't grown yet - that the next step. Apparently, the main problem was that a Spatial in jMe has internal coordinate axis, but they are not aligned with the Spatial (contrary to what wiki says). The axis are attached at the beginning of coordinate system to some well-defined (published in wiki) point, but the directions of the axis change with every setLocalRotation() call. In general, I don't see any (easy) way to figure an angle between the direction of cylinder and its Z-axis.
To find the direction there is a neat trick (and I don't know how it works, but it does):
Vector3f direction = trunk.getLocalRotation().getRotationColumn(2);
direction.normalize();
gives you true direction (vector3f) aligned with the cylinder's axis - coords (x,y,z) in local coordinate system of the end of a vector with length==1.
Conversely, if you multiply that by the length of the cylinder you'll get the coordinates of that point and localToWorld() would correctly convert that!
The full story here
Monday, April 21, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment