Problems with creating a chase camera

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);
   }

}

want to edit some error messages.

the HashMap I've created causes the message

"Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap<K,V> should be parameterized"

what does that mean?



besides can I cast from a Spatial Object to a Bounding Box Object?

green_eire said:

want to edit some error messages.
the HashMap I've created causes the message
"Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap<K,V> should be parameterized"
what does that mean?

besides can I cast from a Spatial Object to a Bounding Box Object?


@The first one:
Generics are "new" in Java 5.0, try searching the web for java + generics.
@The seconde one:
No, you can't. Because BoundingBox doesn't extend Spatial. You can get the BoundingVolume by calling getWorldBound() on Spatial. But, you can only cast it successfully to BoundingBox, if and only if, you setted up a BoundingBox on the given Spatial or any parent of it before.

Hope at least these two answers help :)