#86250 - dak - Mon Jun 05, 2006 10:00 pm
bah, I hate asking for help but I'm kind of stumped here. I'm aware that there are MD2 loaders availible to use, but I'm the kind of jackass that needs to create things to get a grip on whats going on. With the assistance of some OGL literature, I created what seemed to be a pretty straight forward loader while making appropriate changes to fit the handheld. I used the console to output the general numTri info etc. to make sure things aren't going nuts (everything seems to be in order), but the only thing weird is that the model when displayed on screen looks like a jagged cube.
This is my first time working with Nintendo handheld tech as well as with loading a model (tho I do have a good amount of OGL experience). First thing I tried was playing around with casting things between floats, f32, and v16 (particularly when setting the point lists). Then I made my draw function render only 5 polygons. It seems that the polys rendered are just staying in one place, bunching up like pantyhose. Now I love nothing more than bunched up pantyhose, but this is driving me insane.
Well, heres the code; I'll be refreshing like a madman all day to see if anyone can help me out. btw, perhaps this has something to do with it: I am awaiting my flash/pass equiptment to come in and am debugging on the latest version of Dualis.
:D thanks in advanced to those who help and at the least stop by...
-dak[/i]
This is my first time working with Nintendo handheld tech as well as with loading a model (tho I do have a good amount of OGL experience). First thing I tried was playing around with casting things between floats, f32, and v16 (particularly when setting the point lists). Then I made my draw function render only 5 polygons. It seems that the polys rendered are just staying in one place, bunching up like pantyhose. Now I love nothing more than bunched up pantyhose, but this is driving me insane.
Well, heres the code; I'll be refreshing like a madman all day to see if anyone can help me out. btw, perhaps this has something to do with it: I am awaiting my flash/pass equiptment to come in and am debugging on the latest version of Dualis.
:D thanks in advanced to those who help and at the least stop by...
Code: |
// Map Game Cartridge memory to ARM9 WAIT_CR &= ~0x80; GBFS_FILE const * filePtr; //FILE *filePtr; unsigned int fileLen = 0; uint8* buffer; modelData_t *model; modelHeader_t *modHeader; texture_t *md2Tex; stIdx_t *stPtr; frame_t *frm; vector_t *pointListPtr; mesh_t *triIndex, *bufIndexPtr; int i, j; //Open the model file filePtr = find_first_gbfs_file((void*)0x08000000); buffer = (uint8*)gbfs_get_obj(filePtr, filename, &fileLen); //Extract model file header modHeader = (modelHeader_t*)buffer; //Allocate memory for model data model = (modelData_t*)malloc(sizeof(modelData_t)); //Allocate memory for all vertices used in model, inc animations model->pointList = (vector_t*)malloc(sizeof(vector_t)*modHeader->numXYZ*modHeader->numFrames); //Store "vital" model data model->numPoints = modHeader->numXYZ; model->numFrames = modHeader->numFrames; model->frameSize = modHeader->frameSize; //loop thru number of frames in model file for (j=0; j<modHeader->numFrames; j++) { //offset to the points in this frame frm = (frame_t*)&buffer[modHeader->offsetFrames + modHeader->frameSize * j]; //calculate the point positions based on frame details pointListPtr = (vector_t*)&model->pointList[modHeader->numXYZ * j]; for (i=0; i<modHeader->numXYZ; i++) { pointListPtr[i].point[0] = floattov16(frm->scale[0] * frm->fp[i].v[0] + frm->translate[0]); pointListPtr[i].point[1] = floattov16(frm->scale[1] * frm->fp[i].v[1] + frm->translate[1]); pointListPtr[i].point[2] = floattov16(frm->scale[2] * frm->fp[i].v[2] + frm->translate[2]); // pointListPtr[i].point[0] = floattov16((mulf32(floattof32(frm->scale[0]), inttof32(frm->fp[i].v[0])) + floattof32(frm->translate[0]))>>3); // pointListPtr[i].point[1] = floattov16((mulf32(inttof32(-1),(mulf32(floattof32(frm->scale[1]), inttof32(frm->fp[i].v[1])) + floattof32(frm->translate[1]))))>>3); // pointListPtr[i].point[2] = floattov16((mulf32(floattof32(frm->scale[2]), inttof32(frm->fp[i].v[2])) + floattof32(frm->translate[2]))>>3); } } //load the model texture //md2Tex = // --------------------- //Allocate the list of tri indices triIndex = (mesh_t*)malloc(sizeof(mesh_t) * modHeader->numTris); //Set total number of tri model->numTri = modHeader->numTris; model->triIdx = triIndex; //point to tri indices in buffer bufIndexPtr = (mesh_t*)&buffer[modHeader->offsetTris]; //for all tri in each frame for (i=0; i<modHeader->numTris; i++) { // [opt] memcopy //Store mesh and texture indices triIndex[i].meshIdx[0] = bufIndexPtr[i].meshIdx[0]; triIndex[i].meshIdx[1] = bufIndexPtr[i].meshIdx[1]; triIndex[i].meshIdx[2] = bufIndexPtr[i].meshIdx[2]; //Then TEX shit //Then TEX shit //Then TEX shit } //initialize animation variables model->curFrame = 0; model->nextFrame = 1; model->interpol = 0.0; return model; |
-dak[/i]