   Moving object in 3D environment
  Hi,i'm trying to develop a game in directx using VisualBasic 2005 and DirectX 9c.In my 3D environment, i can rotate the world using a RotateTrackBall like function that modify the world Matrix.After that, i need to move object in the world using the mouse.objects should move only on XZ plane accordly to mouse movements, but i cannot find a good way to do this.I tryed using Y rotation angle got from asin(mWorld.M13) and multiply it by DX and DY mouse movements, but when rotating world, movements get inverted.any suggestion?following the code i used===================================================   Public Sub RotateTrackBall(ByVal dX As Single, ByVal dY As Single) Dim dR As Single Dim Radius As Single Dim Den As Single Dim An As Single Dim AxisC, AxisS, wc, base, Origin As Vector3 Dim MT As Matrix dR = Math.Sqrt(dX * dX + dY * dY) Radius = 100.0 Den = Math.Sqrt(Radius * Radius + dR * dR) If dR = 0 Or Den = 0 Then Exit Sub An = dR / Den With AxisC    .X = dY / dR    .Y = -dX / dR    .Z = 0 End With 'transform camera space vector to world space MatViewR = IdMat wc = Vector3.TransformCoordinate(AxisC, MatViewR) 'transform world space vector into Model space AxisS = Vector3.TransformCoordinate(wc, mWorldI) 'transform origin camera space to world coordinates wc = Vector3.TransformCoordinate(Origin, MatViewR) 'transfer cam space origen to model space base = Vector3.TransformCoordinate(wc, mWorldI) AxisS.X = AxisS.X - base.X AxisS.Y = AxisS.Y - base.Y AxisS.Z = AxisS.Z - base.Z MT = Matrix.RotationAxis(AxisS, An) mWorld = Matrix.Multiply(mWorld, MT) yWang = Math.Asin(mWorld.M11)   end Sub------------------------------------------------   Public Sub MoveSelection(ByVal dX As Single, ByVal dY As Single) Dim X, Y As Integer   If Abs(dX) > Abs(dY) Then    X = dX * Cos(yWang)    Y = dX * Sin(-yWang) ElseIf dY <> 0 Then    X = dY * Sin(yWang)    Y = dY * Cos(yWang) End If Block(0).mTrans.M41 += X Block(0).mTrans.M43 += Y   End Sub   
  I'm not sure about the way you convert the mouse coordinats into world coordinates , I spent a lot of time finding out the best way to:- convert screen coordinates into world coordinates.- Picking or selecting meshs.- dragging the mesh according to different axis.And finally I developed a class called DragManager can do all what above, so I uploaded a sample on how to use this class and you can download it from here.   ;  well, I don't know how to translate screen coords to world coords.i have take a look to Fadii code: it's a bit hard to understand for me since it's not commented, and on my PC does not compile. i tryed the example, but movements are not what you can expect.any other suggestions?thanks   ;  i checked out Fadii's MeshDrag program executable and it contains just what i needed for my program (dragging meshes around and having a visible dynamic relation between two meshes). Now i just need to examine his code to incorporate it in my program.Thanks for the upload Fadii. i appreciate it.Zahid   