Re: Drawing in pixels

New Message Reply Date view Thread view Subject view Author view

Yves Martel (martel++at++signifi.com)
Tue, 19 May 1998 15:18:15 -0400


Bill Volz wrote:

> I need to draw some objects that are measured in pixels - they do not have a
> world coordinate size. Something similar to how pfHighlight with a highlight
> style of points works. How does one do this?

If your problem is drawing an object on the screen so that it as the
corect dimentions in pixels, then you can use the "pixel" as a world
coordinate unit in both x and z, the problem is, at what depth should
the
object be to have the correct size ?

if the camera is oriented toward the +y axis, it's a fairly straight
forward
trigonometric problem, knowing the FOV and the screen size, you can
compute y
the depth of your object:

     tan(fov/2) = (res_x/2) / y -> y = (res_x/2) / tan(fov/2) ;

        ...

        float fov_h, fov_v ;
        int res_x, res_y ;
        channel->getSize( &res_x, &res_y ) ;
        channel->getFOV( &fov_h, &fov_v ) ;
        float y = (res_x * 0.5f) / pfTan( fov_h*0.5f ) ;

        ...

The next step is to keep the object aligned with the observer...

If your problem is, knowing the object position in space, what should be
it's
size so that it is "n" pixel big? Then, you need to compute a scale
factor
from pixel-size to object-size. It is again a very similar problem:
the object is at a distance "y", compute the screen width at that
distance,

        width_over_2 = tan(fov/2) * y

this width covers res_x/2 pixels, so the factor is:

        1 pixel = (tan(fov/2) * y) / (res_x/2)

Does this help ?

_______________________________________________________
Yves Martel Signifi.gVR
mailto:Martel++at++signifi.com 417 St-pierre suite 208
Tel: (514) 288-1453 Montreal, QC, CANADA
Fax: (514) 288-4112 H2Y 2M4
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:25 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.