private static void Draw(Camera camera, float size, IList <Vector4> vertices, IList <Color> colors, Matrix4x4 localToWorld)
        {
            if (camera == null || vertices == null)
            {
                return;
            }
            if (vertices.Count != colors.Count)
            {
                return;
            }

            GL.PushMatrix();

            GL.LoadIdentity();
            GL.modelview = camera.worldToCameraMatrix * localToWorld;
            GL.LoadProjectionMatrix(camera.projectionMatrix);

            LineMaterial.SetPass(0);
            GL.Begin(GL.QUADS);

            switch (Orientation)
            {
            case DRAW_ORIENTATION.XY:
                DrawXY(size, vertices, colors);
                break;

            case DRAW_ORIENTATION.XZ:
                DrawXZ(size, vertices, colors);
                break;
            }

            GL.End();

            GL.PopMatrix();
        }
示例#2
0
        private static void DrawVerticesAsLines(Camera camera, Color color, IList <Vector4> vertices, Matrix4x4 localToWorld, IList <int> indices)
        {
            if (camera == null || vertices == null)
            {
                return;
            }
            if (vertices.Count < 2)
            {
                return;
            }

            GL.PushMatrix();

            GL.LoadIdentity();
            GL.modelview = camera.worldToCameraMatrix * localToWorld;
            GL.LoadProjectionMatrix(camera.projectionMatrix);

            LineMaterial.SetPass(0);
            GL.Begin(GL.LINES);
            GL.Color(color);

            int vertexCount = vertices.Count;

            if (indices != null)
            {
                for (int i = 0; i < indices.Count / 2; i++)
                {
                    int i0 = indices[i * 2 + 0];
                    int i1 = indices[i * 2 + 1];

                    if (i0 < 0 || i0 >= vertexCount)
                    {
                        continue;
                    }
                    if (i1 < 0 || i1 >= vertexCount)
                    {
                        continue;
                    }

                    GL.Vertex(vertices[i0]);
                    GL.Vertex(vertices[i1]);
                }
            }
            else
            {
                for (int i = 0; i < vertexCount - 1; i++)
                {
                    GL.Vertex(vertices[i]);
                    GL.Vertex(vertices[i + 1]);
                }
            }

            GL.End();

            GL.PopMatrix();
        }
示例#3
0
文件: Skin2D.cs 项目: yazici/Boner2D
 void OnDrawGizmos()
 {
     // Show the mesh outline
     if (Application.isEditor && meshFilter.sharedMesh != null && showMeshOutline)
     {
         CalculateVertexColors();
         GL.wireframe = true;
         LineMaterial.SetPass(0);
         Graphics.DrawMeshNow(meshFilter.sharedMesh, transform.position, transform.rotation);
         GL.wireframe = false;
     }
 }
示例#4
0
    private void OnRenderObject()
    {
        if (!DebugSubmersion)
        {
            return;
        }

        LineMaterial.SetPass(0);
        GL.PushMatrix();
        GL.Begin(GL.LINES);

        //GL.Color(SubmergLineColor);
        //if (SubmergedPoints.Count > 0)
        //{
        //    for (int i = 0; i < SubmergedPoints.Count; i++)
        //    {
        //        if (i != 0)
        //            GL.Vertex(SubmergedPoints[i]);

        //        GL.Vertex(SubmergedPoints[i]);
        //    }
        //    GL.Vertex(SubmergedPoints[0]);
        //}

        GL.Color(OutlineColor);
        GL.Vertex(CornerVectors[0]);
        GL.Vertex(CornerVectors[1]);
        GL.Vertex(CornerVectors[1]);
        GL.Vertex(CornerVectors[2]);
        GL.Vertex(CornerVectors[2]);
        GL.Vertex(CornerVectors[3]);
        GL.Vertex(CornerVectors[3]);
        GL.Vertex(CornerVectors[0]);



        //GL.Vertex(transform.position);
        //GL.Vertex(transform.position - RawForce * .3f);

        GL.Color(VelocityLineColor);

        GL.Vertex(transform.position);

        var newLine = Vec3.Lerp(_prevVelLine, velocityVector, .1f);

        GL.Vertex(transform.position - newLine * .3f);
        _prevVelLine = velocityVector;
        //GL.Vertex(transform.position);
        //GL.Vertex(transform.TransformPoint(BladeNormal));

        GL.End();
        GL.PopMatrix();
    }
示例#5
0
 public void OnRenderObject()
 {
     if (_Player != null || (!thirdPerson && pl != null))
     {
         LineMaterial.SetPass(0);
         GL.LoadOrtho();
         GL.Begin(GL.LINES);
         GL.Color(Color.green);
         foreach (var a in list)
         {
             var v = new Vector3(Screen.width, Screen.height) / 2 + new Vector3(a.x, a.y);
             v   += a.normalized * (1 + pl.gun.cursorOffset);
             v.x /= Screen.width;
             v.y /= Screen.height;
             GL.Vertex(v);
         }
         GL.End();
     }
 }
    public override void OnDebugElementRenderObject()
    {
        LineMaterial.SetPass(0);

        GL.PushMatrix();
        GL.Begin(GL.TRIANGLES);

        foreach (PathEntry entry in entries)
        {
            foreach (var pair in entry.Nodes)
            {
                NodeType type = pair.Value.type;
                GL.Color(Colors[type]);

                DrawHexagon(Utility.AxialToWorldPosition(pair.Key));
            }
        }

        GL.End();
        GL.PopMatrix();
    }
示例#7
0
        private static void DrawVerticesAsTetrahedron(Camera camera, Color color, IList <Vector4> vertices, Matrix4x4 localToWorld, IList <int> indices)
        {
            if (camera == null || vertices == null)
            {
                return;
            }
            if (vertices.Count < 4)
            {
                return;
            }

            GL.PushMatrix();

            GL.LoadIdentity();
            GL.MultMatrix(camera.worldToCameraMatrix);
            GL.LoadProjectionMatrix(camera.projectionMatrix);

            LineMaterial.SetPass(0);
            GL.Begin(GL.LINES);
            GL.Color(color);

            int vertexCount = vertices.Count;

            if (indices != null)
            {
                for (int i = 0; i < indices.Count / 4; i++)
                {
                    int i0 = indices[i * 4 + 0];
                    int i1 = indices[i * 4 + 1];
                    int i2 = indices[i * 4 + 2];
                    int i3 = indices[i * 4 + 3];

                    if (i0 < 0 || i0 >= vertexCount)
                    {
                        continue;
                    }
                    if (i1 < 0 || i1 >= vertexCount)
                    {
                        continue;
                    }
                    if (i2 < 0 || i2 >= vertexCount)
                    {
                        continue;
                    }
                    if (i3 < 0 || i3 >= vertexCount)
                    {
                        continue;
                    }

                    GL.Vertex(vertices[i0]);
                    GL.Vertex(vertices[i1]);

                    GL.Vertex(vertices[i0]);
                    GL.Vertex(vertices[i2]);

                    GL.Vertex(vertices[i0]);
                    GL.Vertex(vertices[i3]);

                    GL.Vertex(vertices[i1]);
                    GL.Vertex(vertices[i2]);

                    GL.Vertex(vertices[i3]);
                    GL.Vertex(vertices[i2]);

                    GL.Vertex(vertices[i1]);
                    GL.Vertex(vertices[i3]);
                }
            }
            else
            {
                for (int i = 0; i < vertexCount / 4; i++)
                {
                    Vector3 v0 = vertices[i * 4 + 0];
                    Vector3 v1 = vertices[i * 4 + 1];
                    Vector3 v2 = vertices[i * 4 + 2];
                    Vector3 v3 = vertices[i * 4 + 3];


                    GL.Vertex(v0);
                    GL.Vertex(v1);

                    GL.Vertex(v0);
                    GL.Vertex(v2);

                    GL.Vertex(v0);
                    GL.Vertex(v3);

                    GL.Vertex(v1);
                    GL.Vertex(v2);

                    GL.Vertex(v3);
                    GL.Vertex(v2);

                    GL.Vertex(v1);
                    GL.Vertex(v3);
                }
            }

            GL.End();

            GL.PopMatrix();
        }