cf_draw3d_project¶
Category: draw3d
GitHub: cute_draw3d.h
Projects a 3d world position to the 2d draw API's world space.
| Parameters | Description |
|---|---|
world_position |
The 3d position, in the space cf_draw3d_mesh submissions use. |
Return Value¶
Returns xy in 2d draw coordinates and z as the depth in [0, 1]. A negative z means the position is behind the camera and xy are unusable.
Remarks¶
Uses the current 3d projection/view stacks and the current 2d camera, so drawing 2d at the returned xy lands on the same pixel the 3d position rasterizes to -- health bars, nameplates, and damage numbers over 3d objects:
CF_V3 p = cf_draw3d_project(enemy_position);
if (p.z >= 0) cf_draw_text("orc", cf_v2(p.x, p.y + 12.0f), -1);
Related Pages¶
cf_draw3d_unproject
cf_draw3d_push_projection
cf_draw3d_push_view
cf_world_to_screen