How can I serialize a mesh?

Started by Xyvab, April 23, 2010, 08:34:24 PM

Previous topic - Next topic

EgonOlsen

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.

nico_r_a

#16
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

EgonOlsen

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...

nico_r_a

#18
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"

EgonOlsen

Your jPCT-AE seems to be outdated. Try 1.23 or the latest alpha of 1.24 instead.

nico_r_a

#20
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);

EgonOlsen

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.

nico_r_a

yes it's done , i have uploaded the library with the new version alpha. but i have still the same problem

EgonOlsen

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.

nico_r_a

#24
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

EgonOlsen

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...

nico_r_a

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)
"

EgonOlsen

QuoteERROR: Can't merge null!
...just don't merge null.

nico_r_a

#28
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);
            

nico_r_a

#29
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

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));