Exemplo n.º 1
0
    public static void ShowRawContours(DbgRenderMesh renderMesh, Recast.rcContourSet cset)
    {
        renderMesh.Clear();

        UnityEngine.Random.seed = c_RandomSeed;

        float[] orig = cset.bmin;
        float   cs   = cset.cs;
        float   ch   = cset.ch;

        for (int i = 0; i < cset.nconts; ++i)
        {
            Recast.rcContour c = cset.conts[i];

            if (c.nrverts == 0)
            {
                continue;
            }

            Color col = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);

            int triStartIndex = renderMesh.GetTriangleCount();

            Vector3 start = new Vector3(orig[0] + c.rverts[0] * cs,
                                        orig[1] + (c.rverts[1] + 1 + (i & 1)) * ch,
                                        orig[2] + c.rverts[2] * cs);
            Vector3 a = Vector3.zero;
            Vector3 b = start;
            for (int j = 1; j < c.nrverts; ++j)
            {
                a = b;
                int vStart = j * 4;
                b = new Vector3(orig[0] + c.rverts[vStart + 0] * cs,
                                orig[1] + (c.rverts[vStart + 1] + 1 + (i & 1)) * ch,
                                orig[2] + c.rverts[vStart + 2] * cs);
                if (j > 0)
                {
                    renderMesh.AddVerticalQuad(a, b, 0.5f, col);
                }
            }
            // Loop last segment.
            renderMesh.AddVerticalQuad(b, start, 0.5f, col);

            int triEndIndex = renderMesh.GetTriangleCount();

            Vector3 labelPos = renderMesh.GetBoundingBoxTop(triStartIndex, triEndIndex);

            renderMesh.AddLabel(labelPos, "contour " + i + "\nReg: " + c.reg + "\nnrverts:" + c.nrverts + "\nnverts:" + c.nverts);
        }

        /*
         *              dd->end();
         *
         *              dd->begin(DU_DRAW_POINTS, 2.0f);
         *
         *              for (int i = 0; i < cset.nconts; ++i)
         *              {
         *                      const rcContour& c = cset.conts[i];
         *                      unsigned int color = duDarkenCol(duIntToCol(c.reg, a));
         *
         *                      for (int j = 0; j < c.nrverts; ++j)
         *                      {
         *                              const int* v = &c.rverts[j*4];
         *                              float off = 0;
         *                              unsigned int colv = color;
         *                              if (v[3] & RC_BORDER_VERTEX)
         *                              {
         *                                      colv = duRGBA(255,255,255,a);
         *                                      off = ch*2;
         *                              }
         *
         *                              float fx = orig[0] + v[0]*cs;
         *                              float fy = orig[1] + (v[1]+1+(i&1))*ch + off;
         *                              float fz = orig[2] + v[2]*cs;
         *                                  fx,fy,fz, colv);
         *                      }
         *              }
         *              dd->end();
         */
        renderMesh.Rebuild();
    }
Exemplo n.º 2
0
    public static void ShowRawContours(DbgRenderMesh renderMesh, Recast.rcContourSet cset)
    {


        renderMesh.Clear();

        UnityEngine.Random.seed = c_RandomSeed;

        float[] orig = cset.bmin;
        float cs = cset.cs;
        float ch = cset.ch;

        for (int i = 0; i < cset.nconts; ++i)
        {
            Recast.rcContour c = cset.conts[i];

            if (c.nrverts == 0)
            {
                continue;
            }

            Color col = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);

            int triStartIndex = renderMesh.GetTriangleCount();

            Vector3 start = new Vector3(orig[0] + c.rverts[0] * cs,
                                        orig[1] + (c.rverts[1] + 1 + (i & 1)) * ch,
                                        orig[2] + c.rverts[2] * cs);
            Vector3 a = Vector3.zero;
            Vector3 b = start;
            for (int j = 1; j < c.nrverts; ++j)
            {
                a = b;
                int vStart = j * 4;
                b = new Vector3(orig[0] + c.rverts[vStart + 0] * cs,
                                orig[1] + (c.rverts[vStart + 1] + 1 + (i & 1)) * ch,
                                orig[2] + c.rverts[vStart + 2] * cs);
                if (j > 0)
                {
                    renderMesh.AddVerticalQuad(a, b, 0.5f, col);
                }
            }
            // Loop last segment.
            renderMesh.AddVerticalQuad(b, start, 0.5f, col);

            int triEndIndex = renderMesh.GetTriangleCount();

            Vector3 labelPos = renderMesh.GetBoundingBoxTop(triStartIndex, triEndIndex);

            renderMesh.AddLabel(labelPos, "contour " + i + "\nReg: " + c.reg + "\nnrverts:" + c.nrverts + "\nnverts:" + c.nverts);
        }
        /*
			dd->end();
			
			dd->begin(DU_DRAW_POINTS, 2.0f);	
			
			for (int i = 0; i < cset.nconts; ++i)
			{
				const rcContour& c = cset.conts[i];
				unsigned int color = duDarkenCol(duIntToCol(c.reg, a));
				
				for (int j = 0; j < c.nrverts; ++j)
				{
					const int* v = &c.rverts[j*4];
					float off = 0;
					unsigned int colv = color;
					if (v[3] & RC_BORDER_VERTEX)
					{
						colv = duRGBA(255,255,255,a);
						off = ch*2;
					}
					
					float fx = orig[0] + v[0]*cs;
					float fy = orig[1] + (v[1]+1+(i&1))*ch + off;
					float fz = orig[2] + v[2]*cs;
					    fx,fy,fz, colv);
				}
			}
			dd->end();
			*/
        renderMesh.Rebuild();
    }