/************************************************************ * * * simple 3D object viewer * * Join some things together * * * ***********************************************************/ #include #include "herodata.h" //tmd addresses in herodata.h used dataman #define SCREEN_WIDTH 360 #define SCREEN_HEIGHT 256 #define PACKETMAX2 (4096*60) /* Max GPU packets */ static PACKET packetArea[2][PACKETMAX2]; /* GPU PACKETS AREA */ #define UNIT 1 #define TRUE 1 #define FALSE 0 #define OT_LENGTH 14 static GsOT Wot[2]; /* Handler of OT */ static GsOT_TAG wtags[2][1<coord.t[0] = people[pernum].theobjects[objnum].position.vx; people[pernum].theobjects[objnum].handler.coord2->coord.t[1] =(people[pernum].theobjects[objnum].position.vy);// + theobjects[objnum].height); people[pernum].theobjects[objnum].handler.coord2->coord.t[2] = people[pernum].theobjects[objnum].position.vz; GsGetLs(&(people[pernum].theobjects[objnum].coord), &tmpls); GsSetLightMatrix(&tmpls); GsSetLsMatrix(&tmpls); GsSortObject4( &(people[pernum].theobjects[objnum].handler), &Wot[side], 3, getScratchAddr(0)); } } GsSetRefView2(&view); FntPrint("XYZ: %d,%d,%d\n",people[0].theobjects[0].rotate.vx,people[0].theobjects[0].rotate.vy,people[0].theobjects[0].rotate.vz); FntPrint("Vp: %d,%d,%d\n",view.vpx,view.vpy,view.vpz); FntFlush(-1); VSync(0); ResetGraph(1); GsSwapDispBuff(); GsSortClear(0,0,4,&Wot[side]); GsDrawOt(&Wot[side]); side ^= 1; } // program cleanup ResetGraph(3); } /*=======================================================================*/ void movelimbs(int pernum) // move all the limbs { /* if ( ++armcz > armanglez ) armcz=0; if ( ++armcx > armanglex ) armcx=0; if ( ++armcy > armangley ) armcy=0; if ( ++legcz > leganglez ) legcz=0; if ( ++legcx > leganglex ) legcx=0; if ( ++legcy > legangley ) legcy=0; people[pernum].theobjects[2].partrotate.vz = -1 * (people[pernum].theobjects[3].partrotate.vz += (legcz - (int)leganglez/2) * (ONE/1024)); people[pernum].theobjects[2].partrotate.vx = (people[pernum].theobjects[3].partrotate.vx += (legcx - (int)leganglex/2) * (ONE/1024)); people[pernum].theobjects[2].partrotate.vy = -1 * (people[pernum].theobjects[3].partrotate.vy += (legcy - (int)legangley/2) * (ONE/1024)); */ // theobjects[6].partrotate.vz = theobjects[2].partrotate.vz; // theobjects[7].partrotate.vz = theobjects[3].partrotate.vz; } /*=======================================================================*/ void updateobj (int objnum) // do the bounce { if(dbug) printf("in updateobj for object number %d\n",objnum); if(objnum==0) { dofirstobject(objnum); // Special 1st object functions } else { dootherobjects(objnum); // Special other object functions } // Generic functions that happen to all objects go here // if (theobjects[objnum].handler.coord2->coord.t[1] != theobjects[objnum].ceiling) { } } /*=======================================================================*/ void dofirstobject (int objnum) // do the bounce { if(dbug) printf("in dofirstobject for object number %d\n",objnum); /* theobjects[objnum].height += (theobjects[objnum].velocity += theobjects[objnum].gravity); if (theobjects[objnum].height <= theobjects[objnum].floor) { theobjects[objnum].height = theobjects[objnum].floor; theobjects[objnum].velocity = 0; } if (theobjects[objnum].height >= theobjects[objnum].ceiling) { theobjects[objnum].height = theobjects[objnum].ceiling; theobjects[objnum].velocity = -theobjects[objnum].velocity; } */ } /*=======================================================================*/ void dootherobjects (int objnum) // all objects follow the rotation of the first object { int pernum; for ( pernum=0; pernum>3)&0x01) /* if clut exists, load it up */ { rect1.x=tim1.cx; rect1.y=tim1.cy; rect1.w=tim1.cw; rect1.h=tim1.ch; LoadImage(&rect1,tim1.clut); } } /*=======================================================================*/ int DealWithControllerPad (void) { long pad = PadRead(); int pernum; if (pad & PADstart && pad & PADselect) // quit program return 0; if (pad & PADstart) { view.vrx = 5000*UNIT; // reset viewpoint view.vry = 0*UNIT; view.vrz = -2000*UNIT; view.vpx = 5000*UNIT; view.vpy = -600*UNIT; view.vpz = -5000*UNIT; view.rz = 0; } for(pernum=0; pernumcoord.t[0]; tempMatrix.t[1] = coordSystem->coord.t[1]; tempMatrix.t[2] = coordSystem->coord.t[2]; RotMatrix(rotationVector, &tempMatrix); // get rotation matrix from rotation vector coordSystem->coord = tempMatrix; // assign new matrix to coordinate system coordSystem->flg = 0; // tell GTE that coordinate system has been updated } /*=======================================================================*/ void PadInit (void) { GetPadBuf(&bb0, &bb1); } /*=======================================================================*/ u_long PadRead(void) { return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); }