jPCT - a 3d engine for Java > Support

rendered image is mirrored



it seems that when a scene is rendered, the resulting image is flipped left to right. I need to render the scene without this flipping.

see the modified code of the HelloWorld example below, which demonstrates this. The rendered screen is attached The expected rendered image would have a small box to the right from the big box, but in the rendered image the small box is to the left.

I tried to achieve this by modifying the camera matrix: I multiplied the first row by -1. This flipped the scene correctly, but the textures were "inside-out", The textures facing the camera were not visible, but the textures on the other side of the object were visible.

Is there any solution to this problem?

Thank you,

import com.threed.jpct.*;
import javax.swing.*;
import java.awt.*;

 * A simple HelloWorld using the AWTGL-Renderer and rendering into a frame.
 * @author EgonOlsen
public class HelloWorldAWTGL {

   private World world;
   private FrameBuffer buffer;
   private Object3D box;
   private JFrame frame;

   public static void main(String[] args) throws Exception {
      new HelloWorldAWTGL().loop();

   public HelloWorldAWTGL() throws Exception {
      frame=new JFrame("Hello world");
      frame.setSize(800, 600);
      world = new World();
      world.setAmbientLight(0, 255, 0);

      TextureManager.getInstance().addTexture("box", new Texture("box.jpg"));

      box = Primitives.getBox(13f, 2f);
      Object3D smallbox = Primitives.getBox(5f, 2f);
      smallbox.translate(new SimpleVector(30,0,0));  // moving the small box to the right

      world.getCamera().setPosition(0, 0, 200); // camera in front of both boxes

   private void loop() throws Exception {
      buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
      Canvas canvas=buffer.enableGLCanvasRenderer();

      while (frame.isShowing()) {

Please don't fiddle around with the camera's matrix, there's no need for this. You are simply looking on the scene from behind. Positive Z goes into the screen in jPCT's coordinate system. So your code moves the camera behind the objects and then makes a 180 turn around y caused by the lookAt call. Just move the camera -200 units into z-direction instead and you should be fine.

Thank you, I misinterpreted the image describing the coordinate system on the wiki at
Maybe the attached image would be less ambiguous.

That's true, I guess. I've replaced the image in the wiki with your image.


[0] Message Index

Go to full version