Advertisement
Guest User

Untitled

a guest
May 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. private Color getColor(int row, int column, TerrainGridSystem tgs, Texture2D my_texture, List<Cell> myCells)
  2. {
  3.     int Nx = tgs.rowCount;
  4.     int Nz = tgs.columnCount;
  5.    
  6.     int currentIndex = column + Nx * row;
  7.     Vector3 centerCoord = tgs.CellGetPosition(myCells[currentIndex]);
  8.  
  9.     int texture_height = my_texture.height;
  10.     int texture_width = my_texture.width;
  11.  
  12.     int dx_texture_size = texture_height / Nx;
  13.     int dz_texture_size = texture_width / Nz;
  14.  
  15.     int pixel_coord_x = dx_texture_size / 2 + column * dx_texture_size;
  16.     int pixel_coord_z = dz_texture_size / 2 + row * dz_texture_size;
  17.  
  18.     return my_texture.GetPixel(pixel_coord_x, pixel_coord_z);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement