Home | Forums | What's new | Resources | |
Determining the Location of your Polygon? |
slinga - May 16, 2007 |
antime | May 17, 2007 | |||
Likely you will have to calculate the exact positions manually. SGL can't modify the original vertex data or all objects would be destroyed in seconds due to rounding errors, and it probably doesn't keep the transformed polygons around due to memory restrictions. |
RockinB | May 18, 2007 | |||
Slinga, you should have a look at slCalcVector() and slCalcPoint(). They use (or can be used with) the current matrix, so call them at the same position when calling slPutPolygon(). |
slinga | May 20, 2007 | |||
Thanks RockinB, slCalcPoint() worked perfectly. I was able to get the points of the triangle as I drew it to the screen and now collision detection seems to work. I need to plan some optimizations now. Doing 3x3 line intersections tests per triangle (there can be up to 12 players) is killing the saturn's cpu...oh well I will figure it out. Thanks again. |
antime | May 20, 2007 | |||
Before actually testing if the triangles intersect you should do a bounding box/sphere test to quickly reject the obviously nonintersecting cases. Google also gives lots of papers with 2D triangle intersection tests that claim to be faster than plain line-line intersections which you can adapt. You could also try something radically different, like drawing the first ship into an offscreen buffer, then drawing the other one as half-transparent. If they intersect there will be pixels of the transparent colour in the buffer. Might work OK if the ships are not too big, but you have to choose the colour so that transparent over background is different from transparent over the other ship. |