Obj file format does NOT contain animation?

Started by riscbus, February 16, 2015, 06:56:23 AM

Previous topic - Next topic

riscbus

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!

riscbus

Chinese Spring Festival is arriving, My reply will not very often

I will check this time by time...

riscbus

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?

EgonOlsen

Use this to calculate a bounding box: 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.

riscbus

#4
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 += "!";
         }
      }
   }

EgonOlsen

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?

riscbus

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?

EgonOlsen