Announcement

Collapse
No announcement yet.

Runtime Mesh Component

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

  • replied
    +1 for 'instancing support'!

    Great job on what you have done already. The community thrives on the work and support like you provide. Thanks!

    Leave a comment:


  • replied
    Originally posted by Old message
    Hi,

    I am using your amazing plugin !

    Everything worked fine until I created a child class of a class which contained a Runtime Component. Now my project randomly crashes on startup.

    [LOG]

    Like I said, it is random. When it crashes, I can redo exactly what I did on a backup and it will not crash. After X minutes of work, if I close and reopen the project, it may crash...
    (I am using 4.15)
    EDIT : apparently, it still occurs with Procedural Mesh Component so I am going to answerhub, sorry for the inconvenience
    Last edited by Kaiagan; 05-01-2017, 02:58 PM.

    Leave a comment:


  • replied
    Originally posted by Rumbleball View Post
    But could you give a bit insight about "They're meant to live for the short time you're creating/updating something."? It's just a class, why can't it stay as member of another?
    Those by default will keep an entire copy of the mesh wasting quite a bit of memory if you have more than a couple. There's not really any point in keeping them around.

    Originally posted by Rumbleball View Post
    For our main project I want to use more than 2UV-Channels, they way to go seems to be FRuntimeMeshVertex<> where I can specify the amout of UV-Channels, but as shown above it does not work as compilation fails.

    There's several parts to making a new vertex. The way you should be able to do it is by using...

    Code:
    DECLARE_RUNTIME_MESH_VERTEX(FTestVertexConfiguration, true, true, true, true, 3, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision)
    in the header, and...

    Code:
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionDualUVHiPrecisionNormals);
    in a .cpp file. I think there might be a dll problem introduced recently with this so best thing would be to use the github version and alter the generic vertex header and cpp file like what Mase87 did above.

    Now with that said, unfortunately you can't actually disable normal/tangent/color and have to have at least 1 uv channel. you can only disable position if used with a dual buffer section. Won't go into explanation on that right here, but it's an engine thing. It should be working in v3 though.

    Leave a comment:


  • replied
    I just did this extension in a fork of Koderz repo and it worked for me. (Ignore the typo of triple, I know )

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    Originally posted by Rumbleball View Post
    I'm trying to go with some of the helper classes on the runtime mesh but everything seems to fail. Can anyone help out?

    So trying to construct that 'verticesBuilder'

    ...

    Those aren't really meant to stick around as an member variable. They're meant to live for the short time you're creating/updating something. The one you had, like the one below, is the correct way to set that up. You could do it on the heap, but I wouldn't recommend it. Inside whatever generation function you have, just create the 2 builders, do whatever, submit them to the rmc and let them get destroyed when they go out of scope.

    Code:
    	FRuntimeMeshComponentVerticesBuilder VertBuilder(true, false, false, false, false);

    thanks Koderz,
    Code:
    	FRuntimeMeshComponentVerticesBuilder vertices(&(meshData.vertices), nullptr, nullptr, nullptr, nullptr, nullptr);
    	FRuntimeMeshIndicesBuilder triangles;
    	vaseRuntimeMesh->CreateMeshSection(0, vertices, triangles);
    this works for me.

    But could you give a bit insight about "They're meant to live for the short time you're creating/updating something."? It's just a class, why can't it stay as member of another?



    Had another try on:
    Code:
    template<typename VertexType>
    	void CreateMeshSection(int32 SectionIndex, TArray<VertexType>& Vertices, TArray<int32>& Triangles, bool bCreateCollision = false, 
    		EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
    using FRuntimeMeshVertex<true, false, false, false, 0> for VertexType

    Code:
    	TArray<FRuntimeMeshVertex<true, false, false, false, 0>> verticestest;
    	TArray<int32> trianglestest;
    
    	vaseRuntimeMesh->CreateMeshSection(0, verticestest, trianglestest);
    fails compiling: 'TypeInfo': undeclared identifier at code
    Code:
    	virtual const FRuntimeMeshVertexTypeInfo* GetVertexType() const { return &VertexType::TypeInfo; }
    Why can't we use this? This seems to be a nice way to declare a vertices array, as you can specify what you want and what not.


    ok ..., tried your code from Github, which works when adding the modules
    PrivateDependencyModuleNames.AddRange(new string[] { "ShaderCore", "RenderCore", "RHI", "RuntimeMeshComponent" })
    like you explain in your wiki as well.

    Code:
    	TArray<FRuntimeMeshVertexSimple> verticestest2;
    	TArray<int32> trianglestest;
    
    	vaseRuntimeMesh->CreateMeshSection(0, verticestest2, trianglestest);
    What VertexTypes are there?
    Using the search function of VisualStudio I came across
    Code:
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexSimple);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexDualUV);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPosition);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionDualUV);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexHiPrecisionNormals);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexDualUVHiPrecisionNormals);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionHiPrecisionNormals);
    DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionDualUVHiPrecisionNormals);
    Which explains why I could not find it by searching for the class.

    For our main project I want to use more than 2UV-Channels, they way to go seems to be FRuntimeMeshVertex<> where I can specify the amout of UV-Channels, but as shown above it does not work as compilation fails.

    thanks in advance.

    Leave a comment:


  • replied
    Originally posted by shunwang View Post
    I have one more question and now its about lighting. I have a generated mesh which is one sided, normals are generated by:

    CreateMeshSection(SectionIndex, Verts, Tris, true, EUpdateFrequency::Infrequent, ESectionUpdateFlags::CalculateNormalTangent);

    But it looks like surface are filled by the light not as the closed tunnel, but like transparent roof of tunnel skip the light to the floor and its bright as just open surface. If I use this flat tube as double sided (poligons are inside and doubling for outside) its the same effect. But outer, normal objects, convex models are fine and shadows/lights there are correct. Please share your ideas whats wrong with my mesh
    I'd have to see more of how you have things configured. My first guess would be whether you have the light set as static, make sure it's stationary/dynamic. Beyond that I'd have to see how you have the RMC configured as well as other lighting config like directional light/skylight/fog.


    Originally posted by ioFlow Studios View Post
    Hi Koderz,

    Sorry to be a (predictable) pain in the ***, but do you know if you'll get a chance to look at updating your plugin for the new 4.16 preview?

    The new volumetric fog is such a breakthrough for my galaxy simulation (which is based on RMC) and I'm really looking forward to being able to try the two together...

    If you haven't seen what I've been doing with RMC lately, have a look at the end of my eden thread:
    https://forums.unrealengine.com/show...-Project/page4
    Haven't had the time to follow much on the forums recently. I used to track what you were doing. Looks like you've made some serious progress!
    As for 4.16. Unless there's breaking changes introduced (won't surprise me) it should already work. If you mean uploading it to the marketplace, I'm not sure I can for a preview build of the engine. I haven't directly tried v2 in 4.16 yet, might have time in the next few days to give it a shot. RMCv3 is being developed on 4.16 and is likely to be 4.16+ only, might support 4.15 if it's not much work but I won't be backporting beyond that. You could get the RMC from github (if you do just get master branch, not the release builds) and install it to your project.

    On another note, I'd be interested to hear your feedback on the RMC as to what you'd like to see added/changed/improved.



    Originally posted by Rumbleball View Post
    I'm trying to go with some of the helper classes on the runtime mesh but everything seems to fail. Can anyone help out?


    So trying to construct that 'verticesBuilder'
    ...
    Those aren't really meant to stick around as an member variable. They're meant to live for the short time you're creating/updating something. The one you had, like the one below, is the correct way to set that up. You could do it on the heap, but I wouldn't recommend it. Inside whatever generation function you have, just create the 2 builders, do whatever, submit them to the rmc and let them get destroyed when they go out of scope.

    Code:
    	FRuntimeMeshComponentVerticesBuilder VertBuilder(true, false, false, false, false);

    Leave a comment:


  • replied
    I'm trying to go with some of the helper classes on the runtime mesh but everything seems to fail. Can anyone help out?

    Until now I was using

    Code:
    	void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
    		const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision = false,
    		EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None);
    to create my meshes. But the helper classes are there for some reason, make it abit easier, keep stuff where it belongs. Thought to give it a try.

    Trying to use

    Code:
    	void CreateMeshSection(int32 SectionIndex, IRuntimeMeshVerticesBuilder& Vertices, FRuntimeMeshIndicesBuilder& Indices, bool bCreateCollision = false,
    		EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None);
    for the 'IRuntimeMeshVerticesBuilder' I'm trying to use 'FRuntimeMeshComponentVerticesBuilder'.

    Code:
    #pragma once
    
    #include "GameFramework/Actor.h"
    #include "RuntimeMeshComponent.h"
    #include "Vase.generated.h"
    
    
    UCLASS()
    class VASEGENERATOR_API AVase : public AActor
    {
    	GENERATED_BODY()
    
    public:
    	// Sets default values for this actor's properties
    	AVase();
    	~AVase();
    
    protected:
    	// Called when the game starts or when spawned
    	virtual void BeginPlay() override;
    
    public:
    	// Called every frame
    	virtual void Tick(float DeltaTime) override;
    
    private:
    
    	UPROPERTY()
    		URuntimeMeshComponent* vaseRuntimeMesh;
    	FRuntimeMeshComponentVerticesBuilder verticesBuilder; // fails cause there is no default contructor
    	FRuntimeMeshIndicesBuilder triangles;
    
    	// The outline of the vase when looking from the side
    	TArray<FVector> outlineVertical;
    
    	// The outline of the vase when looking down from the top
    	TArray<FVector> outlineHorizontal;
    
    };
    So trying to construct that 'verticesBuilder'

    Code:
    //The constructor im trying to use
    //FRuntimeMeshComponentVerticesBuilder(bool bInWantsNormal, bool bInWantsTangent, bool bInWantsColor, bool bInWantsUV0, bool bInWantsUV1)
    FRuntimeMeshComponentVerticesBuilder verticesBuilder(true, false, false, false, false) //fails with: error C2059: syntax error: 'constant'
    another try

    Code:
    Vase() : verticesBuilder(true, false, false, false, false) {}
    FRuntimeMeshComponentVerticesBuilder verticesBuilder; //fails telling me there is no default constructor
    well, trying pointer

    Code:
    Vase()
    {
    
    }
    FRuntimeMeshComponentVerticesBuilder* verticesBuilder;
    Compiles fine. Able to open the project.

    Code:
    Vase()
    {
        verticesBuilder = new FRuntimeMeshComponentVerticesBuilder(true, false, false, false, false);
    }
    FRuntimeMeshComponentVerticesBuilder* verticesBuilder;
    this compiles, but crashes the project... "The game module could not be loaded. There may be an operating system error or the module may not be properly setup".

    returning back to

    Code:
    Vase()
    {
    
    }
    FRuntimeMeshComponentVerticesBuilder* verticesBuilder;
    I again can compile and open the project. What am I doing wrong?

    Code:
    verticesBuilder = new FRuntimeMeshComponentVerticesBuilder(true, false, false, false, false); // whats the issue?
    'FRuntimeMeshComponentVerticesBuilder' is not of UClass type.

    Leave a comment:


  • replied
    Hi Koderz,

    Sorry to be a (predictable) pain in the ***, but do you know if you'll get a chance to look at updating your plugin for the new 4.16 preview?

    The new volumetric fog is such a breakthrough for my galaxy simulation (which is based on RMC) and I'm really looking forward to being able to try the two together...

    If you haven't seen what I've been doing with RMC lately, have a look at the end of my eden thread:
    https://forums.unrealengine.com/show...-Project/page4

    Leave a comment:


  • replied
    I have one more question and now its about lighting. I have a generated mesh which is one sided, normals are generated by:

    CreateMeshSection(SectionIndex, Verts, Tris, true, EUpdateFrequency::Infrequent, ESectionUpdateFlags::CalculateNormalTangent);

    But it looks like surface are filled by the light not as the closed tunnel, but like transparent roof of tunnel skip the light to the floor and its bright as just open surface. If I use this flat tube as double sided (poligons are inside and doubling for outside) its the same effect. But outer, normal objects, convex models are fine and shadows/lights there are correct. Please share your ideas whats wrong with my mesh

    here is view from inside of tunnel
    Click image for larger version

Name:	HighresScreenshot00002.png
Views:	1
Size:	821.1 KB
ID:	1126815

    and this is from outside
    Click image for larger version

Name:	HighresScreenshot00003.png
Views:	1
Size:	572.3 KB
ID:	1126816
    Last edited by Kobbersvard; 04-24-2017, 08:37 AM.

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    By default the collision is cooked at the start of the next frame. This alleviates the problem where you update multiple sections in the same frame where the PMC would cook for each call to Create/Update/Clear which made an already slow process far slower. If you need to ensure the latest mesh is available in the same frame after you update it, there is a function to force it to cook but I don't remember what it was off hand. It would be something like UpdateCollision or CookCollision.
    It calls CookCollisionNow() and works perfect, thanks!

    Leave a comment:


  • replied
    I have been using RMC and am loving it, THANKS A TON!

    I have a question regarding collision cooking. In a previous post you stated that there would be the ability to cook collision data from another thread and send it to the RMC component to use as the collider.

    My question is: Is this implemented? if so, where should I look to use this feature?
    Attached Files

    Leave a comment:


  • replied
    Originally posted by wilberolive View Post
    OK, I will wait and just press on with the bug as I have no idea how to fix it on my end. Thanks for working on RMC.
    I seem to remember a way around it if you setup the materials/sections correctly but don't remember what that was... Also could be thinking of something else.


    Originally posted by shunwang View Post
    Thanks for both of you, collision works almost out of the box - problem is (and thats why I thought its not working) that raycasting does not affect last generated mesh. It can collide with old mesh which was generated some time ago but fresh mesh is not colliding.

    So question is - how can I get to know that collision is cooked so I can wait for it or maybe use whole render in the thread? I use this True parameter of CreateMeshSection because I need not convex collider. I creating tunnels and try to raycast from inside of each tunnel its sides to get points on it.

    Thanks again guys!
    By default the collision is cooked at the start of the next frame. This alleviates the problem where you update multiple sections in the same frame where the PMC would cook for each call to Create/Update/Clear which made an already slow process far slower. If you need to ensure the latest mesh is available in the same frame after you update it, there is a function to force it to cook but I don't remember what it was off hand. It would be something like UpdateCollision or CookCollision.

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    [MENTION=28104]wilberolive[/MENTION] already got most of this (and yes it really does work) but I wanted to add one other thing. You might have to set bTraceComplex to true on the raycast parameters if you're raycasting against the mesh collision. I don't remember offhand what the defaults are for a ray trace but a standard static RMC with mesh collision will for sure work as I do that daily.
    Thanks for both of you, collision works almost out of the box - problem is (and thats why I thought its not working) that raycasting does not affect last generated mesh. It can collide with old mesh which was generated some time ago but fresh mesh is not colliding.

    So question is - how can I get to know that collision is cooked so I can wait for it or maybe use whole render in the thread? I use this True parameter of CreateMeshSection because I need not convex collider. I creating tunnels and try to raycast from inside of each tunnel its sides to get points on it.

    Thanks again guys!

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    I might be willing to share a subset of it earlier but that's still likely 2 weeks.
    OK, I will wait and just press on with the bug as I have no idea how to fix it on my end. Thanks for working on RMC.

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    Originally posted by Rumbleball
    Hey Koderz. In out project it can happen that really small actors are created, talking about 0.0001cm³. This causes issues, as it seems, with collision cooking for the RMC. The following error is dispatched.

    PHYSX: (D:\Build\++UE4+Release-4.15+PhysX_Compile\Sync\Engine\Source\ThirdParty\PhysX\PhysX_3.4\Source\PhysXCooking\src\mesh\TriangleMeshBuilder.cpp 1080) eINTERNAL_ERROR : cleaning the mesh failed
    That's a PhysX error so I probably can't do a whole lot about it. Why are you needing collision on something that small? You might be able to get around it by making the mesh larger and then scaling it down but something that small is likely to break other pieces of PhysX internally.
    Thanks. The player is able to create objects at runtime and able to scale itself as well the object that is created. Thus, objects can get pretty small. Well, will try to play with scaling.

    EDIT: Was able to resolve it for now. Scaling the object down to the size of the player and calculating the relative meshdata of the RMC by Vertex/size. This ensures the object stays visually the same and is not rejected by PhysX cooking. Thanks Koderz. Keep up the great work.
    Last edited by Rumbleball; 04-18-2017, 12:33 PM.

    Leave a comment:

Working...
X