Search code examples
animationtexturesmeshjavafx-8

How to change texture coord after a TriangleMesh was created in JavaFx?


I created a TriangleMesh in JavaFx. The vertices were assigned some initial texture coordinates. I want to animate the texture on the mesh by changing the texture coordinates of the vertices slowly over time. Is this possible? If so, how to do it? If not, what is the best way to achieve this effect?


Solution

  • It is possible... One approach would be to create a property Double for uvStartX, uvStartY (u,v) .. Override invalidated method, in the invalidated method, call setMesh(meshMethod) change those values in a timeline..

    I've done something similar with points, meshdivisions etc... It works and is rather smooth too.

    Hard part is making sure all your code maps to a point between 0-1.0 and keeping those points lined up to each other.