Texture Mapping

Started by AGP, August 08, 2006, 07:33:12 PM

Previous topic - Next topic

AGP

My x-wing is being loaded from a 3ds file. Upon loading it, the texture files are listed on the command prompt. Is it supposed to load texture-mapped, or am I supposed to do something else.

The 2-part wings, on Egon's suggestion, were loaded separately, and I've even tried getting the instance to Texture Manager and adding the wings' top texture. The following code is what I tried. Am I doing something wrong? Or am I supposed to call something during the rendering process?

   TextureManager manager = TextureManager.getInstance();
   Texture wingTop = new Texture("./WolfXWing/WINGTOP.JPG");
   manager.addTexture("WINGTOP", wingTop);

EgonOlsen

The texture's name (i.e. the name you give it in the TextureManager) has to match the name that is used in the 3DS-file. That's the name that's being printed out during load. It's best practice to determine the names once and load them before loading the model to save some overhead.

AGP

Do you mean that instead of naming it "WINGTOP" I would have to name it "WINGTOP.JPG?" It worked, now, which I'm taking to mean that the textures have to be added before loading the mesh. Or is there another way? Thanks a lot for all your help so far.

EgonOlsen

If you don't load them before the loading of the model happens, you have to replace them afterwards (TextureManager.replace(...)). But that involves the creation of a dummy texture as a place holder during load, which isn't needed when loading them before.

AGP

Some parts of the model aren't coming out textured. I went so far as to load the file as an instance of awt/Image, drawing the image to the screen (which worked), and insantiating Texture from the Image instance. But the texture still won't load.

Melssj5

Well, the textures should be correctly apllied if you have all of them, the no textured parts appears white?

Be sure that they are JPG images.
Nada por ahora

Melssj5

Checkiew the console messages and check if they are being applied well. cometimes when filenames of textures are very long, some programs like 3d studio max rename the texture on the 3ds file.
Nada por ahora

AGP

No, it's not the file names. And the texture coordinates are all right. And I'm not getting any out-of-the-ordinary messages (just the usual "resizing to 256 pixels ones, but that's for all of the textures and most of them work).

And the untextured parts render as flat and grey.

Melssj5

Are u using sw rendering or opengl, can you please give us the 3d model and the textures on a zip file to test.
Nada por ahora

AGP

Software renderer.

And who's "us?"

Melssj5

Egon, me and anyone that wants to help!
Nada por ahora

AGP

Done. Any insights would be appreciated.

EgonOlsen

The texture names used in the file are displayed while loading the model, if the texture can't be found by the manager. Like in this line:

"Texture named XWBACK.JPG added to TextureManager!"

What this means is, that the loader is looking for a texture named "XWBACK.JPG" in the TextureManager. If it doesn't find one, it creates one. So, before loading the model, you should add this texture like so:

TextureManager.getInstance().addTexture("XWBACK.JPG", <your texture>);


Do this for all of the textures that are printed out that way during load. If the texture is named "BLAHBLAH.TGA", use that name even if your actual texture is a jpg or has a completely different name. With the naming of the textures when adding them, you provide a mapping between the names in the 3ds file and the file names of your textures. The names are case sensitive, so if it prints out "XWBACK.JPG", name it "XWBACK.JPG" when adding....not "xwback.jpg" or so.
I hope this makes it a bit clearer.

AGP

No, I got it the first time around. Did you manage to texture map all of it?

I did the whole thing step by step, including reassigning the JPEGs on MAX, so I'll find it very strange if you managed to do it by that line alone.

manumoi

Hello,

Is it possible that your textures are just applied on the wrong side of your model (displayed "inside" the xWing instead of outside). I had such a problem one time but it was just because i created my own model using the JPCT primitives... Not sure if it can be reproduced with 3ds file... that s just a guess...

Manu