[Release] Wavefront OBJ to IMesh
|
13-01-2021, 12:16 AM
Post: #1
|
|||
|
|||
Wavefront OBJ to IMesh
Wavefront OBJ to IMesh
I have created a pure Starfall OBJ parser that will take in OBJ strings and can convert it to an IMesh, ready for hologram or HUD use. As I am pretty unimaginative, I named it Wavefront OBJ to IMesh. This forum post will serve as a reference or tutorial to use this library (you can view the source at Shared/frdhog/libs/wavefront_obj.txt) The advantage this has over external programs is that it allows you to load files that are larger than 1MiB (through io.read & starfallscriptdata), through the HTTP library or pretty much any other means you can think of. Due to quota limits, you can process over multiple ticks and use a callback once completed, use ProcessObjMesh for this Including the library To include the library, you'll need to do the following Note the dependency uses cl as it's easiest to process the meshes on the client rather than network everythingAs this was originally created for my own purposes, this 'library' is just public functions. ParseObjToMesh If you need a new mesh instantly, you can use ParseObjToMesh. It takes one string and returns the IMesh once complete. Unlike ProcessObjMesh, you can use this inline but it will error if the file is too large and such the time quota is exceeded while processing it. ProcessObjMesh The best way to use my library is to use the ProcessObjMesh function.
Not all of these parameters are needed unless you want to have more control. See the ProcessObjMesh example
Examples These are examples of how to use the library, not how to use IMeshes in holograms. For those I recommend checking out other implementations or the files in Shared/frdhog/mesh/ ProcessObjMesh To simply load in a mesh with one callback you can do something like the following
ProcessObjToVerts You can use ProcessObjToVerts for a shorter version of ProcessObjMesh with onlyMeshVerts enabled. This may be useful if you want to join multiple OBJs into one IMesh.
Within a timer or a render hook, Probably in a timer, create mesh if meshCount == 2
Note, the processing will not be run in any logical order.ParseObjToMesh If your mesh is small and your quota is kickin', you can use the inline ParseObjToMesh. This example also includes how to draw using a HUD in 3D space
Other notes This takes into account normals and UVs, so if materials are facing the wrong direction then double check your 3D model If processing is running out of time quota, then reduce the global _wavefront_cpuLimit to below 0.6 (meaning 60%) before processing Please tell me if you get any errors or unexpected behaviour. I will likely ignore errors that include time quota and ParseObjToMesh |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)