How to move U/V Coordinates...

Started by AGP, January 21, 2014, 04:35:18 AM

Previous topic - Next topic

AGP

...so as to animate river water? The following doesn't work, for some reason:


     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.

EgonOlsen

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.