Author Topic: 3D object not rendering properly in nexus 4  (Read 2336 times)

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
3D object not rendering properly in nexus 4
« on: December 09, 2013, 08:09:57 am »
Hi,
I integrated Vuforia and jpct-ae properly in cloud based AR application. on marker detection it downloads 3d model (.obj) in zip file and extract it in external storage and renders it from there. It works fine on Nexus one and Samsung Note one. But when I am testing it on Nexus 4 and Sony xperia z6603 3D model is not rendering properly, I cant see anything or sometimes just a flicker. So I checked the if path is correct but log doesn't show any Nullpointer exception, and it shows all the models and texture built properly. I am using texture in 512*512.
I am not sure if it is the problem of new OS not supporting some texture?? or the fact that external storage path is different in those later two phones, but in this case as I mentioned there is no error shown. Did anybody face similar problem before? As far as I know am using latest version of jpct-ae.

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3D object not rendering properly in nexus 4
« Reply #1 on: December 09, 2013, 08:16:08 am »
No idea if this relates, but both devices are using Adreno GPUs. However, i'm developing the engine on a Nexus 4, so it actually works fine on that device. What exactly do you mean with "flicker"? And your uploaded log file contains one line only... ;)

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #2 on: December 09, 2013, 08:25:49 am »
sorry

[attachment deleted by admin]

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #3 on: December 09, 2013, 08:26:39 am »
here is the screenshot

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3D object not rendering properly in nexus 4
« Reply #4 on: December 09, 2013, 08:28:50 am »
How does your "render loop" looks like, i.e. the section of the code that calls draw and render and stuff?

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #5 on: December 09, 2013, 08:33:53 am »
this is the render loop in renderer,

/** Called to draw the current frame. */
    public void onDrawFrame(GL10 gl)
    {
       if (!mIsActive)
         return;
      
      
      if (mActivity.touchTurnUp != 0 && mActivity.isadded != false) {
         mActivity.new_thing.rotateZ(mActivity.touchTurnUp);
         //cube.rotateX(0.1f);
         mActivity.touchTurnUp = 0;
      }

      // Update render view (projection matrix and viewport) if needed:
      mActivity.updateRenderView();
      
      screenX1 = mActivity.screenX;
      screenY1 = mActivity.screenX;
      //mActivity.new_thing.animate(index, seq)
      
      
      updateCamera();
      renderFrame();
      
      
      world.renderScene(fb);
      world.draw(fb);
      //thing.animate(1, 1);
      fb.display();
    }


and this is where I add new texture and model to world in my main activity, in background thread

try {
            modelstrm = new FileInputStream(new File(imagePath));
            mtlstrm = new FileInputStream(new File(MaterialPath));
            texstrm = new FileInputStream(new File(TexturePath));

            System.out.println("Start loading 3D model");
            // fb = new FrameBuffer(mScreenWidth, mScreenHeight);

            try {

               System.out.println("Start loading Texture");

               // old_texture = new
               // Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ic_launcher)),
               // 64, 64));
               TextureManager tm = TextureManager.getInstance();
               if (!tm.containsTexture("new_texture")) {
                  new_texture = new Texture(BitmapHelper.rescale(
                        BitmapHelper.loadImage(texstrm), 512, 512));
                  // tm.unloadTexture(fb, new_texture);
                  // tm.r
                  // tm.replaceTexture("new_texture", old_texture);
                  new_texture.compress();
                  tm.addTexture("new_texture", new_texture);
               } else {
                  old_texture = new Texture(BitmapHelper.rescale(
                        BitmapHelper.loadImage(texstrm), 512, 512));
                  // tm.addTexture("new_texture", new_texture);
                  old_texture.compress();
                  tm.replaceTexture("new_texture", old_texture);
               }
               // tm.unloadTexture(mRenderer.fb, old_texture);
               System.out.println("End loading Texture");

            } catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }

            if (isadded) {
               new_thing.clearObject();
               new_thing = Object3D.mergeAll(Loader.loadOBJ(modelstrm,
                     mtlstrm, 1.0f));
               new_thing.setTexture("new_texture"); // somtheing is wrong
                                             // here
               new_thing.scale(2.0f);
               // isadded = true;
               isadded = false;
            }

            new_thing = Object3D.mergeAll(Loader.loadOBJ(modelstrm,
                  mtlstrm, 1.0f));
            new_thing.setTexture("new_texture"); // somtheing is wrong here
            // new_thing.scale(2.0f);
            isadded = true;

            // new_thing.translate(0, 0, 50);
            new_thing.rotateX(90);
            System.out.println("End loading 3D model");

         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }

         // dismissDialog(progress_bar_type);

         if (inputStream != null)
            Log.d("TAG", "It worked!");
         mRenderer.world.addObject(new_thing);
         pDialog.dismiss();

      }




Its not the cleanest of codes so please bear with

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #6 on: December 09, 2013, 08:54:59 am »
By the way I checked the far clipping plane configuration too. its 2500 . I think it should be enough.
Also attaching the screenshot from Samsung Note one, for the same model, same code and same far clipping plane.

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3D object not rendering properly in nexus 4
« Reply #7 on: December 09, 2013, 09:46:19 am »
Any chance that you are missing a call to FrameBuffer.clear();?

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #8 on: December 09, 2013, 10:01:21 am »
No, I havent used fb.clear. I have used fb.dispose in onsurfacechanged() though.
Where should I use fb.clear, in Renderer ondrawframe() or after , in my main activity where I am adding obj to world.?
« Last Edit: December 09, 2013, 10:06:01 am by nileshlg »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3D object not rendering properly in nexus 4
« Reply #9 on: December 09, 2013, 10:05:09 am »
Dispose frees the resources, clear clears the screen. They are totally different things. One is like throwing your canvas into the garbage can while the other is painting it white to start a new drawing. You have to call clear() every frame to make sure that frame- and depth buffer are empty.

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #10 on: December 09, 2013, 10:26:25 am »
I am not using fb.clear, because vuforia is already doing that. If I put fb.clear, background video is also cleared and am getting black background.

Offline nileshlg

  • byte
  • *
  • Posts: 9
    • View Profile
Re: 3D object not rendering properly in nexus 4
« Reply #11 on: December 09, 2013, 10:33:08 am »
Its working now,
It was the frame buffer clearing problem, in vuforia native code it was disabled by mistake.
Thanks a lot for your help.