www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: BarbosaRTS on June 06, 2014, 04:12:01 pm

Title: Multi-texture 3Ds
Post by: BarbosaRTS 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.
Title: Re: Multi-texture 3Ds
Post by: EgonOlsen 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 (http://www.jpct.net/wiki/index.php/Loading_models)
Title: Re: Multi-texture 3Ds
Post by: BarbosaRTS 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.
Title: Re: Multi-texture 3Ds
Post by: EgonOlsen 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.
Title: Re: Multi-texture 3Ds
Post by: BarbosaRTS 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
Title: Re: Multi-texture 3Ds
Post by: BarbosaRTS 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 (http://zupimages.net/viewer.php?id=14/24/3fef.png)

Thank you for your help.
Title: Re: Multi-texture 3Ds
Post by: EgonOlsen 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.
Title: Re: Multi-texture 3Ds
Post by: BarbosaRTS on June 10, 2014, 08:52:39 am
I Don't need readtextures finally. because the method of link working thank you  :).