Пример #1
0
    public static void ShowContours(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.nverts == 0)
            {
                continue;
            }

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

            for (int j = 0, k = c.nverts - 1; j < c.nverts; k = j++)
            {
                int   vaStart = k * 4;
                int   vbStart = j * 4;
                Color segCol  = ((c.verts[vaStart + 3] & Recast.RC_AREA_BORDER) != 0) ? bcol : col;

                Vector3 start = new Vector3(orig[0] + c.verts[vaStart + 0] * cs,
                                            orig[1] + (c.verts[vaStart + 1] + 1 + (i & 1)) * ch,
                                            orig[2] + c.verts[vaStart + 2] * cs);
                Vector3 end = new Vector3(orig[0] + c.verts[vbStart + 0] * cs,
                                          orig[1] + (c.verts[vbStart + 1] + 1 + (i & 1)) * ch,
                                          orig[2] + c.verts[vbStart + 2] * cs);

                renderMesh.AddVerticalQuad(start, end, 0.5f, segCol);
            }
        }

        /*
         *              dd->begin(DU_DRAW_POINTS, 3.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.nverts; ++j)
         *                      {
         *                              const int* v = &c.verts[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);
         *                      }
         *              }
         */
        renderMesh.Rebuild();
    }
Пример #2
0
    public static void ShowContours(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.nverts == 0)
                continue;

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

            for (int j = 0, k = c.nverts - 1; j < c.nverts; k = j++)
            {
                int vaStart = k * 4;
                int vbStart = j * 4;
                Color segCol = ((c.verts[vaStart + 3] & Recast.RC_AREA_BORDER) != 0) ? bcol : col;

                Vector3 start = new Vector3(orig[0] + c.verts[vaStart + 0] * cs,
                                            orig[1] + (c.verts[vaStart + 1] + 1 + (i & 1)) * ch,
                                            orig[2] + c.verts[vaStart + 2] * cs);
                Vector3 end = new Vector3(orig[0] + c.verts[vbStart + 0] * cs,
                                          orig[1] + (c.verts[vbStart + 1] + 1 + (i & 1)) * ch,
                                          orig[2] + c.verts[vbStart + 2] * cs);

                renderMesh.AddVerticalQuad(start, end, 0.5f, segCol);
            }
        }

        /*
			dd->begin(DU_DRAW_POINTS, 3.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.nverts; ++j)
				{
					const int* v = &c.verts[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);
				}
			}
			*/
        renderMesh.Rebuild();
    }
Пример #3
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();
    }
Пример #4
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();
    }