Author Topic: Multi-texture 3Ds  (Read 3312 times)

Offline BarbosaRTS

  • byte
  • *
  • Posts: 8
    • View Profile
Multi-texture 3Ds
« on: June 06, 2014, 04:12:01 pm »
Hello,

How to load multi textured object in jpct-ae?

I load my textures  ;D:

Code: [Select]
String[] textures = getAssets ().list("textures");
   
for (int i = 0; i < textures.length; ++i)
{
            TextureManager.getInstance().addTexture(textures[i], new Texture(BitmapHelper.rescale(BitmapHelper.loadImage(getResources(). getAssets (). open ("textures" + "/" + textures[i])), 256, 256)));
}


After I load my model in .3ds format  :):

Code: [Select]
ImageTargetsRenderer.obj3D = Object3D.mergeAll(Loader.load3DS(stream, absScale));

I use settexture()  :-\ :

Code: [Select]
obj3D.setTexture("Metal_Co");
obj3D.setTexture("Metal_Ro");

But finally stay just second texture  ??? :( :(

How to associate the texture with good object and not all objects?

I don't understand how load textures and show them in good place.

help please.
« Last Edit: June 06, 2014, 04:36:52 pm by BarbosaRTS »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Multi-texture 3Ds
« Reply #1 on: June 06, 2014, 09:31:41 pm »
If you are using setTexture on an Object3D, you are setting the texture for the whole model. You have to assign the textures before doing the merge. You do this either in code by using setTexture on the sub-objects or by letting the loader do it: http://www.jpct.net/wiki/index.php/Loading_models

Offline BarbosaRTS

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Multi-texture 3Ds
« Reply #2 on: June 07, 2014, 09:31:37 am »
Thank you for your answer.

I have already tried manually but for my application it would not be adapted.

I have seen this link, but I does not understand to let make the loader...

Just use TextureManager? Because it also I have already tried without succes.

If you have an example of code to give me I would be very grateful to you.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Multi-texture 3Ds
« Reply #3 on: June 07, 2014, 09:56:45 pm »
Actually, the code you need is in that wiki page. You just load some texture of yours and assign it to the manager with the name that it has in the file that you are loading. As mentioned in the wiki, this isn't the file name (or at least it doesn't have to be) but the name in the material definition of the file. For 3ds files, you can get these names from the loader if you have to. For obj, you can parse them yourself out of the mtl-file. Or just read them out of the log when you first load the file.

Offline BarbosaRTS

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Multi-texture 3Ds
« Reply #4 on: June 09, 2014, 09:04:05 am »
I use file 3ds.
I thus have to use the function readTextureNames3DS I presume?

Because

Object3D[] Objs = Loader.load3DS(stream, absScale);
String [] textureNames = Loader.readTextureNames3DS(stream);

logcat:

java.lang.RuntimeException: [ 1402298151668 ] - ERROR: Couldn't read file from InputStream
« Last Edit: June 09, 2014, 09:24:47 am by BarbosaRTS »

Offline BarbosaRTS

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Multi-texture 3Ds
« Reply #5 on: June 09, 2014, 02:01:50 pm »
I have just verified with Deep exploration.
I had good name but in my model nothing was associated.
Maybe because my model come from a conversion of sketchup - > 3ds

http://zupimages.net/viewer.php?id=14/24/3fef.png

Thank you for your help.
« Last Edit: June 09, 2014, 05:18:34 pm by BarbosaRTS »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Multi-texture 3Ds
« Reply #6 on: June 09, 2014, 09:52:43 pm »
That error has nothing to do with the file itself. Your stream either points to the wrong file or you are using an already closed stream. If you are using load and loadTextureNames on the same stream, the stream is closed after the first load...call. Make sure to create a new input stream if that's the case.

Offline BarbosaRTS

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Multi-texture 3Ds
« Reply #7 on: June 10, 2014, 08:52:39 am »
I Don't need readtextures finally. because the method of link working thank you  :).