jPCT-AE加载obj文件
分类:Uncategorized
阅读 (1,158)
12月 172021
将obj和mtl文件放在Android项目中的src/main/assets目录下,在java代码中使用如下代码加载3D模型文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
private Object3D demoObj; private void loadObject() { InputStream mtlStream = null; InputStream objStream = null; try { objStream = getResources().getAssets().open("jeep.obj"); mtlStream = getResources().getAssets().open("jeep.mtl"); } catch (IOException e) { e.printStackTrace(); } Object3D[] demoobjs; demoobjs = Loader.loadOBJ(objStream, mtlStream, 0.7f); demoObj = new Object3D(0); for(Object3D obj3d: demoobjs){ demoObj = Object3D.mergeObjects(demoObj, obj3d); } // demoObj.rotateX(3f); // demoObj.rotateY(-1.5f); // demoObj.rotateZ(0.12f); // demoObj.rotateX(-0.1f); // demoObj.translate(0.8f, 0, -8); } |
Sorry, the comment form is closed at this time.