Ejemplo n.º 1
0
        /// <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)
        {
            // 第一个杀伤盒
            PhysicsMath.CheckVector(list);
            Vector3[] vector3s1 = list.ToArray();                                        // 使数组逆时针排序
            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);
            }

            PhysicsMath.CheckVector(CeilingList);
            Vector3[] vector3s2 = CeilingList.ToArray();                                           // 使数组逆时针排序
            Mesh      mesh1     = GLDraw.CreatePolygon(vector3s2, Ceiling - lower, color.Int32()); // 画出图形

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh0, Matrix4x4.identity);
                Graphics.DrawMeshNow(mesh1, Matrix4x4.identity);
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建圆柱形区域
        /// </summary>
        /// <param name="id"> 命令ID,用作字典key </param>
        /// <param name="point"> 圆心点 </param>
        /// <param name="radius"> 半径 </param>
        /// <param name="height"> 高度 </param>
        public void CreateCylinder(Vector3 point, float radius, float height, Color color)
        {
            Mesh mesh = GLDraw.CreateCylinder(point, radius, height, color.Int32());    // 画出图形

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建半圆形防空区域
        /// </summary>
        /// <param name="origin">中心点</param>
        /// <param name="radius">半径</param>
        /// <param name="angle">张角(默认90度)</param>
        public void CreateHemisphere(Vector3 origin, float radius, Color color, int angle = 90)
        {
            Mesh mesh = GLDraw.CreateHemisphere(origin, radius, 90, color.Int32());

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
            });
        }
Ejemplo n.º 4
0
        /// <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());

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
            });
        }
Ejemplo n.º 5
0
        /// <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)
        {
            PhysicsMath.CheckVector(list);
            Vector3[] vector3s = list.ToArray();                                        // 使数组逆时针排序
            Mesh      mesh     = GLDraw.CreatePolygon(vector3s, height, color.Int32()); // 画出图形

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
            });
        }
Ejemplo n.º 6
0
        private void OnPostRender()
        {
            pos = transform.position + transform.forward * 10 + transform.up * 5 + transform.right * 7;
            shapesMaterial.SetPass(0);
            Graphics.DrawMeshNow(GLDraw.CreateArrow(Color.red, 1), pos, Quaternion.Euler(90, 0, 0));
            GL.Begin(GL.LINES);
            GL.Color(Color.red);
            GL.Vertex(pos);
            GL.Vertex(pos - Vector3.forward * 1);

            GL.End();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 创建空中走廊
        /// </summary>
        /// <param name="id"> 命令ID,用作字典key </param>
        /// <param name="list">中心点链表</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        public void CreateAirCorridorSpace(List <Vector3> list, float width, float height, Color color)
        {
            //Vector3[] vertices = PhysicsMath.GetAirCorridorSpace(list, width, height);       // 获取点集
            //DrawTriangles.DrawAirCorridorSpace(vertices, meshFilter, lineRenderers);        // 画出图形

            Mesh mesh = GLDraw.CreateLineMesh(list, width, height, color.Int32());

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
            });
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 创建两个圆柱,近距火力支援等待空域
        /// </summary>
        /// <param name="id"> 命令ID,用作字典key </param>
        /// <param name="point">低点圆柱的底面圆心点</param>
        /// <param name="radius">半径</param>
        /// <param name="height">圆柱高度</param>
        /// <param name="heightDifference">两个圆柱的高度差</param>
        public void DoubleCylinder(Vector3 point, float radius, float height, float heightDifference, Color color)
        {
            // 下面圆柱
            Mesh meshUp = GLDraw.CreateCylinder(point, radius, height, color.Int32());

            // 上面圆柱
            Vector3 highPoint = point + Vector3.up * (height + heightDifference);
            Mesh    meshDown  = GLDraw.CreateCylinder(highPoint, radius, height);

            m_GrahicsManager.AddGraphics(Camera.main, () =>
            {
                ShapeMaterial.SetPass(0);
                Graphics.DrawMeshNow(meshUp, Matrix4x4.identity);
                Graphics.DrawMeshNow(meshDown, Matrix4x4.identity);
            });
        }
Ejemplo n.º 9
0
            public Resources(Color selectedColor)
            {
                lineMat       = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                lineMat.color = Color.white;

                quadeMat       = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                quadeMat.color = Color.white;

                shapMatRed            = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                shapMatRed.color      = Color.red;
                shapMatBlue           = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                shapMatBlue.color     = Color.blue;
                shapMatGreen          = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                shapMatGreen.color    = Color.green;
                shapMatSelected       = new Material(Shader.Find("RunTimeHandles/VertexColor"));
                shapMatSelected.color = selectedColor;

                arrowMesh = GLDraw.CreateArrow(Color.white, 1);
                cubeMesh  = GLDraw.CreateCube(Color.white, Vector3.zero, 1);
            }