Home Overview FAQ Documentation Download Mailing List Geomview For Windows? Support Users Development Bug Reporting Contributing Contact Us Sponsors
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Closed REQ 5720]: Geomview external module
Hi -- yes, we did get your earlier note, sorry not to have responded. Though you can't directly get a "scale factor" from geomview, you can get information that lets you do what you're asking: specifically, you can have geomview send you a transformation matrix giving the current position of the object. You could get geomview to notify you whenever the transformation changes; however, it's probably easier to write it as a polling loop, which periodically asks geomview for the current transformation. In that case, suppose your object's name (in the geomview object browser) is "mesh". You'd send a command to geomview like: (write transform - mesh focus) This means: Send me the transformation matrix which transform from coordinates of "mesh" to the coordinates of "focus" (which is the currently-active camera window). Your module will receive, on its standard input, something like transform { 0.74639952 -0.00292574 0.05561925 0 -0.00632918 0.7381438 0.1237648 0 -0.05533536 -0.12389196 0.7360726 0 6.4132237e-09 -7.4794553e-07 -4.45694399 1 } Call this 4x4 matrix T. Let p = (x,y,z,1) be the coordinates of a typical point in your object. Appending the "1" represents it properly in homogeneous coordinates, which are what geomview uses. To get the corresponding coordinates in the camera's coordinate system, multiply p . T (note that p appears as a row vector multiplied on the left, not a column vector on the right; that's a common convention in computer graphics). Let p . T = (X, Y, Z, 1), so X,Y,Z are camera coordinates. Assuming it's a perspective camera (the default), that point projects on the screen to something related to (X/Z, Y/Z), multiplied by the window size in pixels, and divided by roughly the camera's field of view in radians (actually, it's twice the tangent of half the angular field of view). GCL commands "(write window - focus)" and "(write camera - focus)" would return information which would let you compute that. However, if you typically adjust the view by scaling the object and/or moving the camera (as opposed to zooming, which changes the angular field of view), it might be easiest to just assume a typical value for window size and field of view: say, 500*(X/Z, Y/Z). That's about right for the default 350-pixel window and 40-degree field of view. Now you can estimate the screen position of a given point on the mesh. The first three elements of the first column of T (.746, -.006, -.055 in this example) are a vector parallel to the screen X-axis; call this vector Sx. So, the screen radius of a small ball of radius r, lying near p in the mesh, is 500 * (magnitude(Sx) * r / Z) This is probably the kind of expression you need to compute optimal feature sizes in the objects you're drawing.
|
||
Home | Overview | FAQ | Documentation | Support | Download | Mailing List Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors |
|||
site hosted by |