Announcement

Collapse
No announcement yet.

Runtime Mesh Component

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

    Originally posted by Koderz View Post
    You *should* only need to set the bool on Create/Update... SetSectionTessellationTriangles is only if you use the utility to calculate it separately, like if you wanted to do it on another thread.
    Okay, that worked. Now, I want to use it with C++, but I just can't seem to get it working. Please have in mind that I'm starting with C++. So:

    Added lines in Build.cs:
    Code:
    // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
    
    using UnrealBuildTool;
    
    public class FlyingShip : ModuleRules
    {
    	public FlyingShip(TargetInfo Target)
    	{
    		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"});
    
    		PrivateDependencyModuleNames.AddRange(new string[] {  });
    
    	    PublicDependencyModuleNames.AddRange(new string[] { "ShaderCore", "RenderCore", "RHI", "RuntimeMeshComponent"});
        }
    }
    *.h file:

    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "GameFramework/Actor.h"
    #include "SeaSurface.generated.h"
    
    UCLASS()
    class FLYINGSHIP_API ASeaSurface : public AActor
    {
    	GENERATED_BODY()
    	
    public:	
    	// Sets default values for this actor's properties
    	ASeaSurface();
    
    	// Called when the game starts or when spawned
    	virtual void BeginPlay() override;
    	
    	// Called every frame
    	virtual void Tick( float DeltaSeconds ) override;
    
    private:
    	UPROPERTY(VisibleAnywhere, Category = Materials)
    		RuntimeMeshComponent * SeaMesh;
    
    };
    *.cpp file:

    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #include "FlyingShip.h"
    #include "SeaSurface.h"
    #include "RuntimeMeshComponent.h"
    
    
    // Sets default values
    ASeaSurface::ASeaSurface()
    {
     	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    	PrimaryActorTick.bCanEverTick = true;
    
    	SeaMesh = CreateDefaultSubobject<RuntimeMeshComponent>(TEXT("GeneratedMesh"));
    	RootComponent = SeaMesh;
    
    }
    
    // Called when the game starts or when spawned
    void ASeaSurface::BeginPlay()
    {
    	Super::BeginPlay();
    	
    }
    
    // Called every frame
    void ASeaSurface::Tick( float DeltaTime )
    {
    	Super::Tick( DeltaTime );
    
    }
    Error:

    Code:
    1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
    2>------ Build started: Project: FlyingShip, Configuration: Development_Editor x64 ------
    2>  Creating makefile for FlyingShipEditor (no existing makefile)
    2>  Parsing headers for FlyingShipEditor
    2>    Running UnrealHeaderTool "O:\FlyingShip\FlyingShip.uproject" "O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
    2>O:/FlyingShip/Source/FlyingShip/FishingShip/SeaSurface.h(25): error : Unrecognized type 'RuntimeMeshComponent' - type must be a UCLASS, USTRUCT or UENUM
    2>EXEC : error : UnrealHeaderTool failed for target 'FlyingShipEditor' (platform: Win64, module info: O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest, exit code: OtherCompilationError (5)).
    2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command ""E:\Unreal Engine 4\Epic Games\4.14\Engine\Build\BatchFiles\Build.bat" FlyingShipEditor Win64 Development "O:\FlyingShip\FlyingShip.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
    ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    What am I doing wrong?
    Last edited by Z-enzyme; 01-16-2017, 12:13 PM.

    Comment


      Originally posted by Z-enzyme View Post
      Okay, that worked. Now, I want to use it with C++, but I just can't seem to get it working. Please have in mind that I'm starting with C++. So:

      What am I doing wrong?
      Add

      Code:
      #include "RuntimeMeshComponent.h"
      to the header file as well.
      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
        to the header file as well.
        if:
        Code:
        #include "GameFramework/Actor.h"
        #include "RuntimeMeshComponent.h"
        #include "SeaSurface.generated.h"
        then:
        Code:
        2>  Parsing headers for FlyingShipEditor
        2>    Running UnrealHeaderTool "O:\FlyingShip\FlyingShip.uproject" "O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
        2>O:/FlyingShip/Source/FlyingShip/FishingShip/SeaSurface.h(70): error : Unrecognized type 'RuntimeMeshComponent' - type must be a UCLASS, USTRUCT or UENUM
        2>EXEC : error : UnrealHeaderTool failed for target 'FlyingShipEditor' (platform: Win64, module info: O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest, exit code: OtherCompilationError (5)).
        2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command ""E:\Unreal Engine 4\Epic Games\4.14\Engine\Build\BatchFiles\Build.bat" FlyingShipEditor Win64 Development "O:\FlyingShip\FlyingShip.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
        ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
        I'm hopeless...

        Comment


          Hey Koderz, thanks for the information. I ended up using Hierarchical Instanced Static Mesh to create instances with collision. This appears to work extremely fast. I've split my terrain into two parts, one is a gigantic single mesh with no collision, and the other the same mesh broken into regions (components). These components do have collision(static) but I've turned the visibility off after they are built. This appears to retain the collision while hiding the actual mesh. Now that I'm updating parts by removing them from the terrain RMC system and making an instance in the HISMC I need to update the collision of the RMC that is collision slices with visibility turned off. I thought it would automatically update the collision because I've updated the vertex locations of that RMC slice. Does it matter that the RMC visibility is turned off? I still want the collision to work, but have the visibilty to be turned off. Any ideas?

          Comment


            Nevermind, I was using EndMeshSectionPositionUpdate instead I should have used EndMeshSectionUpdate. This allows the collision RMCs to update their vertex positions while their visual mesh remains hidden.

            Comment


              Originally posted by Z-enzyme View Post
              if:
              Code:
              #include "GameFramework/Actor.h"
              #include "RuntimeMeshComponent.h"
              #include "SeaSurface.generated.h"
              then:
              Code:
              2>  Parsing headers for FlyingShipEditor
              2>    Running UnrealHeaderTool "O:\FlyingShip\FlyingShip.uproject" "O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
              2>O:/FlyingShip/Source/FlyingShip/FishingShip/SeaSurface.h(70): error : Unrecognized type 'RuntimeMeshComponent' - type must be a UCLASS, USTRUCT or UENUM
              2>EXEC : error : UnrealHeaderTool failed for target 'FlyingShipEditor' (platform: Win64, module info: O:\FlyingShip\Intermediate\Build\Win64\FlyingShipEditor\Development\FlyingShipEditor.uhtmanifest, exit code: OtherCompilationError (5)).
              2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command ""E:\Unreal Engine 4\Epic Games\4.14\Engine\Build\BatchFiles\Build.bat" FlyingShipEditor Win64 Development "O:\FlyingShip\FlyingShip.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
              ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
              I'm hopeless...
              I am kinda clueless about your error, but did you try using "class RuntimeMeshComponent" in your header files instead of "RuntimeMeshComponent"?

              Comment


                GOT IT!

                First, I need a header in the .h file. Okay.
                Then:
                Code:
                	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mesh)
                		class URuntimeMeshComponent *SeaMesh;
                And it works.

                Thank you very much for your help!

                Comment


                  Hey guys, I wanted to test the performance of this plugin by creating a very high poly sphere (say, 1 million triangles).

                  Does anyone have the code to generate a parametric sphere like that? I'm messing around with algorithms, but things are getting complicated for me and I don't want to lose too much time for this, so if anyone has something already done it would be a big help
                  TweenMaker | OutlineMaker

                  Comment


                    Making a sphere isn't that hard

                    If you already understand how to create verts and indices enough to make basic boxes, you're most of the way there.

                    So for instance in eden, I start with a box (with each side being made up of a grid of polygons) then iterate through all of the vert positions mooshing them into a sphere using getSafeNormal which shrinks them to the surface of a unit sphere, then multiply their position again to scale the sphere upto whatever size I want.

                    Comment


                      Hi Koderz, loving your plugin!

                      Got a couple of qns..

                      qns 1: how to uninstall the marketplace plugin? There doesnt seem to have an option in the launcher to uninstall it.

                      qns 2: is it possible to selectively select either marketplace plugin or github plugin in UE4editor>>edit>>plugins? I have made a mess by installing both marketplace plugin and github plugin. And would need just one of them.

                      Comment


                        Originally posted by Beriol View Post
                        Hey guys, I wanted to test the performance of this plugin by creating a very high poly sphere (say, 1 million triangles).

                        Does anyone have the code to generate a parametric sphere like that? I'm messing around with algorithms, but things are getting complicated for me and I don't want to lose too much time for this, so if anyone has something already done it would be a big help
                        In case anyone needs it, I managed to create the sphere, here's the code (I'm actually using the ProceduralMeshComponent in this one, but the code stays basically the same):

                        Code:
                        void ASphereActor::GenerateSphereMesh()
                        {
                        	mVertices.Empty();
                        	mIndices.Empty();
                        	mNormals.Empty();
                        	mUvs.Empty();
                        	mVertexColors.Empty();
                        	mTangents.Empty();
                        
                        	CreateSphereWithTriangles(mVertices, mIndices, mNormals, SphereRadius, SphereRings, SphereSectors);
                        
                        	mMesh->CreateMeshSection(0, mVertices, mIndices, mNormals, mUvs, mVertexColors, mTangents, false);
                        }
                        
                        void ASphereActor::CreateSphereWithTriangles(TArray<FVector> &vertices, TArray<int32> &indices, TArray<FVector> &normals, float radius, int stacks, int slices)
                        {
                        	double stackAngle = PI / stacks;
                        	double sliceAngle = 2.0 * PI / slices;
                        
                        	int i, j, v1_index, v2_index, v3_index;
                        
                        	double a = 0;
                        	double b = a + stackAngle;
                        	double r0 = radius * sin(a);
                        	double r1 = radius * sin(b);
                        	float z0 = radius * cos(a);
                        	float z1 = radius * cos(b);
                        
                        	double c = 0;
                        	float x = cos(c);
                        	float y = sin(c);
                        
                        	vertices.Add(FVector(x * r0, y * r0, z0));
                        	v1_index = vertices.Num();
                        
                        	vertices.Add(FVector(x * r1, y * r1, z1));
                        	v2_index = vertices.Num();
                        
                        	for (i = 0; i < stacks; i++)
                        	{
                        		a = i * stackAngle;
                        		b = a + stackAngle;
                        		r0 = radius * sin(a);
                        		r1 = radius * sin(b);
                        		z0 = radius * cos(a);
                        		z1 = radius * cos(b);
                        
                        		j = i ? 0 : 1;
                        
                        		for (; j <= slices; j++) 
                                        {
                        			c = j * sliceAngle;
                        			x = cos(c);
                        			y = sin(c);
                        
                        			vertices.Add(FVector(x * r0, y * r0, z0));
                        			v3_index = vertices.Num();
                        
                        			indices.Add(v1_index);
                        			indices.Add(v2_index);
                        			indices.Add(v3_index);
                        
                        			v1_index = v3_index;
                        
                        			vertices.Add(FVector(x * r1, y * r1, z1));
                        			v3_index = vertices.Num();
                        
                        			indices.Add(v1_index);
                        			indices.Add(v2_index);
                        			indices.Add(v3_index);
                        
                        			v2_index = v3_index;
                        		}
                        	}
                        }
                        It's not the prettiest code but it works:
                        Click image for larger version

Name:	33p39kz.png
Views:	1
Size:	894.7 KB
ID:	1121770
                        Attached Files
                        TweenMaker | OutlineMaker

                        Comment


                          I am currently having some issues with line trace. It seems the collision bounds are different from the odd shape runtimemesh. Is there a way to pass the collision shape to the runtimemesh function?
                          Attached Files

                          Comment


                            Dev Grant Nomination for the RMC!

                            This is long shot but it's worth a try. I started a thread, and hope to get support from others like me using the RMC in the hope that we can convince Epic to give Koderz a dev grant for the work he's done on the RMC.

                            I'd like to thank Koderz for the work he's done so far!

                            If you use the RMC and think Epic should look into giving Koderz a dev grant, please support it here: https://forums.unrealengine.com/show...or-a-dev-grant

                            Comment


                              Just stopping by to say I started to use it and it is great! Thank you very much for such a great free addition [MENTION=141752]Koderz[/MENTION]!

                              Comment


                                Bug report: Trying to #require Components/SplineComponent.h in a project that has this plugin (doesn't have to be the same class that uses RMC) results in a spate of errors from VS:

                                G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2065: 'UMaterialInterface': undeclared identifier
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2059: syntax error: ','
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2976: 'TMap': too few template arguments
                                2> G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Core\Public\Containers\Map.h(927): note: see declaration of 'TMap'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2065: 'UMaterialInterface': undeclared identifier
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2059: syntax error: ','
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2976: 'TMap': too few template arguments
                                2> G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Core\Public\Containers\Map.h(927): note: see declaration of 'TMap'
                                2> MyRuntimeActorComponent.cpp
                                2>G:\Kasia\UE4 project\cpp\MyProject2 - Kopia\Source\MyProject2\MyRuntimeActorComponent.cpp(1): error C2059: syntax error: '.'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(357): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(357): error C2143: syntax error: missing ',' before '&'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(364): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(364): error C2143: syntax error: missing ',' before '&'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(367): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/EngineBaseTypes.h(367): error C2143: syntax error: missing ',' before '&'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2065: 'UMaterialInterface': undeclared identifier
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2059: syntax error: ','
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(214): error C2976: 'TMap': too few template arguments
                                2> G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Core\Public\Containers\Map.h(927): note: see declaration of 'TMap'
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2065: 'UMaterialInterface': undeclared identifier
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2059: syntax error: ','
                                2>G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Engine\Classes\Engine/TextureStreamingTypes.h(217): error C2976: 'TMap': too few template arguments
                                2> G:\Kasia\UE4 Launcher\Epic Games\4.14\Engine\Source\Runtime\Core\Public\Containers\Map.h(927): note: see declaration of 'TMap'
                                2>ERROR : UBT error : Failed to produce item: G:\Kasia\UE4 project\cpp\MyProject2 - Kopia\Binaries\Win64\UE4Editor-MyProject2.pdb

                                Curiously enough, I *can* work with splines and RMC in blueprints.

                                Comment

                                Working...
                                X