Author Topic: How can I serialize a mesh?  (Read 28379 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #15 on: August 03, 2011, 03:46:07 pm »
It's a jar...exactly like the one that is included in the jPCT-AE zip. You create a plain Java project in Eclipse, add the jpct.jar to the build path, create a new class with a main-method, load your model in the mani-method, call build() on it and use the DeSerializer to write it back to disk. You might want to zip the resulting file afterwards and load it via a ZipInputStream in your Android App.

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #16 on: August 03, 2011, 04:03:13 pm »
sorry but i don't arrive to realize. Because i am not a good person with eclipse.
so i do " create java project", and i after i have a library "jre system library" and a folder "src".
after i create a class, but what is the "mainmethod"??
could you give more detail to realisation ?
thank you very much
« Last Edit: August 03, 2011, 04:25:57 pm by nico_r_a »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #17 on: August 03, 2011, 08:10:31 pm »
Are you serious? You are programming in Java and have no clue about the main-method  :o I strongly suggest to do a basic "programming in Java"-tutorial before continuing with anything else...

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #18 on: August 04, 2011, 10:40:54 am »
ok, it s great i have create a file ser, thanks for the advice java tutorial
but in my project android i write this it's all??
scene = Loader.loadSerializedObject(res.openRawResource(R.raw.serscene));

i don't write this??
   private Object loadModel(InputStream filename, InputStream mtl, float scale) {
         Object3D[] model = Loader.load3DS(filename, scale);

because when i load the ser in the android with "the scene = loader.loadserial......."
In the logcat i have this
"08-04 08:57:05.143: INFO/jPCT-AE(454): [ 1312448225150 ] - ERROR: Unsupported version: 2
08-04 08:57:05.174: INFO/jPCT-AE(454): [ 1312448225175 ] - ERROR: Can't deserialize object: [ 1312448225150 ] - ERROR: Unsupported version: 2"
« Last Edit: August 04, 2011, 10:58:04 am by nico_r_a »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #19 on: August 04, 2011, 11:31:45 am »
Your jPCT-AE seems to be outdated. Try 1.23 or the latest alpha of 1.24 instead.

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #20 on: August 04, 2011, 12:10:58 pm »
but i have a problem same with the new version
what sould i write ?

if i write only this and i place the ser in the rawx it s good??

private Object loadModel(InputStream filename, InputStream mtl, float scale) {
//Object3D[] model = Loader.load3DS(filename, scale);
scene = Loader.loadSerializedObject(getResources().openRawResource(R.raw.serscene));
// Object3D[] model = Loader.loadOBJ(filename, mtl, scale);
« Last Edit: August 04, 2011, 12:12:30 pm by nico_r_a »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #21 on: August 04, 2011, 12:19:33 pm »
If you are using the example projects directly, update the jpct-ae.jar in their lib-directory with the one from the lib-directory that is located directly in the zip. IIRC, i forgot to update those jars in the 1.23 release.

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #22 on: August 04, 2011, 01:52:58 pm »
yes it's done , i have uploaded the library with the new version alpha. but i have still the same problem

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #23 on: August 04, 2011, 02:22:15 pm »
Then you did something wrong. The versions since 1.23 support file format version 2. You must be using an old lib. You can check the version number in Config.

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #24 on: August 04, 2011, 02:57:45 pm »
but some texture are large 1024*1024, there are not problem with this dimension?

scene = Loader.load3DS("C:/workspace/file4/res/raw/scene.3ds", 300)[0];

the "300" and the "0" mean what???
thanks
« Last Edit: August 04, 2011, 05:02:42 pm by nico_r_a »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #25 on: August 04, 2011, 05:41:36 pm »
Please...read the docs. It's not my mission to explain everything that i already did in the docs. About the texture size: 1024*1024 is too large for a mobile device. It will work, but it consumes too much memory. 1024*1024*4=4mb per texture plus the uploaded version to the gpu -> 8mb plus mip maps -> ~12mb...

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #26 on: August 05, 2011, 10:20:43 am »
i have send a message
but i have another problem when i load my 3ds file without used the serialization, the application is not load in the emulator and in my logcat
i have this
"
08-05 08:20:55.532: INFO/jPCT-AE(426): Object 'Car2_jPCT40' created using 204 polygons and 104 vertices.
08-05 08:20:55.532: INFO/jPCT-AE(426): Processing object from 3DS-file: Car2
08-05 08:20:55.572: INFO/jPCT-AE(426): Object 'Car1_jPCT41' created using 204 polygons and 104 vertices.
08-05 08:20:55.585: INFO/jPCT-AE(426): [ 1312532455586 ] - ERROR: Can't merge null!
08-05 08:20:55.612: WARN/dalvikvm(426): threadid=9: thread exiting with uncaught exception (group=0x40014760)
08-05 08:20:55.612: ERROR/AndroidRuntime(426): FATAL EXCEPTION: GLThread 10
08-05 08:20:55.612: ERROR/AndroidRuntime(426): java.lang.RuntimeException: [ 1312532455586 ] - ERROR: Can't merge null!
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at com.threed.jpct.Logger.log(Logger.java:189)
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at com.threed.jpct.Object3D.mergeObjects(Object3D.java:476)
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at com.mm.file4$MyRenderer.loadModel(Ovip.java:499)
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at com.mm.file4$MyRenderer.onSurfaceChanged(Ovip.java:228)
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1422)
08-05 08:20:55.612: ERROR/AndroidRuntime(426):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1184)
"

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I serialize a mesh?
« Reply #27 on: August 05, 2011, 10:37:57 am »
Quote
ERROR: Can't merge null!
...just don't merge null.

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #28 on: August 05, 2011, 11:03:24 am »
ok, i have resolved the problem with the merge.
but my scene is still blue (like the sky), this is the light??
"
if (master == null) {

            world = new World();
            world.setAmbientLight(250, 250, 250);

            sun = new Light(world);
            sun.setIntensity(20, 20, 20);
            
« Last Edit: August 05, 2011, 11:16:06 am by nico_r_a »

Offline nico_r_a

  • byte
  • *
  • Posts: 48
    • View Profile
Re: How can I serialize a mesh?
« Reply #29 on: August 08, 2011, 11:12:23 am »
i have loaded to try your file hose_poser.obj (convert in 3ds), and i see only the "hip:2 hip" in the emulator android. (the hip:2 hip is white and the rest is blue)
why? i write this in the application java to create the ser
Code: [Select]
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.threed.jpct.DeSerializer;
import com.threed.jpct.Loader;
import com.threed.jpct.Object3D;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
//import java.awt.Color;

public class Main {


    public static void main(String[ ] args)  throws FileNotFoundException {
        Object3D hose_poser = null;
 
        DeSerializer de;
       hose_poser = Loader.load3DS("C:/workspace/file/res/raw/hose_poser3ds",20)[0];
       hose_poser.build();
        de = new DeSerializer();
        de.serialize(hose_poser, new FileOutputStream("C:/workspace/file/res/raw/serhose_poser.ser"), true);
               
    }
}


May be it 's in my application android??
should i write in my code android something in rapport with the loading of all the object in ser, because i have writen only this

Hoseposer = Loader.loadSerializedObject(getResources().openRawResource(R.raw.serhose_poser));
« Last Edit: August 08, 2011, 11:25:32 am by nico_r_a »