Author Topic: How to move U/V Coordinates...  (Read 1695 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
How to move U/V Coordinates...
« on: January 21, 2014, 04:35:18 am »
...so as to animate river water? The following doesn't work, for some reason:

Code: [Select]
     public void moveRiverWater(float deltaTime) {
Matrix matrix = river.getTextureMatrix();
if (matrix == null) {
     matrix = new Matrix();
     river.setTextureMatrix(matrix);
}
matrix.translate(river.getXAxis().x*100*deltaTime, river.getXAxis().y*100*deltaTime, river.getXAxis().z*100f*deltaTime);
river.setTextureMatrix(matrix);//WITH OR WITHOUT THIS SEEMINGLY UNNECESSARY CALL, IT DOESN'T WORK
     }

I get absolutely nothing whether or not the object is compiled.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to move U/V Coordinates...
« Reply #1 on: January 21, 2014, 07:44:11 am »
You have to keep three things in mind when using a texture matrix:

  • It works reliable only on compiled objects.
  • It works only on the first texture stage.
  • A texture coordinate is usually something between 0..1, maybe 2...and your translation should be accordingly. Not by some magnitude larger.