Fastest way to find world -> screen mapping

Tim Monks,, tim at merlin.resmel.bhp.com.au
Fri Jun 7 11:05:53 AEST 1991


Original question :
> What is the fastest way of mapping (x,y,z) (world coords) to (sx,sy)
> (screen coords) on a SG?

In article <1991Jun4.235906.4447 at odin.corp.sgi.com> 
   kurt at cashew.asd.sgi.com (Kurt Akeley) writes:
>
>If the result of an operation is intended for anything other than the
>framebuffer, it is NOT the job of the graphics hardware to do it.  The
>best way to transform points is to write code that transforms them on
>the MIPS processor.
>
>If the transform is from world (object) coordinates to screen coordinates,
>no matrix inversion is required.
>

The necessary matrix equations are in Appendix C of the old Graphics Library
Users Guide version 2.0. (007 1201 020)  I cannot find the same info in any 
of the newer documentation. I have used this successfully.

When the destination is the framebuffer there is another way.  My
particular application was in 2D, so all the transformations are linear. 
It was only necessary to find the scale factor that mapped 1 pixel in
screen space to a dx or dy in world space (these will be different of course).
The following code snippet  did this :


    Coord	world_x_origin, 
		world_y_origin,		/* map screen (0,0) -> world coords */
		world_x_pixel, 
		world_y_pixel;		/* map screen (1,1) -> world coords */
    :
    :
    makeobj(w->screen_to_world = genobj() );
      reshapeviewport();
      ortho2(w->world_xmin, w->world_xmax, w->world_ymin, w->world_ymax);
    closeobj();
    callobj(w->screen_to_world);

    /* find mapping of screen coords -> world coords */
    mapw2(w->screen_to_world,(Screencoord)(0), (Screencoord)(0), 
	  &world_x_origin, &world_y_origin);
    mapw2(w->screen_to_world,(Screencoord)(1), (Screencoord)(1), 
	  &world_x_pixel, &world_y_pixel);
    w->x_pixel_to_dx = (world_x_pixel - world_x_origin);
    w->y_pixel_to_dy = (world_y_pixel - world_y_origin);
    :
    :

>From article <1991Jun6.054818.29804 at cs.umn.edu>, 
    by slevy at poincare.geom.umn.edu (Stuart Levy):

> I've wanted to do this too, with yes, destination being the frame buffer.
> This may not be what Mr. Monks has in mind, but for example what is
> the easiest way to draw a "wide point" -- a blob of fixed screen-space
> size, in the location appropriate for a 3-space point, and hidden by
> surfaces in front of it?  GL supports wide lines directly but I don't find
> anything similar for points.  Single-pixel points can be hard to see,
> especially on video.
> 

Has anyone got a good way of making a wide-point in 3D, as an extension of
the code above would not work since the scaling is position dependent?
--
Dr Tim Monks                                
Image Processing & Data Analysis Group | (direct)   (+61-3)566-7448
BHP Research - Melbourne Laboratories  | (switch)   (+61-3)560-7066
245 Wellington Rd, Mulgrave, 3170,     | (fax)      (+61-3)561-6709
AUSTRALIA                              | (internet) tim at resmel.bhp.com.au



More information about the Comp.sys.sgi mailing list