Understanding 3d world and GUI camera space

Im quite new to 3D programming. Im using NGUI as well. Ive realized that while i can understand answers to my questions and look up solutions i have a fundamental lack for understanding what the difference is between the 3D world and the 2D gui screen. I dont even know where to start. For example i want to make a Ngui object draggable so i give it the position of the mouse when dragged but the object dissapears far away.

What should i read up on?

The screen dimensions are measured in pixels whereas the world measurement is in meters. If you want to convert screen positions to world positions, you need to use a specific camera for the projection - in most cases it’s the active camera. E.g. attaching a 3D object in the world to your mouse on the screen depends on the distance from the 3d object to the projecting camera.

For every application that uses graphics, a viewport needs to be defined. The viewport is a rectangular viewing region of the screen where the 3D scene is projected. It is nothing more than mapping the 3 dimensional objects to the 2 dimensional plane.

The following image shows a typical 3D scene with a perspective projection.

alt text

The eye is where the camera is and the viewport is the plane where all the objects found in the view frustum are projected to.

The view frustum is a pyramid with two clipping planes. Objects or parts of objects found outside the frustum, won’t be rendered. It is not possible to define a near clipping plane closer to the observer than the viewport.

When the human eye looks at a scene, objects in the distance appear smaller than objects close by. This is called perspective and this is used for 3D games and applications. Perspective projection is the final image rendered onto the viewport with the objects scaled according to their distance from the observation point.

Orthogonal projection on the other hand, ignores the scaling effect and projects objects to the viewport maintaining their original size.

The following diagram shows the orthogonal projection.

alt text

Source:
https://code.google.com/p/libgdx/wiki/GraphicsFundamentalsViewport

If your looking for something to read, maybe you should read the Unity Manual. It covers all the basic stuff you need to know. It helped me too! :slight_smile:

Unity Manual Link: Unity - Manual: Unity User Manual 2021.3 (LTS)