Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - chocoman

#1
Support / Re: rendered image is mirrored
December 09, 2017, 01:56:47 AM
Thank you, I misinterpreted the image describing the coordinate system on the wiki at http://www.jpct.net/wiki/index.php?title=Coordinate_system
Maybe the attached image would be less ambiguous.
#2
Support / rendered image is mirrored
December 08, 2017, 08:21:03 PM
Hello,

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,
Martin


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);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
      
      world = new World();
      world.setAmbientLight(0, 255, 0);

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

      box = Primitives.getBox(13f, 2f);
      box.setTexture("box");
      box.setEnvmapped(Object3D.ENVMAP_ENABLED);
      box.build();
      world.addObject(box);
      
      Object3D smallbox = Primitives.getBox(5f, 2f);
      smallbox.translate(new SimpleVector(30,0,0));  // moving the small box to the right
      smallbox.setTexture("box");
      smallbox.setEnvmapped(Object3D.ENVMAP_ENABLED);
      smallbox.build();
      
      world.addObject(smallbox);

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

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

      while (frame.isShowing()) {
         box.rotateY(0.01f);
         buffer.clear(java.awt.Color.BLUE);
         world.renderScene(buffer);
         world.draw(buffer);
         buffer.update();
         buffer.displayGLOnly();
         canvas.repaint();
         Thread.sleep(10);
      }
      buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
      buffer.dispose();
      frame.dispose();
      System.exit(0);
   }
}