java - jPCT: Strange camera rotation -


i have created rubik's cube jpct , need rotate whole cube. have tried achieve rotation matrixes , have rotated single cube elements not seem way..

so want rotate camera around cube instead of rotating cube. pretty easy problem jpct changes orientation of camera randomly or have done mistake , unable fix it.

simplevector camerapos = new simplevector(-20, 0, 0); simplevector cubecenter = new simplevector(2, 2, 2);  while (!org.lwjgl.opengl.display.iscloserequested()) {      refreshscene();      // camera position repeatedly rotated     camerapos.rotateaxis(new simplevector(0, 0, 1), (float) math.toradians(1));     // here set camera position     world.getcamera().setposition(camerapos);     // camera looks @ center of cube, unfortunately     // not fixed orientation     world.getcamera().lookat(cubecenter);      try {         thread.sleep(50);     } catch (interruptedexception e) {      } } 

above code performs strange rotation of cube:

current camera rotation

that cool need rotate cube this: desired camera rotation

i have tried set camera orientation setorientation method:

simplevector upvector = world.getcamera().getupvector(); upvector.scalarmul(-1.0f); world.getcamera().setorientation(world.getcamera().getdirection(), upvector); 

the last line in code should imho turn camera orientation upside down, nothing. use last version of jpct.

how can achieve right camera orientation? welcome!

if want rotate cube, seems want do, why not put dummy object3d in center, make elements of cube children of dummy , rotate dummy? should give desired results. approach: can sure rotations aren't random. ask in code. why results in seeing here, hard tell without knowing complete scene setup. anyway, easiest way rotate camera around fixed point in space, make @ point in initial setup, this:

cam.movecamera(camera.camera_movein, distance); cam.rotateaxis(<some axis>, <float>); cam.movecamera(camera.camera_moveout, distance); 

where distance initial distance camera rotation pivot. can find example here.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -