Author Topic: Question on Multitexturing  (Read 2797 times)

Offline dubbox

  • byte
  • *
  • Posts: 24
    • View Profile
Question on Multitexturing
« on: October 05, 2014, 05:12:51 pm »

SOLVED

Hello it is me again :D

Thanks to the help of Egon i applied textures to my .3ds object and load it successfully into android

now i got another question i have read all the posts about multitexturing but i still have a question about it

In some posts its said that .3ds doest not support multi texturing but there is also said that you can apply multiple textures by using the TExtureManager with the rigth names

so what do i have to do?

Do i have to load my model splitted up by texture like one .3ds file for the roof with the roof texture
 another .3ds for the wall with the wall texture

and then merge them together

or

do i have to apply all the textures on one .3ds model and use the texture names for the texture manager??

i tried it using the texturemanager but i am not getting it to work the textures are not showed at all

so what is the best way and maybe some explination code would help
thank you

this is my code right now

Code: [Select]
try {
Texture teppich=new Texture(assetManager.open("teppichHems.jpg"));
Texture decke=new Texture(assetManager.open("StyroporDecke.jpg"));
Texture wand=new Texture(assetManager.open("WandBlech.jpg"));

TextureManager.getInstance().addTexture("Texture.001", teppich);
TextureManager.getInstance().addTexture("Texture", decke);
TextureManager.getInstance().addTexture("Texture.002", wand);
} catch (IOException e) {
e.printStackTrace();
}


    try {
model = Loader.load3DS( assetManager.open("thirdfloorAndroid.3ds"), 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
« Last Edit: October 07, 2014, 01:49:00 pm by dubbox »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Question on Multitexturing
« Reply #1 on: October 05, 2014, 08:26:10 pm »
You are mixing multi-texturing with multiple textures here. Multi-texturing applies multiple texture layers to a polygon. 3ds doesn't support this. Mutiple textures simply means that a models contains multiple textures (but only one texture/polygon). 3ds supports this just fine. Your approach with the names in the manager is already fine, you just don't use the right names (most likely). Scan the log for messages about the texture names when loading the model and you should see if and how these names differ from the ones that you are using.

Offline dubbox

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Question on Multitexturing
« Reply #2 on: October 07, 2014, 01:48:09 pm »
Thank you Egon you are the man :D

simple problems and you give directly simple solutions :)

Offline angieIe

  • byte
  • *
  • Posts: 29
    • View Profile
Re: Question on Multitexturing
« Reply #3 on: October 20, 2014, 06:47:50 am »
hi egon, i don't understand about texture names in TextureManager. I have model with 3 texture file :Bear_Eyes+eeth+Nail_Diffuse.jpg, Bear_Specular.jpg, and Bear_Diffuse.jpg
Code: [Select]
teeth = new File(Environment.getExternalStorageDirectory(),"Folder/"+subfolder+"/"+"Bear_Eyes+eeth+Nail_Diffuse+".jpg");
body= new File(Environment.getExternalStorageDirectory(),"Folder/"+subfolder+"/"+"Bear_Diffuse".jpg");

TextureManager txtMgr = TextureManager.getInstance();
Texture texture1 = new Texture(new FileInputStream(teeth));
Texture texture2 = new Texture(new FileInputStream(body));
 txtMgr.addTexture("texture1", texture1);
 txtMgr.addTexture("texture2", texture2);
object.setTexture("texture1");
object.setTexture("texture2");

but texture of teeth and body not apply :( ..am i wrong using texture names and TextureManage?Please guide me. thanks egon

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Question on Multitexturing
« Reply #4 on: October 20, 2014, 07:49:21 am »
If you let the loader assign the textures, you must not call setTexture(...) on the object, because that will set the texture for the whole object. What you should do is:

  • Find out about the proper names. The file names don't matter. It's the name that you give it in the TextureManager that counts and i highly doubt that these would be "textureX". Look at the log output or use the method to read the texture names that the Loader offers.
  • Add the textures with the proper names to the TextureManager
  • Load the object
  • DON'T call setTexture() on the object
« Last Edit: October 20, 2014, 10:24:04 am by EgonOlsen »

Offline angieIe

  • byte
  • *
  • Posts: 29
    • View Profile
Re: Question on Multitexturing
« Reply #5 on: October 20, 2014, 09:47:45 am »
Thank you egon.it's work now :)


Offline angieIe

  • byte
  • *
  • Posts: 29
    • View Profile
Re: Question on Multitexturing
« Reply #6 on: October 20, 2014, 10:44:36 am »
Hi egon, i have something to ask again.. if i want get proper texture name not from output log, how do that?
Thx you again