Author Topic: Ray intersect Sphere??  (Read 10183 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Ray intersect Sphere??
« Reply #20 on: August 12, 2007 »
For specular lighting you use the dot product of the normalised point->light vector and the reflected ray vector, the calcs for reflecting a ray are in the function I gave before. To reflect a vector you need to know what the initial vector is (incoming) and the surface normal of the point it is reflecting off.

The only way I've raytraced cubes so far is by creating a mesh and using ray->triangle intersections, the example you linked to doesn't allow for rotating the cube at all so if you wanted to do that then you'd need to rotate the ray around the cube, find the intersection (if that's possible) then un-rotate and do your lighting and reflection, a similar procedure would be needed for shadowing.

There may be some specific way to raytrace cubes but I don't know, another idea may be to define the cube as 6 planes and do some sort of tests with those.
« Last Edit: August 12, 2007 by Stonemonkey »

Offline Devils Child

  • C= 64
  • **
  • Posts: 66
  • Karma: 2
    • View Profile
Re: Ray intersect Sphere??
« Reply #21 on: August 12, 2007 »
cool, fast reply :)
i like you!

sorry if a ask sooo many questions at once. i dont want you to feel like my dictionary.
but there is another bug coming up. i thought it would be good to have an infinite ray, but it isnt. i think i need a limited ray again, because the shadowing routine is extreme buggy because of infinite ray... ???

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Ray intersect Sphere??
« Reply #22 on: August 12, 2007 »
Sorry, I don't really understand what you mean by infinite ray. When you test for intersections it shouldn't matter how far away an object is or if there is no intersection and when you test for shadows you first find the distance from the point to the lightsource and only check for intersections within that distance.

Offline Devils Child

  • C= 64
  • **
  • Posts: 66
  • Karma: 2
    • View Profile
Re: Ray intersect Sphere??
« Reply #23 on: August 12, 2007 »
well, whatever the reason is that you dont understand, i need the ray to be NOT infinite...