How to add texture to textured object

Started by Wojtek, November 16, 2009, 04:43:13 PM

Previous topic - Next topic

Wojtek

Hello,

Is it possible to add additional texture to loaded 3ds object that already has some textures?

I see that there is a public void setTexture(TextureInfo tInf) method, but it replaces all existing textures that are associated to the object and I do not see any methods that will be able to return texture list that is already assigned to object.

What I want to do is to add an additional texture that will be used as envmap (just like in viper example http://www.jpct.net/forum2/index.php/topic,988.0.html).

Thanks,
Wojtek

EgonOlsen

Depends on if the object actually uses multiple textures. If it doesn't, the setTexture-method in Object3D is sufficient. If it does, you have to use the PolygonManager to achieve this. Just iterate over each polygon, get the texture id and the u/v coordinated for each vertex, create a new TextureInfo with that, add you additional texture to it and  re-assign it using the PolygonManager. It's a bit awkward though.

Wojtek

Thank you for response. It works :)

Now I have another question. When I added the envmap image, I have lost the shadow effect. There are example screenshots.
The first is with glare effect, and the second is without:



Can you please explain me why the shadow effect disappeard, and if it is possible to have both effects at the same time?

I can add that right now I am not using the ShadowHelper class so this is a standard shadow effect.

EgonOlsen

That's caused by the way the OpenGL rendering pipeline works. You can try to switch the texture stages when assigning the textures and set Config.glForceEnvMapToSecondStage to true.

Wojtek

Thank you for your help once again. It works of course :)

There is a screenshot:

Wojtek

Hello,

I would like to ask if it is possible to get the list of textures that are assigned to given polygon?

The PolygonManager have void setPolygonTexture(int polyID, TextureInfo tInf) method where TextureInfo allows to add many textures to it,
and there is a int getPolygonTexture(int polyID) method that returns id of one texture, but I cannot find any method that will return a list of textures assigned to given polygon.

Thanks,
Wojtek

EgonOlsen

Currently, that's not possible. I'm going to add it to the PolygonManager.

Wojtek

Ok, so i will hold that information in my classes for now.

Thanks,
Wojtek

EgonOlsen

I've uploaded the version (http://www.jpct.net/download/beta/jpct.jar) that has a getPolygonTextures()-method added to the PolygonManager. It's totally untested and the returned int[]-array may contain TextureManager.TEXTURE_NOTFOUND-ids for all unused stages. Once you encounter such a texture, you can break.

Please let me know if it works, because, as said, i haven't tested it at all.

Wojtek

Hello,

Excuse me that I have not replied earlier :(
I have tested that new method and it seems to work correctly.

Thanks,
Wojtek