Hello, Sir:
I find a model make with blender and export it with obj file format
but I can not find any animation info in it, and I find this page: http://stackoverflow.com/questions/757145/do-wavefront-obj-files-support-animation
I try to export with animation checked, but I got 30 obj & mtl files(total 60)
How can I try animation with obj file? any one familliar with blender & obj file format? many thanks!
Chinese Spring Festival is arriving, My reply will not very often
I will check this time by time...
I use this way to add animation http://www.jpct.net/forum2/index.php/topic,2559.msg18872.html#msg18872
but when addkeyframe, I got error: java.lang.RuntimeException: [ 1420062253543 ] - ERROR: Bounding box missing in this mesh!
it is the problem with model self? how can I avoid it?
Use this to calculate a bounding box: http://www.jpct.net/doc/com/threed/jpct/Object3D.html#calcBoundingBox() (http://www.jpct.net/doc/com/threed/jpct/Object3D.html#calcBoundingBox()).
Anyway, OBJ indeed doesn't support animations and neither does 3ds. jPCT by itself eithers loads MD2 (old keyframe based format) or you have to import single keyframes (it might be best to do this on the desktop and serialize the result for Android). Another option is to use the Bones API in addition, which adds skeletal animation support to jPCT.
before I add mesh as keyframes, I call
obj.calcNormals();
obj.calcBoundingBox();
obj.build();
as you suggestion, but the animation is empty, because the bound box is missing from the mesh
My total source as below:
private void loadWalk(Animation walk) {
walk.createSubSequence("walk");
for (int i = 10; i <= 30; i++) {// I got 30 obj & mtl files, I use 20 to make up a animation
try {
InputStream objStream = m_context.getAssets().open(
"sara3d_2015_0000" + i + ".obj");
InputStream mtlStream = m_context.getAssets().open(
"sara3d_2015_0000" + i + ".mtl");
Object3D obj = Loader.loadOBJ(objStream, mtlStream, 1)[0];
obj.setCenter(SimpleVector.ORIGIN);
obj.calcNormals();
obj.calcBoundingBox();
obj.build();
Object3D tmp = new Object3D(0);
tmp = Object3D.mergeObjects(tmp, obj);
tmp.strip();
walk.addKeyFrame(tmp.getMesh()); // can I use objct3D from loader directly?
objStream.close();
mtlStream.close();
} catch (Exception e) {
String err = e.toString();// I always here...
err += "!";
}
}
}
This part
Object3D tmp = new Object3D(0);
tmp = Object3D.mergeObjects(tmp, obj);
tmp.strip();
makes no sense. Just add the mesh directly from the obj instance to the animation. What is this part supposed to do?
now I find the root cause:
the model has no bounding box, so when I load it first, no bounding box
then I load model again, & add keyframe to make animation, if I NOT caleBounding box, the mesh can not add to keyframe
if I caleBounding box, after cale, the mesh is diff from orgin one
so I caleBounding box when I first load the model, the problem solved
Another question: the model has 3-4K faces, 30 frame for walk, the loading speed is very slow, how can I enhance it?
Quote from: riscbus on March 06, 2015, 12:10:40 PM
Another question: the model has 3-4K faces, 30 frame for walk, the loading speed is very slow, how can I enhance it?
Load the models and animation with the desktop version, serialize them to disk (http://www.jpct.net/doc/com/threed/jpct/DeSerializer.html (http://www.jpct.net/doc/com/threed/jpct/DeSerializer.html)) and load that file on Android (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Loader.html#loadSerializedObject(java.io.InputStream) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Loader.html#loadSerializedObject(java.io.InputStream))). It's much faster this way (http://www.jpct.net/wiki/index.php/Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects (http://www.jpct.net/wiki/index.php/Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects)).