www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: gamenewer on October 23, 2014, 11:24:54 AM

Title: How to dynamic change the texture U V ?
Post by: gamenewer on October 23, 2014, 11:24:54 AM
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 !
Title: Re: How to dynamic change the texture U V ?
Post by: Darai on October 23, 2014, 01:07:26 PM
What you need to know is:
Title: Re: How to dynamic change the texture U V ?
Post by: gamenewer on October 23, 2014, 01:14:13 PM
If I do this in ondrawFrame ,  maybe this will cause the framerate drop huge?
Title: Re: How to dynamic change the texture U V ?
Post by: Darai on October 23, 2014, 02:06:56 PM
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.
Title: Re: How to dynamic change the texture U V ?
Post by: EgonOlsen on October 23, 2014, 08:14:18 PM
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) (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.
Title: Re: How to dynamic change the texture U V ?
Post by: gamenewer on October 24, 2014, 11:28:24 AM
Sets a matrix that is applied to transform the texture in stage 0, What's stage 0 ?
Title: Re: How to dynamic change the texture U V ?
Post by: EgonOlsen on October 24, 2014, 11:31:34 AM
The first texture layer.
Title: Re: How to dynamic change the texture U V ?
Post by: gamenewer on October 24, 2014, 11:58:14 AM
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 
Title: Re: How to dynamic change the texture U V ?
Post by: EgonOlsen on October 24, 2014, 01:45:28 PM
Translation happens in normalized texture coordinates. -1 is as good as no translation. Try lower values instead (like 0.01f or something).
Title: Re: How to dynamic change the texture U V ?
Post by: gamenewer on October 24, 2014, 02:30:08 PM
It's ok , thank you very much !