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.


Messages - nileshlg

Pages: [1]
1
Support / dynamic texture loading
« on: February 04, 2015, 12:37:13 pm »
Hi,
In my Vuforia + Jpct-AE app I have to download the 3d model (.obj, .mtl, .jpg) from remote server upon Image detection and render / replace with current 3D object  and respective texture in jpct scene. Until this point it works fine; However my problem is some times some 3D models will have multiple textures (jpegs). How can I add those textures in the texture manager and apply to object dynamically.
For example, Initially I have box model in scene, upon first scan I download and replace Box with table (2 textures) but in next scan I might use Room.obj which contain 4-5 textures. Now I don't know How many texture images are there in folder until I scan the folder and check for no. of jpegs programmatically.  but then how can I replace 4-5 textures with previous 2 textures.
Honestly, I am little confused about texture manager and handling it. I would really appreciate if some one help me with logic or source code wise.

2
Support / Re: 3D object not rendering properly in nexus 4
« 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.

3
Support / Re: 3D object not rendering properly in nexus 4
« 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.

4
Support / Re: 3D object not rendering properly in nexus 4
« 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.?

5
Support / Re: 3D object not rendering properly in nexus 4
« 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]

6
Support / Re: 3D object not rendering properly in nexus 4
« 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

7
Support / Re: 3D object not rendering properly in nexus 4
« on: December 09, 2013, 08:26:39 am »
here is the screenshot

[attachment deleted by admin]

8
Support / Re: 3D object not rendering properly in nexus 4
« on: December 09, 2013, 08:25:49 am »
sorry

[attachment deleted by admin]

9
Support / 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]

Pages: [1]