In developing a project in recent time, it became apparent that the best way to handle generation was with a mesh that is imported and used as a volume. While I do have the generation scripting in place, I would rather like to find a point within a convex mesh rather than a sphere or box because neither fit the needs of the program. Is there a way to go about doing this? I appreciate any help I can get, thank you.
You can try select two points from Mesh randomly and then use random Alpha (although, it is not precisely random point in convex volume, but rather some discrete analogue)
There is example how you can get vertex coords from mesh:
I’ve tried to see how Niagara does it, and although it’s too complex for me to fully understand, the description kind of suggests that it spawns particles and instantly destroys those not within the mesh, if I understand it right. So maybe you can do something similar: get a random point within the mesh bounding box, check if it overlaps the mesh itself, and if not – get another random point. Of course, the efficiency highly depends on how much empty space there is in your mesh.
I suppose I could iterate upon my recursive generation loop for my program to make sure the point is within the “bounds” of the mesh. Is there a chance of it becoming stuck in an infinite loop if I use this method while trying to check the “overlap”?
In theory yes, but probably no. How complex is your mesh? Maybe you can get away with adding several boxes/volumes, and then randomly select volume => randomly select point in the volume?