Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #ifndef OctTreeMapH
- #define OctTreeMapH
- #include "DxcMath.h"
- #include "DxcMatrix.h"
- #include "TachoGLModelSRC.h"
- #include "OPENGL_ATTACH.h"
- #include "gl/glew.h"
- #include "gl/gl.h"
- //---------------------------------------------------------------------------
- struct TOCTreeSector
- {
- t3dpoint A;
- t3dpoint B;
- t3dpoint C;
- t3dpoint D;
- INDEX_ARR indices;
- };
- typedef DynamicArray<TOCTreeSector> OCTSectors;
- typedef DynamicArray<OCTSectors> ModelSectors;
- struct TOCTreeMap
- {
- int maplen;
- TachoGLModelP * map;
- ModelSectors Sectors;
- //map size 120 x 120 (heightmaps)s
- void CreateOctMap(int MAP_SIZE, int BLOCKS, int modelindex)
- {
- double BLOCKS_PER_OCT = double(MAP_SIZE) / double(BLOCKS);
- int BLOCK_SIZE = int(BLOCKS_PER_OCT);
- if ( double(BLOCK_SIZE) != BLOCKS_PER_OCT ) {ShowMessage("OCTree reports that mapsize / blocks is not an integer value. Aborting."); return; }
- int x; int y; int bx; int by;
- Sectors[modelindex].set_length( BLOCKS * BLOCKS );
- int i; int j;
- for (i=0; i < Sectors.Length; i++) Sectors[modelindex][i].indices.set_length( BLOCKSIZE * BLOCKSIZE );
- int cnt; int index; int vindex;
- for (i=0; i < BLOCKS; i++) //x direction
- for (j=0; j < BLOCKS; j++) //y direction
- {
- cnt = -1;
- for (y=0; y < BLOCK_SIZE; y++)
- for (x=0; x < BLOCK_SIZE; x++)
- {
- cnt = cnt + 1;
- index = j * MAP_SIZE * BLOCKSIZE + i * BLOCKSIZE + y * MAP_SIZE + x;
- vindex = map[modelindex]->VBO_BE[index].INDEX_START;
- Sectors[modelindex][ j*BLOCKS + i ].indices[ cnt ] = index;
- if ( (x == 0) && (y == 0) ) A = map[modelindex]->VBO_V[ vindex ];// covers first boundary vertex
- if ( (x == BLOCK_SIZE-1) && (y == 0) ) B = map[modelindex]->VBO_V[ vindex ];// covers second boundary vertex
- if ( (x == BLOCK_SIZE-1) && (y == BLOCK_SIZE-1) ) C = map[modelindex]->VBO_V[ vindex ];// covers third boundary vertex
- if ( (x == 0) && (y == BLOCK_SIZE-1) ) D = map[modelindex]->VBO_V[ vindex ];// covers last boundary vertex
- }
- }
- }
- AssignModels(TachoGLModelP * tmp, int len)
- {
- maplen = len;
- map = new TachoGLModelP[ len ];
- int i;
- for (i=0; i<len; i++) map[i] = tmp[i];
- Sectors.set_length( len );
- }
- void Draw()
- {
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement