summaryrefslogtreecommitdiff
path: root/src/koopatlas/map.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-07-22 17:19:41 -0500
committerColin Noga <Tempus@chronometry.ca>2012-07-22 17:19:41 -0500
commit53116b7ae344edd0ed421a466fd6ae732c2d82d8 (patch)
treef582b24e4fa8a38f3c3a03f08f1068fbd6251556 /src/koopatlas/map.cpp
parenta37e9d8030a5274072cc085db74e463eb4be0a73 (diff)
downloadkamek-53116b7ae344edd0ed421a466fd6ae732c2d82d8.tar.gz
kamek-53116b7ae344edd0ed421a466fd6ae732c2d82d8.zip
Lots of world map path rendering and movement implementations and fixes.
Diffstat (limited to 'src/koopatlas/map.cpp')
-rw-r--r--src/koopatlas/map.cpp100
1 files changed, 83 insertions, 17 deletions
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp
index 9a04e65..46838d9 100644
--- a/src/koopatlas/map.cpp
+++ b/src/koopatlas/map.cpp
@@ -45,9 +45,8 @@ int dWMMap_c::onCreate() {
renderer.allocator.setup(GameHeaps[0], 0x20);
bool result = renderer.setup(&renderer.allocator);
- bgMatrix.translation(1140.0f, -2910.0f, -500.0f);
- s16 rot = 0x4000;
- bgMatrix.applyRotationX(&rot);
+ bgMatrix.identity();
+ bgMatrix.translation(0.0f, 0.0f, -500.0f);
allocator.link(-1, GameHeaps[0], 0, 0x20);
nw4r::g3d::ResFile rf(dScKoopatlas_c::instance->mapData.bgLoader.buffer);
@@ -64,6 +63,25 @@ int dWMMap_c::onCreate() {
bgSrtAnm.bindEntry(&bgModel, anmRes, 0, 0);
bgModel.bindAnim(&bgSrtAnm, 0.0f);
+
+ nw4r::g3d::ResFile rg(getResource("cobCourse", "g3d/model.brres"));
+ renderer.nodeModel.setup(rg.GetResMdl("cobCourse"), &allocator, 0x224, 1, 0);
+
+ // nw4r::g3d::ResFile rg(dScKoopatlas_c::instance->mapData.nodeLoader.buffer);
+ // rg.CheckRevision();
+ // rg.Init();
+ // rg.Bind(rg);
+
+ // nw4r::g3d::ResMdl mdl = rg.GetResMdl("cobCourse");
+ // nw4r::g3d::ResAnmVis anmResVis = rg.GetResAnmVis("cobCourse");
+
+ // renderer.nodeModel.setup(mdl, &allocator, 0x224, 1, 0);
+ renderer.nodeMatrix.identity();
+ // renderer.nodeColor.setup(mdl, anmResVis, &allocator, 0);
+ // renderer.nodeColor.bind(&renderer.nodeModel, anmResVis, 0);
+ // renderer.nodeModel.bindAnim(&renderer.nodeColor, 0.0f);
+ SetupTextures_MapObj(&renderer.nodeModel, 0);
+
allocator.unlink();
return true;
@@ -81,6 +99,18 @@ int dWMMap_c::onExecute() {
}
int dWMMap_c::onDraw() {
+
+ short rz = 0x6000;
+ short rx = 0x4000;
+ short ry = 0x8000;
+ renderer.nodeMatrix.translation(384.0, -504.0 + 4.0, 498.0);
+ renderer.nodeMatrix.applyRotationYXZ(&ry, &rx, &rz);
+ renderer.nodeModel.setDrawMatrix(renderer.nodeMatrix);
+ renderer.nodeModel.setScale(0.8f, 0.8f, 0.8f);
+ renderer.nodeModel.calcWorld(false);
+
+ renderer.nodeModel.scheduleForDrawing();
+
renderer.scheduleForDrawing();
bgModel.scheduleForDrawing();
@@ -108,17 +138,36 @@ void dWMMap_c::renderer_c::drawLayers() {
beginRendering();
+ bool cont = false;
for (int iLayer = data->layerCount - 1; iLayer >= 0; iLayer--) {
dKPLayer_s *layer = data->layers[iLayer];
renderMtx[2][3] += 2.0f;
+ cont = false;
+ for (int iNodes = dataCls->pathLayer->nodeCount - 1; iNodes >= 0; iNodes--) {
+ dKPNode_s *node = dataCls->pathLayer->nodes[iNodes];
+ bool unlock = node->isUnlocked();
+ if (!unlock) {
+ if (node->tileLayer == layer) { cont = true; break; }
+ if (node->doodadLayer == layer) { cont = true; break; }
+ }
+ }
+ for (int iPaths = dataCls->pathLayer->pathCount - 1; iPaths >= 0; iPaths--) {
+ dKPPath_s *path = dataCls->pathLayer->paths[iPaths];
+ if (!path->isAvailable) {
+ if (path->tileLayer == layer) { cont = true; break; }
+ if (path->doodadLayer == layer) { cont = true; break; }
+ }
+ }
+
+ if (cont) { continue; }
TileReport("Checking layer %d with type %d\n", iLayer, layer->type);
- if (layer->type == dKPLayer_s::OBJECTS)
+ if (layer->type == dKPLayer_s::OBJECTS)
renderTileLayer(layer, data->sectors);
else if (layer->type == dKPLayer_s::DOODADS)
renderDoodadLayer(layer);
- else if (layer->type == dKPLayer_s::PATHS)
- renderPathLayer(layer);
+ else if (layer->type == dKPLayer_s::PATHS)
+ renderPathLayer(layer);
}
endRendering();
@@ -266,13 +315,24 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector
float coordY1 = yMult * (tileY + 2.0f);
float coordY2 = yMult * (tileY + 26.0f);
+
+ // GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
+ // GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0);
+
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();
@@ -421,10 +481,10 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
}
void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
- return;
+ // return;
- // for (int i = 0; i < layer->nodeCount; i++) {
- // dKPNode_s *node = layer->nodes[i];
+ for (int i = 0; i < layer->nodeCount; i++) {
+ dKPNode_s *node = layer->nodes[i];
// int world = node->levelNumber[0];
// int level = node->levelNumber[1];
@@ -459,16 +519,22 @@ void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
// else
// node->color.setCurrentFrame(3); // Red
- // node->matrix.translation(node->x, node->y, 500.0);
- // node->matrix.applyRotationYXZ(0, 0, 0);
- // node->model.setDrawMatrix(node->matrix);
- // node->model.setScale(1.0f, 1.0f, 1.0f);
- // node->model.calcWorld(false);
+ if (node->type == dKPNode_s::LEVEL) {
+ float nx = (float)node->x;
+ float ny = (float)node->y;
- // node->model.scheduleForDrawing();
- // }
-}
+ // OSReport("Rendering the node @ %f, %f", nx, ny);
+
+ // nodeMatrix.translation(node->x, node->y, 498.0);
+ // nodeMatrix.applyRotationYXZ(0, 0, 0);
+ // nodeModel.setDrawMatrix(nodeMatrix);
+ // nodeModel.setScale(1.0f, 1.0f, 1.0f);
+ // nodeModel.calcWorld(false);
+ // nodeModel.scheduleForDrawing();
+ }
+ }
+}
void dWMMap_c::renderer_c::endRendering() {