Announcement

Collapse
No announcement yet.

Generate Procedural Mesh

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

    Generate Procedural Mesh

    Anyone know how to make a mesh from vertices and triangles, attach it to an object and spawn it?

    I looked into FDynamicMeshBuilder, but that's only for drawing.
    Dejan Macesic, ing., MBA | Founder | Base64 Inc.

    It is by will alone I set my code in motion.
    It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
    It is by will alone I set my code in motion.

    #2
    There is a CustomMeshComponent, and you fill it with a CustomMeshTriangle array. I have had no luck finding a way to properly apply materials to these however (unless its just a base color).

    Comment


      #3
      CustomMeshComponent derives from MeshComponent, which has a Materials array and a SetMaterial function, that should work. CustomMeshComponent currently only have a single material section. Note that CMC is really an example of how to create your own geometry, you may want to create your own component class so you can get full control over UVs, tangents, sections etc.
      Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
      Twitter: @EpicJamesG

      Comment


        #4
        Thanks for clarifying James. I had only recently found the CMC and had only tinkered around with it in blueprints. Nice to get confirmation on it's intended purpose.

        Comment


          #5
          I would actually like to do a bit more work on it and allow BP authors to specify more geometry information . I love the idea of procedural geometry
          Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
          Twitter: @EpicJamesG

          Comment


            #6
            Is there a performance hit when using dynamically created geometry rather than regular static mesh?
            Point Cloud Plugin: Project Website | Forum Thread | Roadmap

            If you need help: join me on Discord
            Please support me on Patreon if you enjoy my content

            Comment


              #7
              Thanks for the feedback. Can anyone share a bit of code that shows object creation, CustomMeshComponent attach, vertex and triangle assignment, and then spawn?
              Dejan Macesic, ing., MBA | Founder | Base64 Inc.

              It is by will alone I set my code in motion.
              It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
              It is by will alone I set my code in motion.

              Comment


                #8
                Originally posted by JamesG View Post
                I would actually like to do a bit more work on it and allow BP authors to specify more geometry information . I love the idea of procedural geometry
                I suspect many of us developers love the idea of procedural geometry as well. Looking forward to what you come up with!

                Comment


                  #9
                  Ill see if i can find some time, and port my voxel engine code to a custom mesh ( total ****, but creates the cube meshes from 3 dimensional array), and make a tutorial of it.
                  UDK and UE4 programmer and Unreal engine 4 betatester. Currently working on commercial VR games for PSVR.
                  Deep knowlegde of C++ and blueprints. Open to freelance work.
                  Games released, Deathwave(Steam), VRMultigames(Steam), DWVR(Steam,Oculus,PSVR):
                  http://store.steampowered.com/app/463870
                  http://store.steampowered.com/app/500360
                  http://store.steampowered.com/app/520750

                  Comment


                    #10
                    Originally posted by vblanco View Post
                    Ill see if i can find some time, and port my voxel engine code to a custom mesh ( total ****, but creates the cube meshes from 3 dimensional array), and make a tutorial of it.
                    That would be awesome. In the meantime I've hit a snag if anyone know a quick solution. I've created an Actor class setting a UCustomMeshComponent as RootComponent, but I am getting link errors:

                    Code:
                    1>------ Build started: Project: MyProject5, Configuration: Development_Editor x64 ------
                    1>  Parsing headers for MyProject5Editor
                    1>  Code generation finished for MyProject5Editor and took 1.71
                    1>  link.exe UE4Editor-MyProject5.dll
                    1>     Creating library C:\dev\Unreal\Projects\MyProject5\Intermediate\Build\Win64\MyProject5Editor\Development\UE4Editor-MyProject5.lib and object C:\dev\Unreal\Projects\MyProject5\Intermediate\Build\Win64\MyProject5Editor\Development\UE4Editor-MyProject5.exp
                    1>GameGeneratedActor.cpp.obj : error LNK2019: unresolved external symbol "private: static class UClass * __cdecl UCustomMeshComponent::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@UCustomMeshComponent@@CAPEAVUClass@@PEB_W@Z) referenced in function "public: class UCustomMeshComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UCustomMeshComponent,class UCustomMeshComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUCustomMeshComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUCustomMeshComponent@@PEAVUObject@@VFName@@_N22@Z)
                    1>GameGeneratedActor.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl UCustomMeshComponent::SetCustomMeshTriangles(class TArray<struct FCustomMeshTriangle,class FDefaultAllocator> const &)" (?SetCustomMeshTriangles@UCustomMeshComponent@@QEAA_NAEBV?$TArray@UFCustomMeshTriangle@@VFDefaultAllocator@@@@@Z) referenced in function "public: __cdecl AGameGeneratedActor::AGameGeneratedActor(class FPostConstructInitializeProperties const &)" (??0AGameGeneratedActor@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)
                    1>C:\dev\Unreal\Projects\MyProject5\Binaries\Win64\UE4Editor-MyProject5.dll : fatal error LNK1120: 2 unresolved externals
                    1>  -------- End Detailed Actions Stats -----------------------------------------------------------
                    1>ERROR : UBT error : Failed to produce item: C:\dev\Unreal\Projects\MyProject5\Binaries\Win64\UE4Editor-MyProject5.dll
                    1>  Cumulative action seconds (8 processors): 0.00 building projects, 0.00 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.10 linking, 0.00 other
                    1>  UBT execution time: 4.27 seconds
                    1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Unreal Engine\4.0\Engine\Build\BatchFiles\Build.bat" MyProject5Editor Win64 Development "C:\dev\Unreal\Projects\MyProject5\MyProject5.uproject" -rocket" exited with code -1.
                    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
                    This is my Build.cs setup, what am I missing?

                    Code:
                    using UnrealBuildTool;
                    
                    public class MyProject5 : ModuleRules
                    {
                    	public MyProject5(TargetInfo Target)
                    	{
                    		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
                    
                                    PrivateDependencyModuleNames.AddRange(new string[] { "CustomMeshComponent" });
                                    PrivateIncludePathModuleNames.AddRange(new string[] { "CustomMeshComponent" });
                    
                                    MinFilesUsingPrecompiledHeaderOverride = 1;
                                    bFasterWithoutUnity = true;
                    
                    	}
                    }
                    Dejan Macesic, ing., MBA | Founder | Base64 Inc.

                    It is by will alone I set my code in motion.
                    It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                    It is by will alone I set my code in motion.

                    Comment


                      #11
                      As a workaround, I re-implemented CustomMeshComponent in the project and had to add RHI, RenderCore and ShaderCore as dependencies, and it compiled. And now to see if this works...
                      Dejan Macesic, ing., MBA | Founder | Base64 Inc.

                      It is by will alone I set my code in motion.
                      It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                      It is by will alone I set my code in motion.

                      Comment


                        #12
                        Tadaa, from a simple lathe routine:



                        I just uses my HUD blueprint to call SpawnActor and specify my class. Now to continue my experiments...
                        Last edited by dmacesic; 11-28-2014, 01:48 PM.
                        Dejan Macesic, ing., MBA | Founder | Base64 Inc.

                        It is by will alone I set my code in motion.
                        It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                        It is by will alone I set my code in motion.

                        Comment


                          #13
                          Impressive work, man. Will you make a tutorial on how to set that up?
                          UDK and UE4 programmer and Unreal engine 4 betatester. Currently working on commercial VR games for PSVR.
                          Deep knowlegde of C++ and blueprints. Open to freelance work.
                          Games released, Deathwave(Steam), VRMultigames(Steam), DWVR(Steam,Oculus,PSVR):
                          http://store.steampowered.com/app/463870
                          http://store.steampowered.com/app/500360
                          http://store.steampowered.com/app/520750

                          Comment


                            #14
                            Originally posted by vblanco View Post
                            Impressive work, man. Will you make a tutorial on how to set that up?
                            *looking at the picture* ... Only coders will understand!

                            Comment


                              #15
                              Originally posted by vblanco View Post
                              Impressive work, man. Will you make a tutorial on how to set that up?
                              Aha! You guys didn't notice my normals were inverted... (Unreal seems to like clockwise vertices) I will share my code on the wiki to get you started with quick and dirty instructions, although it will not be to Rama-sama standards I'll post here when it's up.

                              Here's another with more segments and proper normals:

                              Last edited by dmacesic; 11-28-2014, 01:48 PM.
                              Dejan Macesic, ing., MBA | Founder | Base64 Inc.

                              It is by will alone I set my code in motion.
                              It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                              It is by will alone I set my code in motion.

                              Comment

                              Working...
                              X