Hey everybody,
i've tried a tutorial to create a chase Camera.
This is what I have so far. Maybe the tutorial is too old.
But some of the code does not work, for example the functions of the Timer object.
I would be very happy if somebody could help me.
Greetz :)
package chasecamera;
import java.util.HashMap;
import com.apple.mrj.macos.carbon.Timer;
import com.jme.bounding.BoundingBox;
import com.jme.input.ChaseCamera;
import com.jme.input.thirdperson.ThirdPersonMouseLook;
import com.jme.math.FastMath;
import com.jme.math.Vector3f;
public class Camera {
private Camera cam;
private ChaseCamera chaser;
private Vector3f targetOffset;
protected Timer timer;
public void buildChaseCamera(){
Player player = new Player();
targetOffset= new Vector3f();
targetOffset.y = ((BoundingBox) player).getWorldBound().yExtent*1.5f;
HashMap props= new HashMap();
props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT,"6");
props.put(ThirdPersonMouseLook.PROP_MINROLLOUT,"3");
props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);
props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+45 * FastMath.DEG_TO_RAD);
props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(5, 0, 30 * FastMath.DEG_TO_RAD));
props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);
chaser = new ChaseCamera(cam, player, props);
chaser.setMaxDistance(8);
chaser.setMinDistance(2);
}
protected void update(float interpolation){
// update to get framerate
timer = Timer.getTimer(properties.getRenderer());
timer.update();
interpolation= timer.getTimePerFrame();
chaser.update(interpolation);
}
}