Casting a ray to the sun
by Bryce · in Torque 3D Professional · 02/25/2013 (4:49 pm) · 3 replies
Hey guys,
I've got a bit of a tricky question here. I'm looking to cast a ray from a position to the location of a sun object to check to see if that position is in the shade. The obvious problem is that the sun is infinitely far away, and I'm not completely sure of the vector math here.
Does anybody know how to get an arbitrary position of a given sun object (say, 500 meters away from the position I'm testing to in the direction of the sun)? I'm quite stuck here.
Help is appreciated!
-Bryce
I've got a bit of a tricky question here. I'm looking to cast a ray from a position to the location of a sun object to check to see if that position is in the shade. The obvious problem is that the sun is infinitely far away, and I'm not completely sure of the vector math here.
Does anybody know how to get an arbitrary position of a given sun object (say, 500 meters away from the position I'm testing to in the direction of the sun)? I'm quite stuck here.
Help is appreciated!
-Bryce
#2
EDIT- Yeah what Ron said would definitely be better especially if you are using the time of day effects of the sun.
02/25/2013 (6:32 pm)
I'm sure you could use the sun's information somehow, but you probably don't need to. Try just adding (or subtracting) in values to the ray's end position and use that as the rays start position. The proper amount to add in can probably be visualized by placing a static shape in the sky and checking the difference in it's x, y, and z values from your end location.EDIT- Yeah what Ron said would definitely be better especially if you are using the time of day effects of the sun.
#3
02/25/2013 (6:34 pm)
I think I've got a solution here, I'll post it when I've perfected it. I'm essentially getting the azimuth and elevation values and rotating a "0 1 0" vector by those values, and adding it to position "0 0 0."
Associate Ron Kapaun
3tdstudios.com
Taking a shot in the dark here....no pun intended ;-). (This is something I learned in Land Navigation in the military...so may not be 100%) Couldn't you take the azimuth and elevation settings for the sun object and work backward? That should give you a number that tells you where the sun is at a specific point. If you are using TOD then you can just add +1 or -1 to your elevation per tick. (or however you have the time of day set) since the azimuth does not change.
Ron