3D object not rendering properly in nexus 4

Started by nileshlg, December 09, 2013, 08:09:57 AM

Previous topic - Next topic

nileshlg

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]

EgonOlsen

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... ;)

nileshlg


nileshlg

here is the screenshot

[attachment deleted by admin]

EgonOlsen

How does your "render loop" looks like, i.e. the section of the code that calls draw and render and stuff?

nileshlg

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

nileshlg

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]

EgonOlsen

Any chance that you are missing a call to FrameBuffer.clear();?

nileshlg

#8
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.?

EgonOlsen

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.

nileshlg

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.

nileshlg

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.