3D Scene transformations not quite working

匆匆过客 提交于 2019-11-29 17:59:07
Yattabyte

In this last stage of my ray picking problem, I was informed that I was doing several things wrong:

  1. My z coordinate for a window space near plane should be -1, not 0
  2. Reminder that I need 2 separate vectors at the opposing planes, don't just use 1 for testing, run it through the actual ray picker to see if it works.
  3. Use a "w" value of 1, not 0. This is the last spot of the glm::vec4 wSC = (mat) * glm::vec4(winX,winY,0,0); line.
  4. That I need to convert my mouse coordinates into NDC coordinates before performing any calculations, so this is:
    • divide mouse x by screen width, times 2, minus 1.
    • subtract mouse y from screen height, divide by screen height, times 2, minus 1: winX = ((float)x/viewport[2]*2)-1; winY = ((float)(viewport[3]-y)/viewport[3]*2)-1;

Since my problem extended over quite a great length of time, and took up several questions, I owe credit to a few individuals who helped me along the way:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!