Beispiel #1
0
        private List<Vertex> cullLine(Vertex p1, Vertex p2, Plane p)
        {
            //List<Vertex> list = getPreCullList(p1, p2, p);
            //if (list != null)
            //    return list;

            List<Vertex> list = new List<Vertex>();
            float value1 = p.getDotValue(p1.pos);
            float value2 = p.getDotValue(p2.pos);

            float temp = value1 * value2;
            if (temp >= 0)
            {
                if (value1>0 && value2 > 0)
                {
                    list.Add(p1);
                    list.Add(p2);
                }
                else if (value1>0 && value2==0 || value2>0 && value1==0)
                {
                    list.Add(p1);
                    list.Add(p2);
                }
            }
            else
            {
                Vertex v = p.getInsertValue(p1, p2);
                if (value1 > 0)
                {
                    list.Add(p1);
                    list.Add(v);
                }
                else
                {
                    list.Add(v);
                    list.Add(p2);
                }
            }

            CullLine cullLine = new CullLine();
            cullLine.inputList.Add(p1);
            cullLine.inputList.Add(p2);
            cullLine.plane = p;
            cullLine.outPutList = list;
            string cacheString = p1.pos.ToString() + p2.pos.ToString() + p.normal.ToString()+p.point.ToString();
            cullLineList[cacheString] = cullLine;

            return list;
        }