GPWiki.org
GPWiki.org
It is currently Wed Jun 19, 2013 3:12 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Sep 13, 2012 7:30 pm 
Level 1 Cleric

Joined: Tue Feb 21, 2012 10:24 pm
Posts: 10
Hi everybody, :)

This is for the more advanced people!

I know that the DirectX9 D3DXIntersect function has the ability to gives the exact coordinates of the intersecting ray-to-polygon, and can give the distance from the ray’s starting point to the intersection point.

Now my question is, how do I retrieve that information of the exact coordinates of the ray’s intersecting point?

I think the information if I’m not mistaken is found in the LPD3DXBUFFER * ppAllHits, but I’m not sure as to how to setup the buffer, nor access the information.

Please help… Thanks!
8)

____________________________________________
Code:
// DirectX9 D3DXIntersect function:
// Determines if a ray intersects with a mesh.
 
HRESULT D3DXIntersect(
LPD3DXBASEMESHpMesh,
CONST D3DXVECTOR3 * pRayPos,
CONST D3DXVECTOR3 * pRayDir,
BOOL *pHit,
DWORD * pFaceIndex,
FLOAT * pU,
FLOAT * pV,
FLOAT * pDist,
LPD3DXBUFFER * ppAllHits,
DWORD * pCountOfHits);

____________________________________________

My variables and code:

Note: My code works great. I just need help with getting the exact coordinates of my ray’s intersection with the mesh.

____________________________________________

Code:
float XBegin, float YBegin, float ZBegin;   // <-- Starting Position of Ray
float XEnd, float YEnd, float ZEnd;           // <-- Ending Position of Ray
sMesh *LevelMesh;
BOOL Hit;
float u, v, Dist;
float XDiff, YDiff, ZDiff, Radius;
DWORD FaceIndex;
D3DXVECTOR3 vecDir;
 
// looking for collision intersection
while(LevelMesh != NULL) {
D3DXIntersect(LevelMesh->m_Mesh, \
&D3DXVECTOR3(XBegin,YBegin,ZBegin), &vecDir, \
&Hit, &FaceIndex, &u, &v, &Dist, NULL, NULL);
if(Hit == TRUE) {
if(Dist < Radius)
return TRUE; // polygons hit
}
return FALSE; // No polygons hit
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group