polygon winding with DrawPoly
BlitzMax Forums/BlitzMax Programming/polygon winding with DrawPoly
| ||
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 |
| ||
Wouldn't you need some sort of Z sort to draw the polygons in the correct order? |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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) |
| ||
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). |
| ||
Thanks guys that fixed it. :) |