How can I get a SimpleVector, in worldspace, of a given Joint?
I add the position o the joint to the transformed center of the object but its not very accurate :(
Thanks for your response, but there has to be a better way.
Of course, i hope there could be a method for that, that should be very handy
Object3D.getTransformedCenter() takes center of Object3D into account and that center is calculated by jPCT. instead, use Object3D.getTranslation().
if there is a rotation on Object3D that should be taken into account to.
simply applying Object3D.getWorldTransformation() matrix to bone location should work (not tested). it should take both translation and rotation into account. ie:
SimpleVector.matMul(Animated3D.getWorldTransformation());
I see. A follow-up, then: How do you, Raft, do area-specific collision-detection. Because the way I was going about it was to add primitives to specific joints and collide them with my collision objects.
if you mean you need info about colliding polygons, attach CollisionListener's to your "joint primitives". see CollisionListener.requiresPolygonIDs().
btw, what is the overall purpose here? why do you want to collide joint primitives instead of the mesh itself?
Most of the time we need to know where the collision happened on the mesh, but in my current particular case, it's a little fighting game. A Joint.getWSPosition() method would be very helpful.
a Joint is just a part of Skeleton. It doesnt know anything about which Animated3D it's related to. furthermore more it does not even have a location in Skeleton. that data is stored in SkeletonPose class.
just use the code below for WS of a joint. (not tested but it should work)
SimpleVector location = skeletonPose.getGlobal(jointIndex).getTranslation();
location.matMul(animated3D.getWorldTransformation());
Thanks a lot, I will use your code. But it should be noted that Joint doesn't have to know anything about its Animated3D. Knowing its location is more important.
Yet another follow-up: why doesn't the following work perfectly (it mostly works in that the head collision object translates with the model, but the head object is front of it)?
head = Primitives.getCube(15);
joint = skeleton.findJointByName(bipName+ " Head");
head.setTranslationMatrix(skeletonPose.getGlobal(joint.getIndex()));
I've just made a quick test and it works as expected. the collision object is positioned just at joint location ???
* although it's uncommon, maybe that joint is actually in front of model?
* are you translating the model itself? maybe that translation is not applied to collision object?
I'm translating it, but as long as they share the same matrix, shouldn't it all move in unison?
I assume Animated3D.getRoot().translate(...) is the way to move everything, including its Skeleton. Am I wrong?
no.
1. jPCT possibly copies matrix values at setTranslationMatrix(..) not holds a reference to it. (beeing open source really helps on these kinds of things)
2. More importantly, the joint transformations retrieved by SkeletonPose.getGlobal(..) are in object space. they have no relation to translation applied to AnimatedGroup or Animated3D.
Quote from: AGP on June 10, 2013, 11:15:04 PM
I assume Animated3D.getRoot().translate(...) is the way to move everything, including its Skeleton. Am I wrong?
no, it just moves the model, AnimatedGroup and Animated3D. Skeleton does not move anywhere. indeed, Skeleton is not even something that can be moved around. it's just a definition of joint hierarchies, not a physical thing if that is the correct expression.
No, jPCT holds a reference to the matrix. So that means that getGlobal(...) won't work for moving objects. But as this way is both very useful and very efficient, is there any chance I can persuade you to write a getGlobalWS(...)?
why not just use that code? I've tested it and it works as expected.
SimpleVector location = skeletonPose.getGlobal(jointIndex).getTranslation();
location.matMul(animated3D.getWorldTransformation());
I wont and cant write such a method because a SkeletonPose knows nothing about the Animated3D and AnimatedGroup it's attached to. Furthermore, same SkeletonPose can be attached to multiple AnimatedGroup/Animated3D's.
I see. Thanks.
hey raft thanks a lot this works great!! ;D
It's just that raft's way you have to adjust the objects every iteration, and you end up with multiple matrices that effectively do the same thing. If getGlobalWS(...) were possible, it would be faster, neater, and used less RAM.