polygon winding with DrawPoly

BlitzMax Forums/BlitzMax Programming/polygon winding with DrawPoly

Scott Shaver(Posted 2005) [#1]
Are there any known issues with the winding of the vertexes when using DrawPoly? I've got a wierd situation where it looks like I can see through polygons that are drawn over other polygons. You kind of have to see it in action but here are some pictures.

should look like this


does look like this



skidracer(Posted 2005) [#2]
Wouldn't you need some sort of Z sort to draw the polygons in the correct order?


Scott Shaver(Posted 2005) [#3]
Yeah I have one, I'm drawing them back to front. I can't figure this out. in the above picture the strip in the middle shouldn't be visible. It behaves like it blends the front and back polygons together on screen but I'm using SOLIDBLEND for the mode.




skidracer(Posted 2005) [#4]
It looks like you still have some radians based maths in there, the 3.1416 at the bottom and things like cycledifference look a bit odd also...

If the original code is in radians I would recomend sticking with that and add your own RADSIN() and RADCOS() functions.


Scott Shaver(Posted 2005) [#5]
Hmm, here is the original Java code. it appears to be working with degrees everywhere except when it does the sin and cos calls because java expects radians.




skidracer(Posted 2005) [#6]
so double check your radians to degrees stuff:
CP[i].rotateBy(Float(Float(ROTATION_SCALE)*Sin(180*(fm+diff)/Pi)))

ps[i,Z] = Int(Float(scale) * Cos(rotation + ang - 180) + Float(scale)+.5)


Floyd(Posted 2005) [#7]
The only obvious problem is 3.1416/2.0, which is clearly Pi/2 i.e. radians.
Replace it with 90, the equivalent in degrees.

This gives Cos(rotation + ang - 90).

In fact, Cos(x - 90) and Sin(x) are the same. You may as well use Sin(rotation + ang).


Scott Shaver(Posted 2005) [#8]
Thanks guys that fixed it. :)