我想在使用Rajawali框架的android應用程序中顯示3d對象。我使用Autodesk 3DS MAX創建了一個3D對象。 (我已經閱讀過推薦使用攪拌器的文章,但是我下載了一個我想用的模型和它的.3ds文件)在Android中使用Rajawali不顯示.obj
我把.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格式,然後將其導入攪拌機,然後再以.obj格式導出。但它也不起作用。 我已經注意到以下出口法規: https://github.com/Rajawali/Rajawali/wiki/Tutorial-17-Importing-.Obj-Files 但我找不到「攪拌器中的」包括法線「選項,所以我選擇了」寫入法線「。