rotation problem (it moves)

Started by theFALCO, December 12, 2006, 08:24:21 PM

Previous topic - Next topic

EgonOlsen

I see...so how does the code that does this looks exactly?

theFALCO

cube init:
private Object3D cube = Primitives.getCube(1);
...
       cube.setOrigin(new SimpleVector(0, 0, 0));
       cube.setBaseTexture("teks");
       cube.setTexture("teks");
       cube.setTranslationMatrix(new Matrix());
... // then goes the theWorld.add(cube); and buildAll();

   private void gameLoop() {
       World.setDefaultThread(Thread.currentThread());
       buffer=new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
       buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
       buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
       buffer.optimizeBufferAccess();
       Timer timer = new Timer(25);
       timer.start();

       while(!exit) {
           if(!isIdle) {
               buffer.clear();
               theWorld.renderScene(buffer);
               theWorld.draw(buffer);
               buffer.update();
               poll();
               camera.setPosition(cube.getTransformedCenter());
               camera.align(cube);
               if(right) {
                   cube.rotateAxis(camera.getBack().getYAxis(), 0.01f);
                   cube.rotateY(0.01f);
               }
               if(left) {
                   cube.rotateAxis(camera.getBack().getYAxis(), 0.01f);
                   cube.rotateY(-0.01f);
               }
               if(up) {
                   cube.rotateAxis(camera.getBack().getXAxis(), 0.01f);
                   cube.rotateX(0.01f);
               }
               if(down) {
                   cube.rotateAxis(camera.getBack().getXAxis(), -0.01f);
                   cube.rotateX(-0.01f);
               }
               camera.setPosition(cube.getTransformedCenter());
               camera.align(cube);
               //camera.moveCamera(Camera.CAMERA_MOVEOUT, 10);
               buffer.display(gFrame, leftBorderWidth, titleBarHeight);
               Thread.yield();
           }
       }
       if (openGL) {
           buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
       } else {
           if (fullscreen) {
               device.setFullScreenWindow(null);
           }
       }
       System.exit(0);
   }

EgonOlsen

Rotate one entity, not a mixture of cube and camera...that may work somehow, but seems to be too confusing to me. Try to change


if(right) {
   cube.rotateAxis(camera.getBack().getYAxis(), 0.01f);
   cube.rotateY(0.01f);
}


to

if(right) {
   cube.rotateAxis(cube.getYAxis(), 0.01f);
}


and the other rotations accordingly.

theFALCO