summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/wm_map.cpp83
-rw-r--r--src/wm_map.h6
2 files changed, 74 insertions, 15 deletions
diff --git a/src/wm_map.cpp b/src/wm_map.cpp
index a4b8a48..c84ff18 100644
--- a/src/wm_map.cpp
+++ b/src/wm_map.cpp
@@ -10,8 +10,15 @@
#include <rvl/GXPixel.h>
#include <rvl/GXTransform.h>
+void dPathTest_c::loadTex() {
+ nw4r::g3d::ResFile rf(dScNewerWorldMap_c::instance->resMng['3D00']);
+ resTex = rf.GetResTex("W2Road");
+ alpha = 255;
+}
+
+void dPathTest_c::drawOpa() { }
-void dPathTest_c::drawOpa() {
+void dPathTest_c::drawXlu() {
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
@@ -23,7 +30,8 @@ void dPathTest_c::drawOpa() {
GXSetNumChans(0);
GXSetNumTexGens(1);
- GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_NRM, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
+ //GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_NRM, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GXSetNumTevStages(0);
GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
@@ -40,7 +48,7 @@ void dPathTest_c::drawOpa() {
GXSetZCompLoc(0);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_FALSE);
- GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
+ GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, (GXColor){0,0,0,0});
GXSetFogRangeAdj(0, 0, 0);
@@ -64,25 +72,42 @@ void dPathTest_c::drawOpa() {
//camMtx[2][3] = 0.0f;
//MTXConcat(viewMatrix, camMtx, viewMatrix);
+
+ // TESTING CRAP!!
+ // Just copying what my old 3D engine had for now
+ GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
+ GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
+ GXSetZCompLoc(GX_TRUE);
+ GXSetNumTevStages(1);
+ GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0);
+ GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0);
+ GXSetNumChans(1);
+ //GXSetChanAmbColor(GX_COLOR0A0, (GXColor){128,128,128,255});
+ GXSetChanMatColor(GX_COLOR0A0, (GXColor){0,0,0,(u8)alpha});
+ GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE);
+ GXSetNumTexGens(1);
+ GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
+ GXSetTevOp(GX_TEVSTAGE0, GX_BLEND);
+
+ GXTexObj to;
+ m3d::InitTexObjWithResTex(&to, &resTex, GX_REPEAT, GX_REPEAT, GX_LINEAR, GX_LINEAR);
+ GXLoadTexObj(&to, GX_TEXMAP0);
GXLoadPosMtxImm(camMtx, GX_PNMTX0);
GXSetCurrentMtx(GX_PNMTX0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
- GXPosition3f32(-400, 0, -400);
+ GXPosition3f32(-400, 90, -400);
GXTexCoord2f32(0, 0);
- GXPosition3f32(400, 0, -400);
+ GXPosition3f32(400, 90, -400);
GXTexCoord2f32(1, 0);
- GXPosition3f32(400, 0, 400);
+ GXPosition3f32(400, 90, 400);
GXTexCoord2f32(1, 1);
- GXPosition3f32(-400, 0, 400);
+ GXPosition3f32(-400, 90, 400);
GXTexCoord2f32(0, 1);
GXEnd();
}
-void dPathTest_c::drawXlu() {
-}
-
dWMMap_c *dWMMap_c::instance = 0;
@@ -131,6 +156,7 @@ int dWMMap_c::onCreate() {
}
SpammyReport("Making path test\n");
+ pathTest.loadTex();
pathTest.setup(&allocator);
SpammyReport("Unlinking allocator\n");
@@ -151,6 +177,14 @@ int dWMMap_c::onDelete() {
int dWMMap_c::onExecute() {
+ /* TESTING */
+ int heldButtons = Remocon_GetButtons(GetActiveRemocon());
+ if (heldButtons & WPAD_UP)
+ pathTest.alpha += 8;
+ if (heldButtons & WPAD_DOWN)
+ pathTest.alpha -= 8;
+ nodes[0].updateAlpha("World2_PathsSinkytoPyramid", pathTest.alpha);
+
return true;
}
@@ -158,12 +192,12 @@ int dWMMap_c::onExecute() {
int dWMMap_c::onDraw() {
SpammyReport("dWMMap_c::onDraw() called\n");
+ //pathTest.scheduleForDrawing();
for (int i = 0; i < data->nodeCount; i++) {
SpammyReport("Drawing node %d\n", i);
nodes[i].draw();
}
- pathTest.scheduleForDrawing();
SpammyReport("dWMMap_c::onDraw() completed\n");
return true;
@@ -184,10 +218,10 @@ void WMSceneNode::loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator) {
void *brres = dScNewerWorldMap_c::instance->resMng[data->brresKey];
nw4r::g3d::ResFile resfile(brres);
- void *mdl = resfile.GetResMdl(data->modelName);
- MapReport("Obtained ResMdl: %p\n", mdl);
+ resMdl = resfile.GetResMdl(data->modelName);
+ MapReport("Obtained ResMdl: %p\n", resMdl);
- MapReport(model.setup(&mdl, allocator, 0, 1, 0) ? "Success\n" : "Fail\n");
+ MapReport(model.setup(resMdl, allocator, 0, 1, 0) ? "Success\n" : "Fail\n");
// todo: more types
SpammyReport("Setting up lightmaps\n");
@@ -204,7 +238,26 @@ void WMSceneNode::loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator) {
}
+void WMSceneNode::updateAlpha(const char *materialName, u8 alpha) {
+ // get the material
+ // too lazy to use dynamic buffers for the ResMatTevColor stuff...
+ //OSReport("trying to update %s to %d\n", materialName, alpha);
+ u8 *mat = (u8*)resMdl.GetResMat(materialName);
+ //OSReport("got mat: %p\n", mat);
+
+ s32 *matDLOffsetPtr = (s32*)(mat + 0x3C);
+ s32 matDLOffset = *matDLOffsetPtr;
+
+ u8 *matTevColorDL = mat + matDLOffset + 0x20;
+ u8 *setTevKonst4Cmd = matTevColorDL + 0x5E;
+ //OSReport("got DL offset: %d. DL is at %p. cmd is at %p.\n", matDLOffset, matTevColorDL, setTevKonst4Cmd);
+
+ setTevKonst4Cmd[2] = (setTevKonst4Cmd[2] & 0xF0) | (alpha >> 4);
+ setTevKonst4Cmd[3] = (setTevKonst4Cmd[3] & 0x0F) | (alpha & 0xF0);
+}
+
+
void WMSceneNode::draw() {
- //model.scheduleForDrawing();
+ model.scheduleForDrawing();
}
diff --git a/src/wm_map.h b/src/wm_map.h
index 9fd269c..da392bf 100644
--- a/src/wm_map.h
+++ b/src/wm_map.h
@@ -22,16 +22,22 @@ struct WMSceneDataHeader {
class WMSceneNode {
public:
WMSceneDataNode *baseData;
+ nw4r::g3d::ResMdl resMdl;
m3d::mdl_c model;
void loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator);
void draw();
+ void updateAlpha(const char *materialName, u8 alpha);
};
class dPathTest_c : public m3d::proc_c {
public:
+ void loadTex();
void drawOpa();
void drawXlu();
+
+ void *resTex;
+ u8 alpha;
};