public void Draw() { GL.Color(new Color(var_4, var_5, var_6, var_7)); GL.TexCoord3(var_1, var_2, var_3); Vector2 edgeAWorld = leftEdge; Vector2 edgeBWorld = rightEdge; Vector2 edgeALocal = leftEdgeLocal; Vector2 edgeBLocal = rightEdgeLocal; float lightDirection = (float)Math.Atan2((edgeAWorld.y + edgeBWorld.y) / 2, (edgeAWorld.x + edgeBWorld.x) / 2) * Mathf.Rad2Deg; float EdgeDirection = (float)Math.Atan2(edgeALocal.y - edgeBLocal.y, edgeALocal.x - edgeBLocal.x) * Mathf.Rad2Deg - 180; lightDirection -= EdgeDirection; lightDirection = (lightDirection + 720) % 360; if (lightDirection > 180) { GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(edgeMiddle.x, edgeMiddle.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(edgeMiddle.x, edgeMiddle.y, 0); GL.Vertex3(rightEdge.x, rightEdge.y, 0); } Vector2?fullResult = Math2D.GetPointLineIntersectLine3(leftEdge, leftCoreOutToEdge, rightEdge, rightCoreInToEdge); if (fullResult != null) { GL.Vertex3(fullResult.Value.x, fullResult.Value.y, 0); GL.Vertex3(rightCoreInToEdge.x, rightCoreInToEdge.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); } else { Vector2?leftResult = Math2D.GetPointLineIntersectLine3(edgeMiddle, projectedMiddle, rightEdge, rightCoreInToEdge); if (leftResult != null) { GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(rightCoreInToEdge.x, rightCoreInToEdge.y, 0); GL.Vertex3(leftResult.Value.x, leftResult.Value.y, 0); GL.Vertex3(rightEdge.x, rightEdge.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); GL.Vertex3(rightEdge.x, rightEdge.y, 0); GL.Vertex3(leftResult.Value.x, leftResult.Value.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); GL.Vertex3(leftResult.Value.x, leftResult.Value.y, 0); } else { Vector2?rightResult = Math2D.GetPointLineIntersectLine3(edgeMiddle, projectedMiddle, leftEdge, leftCoreOutToEdge); if (rightResult != null) { GL.Vertex3(rightCoreInToEdge.x, rightCoreInToEdge.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); GL.Vertex3(rightEdge.x, rightEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(rightCoreInToEdge.x, rightCoreInToEdge.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(rightResult.Value.x, rightResult.Value.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(rightResult.Value.x, rightResult.Value.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); } else { if (lightDirection > 180) { GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(rightCoreInToEdge.x, rightCoreInToEdge.y, 0); GL.Vertex3(rightEdge.x, rightEdge.y, 0); GL.Vertex3(projectedMiddle.x, projectedMiddle.y, 0); GL.Vertex3(leftCoreOutToEdge.x, leftCoreOutToEdge.y, 0); GL.Vertex3(leftEdge.x, leftEdge.y, 0); } } } } }