The I know how to get Actor;s bounds but how to get the bound’s 8 Vertex coordinates.
I presume you mean in c++ right?
You can use a mapping and the actor bounds
Code below is for a single actor, YourActor
It is mostly my own code I wrote for a SelectionBox pull request to Epic. The bounds mapping idea was supplied by Epic/James Golding
Enjoy!
//The Actor Bounds Point Mapping
const FVector BoundsPointMapping[8] =
{
FVector(1, 1, 1),
FVector(1, 1, -1),
FVector(1, -1, 1),
FVector(1, -1, -1),
FVector(-1, 1, 1),
FVector(-1, 1, -1),
FVector(-1, -1, 1),
FVector(-1, -1, -1)
};
//Get Actor Bounds
const FBox EachActorBounds = YourActor->GetComponentsBoundingBox(true); //All Components
//Center
const FVector BoxCenter = EachActorBounds.GetCenter( );
//Extents
const FVector BoxExtents = EachActorBounds.GetExtent( );
for(uint8 BoundsPointItr = 0; BoundsPointItr < 8; BoundsPointItr++)
{
const FVector EachVertex = BoxCenter + (BoundsPointMapping[BoundsPointItr] * BoxExtents) );
//Do something with EachVertex, like draw it
}
1 Like
thank u very much it real worked