Understanding view direction and deprojection

Hi,

I am confused about some things in the video.

Firstly could someone explain if the view port X and Y axes are different from World’s X,Y,Z? So my assumption about the viewport is that the editor screen is actually X horizontally and Y vertically and I realized that for the world, the X, Y and Z axes are in different directions. So is this the right understanding of viewport axes and actual game axes?
Secondly, how does the deprojection method work? We supply it constant unchanging value of screen X and Y. Originally the documentation says mouse 2d position is converted world location and direction. As the mouse is always changing location as we move that intuitively makes sense. But in our case we are not using mouse input and how do we get different values for world direction for constant value screen x and screen y input? Is it because the method internally projects the unchanging values of screen position onto the world axes where values are changing as we move the screen around although the screenx and screeny are fixed?
Thirdly, I don’t quite follow the part where the professor moves around to verify values of the world direction. For example, when mentioning about the Y coordinate, the tank in the game has the barrel pointing to the left and he says that we are pointing right and so Y is 1.0? Could someone explain the perspective to me. I am really confused.

To add to my previous query, how does the deproject method return camera world location when we supply it cross hair x and y location. How is cross hair location related to camera??

Hi Arun, I thought a lot about this as well, here is my best guess as to what is going on.

To define the direction we want, we need two points in 3-D space, so we’re going to need two FVectors to define our direction. So imagine yourself sat at the camera location, looking at the white pixel. The first FVector is the first out parameter given to the deproject function, WorldLocation.

The second FVector is (evidently) figured out somewhere in the body of the deproject function, in the engine source code. But we can imagine where this point might be: picture a glass pane pressed up against your nose, with the white pixel right in front of your eyes. As you move this glass pane outwards, in such a way that the white pixel does not move with respect to the background landscape behind it, it will trace out a vector in 3-D space. The orientation of this vector is WorldDirection!

Question 8 on the mid-section quiz asks us to imagine this scenario, and refers us to Lecture 135 for the explanation. I re-watched the video and did not find it, so if anyone has, please share the timestamp. Otherwise, the above is my best guess, and I hope it helps you imagine what’s going on as well.

Joe

I know it’s been a while, but you learn better by explaining, so let me take a stab at it and if anyone feels the need to correct me, please do so. As I understand it, the 3d render is processed by the GPU as “virtual” 3d space, and then “projected” onto a 2D screen (your monitor). Every pixel on your screen is a vector that was rendered from 3d space to 2d space by the graphics card. Imagine 1920x1080=20,73,600 little “lines” being drawn between your “virtual” 3d rendered space and “projected” onto the 2d screen. That is all OUTPUT by the GPU for display. But to fire our weapon ingame, that requires user INPUT, which reverses the whole process. Now we are taking a single pixel of 2d space, drawing a line onto our “virtual” 3d render and connecting the dots. That is why it is called “Deprojecting” during the input phase and “projecting” during the output phase.

As for the crosshair, it has nothing to do with the code. Remember that we set that up in Blueprints. The crosshair is only a 2d image mapped to the screen that overlays the Deprojected function. If you were to delete that little white dot (or .tga image of a crosshair), the vector would still be there, and you could still shoot, you just wouldn’t know where you’re shooting from.

1 Like

Privacy & Terms