www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Wojtek on November 16, 2009, 04:43:13 pm

Title: How to add texture to textured object
Post by: Wojtek on November 16, 2009, 04:43:13 pm
Hello,

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

I see that there is a
Code: [Select]
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 (http://www.jpct.net/forum2/index.php/topic,988.0.html)).

Thanks,
Wojtek
Title: Re: How to add texture to textured object
Post by: EgonOlsen on November 16, 2009, 05:48:28 pm
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.
Title: Re: How to add texture to textured object
Post by: Wojtek on November 17, 2009, 05:17:45 pm
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:
(http://img41.imageshack.us/img41/9892/withglare.jpg)
(http://img4.imageshack.us/img4/2796/withshadow.jpg)

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.
Title: Re: How to add texture to textured object
Post by: EgonOlsen on November 17, 2009, 06:03:58 pm
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.
Title: Re: How to add texture to textured object
Post by: Wojtek on November 18, 2009, 12:03:18 am
Thank you for your help once again. It works of course :)

There is a screenshot:
(http://img4.imageshack.us/img4/6489/withglareshadow.jpg)
Title: Re: How to add texture to textured object
Post by: Wojtek on December 13, 2009, 01:56:42 pm
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
Title: Re: How to add texture to textured object
Post by: EgonOlsen on December 13, 2009, 11:19:39 pm
Currently, that's not possible. I'm going to add it to the PolygonManager.
Title: Re: How to add texture to textured object
Post by: Wojtek on December 14, 2009, 12:05:23 am
Ok, so i will hold that information in my classes for now.

Thanks,
Wojtek
Title: Re: How to add texture to textured object
Post by: EgonOlsen on December 14, 2009, 09:09:44 pm
I've uploaded the version (http://www.jpct.net/download/beta/jpct.jar (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.
Title: Re: How to add texture to textured object
Post by: Wojtek on January 12, 2010, 11:19:34 pm
Hello,

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

Thanks,
Wojtek