/// <summary> /// 创建扇形防空区 /// </summary> /// <param name="id"> 命令ID,用作字典key </param> /// <param name="origin">起始点</param> /// <param name="tarPoint">水平最远距离点</param> /// <param name="alpha">横向张角</param> /// <param name="theta">纵向张角</param> public void CreateSector(Vector3 origin, Vector3 tarPoint, float alpha, float theta, Color color) { Vector3[] vertices = PhysicsMath.GetSectorPoints_2(origin, tarPoint, alpha, theta); Mesh mesh = GLDraw.CreatePolygon(vertices, color.Int32()); Game.GraphicsModule.AddGraphics(Camera.main, () => { ShapeMaterial.SetPass(0); Graphics.DrawMeshNow(mesh, Matrix4x4.identity); }); }
/// <summary> /// 创建通用多边形区域 /// </summary> /// <param name="id"> 命令ID,用作字典key </param> /// <param name="list">下底面点链表</param> /// <param name="height">高度</param> public void CreatePolygon(List <Vector3> list, float height, Color color) { Vector3[] vector3s = PhysicsMath.CheckVector(list); // 使数组逆时针排序 Mesh mesh = GLDraw.CreatePolygon(vector3s, height, color.Int32()); // 画出图形 Game.GraphicsModule.AddGraphics(Camera.main, () => { ShapeMaterial.SetPass(0); Graphics.DrawMeshNow(mesh, Matrix4x4.identity); }); }
/// <summary> /// 创建紫色杀伤盒 /// </summary> /// <param name="id"> 命令ID,用作字典key </param> /// <param name="list">底面四点链表</param> /// <param name="lower">下限高度</param> /// <param name="Ceiling">上限高度</param> public void CreateKillBox(List <Vector3> list, float lower, float Ceiling, Color color) { // 第一个杀伤盒 Vector3[] vector3s1 = PhysicsMath.CheckVector(list); // 使数组逆时针排序 Mesh mesh0 = GLDraw.CreatePolygon(vector3s1, lower, color.Int32()); // 画出图形 // 第二个杀伤盒 List <Vector3> CeilingList = new List <Vector3>(); // 中层顶点集合 foreach (var item in list) { CeilingList.Add(item + Vector3.up * lower); } Vector3[] vector3s2 = PhysicsMath.CheckVector(CeilingList); // 使数组逆时针排序 Mesh mesh1 = GLDraw.CreatePolygon(vector3s2, Ceiling - lower, color.Int32()); // 画出图形 Game.GraphicsModule.AddGraphics(Camera.main, () => { ShapeMaterial.SetPass(0); Graphics.DrawMeshNow(mesh0, Matrix4x4.identity); Graphics.DrawMeshNow(mesh1, Matrix4x4.identity); }); }