atomix
August 4, 2011, 11:55am
21
@stomrage : Here is the result of when I run your code in my test case…
(Video)
http://www.youtube.com/watch?v=uAMYcJas2d8
More I’m happy to choose your code for a start writing my own implement of ChaseCam for my game. Thanks a lot!
The ChaseCam is quite a hard one to get better tweak. But we will exchange ideas to improve it (one at a time ,OK?)
_________________
First:
Start with your code, (so both of us know how it like), I will add an input trigger to switch between serveral ChaseCam method that implemented in JME3 for comparing and testing.
So the ChaseCam has to be more abstract and have method to link and fit others.
_________________
Second :
I try to tweak some parameters in your code The camera seems to fly a little bit far from the character and the CapsuleCollisionShape seems big, … + something else.
_________________
Third :
Fix the ray casting and the reset method .Look OK but not work as intend
_________________
4th:
Deal with the sudden changes of camera annoy game player => So try to reduce them…
_________________
5th:
Add the "rubber band " or a “flexible cameraman” effect method to making is more nature…
_________________
6th:
Add method to deal with situation when character run or duck through a very tiny space like a tunnel or a drain… The situation which the physic Collision will properly procedure ugly effect of shaking … So then come the Fix camera Trigger to supply with “Fix or Path Camera Movement”.
So a tunnel, The camera will run in a path for sure, no more “smart thought”…
And in a “falling scene”, the camera will change its angle for a more “dramatic look”.
_________________
P/s: I want to hear your opinion for this changes, did you agree with me about the necessary and the order of them??
Oh you give me some points ^^. But’s yeah it’s not perfect… It’s just a test. we have to create an abstract ChaseCamera. Next create a chase camera and after a physicChaseCamera. But what we need for now, it’s just to clear the code and improve the perfomance by adding an input trigger and different method as you said. Beside we can use a test like this.
[java]public void showTime(){
long start;
start = System.currentTimeMillis();
//Fonction to test
long duree = System.currentTimeMillis() - start;
System.out.println(duree);
}[/java]
Oh thanks i’m glad that you choose my chaseCam. As i said it’s not perfect but there is many good point.
2th :
Yes there is many parameter i need to change like the CapsuleCollisionShape or the maxDistance.
3th :
For the ray casting i guess that we must change the Ray by a physicRay like SimplexCollisionShape to detect the collision and change the camera orientation and when it's nescessary change the distance between the camera and the character. What do you mean by the reset method ?
4th :
Something like FastMath.clamp(value, minDistance, maxDistance) must fix the problem. As you see, there is a problem when the camera is too near the character. One solution is to change the vRotation.
5th :
Yes first we have to use Quaternion.slerp for the camera rotation. The location of the camera need to be instant. Otherwise the camera must go inside the wall if we don't do this instantly.
6th :
I know what do you mean by the falling scene. In this situation the camera vRotation change to see what's in the hole in front of the character. However, i don't know what the fix or path camera you mentionned. With my CameraGame try to press the SpaceBar and see if it's what you refers by fix or path camera.
Thanks for the help guys ! We gonna create a perfect Zelda-Like Camera. (Moreover, sorry for my bad english )
1 Like
atomix
August 4, 2011, 5:49pm
23
Abstract ChaseCamera
[java]/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bounding.BoundingBox;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Spatial;
/**
*
@author Stomrage
*/
public abstract class ThirdPersonCamera {
protected Camera cam;
protected Spatial chara;
private float vRotation = FastMath.PI/8;
private float distance = 100;
private float rotation = FastMath.PI;
private float maxDistance;
private float minDistance;
protected final float charaHeight;
public ThirdPersonCamera(Camera cam, Spatial chara){
this.cam = cam;
this.chara = chara;
BoundingBox b = (BoundingBox)chara.getWorldBound();
charaHeight = b.getYExtent()2;
}
public void setMaxDistance(float maxDistance){
this.maxDistance = maxDistance;
}
public void setMinDistance(float minDistance){
this.minDistance = minDistance;
}
protected void computePosition(){
distance = FastMath.clamp(distance, minDistance, maxDistance);
float hDistance = distance * FastMath.sin((FastMath.PI / 2) - vRotation);
Vector3f pos = new Vector3f(hDistance * FastMath.cos(rotation), distance * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
pos = pos.add(chara.getWorldTranslation().add(0,charaHeight,0));
cam.setLocation(pos);
}
protected Quaternion rotateCam(Vector3f direction1, Vector3f direction2, float interpolation){
Quaternion increment1 = new Quaternion();
increment1.fromAngles(direction1.x, 0, direction1.z);
Quaternion increment2 = new Quaternion();
increment2.fromAngles(direction2.x, 0, direction2.z);
Quaternion increment3 = increment2.slerp(increment1, increment2, interpolation);
float[] tempAngles = increment3.toAngles(null);
rotation = FastMath.atan2(tempAngles[2], tempAngles[0]);
return increment3;
}
public void setDistance(float distance){
this.distance = distance;
}
public abstract void updateCam(float tpf);
}
[/java]
ZeldaCam (without physics) in construction:
[java]/
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Spatial;
/**
*
@author Stomrage
/
public class ZeldaCam extends ThirdPersonCamera implements ActionListener{
private boolean focus = false;
private Vector3f finalVector;
protected CharacterControl charaC;
private Quaternion tempIncrement = new Quaternion();
public ZeldaCam(Camera cam, Spatial chara, CharacterControl charaC){
super(cam, chara);
this.charaC = charaC;
}
public void updateCam(float tpf){
computePosition();
if(focus){
float a = FastMath.asin(cam.getDirection().x);
a = FastMath.sin(a+FastMath.PI);
float b = FastMath.acos(cam.getDirection().z);
b = FastMath.cos(b+FastMath.PI);
Quaternion increment = rotateCam(new Vector3f(a,0,b), finalVector, tpf 30);
if (tempIncrement.equals(increment)) {
focus = false;
}
tempIncrement.set(increment);
}
cam.lookAt(chara.getWorldTranslation().add(0, charaHeight, 0), Vector3f.UNIT_Y);
}
public void registerWithInput(InputManager inputManager) {
String[] mappings = new String[]{
"Cam_Focus"
};
inputManager.addMapping("Cam_Focus", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, mappings);
inputManager.setCursorVisible(false);
}
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("Cam_Focus") && isPressed) {
focus = true;
finalVector = new Vector3f(charaC.getViewDirection().x, 0, charaC.getViewDirection().z);
}
if (name.equals("Cam_Focus") && !isPressed) {
focus = false;
}
}
}
[/java]
I think this is a good base to continue.
atomix
August 7, 2011, 2:33pm
25
@stomrage : It’s a nice structure abstract class you got here.
I 'm now struggling my ass to got my SDK work again from a “hell” nighty update, so I can’t post my code here but it got a similar structure, except :
My AbstractThirdPersonCam got separated “computePosition” and “setPosition” method, as it’s more conventional to extended class can use ancestor 's “computePosition” and modify to get a more complex and flexible as need.
[java] protected void computePosition(){
distance = FastMath.clamp(distance, minDistance, maxDistance);
float hDistance = distance * FastMath.sin((FastMath.PI / 2) - vRotation);
Vector3f pos = new Vector3f(hDistance * FastMath.cos(rotation), distance * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
pos = pos.add(chara.getWorldTranslation().add(0,charaHeight,0));
cam.setLocation(pos);
}[/java]
Thank you for note this inconsistency. So the method must be something like this:
[java]
protected void computePosition(){
distance = FastMath.clamp(distance, minDistance, maxDistance);
float hDistance = distance * FastMath.sin((FastMath.PI / 2) - vRotation);
Vector3f pos = new Vector3f(hDistance * FastMath.cos(rotation), distance * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
tempPos = pos.add(chara.getWorldTranslation().add(0,charaHeight,0));
}[/java]
I doubt on one point. As you notice in Zelda, when the player press the left or right arrow the Character just turn around the Camera. I used the viewDirection of the character to do this. if(angle > 1.58 || angle …) i change the camRotation. Do you have an other solution to do this ?
ThirdPersonCamera (abstract) :
[java]/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
/**
*
@author Stomrage
/
public abstract class ThirdPersonCamera {
protected Camera cam;
protected CharacterControl charaC;
protected float vRotation = FastMath.PI/8;
protected float distance = 100;
protected float rotation = FastMath.PI;
protected float maxDistance;
protected float minDistance;
protected final float charaHeight;
protected Vector3f tempPos;
protected Vector3f initialUpVec = new Vector3f();
public ThirdPersonCamera(Camera cam, CharacterControl charaC) {
this(cam, charaC, 0);
}
public ThirdPersonCamera(Camera cam, CharacterControl charaC, float charaHeight){
this.charaHeight = charaHeight;
this.cam = cam;
this.charaC = charaC;
tempPos = new Vector3f(cam.getLocation());
initialUpVec.set(cam.getUp().clone());
}
public void setMaxDistance(float maxDistance){
this.maxDistance = maxDistance;
}
public void setMinDistance(float minDistance){
this.minDistance = minDistance;
}
protected void computePosition(){
distance = FastMath.clamp(distance, minDistance, maxDistance);
float hDistance = distance * FastMath.sin((FastMath.PI / 2) - vRotation);
tempPos.set(hDistance * FastMath.cos(rotation), distance * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
tempPos.addLocal(charaC.getPhysicsLocation().add(0,charaHeight,0));
}
protected Quaternion rotateCam(Vector3f direction1, Vector3f direction2, float interpolation){
Quaternion increment1 = new Quaternion();
increment1.fromAngles(direction1.x, 0, direction1.z);
Quaternion increment2 = new Quaternion();
increment2.fromAngles(direction2.x, 0, direction2.z);
Quaternion increment3 = increment2.slerp(increment1, increment2, interpolation);
float[] tempAngles = increment3.toAngles(null);
rotation = FastMath.atan2(tempAngles[2], tempAngles[0]);
return increment3;
}
public void setDistance(float distance){
this.distance = distance;
}
public abstract void updateCam(float tpf);
}
[/java]
ZeldaCam :
[java]/
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseAxisTrigger;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Spatial;
/**
*
@author Stomrage
/
public class ZeldaCam extends ThirdPersonCamera implements ActionListener, AnalogListener {
private boolean focus = false;
private Vector3f finalVector;
private Quaternion tempIncrement = new Quaternion();
private boolean fpMode = false;
public ZeldaCam(Camera cam, CharacterControl charaC, float charaHeight) {
super(cam, charaC, charaHeight);
}
public void updateCam(float tpf) {
if(!fpMode){
if (focus) {
float a = FastMath.asin(cam.getDirection().x);
a = FastMath.sin(a + FastMath.PI);
float b = FastMath.acos(cam.getDirection().z);
b = FastMath.cos(b + FastMath.PI);
Quaternion increment = rotateCam(new Vector3f(a, 0, b), finalVector, tpf * 30);
if (tempIncrement.equals(increment)) {
focus = true;
}
tempIncrement.set(increment);
}else{
rotation = FastMath.atan2(cam.getLocation().z - charaC.getPhysicsLocation().z, cam.getLocation().x - charaC.getPhysicsLocation().x);
}
calculatePhysic(tpf);
}
computePosition();
cam.setLocation(tempPos);
cam.lookAt(charaC.getPhysicsLocation().add(0, charaHeight, 0), initialUpVec);
}
public void registerWithInput(InputManager inputManager) {
String[] mappings = new String[]{
"Cam_Focus",
"Cam_FP",
"Cam_Left",
"Cam_Right",
"Cam_Up",
"Cam_Down"
};
inputManager.addMapping("Cam_Focus", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("Cam_FP", new KeyTrigger(KeyInput.KEY_T));
inputManager.addMapping("Cam_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping("Cam_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping("Cam_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping("Cam_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addListener(this, mappings);
inputManager.setCursorVisible(false);
}
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("Cam_Focus") && isPressed) {
focus = true;
Vector3f direction = charaC.getViewDirection();
finalVector = new Vector3f(direction.x, 0, direction.z);
}
if (name.equals("Cam_Focus") && !isPressed) {
focus = false;
}
if (name.equals("Cam_FP") && isPressed) {
if(fpMode){ fpMode = false; vRotation = FastMath.PI/8; }else{ fpMode = true; distance = minDistance; }
}
}
protected void calculatePhysic(float tpf) {
}
public void onAnalog(String name, float value, float tpf) {
if(name.equals("Cam_Left") && fpMode){
rotation -= value;
}
if(name.equals("Cam_Right") && fpMode){
rotation += value;
}
if(name.equals("Cam_Up") && fpMode){
vRotation -= value;
}
if(name.equals("Cam_Down") && fpMode){
vRotation += value;
}
}
}
[/java]
With physic :
[java]/
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.collision.CollisionResults;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
/**
*
@author Stomrage
/
public class PhysicZeldaCam extends ZeldaCam {
private Node collides;
public PhysicZeldaCam(Camera cam, CharacterControl charaC, float charaHeight) {
super(cam, charaC, charaHeight);
collides = new Node();
}
@Override
public void updateCam(float tpf) {
super.updateCam(tpf);
}
public void addCollideObject(Spatial obj) {
collides.attachChild(obj);
}
public Node getCollides() {
return collides;
}
@Override
protected void calculatePhysic(float tpf) {
Vector3f tempLocation = charaC.getPhysicsLocation().add(new Vector3f(0, charaHeight, 0));
CollisionResults leftRayResults = new CollisionResults();
CollisionResults rightRayResults = new CollisionResults();
CollisionResults results = new CollisionResults();
Quaternion quat180 = new Quaternion();
quat180.fromAngleAxis(FastMath.PI, cam.getUp());
Vector3f inverseCam = quat180.mult(cam.getDirection());
Ray leftRay = new Ray(tempLocation.add(cam.getLeft()), inverseCam);
Vector3f tempRight = quat180.mult(cam.getLeft());
Ray rightRay = new Ray(tempLocation.add(tempRight), inverseCam);
Ray centerRay = new Ray(charaC.getPhysicsLocation().add(new Vector3f(0, charaHeight, 0)), inverseCam);
collides.collideWith(centerRay, results);
collides.collideWith(leftRay, leftRayResults);
collides.collideWith(rightRay, rightRayResults);
if ((leftRayResults.size() > 0 && leftRayResults.getClosestCollision().getDistance() < maxDistance) && (rightRayResults.size() > 0 && rightRayResults.getClosestCollision().getDistance() < maxDistance)) {
if (results.size() > 0) {
if (results.getClosestCollision().getDistance() < maxDistance) {
distance = results.getClosestCollision().getDistance();
} else {
distance = maxDistance;
}
}
} else if (rightRayResults.size() > 0 && rightRayResults.getClosestCollision().getDistance() < maxDistance) {
rotation += FastMath.PI tpf;
} else if (leftRayResults.size() > 0 && leftRayResults.getClosestCollision().getDistance() < maxDistance) {
rotation -= FastMath.PI*tpf;
} else {
distance = maxDistance;
}
}
}
[/java]
Give me your point of view please. Do you have finish your own implementation ?
atomix
August 15, 2011, 9:40am
28
Yah, almost forget our topic here! My fault!
I’m continuing improve the chase cam as integrating the path follow method.
The abstract classes, almost like yours . I will post them here as soon as I get home!
i saw the video, nice work :
idea: put a max rotation on X axis so character doesnt look at sky (when going under the rock).
Here the pathFollow method in test !
[java]/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.FastMath;
import com.jme3.math.Line;
import com.jme3.math.LineSegment;
import com.jme3.math.Quaternion;
import com.jme3.math.Spline;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import java.awt.Rectangle;
/**
*
@author Stomrage
/
public abstract class ThirdPersonCamera {
protected Camera cam;
protected CharacterControl charaC;
protected float vRotation = FastMath.PI/8;
protected float distance = 100;
protected float rotation = FastMath.PI;
protected String text;
protected float maxDistance;
protected float minDistance;
protected final float charaHeight;
protected Vector3f tempPos;
protected Vector3f initialUpVec = new Vector3f();
protected boolean enabled;
protected Spline path;
protected boolean pathFollow;
private float percent = 0;
private int pos = 0;
public ThirdPersonCamera(Camera cam, CharacterControl charaC) {
this(cam, charaC, 0);
}
public ThirdPersonCamera(Camera cam, CharacterControl charaC, float charaHeight){
this.charaHeight = charaHeight;
this.cam = cam;
this.charaC = charaC;
tempPos = new Vector3f(cam.getLocation());
initialUpVec.set(cam.getUp().clone());
}
public void setPath(Spline path){
this.path = path;
}
public void setPathFollow(boolean value){
pathFollow = value;
}
public void setEnabled(boolean value) {
enabled = value;
}
public void setMaxDistance(float maxDistance){
this.maxDistance = maxDistance;
}
public void setMinDistance(float minDistance){
this.minDistance = minDistance;
}
protected void computePathPos(){
Vector3f vecAB = path.getControlPoints().get(pos+1).subtract(path.getControlPoints().get(pos));
Vector3f vecAP = charaC.getPhysicsLocation().subtract(path.getControlPoints().get(pos));
float magnitudeAB = vecAB.x vecAB.x + vecAB.yvecAB.y + vecAB.z vecAB.z;
float ABAPproduct = vecAB.xvecAP.x+vecAB.y vecAP.y+vecAB.zvecAP.z;
Vector3f point = new Vector3f(0,0,0);
float tempDist = ABAPproduct/magnitudeAB;
point = new Vector3f(path.getControlPoints().get(pos).x + vecAB.x * tempDist,
path.getControlPoints().get(pos).y + vecAB.y * tempDist,
path.getControlPoints().get(pos).z + vecAB.z * tempDist);
text = String.valueOf(point.distance(path.getControlPoints().get(pos)));
path.interpolate(point.distance(path.getControlPoints().get(pos))/path.getSegmentsLength().get(pos), pos, tempPos);
if(point.distance(path.getControlPoints().get(pos)) >= path.getSegmentsLength().get(pos) && pos < path.getSegmentsLength().size()-1){
pos += 1;
}
if(point.distance(path.getControlPoints().get(pos)) <= 5 && pos >= 1){
pos -= 1;
}
}
protected void computePosition(){
distance = FastMath.clamp(distance, minDistance, maxDistance);
float hDistance = distance * FastMath.sin((FastMath.PI / 2) - vRotation);
tempPos.set(hDistance * FastMath.cos(rotation), distance * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
tempPos.addLocal(charaC.getPhysicsLocation().add(0,charaHeight,0));
}
protected Quaternion rotateCam(Vector3f direction1, Vector3f direction2, float interpolation){
Quaternion increment1 = new Quaternion();
increment1.fromAngles(direction1.x, 0, direction1.z);
Quaternion increment2 = new Quaternion();
increment2.fromAngles(direction2.x, 0, direction2.z);
Quaternion increment3 = increment2.slerp(increment1, increment2, interpolation);
float[] tempAngles = increment3.toAngles(null);
rotation = FastMath.atan2(tempAngles[2], tempAngles[0]);
return increment3;
}
public void setDistance(float distance){
this.distance = distance;
}
public abstract void updateCam(float tpf);
public String getString(){
return text;
}
}
[/java]
[java]/
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package mygame;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseAxisTrigger;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
/**
*
@author Stomrage
*/
public class ZeldaCam extends ThirdPersonCamera implements ActionListener, AnalogListener {
private boolean focus = false;
private Vector3f finalVector;
private Quaternion tempIncrement = new Quaternion();
private boolean fpMode = false;
public ZeldaCam(Camera cam, CharacterControl charaC, float charaHeight) {
super(cam, charaC, charaHeight);
}
public void updateCam(float tpf) {
if (enabled) {
if (pathFollow) {
computePathPos();
cam.setLocation(tempPos);
cam.lookAt(charaC.getPhysicsLocation().add(0, charaHeight, 0), initialUpVec);
} else {
if (!fpMode) {
if (focus) {
float a = FastMath.asin(cam.getDirection().x);
a = FastMath.sin(a + FastMath.PI);
float b = FastMath.acos(cam.getDirection().z);
b = FastMath.cos(b + FastMath.PI);
Quaternion increment = rotateCam(new Vector3f(a, 0, b), finalVector, tpf * 30);
if (tempIncrement.equals(increment)) {
focus = true;
}
tempIncrement.set(increment);
} else {
rotation = FastMath.atan2(cam.getLocation().z - charaC.getPhysicsLocation().z, cam.getLocation().x - charaC.getPhysicsLocation().x);
}
text = String.valueOf(fpMode);
calculatePhysic(tpf);
}
computePosition();
cam.setLocation(tempPos);
cam.lookAt(charaC.getPhysicsLocation().add(0, charaHeight, 0), initialUpVec);
}
}
}
public void registerWithInput(InputManager inputManager) {
String[] mappings = new String[]{
“Cam_Focus”,
“Cam_FP”,
“Cam_Left”,
“Cam_Right”,
“Cam_Up”,
“Cam_Down”
};
inputManager.addMapping(“Cam_Focus”, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping(“Cam_FP”, new KeyTrigger(KeyInput.KEY_T));
inputManager.addMapping(“Cam_Left”, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(“Cam_Right”, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(“Cam_Up”, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(“Cam_Down”, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addListener(this, mappings);
inputManager.setCursorVisible(false);
}
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals(“Cam_Focus”) && isPressed) {
focus = true;
Vector3f direction = charaC.getViewDirection();
finalVector = new Vector3f(direction.x, 0, direction.z);
}
if (name.equals(“Cam_Focus”) && !isPressed) {
focus = false;
}
if (name.equals(“Cam_FP”) && isPressed) {
if (fpMode) {
fpMode = false;
vRotation = FastMath.PI / 8;
} else {
fpMode = true;
distance = minDistance;
}
}
}
protected void calculatePhysic(float tpf) {
}
public void onAnalog(String name, float value, float tpf) {
if (name.equals(“Cam_Left”) && fpMode) {
rotation -= value;
}
if (name.equals(“Cam_Right”) && fpMode) {
rotation += value;
}
if (name.equals(“Cam_Up”) && fpMode) {
vRotation -= value;
}
if (name.equals(“Cam_Down”) && fpMode) {
vRotation += value;
}
}
}
[/java]
Tralala i’ll implement this when i finish the pathFollow. And thanks for the sugestion.
mifth
August 31, 2011, 11:19am
31
Guys, put your latest version for testing, please.
Here the whole project Project/ . I don’t make change since the last post sorry. ( The project contains many Test so don’t be afraid…
2 Likes
mifth
September 7, 2011, 8:44am
33
Thanks for sharing. A I see you use native Bullet. Is it possible to cast it to jBullet?
If you tell me how can i do this. I think i can do it. But why do you want this update ?
normen
September 7, 2011, 10:51am
35
Uh @mifth , its pretty easy changing the library to jbullet yourself, why you want him do do that? ^^ Just open the project settings and remove the native physics library then add the normal one instead.