我尝试使用min3d在我的应用中启动3D对象,但它崩溃了。我跟着这个tuto:http://www.mat-d.com/site/using-min3d-for-android-frequently-asked-questions-common-texture-issues-blender-import/
以下是代码:
package com.g171.zaloeil;
import min3d.core.Object3dContainer;
import min3d.core.RendererActivity;
import min3d.parser.IParser;
import min3d.parser.Parser;
import min3d.vos.Light;
public class Vue3D extends RendererActivity {
private Object3dContainer faceObject3D;
/** Called when the activity is first created. */
@Override
public void initScene()
{
scene.lights().add(new Light());
scene.lights().add(new Light());
Light myLight = new Light();
myLight.position.setZ(150);
scene.lights().add(myLight);
IParser myParser = Parser.createParser(Parser.Type.OBJ, getResources(), "com.g171.zaloeil:raw/cle1_obj",true);
myParser.parse();
faceObject3D = myParser.getParsedObject();
faceObject3D.position().x = faceObject3D.position().y = faceObject3D.position().z = 0;
faceObject3D.scale().x = faceObject3D.scale().y = faceObject3D.scale().z = 0.009f;
// Depending on the model you will need to change the scale
faceObject3D.scale().x = faceObject3D.scale().y = faceObject3D.scale().z = 0.009f;
scene.addChild(faceObject3D);
}
@Override
public void updateScene() {
faceObject3D.rotation().x += 0.5;
faceObject3D.rotation().z += 1;
}
}
这是logcat:
01-13 14:57:35.904: D/dalvikvm(12402): Late-enabling CheckJNI
01-13 14:57:36.044: D/dalvikvm(12402): GC_FOR_ALLOC freed 77K, 3% free 7491K/7720K, paused 22ms, total 22ms
01-13 14:57:36.054: I/dalvikvm-heap(12402): Grow heap (frag case) to 10.458MB for 3145744-byte allocation
01-13 14:57:36.094: D/dalvikvm(12402): GC_FOR_ALLOC freed 1K, 3% free 10562K/10796K, paused 37ms, total 37ms
01-13 14:57:36.134: D/dalvikvm(12402): GC_CONCURRENT freed <1K, 3% free 10562K/10796K, paused 9ms+2ms, total 45ms
01-13 14:57:36.194: D/dalvikvm(12402): GC_FOR_ALLOC freed <1K, 3% free 10562K/10796K, paused 23ms, total 23ms
01-13 14:57:36.244: I/dalvikvm-heap(12402): Grow heap (frag case) to 15.771MB for 5571960-byte allocation
01-13 14:57:36.284: D/dalvikvm(12402): GC_FOR_ALLOC freed 0K, 2% free 16003K/16240K, paused 33ms, total 33ms
01-13 14:57:36.324: D/dalvikvm(12402): GC_CONCURRENT freed <1K, 2% free 16004K/16240K, paused 12ms+5ms, total 46ms
01-13 14:57:36.464: D/libEGL(12402): loaded /system/lib/egl/libEGL_tegra.so
01-13 14:57:36.474: D/libEGL(12402): loaded /system/lib/egl/libGLESv1_CM_tegra.so
01-13 14:57:36.484: D/libEGL(12402): loaded /system/lib/egl/libGLESv2_tegra.so
01-13 14:57:36.504: D/OpenGLRenderer(12402): Enabling debug mode 0
01-13 14:57:39.184: I/Min3D(12402): ManagedLightList.reset()
01-13 14:57:39.234: I/Min3D(12402): Renderer.onSurfaceCreated()
01-13 14:57:39.234: V/Min3D(12402): RenderCaps - openGLVersion: 1.1
01-13 14:57:39.234: V/Min3D(12402): RenderCaps - maxTextureUnits: 2
01-13 14:57:39.234: V/Min3D(12402): RenderCaps - maxTextureSize: 2048
01-13 14:57:39.234: V/Min3D(12402): RenderCaps - maxLights: 8
01-13 14:57:39.234: I/Min3D(12402): Scene.init()
01-13 14:57:39.234: I/Min3D(12402): ManagedLightList.reset()
01-13 14:57:39.244: D/Min3D(12402): Start parsing object com.g171.zaloeil:raw/cle1_obj
01-13 14:57:39.244: D/Min3D(12402): Start time 1358085459252
01-13 14:57:39.254: W/ResourceType(12402): No package identifier when getting value for resource number 0x00000000
01-13 14:57:39.254: W/dalvikvm(12402): threadid=12: thread exiting with uncaught exception (group=0x40b99930)
01-13 14:57:39.264: E/AndroidRuntime(12402): FATAL EXCEPTION: GLThread 493
01-13 14:57:39.264: E/AndroidRuntime(12402): android.content.res.Resources$NotFoundException: Resource ID #0x0
01-13 14:57:39.264: E/AndroidRuntime(12402): at android.content.res.Resources.getValue(Resources.java:1014)
01-13 14:57:39.264: E/AndroidRuntime(12402): at android.content.res.Resources.openRawResource(Resources.java:939)
01-13 14:57:39.264: E/AndroidRuntime(12402): at android.content.res.Resources.openRawResource(Resources.java:921)
01-13 14:57:39.264: E/AndroidRuntime(12402): at min3d.parser.ObjParser.readMaterialLib(ObjParser.java:175)
01-13 14:57:39.264: E/AndroidRuntime(12402): at min3d.parser.ObjParser.parse(ObjParser.java:107)
01-13 14:57:39.264: E/AndroidRuntime(12402): at com.g171.zaloeil.Vue3D.initScene(Vue3D.java:25)
01-13 14:57:39.264: E/AndroidRuntime(12402): at min3d.core.Scene.init(Scene.java:254)
01-13 14:57:39.264: E/AndroidRuntime(12402): at min3d.core.Renderer.onSurfaceCreated(Renderer.java:75)
01-13 14:57:39.264: E/AndroidRuntime(12402): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
01-13 14:57:39.264: E/AndroidRuntime(12402): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
有人知道会遗漏什么吗?
答案 0 :(得分:1)
未找到资源异常。
您正在引用尚未添加到包中的资源:
android.content.res.Resources$NotFoundException: Resource ID #0x0
特别是:
01-13 14:57:39.264: E/AndroidRuntime(12402): at com.g171.zaloeil.Vue3D.initScene(Vue3D.java:25)
Vue3D.java:25是你的问题(第25行)。您正在引用项目中不存在的资源(R.id.xxxx)。