Ok got it to work this time.
Still not the proper way to implement it, but here you can have a try.
this is the PoseTrack setTime code
[java]
public void setTime(float time, float weight, AnimControl control,
AnimChannel channel, TempVars vars) {
Spatial spat = control.getSpatial();
Geometry geom = findGeom(spat);
Mesh target = geom.getMesh();
VertexBuffer bindPos = target.getBuffer(Type.BindPosePosition);
VertexBuffer pos = target.getBuffer(Type.Position);
FloatBuffer pb = (FloatBuffer) pos.getData();
FloatBuffer bpb = (FloatBuffer) bindPos.getData();
pb.clear();
bpb.clear();
pb.put(bpb).clear();
if (time < times[0]) {
applyFrame(target, 0, weight);
} else if (time > times[times.length - 1]) {
applyFrame(target, times.length - 1, weight);
} else {
int startFrame = 0;
for (int i = 0; i < times.length; i++) {
if (times[i] < time) {
startFrame = i;
}
}
int endFrame = startFrame + 1;
float blend = (time - times[startFrame]) / (times[endFrame] - times[startFrame]);
// applyFrame(target, startFrame, blend * weight);
applyFrame(target, endFrame, 1.0f);//(1f - blend) * weight);
}
}
[/java]
applyFrame
[java]
private void applyFrame(Mesh target, int frameIndex, float weight){
PoseFrame frame = frames[frameIndex];
VertexBuffer pb = target.getBuffer(Type.Position);
for (int i = 0; i < frame.poses.length; i++){
Pose pose = frame.poses[i];
float poseWeight = frame.weights[i] * weight;
pose.apply(poseWeight, (FloatBuffer) pb.getData());
}
// force to re-upload data to gpu
pb.updateData(pb.getData());
}
[/java]
Pose.apply()
[java]
public void apply(float blend, FloatBuffer vertbuf) {
for (int i = 0; i < indices.length; i++) {
Vector3f offset = offsets[i];
int vertIndex = indices[i];
tempVec.set(offset).multLocal(blend);
// acquire vertex
BufferUtils.populateFromBuffer(tempVec2, vertbuf, vertIndex);
// add offset multiplied by factor
tempVec2.addLocal(tempVec);
// write modified vertex
BufferUtils.setInBuffer(tempVec2, vertbuf, vertIndex);
}
}
[/java]
tell me if it works for you