[X3D-Public] World-to-screen coords in Contact (and others)?

Michalis Kamburelis michalis.kambi at gmail.com
Wed Jul 13 20:51:30 PDT 2011

Dave A wrote:
> I may be missing something obvious, just not seeing an API for it:
> Is there a way to get a screen coordinate (or viewpoint space) for a
> world coordinate in Contact?
> Or any other player?
> X3DOM?
> Any help appreciated.

Not sure will this help, but in my engine (view3dscene) there are
extensions to get matrices to convert between camera-space and world-space:


You can pass such matrix for example to a Script (only KambiScript or
compiled ObjectPascal code for now in my engine), or to a shader (like
ComposedShader with GLSL). This way you can convert freely between
world-space and camera-space everywhere (just multiply 3D point by
appropriate matrix, taking care of homogeneous coords).

In theory, you could construct such matrix yourself (observing Viewpoint
or ProximitySensor output), but it's not that simple in practice (e.g.
you don't know the (final) used field angles or aspect ratio).

To get to screen space you would need to additionally get screen size.
There isn't a standardized way to get this, as far as I know. With
InstantReality, I think you can observe LocalWindow.size output event
although I didn't test it. This may be implemented as an extension in
view3dscene if there's a demand.

Hope this helps,

More information about the X3D-Public mailing list