Changeset 593
- Timestamp:
- 06/01/08 13:15:39 (7 months ago)
- Files:
-
- trunk/run/defend.cfg (modified) (1 diff)
- trunk/src/defend/game/Game.d (modified) (1 diff)
- trunk/src/defend/terrain/Generator.d (modified) (1 diff)
- trunk/src/engine/model/ModelMD2.d (modified) (5 diffs)
- trunk/src/engine/rend/VertexArray.d (modified) (1 diff)
- trunk/src/engine/rend/opengl/VertexArray.d (modified) (1 diff)
- trunk/src/engine/rend/opengl/VertexBuffer.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/run/defend.cfg
r592 r593 41 41 42 42 // use a shader for rendering the terrain? 43 terrain_use_shaders = 043 terrain_use_shaders = 1 trunk/src/defend/game/Game.d
r592 r593 274 274 275 275 // Fog of war 276 fogOfWar = new FogOfWar(gameObjects, terrain.lightmapTexture, vec2i.from(terrain.dimension), false);276 fogOfWar = new FogOfWar(gameObjects, terrain.lightmapTexture, vec2i.from(terrain.dimension), true); 277 277 278 278 // Create the HUD trunk/src/defend/terrain/Generator.d
r583 r593 70 70 { 71 71 localCreate(cast(player_id_t)0, "house", 30, 30); 72 //localCreate(cast(player_id_t)0, "sheep", 32, 29);72 localCreate(cast(player_id_t)0, "sheep", 32, 29); 73 73 74 74 if(players.isPlayer(cast(player_id_t)1)) trunk/src/engine/model/ModelMD2.d
r583 r593 66 66 ubyte[16] name; 67 67 MD2Vertex[] vertices; 68 69 BoundingBox!(float) boundingBox; 70 vec3[] positions; 68 71 } 69 72 } … … 107 110 class MD2ModelInstance : ModelInstance 108 111 { 109 MD2Mesh mesh;110 111 112 AnimationType type; 112 113 uint currentFrame; … … 170 171 auto nextFrame = &frames[state.nextFrame]; 171 172 172 int k = 0; 173 174 Vertex vertex; 175 vec3 currPos, nextPos; 176 int index; 177 vec3ub pos; 178 179 for(uint i = 0; i < header.numTriangles; i++) 173 auto target = vertices.getVertexT!(Mesh.Vertex)(0); 174 auto currPos = currFrame.positions.ptr; 175 auto nextPos = nextFrame.positions.ptr; 176 177 for(uint i = 0; i < header.numTriangles * 3; i++) 180 178 { 181 for(uint j = 0; j < 3; j++) 182 { 183 statistics.vertices_skinned++; 184 185 vertex.texture = texCoords[triangles[i].texCoords[j]]; 186 187 index = triangles[i].indices[j]; 188 pos = currFrame.vertices[index].pos; 189 190 currPos.x = currFrame.scale.x * pos.x + currFrame.translate.x; 191 currPos.y = currFrame.scale.y * pos.y + currFrame.translate.y; 192 currPos.z = currFrame.scale.z * pos.z + currFrame.translate.z; 193 194 pos = nextFrame.vertices[index].pos; 195 196 nextPos.x = nextFrame.scale.x * pos.x + nextFrame.translate.x; 197 nextPos.y = nextFrame.scale.y * pos.y + nextFrame.translate.y; 198 nextPos.z = nextFrame.scale.z * pos.z + nextFrame.translate.z; 199 200 vertex.position.x = currPos.x + state.interp * (nextPos.x - currPos.x); 201 vertex.position.y = currPos.y + state.interp * (nextPos.y - currPos.y); 202 vertex.position.z = currPos.z + state.interp * (nextPos.z - currPos.z); 203 204 bbox.max.x = .max(bbox.max.x, vertex.position.x); 205 bbox.max.y = .max(bbox.max.y, vertex.position.y); 206 bbox.max.z = .max(bbox.max.z, vertex.position.z); 207 208 bbox.min.x = .min(bbox.min.x, vertex.position.x); 209 bbox.min.y = .min(bbox.min.y, vertex.position.y); 210 bbox.min.z = .min(bbox.min.z, vertex.position.z); 211 212 vertices.setVertex(k++, vertex); 213 } 179 target.position.x = currPos.x + state.interp * (nextPos.x - currPos.x); 180 target.position.y = currPos.y + state.interp * (nextPos.y - currPos.y); 181 target.position.z = currPos.z + state.interp * (nextPos.z - currPos.z); 182 183 ++target; 184 ++currPos; 185 ++nextPos; 214 186 } 215 187 188 vertices.dirty(); 216 189 vertices.synchronize(); 217 190 super.render(); 218 191 219 state.boundingBox = bbox;192 state.boundingBox = currFrame.boundingBox; 220 193 } 221 194 } … … 301 274 file.read(frame.name[]); 302 275 file.read((cast(ubyte*)frame.vertices)[0 .. MD2Vertex.sizeof * frame.vertices.length]); 276 277 frame.positions = new vec3[header.numTriangles * 3]; 278 279 for(uint i = 0; i < header.numTriangles; i++) 280 { 281 for(uint j = 0; j < 3; j++) 282 { 283 frame.positions[i * 3 + j] = 284 frame.scale * frame.vertices[triangles[i].indices[j]].pos + frame.translate; 285 286 frame.boundingBox.addPoint(frame.positions[i * 3 + j]); 287 } 288 } 303 289 } 304 290 … … 316 302 mesh.texCoords = new vec2[texCoords.length]; 317 303 318 for(uint i = 0; i < header.numTriangles; i++) 319 { 320 for(uint j = 0; j < 3; j++) 304 { 305 auto vertex = mesh.vertices.getVertexT!(Mesh.Vertex)(0); 306 307 for(uint i = 0; i < header.numTriangles; i++) 321 308 { 322 mesh.texCoords[triangles[i].texCoords[j]].x = 323 cast(float)texCoords[triangles[i].texCoords[j]].s / header.skinWidth; 324 325 mesh.texCoords[triangles[i].texCoords[j]].y = 326 cast(float)texCoords[triangles[i].texCoords[j]].t / header.skinHeight; 309 for(uint j = 0; j < 3; j++) 310 { 311 vertex.texture.x = cast(float)texCoords[triangles[i].texCoords[j]].s / 312 header.skinWidth; 313 314 vertex.texture.y = cast(float)texCoords[triangles[i].texCoords[j]].t / 315 header.skinHeight; 316 317 vertex++; 318 } 327 319 } 328 320 } 329 321 322 mesh.vertices.dirty(); 323 mesh.vertices.synchronize(); 324 330 325 _meshes ~= mesh; 331 326 } trunk/src/engine/rend/VertexArray.d
r583 r593 56 56 57 57 /** 58 * Mark an area as dirty 59 */ 60 abstract void dirty(int begin = 0, int end = -1); 61 62 /** 58 63 * Synchronize local vertex data with graphic card 59 64 */ trunk/src/engine/rend/opengl/VertexArray.d
r583 r593 64 64 } 65 65 66 override void dirty(int begin = 0, int end = -1) 67 { 68 69 } 70 66 71 override void synchronize() 67 72 { trunk/src/engine/rend/opengl/VertexBuffer.d
r583 r593 70 70 } 71 71 72 override void dirty(int begin = 0, int end = -1) 73 { 74 firstSet = begin * size; 75 lastSet = (end == -1 ? count : end) * size; 76 } 77 72 78 override void synchronize() 73 79 {
