keyboard type orbitbehaviour

Hello there,

I would like to make a keybaord-style orbit behaviour

Basically, I want to be able to have a central target point and then using a KeyListener, left and right would rotate the view around the point and up and down would increase, decrease the angle respectivly

Any suggestion? I really need to know the maths behind it, I’m ok with making the views in java3d, etc

Thanks :smiley:

I was in this boat a little while ago. I started with the normal OrbitBehavior and then took out bits I didn’t need. In the end I had almost none of the original OrbitBehaviour left except maybe a couple of variable names.

This was to work of some Swing buttons, but making it related to keys wouldn’t be too hard. Apologies for untidy code- too lazy to sort it now, not sure where I put the final version.

No idea why the page has gone so wide there, mind.

thanks breakfast, I’ll take a look tonight! :smiley:

I too found it easier to do from scratch: P


 public void calculateCamPos() {
        cameraX = objectX + Math.sin( Globals.getDegreesToRadians( angle ) ) * objectDistance;
        cameraZ = objectZ + Math.cos( Globals.getDegreesToRadians( angle ) ) * objectDistance;
    }

it works great!

Often the way- I hope looking at the structure was useful at least…

oh yeah, I was not saying in any way that yours was not helpful cos it was

Thanks again!