www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on May 10, 2013, 07:11:49 pm

Title: Remove texture
Post by: Thomas. on May 10, 2013, 07:11:49 pm
Please, could you add method for remove texture from PolygonManager (PolygonManager.removeTexture(int stage))? So each textures on higher stares will be moved down.
It would be helpful if the method TextureManager.addTexture(...) return texture id.
Title: Re: Remove texture
Post by: EgonOlsen on May 10, 2013, 08:41:43 pm
Why is that needed? If you don't want that texture in that stage, don't add it in the first place... ???
Title: Re: Remove texture
Post by: Thomas. on May 10, 2013, 08:47:58 pm
Is expensive to set on every object 4 texture stages and uses less?
Title: Re: Remove texture
Post by: EgonOlsen on May 10, 2013, 08:51:37 pm
I don't think so. Memory usage on the GPU will be slightly higher (but no difference in main memory), but that's about it...
Title: Re: Remove texture
Post by: Thomas. on May 10, 2013, 11:57:33 pm
Fine, could you add method for change texture id in specific stage? This is needed
Title: Re: Remove texture
Post by: EgonOlsen on May 11, 2013, 12:32:23 pm
Thinking about it, you can already do all that (add/remove/replace) simply by using setPolygonTexture in the PolygonManager...
Title: Re: Remove texture
Post by: Thomas. on May 12, 2013, 01:52:20 am
I have problem with setPolygonTexture method. This code is performed in IRenderHook.setCurrentObject3D(). I do not call strip() anywhere. The object is composed of two triangles. Where could the problem be?

Code: [Select]
PolygonManager pm = obj.getPolygonManager();
int difuseTextureID = pm.getPolygonTexture(0);
TextureInfo ti = new TextureInfo(difuseTextureID);
ti.add(normalTextureID, TextureInfo.MODE_ADD);
ti.add(shadowTextureID, TextureInfo.MODE_ADD);
int maxID = pm.getMaxPolygonID();
for (int i = 0; i < maxID; i++)
pm.setPolygonTexture(i, ti);

Code: [Select]
05-12 01:41:56.427: I/jPCT-AE(1718): [ 1368315716433 ] - ERROR: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
05-12 01:41:56.427: I/jPCT-AE(1718): at com.threed.jpct.PolygonManager.setPolygonTexture(PolygonManager.java:248)
05-12 01:41:56.427: I/jPCT-AE(1718): at cz.chladek.jpct.extension.ObjectInfo.update(ObjectInfo.java:90)
05-12 01:41:56.427: I/jPCT-AE(1718): at cz.chladek.jpct.extension.LightController.setCurrentObject3D(LightController.java:165)
05-12 01:41:56.427: I/jPCT-AE(1718): at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:455)
05-12 01:41:56.427: I/jPCT-AE(1718): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2209)
05-12 01:41:56.427: I/jPCT-AE(1718): at com.threed.jpct.World.draw(World.java:1353)
05-12 01:41:56.427: I/jPCT-AE(1718): at com.threed.jpct.World.draw(World.java:1093)
Title: Re: Remove texture
Post by: EgonOlsen on May 12, 2013, 08:34:57 pm
I'll have a look...the location in which you are calling setPolygonTexture (i.e. inside the IRenderHook) doesn't make much sense anyway, because it's too late. The textures are already set at that stage. However, this has nothing to do with the crash...
Title: Re: Remove texture
Post by: EgonOlsen on May 12, 2013, 08:40:55 pm
I've updated the beta version. The problem seems to be caused by objects that use less stages than the config allows them to. I don't know how you managed to do so, but the uploaded version hopefully fixes it.
Title: Re: Remove texture
Post by: Thomas. on May 12, 2013, 09:56:58 pm
Thanks, error is gone ;) So, when I use it in IRenderHook, result will be delayed by one frame? I'm checking if objects need to update something in setPolygonTexture method. It seems to me better, than before rendering check all objects individually.
Title: Re: Remove texture
Post by: EgonOlsen on May 13, 2013, 08:34:32 am
Yes, it will be delayed by one frame.