This is a tiny tutorial on how to load a .obj file into a 3d MeshView and display it in B4J.
I have loaded .obj files that I downloaded from the web, but they tend to not stick to the same format that I wrote this for (to display 3d scans from my phone).
The program has 4 main parts
1, Read the TriangleMesh data from the .obj file (its basically just a text file)
2, Convert the lists into arrays.
3, Create the MeshView
4, Display the MeshView (its basically a node so can be added as normal)
The program also allows for rotating the object.
It tries to scale the model so it is 75% of the width/height of the node it is in ( a tall model uses the 75% height, afat (not pc) wide model will use 75% of the width)
I have commented the code - but to understand the .obj format it's worth a google.
Unfortunately I cannot upload any of my scans as they are quite big (smallest is 1MB+).
So I have uploaded a screenshot of the output from loading the sony demo model.
I have tried it with big files - 10M+ faces and the conversion takes around 500ms, but to display, takes a few seconds as javafx loads the MeshView (this is still faster than some other mesh viewers I tried, which took 19 seconds to render the mesh)
I have loaded .obj files that I downloaded from the web, but they tend to not stick to the same format that I wrote this for (to display 3d scans from my phone).
The program has 4 main parts
1, Read the TriangleMesh data from the .obj file (its basically just a text file)
2, Convert the lists into arrays.
3, Create the MeshView
4, Display the MeshView (its basically a node so can be added as normal)
The program also allows for rotating the object.
It tries to scale the model so it is 75% of the width/height of the node it is in ( a tall model uses the 75% height, a
I have commented the code - but to understand the .obj format it's worth a google.
Unfortunately I cannot upload any of my scans as they are quite big (smallest is 1MB+).
So I have uploaded a screenshot of the output from loading the sony demo model.
I have tried it with big files - 10M+ faces and the conversion takes around 500ms, but to display, takes a few seconds as javafx loads the MeshView (this is still faster than some other mesh viewers I tried, which took 19 seconds to render the mesh)
Attachments
Last edited: