Esempio n. 1
0
    protected void DrawInstantTris(List <int> listTris_Instant)
    {
        if (null == m_drawRenderMesh)
        {
            return;
        }

        m_drawRenderMesh.DeleteDrawMesh_Range(m_iID_Instant_DrawForDEBUG, m_iID_Instant_DrawForDEBUG + m_listTrisAll_copy.Count);

        foreach (int iterIdxTri in listTris_Instant)
        {
            CTRI triRenderDebug = m_listTrisAll_copy[iterIdxTri];

            //@ Just For Draw Debug Triangles
            m_drawRenderMesh.DrawNewRendermesh(m_iID_Instant_DrawForDEBUG + iterIdxTri,
                                               triRenderDebug._arrv3PT,
                                               m_colorInstantSelect,
                                               m_fEpsilon_forZfight,
                                               CDrawRenderMesh.scaleadjust_render_093);
        }
    }
    //@ Construct All Triangles RenderLines
    public void drawAllTrisOneDrawcall(List <CTRI> listTriangle, Color colorTriangles)
    {
        if (null == m_drawRenderMesh_triCollector)
        {
            return;
        }

        if (listTriangle.Count < 1)
        {
            return;
        }

        int iLengthMapping = listTriangle.Count * 3;

        Vector3[] arrVertexmapping = new Vector3[iLengthMapping];

        for (int iSeqTri = 0; iSeqTri < listTriangle.Count; ++iSeqTri)
        {
            CTRI triCurr = listTriangle[iSeqTri];
            for (int iPnt = 0; iPnt < 3; ++iPnt)
            {
                int     iSeqPnt   = iSeqTri * 3 + iPnt;
                Vector3 v3PntCurr = triCurr._arrv3PT[iPnt];

                arrVertexmapping[iSeqPnt] = v3PntCurr;
            }
        }

        m_iSequenceRenderMesh_forDebug = m_drawRenderMesh_triCollector.DrawNewRendermesh(DFLT_IDX_RENDERNAVIMESH,
                                                                                         arrVertexmapping,
                                                                                         colorTriangles,
                                                                                         CMATH.FEPSILON_F3,
                                                                                         -1.0f);
    } // public void drawAllTrisOneDrawcall()
    //@ For DEBUG, Set Draw way StartCell to Goal
    public void drawStartCellToGoal(CNavigation navigation, CTriCollector tricollector)
    {
        UndrawStartCellToGoal();
        _SetundrawNaviCells_Text3D();

        if (null == navigation.m_arrNavicells)
        {
            return;
        }

        bool bResultOrganized = navigation.collectWay_allStartsToGoal(tricollector, ref m_arrSequenceCell);

        if (false == bResultOrganized)
        {
            return;
        }

        CNAVICELL[] arrNavicells = navigation.m_arrNavicells;

        List <int> listSeqTri      = getListSequenceOrganized();
        int        iBasisUniqueNum = m_iBasisUniqueNum_RenderMesh;

        for (int iTriAdj = 0; iTriAdj < listSeqTri.Count; ++iTriAdj)
        {
            int  iSeqUniqueNum = iBasisUniqueNum + listSeqTri[iTriAdj];
            CTRI triAdj_       = arrNavicells[listSeqTri[iTriAdj]].trilinkcell;

            m_drawRenderMesh_navi.DrawNewRendermesh(iSeqUniqueNum,
                                                    triAdj_._arrv3PT,
                                                    Color.Lerp(Color.gray, Color.black, 0.5f),
                                                    CMATH.FEPSILON_F3 + CMATH.FEPSILON_F3,
                                                    CDrawRenderMesh.scaleadjust_render_070);
        }

        _drawText3D_SeqCells(tricollector, tricollector.m_listTris_naviStart);
    } // private void drawStartCellToGoal()
Esempio n. 4
0
    //@ Function has little risk about triangle match.
    protected bool constructAllTris_IVrecompute(int[] arrTri_in,
                                                Vector3[] arrVertex_in,
                                                ref List <CTRI> listTris_out)
    {
        Vector3[] arrv3TriVer = new Vector3[CTRI.CNTPNTTRI];
        int[]     ariTriIdx   = new int[CTRI.CNTPNTTRI];
        int       iCntVB      = arrVertex_in.Length;
        int       iCntIV      = arrTri_in.Length;

        //CHECKOVERLAPPED
        int iCntSameVer__ = 0;

        if (iCntIV < 1 || iCntVB < 1)
        {
            return(false);
        }

        int[] arrIBConvert = new int[iCntIV];

        int  iIVConvert = 0, iIVCurr = 0;
        bool bfindEQ = false;

        for (int iterIV = 0; iterIV < iCntIV; ++iterIV)
        {
            arrIBConvert[iterIV] = arrTri_in[iterIV];
        }

        for (int iterIV = 0; iterIV < iCntVB; ++iterIV)
        {
            Vector3 v3VBCurr = arrVertex_in[iterIV];
            iIVCurr = iterIV; bfindEQ = false;
            for (int iIVin = 0; iIVin < iIVCurr; ++iIVin)
            {
                Vector3 v3VBCurr_ = arrVertex_in[iIVin];

                //bfindEQ = CMATH.similarVector3_FIn(v3VBCurr, v3VBCurr_, 0.4f);
                bfindEQ = (v3VBCurr == v3VBCurr_);

                if (bfindEQ)
                {
                    //FORTEST
                    iCntSameVer__++;

                    iIVConvert = iIVin;
                    break;
                }
            } // for(int iIVin=0; iIVin<iterIV; ++IV_)

            if (true == bfindEQ)
            {
                for (int iSeqIV = 0; iSeqIV < iCntIV; ++iSeqIV)
                {
                    int iIBCurr = (int)arrTri_in[iSeqIV];
                    if (iIBCurr == iterIV)
                    {
                        arrIBConvert[iSeqIV] = iIVConvert;
                    }
                }
            }
        } // for(int iterIV=0; iterIV<arrVertex_in.size(); ++iterIV)

        //@ Overlap vertex
        if (0 < iCntSameVer__)
        {
            Debug.Log("Notice! (overlapped:" + iCntSameVer__ + " vertices.) Count of exactly same position vertices//constructAllTris_IVrecompute()//arrTri_in.Length=" + arrTri_in.Length);
        }

        //@Insert only validation succeeded triangle.
        CTRI    triCurrent;
        int     iSeqTriCurr = 0, iSeqTri_ = 0;
        Vector3 v3MinAABB = new Vector3(CMATH.FLOAT_MAX, CMATH.FLOAT_MAX, CMATH.FLOAT_MAX),
                v3MaxAABB = new Vector3(-CMATH.FLOAT_MAX, -CMATH.FLOAT_MAX, -CMATH.FLOAT_MAX);

        Vector3 v3VerTri;

        //@ overlap triangles
        int         iCntExactlySameTris = 0, iCntNotValidatePoly = 0;
        List <CTRI> listTriOverlap = new List <CTRI>();

        for (int iSeqIdx = 0, iTri = 0; iSeqIdx < iCntIV; iSeqIdx += 3, ++iTri)
        {
            ariTriIdx[0] = arrIBConvert[iSeqIdx];
            ariTriIdx[1] = arrIBConvert[iSeqIdx + 1];
            ariTriIdx[2] = arrIBConvert[iSeqIdx + 2];

            for (int itV = 0; itV < 3; ++itV)
            {
                v3VerTri = new Vector3(arrVertex_in[ariTriIdx[itV]].x, arrVertex_in[ariTriIdx[itV]].y, arrVertex_in[ariTriIdx[itV]].z);

                if (v3VerTri.x > v3MaxAABB.x)
                {
                    v3MaxAABB.x = v3VerTri.x;
                }
                if (v3VerTri.y > v3MaxAABB.y)
                {
                    v3MaxAABB.y = v3VerTri.y;
                }
                if (v3VerTri.z > v3MaxAABB.z)
                {
                    v3MaxAABB.z = v3VerTri.z;
                }

                if (v3VerTri.x < v3MinAABB.x)
                {
                    v3MinAABB.x = v3VerTri.x;
                }
                if (v3VerTri.y < v3MinAABB.y)
                {
                    v3MinAABB.y = v3VerTri.y;
                }
                if (v3VerTri.z < v3MinAABB.z)
                {
                    v3MinAABB.z = v3VerTri.z;
                }

                arrv3TriVer[itV] = v3VerTri;
            }

            triCurrent = new CTRI();
            triCurrent.Set(arrv3TriVer, ariTriIdx);

            if (true == triCurrent.isValidateASPoly())
            {
                bool bBeExistExactlysame = false;

                for (int iSeqIdx__ = 0; iSeqIdx__ < iSeqTriCurr; ++iSeqIdx__)
                {
                    if (iSeqIdx__ != iSeqIdx)
                    {
                        CTRI tri__ = listTris_out[iSeqIdx__];
                        if (tri__.isEqual(triCurrent))
                        {
                            //FORTEST
                            ++iCntExactlySameTris;

                            listTriOverlap.Add(triCurrent);
                            //FORTEST

                            bBeExistExactlysame = true;
                            break;
                        }
                    }
                } // for (int iSeqIdx__ = 0; iSeqIdx__ < iSeqTriCurr; ++iSeqIdx__)

                if (false == bBeExistExactlysame)
                {
                    iSeqTriCurr = iSeqTri_++;

                    listTris_out.Add(triCurrent);
                }
                else
                {
                    Debug.Log("!ERROR. Overlapped Triangle. Exist Exactly same TRI");
                }
            } // if(true==triCurrent.isValidateASPoly())
            else
            { // //CHECKOVERLAPPED
                ++iCntNotValidatePoly;
            } // if(true==triCurrent.isValidateASPoly())
        }     // for( uint iSeqIdx=0, iTri=0; iSeqIdx<iCntIV; iSeqIdx+=3,++iTri )

        //CHECKOVERLAPPED
        //@ maya에서 같은 위치에 Overlap된 polygon 작업이 있는 지 여부 검사.
        if (listTriOverlap.Count > 0)
        {
            int iSeq = 0;
            foreach (CTRI triOverlap in listTriOverlap)
            {
                m_drawRenderMesh_forcheckoverlap.DrawNewRendermesh(CMATH.INT_MAX_DIV248 + (iSeq++), triOverlap._arrv3PT, color_overllaped_triangle, CMATH.FEPSILON_F2, -1.0f);
            }

            string strDebugOut = "!ERROR triangles overlapped. //count=" + listTriOverlap.Count + "\n";
            strDebugOut += "!constructAllTris_IVrecompute:CountTris=" + listTris_out.Count + "//" +
                           "ExactlySameTris=" + iCntExactlySameTris + "//" + "NoValidateTris=" + iCntNotValidatePoly + "//" + UnityEngine.Random.Range(10.0f, 10000.0f);

            Debug.Log(strDebugOut);
        } // if(listTriOverlap.Count > 0)
          //CHECKOVERLAPPED

        return(true);
    }   //protected bool CTriContainer::constructAllTris_IVrecompute(