Importing .obj/.fbx models at runtime for use in a ingame level editor

Hi everyone,

I am building a Train Simulator game in unreal engine where i want to create a level editor.
I made a script in blueprint that allows me to place object where i click so that works.
But the user could only place models that i included with the game.
Now i want to enable the user to create a model in for example, Blender and enable them to import it in the game and create a level.
I want the user to be able to import several models and allow the user to place multiple of each model(depending on which model they pick from the list and on how many places they click to place a model).
Then the user should be able to save the level, so i need a way to save that model for futher use when the game should load.(but i think i can figure this part out myself)

Now my problem is is that i dont know how to import an object in unreal engine at runtime.
I think it can be done with assimp and Runtime Mesh Component plugins, but i dont knnow how to combine these 2 to make it work.
Also i need help with saving models, as i think loading a 50k verticles(e.g. a train) .obj will be quite slow, so i need a way to save it that makes it load faster i think as it takes 20 min to load a train model in unreal using the import button(But tell me if i am wrong about the slow loading thing).

So can anyone help me with this?(importing an obj and saving it for later use in a level)
Also i am quite new to unreal engine, i come from unity3d where the asset store was full of runtime model importers.

I hope anyone can help,

Thanks in advance

2 Likes

The game doesn’t contain any way of importing those formats, you’d have to code your own file import option.

Yes i know, thats why i’m asking :wink:
In order to write it myself i think i can use assimp(a obj and other model formats importer) and use Runtime Mesh Component to put it in the scene.
But i need help combining these 2.
Anyone can help me with that?
Maybe this is smoething:? GitHub - LaP0573/ue4-fbx-importer
But i dont know how to use it.

Or does anyone know of something that does this?

It was already mentioned on forums along with working example, you obviously did no search for it at all… try to search forums a bit before posting new topics as most of things was already answered. Cheers.

Well, can you point me to that post then?
Ionly found this on github:

But seems to crash with almost every model.
And i realy did search for like a whole day.

edit:
[USER=“316872”]Vertex Soup[/USER] i saw you replyed to that runtime mesh loader plugin i linked to, have you used it?
And how does it work for you?
Almost every model i tryed with it crashes unreal engine with a tryed to read or write to protected error and i need to restart unreal.

2 Likes

Im currently trying to do something very similar, all ive found is either “Create an importer yourself” which i do not believe i am knowledgeable enough to accomplish, or ive seen a couple people asking where the maker of “RuntimeMeshLoader” tells them to use his plugin. However i can not find any sort of examples of it being used, how to use it or any form of documentation, so im kind of stuck.

My goal is to be able to run my ‘Game’ and import a 3D model, place it in my level and then be able to do some maths like measuring the distance between two given coordinates on that model. (These are things im fairly certain i can manage, however i cant seem to import a model to even get started doing this)

When i open the “MeshLoader” in Unreal i see that there are errors in my blueprint, if anyone has any idea on how to get this working maybe that would be helpful for both @lalala312 and myself.

This is what i get after adding the plugin to my plugins folder, fixing the module rules since 4.15 you apparently want “ReadOnlyTargetRules”, opening the blueprint and this is what im presented with.


Im guessing this is due to some recent change in Unreal, I am new to Unreal so i havent got that much experience with it just yet, however i have done some programming in the past, ive taken 2 Java courses and i do know quite a lot of PHP, SQL, JavaScript, HTML, CSS for web development. However i have not work much with C++ before but i made a simple guessing game using classes and stuff to get started.

What ive tried doing is add an Array Ref “Get(a ref)” to then be able to connect them together, however when i compile i cant seem to find the model, ive placed my “teapot.obj” file in the Content folder and set the Type to relative. I dont know if i actually want to link up the “Num Meshes” to the Get, however if i leave it be it doesnt make any difference.

Any help would be appreciated and im sure it would help the creator of the topic who has also had some problems getting it to work.

[USER=“316872”]Vertex Soup[/USER] Also where would i find this, ive legit spent the past 2 days trying to figure this out, all i find is people having problems importing files, but none has any working solution apart from “make your own importer”, if youd be able to point me to one of those topics where this have been answered so i can get it working in my project id be very greatful.

I had the same problem but solved it in this issue:
https://github.com/GameInstitutes/Ru…oader/issues/5
The problem i had that i posted here was related to a bit of a mess in my code, wich crashed unreal when i wanted to load a mesh.
But it isnt completely resolved then, i found that the Num Meshes output on Break Returndata always outputs 0, so only the first part of you model is loaded.(witch is probably why you cant find it)
I resolved this, but it doesnt work perfectly yet, but with a little c++ and assimp knowledge(or just google) you can figure it out.
If you need help you can ask.

But basicly you need to take the value from a variable that should already be used somewhere otherwise it cant read the meshes, and then set that as the return value in ReturnData.
BTW, i am also almost finished adding texture support to it, may you need it i think i can release it(but i dont know when).(i can also guide you on how to do it)

edit:
Oh and with what [USER=“316872”]Vertex Soup[/USER] said about you have to search:
He actually meant the Runtime Mesh Loader plugin(he has commented in that post).
So yeah…

So in the end did you find a solution or a way to import a 3D files into the game via a menu? Because i’m trying to to something like you did but i have no idea where to start. I try to download the runtime mesh loader plugin but it just won’t work with my unreal engine for some reason. I tried to fix it by reinstalling Visual studio and windows SDK and rebuilding the whole project but it just won’t work. Do you have any idea how you did it or point me in the right direction.

Thanks

When you break the return value of LoadMesh() down, it was an integer indicates how many meshes are in the file, and an array of meshInfo stores essential information of each mesh. One can not pass an array to a slot where a single meshInfo is expected, of course, so what @anonymous_user_4263356a did to insert a Get() node was on the correct direction. But what he did wrong was he pass a wrong index to the Get() operation. Languages derived from C usually made their array indexed from 0, that is, if you visit an array “arr” of length “n”, “arr[0]” names the first element, “arr[n-1]” reference the last, and “arr[n]” is always invalid. So change the value of the Get() node to anywhere between 0 and n-1 would partially work.

The other point is that since a file may contain multiple meshes, you should travesal them to get the whole model, or you may end up getting only one arm or one leg. You must exploit all the meshes, and combine them together in some way(relative transform thus need to be used). The total work is more difficult than it seems.

I know that this is an old question, and people who had this question may either managed to solve it or give it up. But considering there may be someone like me visit here by searching on google in the future, I decide to post this and save their time, just like @anonymous_user_4263356a 's post had greatly inspired me and saved my time.

2 Likes