How to dynamic change the texture U V ?

Started by gamenewer, October 23, 2014, 11:24:54 AM

Previous topic - Next topic

gamenewer

Hello , I want to do animation action by change texture U V , but I don't know how to do this? any sugestion or sample  , very Thanks !

Darai

What you need to know is:

  • Use Object3D.build(false) instead of Object3D.build() to tell JPCT that you DONT want static texture
  • Use Object3D.touch() to tell the object that you changed something and he should do again the "lazy transformation".
  • The texture setting is done through "Polygon manager" in following fashion: Object3D.getPolygonManager().setPolygonTexture(TriaID, new TextureInfo(TexID, U1, V1, U2, V2, U3, V3) Where TriaID is the ID of triangle on which you want to change the texture, TexID is the ID of your texture (still the same if you don't want to change the whole thing) and U1 .. V3 are coordinates of the points of the triangle on the texture (U1 - V3 are in range 0 - 1)

gamenewer

If I do this in ondrawFrame ,  maybe this will cause the framerate drop huge?

Darai

Well,

onDrawFrame is a good place to do this. I don't know if there is a better way or place to do it, maybe Egon will give you another advise. For me, it works there.

EgonOlsen

That's one way of doing it. Depending on the kind of animation, a texture matrix (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#setTextureMatrix(com.threed.jpct.Matrix)) might do the trick as well and it's faster.

gamenewer

Sets a matrix that is applied to transform the texture in stage 0, What's stage 0 ?

EgonOlsen


gamenewer

#7
hi, I use following code , but nothing happen , what's wrong

      billbord = Primitives.getPlane(1, 20);
      billbord.setTexture("speedup");
      billbord.build(false);
      world.addObject(billbord);


and  ondrawframe

                mx.translate(-1, 0, 0);
      billbord.setTextureMatrix(mx);


I want  picture translate from right to left and repeat this action 

EgonOlsen

Translation happens in normalized texture coordinates. -1 is as good as no translation. Try lower values instead (like 0.01f or something).

gamenewer