Question

I built an app in JavaFX 8 that can rotate and move TriangleMesh objects on screen. I use the libraries from www.interactivemesh.org to read the STL files and create the TriangleMesh objects.

When I write the TriangleMesh objects back to STL the original data is saved. JavaFX doesn't change the original data. I logged a jira and they said this is how it is supposed to work.

How can I transform the mesh data when I save it? I am hoping for a cross platform library that can transform a mesh that could integrate easily with JavaFX 8.

I found hg.postspectacular.com/toxiclibs/wiki/Home. They developed their own TriangleMesh and other objects. If all else fails I will probably write a converter to convert the JavaFX TriangleMesh to their one and then use their transforms to transform the data so that I can save it to STL. I am not sure if they actually change the data so that I can actually use it

I also see I might need to look at JOGL (Java Bindings for the OpenGL).

Was it helpful?

Solution

See javadoc of javafx.scene.Node for:

Transform Node.getLocalToSceneTransform()

"An affine transform that holds the computed local-to-scene transform. This is the concatenation of all transforms in this node's parents and in this node, including all of the convenience transforms.""

See javadoc of javafx.scene.transform.Transform for:

Point3D transform(Point3D point)

"Transforms the specified point by this transform."

  1. Get the 'LocalToSceneTransform' from the TriangleMesh's Shape3D node
  2. Apply the transform-method to the three Point3Ds of each triangle
  3. Convert the Point3Ds from JavaFX 3D coordinate system to one of STL by flipping the y- and z-values
  4. Use the transformed and converted three Point3Ds to calculate the face/triangle normal
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top