Announcement

Collapse
No announcement yet.

Runtime Mesh Component

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

  • replied
    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"?

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    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?

    Leave a comment:


  • replied
    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...

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    The overall plugin supports back to 4.10, the current version supports 4.13 and 4.14. The marketplace is the easiest place to get it. Otherwise you can install it from github in which case it should work with 4.15 and master branch source as well.


    On another note, the slicer is known to be extremely buggy right now. I'm looking into it slowly.

    Leave a comment:


  • replied
    Does this plugin work with 4.14? I am thinking of procedurally creating a couple of (building) RMCs and then converting them to normal static meshes for further use.

    Leave a comment:


  • replied
    Originally posted by Z-enzyme View Post
    Question, how to use Tessellation with this? I'm having trouble figuring it out.

    I believe I need to check the Bool property for "Generate Tessellation Triangles" and then use this "Set Section Tessellation Triangles". How to setup that properly? What are those tessellation triangles exactly?

    Please help, right now time is of the essence.
    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.

    Leave a comment:


  • replied
    Question, how to use Tessellation with this? I'm having trouble figuring it out.

    I believe I need to check the Bool property for "Generate Tessellation Triangles" and then use this "Set Section Tessellation Triangles". How to setup that properly? What are those tessellation triangles exactly?

    Please help, right now time is of the essence.
    Last edited by Z-enzyme; 01-12-2017, 01:10 PM.

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    Thanks! It should actually get faster here soon with the new version! Also it will use substantially lower memory in cases where you don't need to update something after the first time (loading a static model like you are, or just generate once and use type things) and supporting multiple instances without full memory duplication.
    Hooo, great ! Looking forward to those improvements !

    Leave a comment:


  • replied
    Originally posted by Thumper View Post
    After a little trial and error I was able to get the convex collision setup working. I have a couple questions for optimization and perhaps your findings so far with them. At any one given time I spawn around 30-50 Actors with an RMC component. Each RMC component houses probably 30-200 triangles, but each triangle I'm creating a convex triangle collision primitive. I use the RMC->AddCollisionConvexMesh(convexCollisionVerts) for each triangle collision primitive which ends up being the same number of primitives as their are triangles on the visual mesh. This appears to work fine up until I start having my peak amount of 30-50 actors. Each actor containing 30-200 triangles and roughly the same number of convex collision triangle hulls, then I start to see some slow down. This seems low to me. Any idea where this slowdown may be coming from? To test the movable collision aspect of the convex collision hulls I just simply scale the actors in and out using a timeline. So all the actors use the same float curve in the timeline.
    Glad to here you got it working at least! I was going to say that enabling physics is probably what you missed.

    Now, for a quickie overview on how that works... The convex mesh support there is going to take whatever you feed it in each batch and make a convex hull out of it. This means that any concavity would be filled in, but it will technically accept almost anything you feed it. The problem there is obviously by filling in concave areas you get some weird physics behaviors. What's really needed is something like convex decomposition which will turn a big complex body into multiple smaller convex shapes. Unfortunately this is usually a very slow process unless you know enough about your input information to generate it directly. See below for the difference between convex hull and convex decomposition.

    Click image for larger version

Name:	chvsacd.png
Views:	1
Size:	68.7 KB
ID:	1121077

    Now, the problem with what you're doing is the sheer volume of convex objects. While I'm not entirely sure on how PhysX handles compound shapes (single actor with multiple independent shapes), My assumption is that they're just not checked against eachother but still checked in turn against all the shapes in another actor. This leads to an exponential growth problem. If both actors have 10 shapes, you have 100 possible combinations, but if both actors have 20 shapes, then you have 400 possible combinations. With your example of 30-200 triangles independently that means upper end of 40,000 possible combinations in collision detecting 2 of those actors together. This gets even worse when colliding against a mesh. PhysX, to my knowledge, uses a BVH tree for static meshes which is why they're incredibly fast. The problem is moving/rotating a BVH can get costly to update so PhysX doesn't support moving triangle meshes. UE4 handles this for normal objects by either importing custom collision shapes for it or using V-HACD ( https://github.com/kmammou/v-hacd ) to decompose the triangle mesh into a small number of convex objects to approximate it. The problem is this is *EXTREMELY* slow in some cases (Like hours slow for complex meshes).

    Now, not knowing what you're actually working with I can't say if there's a way to easily figure out a roughly minimal set of convex shapes to approximate it fast enough to be usable at run-time.




    Originally posted by Froyok View Post
    I just wanted to chime in and congrats you for this wonderful plugin. Great job [MENTION=141752]Koderz[/MENTION] !
    Performances are really good and the plugin is very easy to work with.
    Thanks! It should actually get faster here soon with the new version! Also it will use substantially lower memory in cases where you don't need to update something after the first time (loading a static model like you are, or just generate once and use type things) and supporting multiple instances without full memory duplication.
    Last edited by Koderz; 01-07-2017, 06:14 PM.

    Leave a comment:


  • replied
    I just wanted to chime in and congrats you for this wonderful plugin. Great job [MENTION=141752]Koderz[/MENTION] !
    Performances are really good and the plugin is very easy to work with.

    Here is a little demo of a project where I'm using the RuntimeMeshComponent to load OBJ files at runtime :

    Leave a comment:


  • replied
    After a little trial and error I was able to get the convex collision setup working. I have a couple questions for optimization and perhaps your findings so far with them. At any one given time I spawn around 30-50 Actors with an RMC component. Each RMC component houses probably 30-200 triangles, but each triangle I'm creating a convex triangle collision primitive. I use the RMC->AddCollisionConvexMesh(convexCollisionVerts) for each triangle collision primitive which ends up being the same number of primitives as their are triangles on the visual mesh. This appears to work fine up until I start having my peak amount of 30-50 actors. Each actor containing 30-200 triangles and roughly the same number of convex collision triangle hulls, then I start to see some slow down. This seems low to me. Any idea where this slowdown may be coming from? To test the movable collision aspect of the convex collision hulls I just simply scale the actors in and out using a timeline. So all the actors use the same float curve in the timeline.

    Leave a comment:


  • replied
    Hey Koderz any chance of getting an example using the Convex collision? I'm trying to take a couple faces from a RMC that is using complex collision and convert it to a piece that uses the same verts but now has convex collision. I'm doing this with the hope of applying physics.

    I've set the bUseComplexAsSimpleCollision = false;
    I've also set the component SetMobility(EComponentMobility::Movable);

    After I build a list of vertices I RuntimeMesh->AddCollisionConvexMesh(Vertices);

    Yet when I load in the level and set this in motion by scaling the component (to test), I don't see any collision in the view options, but I do see the visible mesh of the RMC scale.
    Last edited by Thumper; 01-03-2017, 07:07 PM.

    Leave a comment:

Working...
X