Changeset 820
- Timestamp:
- Nov 26, 2007, 11:34:00 AM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/HeightMap.cpp
r780 r820 8 8 #include <memory.h> 9 9 #include <R2/R2FilePath.h> 10 #include "RpField1D.h" 11 #include <sys/time.h> 12 #include <sys/types.h> 13 #include <unistd.h> 14 #include <fcntl.h> 10 15 11 16 HeightMap::HeightMap() … … 104 109 } 105 110 106 void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount )111 void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights) 107 112 { 108 113 indexCount = (xCount - 1) * (zCount - 1) * 6; … … 114 119 int boundaryHeight = zCount - 1; 115 120 int* ptr = indexBuffer; 116 for (i = 0; i < boundaryHeight; ++i) 121 int index1, index2, index3, index4; 122 bool index1Valid, index2Valid, index3Valid, index4Valid; 123 index1Valid = index2Valid = index3Valid = index4Valid = true; 124 125 if (heights) 117 126 { 118 for (j = 0; j < boundaryWidth; ++j) 127 int ic = 0; 128 for (i = 0; i < boundaryHeight; ++i) 119 129 { 120 *ptr = i * xCount + j; ++ptr; 121 *ptr = (i + 1) * xCount + j; ++ptr; 122 *ptr = (i + 1) * xCount + j + 1; ++ptr; 123 124 *ptr = i * xCount + j; ++ptr; 125 *ptr = (i + 1) * xCount + j + 1; ++ptr; 126 *ptr = i * xCount + j + 1; ++ptr; 130 for (j = 0; j < boundaryWidth; ++j) 131 { 132 index1 = i * xCount +j; 133 if (isnan(heights[index1])) index1Valid = false; 134 index2 = (i + 1) * xCount + j; 135 if (isnan(heights[index2])) index2Valid = false; 136 index3 = (i + 1) * xCount + j + 1; 137 if (isnan(heights[index3])) index3Valid = false; 138 index4 = i * xCount + j + 1; 139 if (isnan(heights[index4])) index4Valid = false; 140 141 142 143 if (index1Valid && index2Valid && index3Valid) 144 { 145 *ptr = index1; ++ptr; 146 *ptr = index2; ++ptr; 147 *ptr = index3; ++ptr; 148 ++ic; 149 } 150 if (index1Valid && index3Valid && index4Valid) 151 { 152 *ptr = index1; ++ptr; 153 *ptr = index3; ++ptr; 154 *ptr = index4; ++ptr; 155 ++ic; 156 } 157 } 127 158 } 128 159 } 160 else 161 { 162 for (i = 0; i < boundaryHeight; ++i) 163 { 164 for (j = 0; j < boundaryWidth; ++j) 165 { 166 *ptr = i * xCount + j; ++ptr; 167 *ptr = (i + 1) * xCount + j; ++ptr; 168 *ptr = (i + 1) * xCount + j + 1; ++ptr; 169 170 *ptr = i * xCount + j; ++ptr; 171 *ptr = (i + 1) * xCount + j + 1; ++ptr; 172 *ptr = i * xCount + j + 1; ++ptr; 173 } 174 } 175 } 176 129 177 } 130 178 … … 195 243 } 196 244 197 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount );245 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount, 0); 198 246 //} 199 247 //else … … 258 306 } 259 307 260 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount );308 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount, heights); 261 309 //} 262 310 //else -
trunk/vizservers/nanovis/HeightMap.h
r780 r820 9 9 #include "Vector3.h" 10 10 11 /** 12 *@class HeightMap 13 *@brief Create a surface from height map and line contour of the generated surface 14 */ 11 15 class HeightMap { 12 16 unsigned int _vertexBufferObjectID; … … 28 32 29 33 public : 34 /** 35 *@brief Constructor 36 */ 30 37 HeightMap(); 38 /** 39 *@brief Destructor 40 */ 31 41 ~HeightMap(); 32 42 33 43 private : 34 void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount );44 void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights); 35 45 Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height); 36 46 void reset(); 37 47 public : 38 48 void render(); 49 /** 50 *@brief Create a height map with heigh values 51 *@param startX a x position of the first height value 52 *@param startY a y position of the first height value 53 *@param endX a x position of the last height value 54 *@param endY a y position of the last height value 55 *@param xCount the number of columns of height values 56 *@param yCount the number of rows of height values 57 *@param height a pointer value adrressing xCount * yCount values of heights 58 */ 39 59 void setHeight(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height); 60 61 /** 62 *@brief Create a height map with a set of points 63 *@param xCount the number of columns of height values 64 *@param yCount the number of rows of height values 65 */ 40 66 void setHeight(int xCount, int yCount, Vector3* heights); 67 68 /** 69 *@brief Define a color map for color shading of heighmap 70 */ 41 71 void setColorMap(TransferFunction* colorMap); 42 72 73 /** 74 *@brief Set the visibility of the height map 75 */ 43 76 void setVisible(bool visible); 77 78 /** 79 *@brief Return the status of the visibility 80 */ 44 81 bool isVisible() const; 82 83 /** 84 *@brief Set the visibility of the line contour 85 */ 45 86 void setLineContourVisible(bool visible); 87 88 /** 89 *@brief Defind the color of the line contour 90 */ 46 91 void setLineContourColor(float r, float g, float b); 47 92 };
Note: See TracChangeset
for help on using the changeset viewer.