Can I reset the local origin of static meshes within an actor (to change its bounding box)?

Hi,

Summary:

My source meshes all have a big offset and I want to get a more accurate bounding box.

In the following picture the red box is a DrawDebugBox of the Actor Bounds. What I want to get is the yellow box.

Detail

I’m importing a set of meshes created by converting a USD file. And creating a static mesh component for each mesh and then adding that component to a static mesh actor. There can be anywhere from 1,000 to 100,000 meshes. All the meshes have an origin of 0,0,0. They all line up correctly because the geometry uses an absolute value.

However, I want to determine the real bounding box of the “viewable” geometry (mathematically, in the above I want to subtract something from all the z values) - but I don’t know how to figure out how much and how to adjust the mesh so that it actually changes the bounding box.

Any help greatly appreciated. Many thanks for reading. I feel like I’m missing something obvious!

Hi @jdh25501!

I believe the value you’re looking for is the Local Bounds. However, what is your goal here? Are you looking to develop a tool to find that offset and transform the object accordingly?

You can only get this value through a blueprint or tool, so this would require iterating over a lot of objects

Yes, that’s exactly what I want to acheive.

I don’t mind iterating over all the objects if I can then modify things so that I don’t have to do that every time…

Thanks very much for the tip on Local Bounds. I’ll dig into that more.

So, my approach will be:

(a) Iterate over every component and use local bounds to find the “most minimum” to the “most maximum” and that will be the two points defining my “yellow box”

(b) now I want to adjust all the geometry so I don’t have to deal with the offset all the time

Unfortunately I don’t have control over the process that’s creating the USD file. My other thought was to parse the USD file and manipulate it before importing it into UE. Not sure if that’s more or less viable… Thoughts?

@jdh25501 The Unreal modeling toolkit now has a tool that lets you reset the mesh’s pivot- perhaps this is all you need to solve this problem.

Otherwise, if you need help developing the logic for this tool, let me know and I can take a crack at it

@sarahlenker - sorry for the late reply… I missed this :slight_smile:

I haven’t tried adjusting the pivot-point - I doubt that will work as I need to change the origin (my understanding is that the pivot point defaults to the center of the bounding box but can be moved)

I want to update all my meshes. In that above diagram the origin of the model is at the bottom left of the red box. And, in this example, all the meshes (the cyan stuff) have a “z-offset” of 3,000. That offset is hard coded into the actual geometry of every object (i.e. my input geometry has points at x,y,3000+z etc. and not at x,y,z with a transform of (0,0,3000).

Right now, I apply a transform of (0,0,-3000) to the actor (that contains all the static meshes) and I can position things correctly. However, I still have a bounding box that is too big.

Am I making sense??

Hi @jdh25501,

I actually can’t replicate your issue. I tried a test where I imported a new mesh with an offset pivot, and it was still able to correctly detect the bounds.

I’m wondering if something is up with your meshes. Are they all parented under the same actor/blueprint? On further research, bounding boxes are automatically calculated, so it’s not anything to do with object import. I would check your object collisions and make sure they’re accurate, and check for any geometry at the origin within the same mesh.

Let me know what you come up with!

1 Like

Yeah, my meshes are working fine now - I think I’d corrupted the original import in some way. After re-importing things are working as expected.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.