Author Topic: Remove texture  (Read 3776 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Remove texture
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #1 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... ???

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Remove texture
« Reply #2 on: May 10, 2013, 08:47:58 pm »
Is expensive to set on every object 4 texture stages and uses less?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #3 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...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Remove texture
« Reply #4 on: May 10, 2013, 11:57:33 pm »
Fine, could you add method for change texture id in specific stage? This is needed

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #5 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...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Remove texture
« Reply #6 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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #7 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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #8 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.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Remove texture
« Reply #9 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remove texture
« Reply #10 on: May 13, 2013, 08:34:32 am »
Yes, it will be delayed by one frame.