Author Topic: setting polygon texture  (Read 2693 times)

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
setting polygon texture
« on: October 14, 2010, 02:08:50 am »
I have a merged object which is serialized with desktop jPCT. i change textures of some polygons during the course of the game. this works fine in desktop jPCT. but in AE I got some strange behaviour:

* with one subobject to change texture this works fine
* with a couple subobjects, i only get a result by setting texture of first one and this operation sets textures of other subobjects too. setting texture on other subobjects has no effect

i suspect this thing requires, build(false) method. if this is the case, there is no such method in AE, how can i serialize such an object from desktop jPCT?

i've also tried calling compile(true) before serialization but didnt help.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: setting polygon texture
« Reply #1 on: October 14, 2010, 07:04:51 am »
Try to set Config.aggressiveStripping=false;

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #2 on: October 14, 2010, 12:25:11 pm »
didnt help. the merged object is already stripped before serialization, does it make a difference?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: setting polygon texture
« Reply #3 on: October 14, 2010, 02:02:44 pm »
That shouldn't matter. I'm still not 100% sure what you are actually doing...you have some object that is a merge result of some other objects using different textures. And you compile this thing von Android and it splits into different sub-objects, because of the different textures. You then replace the textures of some of these compiled sub-objects? How?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: setting polygon texture
« Reply #4 on: October 14, 2010, 02:04:32 pm »
BTW: You can't set textures using TextureInfo on a compiled and stripped object anyway. The method simply returns without doing anything. The method that uses the texture ID should work though.
« Last Edit: October 14, 2010, 02:13:20 pm by EgonOlsen »

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #5 on: October 14, 2010, 04:04:11 pm »
exactly. my level consists of several types of tiles. i merge them into one, compile strip and serialize. meanwhile i also save polygon limits and vertex limits of tiles. here i depend on the fact, during merging polygon and vertex orders are preserved.

then in Android, i set texture via PolygonManager:
Code: [Select]
PolygonManager.setPolygonTexture(polyId, textureId);
if i have only one of a certain tile type T all goes well. if i have many tiles of type T, then the problem above happens. setting texture on second and third has no effect, setting texture on first one sets texture of all three ???

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #6 on: October 14, 2010, 04:10:32 pm »
i use subobject in a different meaning here. i call every tile as a subobject but in your terminology, several tiles of same type (single texture) make a subobject.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: setting polygon texture
« Reply #7 on: October 14, 2010, 08:47:12 pm »
I see...well, that won't work. Compilation happens based on the textures. You can't change the texture of some inbetween polygons without triggering a complete recompilation again...if IIRC, this isn't supported anyway. A solution is to put all textures into one and just change u/v-mapping. That requires no new compilation, "just" a new fill of the native buffers, which isn't particularly fast either, but depending on the frequency in which this happens, it might be fast enough.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #8 on: October 14, 2010, 09:15:08 pm »
mm, i see. that's kind of bad news. i will think of the uv thing

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #9 on: October 14, 2010, 09:59:06 pm »
on some cases i need to set texture of all tiles of some kind. seems as this happens automatically at the moment, if i set first one all is set. can i count on this?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: setting polygon texture
« Reply #10 on: October 14, 2010, 11:53:38 pm »
As long as they don't split into several sub-objects when compiled, then yes. Or simply use setTexture() in Object3D itself.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #11 on: October 15, 2010, 12:07:19 am »
i cant use setTexture here. because these are merged with other kind of tiles. i want to set textures of all tiles of a kind

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: setting polygon texture
« Reply #12 on: October 16, 2010, 10:13:02 pm »
i preferred to put two tiles with different textures on same place and hide/show one of them via VertexController as discussed in this thread. this may be slightly more expensive but seemed easier to me. one obvious advantage is i can use the tiles as they are modelled/textured in a 3d editor.