Exemplo n.º 1
0
 public n_Square(n_Node a, n_Node b, n_Node c, n_Node d)
 {
     n_nodes = new n_Node[4]
     {
         a, b, c, d
     };
 }
Exemplo n.º 2
0
    public Wall_Square_Grids(List <List <int> > Outlines, List <Vector3> Verts_, int r_ = 10, float w_ = 5f)
    {
        #region Initialize
        Points_   = new List <n_Node>();
        Tri_index = new List <int>();
        #endregion

        #region List<n_Node[,]>
        List <n_Node[, ]> N_ = new List <n_Node[, ]>();

        float s = w_ / (r_ - 1);

        for (int u = 0; u < Outlines.Count; u += 1)
        {
            List <int> index_ = Outlines[u];
            int        x_L    = Outlines[u].Count;
            n_Node[,] new_2D_n_Node_Array = new n_Node[x_L, r_];

            for (int x = 0; x < x_L; x += 1)
            {
                Vector3 dir_ = Vector3.zero;
                Vector3 v_   = Verts_[index_[x]];
                #region dir_ && v
                if (x <= x_L - 2)
                {
                    Vector3 a = Verts_[index_[x + 1]] - Verts_[index_[x]];
                    Vector3 b = Vector3.down;

                    dir_ = -Vector3.Cross(a, b);
                }
                else
                {  // Last_vert
                    Vector3 a = Verts_[index_[1]] - Verts_[index_[0]];
                    Vector3 b = Vector3.down;

                    dir_ = -Vector3.Cross(a, b);
                }
                #endregion

                for (int y = 0; y <= r_ - 1; y += 1)
                {
                    Vector3 p_ = v_ + (Vector3.down * (s) * y);
                    new_2D_n_Node_Array[x, y] = new n_Node(p_, dir_);
                }
            }
            N_.Add(new_2D_n_Node_Array);
        }
        #endregion

        #region points_on_wall
        wall_spacing_points = new List <n_Node>();
        for (int i = 0; i < N_.Count; i += 1)
        {
            int V_spacing = r_ / 2;
            int H_spacing = 10;
            int loop_t    = N_[i].GetLength(0) / H_spacing;

            int y = V_spacing;
            for (int x = 0; x < loop_t; x += H_spacing)
            {
                n_Node new_n_Node = N_[i][x, y];
                wall_spacing_points.Add(new_n_Node);
            }
        }
        //Debug.Log(wall_spacing_points.Count);
        #endregion

        #region List<n_Square>
        List <n_Square> n_squares = new List <n_Square>();

        for (int u = 0; u < Outlines.Count; u += 1)
        {
            int x_L = Outlines[u].Count;
            n_Node[,] _n_ = N_[u];

            for (int y = 0; y <= r_ - 2; y += 1)
            {
                for (int x = 0; x <= x_L - 2; x += 1)
                {
                    n_Square new_n_sq = new n_Square(_n_[x, y], _n_[x, y + 1], _n_[x + 1, y + 1], _n_[x + 1, y]);
                    n_squares.Add(new_n_sq);
                }
            }
        }
        #endregion

        #region Loop_through_all     n_sq in ...........List
        for (int i = 0; i < n_squares.Count; i += 1)
        {
            n_Square sq = n_squares[i];
            // Create_Bridge
            Create_Bridge(sq);
            //Make Triangle
            Make_Triangle(sq.n_nodes);
        }
        #endregion
    }