lixiaojun
6 天以前 fba4613d6b8dcbcaea6c7dc83bda14ed49d2f6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using OpenTK.Graphics.OpenGL;
 
namespace Yw.WinFrmUI.Hydro
{
    /// <summary>
    /// 绘制水源2d辅助类
    /// </summary>
    internal static class DrawSource2dExtensions
    {
        /// <summary>
        /// 绘制水源
        /// </summary>
        public static void Draw2d(this SourceL3d source, float zoom)
        {
            var radiu = source.Style2d.Normal.Radiu;
            var color = source.Style2d.Normal.Color;
            if (source.IsSelected)
            {
                radiu = source.Style2d.Selected.Radiu;
                color = source.Style2d.Selected.Color;
            }
            if (source.IsHovered)
            {
                radiu = source.Style2d.Hovered.Radiu;
                color = source.Style2d.Hovered.Color;
            }
            radiu *= zoom;
            float z = source.Position.Z;
 
 
 
            //计算水池下方矩形的四个顶点相对于中心点的坐标
            float left_b = source.Position.X - radiu * 1f;
            float right_b = source.Position.X + radiu * 1f;
            float bottom_b = source.Position.Y - radiu * 1.5f;
            float top_b = source.Position.Y;
 
            float left_t = source.Position.X - radiu * 2f;
            float right_t = source.Position.X + radiu * 2f;
            float bottom_t = source.Position.Y;
            float top_t = source.Position.Y + radiu * 1.5f;
 
            GL.Color3(color);
 
            // 绘制下方矩形
            GL.Begin(PrimitiveType.Quads);
            GL.Vertex3(left_b, bottom_b, z);
            GL.Vertex3(right_b, bottom_b, z);
            GL.Vertex3(right_b, top_b, z);
            GL.Vertex3(left_b, top_b, z);
            GL.End();
 
            // 绘制水池中的水
            GL.Begin(PrimitiveType.Quads);
            GL.Vertex3(left_t, bottom_t, z);
            GL.Vertex3(right_t, bottom_t, z);
            GL.Vertex3(right_t, top_t, z);
            GL.Vertex3(left_t, top_t, z);
            GL.End();
        }
 
 
    }
}