Issues with interection and LPD3DXBUFFER plz help

Started by
0 comments, last by LittleFreak 19 years, 10 months ago
The issue comes up when I try to test intersect. Both of my errors come up in that. My intersect code is: float cNodeTreeMesh::GetHeightAbove(float XPos, float YPos, float ZPos) { BOOL Hit; float u, v, Dist; DWORD FaceIndex; D3DXIntersect(m_Mesh->m_Mesh, &D3DXVECTOR3(XPos,YPos,ZPos), &D3DXVECTOR3(0.0f, 1.0f, 0.0f), &Hit, &FaceIndex, &u, &v, &Dist, LPD3DXBUFFER &ppAllHits, DWORD &pCountOfHits); if(Hit == TRUE) return YPos+Dist; return YPos; } The errors I am getting is : C:\NodeTree.cpp(374) : error C2065: ''ppAllHits'' : undeclared identifier C:\NodeTree.cpp(374) : error C2275: ''LPD3DXBUFFER'' : illegal use of this type as an expression c:\dxsdk\include\d3dx8core.h(30) : see declaration of ''LPD3DXBUFFER'' C:\NodeTree.cpp(374) : error C2065: ''pCountOfHits'' : undeclared identifier C:\NodeTree.cpp(374) : error C2275: ''DWORD'' : illegal use of this type as an expression c:\program files\microsoft visual studio\vc98\include\windef.h(141) : see declaration of ''DWORD'' Any ideas i mean its almost an exact copy of what the SDK says for intersect. Any ideas?
Advertisement
Look at what the errors are telling you. They''re saying that you have a couple of "undeclared identifier"s. That means that you''re trying to use a variable that you never declared anywhere.

That''s the problem when you cut and paste code from the SDK without really looking at it. It seems that you literally cut and pasted the code from the functions reference page. Change your code to this:
float cNodeTreeMesh::GetHeightAbove(float XPos, float YPos, float ZPos){ BOOL bHit = FALSE;float u, v, Dist;DWORD dwFaceIndex, dwCountOfHits;LPD3DXBUFFER pAllHits = NULL;D3DXIntersect(m_Mesh->m_Mesh, &D3DXVECTOR3(XPos,YPos,ZPos), &D3DXVECTOR3(0.0f, 1.0f, 0.0f), &bHit, &dwFaceIndex, &u, &v, &Dist, &pAllHits, &dwCountOfHits);if(bHit == TRUE)  return YPos+Dist;return YPos;} 

In your case, I doubt that you''re interested in the list of all the faces your ray has hit. If that''s true, then you can just set the last two parameters of the intersect function to NULL and it should work just fine.

neneboricua

This topic is closed to new replies.

Advertisement