Exemple #1
0
        public void AddHitPoint(Vector3 point, float startRange, float endRange)
        {
            if (!this.isMeshComplete)
            {
                return;
            }
            HitPoint hp = new HitPoint();

            hp.point = point;

            hp.stopRange    = endRange;
            hp.currentRange = startRange;

            List <Vector3> verticesInRange = new List <Vector3>();

            foreach (Edge e in edgeArray)
            {
                float distance = (ToWorld(e.a) - hp.point).magnitude;
                if (distance < hp.currentRange)
                {
                    verticesInRange.Add(ToWorld(e.a));
                    verticesInRange.Add(ToWorld(e.b));
                }
            }
            hp.vertices = verticesInRange;

            this.HitList.Add(hp);
        }
Exemple #2
0
        void OnRenderObject()
        {
            if (!this.isMeshComplete)
            {
                return;
            }

            if (lineMaterial == null)
            {
                GameLog.Log("no line material");
                return;
            }

            if (HitList == null)
            {
                return;
            }
            if (HitList.Count <= 0)
            {
                return;
            }

            lineMaterial.SetPass(0);
            GL.Color(lineColor);
            GL.Begin(GL.LINES);

            for (int i = 0; i < this.HitList.Count; i++)
            {
                HitPoint hp = this.HitList[i];
                for (int h = 0; h < hp.vertices.Count; h += 2)
                {
                    Vector3 a        = hp.vertices[h];
                    float   distance = (a - hp.point).magnitude;
                    if (distance < hp.currentRange)
                    {
                        Vector3 b = hp.vertices[h + 1];
                        GL.Vertex(a);
                        GL.Vertex(b);
                    }
                    else
                    {
                        this.HitList[i].vertices.RemoveRange(h, 2);
                    }
                }

                hp.currentRange *= this.DecayRate;

                this.HitList[i] = hp;

                if (hp.currentRange < hp.stopRange)
                {
                    this.HitList.RemoveAt(i);
                }
            }
            GL.End();
        }