Multi-texture 3Ds

Started by BarbosaRTS, June 06, 2014, 04:12:01 PM

Previous topic - Next topic

BarbosaRTS

Hello,

How to load multi textured object in jpct-ae?

I load my textures  ;D:


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  :):


ImageTargetsRenderer.obj3D = Object3D.mergeAll(Loader.load3DS(stream, absScale));


I use settexture()  :-\ :


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.

EgonOlsen

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

BarbosaRTS

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.

EgonOlsen

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.

BarbosaRTS

#4
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

BarbosaRTS

#5
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.

EgonOlsen

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.

BarbosaRTS

I Don't need readtextures finally. because the method of link working thank you  :).