www.jpct.net

Bones - Skeletal and Pose Animations for jPCT/jPCT-AE => Bones => Topic started by: ani.tumanyan on March 05, 2013, 08:13:45 pm

Title: Pick a specific part of Ninja
Post by: ani.tumanyan on March 05, 2013, 08:13:45 pm
Hi everybody,

I'm trying to rotate specific parts of Ninja object. So I need to determine the specific bone the user has picked by touching on some part of the screen. Using collision detection technique I can understand which object was picked, but that's not enough as this returns only the whole object (the Ninja).

So my question here is,  how to know which bone was selected by a touch event?


Thanks in advance!
Ani
Title: Re: Pick a specific part of Ninja
Post by: raft on March 07, 2013, 08:13:02 am
if you know vertex index, you can query which bones (joints) effect that vertex as below:

Code: [Select]
short[] indices = animated3D.getSkinData().getJointIndices(vertexIndex);
float[] weights = animated3D.getSkinData().getWeights(vertexIndex);

now, indices points which joints effect that vertex and weights points how much each joint effect that vertex*

accesing vertex index is another story. AFAIK there is no direct way of it. using a CollisionListener and retrieving polygons id's from CollisionEvent and reverse querying IVertexController.getPolygonIDs for each vertex for matching polygons may help. Egon may clarify this.

* SkinData was not exposed before, I've just added a method to Animated3D to get SkinData. so re-download Bones. also note, Animated3D.getSkinData() and SkinData.getXX() always returns a copy, so caching them makes sense.