Waving flag?

Hi,



I am new to jMonkey and I am trying to create a waving flag. I have managed to create a TriMesh of 5x5 but have no idea how I would proceed to “animate” it.



I tried something simple such as setting the z value of the vertices array (just a sin function) and call setVertices() on the TriMesh object that I created. The outcome of this is rather puzzling … i don’t really know how to explain but the vertices do move except that the wrong vertices are moving and not all of them are moving. I am pretty sure that I iterated and manipulated all the vertices in order.



Since that didn’t work, I thought I would call getVertices() and manipulate that instead … same results. I tried reconstruct() but that didn’t work out properly either.



I guess the question I would like to ask is: what is the best approach to my problem - creating a waving flag?



Thanks in advance for any input/help/pointers/hints.



Cheers,

Hong Ngee

Theres a cloth class under com.jme.effects.cloth



It will do a realistic flag for you. It wont wave unless there is wind and whatnot making it wave…



Experiement with that, theres also a test for it under jmetest.effects.cloth.



Hope that helps,

DP