Thanks for your patient reply, Maybe I find the reason for this issue, because the car looks invert , I change the direction(Z) vector as following :
SimpleVector posAhead = Interp(lookAheadAmount+percent);
SimpleVector poscurrent = cube.getTransformedCenter();
posAhead.sub(poscurrent);
/*
the car is invert , if I use posAhead.scalarMul(-1f); the car looks ok,
I think if here is the reason for issue
*/
posAhead.scalarMul(-1f);
Matrix rotY=posAhead.getRotationMatrix( new SimpleVector(0,-1,0));
cube.setRotationMatrix(rotY);
So I remove this line :
posAhead.scalarMul(-1f);
In this case , the camera is behind the car , of course ,the car looks invert. but a new issue appears, the distance between car and camera becomes far and far, and the car out of view at last , here is camera postion set code:
Camera camera = world.getCamera();
SimpleVector oldCamPos=camera.getPosition();
SimpleVector oldestCamPos=new SimpleVector(oldCamPos);
oldCamPos.scalarMul(9f);
SimpleVector carCenter=cube.getTransformedCenter();
SimpleVector camPos=new SimpleVector(carCenter);
SimpleVector zOffset=cube.getZAxis();
SimpleVector yOffset=new SimpleVector(0, -10, 0); //-100
zOffset.scalarMul(-20); //-250
camPos.add(zOffset);
camPos.add(yOffset);
camPos.add(oldCamPos);
camPos.scalarMul(0.1f);
SimpleVector delta=camPos.calcSub(carCenter);
//distance between camera and car
float len=delta.length();
Logger.log("-->distance between camera and car --->" + len ); // the len becomes biger and biger and the car out of view at last
camera.setPosition(camPos);
camera.lookAt(cube.getTransformedCenter());
I try to change the ZOffset , but no effect , distance between camera and car should constant and a little change. Could you help me? Thanks a lot.
I captured some pictures help me to explain clearn.
[attachment deleted by admin]