setting polygon texture

Started by raft, October 14, 2010, 02:08:50 AM

Previous topic - Next topic

raft

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.

EgonOlsen

Try to set Config.aggressiveStripping=false;

raft

didnt help. the merged object is already stripped before serialization, does it make a difference?

EgonOlsen

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?

EgonOlsen

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

raft

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:
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 ???

raft

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.

EgonOlsen

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.

raft

mm, i see. that's kind of bad news. i will think of the uv thing

raft

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?

EgonOlsen

As long as they don't split into several sub-objects when compiled, then yes. Or simply use setTexture() in Object3D itself.

raft

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

raft

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.