//Finds a Poly given the topLeft, the steps will find it in the Vector3[] arrayVerts public static List <Vector3> FindPoly(Vector3 topLeft, float stepX, float stepZ, Vertexer vertex, Vector3[] arrayVerts) { //with the creating of the dummy ones is working like a charm.. bz the dummy vector3 is really close //to the real one... before in mountains didnt work bz in Y they were to far and the closest vertices //in a list were diffrent tht i was expecting Vector3 temp = topLeft; List <Vector3> poly = new List <Vector3>() { topLeft }; //top Right temp.x = topLeft.x + Mathf.Abs(stepX); Vector3 toprightDummy = vertex.BuildVertexWithXandZ(temp.x, temp.z); Vector3 topright = m.Vertex.FindClosestVertex(toprightDummy, arrayVerts); poly.Add(topright); //bottom right temp.x = topLeft.x + Mathf.Abs(stepX); temp.z = topLeft.z - Mathf.Abs(stepZ); Vector3 bottomRightDummy = vertex.BuildVertexWithXandZ(temp.x, temp.z); Vector3 bottomRight = m.Vertex.FindClosestVertex(bottomRightDummy, arrayVerts); poly.Add(bottomRight); //bottom left temp.x = topLeft.x; //refer again to orignal val temp.z = topLeft.z - Mathf.Abs(stepZ); Vector3 bottomLeftDummy = vertex.BuildVertexWithXandZ(temp.x, temp.z); Vector3 bottomLeft = m.Vertex.FindClosestVertex(bottomLeftDummy, arrayVerts); poly.Add(bottomLeft); return(poly); }
//Return the subpolygons selected ... this are fake subpolygons... a bunch of them public List <Vector3> SubPolygonsSelected(int cols, int rows, ref List <Vector3> objsHitTerrain, Vector3 iniHit, SubDivider subDivide, int rotationFacer, bool isMouseOnTerrain, Vertexer vertex, UPoly poly, List <Vector3> currentHoverVertices) { List <Vector3> subPolys = new List <Vector3>(); subPolys = CreateListSelected(ref objsHitTerrain, cols, rows, iniHit, subDivide, isMouseOnTerrain, vertex, poly, currentHoverVertices); //print(cols + ".c||r."+rows+ " ini:."+iniHit); //print(objsHitTerrain.Count + " objsHitTerrain.cou"); //print(subPolys.Count + " subPolys.coun"); //List<Vector3> firstRow = ReturnFirstRow(subPolys, rotationFacer); return(subPolys); }
/// Creates a list for the selected sub polygons given the columns and rows List <Vector3> CreateListSelected(ref List <Vector3> objsHitTerrain, int columns, int rows, Vector3 iniHit, SubDivider subDivide, bool isMouseOnTerrain, Vertexer vertex, UPoly poly, List <Vector3> currentHoverVertices) { objsHitTerrain = UMesh.ReturnThePos(iniHit, subDivide.XSubStep, subDivide.ZSubStep, columns, rows); List <Vector3> res = new List <Vector3>(); for (int i = 0; i < objsHitTerrain.Count; i++) { res = UList.AddOneListToList(res, CreateOneSubPoly(objsHitTerrain[i], isMouseOnTerrain, vertex, subDivide, poly, currentHoverVertices)); } //still needs to eliminate duplicates return(res); }
public static List <Vector3> ReturnARealPoly(Vector3 hitVector3, Vector3[] Vertices, InitializerTerrain iniTerr, Vertexer vertex) { if (hitVector3 == null || hitVector3 == new Vector3()) { return(new List <Vector3>()); } Vector3 firstVertex = vertex.FindClosestVertex(hitVector3, Vertices); Dir quadrant = vertex.FindVertexQuadrant(firstVertex, hitVector3); Vector3 lefTopVertex = vertex.FindTopLeftVertex(firstVertex, quadrant, iniTerr.StepX, iniTerr.StepZ, Vertices); //UVisHelp.CreateHelpers(lefTopVertex, Root.redSphereHelp); List <Vector3> poly = FindPoly(lefTopVertex, iniTerr.StepX, iniTerr.StepZ, vertex, Vertices); //UVisHelp.CreateHelpers(poly, Root.boxCollHelp); return(poly); }
// Use this for initialization void Start() { camera = USearch.FindCurrentCamera(); Malla = (Malla)General.Create(Root.malla, container: Program.ClassContainer.transform); Poly = new UPoly(); subDivide = new SubDivider(); Vertex = new Vertexer(); iniTerr = new InitializerTerrain(); iniTerr.Initializer(ref Vertices, ref mesh); iniTerr.InitializeMallaStats(Vertices, ref wholeMalla, ref nextStart, ref zLot); SubPolyr = new SubPolyr(); subMesh = new SubMeshData(); IsLoading = true; //bz is static and if a new game is started needs to clean up and start again CrystalManager1 = new CrystalManager(); }
//create one subpoly based on where we hit the terrain List <Vector3> CreateOneSubPoly(Vector3 hitPointOnSubPoly, bool isMouseOnTerrain, Vertexer vertex, SubDivider subDivide, UPoly poly, List <Vector3> currentHoverVertices) { //print(isMouseOnTerrain + "isMouseOnTerrain"); List <Vector3> subPoly = new List <Vector3>(); if (isMouseOnTerrain) { Vector3 firstVertex = vertex.FindClosestVertex(hitPointOnSubPoly, currentHoverVertices.ToArray()); Dir quadrant = vertex.FindVertexQuadrant(firstVertex, hitPointOnSubPoly); Vector3 lefTopVertex = vertex.FindTopLeftVertex(firstVertex, quadrant, subDivide.XSubStep, subDivide.ZSubStep, currentHoverVertices.ToArray()); subPoly = UPoly.FindPoly(lefTopVertex, subDivide.XSubStep, subDivide.ZSubStep, vertex, currentHoverVertices.ToArray()); //UVisHelp.CreateHelpers(subPoly, Root.blueCube); } return(subPoly); }