我尝试使用 min3d 在我的动态壁纸应用程序中加载 3d 对象,但我有这个例外:“E/AndroidRuntime(5989): android.content.res.Resources$NotFoundException: Resource ID #0x0”。
我把“sunflower_obj”和“sunflower_mlt”文件放到“res/raw”文件夹,“sunflower.jpg”放到“res/drawable”文件夹。这是我的代码:
package com.electricpunch.wallpaper;
import min3d.core.Object3dContainer;
import min3d.objectPrimitives.ParticleSprite;
import min3d.parser.IParser;
import min3d.parser.Parser;
import min3d.wallpaper.CommonRender;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
public class TestRenderer extends CommonRender {
private Context mContext;
private float mCameraPosition;
private Object3dContainer objModel;
public TestRenderer(Context _context) {
super(_context);
this.mContext = _context;
mCameraPosition = 0.5f;
}
@Override
public void initScene() {
IParser parser = Parser.createParser(Parser.Type.OBJ, mContext.getResources(), "com.electricpunch.wallpaper:raw/sunflower_obj", true);
parser.parse();
objModel = parser.getParsedObject();
objModel.scale().x = objModel.scale().y = objModel.scale().z = .7f;
scene.addChild(objModel);
}
@Override
public void updateScene() {
objModel.rotation().x++;
objModel.rotation().z++;
}
@Override
public void onTouchUp(int x, int y) {
Log.i("TAG", "Touch");
}
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) {
mCameraPosition = xOffset;
}
}