| Re: Anatomic object graphic in IDL [message #43755] |
Wed, 27 April 2005 09:21  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
Valentine wrote:
> Ok, what I mean is to return the
> coordinates (or better, their indexes) of a polygon of a
> polygon-model. I mean, I want to Know exactly which are the indexes
> (x,y,z) of the object when I push down in my model with the mouse.
There is no built in function in IDL to do this that I know of...
Off the top of my head you would need to select your object, cast a ray
from your viewpoint thru that object, then perform triangle/ray
intersection tests on that object's polys. Selection is built into IDL.
Polygon/ray intersection is well published on the web and there are
many algorithms to choose from (Here is an excellent resource:
http://www.realtimerendering.com/int/ I've used the Haines ray/poly
code with success. I like the Gems code since it is available online
and it is straightforward C. Easy to drop into a dlm.)
But casting the ray will take a bit more work.
Using the view parameters, I would construct the view pyramid (far clip
plane to viewpoint). Then when you click on your window, get the X,Y
window coordinates of the mouse click. Assuming your view is projected
onto the near plane, your near plane location will give you your Z.
Then cast your ray from your viewpoint thru this X,Y,Z location. My
guess is that your coordinates returned from PickData will be in screen
coords but you should be able to calculate position on the projection
plane by normalizing the screen coordinates.
This approach may not work and even if it does there probably is a
better way to cast your ray. I got very little sleep last night since
my son has been fighting a cold and was up all night crying so I am not
thinking too clearly (It was like when he was a newborn.) But at any
rate this should get you started. :)
-Rick
|
|
|
|