Load 3DS with texture

Started by bayee, September 27, 2010, 11:29:02 AM

Previous topic - Next topic

bayee

Hi,

I have download a 3DS file from the net and I try to load it into AE.

I have use the DeSerializer from PC. Here is my code:


                Config.oldStyle3DSLoader = true;
                Object3D[] obj = Loader.load3DS(args[0], 1f);
                System.out.println("Object loaded!");
                DeSerializer ds = new DeSerializer();
                for(int i = 0; i < obj.length; i++) {
                        System.out.println("serializing object: " + i + "/" + obj.length);
                        obj[i].build();
                        ds.serialize(obj[i], new FileOutputStream("out"+i+".ser"), true);
                }



When I run the above program, I got this in console (my 3DS file is called 23moon.3DS)


Loading file 23moon.3DS
File 23moon.3DS loaded...243558 bytes
Processing new material Material #1!
Texture named MOONMAP.JPG added to TextureManager!
Processing object from 3DS-file: Sphere01
Object 'Omni04_jPCT-2' created using 9800 polygons and 4902 vertices.
Object loaded!
serializing object: 0/1



Now I have out0.ser which I can load into AE, but I am not sure how I can apply texture to it.

Please advice. Thx.




JKumar

HI,

        Follow the steps below.

TextureManager.getInstance().addTexture("<Name of texture>", new Texture(getResources().openRawResource(R.raw.mytexture)));


model.setTexture("<Name of texture>);
         

bayee

#2
 :-\
Quote from: JKumar on September 27, 2010, 11:59:36 AM
HI,

       Follow the steps below.

TextureManager.getInstance().addTexture("<Name of texture>", new Texture(getResources().openRawResource(R.raw.mytexture)));


model.setTexture("<Name of texture>);
         

thx for the quick reply, but where do i get the mytexture file ? it is in the 3ds file right ? sorry if this sound stupid, but I am really new with all these...

JKumar

Hi,

          Its an image file which u might have as an additional with the 3ds.You can put the file in any of the resource folders and can access the same using the above code.


bayee

Quote from: JKumar on September 28, 2010, 09:46:19 AM
Hi,

          Its an image file which u might have as an additional with the 3ds.You can put the file in any of the resource folders and can access the same using the above code.



hi JKumar, thx once again... does this mean the texture image file is not embed in the 3ds file which i download from the net ? but most of the free 3ds file in the net does not come with an image texture file, though many of their preview have texture....

kamax

I have the same "problem", i have download a free palm tree  (.3ds) and i have just this file.
When i open it with blender i can see it colored but with the script in this topic to transform it into .ser file i have just .ser file.
The palm tree is white in the game engine.

Any help ?

EgonOlsen

That's a weakness of the serialization idea: jPCT loads the diffuse color information but doesn't store it in the model. It just creates colored textures from them and add them to the TextureManager and the model. In the serialization step, the actual coloring information is gone. However, the names of the textures created will be serialized. One (rather clumsy) way, is to get the list of texture names from the TextureManager after loading the model and before serializing it and creating texture with the same names in jPCT-AE "by hand" before loading the model. That will give you the correct names...the only problem left are the actual color values. But luckily, the names contain them. You can simply derive them from the names...or create the names from the values. As said, this is clumsy, but it's the only way to get the coloring information back for deserialized models.