Need setTexture by texture id

Started by kunong, January 05, 2013, 01:43:15 PM

Previous topic - Next topic

kunong

First of all sorry if my question was existed here before.
How can I set texture of Object3D by using texture id? Because I only know that it has setTexture methods by using texture name and texture info. I think if there are many textures caching in TextureManager, it maybe slow to search a texture from texture name.
And in case of texture info, I still don't know how to get texture info from texture id.

All of these I say, I just want to increase performance of Particle System. Because I've read other topics that relating particle and I know how to render particle by changing particle texture time to time. So, if there are many particle textures, it quite drop performance when changing particle texture.

Moreover, I've read source code about particle from Robombs (Explosion.java) and I want to use it but unfortunately in jPCT-AE it doesn't have recreateTextureCoords method in Object3D.

Could you think how can I increase performance from this?
Thanks and lovely this engine.

EgonOlsen

Accessing a texture via its name runs in O(1) if you access the same texture, so this shouldn't be an issue.

In jPCT-AE, there's no need for recreateTextureCoords. You can simply leave it out.

kunong

Thanks EgonOlsen, but I still don't understand why set texture via name runs in O(1) if I switch many textures when the time has passed.
eg. first frame for texture_01.png, second frame for texture_02.png and more by following this sequence.

What's the trick you used?

EgonOlsen

Not for the first access with another name, but subsequent accesses to the same name run in O(1). Really, this shouldn't be an issue at all.

kunong

Never mine, I don't want to know it anymore. I'm just wonder why search with string run in O(1).

Thank you so much for your replying.