title: LWJGL - How to trace a ray effectively and efficiently?
body: <p>I have got the origin and a direction vector but I have no clue how to follow the ray and check for collisions...</p>
  
  <p><a href="http://tinypic.com/view.php?pic=344e25t&amp;s=6" rel="nofollow">Here</a> is a picture of the ray, it goes out about 6 blocks.</p>
  
  <pre><code>Vector3f cam = camera.getPosition();
  Vector3f dir = getDirection();
  
  dir.x *= 40;
  dir.y *= 40;
  dir.z *= 40;
  
  Vector3f dest = new Vector3f(cam.x + dir.x, cam.y + dir.y, cam.z + dir.z);
  
  
  public Vector3f getDirection()
  {
      Vector3f vector = new Vector3f();
  
      float rotX = camera.yaw;
      float rotY = camera.pitch;
  
      vector.y = (float) -Math.sin(Math.toRadians(rotY));
  
      float h = (float) Math.cos(Math.toRadians(rotY));
  
      vector.x = (float) (h * Math.sin(Math.toRadians(rotX)));
      vector.z = (float) (-h * Math.cos(Math.toRadians(rotX)));
  
      return vector;
  }
  </code></pre>
  
  <p></p>
  
  <p>I have tried using gluUnProject and it worked a little bit but like when you picked a face of a block it wasn't very precise.</p>
  
  <p>BTW: I am using display lists for the chunks and I am just rendering block quads inside that display list. I get 60 FPS. I have been searching and searching but I cannot find ANYTHING on ray tracing and or ray picking... Thanks!</p>