Announcement

Collapse
No announcement yet.

Runtime Mesh Component

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hi!
    I've some problems with the "URuntimeMeshLibrary::CalculateTangentsForMesh" function...

    I have each variables declared as below:

    TArray<int32> Triangles;
    TArray<FVector2D> UV0;
    TArray<FVector> Normals;
    TArray<FRuntimeMeshTangent> Tangents;
    TArray<FColor> VertexColors;

    // code to fill the arrays

    URuntimeMeshLibrary::CalculateTangentsForMesh(Vertices, Triangles,UV0, Normals, Tangents);

    when I call the method to calculate tangents and normals the engine chash, and I get this error.

    Assertion failed: UV1s && UV1s->Num() > CurrentPosition [File:d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\public\RuntimeMeshBuilder.h] [Line: 786]



    KERNELBASE
    UE4Editor_Core
    UE4Editor_Core
    UE4Editor_Core
    UE4Editor_RuntimeMeshComponent!FRuntimeMeshComponentVerticesBuilder::GetUV() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\public\runtimemeshbuilder.h:787]
    UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::CalculateTangentsForMesh() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\private\runtimemeshlibrary.cpp:243]
    UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::CalculateTangentsForMesh() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\private\runtimemeshlibrary.cpp:328]
    UE4Editor_Mockingbird_9502!ASimpleTerrainGeneration::GenerateMesh() [c:\agus\projects\tesis\prototipo\mockingbird\source\mockingbird\private\terraingenerators\simpleterraingeneration.cpp:139]
    UE4Editor_Engine
    UE4Editor_Engine
    UE4Editor_Engine
    UE4Editor_Engine
    UE4Editor_Engine
    UE4Editor_Engine
    UE4Editor_UnrealEd
    UE4Editor_UnrealEd
    UE4Editor_UnrealEd
    UE4Editor_UnrealEd
    UE4Editor_UnrealEd
    UE4Editor
    UE4Editor
    UE4Editor
    UE4Editor
    UE4Editor
    kernel32
    ntdll

    Anyone can helpme?

    Comment


      Hi!
      I've some problems with the "URuntimeMeshLibrary::CalculateTangentsForMesh" function...

      I have each variables declared as below:

      TArray<int32> Triangles;
      TArray<FVector2D> UV0;
      TArray<FVector> Normals;
      TArray<FRuntimeMeshTangent> Tangents;
      TArray<FColor> VertexColors;

      // code to fill the arrays

      URuntimeMeshLibrary::CalculateTangentsForMesh(Vertices, Triangles,UV0, Normals, Tangents);

      when I call the method to calculate tangents and normals the engine chash, and I get this error.

      Assertion failed: UV1s && UV1s->Num() > CurrentPosition [File:d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\public\RuntimeMeshBuilder.h] [Line: 786]



      KERNELBASE
      UE4Editor_Core
      UE4Editor_Core
      UE4Editor_Core
      UE4Editor_RuntimeMeshComponent!FRuntimeMeshComponentVerticesBuilder::GetUV() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\public\runtimemeshbuilder.h:787]
      UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::CalculateTangentsForMesh() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\private\runtimemeshlibrary.cpp:243]
      UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::CalculateTangentsForMesh() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\private\runtimemeshlibrary.cpp:328]
      UE4Editor_Mockingbird_9502!ASimpleTerrainGeneration::GenerateMesh() [c:\agus\projects\tesis\prototipo\mockingbird\source\mockingbird\private\terraingenerators\simpleterraingeneration.cpp:139]
      UE4Editor_Engine
      UE4Editor_Engine
      UE4Editor_Engine
      UE4Editor_Engine
      UE4Editor_Engine
      UE4Editor_Engine
      UE4Editor_UnrealEd
      UE4Editor_UnrealEd
      UE4Editor_UnrealEd
      UE4Editor_UnrealEd
      UE4Editor_UnrealEd
      UE4Editor
      UE4Editor
      UE4Editor
      UE4Editor
      UE4Editor
      kernel32
      ntdll

      Anyone can helpme?

      Comment


        Originally posted by housekiller View Post
        I'm generating normals with assimp but it doesn't change much in execution speed, I also have collision enabled but would like to leave that on and doesn't make much of a change in speed either. Later on I'll be working with bigger models so I'm looking into doing the conversion to another thread.

        I have a couple of questions though about other stuff;
        -How can I convert to a normal static mesh if possible? Does it create a .uasset file? (so it doesn't need to be imported every time)
        -How are you thinking to handle replication over network? (via conversion to static mesh and copying the asset to clients or something?)

        -I'm having trouble to create physics enabled objects, I use the following code to create an object that should have a lot of 'drag' but it moves at constant speed when receiving a push.

        Code:
        RuntimeMesh->CreateMeshSection(0, vertices, triangles, normals, texMap, vertexColors, tangents, true, EUpdateFrequency::Infrequent);
        
        	RuntimeMesh->SetMaterial(0, MeshMaterial);
        	RuntimeMesh->SetMobility(EComponentMobility::Movable);
        	RuntimeMesh->SetLinearDamping(100.f);
        	RuntimeMesh->SetAngularDamping(100.f);
        	RuntimeMesh->SetSimulatePhysics(true);
        	RuntimeMesh->SetEnableGravity(false);
        	RuntimeMesh->SetLockedAxis(EDOFMode::XYPlane);
        SetLinearDamping(100.f) and SetAngularDamping(100.f) are correctly set on the mesh but it seems to be ignored.

        I donated around 10 bucks, happy to support

        EDIT:
        It works when disabling bUseComplexAsSimpleCollision, is it possible/legal to make the engine calculate a convex hull at runtime? (I'll probably write my own algorithm anyway but would be handy for now).

        EDIT2:
        I cleaned up some debugging which decreased the duration a 10-fold.

        Thanks for the donation!

        You can convert to a static mesh by selecting the RMC in editor and finding "Convert to Static Mesh" in the details panel. This will only work in editor.

        It's been a while since I've put much thought into replication, but you can't do conversion to static mesh at runtime, and even then the SMC does support replicating the mesh either. I've had a few thoughts on how to do it, but I've not really dug into it as you're talking replicating potentially MB's of mesh data and it usually ends up being better for the app to do it's own replication. In the case of voxel, it's easier to replicate the voxel data and regenerate the mesh on the client for example. Other projects have similar ways to more efficiently get the needed parts to client/server than straight mesh replication.

        From your edits it appears you found the problem to movable objects. Basically PhysX (the underlying physics engine) doesn't support dynamic moving triangle meshes. They work well for static objects, but for dynamic you have to use an approximation of the object through some combination of convex hulls, cubes, spheres, and capsules. Currently the RMC only supports convex hulls but that will be changed in the future. I'm investigating ways to generate this at runtime, but there isn't an easy solution to this.
        Runtime Mesh Component - The best way to render procedural/runtime created meshes! - Version 4.1 out now!

        Come talk about anything RMC or Procedural Mesh Related in our Discord!

        Comment


          Hi Koderz,

          i have downloaded your project and I can't run.

          RMC_Examples could not be compiled. Try rebuilding from source manually.

          Comment


            Originally posted by Koderz View Post
            Thanks for the donation!

            You can convert to a static mesh by selecting the RMC in editor and finding "Convert to Static Mesh" in the details panel. This will only work in editor.
            So not available/legal in built application?

            Originally posted by Koderz View Post
            It's been a while since I've put much thought into replication, but you can't do conversion to static mesh at runtime, and even then the SMC does support replicating the mesh either. I've had a few thoughts on how to do it, but I've not really dug into it as you're talking replicating potentially MB's of mesh data and it usually ends up being better for the app to do it's own replication. In the case of voxel, it's easier to replicate the voxel data and regenerate the mesh on the client for example. Other projects have similar ways to more efficiently get the needed parts to client/server than straight mesh replication.
            It's meant to run on local network only for now so size is practically no problem, for now I'll share the files between server & clients, import on both and replicate the transforms with necesary logic checks as a quick fix.
            Interesting ideas for voxel based meshes, I'm planning a project on the side where this will be relevant.

            Originally posted by Koderz View Post
            From your edits it appears you found the problem to movable objects. Basically PhysX (the underlying physics engine) doesn't support dynamic moving triangle meshes. They work well for static objects, but for dynamic you have to use an approximation of the object through some combination of convex hulls, cubes, spheres, and capsules. Currently the RMC only supports convex hulls but that will be changed in the future. I'm investigating ways to generate this at runtime, but there isn't an easy solution to this.
            For now I made a simple box hull which is enough for my current project, might make something more complex as the need arises.

            Comment


              Originally posted by Tomza View Post
              Hi Koderz,

              i have downloaded your project and I can't run.

              RMC_Examples could not be compiled. Try rebuilding from source manually.
              Hey, I just updated the Examples to UE4.13 and RMC v2.0. This is just for a temporary solution until I get the new examples project done. You can find that here: https://github.com/Koderz/UE4Runtime...eases/tag/v2.0





              Originally posted by housekiller View Post
              So not available/legal in built application?



              It's meant to run on local network only for now so size is practically no problem, for now I'll share the files between server & clients, import on both and replicate the transforms with necesary logic checks as a quick fix.
              Interesting ideas for voxel based meshes, I'm planning a project on the side where this will be relevant.



              For now I made a simple box hull which is enough for my current project, might make something more complex as the need arises.

              Unfortunately, creating a static mesh component requires some editor only modules that can't be linked into a package game. Out of curiosity, why is it you're wanting to convert them to a static mesh? What files are you talkinga bout sharing between the server/client? If you really don't care about bandwidth, probably the easiest way is to stay within the RMC and use the SerializeRMC() or SerializeRMCSection() functions. With those you setup an FArchive to either load or save and just call that function (it loads/saves based on what the FArchive is setup to do) So you could probably just to a memory archive, serialize it to that, send the data across and feed the archive back into the RMC on the other side. It's not going to be light on bandwidth but within a LAN you're probably OK.
              Runtime Mesh Component - The best way to render procedural/runtime created meshes! - Version 4.1 out now!

              Come talk about anything RMC or Procedural Mesh Related in our Discord!

              Comment


                Originally posted by Koderz View Post
                Hey, I just updated the Examples to UE4.13 and RMC v2.0. This is just for a temporary solution until I get the new examples project done. You can find that here: https://github.com/Koderz/UE4Runtime...eases/tag/v2.0



                Unfortunately, creating a static mesh component requires some editor only modules that can't be linked into a package game. Out of curiosity, why is it you're wanting to convert them to a static mesh? What files are you talkinga bout sharing between the server/client? If you really don't care about bandwidth, probably the easiest way is to stay within the RMC and use the SerializeRMC() or SerializeRMCSection() functions. With those you setup an FArchive to either load or save and just call that function (it loads/saves based on what the FArchive is setup to do) So you could probably just to a memory archive, serialize it to that, send the data across and feed the archive back into the RMC on the other side. It's not going to be light on bandwidth but within a LAN you're probably OK.

                Great! I will try it out.

                To be sure, can your meshes be saved in Editor or exported as FBX, OBJ, etc? And then imported, for example. All at runtime, without Editor. I need a feature where it is possible. For example, the mesh is created, changed, saved, exported, then imported, changed, saved, etc.

                Comment


                  Originally posted by Tomza View Post
                  Great! I will try it out.

                  To be sure, can your meshes be saved in Editor or exported as FBX, OBJ, etc? And then imported, for example. All at runtime, without Editor. I need a feature where it is possible. For example, the mesh is created, changed, saved, exported, then imported, changed, saved, etc.
                  I'm not quite sure what you're trying to do but... UE4 doesn't support importing static meshes at runtime (they're basically un-editable at runtime), which is also why the RMC can't convert to a static mesh at runtime since it uses the import pipeline. You can load/save meshes out to things like fbx/obj with something like Assimp but there's not a built in way to do this yet.
                  Runtime Mesh Component - The best way to render procedural/runtime created meshes! - Version 4.1 out now!

                  Come talk about anything RMC or Procedural Mesh Related in our Discord!

                  Comment


                    Originally posted by Koderz View Post
                    Unfortunately, creating a static mesh component requires some editor only modules that can't be linked into a package game. Out of curiosity, why is it you're wanting to convert them to a static mesh? What files are you talkinga bout sharing between the server/client? If you really don't care about bandwidth, probably the easiest way is to stay within the RMC and use the SerializeRMC() or SerializeRMCSection() functions. With those you setup an FArchive to either load or save and just call that function (it loads/saves based on what the FArchive is setup to do) So you could probably just to a memory archive, serialize it to that, send the data across and feed the archive back into the RMC on the other side. It's not going to be light on bandwidth but within a LAN you're probably OK.
                    I was hoping converting to a static mesh would take away the limitations of procedural meshes and/or allow for saving or replication. I'll either serialize or simply share .fbx files or the like between server-client.

                    Originally posted by Tomza View Post
                    Great! I will try it out.

                    To be sure, can your meshes be saved in Editor or exported as FBX, OBJ, etc? And then imported, for example. All at runtime, without Editor. I need a feature where it is possible. For example, the mesh is created, changed, saved, exported, then imported, changed, saved, etc.
                    With the same data used for making a procedural mesh, you can make an OBJ/FBX/... file via a c++ library like assimp, which you can import at later times. A more direct and existing way has been done by Rama: https://www.unrealengine.com/marketp...ma-save-system

                    Comment


                      Originally posted by housekiller View Post
                      I was hoping converting to a static mesh would take away the limitations of procedural meshes and/or allow for saving or replication. I'll either serialize or simply share .fbx files or the like between server-client.
                      Well static meshes don't have any replication capabilities of the mesh data. They assume the mesh itself already exists with the game install on both server and client. The RMC has support for natively saving itself, but it's a custom format meant to quickly load/save itself, not a full interchange format like OBJ.

                      Are there any other limitations of the RMC when compared to the StaticMeshComponent that you're hoping for?
                      Runtime Mesh Component - The best way to render procedural/runtime created meshes! - Version 4.1 out now!

                      Come talk about anything RMC or Procedural Mesh Related in our Discord!

                      Comment


                        I downloaded the big zipped folder (https://github.com/Koderz/UE4Runtime...eases/tag/v2.0) and run the project. What to do know? Where's the cut mesh feature? Do you have any movie on Youtube.?

                        Comment


                          Can anybody advice me on how to do a proper lighting with the runtime mesh component without taking a performance hit? I am unable to maintain 90fps in a oculus rift with Geforce 1070 after I turn on dynamic lights and shadows from a single directed light source with a very simple scene - an apartment with 2-3 rooms, where every room is an actor with 3 subComponents - floor, ceiling and walls - all of them are a single RuntimeMeshComponent, although the walls component has many different sections - 4 to 30, depending on the room topology, every section is a flat surface though. My meshes are procedurally generated once at a startup from a text file and never touched afterwards.
                          Click image for larger version

Name:	ue_Screenshot_2.png
Views:	1
Size:	142.4 KB
ID:	1120076
                          Click image for larger version

Name:	Screenshot_tree.png
Views:	1
Size:	18.5 KB
ID:	1120079
                          Attached Files
                          Last edited by Mtimofeev; 12-19-2016, 05:18 PM.

                          Comment


                            Just came across an Editor Crash related to CopyRuntimeMeshFromStaticMeshComponent Blueprint Node.

                            I run the node within the construction script. When the Input StaticMeshComp is empty the editor crashes.

                            Access violation - code c0000005 (first/second chance not available)

                            UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::CopyRuntimeMeshFromStaticMeshComponent() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\private\runtimemeshlibrary.cpp:470]
                            UE4Editor_RuntimeMeshComponent!URuntimeMeshLibrary::execCopyRuntimeMeshFromStaticMeshComponent() [d:\build\++portal+main+full\sync\localbuilds\plugintemp\hostproject\plugins\runtimemeshcomponent\source\runtimemeshcomponent\public\runtimemeshlibrary.h:14]
                            UE4Editor_CoreUObject!UFunction::Invoke() [d:\build\++ue4+release-4.14+compile\sync\engine\source\runtime\coreuobject\private\uobject\class.cpp:4474]
                            UE4Editor_CoreUObject!UObject::CallFunction() [d:\build\++ue4+release-4.14+compile\sync\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:700]
                            UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [d:\build\++ue4+release-4.14+compile\sync\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2139]
                            UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\build\++ue4+release-4.14+compile\sync\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:925]



                            regards
                            NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                            Comment


                              Originally posted by Koderz View Post
                              Well static meshes don't have any replication capabilities of the mesh data. They assume the mesh itself already exists with the game install on both server and client. The RMC has support for natively saving itself, but it's a custom format meant to quickly load/save itself, not a full interchange format like OBJ.

                              Are there any other limitations of the RMC when compared to the StaticMeshComponent that you're hoping for?
                              The main limitation is that I have to adjust older code of my own that doesn't take procedural meshes into account.
                              I have implemented replication based on the system I already had but it's for static objects only atm. I'll look into replication of completely dynamic meshes later, I have much to learn still about the programming side of it but the idea is pretty solid and very do-able.

                              Originally posted by Mtimofeev View Post
                              Can anybody advice me on how to do a proper lighting with the runtime mesh component without taking a performance hit? I am unable to maintain 90fps in a oculus rift with Geforce 1070 after I turn on dynamic lights and shadows from a single directed light source with a very simple scene - an apartment with 2-3 rooms, where every room is an actor with 3 subComponents - floor, ceiling and walls - all of them are a single RuntimeMeshComponent, although the walls component has many different sections - 4 to 30, depending on the room topology, every section is a flat surface though. My meshes are procedurally generated once at a startup from a text file and never touched afterwards.
                              Have you tried the difference with normal imported movable static meshes? Try optimizing such a scene first for VR performance, it's not an easy feat making a game perform well in VR while still looking good.
                              I'm finding performance with procedural meshes to be surprisingly good but having lots of dynamic lights and objects will always be hard on the GPU and is not necessarily linked to procedural meshes (rather to all dynamic objects).
                              Last edited by housekiller; 12-15-2016, 08:03 AM.

                              Comment


                                Originally posted by housekiller View Post
                                The main limitation is that I have to adjust older code of my own that doesn't take procedural meshes into account.
                                I have implemented replication based on the system I already had but it's for static objects only atm. I'll look into replication of completely dynamic meshes later, I have much to learn still about the programming side of it but the idea is pretty solid and very do-able.



                                Have you tried the difference with normal imported movable static meshes? Try optimizing such a scene first for VR performance, it's not an easy feat making a game perform well in VR while still looking good.
                                I'm finding performance with procedural meshes to be surprisingly good but having lots of dynamic lights and objects will always be hard on the GPU and is not necessarily linked to procedural meshes (rather to all dynamic objects).
                                I appreciate your reply. A similar scene with imported static mesh gives me steady 120+ fps. My scene is really very simple - it is just few rooms: walls, floors and ceilings, a single source of light (the sky light) and I'd assume there should be a way to get 90fps. What I think could be problematic is that every room is currently an actor with single RuntimeMeshComponent that consists of a large number of sections. I have mistyped it in my OP, the RuntimeMeshComponent is rather constituted by 40-120 sections. But there are only 4-8 such components in the whole scene. Can this be a problem? Would it be better if these sections were instead separate actors? I absolutely need to be able to apply a material separately to each of the sections, so I either have to make them RuntimeMeshComponent sections or separate actors.

                                Comment

                                Working...
                                X