[fluxus] Location in screen coordiantes WAS Re: a couple of questions

Dave Griffiths dave at pawfal.org
Tue Mar 14 02:07:24 PST 2006


> hmm, I'm still struggling with this, I want to be able to find the X
> and Y position of an object relative to the screen, ie an object at
> 1,0,0 would have a greater X then something at 1,0,-10 because of
> perspective.
> also, if i move the view to the right with the middle mouse drag, i'd
> like the X position to change because an object would move the the
> right (ie. the center of the screen should be (0,0))

(get-camera-transform) returns the current camera transform matrix, if you
transform the worldspace points by this you'll get the points in camera
space (relative to the camera), which may be enough for your purposes.

to go all the way, we also need a (get-projection-transform) call to get
the matrix that will project the points and do the perspective to put the
points in NDC space (normalised display coordinates). then we also need
(get-viewport-transform) which would then scale the NDC points to account
for the resolution of the window, and get you the pixel coordinates of a
point.

I'll put these on the todo list.

> I'd also like to find the distance from the camera to an object.
>
> is there any way to do this?

(vdist obj-position (vtransform (vector 0 0 0) (get-camera-transform)))

untested, but should do it

cheers,

dave




More information about the Fluxus mailing list