I have created a simple model of a box and created a color interpolation image using a texture map. I exported the model to fxml using the code found at
I have a jpeg of the colored model I tried to export and the resulting imported model, but I am new to Stack Overflow and I am not allow to post images yet.
I also could not find a way to attach the content of the FXML file that was exported, but I would be happy to share it.
When I import the fxml file back into my application using the standard FXMLLoader, the color mapping is not visible. I don't know if the export was incomplete or the import was incorrect. The FXML file appears to have the correct mesh and texture map pointers, but I don't see a representation of the texture map. I used the PhongMaterial setDiffuseMap method to assign an image to the material object that was constructed using an WritableImage and PixelWriter to create a band of colors. Does anyone know whether export of the PhongMaterial object constructed in this way is supported in the FXMLExporter or if the FXMLImporter does not support importing such a color map?
Based on the suggestions from Jose I made changes to my code, but I encountered some issues.
I defined each face of my two cubes as a separate TriangleMesh, thinking that eventually I want to be able to distinguish each face when selecting objects in the scene. I have a single PhongMaterial object that has the image as a diffuse map. I have assigned the same material to each face of my two cubes.
When I export my model, the export method tries to write the image file 12 times. It seems there should be a way to convey to the model definition that a single phong material is being used and it is based on a single color image.
I added code to the export method to remember the filename used to export the FXML file so that I could assign a name to the image file based on the FXML filename (full pathname passed to exportImage()). Without a path, the image file is stored inside my Eclipse workspace instead of in the same folder as my FXML file. I am not sure what name should be given to fxmlImage.addProperty("url",filename). Should it be the full path name or just the filename? If I use the full pathname, then I have a hardcoded path inside the FXML file and that seems like a bad idea. I tried saving the URL name with and without the full path and got the same result both ways... which was that no model appeared when I imported the FXML file. I also tried with and without the leading @, with the same result. Does anyone have an idea what I might be doing wrong?