Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #ifndef OctTreeMapH
  4. #define OctTreeMapH
  5. #include "DxcMath.h"
  6. #include "DxcMatrix.h"
  7. #include "TachoGLModelSRC.h"
  8. #include "OPENGL_ATTACH.h"
  9. #include "gl/glew.h"
  10. #include "gl/gl.h"
  11. //---------------------------------------------------------------------------
  12. struct TOCTreeSector
  13. {
  14. t3dpoint A;
  15. t3dpoint B;
  16. t3dpoint C;
  17. t3dpoint D;
  18. INDEX_ARR indices;
  19. };
  20.  
  21. typedef DynamicArray<TOCTreeSector> OCTSectors;
  22. typedef DynamicArray<OCTSectors> ModelSectors;
  23.  
  24. struct TOCTreeMap
  25. {
  26. int maplen;
  27. TachoGLModelP * map;
  28.  
  29. ModelSectors Sectors;
  30.  
  31.  
  32. //map size 120 x 120 (heightmaps)s
  33. void CreateOctMap(int MAP_SIZE, int BLOCKS, int modelindex)
  34. {
  35. double BLOCKS_PER_OCT = double(MAP_SIZE) / double(BLOCKS);
  36.  
  37. int BLOCK_SIZE = int(BLOCKS_PER_OCT);
  38.  
  39. if ( double(BLOCK_SIZE) != BLOCKS_PER_OCT ) {ShowMessage("OCTree reports that mapsize / blocks is not an integer value. Aborting."); return; }
  40.  
  41.       int x; int y;     int bx; int by;
  42.  
  43. Sectors[modelindex].set_length( BLOCKS * BLOCKS );
  44.  
  45. int i; int j;
  46.  
  47. for (i=0; i < Sectors.Length; i++) Sectors[modelindex][i].indices.set_length( BLOCKSIZE * BLOCKSIZE );
  48.  
  49.  
  50.  
  51.  
  52. int cnt;       int index;           int vindex;
  53.  
  54. for (i=0; i < BLOCKS; i++)      //x direction
  55. for (j=0; j < BLOCKS; j++)      //y direction
  56. {
  57. cnt = -1;
  58. for (y=0; y < BLOCK_SIZE; y++)
  59. for (x=0; x < BLOCK_SIZE; x++)
  60. {
  61. cnt = cnt + 1;
  62. index = j * MAP_SIZE * BLOCKSIZE + i * BLOCKSIZE + y * MAP_SIZE + x;
  63.  
  64. vindex = map[modelindex]->VBO_BE[index].INDEX_START;
  65.  
  66. Sectors[modelindex][ j*BLOCKS + i ].indices[ cnt ] = index;
  67.  
  68. if ( (x == 0) && (y == 0) )                         A = map[modelindex]->VBO_V[ vindex ];// covers first boundary vertex
  69. if ( (x == BLOCK_SIZE-1) && (y == 0) )              B = map[modelindex]->VBO_V[ vindex ];// covers second boundary vertex
  70. if ( (x == BLOCK_SIZE-1) && (y == BLOCK_SIZE-1) )   C = map[modelindex]->VBO_V[ vindex ];// covers third boundary vertex
  71. if ( (x == 0) && (y == BLOCK_SIZE-1) )              D = map[modelindex]->VBO_V[ vindex ];// covers last boundary vertex
  72.  
  73. }
  74.  
  75. }
  76.  
  77.  
  78. }
  79.  
  80. AssignModels(TachoGLModelP * tmp, int len)
  81. {
  82. maplen = len;
  83. map = new TachoGLModelP[ len ];
  84.  
  85. int i;
  86. for (i=0; i<len; i++) map[i] = tmp[i];
  87.  
  88. Sectors.set_length( len );
  89. }
  90.  
  91.  
  92.  
  93. void Draw()
  94. {
  95.  
  96. }
  97.  
  98. };
  99.  
  100.  
  101. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement