Guest User

Untitled

a guest
Sep 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. public uint[] LoadVXL(byte[] bytes)
  2. {
  3. uint[] map = new uint[Width*Height*Depth];
  4. var r = new System.Random();
  5. int pos = 0;
  6.  
  7. for (int y = 0; y < Depth; ++y)
  8. {
  9. for (int x = 0; x < Width; ++x)
  10. {
  11. int z = 0;
  12. uint color = 0;
  13.  
  14. for (; z < Height; ++z)
  15. {
  16. uint col = 0x646250; //london color
  17. col ^= 0x070707 & (uint) r.Next();
  18. map[GetPosition(x, z, y)] = col;
  19. }
  20.  
  21. z = 0;
  22. while (true)
  23. {
  24. int number_4byte_chunks = bytes[pos];
  25. int top_color_start = bytes[pos + 1];
  26. int top_color_end = bytes[pos + 2];
  27. int bottom_color_start;
  28. int bottom_color_end;
  29. int len_top;
  30. int len_bottom;
  31.  
  32. for (; z < top_color_start; ++z)
  33. {
  34. map[GetPosition(x, z, y)] = 0x000000;
  35. }
  36.  
  37. int colorpos = pos + 4;
  38. for (; z <= top_color_end; z++)
  39. {
  40. color = BitConverter.ToUInt32(bytes, colorpos);
  41. colorpos += 4;
  42. map[GetPosition(x, z, y)] = color;
  43. }
  44.  
  45. if (top_color_end == Height - 2)
  46. {
  47. map[GetPosition(x, y, Height - 1)] = map[GetPosition(x, y, Height - 2)];
  48. }
  49.  
  50. len_bottom = top_color_end - top_color_start + 1;
  51.  
  52. if (number_4byte_chunks == 0)
  53. {
  54. pos += 4 * (len_bottom + 1);
  55. break;
  56. }
  57.  
  58. len_top = (number_4byte_chunks - 1) - len_bottom;
  59.  
  60. pos += (int) bytes[pos] * 4;
  61.  
  62. bottom_color_end = bytes[pos + 3];
  63. bottom_color_start = bottom_color_end - len_top;
  64.  
  65. for (z = bottom_color_start; z < bottom_color_end; z++)
  66. {
  67. color = BitConverter.ToUInt32(bytes, colorpos);
  68. colorpos += 4;
  69. map[GetPosition(x, z, y)] = color;
  70. }
  71. if (bottom_color_end == Height - 1)
  72. {
  73. map[GetPosition(x, y, Height - 1)] = map[GetPosition(x, y, Height - 2)];
  74. }
  75. }
  76. }
  77. }
Add Comment
Please, Sign In to add comment