[ODE] TR: collision detection problems ... ray and box

LR logreg at free.fr
Sat Mar 25 05:37:30 MST 2006


I suggest you to place your box at a specific position, force your ray
position and direct to values that you know to be good then call the
dcollide methods.
to see if the problem is your vectors/positions or the use of ODE collisions
detection...
 
To compute mouse pick ray i do that:
 
//--------------------------------------------------------------------------
------------

void nmViewpointPerspective::UpdatePickVector(nmWindow *pWindow,int
MouseX,int MouseY)

{

//Get the inverse view matrix

D3DXMATRIXA16 matView, matProj,m;

matView=*GetViewMatrix();

matProj=*GetProjMatrix();

POINT ptCursor;

ptCursor.x=MouseX;

ptCursor.y=MouseY;

// Compute the vector of the pick ray in screen space

D3DXVECTOR3 v;

v.x = ( ( ( 2.0f * ptCursor.x ) / pWindow->GetSurfaceRectangle()->right ) -
1 ) / matProj._11;

v.y = -( ( ( 2.0f * ptCursor.y ) / pWindow->GetSurfaceRectangle()->bottom )
- 1 ) / matProj._22;

v.z = 1.0f;

D3DXMatrixInverse( &m, NULL, &matView );

// Transform the screen space pick ray into 3D space

vPickRayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31;

vPickRayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32;

vPickRayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33;

vPickRayOrig.x = m._41;

vPickRayOrig.y = m._42;

vPickRayOrig.z = m._43;

}

 
Laurent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://q12.org/pipermail/ode/attachments/20060325/08bc84a7/attachment.htm


More information about the ODE mailing list