I got c++ code for you, which works. Simply first create a ray, like you find in the picking example(VB/C++) that comes with the sdk, or from MVPS.org (google: improved ray picking or something)

**Code:**

//Check if we hit an object

//Check if we hit our model:

DWORD dwNumFaces = g_pGame->objTerrain->objMS3DModel->m_pMS3DFile->GetNumTriangles();

D3DXVECTOR3 *v0,*v1,*v2;

D3DXVECTOR3 vv0,vv1,vv2;

float fBary1, fBary2;

float fDist;

int intersects = 0;

D3DXVECTOR3 vNear,vDir;

D3DXMATRIX invMat;

D3DXMATRIX m_combinedMat;

//temp: get the transform:

//g_pGame->mp_d3d_device->GetTransform(D3DTS_WORLD,&m_combinedMat);

m_combinedMat = g_pGame->objTerrain->matobject;

D3DXMatrixInverse(&invMat,NULL,&m_combinedMat);

D3DXVec3TransformCoord(&vNear,&vPickRayOrig,&invMat);

D3DXVec3TransformNormal(&vDir,&vPickRayDir,&invMat);

for( DWORD i=0; i<dwNumFaces; i++ )

{

g_pGame->objTerrain->objMS3DModel->GetVectorAt((i*3),&v0);

g_pGame->objTerrain->objMS3DModel->GetVectorAt((i*3)+1,&v1);

g_pGame->objTerrain->objMS3DModel->GetVectorAt((i*3)+2,&v2);

vv0 = *v0;

vv1 = *v1;

vv2 = *v2;

// Check if the pick ray passes through this point

if( IntersectTriangle( vNear, vDir, vv0, vv1, vv2,

&fDist, &fBary1, &fBary2 ) )

{

intersects++;

//Transform vertex back to world space!

D3DXVECTOR3 vnewpos;

D3DXVec3TransformCoord(&vnewpos,&vv0,&m_combinedMat);

g_pGame->m_pCube1->SetPosition(vnewpos.x,vnewpos.y,vnewpos.z);

break;

}

}

IntersectTriangle is simply a functions which checks if a line is going through a triangle, it's probably from gameprogrammer.com or something. (or gametutorials.com).

Now, the most important thing in this code, is that you actually use the MATRIX that was used to render the object on it's place. So, you did your rotation, scaling, translating, etc, and Multiplied it in a new matrix and then did SetTransform.

I simply used a global object for it to test, called matobject. Now, even if I scale my model, ray intersection still works.

**btw: first do box intersection, if hit -> proceed triangle intersection **
hth