【问题标题】:Texture ambiguty when integrating jpct-ae with vuforia将 jpct-ae 与 vuforia 集成时纹理模糊
【发布时间】:2013-08-04 13:22:51
【问题描述】:
我成功集成了 vuforia 和 jpct-ae。我可以下载 .obj 模型及其 .Mtl 文件和纹理文件,并在标记检测时使用 jpct-ae 加载器加载它。 3D 模型在图像目标上显示得非常好,但没有纹理(材质很好)。在深入挖掘时,我发现当我在我的 Renderer 类中声明纹理时,它采用 JPCT-ae 纹理,但是当我在我的 Main Activity 类中这样做时,它采用纹理作为 Vuforia 纹理。我尝试在主要活动中明确包含 Jpct-ae Texture.h,但 QCAR 不会初始化。如果没有在主要活动中声明纹理,我不知道如何实时更改/更新新纹理(下载的图像)。
基本上我需要使用新下载的图像动态更新纹理。
谁能建议我如何解决这个问题?任何帮助或建议表示赞赏。
谢谢
【问题讨论】:
标签:
android
opengl-es-2.0
textures
vuforia
jpct
【解决方案1】:
我通过禁用将纹理发送到本机代码的 getProductTexture() 解决了歧义问题。
现在我可以在主 Activity 和渲染 Activity 中应用纹理。
为了动态更新纹理,我使用了 jpct-ae 的 ReplaceTexture()。以下是代码 sn-p (我不确定这是最好的方法,但它对我来说很好)\
尝试 {
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();
}