summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-07-18 21:16:24 -0500
committerColin Noga <Tempus@chronometry.ca>2012-07-18 21:16:24 -0500
commit8f1b1aa7eb7f8700e1979b5c4d1d4e96d274119b (patch)
tree5b5b60ec7b346758d4fb6e783a1315a8c3532481 /src
parentd2f76bb1313364397135c93c37672e57b50fb0a2 (diff)
downloadkamek-8f1b1aa7eb7f8700e1979b5c4d1d4e96d274119b.tar.gz
kamek-8f1b1aa7eb7f8700e1979b5c4d1d4e96d274119b.zip
Updated doodad engine spec with delays, and a few other minor fixes
Diffstat (limited to '')
-rw-r--r--src/koopatlas/core.cpp1
-rw-r--r--src/koopatlas/map.cpp197
-rw-r--r--src/koopatlas/map.h1
-rw-r--r--src/koopatlas/mapdata.cpp20
-rw-r--r--src/koopatlas/mapdata.h10
5 files changed, 159 insertions, 70 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index eefde51..b8c9083 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -140,6 +140,7 @@ bool WMInit_LoadSIAnims(void *ptr) {
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0);
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
+ DVD_LoadFile(GetDVDClass(), "Object", "I_hammer", 0);
return true;
}
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp
index f4b953c..38610e6 100644
--- a/src/koopatlas/map.cpp
+++ b/src/koopatlas/map.cpp
@@ -117,6 +117,8 @@ void dWMMap_c::renderer_c::drawLayers() {
renderTileLayer(layer, data->sectors);
else if (layer->type == dKPLayer_s::DOODADS)
renderDoodadLayer(layer);
+ else if (layer->type == dKPLayer_s::PATHS)
+ renderPathLayer(layer);
}
endRendering();
@@ -298,82 +300,92 @@ 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];
- u32 baseTick = anim->baseTick;
- if (baseTick == 0) {
- anim->baseTick = baseTick = GlobalTickCount;
- }
+ if (anim->delayOffset == 0) {
+ u32 baseTick = anim->baseTick;
+ if (baseTick == 0) {
+ anim->baseTick = baseTick = GlobalTickCount;
+ }
- u32 elapsed = GlobalTickCount - baseTick;
- if (anim->isReversed)
- elapsed = anim->frameCount - 1 - elapsed;
+ u32 elapsed = GlobalTickCount - baseTick;
+ u32 elapsedAdjusted = elapsed;
+ if (anim->isReversed)
+ elapsed = anim->frameCount - 1 - elapsed;
+
+ if (elapsed >= anim->frameCount) {
+ if (elapsed >= (anim->frameCount + delay)) {
+
+ // we've reached the end
+ switch (anim->loop) {
+ case dKPDoodad_s::animation_s::CONTIGUOUS:
+ // Stop here
+ elapsed = anim->frameCount - 1;
+ break;
+
+ case dKPDoodad_s::animation_s::LOOP:
+ // Start over
+ elapsed = 0;
+ anim->baseTick = GlobalTickCount;
+ break;
+
+ case dKPDoodad_s::animation_s::REVERSE_LOOP:
+ // Change direction
+ anim->isReversed = !anim->isReversed;
+ elapsed = (anim->isReversed) ? (anim->frameCount - 1) : 0;
+ anim->baseTick = GlobalTickCount;
+ break;
+ }
+ }
+ elapsedAdjusted = anim->frameCount;
+ }
- if (elapsed >= anim->frameCount) {
- // we've reached the end
- switch (anim->loop) {
- case dKPDoodad_s::animation_s::CONTIGUOUS:
- // Stop here
- elapsed = anim->frameCount - 1;
- break;
+ // now calculate the thing
+ float progress = elapsedAdjusted / (float)anim->frameCount;
+ float value;
- case dKPDoodad_s::animation_s::LOOP:
- // Start over
- elapsed = 0;
- anim->baseTick = GlobalTickCount;
+ switch (anim->curve) {
+ case dKPDoodad_s::animation_s::LINEAR:
+ value = progress;
break;
-
- case dKPDoodad_s::animation_s::REVERSE_LOOP:
- // Change direction
- anim->isReversed = !anim->isReversed;
- elapsed = (anim->isReversed) ? (anim->frameCount - 1) : 0;
- anim->baseTick = GlobalTickCount;
+ case dKPDoodad_s::animation_s::SIN:
+ value = (sin(((progress * M_PI * 2)) - M_PI_2) + 1) / 2;
+ break;
+ case dKPDoodad_s::animation_s::COS:
+ value = (cos(((progress * M_PI * 2)) - M_PI_2) + 1) / 2;
break;
}
- }
- // now calculate the thing
- float progress = elapsed / (float)anim->frameCount;
- float value;
-
- switch (anim->curve) {
- case dKPDoodad_s::animation_s::LINEAR:
- value = progress;
- break;
- case dKPDoodad_s::animation_s::SIN:
- value = (sin(((progress * M_PI * 2)) - M_PI_2) + 1) / 2;
- break;
- case dKPDoodad_s::animation_s::COS:
- value = (cos(((progress * M_PI * 2)) - M_PI_2) + 1) / 2;
- break;
- }
+ float delta = anim->end - anim->start;
+ float frame;
- float delta = anim->end - anim->start;
- float frame;
-
- if (anim->isReversed)
- frame = anim->start + ceil(delta * value);
- else
- frame = anim->start + (delta * value);
-
- // and apply it!
- switch (anim->type) {
- case dKPDoodad_s::animation_s::X_POS:
- effectiveX += frame;
- break;
- case dKPDoodad_s::animation_s::Y_POS:
- effectiveY += frame;
- break;
- case dKPDoodad_s::animation_s::ANGLE:
- effectiveAngle += frame;
- break;
- case dKPDoodad_s::animation_s::X_SCALE:
- effectiveWidth = (effectiveWidth * frame / 100.0);
- break;
- case dKPDoodad_s::animation_s::Y_SCALE:
- effectiveHeight = (effectiveHeight * frame / 100.0);
- break;
- case dKPDoodad_s::animation_s::OPACITY:
- // TODO
- break;
+ if (anim->isReversed)
+ frame = anim->start + ceil(delta * value);
+ else
+ frame = anim->start + (delta * value);
+
+ // and apply it!
+ switch (anim->type) {
+ case dKPDoodad_s::animation_s::X_POS:
+ effectiveX += frame;
+ break;
+ case dKPDoodad_s::animation_s::Y_POS:
+ effectiveY += frame;
+ break;
+ case dKPDoodad_s::animation_s::ANGLE:
+ effectiveAngle += frame;
+ break;
+ case dKPDoodad_s::animation_s::X_SCALE:
+ effectiveWidth = (effectiveWidth * frame / 100.0);
+ break;
+ case dKPDoodad_s::animation_s::Y_SCALE:
+ effectiveHeight = (effectiveHeight * frame / 100.0);
+ break;
+ case dKPDoodad_s::animation_s::OPACITY:
+ // TODO
+ break;
+ }
+ }
+ else {
+ anim->delayOffset -= 1;
}
}
}
@@ -406,6 +418,55 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
}
}
+void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
+ 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
+
+ matrix.translation(node->x, node->y, 500.0); }
+ matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
+ node->model.setDrawMatrix(matrix);
+ node->model.setScale(1.0f, 1.0f, 1.0f);
+ node->model.calcWorld(false);
+
+ node->model.scheduleForDrawing();
+ }
+}
+
+
+
void dWMMap_c::renderer_c::endRendering() {
}
diff --git a/src/koopatlas/map.h b/src/koopatlas/map.h
index 72dd2d5..e951a41 100644
--- a/src/koopatlas/map.h
+++ b/src/koopatlas/map.h
@@ -44,6 +44,7 @@ class dWMMap_c : public dBase_c {
void renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sector);
void renderDoodadLayer(dKPLayer_s *layer);
+ void renderPathLayer(dKPLayer_s *layer);
void loadTexture(GXTexObj *obj);
diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp
index 6838741..4a51519 100644
--- a/src/koopatlas/mapdata.cpp
+++ b/src/koopatlas/mapdata.cpp
@@ -50,6 +50,7 @@ bool dKPMapData_c::load(const char *filename) {
bool didLoadTilesets = loadTilesets();
bool didLoadBG = (bgLoader.load("/Maps/Water.brres") != 0);
+ bool nodeLoader.load("/Maps/visCobCourse.brres");
return didLoadTilesets && didLoadBG;
}
@@ -89,6 +90,7 @@ void dKPMapData_c::unloadTilesets() {
}
bgLoader.unload();
+ nodeLoader.unload()
}
void dKPMapData_c::fixup() {
@@ -140,6 +142,24 @@ void dKPMapData_c::fixup() {
if (node->type == dKPNode_s::CHANGE)
fixRef(node->destMap);
+ else if (node->type == dKPNode_s::LEVEL) {
+
+ node->allocator.link(-1, GameHeaps[0], 0, 0x20);
+
+ nw4r::g3d::ResFile rf(nodeLoader.buffer);
+ rf.CheckRevision();
+ rf.Init();
+ rf.Bind(rf);
+
+ nw4r::g3d::ResMdl mdl = rf.GetResMdl("cobCourse");
+ nw4r::g3d::ResAnmVis anmRes = rf.GetResAnmVis("cobCourse");
+
+ node->model.setup(mdl, &node->allocator, 0x224, 1, 0);
+ node->color.setup(mdl, anmRes, &node->allocator, 0, 1);
+ node->color.bind(&node->model, anmRes, 0);
+ node->model.bindAnim(&node->color, 0.0f);
+ SetupTextures_MapObj(&node->model, 0);
+ }
}
break;
}
diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h
index ace1edd..c4d16b5 100644
--- a/src/koopatlas/mapdata.h
+++ b/src/koopatlas/mapdata.h
@@ -28,6 +28,7 @@ struct dKPDoodad_s {
int frameCount;
AnimTypes type;
int start, end;
+ int delay, delayOffset;
u32 baseTick;
bool isReversed;
@@ -66,11 +67,10 @@ struct dKPNode_s {
NodeTypes type;
union {
- struct { u8 levelNumber[2]; };
+ struct { u8 levelNumber[2]; bool hasSecret; };
struct { const char *destMap; u8 thisID, foreignID, transition, _; };
};
-
dKPPath_s *getAnyExit() {
for (int i = 0; i < 4; i++)
if (exits[i])
@@ -79,6 +79,11 @@ struct dKPNode_s {
}
dKPPath_s *getOppositeExitTo(dKPPath_s *path);
+
+ mHeapAllocator_c allocator;
+ m3d::mdl_c model;
+ m3d::anmVis_c color;
+ mMtx matrix;
};
struct dKPPath_s {
@@ -201,6 +206,7 @@ class dKPMapData_c {
dKPLayer_s *pathLayer;
dDvdLoader_c bgLoader;
+ dDvdLoader_c nodeLoader;
dKPMapData_c();
bool load(const char *filename);