예제 #1
0
파일: UMesh.cs 프로젝트: naaturaz/SM
    public static List <Vector3> ReturnCurrentLotsVertex(List <int> currentIndexes, List <Lot> squares)
    {
        List <Vector3> vertexs = new List <Vector3>();

        for (int i = 0; i < currentIndexes.Count; i++)
        {
            vertexs = UList.AddOneListToList(vertexs, squares[currentIndexes[i]].LotVertices);
        }
        return(vertexs);
    }
예제 #2
0
    /// <summary>
    /// Scan Routine will add new lots to lots list from the result of ScanTerraRetLotVertex()
    /// </summary>
    /// <param name="inPolyDiv">how many div ex 5x5 a real poly will have</param>
    /// <param name="polyX">real polys in X will cover in each scan pass</param>
    /// <param name="polyZ">real polys in Z will cover in each scan pass</param>
    private void ScanProcedure(int inPolyDiv, int polyX, int polyZ)
    {
        //return;

        List <Vector3> newLotVertex = new List <Vector3>();

        newLotVertex = ScanTerraRetLotVertex(inPolyDiv, polyX, polyZ);
        Lots.Add(new Lot(newLotVertex, Lots.Count, lotStart, lotEnd));
        //print("LotsScanned:" + Lots.Count);
        AllVertexs = UList.AddOneListToList(AllVertexs, newLotVertex);
    }
예제 #3
0
파일: SubPolyr.cs 프로젝트: Cdrix/SM
    /// 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);
    }
예제 #4
0
    /// <summary>
    /// Subdive a lot. Will move the ref Vector3 start to the end of
    ///  the lot and will send the value bak to the caller of this method
    /// </summary>
    /// <param name="start">Start point of the lot... will be ref back here</param>
    /// <param name="polyX">how many poly on X</param>
    /// <param name="polyZ">how many ppoly oin Z</param>
    /// <param name="stepX">how far in X a real vertices is from another</param>
    /// <param name="stepZ">how far in Z a real vertices is from another</param>
    /// <param name="inPolyDiv">in poly divisions</param>
    /// <param name="vertices">all mesh vertices[]</param>
    /// <returns>a Vector3 list with the lot</returns>
    public List <Vector3> SubDivideLot(ref Vector3 start, int polyX, int polyZ,
                                       float stepX, float stepZ, int inPolyDiv, Vector3[] vertices)
    {
        float          localStepZ = 0;
        List <Vector3> lot        = new List <Vector3>();
        Vector3        temp       = start;
        Vector3        real       = new Vector3();

        for (int i = 0; i < polyZ; i++)
        {
            temp   = start;
            temp.z = start.z + localStepZ;
            //to make sure we are on top of a real vertex
            Vector3 realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z);
            real = m.Vertex.FindClosestVertex(realDummy, vertices);

            for (int j = 0; j < polyX; j++)
            {
                List <Vector3> poly   = returnPoly(real, vertices);
                List <Vector3> newLot = SubDividePoly(poly, inPolyDiv, H.Tile);

                CheckIfStopScanning(newLot, polyX, polyZ, start);

                lot    = UList.AddOneListToList(lot, newLot);
                temp.x = real.x + Mathf.Abs(stepX);

                realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z); //

                //in the last row has to jump in Z: temp.z - Mathf.Abs(stepZ))
                if (j == polyX - 1)
                {
                    //to make sure we are on top of a real vertex
                    realDummy = m.Vertex.BuildVertexWithXandZ(temp.x, temp.z - Mathf.Abs(stepZ)); //
                }
                real = m.Vertex.FindClosestVertex(realDummy, vertices);
            }
            //with multoplicacton was loosing big time precision...
            //that why im adding here the values... with floats avoid multiplcations
            localStepZ = localStepZ + stepZ;
        }
        start = real;
        //lot = UList.EliminateDuplicatesByDist(lot, 0.01f);
        //print(lot.Count + ".lot.count");
        return(lot);
    }
예제 #5
0
    // Full,//this will use create object everywere in the poly
    //Tile//this one will only fill so the next poly doesnt create any obj was created on this one
    //already
    public List <Vector3> SubDividePoly(List <Vector3> poly, int divs, H fillStyle)
    {
        List <Vector3> filled   = new List <Vector3>();
        List <Vector3> topLine  = SubDivideLine(poly, 0, 1, divs, H.X);
        List <Vector3> leftLine = SubDivideLine(poly, 1, 2, divs, H.Z);

        if (fillStyle == H.Full)
        {
            List <Vector3> botLine   = SubDivideLine(poly, 2, 3, divs, H.X);
            List <Vector3> rightLine = SubDivideLine(poly, 3, 0, divs, H.Z);
            filled = UList.AddManyListToList(botLine, rightLine, leftLine);
        }
        List <Vector3> fill = FillPolygonWrite(topLine, leftLine);

        filled = UList.AddManyListToList(filled, topLine, leftLine);
        filled = UList.AddOneListToList(filled, fill);
        float dist = 0.001f;

        //filled = UList.EliminateDuplicatesByDist(filled, dist);
        filled = filled.Distinct().ToList();
        //print(filled.Count + "filled");
        return(filled);
    }