Author Topic: Texture Mapping  (Read 21197 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« on: August 08, 2006, 07:33:12 pm »
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);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #1 on: August 08, 2006, 11:07:23 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #2 on: August 09, 2006, 12:19:46 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #3 on: August 09, 2006, 12:22:30 am »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #4 on: August 09, 2006, 06:07:13 am »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Texture Mapping
« Reply #5 on: August 10, 2006, 03:38:08 am »
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

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Texture Mapping
« Reply #6 on: August 10, 2006, 03:40:32 am »
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

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #7 on: August 10, 2006, 04:08:36 am »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Texture Mapping
« Reply #8 on: August 10, 2006, 04:16:25 am »
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

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #9 on: August 10, 2006, 05:23:05 am »
Software renderer.

And who's "us?"

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Texture Mapping
« Reply #10 on: August 10, 2006, 05:50:38 am »
Egon, me and anyone that wants to help!
Nada por ahora

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #11 on: August 10, 2006, 05:59:04 am »
Done. Any insights would be appreciated.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #12 on: August 10, 2006, 05:04:11 pm »
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:

Code: [Select]
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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Mapping
« Reply #13 on: August 10, 2006, 06:42:32 pm »
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.

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Texture Mapping
« Reply #14 on: August 10, 2006, 07:07:55 pm »
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