//--------------------------------- public void exportNavMeshToOBJ() { if (mPathMeshTris.Count == 0) { return; } //ouput our data to the file. OBJFile output = new OBJFile(); output.addObject("Terrain"); List <int> inds = new List <int>(); for (int i = 0; i < mPathMeshTris.Count; i++) { Export360.XTD_DeulanyTIN.triangle tri = mPathMeshTris[i]; //if this tri has 0 area, get rid of it.. //CLM deulany outputs a different clockwise winding than i want.. //this SHOULD be a proper clockwise winding test inds.Add(tri.vertIndex[0]); inds.Add(tri.vertIndex[1]); inds.Add(tri.vertIndex[2]); } output.addVertexList(0, mPathMeshVerts, inds); string filenameNoExt = Path.GetFileNameWithoutExtension(CoreGlobals.ScenarioFile); string targetFilename = CoreGlobals.ScenarioDirectory + @"\" + filenameNoExt + ".obj"; if (File.Exists(targetFilename)) { File.Delete(targetFilename); } output.write(new FileStream(targetFilename, FileMode.OpenOrCreate)); output = null; }
void pruneTriList(List <Export360.XTD_DeulanyTIN.triangle> triList, List <Point> primeSimVerts) { //remove any trs that span impassible terrain for (int i = 0; i < triList.Count; i++) { Export360.XTD_DeulanyTIN.triangle tri = triList[i]; Vector3 v0 = new Vector3(primeSimVerts[tri.vertIndex[0]].X, 0, primeSimVerts[tri.vertIndex[0]].Y); // TerrainGlobals.getTerrain().getPostDeformPos(primeSimVerts[tri.vertIndex[0]].X, primeSimVerts[tri.vertIndex[0]].Y); Vector3 v1 = new Vector3(primeSimVerts[tri.vertIndex[1]].X, 0, primeSimVerts[tri.vertIndex[1]].Y); //TerrainGlobals.getTerrain().getPostDeformPos(primeSimVerts[tri.vertIndex[1]].X, primeSimVerts[tri.vertIndex[1]].Y); Vector3 v2 = new Vector3(primeSimVerts[tri.vertIndex[2]].X, 0, primeSimVerts[tri.vertIndex[2]].Y); //TerrainGlobals.getTerrain().getPostDeformPos(primeSimVerts[tri.vertIndex[2]].X, primeSimVerts[tri.vertIndex[2]].Y); if (BMathLib.cFloatCompareEpsilon > BMathLib.areaOfTriangle(ref v0, ref v1, ref v2)) { removeTri(triList, i); i--; continue; } //find the centroid of this triangle. bail if it's surrounded by impassible area Vector3 p0v = new Vector3(primeSimVerts[tri.vertIndex[0]].X, 0, primeSimVerts[tri.vertIndex[0]].Y); Vector3 p1v = new Vector3(primeSimVerts[tri.vertIndex[1]].X, 0, primeSimVerts[tri.vertIndex[1]].Y); Vector3 p2v = new Vector3(primeSimVerts[tri.vertIndex[2]].X, 0, primeSimVerts[tri.vertIndex[2]].Y); Vector3 centroid = BMathLib.centroidOfTriangle(ref p0v, ref p1v, ref p2v); Point cx = new Point((int)centroid.X, (int)centroid.Z); if (0x0F == giveSimValueForVisVert(cx.X, cx.Y, true)) { removeTri(triList, i); i--; continue; } triList[i].myIndex = i; } }