public class ObjParser extends AParser
The options that should be checked when exporting from blender are:
The files should be written to your “res/raw” folder in your ADT project. Usually you’ll get errors in the console when you do this. The Android SDK ignores file extensions so it’ll regard the .obj and .mtl files as duplicates. The way to fix this is to rename the files. For instance: - myobject.obj > myobject_obj - myobject.mtl > myobject_mtl The parser replaces any dots in file names, so this should be picked up automatically by the parser. Path fragments in front of file names (also texture paths) are discarded so you can leave them as is.
The texture file paths in the .mtl files are stripped off periods and path fragments as well. The textures need to be placed in the res/drawable-nodpi folder.
If it still throws errors check if there are any funny characters or unsupported texture formats (like bmp).
Just as a reminder, here’s the code that takes care of the parsing:
ObjParser objParser = new ObjParser(mContext.getResources(), mTextureManager, R.raw.myobject_obj);
objParser.parse();
BaseObject3D mObject = objParser.getParsedObject();
mObject.setLight(mLight);
addChild(mObject);
Constructor and Description |
---|
ObjParser(RajawaliRenderer renderer,
java.lang.String fileOnSDCard) |
ObjParser(Resources resources,
TextureManager textureManager,
int resourceId) |
Modifier and Type | Method and Description |
---|---|
void |
parse() |
getParsedAnimationObject, getParsedObject
public ObjParser(RajawaliRenderer renderer, java.lang.String fileOnSDCard)
public ObjParser(Resources resources, TextureManager textureManager, int resourceId)