   very stuck with understand picking d3d
  i understand upon till this point vPickRayDir.x  = v.x*m._11 + v.y*m._21 + v.z*m._31; //here i am totally lostvPickRayDir.y  = v.x*m._12 + v.y*m._22 + v.z*m._32; //here tovPickRayDir.z  = v.x*m._13 + v.y*m._23 + v.z*m._33; //and hereand i thought these matrix values are todo with rotation and scaling...vPickRayOrig.x = m._41; //so this would be XvPickRayOrig.y = m._42; //this would be YvPickRayOrig.z = m._43; //this would be Zi understand that v.x and v.y are the cursorpos in screenspace but what is it doing multiplying by those matrix floats,   
  It's a 3x3 matrix multiplication. m is a matrix, and _ij represents the i'th row, and j'th column in the matrix.    [ x ]v = [ y ]    [ z ]    [ a b c ]A = [ d e f ]    [ g h i ] [ a*x+b*y+c*z ]A*v = [ d*x+e*y+f*z ] [ g*x+h*y+i*z ]Note: I may have this the wrong way around, you might have to flip the rows/columns because of the way D3D handles matrices.   ;  but i thought D3DXMATRIX is 4x4 matrix _11 to _44, i just dont seem to why it need to multiply the rotation and scaling floats ?i need a really good discription of what each float means in this matrix, i am totally clueless, my book dosent say much at all[Edited by - Anddos on June 14, 2009 2:39:20 AM];  The ray direction is, as the name says, a direction and not a position. With matrix multiplications, when you multiply with a 4x4 matrix you need a vector with 4 axis. That forth value is set to 0 for directions and 1 for points. So actually it's:vPickRayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31 + v.w*m._41;vPickRayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32 + v.w*m._42;vPickRayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33 + v.w*m._43;vPickRayDir.w = v.x*m._14 + v.y*m._24 + v.z*m._34 + v.w*m._44;However, since w is 0 in case of a direction, the last part can simply be left out. And so can vPickRayDir.w, as it isn't needed, so the code is actually just a matrix transformation with some useless calculations removed. The transformation is needed to get the direction vector back in 3D space, the vector from your mouse is pointing to the back of the screen, a bit up/down/left/right. But in reality, the scene might have been rotated 90 degrees to the right, so for picking you need to rotate the direction from the mouse back with the inverse matrix.   ;  ok so what do you mean by direction,its kind of wierd as my directx book shows some of those m._ values only needed for otating and scaling yet and puzzeled to where its needed in this case when i am not scaling or rotating the ray   ;  You have directions and points that you can store in a 3d vector. A direction is something as 'up', or 'left', stored in a vector this can for example be (-1,0,0), in other words, the direction is -1 on the X-axis. which could mean left. Directions can be normalized, meaning their length is 1 (length of a vector is sqrt(x*x + y*y + z*z)), but can also be used as speed, for example (-0.5,0,0) means slowly to the left, and (2,0,0) fast to the right.Same with picking, you are not clicking at a certain position, but in a certain direction. For example, when you click exactly in the middle, and are looking in the z direction, your picking direction will be (0,0,1), no matter where the camera is located. That's why it's a picking ray and no line, a ray is infinite in the given direction, meaning it has no end. So let's keep the above example of the direction (0,0,1), and you are standing at position (2,6,2), the ray will be (2,6,2....n), (2,6,4) will be in the ray, so will (2,6,9262), but (2,6,1) is not (wrong direction).   ;  so the ray orgin is the position , i am really struggling to understand whats happening in this direction thing,i wish there was more things on the net about direction and rays with diagrams   ;  Wikipedia has a small part about rays: http://en.wikipedia.org/wiki/Line_(mathematics)#RayTranslating to this program, point A in that picture is vPickRayOrig, while point B is vPickRayOrig + vPickRayDir and C is vPickRayOrig + vPickRayDir + vPickRayDir. All point on the ray can be found using vPickRayOrig  + vPickRayDir * i, where i >= 0.   ;  here is a quick diagram of what i think is happening , http://img41.imageshack.us/i/rayj.jpg/i just cannot for the life of me understand this direction thing   ;  The picking ray is a ray from the eye position through the position you clicked on the screen into the scene. It can be represented by an origin and a direction. The origin is the eye position, the direction is the vector between the eye position and the point clicked on the screen. You need the coordinates of the origin and the ray direction in worldspace to be able to construct the ray and check for intersections with objects (worldspace is like a common frame of reference, objects are transformed to worldspace by the modeling transform).You already have the eye position in world space - it's the translation component of your view matrix m. That is what the following part states:vPickRayOrig.x = m._41; vPickRayOrig.y = m._42; vPickRayOrig.z = m._43; Now you need to get the ray direction in worldspace. m is your view matrix. It is used to transform worldspace coordinates to screenspace coordinates. Here, you need to do the opposite - transform the screenspace coordinates back into worldspace. This equates to multiplying the direction vector with the inverse of the view matrix. If a matrix is orthogonal, it's inverse is the same as it's transpose. This is what the following states: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;where v is the ray direction in screenspace, vPickRayDir is the ray direction in worldspace, and[m._11 m._21 m._31][m._12 m._22 m._32][m._13 m._23 m._33]is the transpose of upper-left 3x3 part of the view matrix.Why only the upper-left 3x3 part? MichaBen's post contains the answer from a linear algebra point of view. Here's another, more down-to-earth view: a direction vector has no position, only an orientation, so transposing it doesn't make any sense. The only transformation that applies is rotation, and the upper 3x3 part of the view matrix contains the rotation.EDIT: view direction was a misleading name choice, changed it to ray direction[Edited by - Morrandir on June 14, 2009 1:12:52 PM]