owl-project / NVISII

Apache License 2.0
319 stars 27 forks source link

Understanding World Position #137

Closed mlevy2525 closed 2 years ago

mlevy2525 commented 2 years ago

For the method get_world_position of a transform what's the unit of measure to understand this. Is it distance from the origin in terms of pixels of mm?

natevm commented 2 years ago

The units are up to you, though position is always a world space measure. That worldspace position is independent of any camera. For example, a point light could be at (0,0,1) and a floor mesh could be at (0,0,0), so the distance between those objects would be 1 along the zed axis. These positions are relative to a global world origin at (0,0,0).

As far as light transport goes, it is assumed that this unit is in meters. But you might choose to render centimeter measured objects in a meters scale, just for rendering purposes.

Pixels is a screen space distance measurement, and depends on the camera you are using, the resolution of the image you're rendering, etc. Since nvisii supports multiple simultaneous cameras, it's largely up to you to transform the world space position into a camera coordinate system using the cam_entity.get_transform().get_world_to_local_matrix() and cam_entity.get_camera().get_projection() matrices.