Help adding procedurally generated mesh code into a project

Hi all, so I was told about this:

github page which has code to give your procedurally generated mesh collision.
I have no idea what to do or where to start. I’ve already made a .cpp and .h file which are customMesh classes called

GenertatedMeshComponent

My project is called

TriKakei

when I try to copy the respective .cpp and .h files found on the github page, into my .h and .cpp files I get tons of errors. What am I suppose to rename/ include/replace etc.?
Please forgive my lack of knowledge, I have absolutely no knowledge of C++ coding with UE4.

EDIT WITH MORE INFORMATION:

I know the basics of coding, not much about C++, since blueprints have been doing it for me fine until now.

The github link has both the .proceduralmeshcomponent.cpp and .proceduralmeshcomponent.h.

If you click ‘view’ in the top right of each you get to these two pages:

(That’s the .h and .cpp I’m directly copying)

After doing Test>Debug>All tests I get a these errors:

Maybe I’m suppose to rename some stuff and delete it? Not sure…

What errors do you get exactly? Which code are you copying?
Also if you don’t know c++ it is never too late to learn the basics at least :slight_smile:

Updated the main post with more info.

First of all you can forget about the Error List tab it is used by intel sense which is completely messed up thanks fully to the precompiler headers. =(

Go look at the Output tab if you need errors and warning messages.

You only need these files:

  • ProceduralMeshComponent.h
  • ProceduralMeshComponent.cpp

Secondly:

Replace all occurrence of

#include "ProceduralMesh.h"

to

#include "TriKakei.h"

Also find your TriKakei.Build.cs file and make sure it looks like something this:

using UnrealBuildTool;

public class TriKakei : ModuleRules
{
	public TriKakei(TargetInfo Target)
	{
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
        PublicDependencyModuleNames.AddRange(new string[] { "RHI", "RenderCore", "ShaderCore" });

        PrivateDependencyModuleNames.AddRange(new string[] { });

	}
}

I think that’s all. Now you should be able to compile your code without errors
If not, let me know i update my post.

I don’t seem to have a

Proceduralmesh.h
At least when I ctrl + f I don’t find any. I have multiple
ProceduralMeshComponent
And other functions involving ProceduralMesh such as
ClearProceduralMeshTriangles(); OR SetProceduralMeshTeriangle($SomeArgs)

This is what my build.cs looks like:

Thanks for all your help so far! I’ve up voted your answer :smiley:

EDIT: So I went to Test>Debug>All Tests again, and I got a pop-up saying:

There were build errors. Would you like to continue and run tests from the last successful build?

Clicking ‘no’ and looking at my output tab it says:

The operation was canceled
Clicking ‘yes’ brings me to an empty output tab. (I assume no errors)?

You need only those 2 files if you plan to work with blueprints. The other files are just c++ usage examples.

Alright. I’ll test it out and get back to you/ mark your answer as correct if it works!

What would be the nodes I would use in blueprints to enable collision for this procedural mesh?

It seems I’m unable to create this file!

36379-capture.png

The github page says:

Basic blueprints are created from the C++ Procedural Actor classes. This help demonstrating how they can be spawned manually in the level at construction time

Also, when I type in ‘generatedMesh’ which is the class name, nothing appears :\

36380-capture2.png

What else could I have done wrong?

Create a new Actor and add the Procedural Mesh Component component to it

Procedural Mesh compoennt is not showing up.

If I click ‘new C++ Component’ and then I can choose generatedMeshComponent, but that I believe is with blueprints.

here?

The assimp mesh is the same as the procedural mesh i just renamed it.

Alright. I got it. Thanks.

How would I go about just simply creating a triangle that has collision with this?

Yes, Just create your triangles and the Set Procedural Mesh Triangles node will do the trick! :wink:

I don’t have a custom Set procedural mesh triangles only a custom mesh triangles.

If you did everything right then you should have these new nodes avalaible:

I don’t seem to have it.
This is a link to my .cpp .h and .cs files:

You should be able to view them in-browser.

Oh, well delete those 2 GeneratedMeshComponent files.

And download these 2 files:

ProceduralMeshComponent.cpp

https://raw.githubusercontent.com/SRombauts/UE4ProceduralMesh/master/Source/ProceduralMesh/ProceduralMeshComponent.cpp

ProceduralMeshComponent.h

https://raw.githubusercontent.com/SRombauts/UE4ProceduralMesh/master/Source/ProceduralMesh/ProceduralMeshComponent.h

Copy them into your Sources folder.

Go to your .uproject file right click and select Generate Visual Studio Project files. (It will update the solution file with the new source files)

Replace the

#include "ProceduralMesh.h"

Inside your ProceduralMeshComponent.cpp file.

To generate the .cpp and .h
files I made a new which is a ‘custommeshcomponent’

I then erased and replaced all the code with what you gave me.

The files were put in Source > Trikakei instead of just source.

It still does not appear though. Thanks so much for your help so far!!!

It is very much appreciated.

It is not Custom Mesh. It is Procedural Mesh Component:

When I’m choosing a parent class which’ll generate the .cpp and .h files, which one should I choose?