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

Alex x37v.alex at gmail.com
Tue Mar 14 16:05:04 PST 2006


thanks, the distance help, i cannot seem to get the
get-camera-transform to give me the data i want.
this works great if i only rotate (no scale or translate camera):
(clear)
(define x (build-cube))
(push)
(translate (vector 3 0 0))
(colour (vector 1 0 0))
(define y (build-cube))
(pop)
(define getpos (lambda () (vtransform (vector 0 0 0) (get-transform))))
(define (render)
  (grab y)
  (display (vector-ref (vtransform-rot (getpos) (get-camera-transform)) 0))
  (newline)
  (ungrab)
  )
(desiredfps 5)
(every-frame "(render)")


getting the screen coordiantes would greatly improve my current
project, if you can point me in the right direction for adding this
get-projection-transfrom and get-viewport-transform I'll look into
adding them myself.

-Alex

On 3/14/06, Dave Griffiths <dave at pawfal.org> wrote:
> > 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