public void DrawMesh_user(int iIDX_, Vector3[] arrVertex_in, int[] arriIB, Color colorUser_, float fScale_, float fEpsilonForZFight) { m_iIDX = iIDX_; int iCntVertices = arrVertex_in.Length; Vector3[] arrVertex_to = new Vector3[arrVertex_in.Length]; if (fEpsilonForZFight > CMATH.FEPSILON_F4) { for (int iVB = 0; iVB < iCntVertices; ++iVB) { Vector3 v3Src_ = arrVertex_in[iVB]; arrVertex_to[iVB] = new Vector3(v3Src_.x, v3Src_.y + fEpsilonForZFight, v3Src_.z); } } else { Array.Copy(arrVertex_in, arrVertex_to, arrVertex_in.Length); } if (fScale_ > 0) { CMATH.rescaleVertices(ref arrVertex_to, fScale_); } Mesh meshUser = gameObject.AddComponent <MeshFilter>().mesh; Renderer rendererNew = gameObject.AddComponent <MeshRenderer>().GetComponent <Renderer>(); Vector2[] arrv2UV = new Vector2[iCntVertices]; for (int iVB = 0; iVB < iCntVertices; ++iVB) { arrv2UV[iVB] = new Vector2(arrVertex_to[iVB].x, arrVertex_to[iVB].z); } meshUser.vertices = arrVertex_to; meshUser.triangles = arriIB; meshUser.uv = arrv2UV; meshUser.RecalculateNormals(); // Option rendererNew.material = m_materialUser; // material Mesh rendererNew.material.color = colorUser_; // Color Mesh } // public void DrawMesh_user()
} // public bool intersectRay_inAdjs(int iSeqCell, Vector3 v3RayOrigin, Vector3 v3RayDir, ref Vector3 posIntersected_out) //@ Organize shortest way block edges only Current cell public bool setNaviPortal_forShortestWay(Vector2[] arrv2PntObjBoundary, ref CNAVICELL cellWayStart) { if (true == cellWayStart.useWaytoPortal) { return(true); } List <CNAVICELL> listSequenceCell = new List <CNAVICELL>(); collectWayToGoalLinear(m_arrNavicells, cellWayStart, ref listSequenceCell, ref m_computeEdgeBlock); if (listSequenceCell.Count < 2) { return(true); } Vector3 v3PntPrev = new Vector3(); Vector3 v3PntCurr = new Vector3(); Vector3 v3PntNext = new Vector3(); int iLenSeq = listSequenceCell.Count; int iSeqIteration = 0; CNAVICELL cellGOAL = listSequenceCell[iLenSeq - 1]; CNAVICELL cellNext, cellPrev; bool bCrosswithBlock = false; bool bSetNewPortalPosition = false; Vector3[] arrv3Pnt_Cell_start = new Vector3[cellWayStart.m_arrv3PT.Length]; Array.Copy(cellWayStart.m_arrv3PT, arrv3Pnt_Cell_start, cellWayStart.m_arrv3PT.Length); CMATH.rescaleVertices(ref arrv3Pnt_Cell_start, DFLT_ADJUST_SCALE_FOR_VISIBLECHECK); foreach (CNAVICELL cellCurr in listSequenceCell) { int iSeqCurr = iSeqIteration++; if (0 == iSeqCurr) { continue; } if (cellGOAL == cellCurr) { cellWayStart.SetPortalPosition(cellGOAL.seqCell, cellGOAL.getPos_cellCenter()); bSetNewPortalPosition = true; break; } cellPrev = listSequenceCell[iSeqCurr - 1]; cellNext = listSequenceCell[iSeqCurr + 1]; cellCurr.getPos_BestWay_onEdge(ref v3PntCurr); cellNext.getPos_BestWay_onEdge(ref v3PntNext); cellPrev.getPos_BestWay_onEdge(ref v3PntPrev); bCrosswithBlock = false; foreach (Vector3 v3PntCell in arrv3Pnt_Cell_start) { if (m_computeEdgeBlock.crossBlockIteration(v3PntCell, v3PntNext)) { bCrosswithBlock = true; break; } } //@ Set Portal if (true == bCrosswithBlock) { cellWayStart.SetPortalPosition(cellCurr.seqCell, v3PntCurr); bSetNewPortalPosition = true; break; } Vector2 v2PntNext = CMATH.ConvertToV2_Y(v3PntNext); foreach (Vector2 v2PntObj in arrv2PntObjBoundary) { //@ Cross At least 1 mo if (true == m_computeEdgeBlock.crossBlockIteration(v2PntObj, v2PntNext)) { bCrosswithBlock = true; break; } } //@ Set Portal -2 if (true == bCrosswithBlock) { cellWayStart.SetPortalPosition(cellCurr.seqCell, v3PntCurr); bSetNewPortalPosition = true; break; } } // foreach (CNAVICELL cellCurr in listSequenceCell) listSequenceCell.Clear(); listSequenceCell = null; return(bSetNewPortalPosition); } // public bool setNaviPortal_forShortestWay(int iSeqCell)