Recent Posts

Pages: [1] 2 3 ... 10
1
Support / Re: rendered image is mirrored
« Last post by chocoman on 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 / Re: rendered image is mirrored
« Last post by EgonOlsen on December 08, 2017, 08:38:15 pm »
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.
3
Support / rendered image is mirrored
« Last post by chocoman on 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);
   }
}
4
Support / Camera back inversing after crossing threshold
« Last post by ghosalmartin on December 06, 2017, 04:54:44 pm »
So now am getting the camera information here

Quote
           
 // Get camera matrix and draw.
val viewmtx = FloatArray(16)
frame.pose.toMatrix(viewmtx, 0)

val matrix = Matrix()
matrix.dump = viewmtx
         
cam!!.back = matrix

But then the camera randomly left and right when I cross a certain location, SimpleVector.ORIGIN I think and not quite sure why


Yet another edit:

Fixed my issue doing what this guy did in the 2nd post

http://www.jpct.net/forum2/index.php/topic,3843.0.html

This forums thought of everything :D

I have a mask which is a sphere, and inside in the sphere another set of models which is the world, and the inner models is slightly popping out of the mask to give the effect of a portal, and the camera is in the background. but how can I make the mask transparent or give that effect, but also have it enclose the model inside it.

Since I can add transparency to the mask but that reveals the object inside. or am I asking for something not possible

Think am trying to do what this guy tried to do:

http://www.jpct.net/forum2/index.php?topic=1645.0


ignore the below since it seems am being a bit of an idiot :P

So am trying to map a texture to my texture manager and following this topic

http://www.jpct.net/forum2/index.php?topic=3794.0

But it won't display that texture but another texture from the texture manager. The textureid am using is from here https://github.com/google-ar/arcore-android-sdk/blob/master/samples/java_arcore_hello_ar/app/src/main/java/com/google/ar/core/examples/java/helloar/rendering/BackgroundRenderer.java#L71

What am I missing? Since the camera renders fine as the background, but I need it to render as a texture to an object.


Big fan of the engine btw :D
5
Support / Re: How can I get a bitmap from fb.getpixel()?
« Last post by EgonOlsen on December 04, 2017, 08:22:33 am »
Yes, reading the pixels from GPU memory is a slow process...
6
Support / Re: How can I get a bitmap from fb.getpixel()?
« Last post by ScienceHill on December 02, 2017, 11:55:58 pm »
Thank you for your reply! And I had figured out why it didn't work. You are right. My frame buffer was empty. To solve this problem, I just put the getPixels() method in the onDrawFrame like this:
```
public int[] tmpPixels;// Global variance
public void onDrawFrame(GL10 gl) {
            tmpPixels = fb.getPixels();
            fb.clear(back);

            world.renderScene(fb);
            world.draw(fb);
            fb.display();
}
```
Then I convert the int array (tmpPixels) to bitmap and save it in my dispatchKeyEvent like this way:
```
case KeyEvent.KEYCODE_VOLUME_UP:
                if (action == KeyEvent.ACTION_DOWN) {
                    Bitmap lastImage = Bitmap.createBitmap(fb.getWidth(), fb.getHeight(), Bitmap.Config.ARGB_4444);
                    lastImage.copyPixelsFromBuffer(IntBuffer.wrap(tmpPixels));

                    File sdCard = Environment.getExternalStorageDirectory();
                    File dir = new File (sdCard.getAbsolutePath() + "/my_jpg_test");
                    Log.i("JPCT","My File path" + sdCard.getAbsolutePath() + "/my_jpg_test");
                    dir.mkdirs();

                    String fileName = String.format("The.jpg");
                    File outFile = new File(dir, fileName);
                    FileOutputStream outputStream = null;
                    try {
                        outputStream = new FileOutputStream(outFile);
                        int quality = 100;
                        lastImage.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
                        outputStream.flush();
                        outputStream.close();

                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
}
```
And it works!
By the way, obviously, the program becomes extremely slow by using tmpPixels to record the pixel of image on onDrawFrame in this way. Of course I will use some flags to control this process. Thanks again!
7
Support / Re: Retrieve Model Matrix and scale along a particular Matrix
« Last post by tsaha on December 02, 2017, 08:56:48 pm »
Thank you for your help. I will try that out.  ;D
8
Support / Re: Retrieve Model Matrix and scale along a particular Matrix
« Last post by EgonOlsen on December 02, 2017, 10:28:41 am »
Out of the box, jPCT doesn't support non-uniform scaling, because of...reasons. However, you can retrieve the rotation matrix and apply a scale to it. The drawback is, that this will modify the normals as well, so it might cause lighting to go off. But depending on the app, that might not even be an issue at all.
9
Support / Retrieve Model Matrix and scale along a particular Matrix
« Last post by tsaha on December 02, 2017, 12:20:58 am »
Hello Everyone,

I working on AR (ARToolkit) android application as a part of my coursework. I am using JPCT-AE to render 3D objects. Now my world objects has multiple 3D objects. I intend to scale a cylinder along Y axis only to represent some parameter value. I went through the official documentation and could find anything useful. Can anyone direct me towards the right way. Thanks in advance. Appreciate your help.
10
Support / Re: How can I get a bitmap from fb.getpixel()?
« Last post by EgonOlsen on November 29, 2017, 08:20:22 am »
Can you check the actual array content? Maybe it's all 0 at that stage already from some reason.
Pages: [1] 2 3 ... 10