Announcement

Collapse
No announcement yet.

Generate Procedural Mesh

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

    #31
    I'm trying to confirm this, but I'm getting a bunch on link errors on cook (works fine in editor), investigating. E.g.

    Code:
    LogPlayLevel:Display: UnrealBuildTool:    Creating library C:\dev\Unreal\Projects\MyProject5\Binaries\Win64\MyProject5.lib and object C:\dev\Unreal\Projects\MyProject5\Binaries\Win64\MyProject5.exp
    LogPlayLevel:Display: UnrealBuildTool: MyProject5.h.obj : warning LNK4217: locally defined symbol ??0FName@@QEAA@PEBDW4EFindName@@_N@Z (public: __cdecl FName::FName(char const *,enum EFindName,bool)) imported in function "void __cdecl `dynamic initializer for 'NAME_DeviceType''(void)" (??__ENAME_DeviceType@@YAXXZ)
    LogPlayLevel:Display: UnrealBuildTool: GameHUD.cpp.obj : warning LNK4049: locally defined symbol ??0FName@@QEAA@PEBDW4EFindName@@_N@Z (public: __cdecl FName::FName(char const *,enum EFindName,bool)) imported
    LogPlayLevel:Display: UnrealBuildTool: MyProject5.h.obj : warning LNK4049: locally defined symbol ?ZeroVector@FVector@@2V1@B (public: static class FVector const FVector::ZeroVector) imported
    LogPlayLevel:Display: UnrealBuildTool: GameHUD.cpp.obj : warning LNK4049: locally defined symbol ?ZeroVector@FVector@@2V1@B (public: static class FVector const FVector::ZeroVector) imported
    LogPlayLevel:Display: UnrealBuildTool: GeneratedMeshComponent.cpp.obj : warning LNK4049: locally defined symbol ?ZeroVector@FVector@@2V1@B (public: static class FVector const FVector::ZeroVector) imported
    LogPlayLevel:Display: UnrealBuildTool: MyProject5PlayerController.cpp.obj : warning LNK4049: locally defined symbol ?ZeroVector@FVector@@2V1@B (public: static class FVector const FVector::ZeroVector) imported
    LogPlayLevel:Display: UnrealBuildTool: MyProject5PlayerController.cpp.obj : warning LNK4049: locally defined symbol ?Logf__VA@FMsg@@SAXPEBDHAEBVFName@@W4Type@ELogVerbosity@@PEB_WZZ (public: static void __cdecl FMsg::Logf__VA(char const *,int,class FName const &,enum ELogVerbosity::Type,wchar_t const *,...)) imported
    LogPlayLevel:Display: UnrealBuildTool: GameGeneratedActor.cpp.obj : warning LNK4217: locally defined symbol ?Logf__VA@FMsg@@SAXPEBDHAEBVFName@@W4Type@ELogVerbosity@@PEB_WZZ (public: static void __cdecl FMsg::Logf__VA(char const *,int,class FName const &,enum ELogVerbosity::Type,wchar_t const *,...)) imported in function "public: class UGeneratedMeshComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UGeneratedMeshComponent,class UGeneratedMeshComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUGeneratedMeshComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUGeneratedMeshComponent@@PEAVUObject@@VFName@@_N22@Z)
    LogPlayLevel:Display: UnrealBuildTool: GameHUD.cpp.obj : warning LNK4049: locally defined symbol ?Logf__VA@FMsg@@SAXPEBDHAEBVFName@@W4Type@ELogVerbosity@@PEB_WZZ (public: static void __cdecl FMsg::Logf__VA(char const *,int,class FName const &,enum ELogVerbosity::Type,wchar_t const *,...)) imported
    
    etc...
    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


      #32
      In your code it should simply be a single line change in GeneratedMeshComponent.cpp: -

      virtual void DrawDynamicElements(FPrimitiveDrawInterface* PDI, const FSceneView* View)
      {
      QUICK_SCOPE_CYCLE_COUNTER(STAT_GeneratedMeshSceneProxy_DrawDynamicElements);

      const bool bWireframe = View->Family->EngineShowFlags.Wireframe;

      FColoredMaterialRenderProxy WireframeMaterialInstance(
      //GEngine->WireframeMaterial->GetRenderProxy(IsSelected()),
      WITH_EDITOR ? GEngine->WireframeMaterial->GetRenderProxy(IsSelected()) : NULL,
      FLinearColor(0, 0.5f, 1.f)
      );

      Comment


        #33
        Originally posted by AndrewJSch View Post
        The problem with packaged builds is that it dereferences GEngine->WireframeMaterial, which is NULL after packaging the game without editor support. You can fix the problem by checking if WITH_EDITOR is true before dereferencing WireframeMaterial.

        You can see the fix I made to my similar primitive component implementation here: https://github.com/AndrewScheidecker...691e354b36728a
        Good work, I've updated the Procedural Mesh Generation code example on the wiki with your solution.

        And now to figure out why my Launch button won't build properly and gives me unresolved externals when cooking and running in the editor work fine... (not related to this fix)
        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


          #34
          Hi everyone,

          I based my work on CustomMeshComponent to allow per-vertex and uv animation.
          Everything started quite well and i can now animate like expected.

          Unfortunately i am stuck to one big issue : i cant see the applied material to this mesh.
          My mesh is rendered in plain color (ranging from white to black depending on the lighting and ... luck... ).

          I added support for UVs just like HighOnFire did, the material is attached and gettable with GetMaterial(0)...
          If you guys ran into these kind of issues and know how to adapt the code for it to work, i would really appreciate

          Thanks

          Comment


            #35
            ~~~

            UVs For GeneratedMesh

            You have to modify the procedure mesh code to use DynamicMeshVertex data rather than just FVector

            Then when you cache the vertices the UVs will be included!

            Here's the section you need to look at, with my modified code (it wont look the same as what you have currently)

            Code:
            FGeneratedMeshSceneProxy(UVictoryMeshComponent* Component)
            		: FPrimitiveSceneProxy(Component)
            		, MaterialRelevance(Component->GetMaterialRelevance())
            	{
            		
             
            		// Add each triangle to the vertex/index buffer
            		for(int TriIdx=0; TriIdx<Component->GeneratedMeshTris.Num(); TriIdx++)
            		{
            			FVMeshTri& Tri = Component->GeneratedMeshTris[TriIdx];
            			
            			IndexBuffer.Indices.Add(
            				VertexBuffer.Vertices.Add(Tri.Vertex0) //returns new index
            			);
            		
            			IndexBuffer.Indices.Add(
            				VertexBuffer.Vertices.Add(Tri.Vertex1) //returns new index
            			);
            			
            			IndexBuffer.Indices.Add(
            				VertexBuffer.Vertices.Add(Tri.Vertex2) //returns new index
            			);
            		}
             
            		// Init vertex factory
            		VertexFactory.Init(&VertexBuffer);
            I modified my triangle struct to look like this (which is the unit for GeneratedMeshTris)

            Code:
            USTRUCT()
            struct FVMeshTri
            {
            	GENERATED_USTRUCT_BODY()
             
            	
            	FDynamicMeshVertex Vertex0;
            	FDynamicMeshVertex Vertex1;
            	FDynamicMeshVertex Vertex2;
            	
            	FVMeshTri()
            	{
            	}
            };

            DynamicMeshVertex has support for UVs in its TextureCoordinate


            So now pass the entire DynamicMeshVertex into VertexBuffer.Vertices.Add(

            and UVs will work correctly!

            I've already proven this in my own project, resulting in fact that now I can make dynamic UV'ed meshes with collision (thanks Dmacesic!)



            Rama

            PS: UPROPERTY() doesnt work with DynamicMeshVertex so I took that out
            Attached Files
            Last edited by Rama; 04-13-2014, 02:10 PM.
            100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

            Comment


              #36
              Thank you for the input Rama.
              I finally found out the issue... again something stupid and tricky...
              I was actually using FDynamicMeshVertex to build the vertex buffer BUT instead of adding the whole structure i was only adding the FVector position component....
              I wish someone told me about it at compile time

              Comment


                #37
                How can we add the support for simulating physics for this generated mesh?

                Comment


                  #38
                  Originally posted by arkenthera View Post
                  How can we add the support for simulating physics for this generated mesh?
                  I cant post the code here for legal reasons, but check out SphereComponent.cpp

                  and the AggGeom.

                  adding to AggGeom you can create a physics composite shape to match your mesh!

                  This does require a lot of careful manual arrangement, just like the UE4 Physics Editor / Phat.

                  So you will have to do this per shape that you create

                  Rama
                  100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

                  UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                  Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

                  Comment


                    #39
                    Originally posted by Rama View Post
                    I cant post the code here for legal reasons, but check out SphereComponent.cpp

                    and the AggGeom.

                    adding to AggGeom you can create a physics composite shape to match your mesh!

                    This does require a lot of careful manual arrangement, just like the UE4 Physics Editor / Phat.

                    So you will have to do this per shape that you create

                    Rama

                    Thank you! Will try this for sure and post here if I could achieve it

                    Comment


                      #40
                      Hi everyone,

                      Is there a way to create multiple instances of the same CustomMeshComponent? Like InstancedStaticMeshComponent?

                      Thanks

                      Comment


                        #41
                        Originally posted by ACCA software S.p.A. View Post
                        Is there a way to create multiple instances of the same CustomMeshComponent? Like InstancedStaticMeshComponent?
                        No, you would just need to add multiple components. Or create your own InstancedCustomMeshComponent
                        Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
                        Twitter: @EpicJamesG

                        Comment


                          #42
                          James, any hints on the best way to use procedural meshes with SkeletalMeshActors? I noticed you can either have SkeletalMeshComponents (that wrap SkeletalMeshes), or have any AActor derived class attach to a socket. Would the latter be a way of allowing procedural meshes to be connected to a skeletal mesh?
                          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


                            #43
                            First up, I'm no C++ programmer but if I have no other way, I have to finally learn some... So here's my question.
                            If I want to have a deformable Landscape in my game (think worms or scorched earth), would I need what is talked about here or is there an easier way in UE4?

                            Comment


                              #44
                              Originally posted by JamesG View Post
                              No, you would just need to add multiple components. Or create your own InstancedCustomMeshComponent
                              Thanks for the reply.

                              On the other hand, is it possible to create a procedural StaticMesh at runtime? Can we use RawMesh?

                              Thanks.

                              Comment


                                #45
                                Originally posted by ACCA software S.p.A. View Post
                                Thanks for the reply.

                                On the other hand, is it possible to create a procedural StaticMesh at runtime? Can we use RawMesh?

                                Thanks.
                                Yes you can, that's what most of these procedural mesh discussions have accomplished so far

                                Here's a pic of my own procedural mesh, made at runtime and uv-mapped via algorithm!

                                Notice that it has collision!

                                100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

                                UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                                Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

                                Comment

                                Working...
                                X