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 do you get the 2D coordinate a SceneCaptureComponent2D is projecting to?

Okay, So I have a minimap which is being drawn from a Scene Capture Component 2D, and it captures the whole terrain. Problem is that capturing all the actors in terrain every tick causes the game to drop below 60 FPS, so my work around is to just render the terrain once on event begin play. Then draw an image widget that overlays on top of the static minimap. Afterwards, whenever the player moves, then update the player icon on the image widget to the new position. This would circumnavigate all the computation of the minimap for each and every tick.

So, here in lies my problem: I want to get the player location in the world, and then project that into the 2D coordinates that would be on my minimap.

I was trying to find a way to get the projection matrix that the scene capture component 2D uses, and then maybe try to use that to map 3D points in world space to the 2D points that I'm trying to compute. Does anyone have any suggestions? The Scene Capture Component 2D allows you to access a custom projection matrix, but I don't want to define a custom projection matrix, I just want to grab the projection matrix that's already being used by the Capture Component, and use that to get the coordinates I want.

Product Version: UE 4.15
more ▼

asked Nov 15 '17 at 10:11 PM in Blueprint Scripting

avatar image

32 3 7 10

avatar image jefferson font Jul 26 '18 at 02:15 PM

Hi guy, have you solved the problem yet? I'm looking for this solution too.

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

1 answer: sort voted first


I was facing the same issue, as I could not find any information about that I decided to try to calibrate the SceneCaptureComponent2D's camera the same way I would do it for a real camera (with a chessboard etc) and it amees to work well.
The resulting camera matrix allows me to compute the 2D coordinates of an object based on the location of the object, the location of the camera and the rotation of the camera, it works fine for me. If that can help you the camera matrix I found for a 1920x1080 image is:
9.5971160723108721e+02, 0, 9.6055043729890588e+02,
0, 9.6132797478587622e+02, 5.4029398159070877e+02,
0, 0, 1;

And also the following distortions parameters:
k1 = 7.3166520138576770e-03
k2 = -8.2875850280479196e-02
p1 = 9.4918855815189523e-05
p2 = 2.4066111259195101e-04
k3 = 2.7776018336345953e-01

I don't know how familiar you are with projection matrices, if you are not, here is a quick explanation on how to get the coordinates of the object you wish to project in the camera's coordinate system:

alt text . Once you have that you just need to divide all the coordinates by the Z coordinate and then multiply the resulting vector by the camera matrix.

You can also apply the following formula before multiplying with the camera matrix if you want to remove the distortion of your images.

alt text

Where x' and y' is what you get after dividing by the Z coordinates. After that you just need to multiply the camera matrix with the vector (x'', y'', 1) and you should obtain the 2D coordinates of you object.

Hope that can help.

( ͡° ͜ʖ ͡°)

more ▼

answered Aug 06 '18 at 09:55 AM

avatar image

6 1 2 2

(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