x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Getting the bounding box of a static mesh collision data

I have a static mesh imported into my project, which includes simple and complex collision data. I can see both fine in the UE4 mesh editor. Now I want the bounding box of the simple collision data of a given UStaticMeshComponent in C++. Is there an easy way to achieve this?

Product Version: UE 4.21
Tags:
more ▼

asked Mar 05 '19 at 12:12 AM in C++ Programming

avatar image

haimat
236 20 36 42

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

The collision data is storing @UBodySetup->AggGeom

You can access these data through: Actor->GetStaticMeshComponent()->GetBodySetup()->AggGeom;

more ▼

answered Mar 05 '19 at 01:26 PM

avatar image

avinchen111414
21 1 1

avatar image avinchen111414 Mar 05 '19 at 01:26 PM

The member "BoxElems" is exactly the bounding box data.

avatar image haimat Mar 05 '19 at 08:16 PM

Ok, that works, thanks. I am doing the following:

FBoxSphereBounds bsBounds;
StaticMeshComp->GetBodySetup()->AggGeom.CalcBoxSphereBounds(bsBounds, FTransform());

However, that gives me the bounds at center 0,0,0 - how can I get the correct world space location, what do I have to use as transform?

avatar image avinchen111414 Mar 06 '19 at 03:01 AM

Of course you get the bounds at the origin. Cause FTransform(), the default constructor, construct a ZERO translation. The second params of CalcBoxSphereBounds is LocalToWorld transformation.

avatar image avinchen111414 Mar 06 '19 at 03:03 AM

Try AggGeom->CalcBoxSphereBounds(sb, FTransform(FVector(100.0f, 100.0f, 100.0f))); You will find the origin of the box is translated to (100.0f, 100.0f, 100.0f)

:)

avatar image haimat Mar 06 '19 at 08:18 AM

Ahh I see, that works, thanks a lot!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question