Hi all,
I have a PCG graph as part of a BP, along with the static mesh components I’m reading from.
I’m using the Get Actor Data to parse through those, and filtering the components by tag to only read some of them.
I’m filtering the actor as self and my data retrieval mode is Single Point. With that mode, I get access to the $BoundsMin and $BoundsMax per axis, but that’s the bounds of the whole actor, not that of the filtered components.
How can I get access to the bounds of the filtered Static Mesh components ?
Hi Mickaëlle,
Thanks for reaching out.
In your case, what happens is that the single point really means ‘a single point for the whole actor’ which happens before any component filtering.
However, if you’re in a situation where you can retrieve the static mesh in some way (which unfortunately, the get actor data does not at this point in time), you can get the bounds of the static mesh with the Get Bounds From Mesh node.
It could be as simple as you having a custom BP node that adds an attribute containing the mesh on the single point data (or as a tag), which would be efficient & simple.
Let me know if you have more questions,
Cheers,
Julien
Merci Julien !
Fair point, I was trying to solve everything from within PCG, forgetting I can feed some custom properties from BP.
I can get the static mesh reference in PCG: Get Actor Data [Get Component Reference ] > Get Property From Object Path [StaticMesh]. I was considering grabbing each actor’s transform in PCG (which I have already done), spawning static meshes, getting their bounds and then deleting the meshes to only keep my bounds info, but that sounded pretty dirty.
I think I’ll check my bounds in BP and store the result I need in a variable and just work with that property in PCG.
Thanks for opening my eyes.
Hi again Mickaëlle,
I had forgot for a second that we had a way to return the component reference, so you can make it pretty simple then, no need for BP at all in this case.
1- Get actor data w/ components reference - will get you all components with their tags as attributes
2- Filter on the components you’re interested in - w/ filter by attribute
3- Get the static mesh in the static mesh component w/ Get Property From Object Path
4- Get relative transform using RelativeLocation, RelativeRotation and RelativeScale3D w/ Get Property From Object Path
5- Use the static mesh in Get bounds from mesh to get the local space bounds
All should be there, no need for BP after all.
Bonne journée,
Julien
Am I missing sth?
The debug preview of Get bounds from mesh in the viewport looks accurate but the bounds attributes all have the same value, which make no sense.
(the subgraph retrieves all the relative transforms, makes them absolute and merges them into multiple points within a single data set)
[Image Removed]
Since you have warning on the Bounds From Mesh node, I’ll assume what’s wrong here:
- you get the static mesh from the object path - that’s ok
- you pass that to override the “Attribute” part (e.g. the attribute name to read from) in the Bounds From Mesh - that’s not going to work.
In this case, just do an “Add Attribute” on the output of your “Components to Points” subgraph, adding the attribute from the Get Property.
This will add the static mesh attribute to all of your points, and in the Bounds From Mesh you can specify that attribute name or use @Last and you should be fine.
Cheers,
Julien
I’ve got it working fine following your advice, unfortunately the $Bounds I get from the following setup are still the same for each component. Originally I misinterpreted it as the data being passed through wrongly, but now I believe that this is just because it grabs the bounds from the static mesh asset, before any transform has been applied to it.
[Image Removed]
So I *think* that what I need is just to scale the $bounds with the components’ scale.
I’ve tested it with a single component and it seemed to work fine and make sense, but I’m struggling with making it work over multiple components.
[Image Removed]
I’ve tried making a loop subgraph, the content of which is the following:
[Image Removed]but this is still complaining about multi entry attribute sets.
I thought perhaps I need to find a way to turn point data into an attribute set but didn’t find a way to solve it.
Thanks for your patience,
Mickaëlle
Found it, I needed to use Attribute Partition with $Index to split each point into its own data set and loop over this.
[Image Removed]
Hi Mickaëlle,
So normally, after the ‘bounds from mesh’ node, all your points (which should be 1 point per component) should have their proper bounds.
After that, if you want to scale the bounds according to the scale on the points, you can also use the Apply Scale To Bounds node (which will reset the scale to 1, and make the bounds := bounds * original scale).
That might remove the need for you to do the partition+loop.
Let me know if you need more details.
Cheers,
Julien
After bounds from mesh, the return value of the bounds is the untransformed value. Whatever scale or rotation the component has had is not reflected in the bounds vlaue.
(even though the preview appears correct).
Using a 1m engine cube
Component transform is:
[Image Removed]Preview in the viewport:[Image Removed]Attribute inspection:
[Image Removed]
This is why I have been trying to manually apply the components transform to the bounds. Scale and Position I can manage, but the Rotation is causing me to melt down.
[As a reminder, the idea behind all this is to find the furthest vertices on every axis and define the center of all the components]
But this is correct - the 1m cube has [-50cm, +50cm] local bounds, and you have no rotation and a scale of (4, 1, 1).
If your point doesn’t have any rotation, then using Apply Scale To Bounds would work (would end up with [-200cm, -50, -50] and [+200, 50, 50], but of course that doesn’t work if there is a rotation.
What you need to do is to transform the local bounds using the transform.
As I said, it’s very unfortunate that we don’t expose that right now, but you could the following with maybe less subgraphs/loops.
Either
(A)
- Construct all 8 points at position + bounds min/max per axis
- Transform all 8 points with Transform Location
- Reduce to find min/max
(b)
- Transform the local center ($LocalCenter) by the transform ($Transform) into WS_Center.
- Transform the local axis, then scale each by the transform scale
- .. Construct all 8 points
Ultimately the easier solution is that we add a custom property for that on the points directly, but that might come later (5.8).
Hopefully this clarifies a bit the situation.
Cheers,
Julien
Hi Julien,
I used method A in the end, I had already started using Transform Points when you suggested Transform Location, so I kept going down this route.
So I’m constructing each point manually (not the neastest but the easiest for me), transforming them, merging them, then reducing.
[Image Removed]
Thanks for your guidance!