jPCT-AE - a 3d engine for Android > Support
jPCT-AE wiki
redfalcon:
I thought I share my simple implementation of the serializer (for *.obj and *.mtl files) for the Android version, might be useful for others. If you don't mind, you can add it to the wiki.
I expected worse when I read that "It's a bit painful to use right now" ;) It has no special error checking etc., but its usable and should be quickly adaptable for other filetypes.
--- Code: ---import java.io.FileOutputStream;
import com.threed.jpct.DeSerializer;
import com.threed.jpct.Loader;
import com.threed.jpct.Object3D;
public class Serializer {
//Adjust the paths as necessary
private static final String INPUT_MODEL = "c:/myobj.obj";
private static final String INPUT_MATERIAL = "c:/mymtl.mtl";
private static final String OUTPUT_FILE = "c:/serialized.obj";
public static void main(String[] args) {
Object3D[] objs = null;
objs = Loader.loadOBJ(INPUT_MODEL, INPUT_MATERIAL, 1);
for (Object3D o : objs)
o.build();
DeSerializer ds = new DeSerializer();
try {
FileOutputStream baos = new FileOutputStream(OUTPUT_FILE);
ds.serializeArray(objs, baos, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
--- End code ---
Load in jpct-ae with:
--- Code: ---/...
Object3D[] serializedObject = null;
serializedObject = Loader.loadSerializedObjectArray(res.openRawResource(R.raw.INSERT_FILE_NAME));
/...
--- End code ---
yindroid:
I noticed that there is no such class as DeSerializer in jPCT-AE (1.24)...
EgonOlsen:
No, it hasn't. That's because it makes no sense to serialize objects on Android directly. The idea is to serialize them using the desktop version and then load them via http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Loader.html#loadSerializedObject(java.io.InputStream)
OneManSitting:
Thanks for making such a great wiki, and i would love to take part in it.
EgonOlsen:
I'll create an account for you when i'm back home...in a week or so.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version