Path: chuka.playstation.co.uk!news From: "Peter Dollochan" Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Collision Detection Date: 15 Sep 1998 17:16:35 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 120 Message-ID: <01bde0cb$da190e60$026f6f6f@two> References: <35fd5208.9088684@news.playstation.co.uk> NNTP-Posting-Host: host5-171-229-204.btinternet.com X-Newsreader: Microsoft Internet News 4.70.1161 Hi, Okay to keep your car in the world and assuming each cell is say 64X64 and the first entry is at (0,0,0) the last is at (896,0,-896) if(CarModel.Object_Coord.coord.t[0]<0) { CarModel.Object_Coord.coord.t[0]=0; } if(CarModel.Object_Coord.coord.t[0]>959) { CarModel.Object_Coord.coord.t[0]=959; } if(CarModel.Object_Coord.coord.t[2]>0) { CarModel.Object_Coord.coord.t[2]=0; } if(CarModel.Object_Coord.coord.t[2]<-959) { CarModel.Object_Coord.coord.t[2]=-959; } That should stop your car going of off the cell data altogether To find out what cell the car is on again I assume the cell size 64X64. add the declarations int Cell_numX,Cell_numZ; to your object struct..... then to tell what cell you are in use bitshifting on the positional data of your car. CarModel.Cell_numX = CarModel.Object_Coord.coord.t[0]>>6; CarModel.Cell_numZ = CarModel.Object_Coord.coord.t[2]>>6; from here its up to you what to do, you could use another couple of variables to store the last position of the car so that in the event that you drive of off the track (I take it you have zeros in your array data to signify no track) you just dump the car back to the position prior to leaving the track...or you could try angle of incidence/reflection thereby giving the idea that the car bounced of off a wall or something whatever you choose this should get you going...all this aside Phils suggestion that you look into 2D stuff first may be the way to go and everything I said is prolly wrong (but I hope not :-) Pete. Tanvir Khan <2bad@lineone.net> wrote in article <35fd5208.9088684@news.playstation.co.uk>... > Hi, > > I am still getting nowhere with collision detection even after some > help from George Bain's sample, so I am putting some bits of the code > of the code I'm working on for your knowledge so you know whats going > on. > > I want a 3D car to collide once it is of the track which is made of > cells. > > The struct of the car is: > > typedef struct > { > SVECTOR rotation; > long speed; > GsDOBJ2 Object_Handler; > GsCOORDINATE2 Object_Coord; > > } Object_Header0; > Object_Header0 CarModel; > > Track struct is: > > typedef struct > { > long numberObjects; > GsDOBJ2 Object_Handler[GROUND_MAX_OBJECTS]; > GsCOORDINATE2 Object_Coord[GROUND_MAX_OBJECTS]; > u_long *Back_Pointer[GROUND_MAX_OBJECTS]; > > u_long *Object_Pointer[GROUND_MAX_OBJECTS]; > } Track_Header0; > Track_Header0 TrackData; > Track_Header0 Track1Data; > Track_Header0 Track2Data; > Track_Header0 Track3Data; > Track_Header0 Track4Data; > Track_Header0 Track5Data; > > Tack array: > > char RawGroundArray[GROUND_MAXX][GROUND_MAXZ] ={ > {'6','1','1','1','1','1','2','0','0','0','0','0','0','6','2'}, > {'3','0','0','0','0','0','5','1','2','0','0','6','1','4','3'}, > {'3','0','0','0','0','0','0','0','3','0','0','3','0','0','3'}, > {'3','0','0','0','6','1','1','1','4','0','0','3','0','0','3'}, > {'3','0','0','0','3','0','0','0','0','0','0','3','0','0','3'}, > {'5','1','2','0','5','1','1','1','1','1','1','4','0','0','3'}, > {'0','0','3','0','0','0','0','0','0','0','0','0','0','0','3'}, > {'0','0','3','0','0','6','1','1','1','1','1','1','1','1','4'}, > {'0','6','4','0','0','3','0','0','0','0','0','0','0','0','0'}, > {'0','3','0','0','6','4','0','0','0','0','0','0','0','0','0'}, > {'6','4','0','0','3','0','0','0','0','0','0','0','0','0','0'}, > {'3','0','0','0','5','1','1','1','1','1','1','1','1','1','2'}, > {'3','0','0','0','0','0','0','0','0','0','0','0','0','0','3'}, > {'3','0','0','0','0','0','0','0','0','0','0','0','0','0','3'}, > {'5','1','1','1','1','1','1','1','1','1','1','1','1','1','4'}}; > > Can anyone please put some examples for collision detection using the > information provided. > > If anymore info is needed that's no problem. > > Sorry for the trouble. > > Tanvir Khan > EMAG DESIGN > > 2bad@lineone.net >