diff --git a/Makefile.mingw b/Makefile.mingw index 38e9904..c047ee8 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -5,10 +5,11 @@ BUILD=null BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/') BUILDDIR=build-$(BUILD) SRCDIR=src -SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.cpp\ - geometry.cpp plugins.cpp pipeline.cpp\ - ps2.cpp ogl.cpp xbox.cpp\ - image.cpp gtaplg.cpp) +#SRC := $(patsubst %.cpp,$(SRCDIR)/%.cpp, rwbase.cpp clump.cpp\ +# geometry.cpp plugins.cpp pipeline.cpp\ +# ps2.cpp ogl.cpp xbox.cpp\ +# image.cpp gtaplg.cpp) +SRC := $(wildcard $(SRCDIR)/*.cpp) OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC)) DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC)) CFLAGS=-Wall -Wextra -g -DGLEW_STATIC $(BUILDDEF) -Wno-parentheses #-Wconversion diff --git a/src/gtaplg.h b/src/gtaplg.h index 4322af9..923b25d 100644 --- a/src/gtaplg.h +++ b/src/gtaplg.h @@ -64,6 +64,7 @@ struct ExtraVertColors }; extern int32 extraVertColorOffset; +void allocateExtraVertColors(Geometry *g); void registerExtraVertColorPlugin(void); // Environment mat diff --git a/src/plugins.cpp b/src/plugins.cpp index 7868d0f..9ba2649 100644 --- a/src/plugins.cpp +++ b/src/plugins.cpp @@ -203,7 +203,6 @@ static int32 getSizeHAnim(void *object, int32 offset, int32) { HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset); - // TODO: version correct? if(!hAnimDoStream || version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == NULL) return 0; @@ -593,6 +592,18 @@ readSkin(Stream *stream, int32 len, void *object, int32 offset, int32) if(oldFormat) stream->seek(4); // skip 0xdeaddead stream->read(&skin->inverseMatrices[i*16], 64); + + //{ + //float *mat = &skin->inverseMatrices[i*16]; + //printf("[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + // " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + // " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + // " [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n", + // mat[0], mat[4], mat[8], mat[12], + // mat[1], mat[5], mat[9], mat[13], + // mat[2], mat[6], mat[10], mat[14], + // mat[3], mat[7], mat[11], mat[15]); + //} } if(oldFormat){ @@ -842,7 +853,7 @@ getSizeAtomicMatFX(void *object, int32 offset, int32) { int32 flag = *PLUGINOFFSET(int32, object, offset); // TODO: not sure which version - return flag || rw::version < 0x35000 ? 4 : -1; + return flag || rw::version < 0x34000 ? 4 : 0; } // Material diff --git a/src/rwbase.cpp b/src/rwbase.cpp index ec3cd69..eb26d3a 100644 --- a/src/rwbase.cpp +++ b/src/rwbase.cpp @@ -26,13 +26,32 @@ int32 build = 0xFFFF; char *debugFile = NULL; void -matrixIdentify(float32 *mat) +matrixIdentity(float32 *mat) { memset(mat, 0, 64); mat[0] = 1.0f; mat[5] = 1.0f; mat[10] = 1.0f; - mat[16] = 1.0f; + mat[15] = 1.0f; +} + +int +matrixEqual(float32 *m1, float32 *m2) +{ + for(int i = 0; i < 16; i++) + if(m1[i] != m2[i]) + return 0; + return 1; +} + +int +matrixIsIdentity(float32 *mat) +{ + for(int32 i = 0; i < 4; i++) + for(int32 j = 0; j < 4; j++) + if(mat[i*4+j] != (i == j ? 1.0f : 0.0)) + return 0; + return 1; } void diff --git a/src/rwbase.h b/src/rwbase.h index a285174..fb33218 100644 --- a/src/rwbase.h +++ b/src/rwbase.h @@ -153,7 +153,9 @@ extern int build; extern int platform; extern char *debugFile; -void matrixIdentify(float32 *mat); +void matrixIdentity(float32 *mat); +int matrixEqual(float32 *m1, float32 *m2); +int matrixIsIdentity(float32 *mat); void matrixMult(float32 *out, float32 *a, float32 *b); void vecTrans(float32 *out, float32 *mat, float32 *vec); void matrixTranspose(float32 *out, float32 *in); diff --git a/src/rwobjects.h b/src/rwobjects.h index 70be9ee..c00de9c 100644 --- a/src/rwobjects.h +++ b/src/rwobjects.h @@ -1,3 +1,5 @@ +#include + namespace rw { struct RGBA diff --git a/tools/insttest/insttest.cpp b/tools/insttest/insttest.cpp index 28944d1..400c85c 100644 --- a/tools/insttest/insttest.cpp +++ b/tools/insttest/insttest.cpp @@ -65,6 +65,19 @@ dumpFrameHier(Frame *frame, int ind = 0) for(int i = 0; i < h->numNodes; i++){ name = h->nodeInfo[i].frame ? gta::getNodeName(h->nodeInfo[i].frame) : ""; printf("\t\t%d %d\t%p %s\n", h->nodeInfo[i].id, h->nodeInfo[i].flags, h->nodeInfo[i].frame, name); + + { + h->nodeInfo[i].frame->updateLTM(); + float *mat = h->nodeInfo[i].frame->ltm; + printf("[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" + " [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n", + mat[0], mat[4], mat[8], mat[12], + mat[1], mat[5], mat[9], mat[13], + mat[2], mat[6], mat[10], mat[14], + mat[3], mat[7], mat[11], mat[15]); + } } } for(Frame *child = frame->child; diff --git a/tools/txdwrite/txdwrite.cpp b/tools/txdwrite/txdwrite.cpp index 362de42..24443af 100644 --- a/tools/txdwrite/txdwrite.cpp +++ b/tools/txdwrite/txdwrite.cpp @@ -17,7 +17,6 @@ struct { char *str; uint32 val; } platforms[] = { - { "mobile", PLATFORM_OGL }, { "ps2", PLATFORM_PS2 }, { "xbox", PLATFORM_XBOX }, { "d3d8", PLATFORM_D3D8 }, @@ -99,7 +98,7 @@ main(int argc, char *argv[]) // rw::platform = rw::PLATFORM_XBOX; // rw::platform = rw::PLATFORM_D3D8; // rw::platform = rw::PLATFORM_D3D9; - int outplatform = rw::PLATFORM_PS2; + int outplatform = rw::PLATFORM_XBOX; char *s; ARGBEGIN{ @@ -151,6 +150,7 @@ main(int argc, char *argv[]) } // for(Texture *tex = txd->first; tex; tex = tex->next) // tex->filterAddressing = (tex->filterAddressing&~0xF) | 0x2; + rw::platform = outplatform; rw::StreamFile out; if(argc > 1)