Changeset 72
- Timestamp:
- 1.11.2009 12:35:25 (3 weeks ago)
- Location:
- SoTerrain
- Files:
-
- 1 removed
- 5 modified
-
include/data/SbTexture2Tile.h (modified) (1 diff)
-
include/data/SbTile.h (modified) (1 diff)
-
include/gui/Makefile.in (deleted)
-
src/data/SbTexture2Tile.cpp (modified) (5 diffs)
-
src/data/SoTexture2TileCache.cpp (modified) (1 diff)
-
src/test/SoDummyTileCacheUser.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
SoTerrain/include/data/SbTexture2Tile.h
r63 r72 65 65 /* Attributes. */ 66 66 67 /// 67 /// Offset in X direction in the underlaying texture that coresponds to X 68 /// coordinate of the tile. 68 69 int32_t offsetX; 69 70 70 /// 71 /// Offset in Y direction in the underlaying texture that coresponds to Y 72 /// coordinate of the tile. 71 73 int32_t offsetY; 72 74 73 /// 75 /// Width of a line in the underlaying texture. 74 76 int32_t lineWidth; 75 77 76 /// 78 /// Data of the underlaying texture. 77 79 const unsigned char * data; 78 80 }; -
SoTerrain/include/data/SbTile.h
r63 r72 77 77 78 78 /* Attributes. */ 79 /// 79 /// X coordinate of a left-down corner of the tile in heightmap coordinates. 80 80 int32_t x; 81 81 82 /// 82 /// Y coordinate of a left-down corner of the tile in heightmap coordinates. 83 83 int32_t y; 84 84 85 /// 85 /// Width of the tile in heightmap coordinates. 86 86 int32_t width; 87 87 88 /// 88 /// Height of the tile in heightmap coordinates. 89 89 int32_t height; 90 90 91 /// 91 /// Additional attributes that can be attached to tile. 92 92 SbTileAttributes * attibutes; 93 93 -
SoTerrain/src/data/SbTexture2Tile.cpp
r63 r72 23 23 /////////////////////////////////////////////////////////////////////////////// 24 24 25 // Standard includes. 26 #include <assert.h> 27 25 28 // OpenGL includes. 26 29 #if defined(__WIN32__) || defined(_WIN32) … … 40 43 const int32_t width, const int32_t height, const int32_t _lineWidth, const 41 44 unsigned char * _data): 42 SbTile( x + (width >> 1), y + (height >> 2), width, height),43 offsetX( x), offsetY(y), lineWidth(_lineWidth), data(_data)45 SbTile(_offsetX, _offsetY, width, height), 46 offsetX(_offsetX), offsetY(_offsetY), lineWidth(_lineWidth), data(_data) 44 47 { 45 48 // Nothing. … … 53 56 unsigned char SbTexture2Tile::get(const int32_t x, const int32_t y) const 54 57 { 58 assert(this->data); 55 59 return this->data[((y + this->offsetY) * this->lineWidth) + 56 60 (x + this->offsetX)]; … … 59 63 void SbTexture2Tile::GLRender() 60 64 { 65 assert(this->data); 66 61 67 // Render tile with quad strips. 62 for (int Y = this->y; Y < (this->y + this->height - 1); ++Y)68 for (int Y = 0; Y < this->height; ++Y) 63 69 { 64 70 glBegin(GL_QUAD_STRIP); 65 66 // First two vertices of a quad strip. 67 glVertex3f(this->x, Y + 1, data[(Y + 1 + this->offsetY) * this->lineWidth 68 + this->x + this->offsetX] * 0.1f); 69 glVertex3f(this->x, Y, data[(Y + this->offsetY) * this->lineWidth + 70 + this->x + this->offsetX] * 0.1f); 71 72 // Other pairs of vertices in line. 73 for (int X = (this->x + 1); X < (this->x + this->width); ++X) 71 for (int X = 0; X <= this->width; ++X) 74 72 { 75 glVertex3f( X, Y + 1, data[(Y + 1 + this->offsetY) * this->lineWidth + X76 + this->offsetX] * 0.1f);77 glVertex3f( X, Y, data[(Y + this->offsetY) * this->lineWidth + X78 + this->offsetX] * 0.1f);73 glVertex3f(this->x + X, this->y + Y + 1, data[(this->offsetY + Y + 1) * 74 this->lineWidth + this->offsetX + X] * 0.1f); 75 glVertex3f(this->x + X, this->y + Y, data[(this->offsetY + Y) * 76 this->lineWidth + this->offsetX + X] * 0.1f); 79 77 } 80 78 glEnd(); … … 84 82 SbBox3f SbTexture2Tile::computeBBox() 85 83 { 86 SbBox3f bounds;84 assert(this->data); 87 85 88 86 // Compute bounds by iterating over all pixels of tile. 87 SbBox3f bounds; 89 88 for (int Y = this->y; Y <= (this->y + this->height); ++Y) 90 89 { -
SoTerrain/src/data/SoTexture2TileCache.cpp
r63 r72 54 54 queued) 55 55 { 56 DEBUG_MSG(x << " " << y << " " << width << " " << height << " " << resolution);57 58 56 if (queued) 59 57 { -
SoTerrain/src/test/SoDummyTileCacheUser.cpp
r59 r72 85 85 int32_t x_step = width >> 1; 86 86 int32_t y_step = height >> 1; 87 DEBUG_MSG("frame");88 87 for (int32_t J = 0; J < 2; ++J) 89 88 { … … 97 96 y_step, x_step); 98 97 99 // Render t ile.98 // Render the tile. 100 99 if (tile) 101 100 { 102 for (int32_t tile_y = 0; tile_y < y_step; ++tile_y) 103 { 104 glBegin(GL_QUAD_STRIP); 105 for (int32_t tile_x = 0; tile_x <= x_step; ++tile_x) 106 { 107 unsigned char height = tile->get(tile_x, tile_y); 108 //glColor3ub(height, 0, 0); 109 glVertex3f(tile_offset_x + tile_x, tile_offset_y + tile_y, height * 110 0.1); 111 height = tile->get(tile_x, tile_y + 1); 112 //glColor3ub(height, 0, 0); 113 glVertex3f(tile_offset_x + tile_x, tile_offset_y + tile_y + 1, 114 height * 0.1); 115 } 116 glEnd(); 117 } 101 tile->GLRender(); 118 102 } 119 103 }
