Author Topic: Need setTexture by texture id  (Read 2178 times)

Offline kunong

  • byte
  • *
  • Posts: 4
    • View Profile
Need setTexture by texture id
« on: January 05, 2013, 01:43:15 pm »
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.
« Last Edit: January 05, 2013, 05:10:00 pm by kunong »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Need setTexture by texture id
« Reply #1 on: January 05, 2013, 08:08:43 pm »
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.

Offline kunong

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Need setTexture by texture id
« Reply #2 on: January 06, 2013, 06:03:28 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Need setTexture by texture id
« Reply #3 on: January 06, 2013, 09:19:53 am »
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.

Offline kunong

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Need setTexture by texture id
« Reply #4 on: January 06, 2013, 12:37:10 pm »
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.