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"

How to Transforms a actor's bound from the view's world-space into pixel coordinates with bounding box

How to transforms a actor's bound from the view's world-space into pixel coordinates with bounding box like

Rect(x,y,width,height)

X,Y relative to the view's X,Y (left, top) and

width,height relative to view's Z and rotation

Product Version: Not Selected
Tags:
more ▼

asked Aug 13 '14 at 08:18 AM in Using UE4

avatar image

ryuikuya
314 71 86 108

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

1 answer: sort voted first

Here's a modified excerpt from AHUD::GetActorsInSelectionRectangle, which is doing bounding box comparisons for actors inside rectangle in screen space.

It's projecting the corners of the actors bounding box into screen space, and using the FBox2D to accumulate the extents of that box in screen space.

 //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    casting to base class, checked by template in the .h
 const FBox EachActorBounds = Actor->GetComponentsBoundingBox(true); /* All Components */

 //Center
 const FVector BoxCenter = EachActorBounds.GetCenter();

 //Extents
 const FVector BoxExtents = EachActorBounds.GetExtent();

 // Build 2D bounding box of actor in screen space
 FBox2D ActorBox2D(0);
 for (uint8 BoundsPointItr = 0; BoundsPointItr < 8; BoundsPointItr++)
 {
     // Project vert into screen space.
     const FVector ProjectedWorldLocation = Project(BoxCenter + (BoundsPointMapping[BoundsPointItr] * BoxExtents));
     // Add to 2D bounding box
     ActorBox2D += FVector2D(ProjectedWorldLocation.X, ProjectedWorldLocation.Y);
 }
more ▼

answered Sep 12 '14 at 06:27 AM

avatar image

gribsoteur
1 1 1

avatar image ryuikuya Sep 18 '14 at 03:24 AM

thank you very much

avatar image CMHungSteve Jul 02 '16 at 03:05 PM

Where should I put these codes? In the files like MyActor.cpp or MyActor.h?

(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