00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(__INCLUDE_MipMapPatchIndexsh_INCLUDE__)
00022 #define __INCLUDE_MipMapPatchIndexsh_INCLUDE__
00023
00024 #include <geomipmap/MipMapPatchIndex.h>
00025 #include <common/DefinesAssert.h>
00026 #include <common/DefinesMath.h>
00027 #include <vector>
00028
00029 class GLVertexBufferObject;
00030 class MipMapPatchIndexs
00031 {
00032 protected:
00033
00034 class IndexLevel
00035 {
00036 public:
00037 IndexLevel();
00038 ~IndexLevel();
00039
00040 std::vector<MipMapPatchIndex *> borderIndexs_;
00041 };
00042
00043 public:
00044 MipMapPatchIndexs();
00045 ~MipMapPatchIndexs();
00046
00047 MipMapPatchIndex *getIndex(int lod, int leftLod, int rightLod, int topLod, int bottomLod, int addLod = 0)
00048 {
00049 lod = MIN(lod + addLod, getNoLevels() - 1);
00050 leftLod = MIN(leftLod + addLod, getNoLevels() - 1);
00051 rightLod = MIN(rightLod + addLod, getNoLevels() - 1);
00052 topLod = MIN(topLod + addLod, getNoLevels() - 1);
00053 bottomLod = MIN(bottomLod + addLod, getNoLevels() - 1);
00054
00055 unsigned int borders = 0;
00056 if (leftLod != -1 && leftLod > lod)
00057 {
00058 borders |= (leftLod - lod);
00059 }
00060 if (rightLod != -1 && rightLod > lod)
00061 {
00062 borders |= (rightLod - lod) << 3;
00063 }
00064 if (topLod != -1 && topLod > lod)
00065 {
00066 borders |= (topLod - lod) << 9;
00067 }
00068 if (bottomLod != -1 && bottomLod > lod)
00069 {
00070 borders |= (bottomLod - lod) << 6;
00071 }
00072
00073 return getIndex(lod, borders);
00074 }
00075
00076 MipMapPatchIndex *getIndex(int lod, int border)
00077 {
00078 if (lod<0) lod=0;
00079 else if (lod >= getNoLevels()) lod = getNoLevels()-1;
00080
00081 DIALOG_ASSERT(border < 4096);
00082
00083 IndexLevel *level = levels_[lod];
00084 MipMapPatchIndex *index = level->borderIndexs_[border];
00085 if (!index->getIndices()) return 0;
00086
00087 return index;
00088 }
00089 int getNoLevels() { return (int) levels_.size(); }
00090
00091 void generate(int size, int totalsize, unsigned int totallods = 99);
00092
00093 GLVertexBufferObject *getBufferObject() { return bufferObject_; }
00094
00095 protected:
00096 std::vector<IndexLevel *> levels_;
00097 GLVertexBufferObject *bufferObject_;
00098 };
00099
00100 #endif // __INCLUDE_MipMapPatchIndexsh_INCLUDE__