Announcement

Collapse
No announcement yet.

Runtime Mesh Component

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

    [MENTION=141752]Koderz[/MENTION]I figured out how to get the plugin installed and compiled into my project by poking through the UE4 docs.

    The navmesh issue I was having with it not updating seems to be fixed. The navmesh now updates every time without any problems. Was really exciting to see my AI actually walk around the objects instead of through them! However, I did have to delete the navmesh and recreate it for it to start working, but not a big deal.

    The issue with it not rendering with a translucent material still remains however. I have put together some information to help reproduce the problem.

    Firstly I created a new C++ actor called MyActor, added the following code to it, and compiled.

    MyActor.h
    Code:
    #pragma once
    
    #include "RuntimeMeshComponent.h"
    #include "MyActor.generated.h"
    
    UCLASS()
    class BLOCKHOSPITAL_API AMyActor : public AActor
    {
    	GENERATED_BODY()
    
    public:
    	AMyActor();
    
    	virtual void BeginPlay() override;
    	
    	virtual void Tick(float DeltaSeconds) override;
    
    	UFUNCTION(BlueprintCallable, Category = "Default")
    	void UpdateMesh();
    
    	UPROPERTY(BlueprintReadOnly, Meta = (ExposeOnSpawn = true))
    	UMaterialInterface* MeshMaterial;
    
    	URuntimeMeshComponent* RuntimeMesh;
    
    	float Size;
    };
    MyActor.cpp
    Code:
    #include "MyProject.h"
    #include "MyActor.h"
    #include "RuntimeMeshLibrary.h"
    
    AMyActor::AMyActor()
    {
    	PrimaryActorTick.bCanEverTick = true;
    
    	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
    
    	Size = 10.0f;
    }
    
    void AMyActor::BeginPlay()
    {
    	Super::BeginPlay();
    
    	RuntimeMesh = NewObject<URuntimeMeshComponent>(this);
    	RuntimeMesh->SetupAttachment(RootComponent);
    	RuntimeMesh->SetMaterial(0, MeshMaterial);
    	RuntimeMesh->RegisterComponent();
    }
    
    void AMyActor::Tick(float DeltaTime)
    {
    	Super::Tick(DeltaTime);
    
    	Size += DeltaTime * 2.0f;
    }
    
    void AMyActor::UpdateMesh()
    {
    	FVector BoxRadius(Size, 100.0f, 100.0f);
    
    	TArray<FVector> Vertices;
    	TArray<int32> Triangles;
    	TArray<FVector> Normals;
    	TArray<FVector2D> UVs;
    	TArray<FColor> Colors;
    	TArray<FRuntimeMeshTangent> Tangents;
    
    	URuntimeMeshLibrary::CreateBoxMesh(BoxRadius, Vertices, Triangles, Normals, UVs, Tangents);
    
    	for (int32 i = 0; i < Vertices.Num(); ++i)
    		Colors.Add(FColor::White);
    
    	RuntimeMesh->CreateMeshSection(0, Vertices, Triangles, Normals, UVs, Colors, Tangents, true);
    }
    Then I created a material in the editor called NewMaterial and set it up like this.

    Click image for larger version

Name:	material.png
Views:	1
Size:	93.4 KB
ID:	1116924

    Finally I created a PlayerController in the editor and added the following to its blueprint.

    Click image for larger version

Name:	player.png
Views:	1
Size:	100.5 KB
ID:	1116925

    Now I run the project in the editor and turn on the navmesh rendering using the "show Navigation" console command. Then when I press the space bar, this is what I get.

    Click image for larger version

Name:	result.png
Views:	1
Size:	183.0 KB
ID:	1116926

    So you can clearly see that a mesh is being generated, added to the runtime mesh and affects the navmesh. However it just doesn't render.

    Now if I go back to the material and change its Blend Mode to Opaque, then It renders fine.

    Click image for larger version

Name:	result2.png
Views:	1
Size:	167.0 KB
ID:	1116927

    Also, if I change the code over in MyActor to use a UProceduralMeshComponent instead of a URuntimeMeshComponent then it also works fine. So it must be an issue with RMC and translucent materials.

    Comment


      [MENTION=141752]Koderz[/MENTION] Any luck reproducing the bug with translucency?

      Comment


        I really love you to make this awesome package!!
        This makes my whole problems easier.
        By the way, is the market-place uploaded content version 1.2??

        Comment


          Originally posted by alleysark View Post
          By the way, is the market-place uploaded content version 1.2??
          Yes it is. v2.0 is still in the works but hopefully it is ready for the marketplace soon. You can test with v2.0 by following the instructions on GitHub to add it to your project. It might have bugs though.

          Comment


            Originally posted by wilberolive View Post
            [MENTION=141752]Koderz[/MENTION] Any luck reproducing the bug with translucency?
            I was successful in reproducing it, but haven't been able to find the cause yet.

            [MENTION=46051]alleysark[/MENTION] version 1.2 (the marketplace version and current release) doesn't have these parts yet. I hope to get v2 finished up here pretty quick, as it's mostly bugs left, then I'll update the marketplace.
            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
              I was successful in reproducing it, but haven't been able to find the cause yet.
              That's good. I was worried it was just me! So hope you can find a fix for it as that bug is driving me crazy. I tried to have a look through the code myself to see if I could work out a fix, but unfortunately, I just couldn't grasp the architecture of it all enough to know where to look.

              Comment


                Hi Koderz,

                Is it possible to bake lighting for meshes generated using your plugin? Thanks!

                Comment


                  Originally posted by wilberolive View Post
                  That's good. I was worried it was just me! So hope you can find a fix for it as that bug is driving me crazy. I tried to have a look through the code myself to see if I could work out a fix, but unfortunately, I just couldn't grasp the architecture of it all enough to know where to look.
                  Yeah, sorry about not getting back to you. I had this fix locally for a couple days waiting on bigger push of updates but I decided to go ahead and push this one to github. So it should be fixed now using the github master branch.


                  Originally posted by thebarryman View Post
                  Hi Koderz,

                  Is it possible to bake lighting for meshes generated using your plugin? Thanks!


                  It depends on what you're asking. If you mean at runtime, no as that requires editor only code. If you mean in the editor, I'm not really sure as I haven't really investigated it, but I would think it would work.
                  Last edited by Koderz; 11-07-2016, 12:45 AM.
                  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


                    Can this component be used with splines? In space of the spline mesh component? I'd like to smooth/edit vertices of my spline's corners...

                    Does this component support skeletal meshes or just static meshes?

                    Comment


                      Originally posted by Zireael07 View Post
                      Can this component be used with splines? In space of the spline mesh component? I'd like to smooth/edit vertices of my spline's corners...

                      Does this component support skeletal meshes or just static meshes?
                      Splines are not something it natively supports, but depending on what you're wanting you could mimic the behavior by creating large meshes out of the repeated smaller ones with the spline. I've never attempted it, or used the spline mesh component so that's just a guess. Basically you can create the mesh however you want, but it's up to you to create it. The RMC is just meant to efficiently draw them and provide other core features like collision.

                      Skeletal meshes are something I've thought about, but haven't decided whether I want to pursue it as they're quite a bit more complicated than static meshes. The answer for the foreseeable future is it's just meant for static meshes.
                      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
                        Yeah, sorry about not getting back to you. I had this fix locally for a couple days waiting on bigger push of updates but I decided to go ahead and push this one to github. So it should be fixed now using the github master branch.
                        That is great news. Thanks for all your effort. I did use the GitHub version for a while, but I found that it slowed my project compile times down way too much, so I'll just wait for the binary release on the marketplace. Cheers.

                        Comment


                          Thanks Koderz for this amazing plugin. It allows us to do stuff that would not have been possible with PMC. Very nice is the second UV channel.
                          NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                          Comment


                            Originally posted by wilberolive View Post
                            That is great news. Thanks for all your effort. I did use the GitHub version for a while, but I found that it slowed my project compile times down way too much, so I'll just wait for the binary release on the marketplace. Cheers.
                            Yeah, I hate the part that it requires compiling, but I just came across the "Package" option for a plugin so if that does what I assume it does then when I release the next version on github here soon I'll package it so it should solve much of this problem. The github version is very far ahead of marketplace right now.


                            Originally posted by Rumbleball View Post
                            Thanks Koderz for this amazing plugin. It allows us to do stuff that would not have been possible with PMC. Very nice is the second UV channel.
                            You're welcome! Also, just to let you know it will support far more than 2 UV channels, those are just predefined vertex formats. The github version, which will be v2 soon, can support quite a few configurations, and up to 8 uv channels with the builtin vertex. I will be updating the example project and docs over this next week.
                            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
                              You're welcome! Also, just to let you know it will support far more than 2 UV channels, those are just predefined vertex formats. The github version, which will be v2 soon, can support quite a few configurations, and up to 8 uv channels with the builtin vertex. I will be updating the example project and docs over this next week.
                              Thanks, but will wait for the Marketplace update.
                              NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                              Comment


                                having issue with using VertexColor of RMC.

                                The material applied is as simple as it can be. Using a Material with a fixed color, everything is fine. Using a Material that shows VertexColor, the RMC color differs.
                                Shadows are disabled to get rid of shadowing difference.

                                The Sphere is default static mesh from Unreal. The line is the RMC-Mesh.

                                Here is what I got with fixed color:
                                Click image for larger version

Name:	Material1.png
Views:	1
Size:	43.5 KB
ID:	1118470Click image for larger version

Name:	VertexColorBug_noVertexColor.png
Views:	1
Size:	6.7 KB
ID:	1118471

                                Using VertexColors. Material and colors are the same. Sphere does show the color wanted.
                                Click image for larger version

Name:	Material2.png
Views:	1
Size:	39.5 KB
ID:	1118472Click image for larger version

Name:	VertexColorBug_VertexColor.png
Views:	1
Size:	30.4 KB
ID:	1118473

                                The mesh is build via Blueprint CreateMeshSection/UpdateMeshSection.

                                Comment

                                Working...
                                X