Remove texture

Started by Thomas., May 10, 2013, 07:11:49 PM

Previous topic - Next topic

Thomas.

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.

EgonOlsen

Why is that needed? If you don't want that texture in that stage, don't add it in the first place... ???

Thomas.

Is expensive to set on every object 4 texture stages and uses less?

EgonOlsen

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

Thomas.

Fine, could you add method for change texture id in specific stage? This is needed

EgonOlsen

Thinking about it, you can already do all that (add/remove/replace) simply by using setPolygonTexture in the PolygonManager...

Thomas.

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?

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


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)

EgonOlsen

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

EgonOlsen

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.

Thomas.

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.

EgonOlsen

Yes, it will be delayed by one frame.