Search code examples
androidopengl-es-2.0texturesvuforiajpct

Texture ambiguty when integrating jpct-ae with vuforia


I successfully integrated vuforia and jpct-ae. I can download .obj model with its .Mtl file and texture file, and load it using jpct-ae loader on marker detection. 3D model is displayed very well over image target but without Texture (Material is fine). On digging more I found out that in when I declare texture in my Renderer class it takes as JPCT-ae Texture but when i do it in my Main Activity class it take Texture as Vuforia texture. I tried to Explicitly Include Jpct-ae Texture.h in Main activity but then QCAR won't initialize. without Declaring Texture in main activity I don't know how to change/update new texture (downloaded image) in real time.

Basically I need to update texture dynamically uing newly downloaded image.

Can anybody suggest me any how can i solve this problem? Any help or suggestion is appreciated.

Thanks


Solution

  • I solved ambiguity problem by disabling the getProductTexture() which sends Texture to Native code. Now I can apply the texture in main Activity as well as in render activity. To update the texture dynamically I used jpct-ae's ReplaceTexture(). following is the code snippet (I am not sure this is the best way to it, but it works fine for me)\ try { modelstrm = new FileInputStream(new File(imagePath));

                texstrm = new FileInputStream(new File(TexturePath));               
                System.out.println("Start loading crab md2 model");     
    
    
                try {
    
                    System.out.println("Start loading Texture");        
    
    
                    TextureManager tm = TextureManager.getInstance();
                    if(!tm.containsTexture("new_texture")){
                        new_texture = new Texture(BitmapHelper.rescale(BitmapHelper.loadImage(texstrm), 512, 512));
    
                        tm.addTexture("new_texture", new_texture);
                    }   
                    else{               
                        old_texture = new Texture(BitmapHelper.rescale(BitmapHelper.loadImage(texstrm), 512, 512));
    
                        tm.replaceTexture("new_texture", old_texture);
                    }
    
                    System.out.println("End loading Texture");
    
    
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }