Author Topic: [Solved] changing Texture UV Map on Polygon at runtime  (Read 1501 times)

Offline CultiMAN

  • byte
  • *
  • Posts: 3
    • View Profile
[Solved] changing Texture UV Map on Polygon at runtime
« on: February 23, 2012, 10:27:52 pm »
Hi

I have a strange problem with my project.
I have a method on my cube class that changes the UV mapping of a textureatlas for one of the sides of the cube.
The method uses model.getPolygonManager().setPolygonTexture(...) to change the UV mapping of the polygons in question - and i know it works fine.
My problem is that i only works in my initial onSurfaceChanged (when game starts). If i call the same method when scene is running/updating/drawing - it won't do the update of the texture.

I know the method is being called while the game is running (debugger confirms)

Do i need to call somekind of update method on my world like : world.RefreshAllUVMappings() ?

Hope you can help.

/Kristian, Denmark
« Last Edit: February 24, 2012, 02:20:00 pm by CultiMAN »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: changing Texture on Polygon at runtime
« Reply #1 on: February 23, 2012, 10:42:27 pm »
You want to change the u/v-mapping or the texture? That's a pretty huge difference... ???

Offline CultiMAN

  • byte
  • *
  • Posts: 3
    • View Profile
Re: changing Texture on Polygon at runtime
« Reply #2 on: February 23, 2012, 10:48:40 pm »
the UV mapping

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: changing Texture on Polygon at runtime
« Reply #3 on: February 23, 2012, 11:26:34 pm »
In that case, you have to explicitly compile the object using Object3D.compile(true, false); and you have to call Object3D.touch(); after adjusting the uv-mapping.

Offline CultiMAN

  • byte
  • *
  • Posts: 3
    • View Profile
Re: changing Texture on Polygon at runtime
« Reply #4 on: February 24, 2012, 02:18:56 pm »
Thanks Egon! That did the trick! Groovy. Great job on a Great engine! Hats off to you.