Jump to content
  • Advertisement

cindy_uk

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

110 Neutral

About cindy_uk

  • Rank
    Newbie
  1. cindy_uk

    3d position in space

    XMVECTOR rayDir = CursorObjectSpace - RayOrigin; rayDir = RayOrigin - (XMVectorGetY(RayOrigin) / XMVectorGetY(rayDir)) * rayDir; rayDir = XMVector3Normalize(rayDir); rayDir = XMVector3Normalize(rayDir); " comes in 2nd maybe,I think it was my problem.Checking it.
  2. cindy_uk

    3d position in space

    Hello.   Camera,viewport,. are ok I checked it. XMVECTOR CursorScreenSpace = XMVectorSet((FLOAT)Mouse.x, (FLOAT)Mouse.y, 0.0f, 0.0f); const XMVECTOR RayOrigin = camPosition; XMVECTOR CursorObjectSpace = XMVector3Unproject(CursorScreenSpace, 0, 0, viewport.Width,viewport.Height, 0.0f, 1.0f,camProjection,camView, XMMatrixIdentity()); XMVECTOR rayDir = CursorObjectSpace - RayOrigin; rayDir = RayOrigin - (XMVectorGetY(RayOrigin) / XMVectorGetY(rayDir)) * rayDir; rayDir = XMVector3Normalize(rayDir); XMMATRIX Translation = XMMatrixTranslation(XMVectorGetX(rayDir), XMVectorGetY(rayDir), XMVectorGetZ(rayDir)); But the positions are wrong.
  3. cindy_uk

    3d position in space

     Hello.I'm so lost. XMMATRIX P = camProjection; XMVECTOR rayOrigin; XMVECTOR rayDir; XMVECTOR screenpoint = XMVectorSet(Mouse.x, Mouse.y, 0.0f, 0.0f);//Mouse.x=300 Mouse.y=200 rayOrigin = XMVector3Unproject(screenpoint, viewport.TopLeftX,viewport.TopLeftY, viewport.Width,viewport.Height,viewport.MinDepth,viewport.MaxDepth,camProjection,camView,World); screenpoint = XMVectorSet(Mouse.x,Mouse.y, 1.0f, 0.0f); rayDir = XMVector3Unproject(screenpoint,viewport.TopLeftX,viewport.TopLeftY, viewport.Width,viewport.Height,viewport.MinDepth,viewport.MaxDepth,camProjection,camView,World); //*Breakpoint to see results rayDir = rayDir - rayOrigin; rayOrigin = {m128_f32=0x03e4f900 {-1.#IND0000, -1.#IND0000, -1.#IND0000, -1.#IND0000} m128_u64=0x03e4f900 {18428729679490842624, ...} ...} rayDir = {m128_f32=0x0404fa00 {-1.#IND0000, -1.#IND0000, -1.#IND0000, -1.#IND0000} m128_u64=0x0404fa00 {18428729679490842624, ...} ...}
  4. cindy_uk

    3d position in space

    Positions aren't good.it's worst if I move the camera.
  5. cindy_uk

    3d position in space

    Hello It seems to work but there an issue,I gave a mesh the position(position.x,position.y,position.z),the x position seems to be correct but the z is like reversed.When I click on the bottom of the window it moves away and when I click the top it comes closer. Thanks.
  6. cindy_uk

    3d position in space

    Hello. Isn't a mesh, just a imaginary floor at the position y=0,maybe I'm gonna create it with 6 vertexes. I don't want to find the position of a mesh but the mouse pointer on the floor. Thanks.
  7. Hello. I need to know the position x,y,z on the ground when I press the mouse. I found something: XMMATRIX P = mCam.Proj(); // Compute picking ray in view space. float vx = (+2.0f*sx/mClientWidth - 1.0f)/P(0,0); float vy = (-2.0f*sy/mClientHeight + 1.0f)/P(1,1); // Ray definition in view space. XMVECTOR rayOrigin = XMVectorSet(0.0f, 0.0f, 0.0f, 1.0f); XMVECTOR rayDir = XMVectorSet(vx, vy, 1.0f, 0.0f); If I did understand it traces a ray.So I guess I'm half way.But I don't know where I go now. Please help me Obiwan,you're my only hope. Thanks. Directx11(skd jun 2010),Visual studio 2013,c++,Window7
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!