With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.
// yes, convert ray to model space
D3DXVECTOR3 vNear,vDir;
D3DXMATRIX invMat;
D3DXMatrixInverse(&invMat,NULL,&m_combinedMat);
D3DXVec3TransformCoord(&vNear,pvNear,&invMat);
D3DXVec3TransformNormal(&vDir,pvDir,&invMat);
// test for intersection
BOOL bHit;
DWORD dwIndex;
float u,v;
float dist;
D3DXIntersect(m_pMesh,&vNear,&vDir,&bHit,&dwIndex,&u,&v,&dist,NULL,NULL);
example.jpg
float cursorX = mouseCursor.getCursorX();
float cursorY = mouseCursor.getCursorY();
Vector3 near = new Vector3(cursorX, cursorY, 0);
Vector3 far = new Vector3(cursorX, cursorY, 1);
// Transform points to world space
near.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
far.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
far.Normalize();
// Retrieve intersection information
IntersectInformation closestIntersection;
hit = targetMesh.Intersect(near, far, out closestIntersection);
float cursorX = mouseCursor.getCursorX();
float cursorY = mouseCursor.getCursorY();
// yes, convert ray to model space
Vector3 near = new Vector3(cursorX, cursorY, 1);
Vector3 far = (new Vector3(cursorX, cursorY, 1)) - (new Vector3(headX, headY, headDist));
// Transform points to world space
near.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
far.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
far.Normalize();
// Retrieve intersection information
IntersectInformation closestIntersection;
hit = targetMesh[1].Intersect(near, far, out closestIntersection);
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.