diff options
Diffstat (limited to 'src/koopatlas/map.cpp')
-rw-r--r-- | src/koopatlas/map.cpp | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index a03d819..4d2bc1d 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -84,6 +84,10 @@ int dWMMap_c::onDraw() { renderer.scheduleForDrawing(); bgModel.scheduleForDrawing(); + + dKPMapData_c *dataCls = &dScKoopatlas_c::instance->mapData; + renderPathLayer(dataCls->pathLayer); + return true; } @@ -133,11 +137,9 @@ void dWMMap_c::renderer_c::drawLayers() { if (cont) { continue; } TileReport("Checking layer %d with type %d\n", iLayer, layer->type); if (layer->type == dKPLayer_s::OBJECTS) - renderTileLayer(layer, data->sectors); + renderTileLayer(layer, data->sectors, 255); else if (layer->type == dKPLayer_s::DOODADS) - renderDoodadLayer(layer); - else if (layer->type == dKPLayer_s::PATHS) - renderPathLayer(layer); + renderDoodadLayer(layer, 255); } endRendering(); @@ -207,7 +209,7 @@ void dWMMap_c::renderer_c::beginRendering() { GXSetTevColor(GX_TEVREG1, (GXColor){0,0,0,255}); } -void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sectors) { +void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sectors, int alpha) { //TileReport("Rendering layer %p\n", layer); // don't render it if we don't need to @@ -286,23 +288,15 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector float coordY2 = yMult * (tileY + 26.0f); - // GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); - // GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); - + GXSetTevColor(GX_TEVREG0, (GXColor){255,255,255,alpha}); + GXBegin(GX_QUADS, GX_VTXFMT0, 4); - // GXColor1u32(0xFFFFFF80); GXPosition2s16(worldX + 24, worldY - 24); GXTexCoord2f32(coordX2, coordY2); - - // GXColor1u32(0xFFFFFF80); GXPosition2s16(worldX + 24, worldY); GXTexCoord2f32(coordX2, coordY1); - - // GXColor1u32(0xFFFFFF80); GXPosition2s16(worldX, worldY); GXTexCoord2f32(coordX1, coordY1); - - // GXColor1u32(0xFFFFFF80); GXPosition2s16(worldX, worldY - 24); GXTexCoord2f32(coordX1, coordY2); GXEnd(); @@ -316,7 +310,7 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector //TileReport("Layer complete\n"); } -void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { +void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer, int alpha) { for (int i = 0; i < layer->doodadCount; i++) { dKPDoodad_s *doodad = layer->doodads[i]; DoodadReport("Doodad @ %f,%f sized %f,%f with angle %f\n", doodad->x, doodad->y, doodad->width, doodad->height, doodad->angle); @@ -330,20 +324,19 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { for (int j = 0; j < doodad->animationCount; j++) { dKPDoodad_s::animation_s *anim = &doodad->animations[j]; - // FORWARDS COMPATIBILITY: (has a ***) - // *** if (anim->delayOffset == 0) { + if (anim->delayOffset == 0) { u32 baseTick = anim->baseTick; if (baseTick == 0) { anim->baseTick = baseTick = GlobalTickCount; } u32 elapsed = GlobalTickCount - baseTick; - // *** u32 elapsedAdjusted = elapsed; + u32 elapsedAdjusted = elapsed; if (anim->isReversed) elapsed = anim->frameCount - 1 - elapsed; if (elapsed >= anim->frameCount) { - // *** if (elapsed >= (anim->frameCount + anim->delay)) { + if (elapsed >= (anim->frameCount + anim->delay)) { // we've reached the end switch (anim->loop) { @@ -365,13 +358,13 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { anim->baseTick = GlobalTickCount; break; } - // *** } - // *** elapsedAdjusted = anim->frameCount; + } + elapsedAdjusted = anim->frameCount; } // now calculate the thing - // *** float progress = elapsedAdjusted / (float)anim->frameCount; - float progress = elapsed / (float)anim->frameCount; + float progress = elapsedAdjusted / (float)anim->frameCount; + // float progress = elapsed / (float)anim->frameCount; float value; switch (anim->curve) { @@ -415,10 +408,10 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { // TODO break; } - // *** } - // *** else { - // *** anim->delayOffset -= 1; - // *** } + } + else { + anim->delayOffset -= 1; + } } } @@ -437,6 +430,7 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { loadCamera(doodadMtx); loadTexture(doodad->texObj); + GXSetTevColor(GX_TEVREG0, (GXColor){255,255,255,alpha}); GXBegin(GX_QUADS, GX_VTXFMT1, 4); GXPosition2f32(halfW, -halfH); GXTexCoord2u8(255, 255); @@ -450,17 +444,12 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { } } -void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) { +void dWMMap_c::renderPathLayer(dKPLayer_s *layer) { for (int i = 0; i < layer->nodeCount; i++) { dKPNode_s *node = layer->nodes[i]; if (node->type == dKPNode_s::LEVEL) { - // OSReport("Node Extra: %x", node->extra); - // float nx = (float)node->x; - // float ny = (float)node->y; - // OSReport("Node Extra: %x, model: %x, matrix: %x, pos: %f, %f", node->extra, node->extra->model, node->extra->matrix, nx, ny); - short rz = 0x6000; short rx = 0x4000; short ry = 0x8000; |