Hello,
First thanks for every help I get. I am new in DirectX and SlimDx. This is why I first developed a test application. Later I want to develop a 2D game. Now to my Problem. I want to get the mouse position in the 3D space. But I have problems with the calculation of the point.
#region fours try float m_iClientSizeW = _control.Device.Viewport.Width; float m_iClientSizeH = _control.Device.Viewport.Height; Matrix worldview = _control.Device.GetTransform(Dx9.TransformState.View); Matrix worldviewprojection = Matrix.Multiply(worldview, _control.Device.GetTransform(Dx9.TransformState.Projection)); Dx9.Viewport vp = _control.Device.Viewport; // Unproject near plane Vector3 vNear = new Vector3((float)posPoint.X, (float)posPoint.Y, 0); Vector3 vFar = new Vector3((float)posPoint.X, (float)posPoint.Y, 1); Vector3 vNearW = Vector3.Unproject(vNear, 0, 0, m_iClientSizeW, m_iClientSizeH, 0, 1, Matrix.Identity * worldviewprojection); Vector3 vFarW = Vector3.Unproject(vFar, 0, 0, m_iClientSizeW, m_iClientSizeH, 0, 1, Matrix.Identity * worldviewprojection); Ray ray = new Ray(vNearW, vFarW - vNearW); #endregion
Here you can find my source code: https://github.com/ascholz/SlimDxTest
I have rode this article, http://www.vb6.us/tutorials/using-mouse-click-3d-space-directx-8 . But I have problems defining the plane for the z equals zero.
I hope someone can help me.
Best Regards
ascholz