Re: Hot to get exactly hit point in Pick?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jack Hoxley (Jack.Hoxley_at_ntlworld.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 09:27:28 +0100

I don't have the information to hand, but I thought that D3DXIntersect()
returned the triangle index and a pair of barycentric coordinates. Look
through the vertex buffer/index buffer for your mesh to identify the three
vertices that make up the identified triangle. Then feed these values, along
with the barycentric coordinates from Intersect() into Vec3Barycentric() and
you should get the exact coordinate of intersection.

The code itself shouldn't be too complicated as long as you read through the
SDK helpfiles, as it's just a case of swapping/changing a few parameters and
return codes around.

hth
Jack

"pingyingtu" <pingyingtu@hotmail.com> wrote in message
news:3cca2ed3.0409141911.505ececb@posting.google.com...
> Hi,
> I am a newbie of DX9. I'm studying Pick sample in SDK now.
> This sample uses "D3DXIntersect()" to check if hit or not. and I know
> which triangle hit.
> Could I get exactly hit point in this triangle?
> I found a message from google say:
>
> >you also get back barrycentric
> >coordinates. You can use the D3DXVec3BaryCentric to convert these
> >values, plus the three vertex locations of the hit face, into the
> >coordinates where the intersection occurred.
>
> But I don't know hot to code.
> Somebody give any sample code is appreciated.
> Thanks a lot.



Relevant Pages

  • Re: vector analysis example question
    ... case the triangle they form). ... The barycentric coordinates of the midpoint of ... t = 0.5 and you have the midpoint. ... and V' = vector parallel to the ...
    (sci.math)
  • Re: Barycentric to cartesian?
    ... the plane and then determine if it is in the triangle. ... but it leaves me with barycentric coordinates. ... the Moller-Trumbore ray-triangle intersection algorithm. ... My apologies, you are right, I was looking at the Moller-Trumbore algorithm ...
    (comp.graphics.algorithms)
  • Re: Barycentric to cartesian?
    ... the plane and then determine if it is in the triangle. ... I have been reading some stuff which id supposed to do it more efficiently, ... but it leaves me with barycentric coordinates. ... the Moller-Trumbore ray-triangle intersection algorithm. ...
    (comp.graphics.algorithms)
  • Re: Hot to get exactly hit point in Pick?
    ... > Could I get exactly hit point in this triangle? ... > Somebody give any sample code is appreciated. ... If you name those 2 barycentric coordinates "u" and "v". ...
    (microsoft.public.win32.programmer.directx.graphics)