0

I'm learning UE4 C++ Development and I have a idea but I don't know if that is possible to make. I have a folder on my WAMP SERVER for exemplo ( C:\wamp\www\staticmesh\My3DModel.3DS ). My idea is create a button on my UE4 widget and when It's pressed it import my Static Mesh from my folder to my currently scene. It's possible ?

OBS: because my game will be too heavy, so I thought I would import the static meshs and put in the scene in real time, without building next to the game. If you know another solution or any idea it will be welcome. **

Would Somebody be willing to helping me step by step How could I implementing that code below ? It's very very important to me, because I'm learning UE4 C++.

// Load Static Mesh From Path 
static FORCEINLINE UStaticMesh* LoadMeshFromPath(const FName& Path)
{
    if(Path == NAME_None) return NULL;
    //~

    return LoadObjFromPath<UStaticMesh>(Path);
}

enter image description here

Thank you so much for any answer.

Colin Basnett
  • 4,052
  • 2
  • 30
  • 49
Desenvolvedor
  • 95
  • 1
  • 4

2 Answers2

1

You are asking a bit much if all you did yet is draw that sketch. If you did more already please share the information.

I recently answered what I could identify as core part of your question tho - how to get the mesh from local drive into ue4 -

https://stackoverflow.com/a/41753091/5196012

This also features the link to the wiki where your code sample seems to come from.

You are missing the template the person has on the wiki

//TEMPLATE Load Obj From Path
template <typename ObjClass>
static FORCEINLINE ObjClass* LoadObjFromPath(const FName& Path)
{
    if(Path == NAME_None) return NULL;
    //~

      return Cast<ObjClass>(StaticLoadObject( ObjClass::StaticClass(), NULL,*Path.ToString()));
}

Since no one knows what selectionstrategy you have I guess it will be some standard file browser dialog returning a file handle...

All you would need to do then is to call your function in the widget button "on pressed" event.

Community
  • 1
  • 1
t0b4cc0
  • 319
  • 4
  • 19
0

OBS: because my game will be too heavy, so I thought I would import the static meshs and put in the scene in real time, without building next to the game.

That is not possible. The moment you import a static mesh it will be saved as a .uasset file in your content folder. How big are your meshes and how small is your disk that you cannot import them?

If you absolutely do not want to import any assets you can generate your meshes at runtime with this plugin: https://www.unrealengine.com/marketplace/runtime-mesh-component Note however that you lose a lot of extra goodies and optimizations with that approach.

TheBrain
  • 597
  • 6
  • 12
  • 2
    +1...UE can't do things like runtime-importing raw mesh resources, the process of converting raw resource to unreal asset, setting up reference for the asset and finally loading it in game is extremely complicated. – Marson Mao Feb 02 '17 at 02:29
  • Unless the widget OP talking about is used in editor environment, but I guess OP's "runtime" refers to gameplay runtime. – Marson Mao Feb 02 '17 at 02:30