Minor change in ChaseCamera

One thing that annoys me is that when I click using the left mouse button the cursor disappears. I also don’t want to use that button to rotate the world, but I couldn’t fix it without touching the base class because “canRotate” is private. (I override onAction(…) and registerWithInput(…))



So I changed it to protected (also did a bit of cleanup).



Here’s the diff if you guys are interested in adding it.



[patch]# This patch file was generated by NetBeans IDE

It uses platform neutral UTF-8 encoding and n newlines.

— Base (BASE)

+++ Locally Modified (Based On LOCAL)

@@ -85,7 +85,6 @@

private boolean zooming = false;

private boolean trailing = false;

private boolean chasing = false;

  • private boolean canRotate;

    private float offsetDistance = 0.002f;

    private Vector3f prevPos;

    private boolean targetMoves = false;

    @@ -96,9 +95,9 @@

    private final Vector3f pos = new Vector3f();

    protected boolean dragToRotate = true;

    protected Vector3f lookAtOffset = null;
  • protected boolean invertYaxis=false;
  • protected boolean canRotate;
  • protected boolean invertYaxis = false;



    -

    /**
  • Constructs the chase camera
  • @param cam the application camera

    @@ -137,8 +136,6 @@

    }

    }

    }

    -

    -

    }

    boolean zoomin;



    @@ -164,7 +161,6 @@

    }

    zoomin = false;

    }

    -

    }



    /**

    @@ -175,10 +171,10 @@

    String[] inputs = {"toggleRotate", "Down", "Up", "mouseLeft", "mouseRight", "ZoomIn", "ZoomOut"};



    this.inputManager = inputManager;
  •    if(!invertYaxis){<br />
    
  •    if (!invertYaxis) {<br />
    

inputManager.addMapping("Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true));

inputManager.addMapping("Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false));

  •    }else{<br />
    
  •    } else {<br />
    

inputManager.addMapping("Down", new MouseAxisTrigger(MouseInput.AXIS_Y, false));

inputManager.addMapping("Up", new MouseAxisTrigger(MouseInput.AXIS_Y, true));

}

@@ -190,8 +186,6 @@

inputManager.addMapping("toggleRotate", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));



inputManager.addListener(this, inputs);

-

-

}



private void computePosition() {

@@ -780,15 +774,13 @@

this.invertYaxis = invertYaxis;

inputManager.deleteMapping("Down");

inputManager.deleteMapping("Up");

  •    if(!invertYaxis){<br />
    
  •    if (!invertYaxis) {<br />
    

inputManager.addMapping("Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true));

inputManager.addMapping("Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false));

  •    }else{<br />
    
  •    } else {<br />
    

inputManager.addMapping("Down", new MouseAxisTrigger(MouseInput.AXIS_Y, false));

inputManager.addMapping("Up", new MouseAxisTrigger(MouseInput.AXIS_Y, true));

}

  •    inputManager.addListener(this, &quot;Down&quot;,&quot;Up&quot;);<br />
    
  •    inputManager.addListener(this, &quot;Down&quot;, &quot;Up&quot;);<br />
    

}

-

-

}

[/patch]

oh boy! canRotate is an internal flag, and making it private is intended.

If you modify it in a sub class, results will be unexpected. (I guess you only “read” it, but who knows what a monkey can do…)



If you don’t want the left button to rotate the cam, you can just delete the “toggleRotate” mapping from the inputManager and then re-add the mapping on the right mouse button.

I reckon it’s not really convenient…maybe I should provide a way to easily change the mapping…



For the cursor, adding a flag hideCursorOnRotate could have done the trick.

Honestly, I wasn’t too thrilled about editing it. :wink:



Anyway, if you come up with a way to specify which button to bind to rotation, let me know.



As for the cursor hiding, I do want it hidden when rotating, but only when it’s the right mouse button. I want it that way because if you left-click something but move the mouse slightly as you click, there will be both rotation and a click. I just want a click with that button. :slight_smile:

oh ok so just removing the mapping on the left button should do the trick

Alright. I did it as you suggested, but it’s not convenient as you also said.

:smiley: