Parsing a .obj Model from a Rajawali SD Card

I am working with the Rajawali 3D Framework and trying to download .obj files from an SDcard. I can download and analyze the obj file when I put these files (.obj, .mtl, texture.png (drawable folder)) in the source folder, but when I try to parse it on the SD card, it says:

[org.rajawali3d.materials.Material] Could not compile fragmentshader: Shader log: Fragment shader compilation failed. 

Here is my code for downloading .obj files from Sdcard:

 private Object3D Object; LoaderOBJ objParser = new LoaderOBJ(this,"Load/1c_obj"); try { objParser.parse(); Object = objParser.getParsedObject(); getCurrentScene().addChild(Object); } catch (ParsingException e) { e.printStackTrace(); } 

Logcat:

  D/Rajawali﹕ Parsing: /storage/emulated/0/Load/1c_obj D/LoaderOBJ﹕ Found Material Lib: 1c_mtl D/LoaderOBJ$MaterialLib﹕ Parsing material: Texture0 D/LoaderOBJ$MaterialLib﹕ Parsing material: Texture1 9578-9612/com.example.loadobj D/LoadModelFragment$LoadModelRenderer﹕ startRendering() E/Rajawali﹕ [org.rajawali3d.materials.Material] Could not compile fragment shader: 9578-9612/com.example.loadobj E/Rajawali﹕ Shader log: Fragment shader compilation failed. ERROR: 0:13: '.' : Syntax error: syntax error ERROR: 1 compilation errors. No code generated. 

Link: https://plus.google.com/111465395343320783064/posts/g19G56J3iGW

+5
source share
1 answer

If you can read obj files from your source folder, which

 LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(),mTextureManager, R.raw.camero_obj); 

and not from your SD card, you should make the following changes to your files: In your obj file, which should be saved as _obj in your SD card (therefore for _jpg and _mtl in the same place)

in your case:

 mtllib 1c_mtl v -0.7526 14.5146 0.171602 v -0.7922 14.5792 0.075402 v -0.4998 14.7082 0.457802 v -0.5409 14.7486 0.393002 v -0.5358 14.5862 0.414902 

Following the mtl file

 newmtl Texture0 illum 0 Kd 0.7 0.7 0.7 Ks 0 0 0 Ka 0 0 0 newmtl Texture1 illum 0 Kd 0.7 0.7 0.7 Ks 0 0 0 Ka 0 0 0 map_Kd parse_jpg 

Remember to rename your jpg texture to _jpg Where do you get the error message:

ERROR: 0:13: '.': Syntax error: syntax error

After that, execute your code to parse:

 private Object3D Object; LoaderOBJ objParser = new LoaderOBJ(this,"Load/1c_obj"); try { objParser.parse(); Object = objParser.getParsedObject(); getCurrentScene().addChild(Object); } catch (ParsingException e) { e.printStackTrace(); } 

And the error you get

E / Rajawali: [org.rajawali3d.materials.Material] Failed to compile fragment shader:

Unable to read your texture file from your material file. To do this, you can make the above changes in your material file.

For more information on custom materials or the vertex shader, follow the Rajawail document and sample

+7
source

All Articles