Mapping 3D vector to 2d screen space

I’ve almost got this working but having problems mapping the z of the camera.

I have a thing made up of nodes spinning a 3D space, using oFEasyCam to control the world. I’m trying to map cross hairs over the top to track for example one of the nodes. I’m using worldToScreen to map the nodes xyz to the screen, but it doesn’t seem to take into account the zoom level of the camera. The cross hairs move correctly but the mapping is off. Is this something to do with projection Matrix or something? I tried getting the camera’s z position then offsetting the vector before applying worldToScreen. So close to getting this working so if anyone can point me in the correct direction that would be great.

I am sure there is a much better way, but I recently had the exact same issue on something and I remember recording the original z value of the camera, then grabbing the current z value dividing (can’t remember if it’s new/old or old/new…) and using that value as a scalar for the points, it seemed to help. It’s a hack for sure and there’s def a better way…

Thanks Zach - trying that idea and there’s definitely improvement but still not quite right. I’ll keep digging.

Hey @bjdawes. I think I’ve done this, or something similar at least. Are you still working on this? If so let me know and I can dig out my code to find the relevant bits.