使用Rajawali在Android中显示.obj不起作用

使用Rajawali在Android中显示.obj不起作用,android,opengl-es,3d,3dsmax,rajawali,Android,Opengl Es,3d,3dsmax,Rajawali,我想使用Rajawali框架在android应用程序中显示一个3d对象。我用Autodesk 3DS MAX创建了一个3d对象。(我读过一些文章,建议使用blender。但我下载了一个我想使用的模型及其.3DS文件) 我将.obj和.mtl放入原始文件夹(按照mymodel_obj和mymodel_mtl中的建议重命名文件),然后创建了一个渲染器类: public class Renderer extends RajawaliRenderer { private Context context

我想使用Rajawali框架在android应用程序中显示一个3d对象。我用Autodesk 3DS MAX创建了一个3d对象。(我读过一些文章,建议使用blender。但我下载了一个我想使用的模型及其.3DS文件)

我将.obj和.mtl放入原始文件夹(按照mymodel_obj和mymodel_mtl中的建议重命名文件),然后创建了一个渲染器类:

public class Renderer extends RajawaliRenderer {

private Context context;
private Object3D mObject;


//constructor
public Renderer(Context context) {
    super(context);
    this.context = context;
    setFrameRate(60);
}

@Override
protected void initScene() {
    try {
        LoaderOBJ objParser = new LoaderOBJ(context.getResources(),mTextureManager, R.raw.denture_obj);
        objParser.parse();
        mObject = objParser.getParsedObject();       
        getCurrentScene().addChild(mObject);  
    }catch (ParsingException e){
        e.printStackTrace();
    }
}

@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {}

@Override
public void onTouchEvent(MotionEvent event) {}
}
我想在片段中显示模型。这是片段:

public class VisualizationFragment extends Fragment {

private IRajawaliSurface surface;
private Renderer mRenderer;
private final static String TAG = "VFRAG";

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View v = inflater.inflate(R.layout.visualization_frag, container, false);
    mRenderer = new Renderer(getActivity());
    applyRenderer(v);
    return v;
}

protected void applyRenderer(View v) {
    surface = (IRajawaliSurface) v.findViewById(R.id.brush_surface);
    surface.setSurfaceRenderer(mRenderer);
}
}
当我启动应用程序时,我得到的只是一个黑色背景,没有任何模型和以下错误:

 11-25 20:33:19.677 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
 11-25 20:33:19.678 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
 11-25 20:33:19.683 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
 11-25 20:33:19.683 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
 11-25 20:33:19.686 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
 11-25 20:33:19.686 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
 11-25 20:33:19.689 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uModelMatrix returned -1!
 11-25 20:33:19.689 3187-3201/com.example.marti.ibrush E/Rajawali: Getting location of uniform: uTime returned -1!
我还尝试以3ds格式导出模型,然后将其导入blender,然后再次以.obj格式导出。但它也不起作用。 我注意到以下出口规定:
但我在blender中找不到“包含法线”选项,所以我选择了“写入法线”

在您的代码中,我认为您需要在
initScene()下添加灯光和照相机。

在Blender上,在导出之前,我建议确保底层纹理图像文件名是小写的。 导出时,请选择“条带路径”选项


请记住将纹理图像文件复制到应用程序项目下的res\drawable文件夹中。

在代码中,我认为您需要在
initScene()下添加灯光和相机。

在Blender上,在导出之前,我建议确保底层纹理图像文件名是小写的。 导出时,请选择“条带路径”选项

请记住将纹理图像文件复制到应用程序项目下的res\drawable文件夹中