No announcement yet.

"Explode" Static Mesher Adder Blueprint

  • Filter
  • Time
  • Show
Clear All
new posts

    "Explode" Static Mesher Adder Blueprint

    Hey everyone,

    I am working on a project where I taking in an exceltable of data and use the dataset to generate coordinates for different trees. Each type of tree is using a unique .csv file and unqie blueprint. I am adding a random value in order to scatter the trees around a bit, the issue is that the seed isn't constant so the random values keep changing when I build or reopen the file. I would like to start adding other objects into the scene and need to control where each tree is. So What I would like to do is to "Explode" (Im using the word as it is used in Rhino) the blueprint so I get each static mesh as unique scene components so I can move them around manually afterwards.

    A quick extra question: The scene is quickly becoming very heavy. I suppose it's to be expected when placing a static meshes with around 40.000 vertices each. How would I optimise this without loosing much detail?

    First of all, if you want to keep getting same random result every time, use random [something] from stream. Stream holds seed value that can be used in any random operation.

    Another good thing is using LOD system for each tree, you can't have a lot of high poly trees in your scene and besides, why should you? The point is that you can't see the tree details from 200m distance, you only see tree as a blur. So either go to your 3d editor and make some LOD models or use built in UE4 system that you can find within static mesh options.

    Also avoid using "add static mesh component" for foliage. Maybe they have change it but a while ago there was known that using this component calculates LOD distance from actor bounds and not the respective component therefore untill you will be far away from your actor, all the trees will remain in the highest details possible. To avoid this, use "hierarchial instanced static mesh" (further just "HISM") component for each different tree mesh. This component calculates LOD distance from each instance instead one actor. I've highlighted different to point out that you don't need to add 200 HISM components for one mesh, instead you will add 200 instances for one hlod component.

    Hope this helps.
    Last edited by Mat5i6; 11-25-2018, 05:51 PM.


      Thank you for your reply. Random from Stream was very helpful, although I would still like to be able to edit each static mesh directly in the editor. Is this possible?

      About the "Add hierarchial instanced static mesh component", I don't understand how to make it create 200 instances using the transformation values from the .csv file. I somehow need to control the details of the component from within the construction strip.

      Also, I am currently creating a new script for each different mesh. How do I make it so that I can set the values and mesh in the details of the actor-blueprint? Just need to know what to google.


        I would still like to be able to edit each static mesh directly in the editor. Is this possible?
        Depends on what exacly you want to do with the specific instance. But mostly the answer would be: yes but not out of the box. Problem is that every time the BP gets constructed all instances are removed and build again so if you want to add some additional transform to it, you would need to remember those values somewhere. I would chose some map/dictionary to remember which instance index had which transform and then sum it with your cvs values and random results.

        I don't understand how to make it create 200 instances
        Once you create an HISM component you can add instances from it's component object reference (the blue pin on the right named"return value") and just type add instance or add instance world space. There you can manipulate with each instance transform and that's where you should link your math.
        I would suggest you to look for some documentation or tutorial about (hierarchial) instanced static mesh components, maybe you will find some useful functions. But feel free to ask if you want to.

        Also, I am currently creating a new script for each different mesh.
        If i get this right, are you trying to create a separate actor for each tree? If so, there is no need for any of this HISM shenanigans. Just create an empty actor with static mesh and set it during construction.

        How do I make it so that I can set the values and mesh in the details of the actor-blueprint?
        If you want to set variable outside of BP let's say somewhere in the scene, simply click on the specific variable and tick the "Instance editable" checkbox in the variable properties. Then you will find those variables exposed most probably in the default group tab (depends on the group the variable is set in) when you click on your actor in the scene. Also worth to mention if you tick "expose on spawn" you can set the variables even before construction script gets called but you can set those variables only by using node "spawn actor from class" (also note, you cannot spawn actor from constructor for some to me unknown reason)


          Thank you so much! Getting very close now. Just an issue with reading the datatable when making it a variable. Any idea how to solve it?

          EDIT: Never mind, I figured it out. The component didn't know the which structure was used to create the datatable.
          Last edited by Ludvig1008; 11-26-2018, 08:17 AM.


            I've never used data tables before so I'm afraid that I won't be much of a help with this problem. But my wild guess is that UE4 is funky again so try to either right click on the node and refresh it or delete the node, compile your BP and BP where the function is located (if you have made it) and place it again. The latter helped me yesterday when i had similar problem with my custom function that returned structure as a return but it's name wasn't updated.


              Hey! I've come a long way since last time, but the initial question steel needs answering:

              As you can see, I have plotted each tree/bush according to a datatable. Now I would like to start manipulating each one from their starting position (which is from the datatable) in order to fix issues like the one shown in the picture (the bushes are floating in mid air and should be moved to the sides). Does anybody know how to this? Alternatively, is it possible to project them down onto the landscape as though they were foliage?


                Hi there again.

                In order to manipulate as I wrote there is no out of the box solution to my knowledge (feel free to correct me).
                I would probably go with a map of int : transforms which would be mine offset regulator (basically, your DB position + position from map, DB rotation + rotation and DB scale * scale) for some index. Unfortunately this approach can get laggy with few hundreds of instances (depends on a machine you are using but when I had over 200-300 it was laggy simply because it needed to remove and place again all those instances with every change of any value in that map).

                Alternatively if you need to manipulate position just because you want to avoid scene obstacles. I would recommend using any kind of trace (line, sphere, rectangle, ...) and look for landscape. If it hits anything other than that, you should either search for another location or skip that instance. This way you will get properly Z aligned foliage without any collisions with custom enviroment and as a bonus no further user manipulation needed.

                Also if you don't mind me asking, why do you need to load positions? If I would need to distribute foliage around my landscape I would definitely use Procedural foliage spawner. Which is already in UE4 with tons of options and minimal setup can take no more than 10 minutes. It's also probably more optimized than what I could ever come up with and you can add or remove foliage with brushes.


                  Thank for reply. That datatable I use to distribute the trees, is a dataset containing all conflicts over 30 fatalities from the 15th century until today. The idea is to turn the data into a forest. Would I be able to do this with the Procedural foliage spawner?

                  The tracer seems easiest and will do what I need it to. How do I detect landscape and other objects though? Don't know how to get them into the construction script.


                    Oh nice. Well in that case I believe that Procedural foliage spawner isn't suitable for your task. To my knowledge it uses only random streams to randomly place foliage all around.

                    For tracing, I would go with, in your case sphere trace by channel and either compare hit actor pin with your landscape reference (by manual setting from exposed variable or get all actors of class and get Nth item from array; most likely 0) or you can drag hit actor pin and cast it to Landscape I believe is the one. Then either use == and branch to separate Landscape from everything else or use an exec pin from cast node (cast failed happens when something other than Landscape or it's child class actor is hit)

                    I hope this will get you closer to your goal


                      Thank you! That work very well. There is an issue where the trees hit each other and gets cancelled out by the branch(hit actor == landscape), but worked around it by removing some colliers so its a problem only for a very few trees. I'm presenting the project next week and I'm very happy with the outcome. Thank you so much!


                        No problem, I'm glad that it worked out. Good luck with the presentation.