Martin Roth (roth++at++ifi.unizh.ch)
Fri, 17 Feb 1995 10:24:25 +0100
I've got a similar problem to David Luebke's. I`d like to select geometry
out of my scene using the mouse clicking on it. To this aim I'm constructing
a ray starting from the eyepoint which I use to intersect with in the
corresponding pfGeode draw callbacks. I'm doing this as follows:
pfChannel channel;
pfCoord view ; // current viewpoint
pfSeg ray; // ray to select geometry
float hor, vert; // horizontal and vertical field of view
float mx, my; // coordinates of mouse click
pfMatrix m; // transformation matrix
pfGetChanFOV(channel, &hor, &vert);
pfMakeCoordMat(m, &view); // get actual transformation matrix
pfMakePolarSeg(&ray, view.xyz,
-pfArcTan2(mx, 1.0f/pfTan(hor/2.0f)),
pfArcTan2(my, 1.0f/pfTan(vert/2.0f)),
999999.9f);
pfXformVec3(ray.dir, ray.dir, m); // transform ray direction
The idea is the following: I imagine myself standing at the origin and looking
in the direction:
h: 0
p: 0
r: 0
Then I get the horizontal and vertical FOV of the channel's current viewing
frustum. Then I calculate the angular difference of the ray through the middle
axis of the frustum to the one defined through the mouse click in the channel's
pipe GL window. The mouse coordinates are normalized in the range [-1.0, 1.0].
I hope my trigonometry isn't all wrong. Now I get the intersection ray
when calling pfMakePolarSeg with the angular differences h resp. p. What's
left is a transformation of the ray's direction according to the one of the
current view.
The whole thing works acceptable. But still only acceptable. I can select
geometry from whereever I'm looking at it, so the transformation stuff seems to
work, but it's only real exact when I don't click near to the GL window's frame.
For big angular differences I don't seem to get an exact ray. Is this because
the matrix doesn't take into account the projection into screen space?
Could the whole thing (selecting geometry through mouse clicks) be achieved
in a simpler and more exact way?
Any suggestions are welcome...
Martin
_______________________________________________________________________________
/| /|) S. H. Martin Roth
/ |/ |\OTH Student in Computer Science
ETHZ, Swiss Federal Institute of Technology Zuerich email: sroth++at++iiic.ethz.ch
UniZh, University of Zuerich email: roth++at++ifi.unizh.ch
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:58 PDT