www.jpct.net

Bones - Skeletal and Pose Animations for jPCT/jPCT-AE => Bones => Topic started by: AGP on October 01, 2014, 08:49:03 pm

Title: Joint.addChild(Object3D)
Post by: AGP on October 01, 2014, 08:49:03 pm
That would be beyond useful...
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 01, 2014, 09:20:11 pm
I did the following:

Code: [Select]
     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:

Code: [Select]
     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);
     }
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 02, 2014, 08:52:01 am
and the question is?

i cant see the relation between jPCT camera and Bones
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 02, 2014, 08:20:57 pm
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.
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 03, 2014, 10:36:16 am
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
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 03, 2014, 07:59:00 pm
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.
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 04, 2014, 02:14:37 pm
i cant see the relation between the model being single part and adding an object as a child of Joint  ???
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 05, 2014, 01:49:06 am
I want the gun to move up and down as the hand, not the object as a whole, moves up and down.
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 05, 2014, 01:51:10 am
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...
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 05, 2014, 03:40:27 pm
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.
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 05, 2014, 07:24:37 pm
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?).
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 06, 2014, 12:54:58 pm
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.
Title: Re: Joint.addChild(Object3D)
Post by: AGP on October 06, 2014, 07:23:32 pm
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?
Title: Re: Joint.addChild(Object3D)
Post by: raft on October 07, 2014, 01:17:03 pm
yes that is what SkeletonDebugger does
Title: Re: Joint.addChild(Object3D)
Post by: AGP on December 15, 2014, 06:49:26 pm
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")?
Title: Re: Joint.addChild(Object3D)
Post by: raft on December 16, 2014, 10:13:24 am
Please try the following jar:
http://aptalkarga.com/bones/bones_tmp.jar

if joint has a name, corresponding joint object in SkeletonDebugger will have that name. o/w it will be named as joint_[index]. bone objects are named as [parent joint's name] -> [joint's name]

Title: Re: Joint.addChild(Object3D)
Post by: AGP on December 16, 2014, 04:34:16 pm
I appreciate it, pal. Thanks. But do I have to re-export my models, now (see below)?

Quote
File? Yes. Success? No: Version mismatch. Current version: 4, stream version: 3
Exception in thread "main" java.lang.NullPointerException
        at Hero.<init>(Hero.java:27)
        at RPG3D.loadModels(RPG3D.java:673)
        at RPG3D.<init>(RPG3D.java:115)
        at RPG3D.main(RPG3D.java:1013)
Title: Re: Joint.addChild(Object3D)
Post by: raft on December 16, 2014, 05:00:15 pm
your exception is not Bones related as stack trace has no Bones class ;)

but right, I had increased the internal stream version to 4 as mentioned in first line. you dont need to re-export your models but convert them from Ogre format to Bones' binary format again.
Title: Re: Joint.addChild(Object3D)
Post by: AGP on December 16, 2014, 06:12:29 pm
I will, then, but line 27 is
Code: [Select]
SkinClipSequence clipSequence = model.getSkinClipSequence();
Title: Re: Joint.addChild(Object3D)
Post by: raft on December 16, 2014, 06:36:32 pm
possibly you couldnt loaded the model because Bones had thrown an IOException complaining about version mismatch, you caught the exception then tried to access to model and had an NPE
Title: Re: Joint.addChild(Object3D)
Post by: AGP on December 16, 2014, 07:59:24 pm
Makes sense. Thanks again.