Re: Picking/object selection in directx
Group: microsoft.public.win32.programmer.directx.graphics · Group Profile · Search for vray in microsoft.public.win32.programmer.directx.graphics
Author: Robert Dunlop
Date: Nov 1, 2006 18:31
... space // vFar is intersection of cursor with far plane in world space Vec3 vRay=normalize(vFar-vNear); float rayLen=Length(vFar-vNear); // inside render loop.... Vec3 vCent=TransformVec3(mesh.center,mesh.worldMatrix); Vec3 vh=vCent-vNear; float a=dot(vh,vRay); if (a<0.0f) a=0.0f; else if (a>rayLen) a=rayLen; Vec3 vClosest=vNear+vRay*a; float vToCenter=vCent-vClosest; if (sqRad>=dot(vToCenter,vToCenter)) // possible hit...
Show full article (3.01Kb) |