need help on shadow engine (intersection)

Blitz3D Forums/Blitz3D Programming/need help on shadow engine (intersection)

Kalisme(Posted 2005) [#1]
I'm trying to create an easy shadow engine for my games... I know that people are going to tell me to go use SSwifts engine (and why shouldn't they? it's a great engine and he's a great programmer) It's just that I don't really have much money at the moment to invest in the engine and I would feel more comfortable (and prouder) if I could build an engine from the ground up... and so far I've done a good job (I think) I just cant do one thing...
SSwift has an amazing intersection engine for detecting which polygons touch the area where the shadow is going to go... me on the other hand hasn't :(
Has anyone got a quick and easy intersection engine for checking if a triangle intersects with a box or something? (inside the area of the box) That would be very useful...

And another reason I want to do my own shadow engine is because my artwork is very shaded and dark... so I want to be able to match my conceptual work...
If anyone could help me I'd be very thankful...
-Kev


Kalisme(Posted 2005) [#2]
so I presume no one's going to help with this problem any time soon?
all I want is a function that checks if a triangle intersects with a cube, not just the wire of the cube, but if it has any part that's inside the cube the function should return true... could anyone help?


elias_t(Posted 2005) [#3]
You don't check the code archives dont' you?

http://www.blitzbasic.com/codearcs/codearcs.php?code=1191


sswift(Posted 2005) [#4]
This is how I do it:
http://www.google.com/search?hl=en&c2coff=1&safe=off&q=Sutherland+Hodgman&spell=1

Basically, you clip the triangle to the box, frustum, whatever, using that algorithm.

If any of the triangle is left at the end, then its inside or intersecting the region.

There is also a way to avoid doing this test entirely by determining ahead of time if all the vertices of triangle are on the outside side of any one of the planes.

You can do that by creating an array which stores which side of each plane each vertex is on in the bits of an integer. Then you can use AND and an OR comparisons to check each vertex in the triangle against these planes all at once.