Author Topic: rotation problem (it moves)  (Read 7184 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
rotation problem (it moves)
« Reply #15 on: December 14, 2006, 08:10:43 pm »
I see...so how does the code that does this looks exactly?

Offline theFALCO

  • byte
  • *
  • Posts: 39
    • View Profile
rotation problem (it moves)
« Reply #16 on: December 14, 2006, 08:22:49 pm »
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();

Code: [Select]
   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);
    }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
rotation problem (it moves)
« Reply #17 on: December 14, 2006, 08:26:28 pm »
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

Code: [Select]

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


to

Code: [Select]
if(right) {
    cube.rotateAxis(cube.getYAxis(), 0.01f);
}


and the other rotations accordingly.

Offline theFALCO

  • byte
  • *
  • Posts: 39
    • View Profile
rotation problem (it moves)
« Reply #18 on: December 14, 2006, 08:37:25 pm »
cool, it works
thanks  :D