Jump to content

  • Log In with Google      Sign In   
  • Create Account

Odd ray intersect behavior


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Oblivion165   Members   -  Reputation: 107

Like
1Likes
Like

Posted 10 February 2011 - 04:07 PM

EDIT: Of course after fighting it for 3 days I figure it out 5 minutes after I post. The correct way to do it was to calculate a direction based off the source and taget vectors.

public Ray CalculateRay(Vector3 src, Vector3 tar)
    	{
        	Vector3 direction = (tar - src);
        	return new Ray(src,direction);
    	}
RayFixed.png

It looks like a mess but it works on every test I threw at it. Posted this solution incase someone has a similar problem.


............ Original Post:


Hi there, I'm having some odd ray to bounding box intersection issues. I have working picking code and its pixel perfect but when I use rays in this manor, it claims collisions where it shouldn't and doesn't where it should. (Box one the end of the top row should be shadowed by the one to its left)

I'm working on some basic lights and using rays to determine shadows etc.

RayOdd.png

As you can see in this one, the rays start at the top of the box only and goes directly to the light source:
(I am not checking for collision on the origin squares bounding box)

RayOdd2.png

Now to me it looks like the ray intersect is calculating it as if the ray were pointing straight up in the air with no angle. The ones below the top layer collide with the cube above it but ones at the top don't collide with the ones next to them.

I have verified that the bounding boxes are perfectly aligned to each cube and the only thing i can see is that the picking code uses matrix data to align itself. Do i need to adjust the rays for the world matrix or some such? Right now I'm making rays by simply Ray ry = new Ray(SourceVector3, TargetVector3) and that's it.

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS