diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-07-22 21:26:01 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-07-22 21:26:01 -0500 |
commit | 248e7915227efa19a443f22aa6f80fe52a5a3b3a (patch) | |
tree | 7dcfa8829f4ce8277fb606022b0ad8bbee2c0741 | |
parent | 873b0352478f0bf27ee3123e46d3bae5cb2720fb (diff) | |
download | kamek-248e7915227efa19a443f22aa6f80fe52a5a3b3a.tar.gz kamek-248e7915227efa19a443f22aa6f80fe52a5a3b3a.zip |
Added node model rendering junk - non working.
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/core.cpp | 2 | ||||
-rw-r--r-- | src/koopatlas/map.cpp | 96 | ||||
-rw-r--r-- | src/koopatlas/map.h | 4 | ||||
-rw-r--r-- | src/koopatlas/mapdata.cpp | 70 | ||||
-rw-r--r-- | src/koopatlas/mapdata.h | 7 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 4 |
6 files changed, 88 insertions, 95 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 5f06d61..6b1f290 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -141,7 +141,7 @@ bool WMInit_LoadSIAnims(void *ptr) { DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0); DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0); DVD_LoadFile(GetDVDClass(), "Object", "I_hammer", 0); - DVD_LoadFile(GetDVDClass(), "WorldMap", "cobCourse", 0); + DVD_LoadFile(GetDVDClass(), "Object", "cobCourse", 0); return true; } diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index f9403ba..a03d819 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -63,25 +63,6 @@ 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; @@ -100,21 +81,6 @@ int dWMMap_c::onExecute() { int dWMMap_c::onDraw() { - short rz = 0x6000; - short rx = 0x4000; - short ry = 0x8000; - - // Node rotation (0x6000, 0x4000, 0x8000) - // Node Position (node->x, -node->y + 4.0, 498.0) - // Node Scale (0.8) - 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(); @@ -485,57 +451,27 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { } void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) { - // return; for (int i = 0; i < layer->nodeCount; i++) { dKPNode_s *node = layer->nodes[i]; - // int world = node->levelNumber[0]; - // int level = node->levelNumber[1]; - - // SaveBlock *save = GetSaveFile()->GetBlock(-1); - // u32 conds = save->GetLevelCondition(world-1, level-1); - - // bool isUnlocked = true; - // bool exitComplete = false; - // bool secretComplete = false; - - // if (conds & 0x10) - // exitComplete = true; - // if (conds & 0x20) - // secretComplete = true; - - // // Is it unlocked? - // if (!isUnlocked) - // node->color.setCurrentFrame(0); // Black - - // // Is it complete? - // else if ((exitComplete) || (secretComplete)) - // // Does it have two exits? - // if ((node->hasSecret) && ((!exitComplete) || (!secretComplete))) - // node->color.setCurrentFrame(2); // Yellow - - // // All exits are complete - // else - // node->color.setCurrentFrame(1); // Blue - - // // Not complete after all - // else - // node->color.setCurrentFrame(3); // Red - if (node->type == dKPNode_s::LEVEL) { - float nx = (float)node->x; - float ny = (float)node->y; - - // 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(); + // 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; + + node->extra->matrix.translation(node->x, -node->y + 4.0, 498.0); + node->extra->matrix.applyRotationYXZ(&ry, &rx, &rz); + node->extra->model.setDrawMatrix(node->extra->matrix); + node->extra->model.setScale(0.8f, 0.8f, 0.8f); + node->extra->model.calcWorld(false); + + node->extra->model.scheduleForDrawing(); } } } diff --git a/src/koopatlas/map.h b/src/koopatlas/map.h index 9616f5c..e951a41 100644 --- a/src/koopatlas/map.h +++ b/src/koopatlas/map.h @@ -36,10 +36,6 @@ class dWMMap_c : public dBase_c { void drawOpa(); void drawXlu(); - m3d::mdl_c nodeModel; - m3d::anmVis_c nodeColor; - mMtx nodeMatrix; - private: void drawLayers(); diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp index 7fd2d17..f65d038 100644 --- a/src/koopatlas/mapdata.cpp +++ b/src/koopatlas/mapdata.cpp @@ -21,6 +21,71 @@ bool dKPNode_s::isUnlocked() { return false; } +void dKPNode_s::setupNodeExtra() { + int world = this->levelNumber[0]; + int level = this->levelNumber[1]; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + u32 conds = save->GetLevelCondition(world-1, level-1); + + bool isUnlocked = this->isUnlocked(); + bool exitComplete = false; + bool secretComplete = false; + + if (conds & 0x10) + exitComplete = true; + if (conds & 0x20) + secretComplete = true; + + const char *colour; + + // Is it unlocked? + if (!isUnlocked) + colour = "g3d/black.brres"; + + // Is it a one time level? + else if ((level >= 30) && (level <= 37)) { + // Is it complete? + if (exitComplete) + colour = "g3d/yellow.brres"; + + // It's still available + else + colour = "g3d/green.brres"; + } + + // Is it a shop? + else if (level == 41) + const char *colour = "g3d/shop.brres"; + + // Is it complete? + else if ((exitComplete) || (secretComplete)) { + // Does it have two exits? + if ((this->hasSecret) && (!exitComplete) && (!secretComplete)) + colour = "g3d/blue.brres"; + + // Does it have one exit? + else if ((!this->hasSecret) && (exitComplete)) + colour = "g3d/blue.brres"; + + // All exits are complete + else + colour = "g3d/purple.brres"; + } + // Not complete after all + else + colour = "g3d/red.brres"; + + // model time + this->extra->mallocator.link(-1, GameHeaps[0], 0, 0x20); + + nw4r::g3d::ResFile rg(getResource("cobCourse", colour)); + this->extra->model.setup(rg.GetResMdl("cobCourse"), &this->extra->mallocator, 0x224, 1, 0); + this->extra->matrix.identity(); + SetupTextures_MapObj(&this->extra->model, 0); + + this->extra->mallocator.unlink(); +} int dKPLayer_s::findNodeID(dKPNode_s *node) { for (int i = 0; i < nodeCount; i++) @@ -58,9 +123,8 @@ bool dKPMapData_c::load(const char *filename) { bool didLoadTilesets = loadTilesets(); bool didLoadBG = (bgLoader.load("/Maps/Water.brres") != 0); - bool didLoadNode = nodeLoader.load("/Maps/visCobCourse.brres"); - return didLoadTilesets && didLoadBG && didLoadNode; + return didLoadTilesets && didLoadBG; } bool dKPMapData_c::loadTilesets() { @@ -98,7 +162,6 @@ void dKPMapData_c::unloadTilesets() { } bgLoader.unload(); - nodeLoader.unload(); } void dKPMapData_c::fixup() { @@ -173,6 +236,7 @@ void dKPMapData_c::fixup() { for (int nodeIdx = 0; nodeIdx < pathLayer->nodeCount; nodeIdx++) { if (pathLayer->nodes[nodeIdx]->type == dKPNode_s::LEVEL) { pathLayer->nodes[nodeIdx]->extra = &levelNodeExtraArray[extraIdx]; + pathLayer->nodes[nodeIdx]->setupNodeExtra(); extraIdx++; } } diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h index 6739086..f3739a0 100644 --- a/src/koopatlas/mapdata.h +++ b/src/koopatlas/mapdata.h @@ -76,9 +76,9 @@ struct dKPNode_s { // The union is placed at the very end so we can leave out padding in the // kpbin union { - struct { u8 levelNumber[2]; }; + // struct { u8 levelNumber[2]; }; // FORWARDS COMPATIBILITY: - // struct { u8 levelNumber[2]; bool hasSecret; }; + struct { u8 levelNumber[2]; bool hasSecret; }; struct { const char *destMap; u8 thisID, foreignID, transition, _; }; }; @@ -90,6 +90,7 @@ struct dKPNode_s { } bool isUnlocked(); + void setupNodeExtra(); dKPPath_s *getOppositeExitTo(dKPPath_s *path); }; @@ -213,7 +214,6 @@ class dKPMapData_c { dKPLayer_s *pathLayer; dDvdLoader_c bgLoader; - dDvdLoader_c nodeLoader; dKPNodeExtra_c *levelNodeExtraArray; @@ -226,6 +226,7 @@ class dKPMapData_c { // Currently only available for LEVEL nodes class dKPNodeExtra_c { public: + mHeapAllocator_c mallocator; mMtx matrix; m3d::mdl_c model; }; diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index cfdf2b7..7457f99 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -46,7 +46,6 @@ void dWMPathManager_c::setup() { } if (!found) { - OSReport("Couldn't find target node %d!\n", changeID); currentNode = pathLayer->nodes[0]; mustComplainToMapCreator = true; } @@ -67,7 +66,6 @@ void dWMPathManager_c::setup() { for (int i = 0; i < pathLayer->pathCount; i++) { dKPPath_s *path = pathLayer->paths[i]; - OSReport("Path unlocked by %d-%d, unlock type %d, is available %d", path->unlockLevelNumber[0], path->unlockLevelNumber[1], path->unlockType, path->isAvailable); if (path->unlockType > 0) { u32 conds = save->GetLevelCondition(path->unlockLevelNumber[0] - 1, path->unlockLevelNumber[1] - 1); @@ -297,8 +295,6 @@ void dWMPathManager_c::moveThroughPath() { else { a = timer; } player->jumpOffset = -sin(a * 3.14 / len) * top; - OSReport("%f = sin(%f * 3.14 / %f) * %f", player->jumpOffset, a, len, top); - timer -= move.y; } |