// // SAMPLE TOD ANIMATION PROGRAM // // INCLUDE FILES //--------------- #include #include #include "pad.h" // pad controller functions #include "tod.h" // definition for TOD functions #include "IDLists.h" // TMD ID list #include "graphics.h" // anything to do with display objects #include "addrs.h" // memory addresses of TMDS and TODS // DEFINES //------------ // PROTOTYPES //------------ void UpdateWorld(); void RenderWorld(); long ProcessInput(); // GLOBALS //---------- u_long pad; // For controller GsRVIEW2 view; // For viewing LinkObjectStruct theModel; // The instance of the model object LinkObjectStruct theModel2; ////////////////////////////////////////////////////////////////////////////////// // Updates everything in the world. void UpdateWorld() { } // Renders the graphics in the // world. void RenderWorld() { RenderPrepare(); DrawObjectLink(theModel.objs); DrawObjectLink(theModel2.objs); RenderFinish(); } // Processes all user input. long ProcessInput() { /* Read the pad data */ pad = PadRead(); if((pad & PADRright) > 0) ResetAnim(&theModel,0); if((pad & PADRleft) > 0) ResetAnim(&theModel,1); if((pad & PADRdown) > 0) NextFrame(&theModel,TRUE); if((pad & PADRup) > 0){NextFrame(&theModel,TRUE); NextFrame(&theModel2,TRUE);} if ((pad & PADLleft) >0) ResetAnim(&theModel2,1); if ((pad & PADLright)>0) ResetAnim(&theModel2,0); if ((pad & PADLdown)>0) NextFrame(&theModel2,TRUE); if ((pad & PADLup)>0) {NextFrame(&theModel,TRUE); NextFrame(&theModel2,TRUE);} if ((pad & PADh)>0) InitialiseView(&view,100,0,-2000,-4000,-5000,0,0,0); if ((pad & PADk)>0) return FALSE; return TRUE; } ////////////////////////////////////////////////////////// // Main routine //-------------- void main() { long running=TRUE; PadInit(); Initialise3DGraphics(); InitialiseView(&view,100,0,0,-2000,-4000,0,0,0); InitialiseLights(); InitialiseModelLink(&theModel,1,-2000,0,0,(u_long *)BALL_TMD); initTod(&theModel,&ball_list,0,(u_long *)BALLSTRE_TOD); initTod(&theModel,&ball_list,1,(u_long *)BALLBOU_TOD); InitialiseModelLink(&theModel2,1,2000,0,0,(u_long *)BALL_TMD); initTod(&theModel2,&ball_list,0,(u_long *)BALLSTRE_TOD); initTod(&theModel2,&ball_list,1,(u_long *)BALLBOU_TOD); //Set animation to first frame ResetAnim(&theModel,0); ResetAnim(&theModel2,1); // printf("\nposition 0 =%d\n",theModel.ID_list[0]); // printf("position 1 =%d\n",theModel.ID_list[1]); // printf("position 2 =%d\n",theModel.ID_list[2]); // main loop. while(running) { if(ProcessInput() == FALSE) running = FALSE; UpdateWorld(); RenderWorld(); } ResetGraph(3); }