• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaFX modify the coordinates of a given mesh in real time

 
Ben Taylor
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would like to modify the coordinates of a given mesh in real time in JavaFX which is triangulated. Is is possible ?

I can not think of a way to do so, just to reinitialize the points all over again in a MeshView which is not correct.

I would like something like in this video: https://www.youtube.com/watch?v=RqAa8Uu9zbQ&index=9&list=PLvPs0rMPHQHcoN-dPnXXvETarhsUNz5oO

Does somebody have an ideea?

Thank you.
 
Ben Taylor
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I posted on Stackoverflow too. I need help to solve this issue, hopefully in shot time.
 
Piet Souris
Rancher
Pie
Posts: 1511
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some strategies are thinkable:

1) you could use one or more Transforms

2) have one separate Thread (or more) calculate the new coordinates, giving these as much time
to do it as possible between two redraws

3) calculate alll required sets of points upfront, before displaying them, i.e. many meshes

But indeed, you simply need to update yur points. But your texture coordinates and faces
dcanbe left unchanged.
 
Ben Taylor
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I keep track of the points inside the array? I suppose I have to divide them by 3 and create a point from each set of 3 values from the array and then when a point needs to be updated I iterate the array till the values are found and update them.
 
Piet Souris
Rancher
Pie
Posts: 1511
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in your points array you have three entries for each point. But you could also calculate all necessary oordinates upfront, so that all that is needed is to change the contents of your points array with the contents of one of those pre calculated arrays.

I cannot say what is the best strategy. But my advice is: pick the simplest one to implement that is also fast enough.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer depends a bit on what you are trying to do.  For the video you posted is doing a couple of things, one is transforming the model by rotation in 3D space, and the other is changing the internal geometry of the model through deformation.  To deform the mesh, then you need to change the points in your mesh.  To apply a transform on the complete mesh, such as rotating it or translating it, there is in-built animation support in JavaFX that can assist with that (for example TranslateTransition, RotateTransition) and there is also a transform property of the mesh you can manipulate directly in an AnimationTimer or Timeline or in response to user input.  An example for applying a transformation on a complete model and not changing its internal geometry is: Some code for rotating a cube.  It would seem though that you are attempting to do more in deforming the model, so to do that you will also need to change your mesh points according to some animation, user manipulation or algorithm you provide.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic