www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Xyvab on April 23, 2010, 08:34:24 pm

Title: How can I serialize a mesh?
Post by: Xyvab on April 23, 2010, 08:34:24 pm
Hello
I saw that into the res.zip example package there are some files with the ".ser" extension.
How can I create some like them?
Thanks in advance,
Xyvab

_______
I'm not english so I'm sorry for any orthographic error  :-\
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on April 23, 2010, 08:50:45 pm
You'll need the desktop version of jPCT for this: http://www.jpct.net/jpct-ae/download/alpha/jpctapi_121a.zip (http://www.jpct.net/jpct-ae/download/alpha/jpctapi_121a.zip)
It contains a DeSerializer class that creates serialized data that jPCT-AE can load at maximum speed.
Title: Re: How can I serialize a mesh?
Post by: Xyvab on April 23, 2010, 11:32:08 pm
Thanks for the fast answer, man !
Now I have another problem: which code have I to type to work the "serialize" method?
I've looked to the API page on DeSerializer, but I didn't understand a lot ... can you help me?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on April 23, 2010, 11:50:18 pm
Opps, forgot to document that class...actually it's pretty easy. All you have to do is this:

Code: [Select]
new DeSerializer().serialize(yourObject3D, someOutputStream, true);

yourObject3D is...your Object3D. Just load it and set it up by assigning textures and calling build() on it. Just like you would do it, if you were about to render it. someOutputStream is most likely a FileOutputStream, reduced can always be true if you serialize for jPCT-AE only.
Textures aren't serialized, but their names are. So if you set up and serialize your object in desktop jPCT with two texture assigned called "hurz" and "gurz", just make sure that your Android version adds textures with the same names "hurz" and "gurz" to the TextureManager prior to loading the serialized object.
Title: Re: How can I serialize a mesh?
Post by: Xyvab on April 24, 2010, 02:40:08 pm
Thanks again for the fast answer  ;D
Now, I wrote this:
new DeSerializer().serialize(Loader.load3DS("C:/file.3ds", 1), new FileOutputStream("C:/file.ser"), true);

but it gives this error:
"The method serialize(Object3D, OutputStream, boolean) in the type DeSerializer is not applicable for the arguments (Object3D[], FileOutputStream, boolean)"

How can I fix it?

P.S.:
I imported these packages:
import java.io.FileOutputStream;
import java.io.OutputStream;

import com.threed.jpct.DeSerializer;
import com.threed.jpct.Loader;
import com.threed.jpct.Object3D;
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on April 24, 2010, 03:37:06 pm
The 3ds loader returns an array of Object3Ds, not a single one. There a mergeAll-method in Object3D that you use to combine them or you serialize them as single objects. However, its not the best idea to serialize what comes right from the Loader. Its better to call build() on each object before serializing it because that reduces setup time on Android.
Title: Re: How can I serialize a mesh?
Post by: Xyvab on April 25, 2010, 10:49:11 am
Thanks a LOT !!
Now it works !!!
Title: Re: How can I serialize a mesh?
Post by: pritom057 on July 06, 2010, 11:27:58 am
hi EgonOlsen

I am not getting you...can you please explain it or show me some code which you are talking about
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on July 06, 2010, 09:03:06 pm
You have to use the desktop version of jPCT to serialize an Object3D. Unfortunatly, there's no tool present ATM that eases this serialization task, so it's up to you to code some small application that does it.

These are the steps to follow:

Note that textures themselves are not part of the file, but their names are. I.e. if you assign textures with the same names to the TextureManager on Android as you do on desktop jPCT before loading the serialized object, jPCT-AE will automagically assign them to your loaded object.
Title: Re: How can I serialize a mesh?
Post by: pritom057 on July 07, 2010, 11:28:34 am
got it man thanks
Title: Re: How can I serialize a mesh?
Post by: pritom057 on July 11, 2010, 03:54:21 pm
Sir I fave got another problem.....and that is how do i add texture into Serialize file
I have done flowing.....whats wrong with this
Code: [Select]
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication2;

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;

/**
 *
 * @author sarwar.siddique
 */
public class Main {

    /**
     * @param args the command line arguments
     */


    public static void main(String[] args) throws FileNotFoundException {
        // TODO code application logic here
        Object3D grass = null;
        TextureManager.getInstance().flush();


TextureManager tm = TextureManager.getInstance();
Texture grass2 = new Texture("C:/Worksapce/SaveMe/res/raw/f15e.jpg");
        DeSerializer de;
        grass = Loader.load3DS("C:/Worksapce/SaveMe/res/raw/f15.3ds",5)[0];
        tm.addTexture("grass2", grass2);
        grass.setTexture("grass2");
        //grass.setAdditionalColor(Color.yellow);
        grass.build();
        de = new DeSerializer();
        de.serialize(grass, new FileOutputStream("C:/Worksapce/SaveMe/res/raw/sf15.ser"), true);
                //.serialize(Loader.load3DS("C:/file.3ds", 1), new FileOutputStream("C:/file.ser"), true);
    }

}

Thanks In Advance
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on July 11, 2010, 09:48:21 pm
Nothing is wrong with that at first glance. But you are just showing the serializing code, not how you load it. And you are not telling what the actual problem is. Regarding textures, i can only repeat myself from the post above:

Quote
Note that textures themselves are not part of the file, but their names are. I.e. if you assign textures with the same names to the TextureManager on Android as you do on desktop jPCT before loading the serialized object, jPCT-AE will automagically assign them to your loaded object.
Title: Re: How can I serialize a mesh?
Post by: pritom057 on July 15, 2010, 07:40:01 am
Sir
I am not rendering the texture over the object..
after serialize I am getting only white object...
And I load the object as you show in your demo code.....

I just want to know how to texture over the object..

thanks in advance
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on July 15, 2010, 01:44:29 pm
Object3D.setTexture(...)...
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 03, 2011, 11:26:29 am
i have downloaded the "jpctapi" but i don't know what i have to open to serialize an object.
so what is the procedure?
how do you use the "jpct api"? with "eclipse jee"? because eclipse don't find a project in "jpctapi"
where do you write this sentence "new DeSerializer().serialize(yourObject3D, someOutputStream, true);"??
thank you
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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...
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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"
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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);
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen 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...
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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)
"
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 05, 2011, 10:37:57 am
Quote
ERROR: Can't merge null!
...just don't merge null.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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);
            
Title: Re: How can I serialize a mesh?
Post by: nico_r_a 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));
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 08, 2011, 12:19:54 pm
You haven't read my mail, have you?
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 08, 2011, 02:02:39 pm
yes i have read your mail, thanks
sorry but i don't know how i serialize the file, when i delete  [ 0 ], i have an error in my line?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 08, 2011, 02:21:51 pm
How about reading the docs? http://www.jpct.net/doc/com/threed/jpct/DeSerializer.html (http://www.jpct.net/doc/com/threed/jpct/DeSerializer.html)
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 08, 2011, 02:37:04 pm
Code: [Select]
    public static void main(String[ ] args)  throws FileNotFoundException {
        Object3D[] sc = null;


        DeSerializer de;
        sc = Loader.load3DS("C:/workspace/file/res/raw/sc.3ds",20);

        //sc.build;
        de = new DeSerializer();
        de.serializeArray(sc, new FileOutputStream("C:/workspace/file/res/raw/sersc.ser"), true);
    }
}
i write this, i have modified the serialize by the serializeArray, but i have still an object which is loaded
i am sorry, but i read and i read your doc deserialize, but i have big problem to understand (in english it's not easy to me so i ask you lots of questions)

so how do i serialize a file (lots of object) please? ? ?


in more when i try to compil my program  java with texture to create a file ser
the console says me :
"[ Mon Aug 08 17:23:19 CEST 2011 ] - ERROR: Tried to set an undefined texture as default!"
while i have given the good name associated between the object and the texture

Code: [Select]
    TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();
   Texture textureai= new Texture("C:/workspace/file/res/drawable/ai.jpg");
        tm.addTexture("ai", textureai);
        scene.setTexture("textureai");

it's correct, is'nt it??
and how do i serialize a file (lots of object) please? ? ? ?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 08, 2011, 07:43:08 pm
Your serialization code is fine. If it doesn't load it correctly, your loading code is wrong. Make sure to use the array-version of the loader-method too.

Wrong:
Code: [Select]
   tm.addTexture("ai", textureai);
   scene.setTexture("textureai");


Right:
Code: [Select]
 
   tm.addTexture("ai", textureai);
   scene.setTexture("ai");

Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 08, 2011, 11:21:47 pm
thank you for the reply by the mail. I listen your advice. But you have said i load the object in the array and i work with but i don't see.
Because in my file .3ds i have 80  objects how do i to load all this object in minimum of line code?
because i don't ssee how do i load the 3ds with all this object same after i have read your doc on the deserialize.
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 08, 2011, 11:28:11 pm
load3DS() already loads all objects from the file. serializeArray() serializes all these objects and Loader.loadSerializedObjectArray() loads them all into jPCT-AE. If they still doesn't appear in your app, you are doing something wrong with the loaded objects that i can't possibly guess.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 09, 2011, 09:39:32 am
so in my jpct (to create the ser)
i have writen this
Code: [Select]

Object3D[] sce = null;

TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();

Texture textureai = new Texture("C:/workspace/file/res/drawable/ai.jpg");


 DeSerializer de;
       
       
        sce = Loader.load3DS("C:/workspace/file/res/raw/sce.3ds",20);

        tm.addTexture("ai", textureai);
        sce.setTexture("ai");

  //  sce.build();


 de = new DeSerializer();
       
       
        de.serializeArray(sce, new FileOutputStream("C:/workspace/file/res/raw/sersc.ser"), true);



When i have changed the "serialize" by the "serializeArray", eclipse has asked to change "object3d" by "object3d[]" and since i have lots of mistakes
but i have an error on the line         
sce.setTexture("ai");
sce.build()


and i writte this in my application android

Code: [Select]
Scee = Loader.loadSerializedObjectArray(getResources().openRawResource(R.raw.sersc));
and i have the same problem that in my jpct i have changed the
Scee = Loader.loadSerializedObject(getResources().openRawResource(R.raw.sersc));
by
Scee = Loader.loadSerializedObjectArray(getResources().openRawResource(R.raw.sersc));

So eclipse says me that i must to change the objkect 3d in object3[] what create lots of mistakes
example : world.addObject(Scee);


Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 09, 2011, 09:48:47 am
Sorry, but the only real advise i can give you is: Learn how to code! You obviously haven't much clue about what you are doing. That's not a problem, everybody has to start somewhere...but 3D graphics doesn't seem to be the right project for a beginner to me.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 09, 2011, 03:08:37 pm
I have changed my code, but now i have "n" file ser (about 30ko each) with "n" the number of object in my 3ds.
It' better than before, but the problem is to load each ser.
i have tried to use the array but there is an error then i use it,
the code in my jpct to create ser is this

Code: [Select]
        for(int i = 0; i < scee.length; i++) {
             System.out.println("serializing object: " + i + "/" + scee.length);
            scee[i].build();
            de.serialize(scee[i], new FileOutputStream("C:/workspace/file/res/raw/serscee"+i+".ser"), true);
        }
How do i do to not load  each ser one per one, i try , i try to load by array but i don't arrive, there is possibility that you help me same if i am bad in java
because i would like to introduce the "de.serializearray" but it's incompatible with the "scee[ i ]"


and i always have the problem with the texture because like my scee is in "object3D[]", this line of code is specified with error in eclipse, so i have written this
Code: [Select]
tm.addTexture("ai", textureai);
        scee[i].setTexture("ai");

but now in the console after the compilation, there are written to each texture

[ Tue Aug 09 ] - ERROR: A texture with the name 'ai' has been declared twice!



Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 09, 2011, 08:53:41 pm
Just serialize all objects in one array like you did before. Then load the whole array at once from one file. Then iterator over the array and do everything that you would normally do on one object only on each. Like (pseudo-code):

On the desktop:
Code: [Select]
Object3D[] objs=Loader.load3DS(....);

for (Object3D obj:objs) {
     obj.build();
}

new DeSerializer().serializeArray(objs....);

On Android:

Code: [Select]
tm.addTexture("ai", textureai);
...

Object3D objs=Loader.loadSerializedObjectArray(....);
world.addObjects(objs);

There's no need serialize each object on its own. There's also no need to assign the textures by using setTexture()...the Loader will do this based on the names (as i've explained multiple times). Just make sure that you've added the textures to the manager BEFORE loading the serialized model.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 10:46:52 am
thank you very much  ;D ;D ;D ;D ;D ;D ;D ;D
 i have loaded the 3ds thantks to file ser. but i have loaded without texture
now the scene load in 1minute, it's great
i am going to try to load with texture now, thank you
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 11:58:30 am
i don't arrive to load the texture, actually i think to load in my code several texture but the application load only one texture on the all object of the scene.
in my jpct to create the ser i write nothing on the texture, don't you?*
in my application android, (my textures are 256*256 or 512*512) it's not a problem?

Code: [Select]
TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();

Texture textureai1 = new Texture(getResources().getDrawable(R.drawable.ai1));
Texture textureai2 = new Texture(getResources().getDrawable(R.drawable.ai2));

tm.addTexture("ai1", textureai1);
tm.addTexture("ai2", textureai2);

    Object3D[] scee = Loader.loadSerializedObjectArray(getResources().openRawResource(R.raw.sersce));

world.addObjects(scee);

for(int i = 0; i < scee.length; i++) {
            System.out.println("serializing object: " + i + "/" + scee.length);

SimpleVector Sv = new SimpleVector();
Sv.x = 0;
Sv.y = 0;
Sv.z = 0;
scee[i].strip();
scee[i].build();




so i have tried this second code too, because i have said me that the size of texture is too much, but it's more long and sometimes there is a bug (i have to load 32 textures)

Code: [Select]
TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();

     Texture textureai1 = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ai1)), 256, 256));
     Texture textureai2 = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ai2)), 256, 256));
     
textureai1.compress();
textureai2.compress();

tm.addTexture("ai1", textureai1);
tm.addTexture("ai2", textureai2);

    Object3D[] scee = Loader.loadSerializedObjectArray(getResources().openRawResource(R.raw.sersce));

world.addObjects(scee);

for(int i = 0; i < scee.length; i++) {
            System.out.println("serializing object: " + i + "/" + scee.length);

SimpleVector Sv = new SimpleVector();
Sv.x = 0;
Sv.y = 0;
Sv.z = 0;
scee[i].strip();
scee[i].build();



Do you have a solution??
and another question, if i put color on object in my 3ds ,and i put a spotlight (near camera) in my 3ds or with the application android, will i have the shape effect on the object??
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 10, 2011, 12:38:37 pm
I'm not sure what you are tyring to say here...the object has no texture? Or the it has only one texture? Or you don't know how to load 32 textures? It's actually really simple and i tried to explain it multiple times before: The names in the file and the names in the manager have to match exactly. And the textures have to be added to the manager BEFORE loading the mesh. This is needed for deserializing them only, it's not needed for serializing. On the desktop (i.e. where you serialize your object), you can check for all the names that the Android version has to know by calling getNames(); on your instance of the TextureManager. Do these names match your names in the Android code?

Or do you have some setTexture() left in your code from former versions? If so, remove it.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 01:09:52 pm
actually, on the emulator i have only one texture which is load on all objects. whereas i should have 32 textures loaded on each object with each object a texture different.
and is there shape effect with the jpct if i put a spotlight in my 3ds or in the code android ?
so the second code is not good? i should rather use a texture 512*512
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 10, 2011, 01:33:52 pm
I've no idea what you mean with shape effect... ???
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 01:42:10 pm
shadow effect, (sorry i have done a mistake of traduction)
do you have an idea about the texture when you see my code??
because my code correspond at your explications
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 10, 2011, 02:25:15 pm
Shading yes, real shadows...no.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 02:53:01 pm
ok, but do you have an idea for my code because i always have nothing with my texture??
and if i load the texture in my 3ds, do i keep the texture after when i load in my application android without used (the texture manager)?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 10, 2011, 04:30:10 pm
Sorry, but i don't have the slightest idea of what you are trying to say... ???
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 10, 2011, 04:53:51 pm
actually, i am going to give you an example to explain my problem
i have three textures :
1.jpg
2.jpg
3.jpg

And i have 3 objects in my scene 3ds when i load on the emulator
on the first object i see 1.jpg
on the second object i see 1.jpg
on the third object i see 1.jpg

whereas i should have when i load
on the first object i should see 1.jpg
on the second object i should see 2.jpg
on the third object i should see 3.jpg
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 10, 2011, 08:34:07 pm
I'm not going to repeat myself about how texture assignment works. If your model has the correct textures assigned, you are doing it wrong. It's most likely, that you do an explicit setTexture() either in the serialization code or in the Android code.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 11, 2011, 02:29:57 am
but if i write this in my application
Code: [Select]
TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();

Texture textureai1 = new Texture(getResources().getDrawable(R.drawable.ai1));
Texture textureai2 = new Texture(getResources().getDrawable(R.drawable.ai2));

tm.addTexture("ai1", textureai1);
tm.addTexture("ai2", textureai2);
i have loaded nothing texture in my scene, nothing
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 11, 2011, 07:36:45 am
Yes, and that's all fine...but it doesn't say anything about your problem. Without code, logs (at least from the serialization process) or the model, i can't help here. CHECK THE NAMES! ARE THEY REALLY ai1 AND ai2 IN THAT 3DS??
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 11, 2011, 09:22:20 am
but when i looks the console while the compilation of jpct (to create a file ser)
i see that
ai1_jPCT0
ai2_jPCT1
do you use this name may be?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 11, 2011, 10:47:14 am
These are the names of the objects, not of the textures.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 11, 2011, 11:05:44 am
and is there a topic who is good to explain how we change between the camera when we click on a part (precise) of the screen?
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 11, 2011, 12:26:02 pm
 ???
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 11, 2011, 03:18:45 pm
i have found your code in the topic "How to rotate and move 3D object in world space by 2D mouse coordinaes?"
but how do i add this library in android?
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
Title: Re: How can I serialize a mesh?
Post by: EgonOlsen on August 11, 2011, 03:40:34 pm
You don't! It's for desktop Java. You have to use the corresponding Android events instead like touch events.
Title: Re: How can I serialize a mesh?
Post by: nico_r_a on August 11, 2011, 03:46:24 pm
so with the touchevents i can slide