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"

Find objects overlapping a frustum

Hi,

I would like the player to select objects in 3D space by drawing a selection rectangle (like in every RTS).

Now, since objects are in 3D that UI's rectangle is a frustum in the game's world. So I need to find objects which colliders overlap the said frustum. Is there an already present solution in UE for that? Alternatively if not I can of course present the frustum as 6 (or 4) planes and check if objects are on the correct side of all the planes. Is there a method to find objects on the positive side of a plane?

Thanks!

Product Version: UE 4.10
Tags:
more ▼

asked Feb 08 '16 at 11:54 AM in C++ Programming

avatar image

fszczemton
291 16 19 248

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

1 answer: sort voted first

So it seems there's no already-written function to that.

I think I'll go with the following solution:

  1. Since FPlane holds the plane in form Ax + By + Cx = D then X, Y and Z coordinates of FPlane are the normal vector of the plane (N0)

  2. There's a FVector::PointPlaneProject static method. Use this method to project the sphere center (Rs) onto plane, get Rp

  3. Rs - Rp is the vector from the sphere center's projection to sphere's center. Calculate a dot product of this and the plane's normal vector: N0 * (Rs - Rp)

  4. Now, if that dot product is larger than -SphereRadius then the sphere is on the positive side of the plane or intersecting with the plane.

  5. Do that for every plane in the frustum, if the plane check above succeeds for all the frustum planes, then the sphere overlaps the frustum.

Needs consistent orientation of the frustum's planes of course.

Here I'd also like to express my disappointment with the fact that FPlane inherits from FVector. A plane is not a vector.

more ▼

answered Feb 09 '16 at 10:07 AM

avatar image

fszczemton
291 16 19 248

(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