Joint.addChild(Object3D)

Started by AGP, October 01, 2014, 08:49:03 PM

Previous topic - Next topic

AGP


AGP

#1
I did the following:


     gun.setRotationMatrix(rightHand.getBindPose());
     moveTo(gun, getJointPosition(rightHand));


I appears to work ONLY if I don't call the following (necessary) method that updates the camera's position and rotation:


     private void follow(AnimatedGroup group) {
Animated3D toFollow = group.get(0);
Matrix matrix = toFollow.getWorldTransformation().invert3x3();
theCamera.setBack(matrix);
SimpleVector center = toFollow.getTransformedCenter();
theCamera.setPosition(center);
theCamera.rotateCameraY((float)Math.PI +cameraDisplacementY);
skeletonPose.updateTransforms();
theCamera.moveCamera(Camera.CAMERA_MOVEOUT, cameraToObjectDistance);
     }

raft

and the question is?

i cant see the relation between jPCT camera and Bones

AGP

The question was stated clearly in two parts: a request for Joint.addChild(Object3D) and a solution for the equivalent. I don't see the relationship, either. In further tests, whenever the character rotates AND follow() gets called, the gun's rotation breaks (it seems to rotate counter-camera). But if either just the camera or just the character rotates, that above code works.

raft

Joint is not a 3d object but a piece of data. adding a child to it makes no sense IMHO. you can achieve a similar effect by adding your object as child to relevant Object3D in SkeletonDebugger.

for the Camera, I dont know. that just doesnt make sense. there must be some other reason

AGP

The problem is that in this case the entire human model has a single part. Obviously, the hand moves differently from the rest of the body. Which is why I think that you should be able to add an Object3D as a child of a Joint.

raft

i cant see the relation between the model being single part and adding an object as a child of Joint  ???

AGP

I want the gun to move up and down as the hand, not the object as a whole, moves up and down.

AGP

Look, in this particular case, I've solved it by adjusting the gun's position to the Joint's ever iteration and by rotating the gun whenever I rotate the character. But I maintain that adding an Object3D as child of a Joint would be very useful. Surely you can see how useful it can be for any item the character may hold...

raft

I can see it may be useful but as i said you can achieve a similar effect by adding your object as child to relevant Object3D in SkeletonDebugger.

AGP

I'm not sure how that would be different than just adding it to the hero straight up (in which case the gun would probably move the average of the entire idle movement or something similar, right?).

raft

i cant understand your line of thought. you want the gun follow the joint right? the objects corresponding to joints in SkeletonDebugger already do that. if you add your gun as child to corresponding object, it will also follow the joint.

AGP

The only way your point makes sense is if Bones creates internal objects, that are not the actual hero model, corresponding to the joints. Is that what it does?

raft

yes that is what SkeletonDebugger does

AGP

The kinds of names I'm getting from SkeletonDebugger are "object4359." Is there a way in which for me to identify which object was created for which joint (the joints themselves have Biped names like "Bip01 R Hand")?