Path: chuka.playstation.co.uk!chuka.playstation.co.uk!chuka.playstation.co.uk!not-for-mail From: Lewis_Evans@Playstation.sony.com Newsgroups: scee.yaroze.programming.3d_graphics Subject: vectored bullets code sample Date: 7 Jan 1998 17:17:28 -0000 Organization: Sony Computer Entertainment Europe - 119.SS5 Lines: 102 Sender: news@chuka.playstation.co.uk Message-ID: <690db8$sil1@emeka.playstation.co.uk> Reply-To: Lewis_Evans@Playstation.sony.com NNTP-Posting-Host: emeka.playstation.co.uk From: Lewis_Evans@Playstation.sony.com To: news@playstation.co.uk I cannot say much about the sample code given, because I can't see what AdvanceModel does. The one oddity is: // here: position of car is assigned to of bullet? // surely should assign to position of bullet? theBullet->rotation.vx = theCar.gsObjectCoord.coord.t[0]; theBullet->rotation.vy = theCar.gsObjectCoord.coord.t[1]; theBullet->rotation.vz = theCar.gsObjectCoord.coord.t[2]; // here: rotation vector of bullet is assigned to position of bullet????? theBullet->gsObjectCoord.coord.t[0] = theBullet->rotation.vx; theBullet->gsObjectCoord.coord.t[1] = theBullet->rotation.vy; theBullet->gsObjectCoord.coord.t[2] = theBullet->rotation.vz; What really needs to happen is: when you create a bullet, set its position to the centre / front edge of the car. Then you want the velocity of the bullet to point in the direction that the car faces in. This vector is directly obtainable from the car matrix (COORD2.coord.m); the way it faces is the car matrix z axis, eg use worldVelocityVector.vx = car.coord.m[0][2]; worldVelocityVector.vy = car.coord.m[1][2]; worldVelocityVector.vz = car.coord.m[2][2]; [Note: should scale for absolute bullet speed, ie each element *= bulletSpeed, then /= ONE]. [The above works because a rotation matrix is really just an expression of three axes: the car x, y and z axes, each expressed in world terms]. now the worldVelocityVector points in the direction the car faces. Each frame, update the bullet's position by the velocity, and there it is. See the SCEE demos flying and dungeon for more examples of ships shooting bullets in the direction they are facing. Lewis To: Lewis Evans cc: From: news @ playstation.co.uk Subject: vectored bullets code sample:scee.yaroze.programming.3d_graphics From: "Linda J. Hodge" Newsgroups: scee.yaroze.programming.3d_graphics Subject: vectored bullets code sample Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit hello,Im trying to make a bullet fly from the center of the Car in the current vector of the car and proceed,like the missiles in twisted metal.I have some code but it doesnt seem to work.All it displays is the bullet tmd around the car and wherever the car moves the bullet rotates around the car. code Sample: void Shoot(PlayerStructType2 *theBullet, unsigned long *lModelAddress) { DrawPlayer(theBullet,&othWorld[currentBuffer]); lModelAddress++; GsMapModelingData((unsigned long *)lModelAddress); GsInitCoordinate2(WORLD, &theBullet->gsObjectCoord); lModelAddress++; lModelAddress++; GsLinkObject4((unsigned long*)lModelAddress,&theBullet->gsObjectHandler,0); theBullet->gsObjectHandler.coord2 = &theBullet->gsObjectCoord; theBullet->rotation.vx = theCar.gsObjectCoord.coord.t[0]; theBullet->rotation.vy = theCar.gsObjectCoord.coord.t[1]; theBullet->rotation.vz = theCar.gsObjectCoord.coord.t[2]; theBullet->gsObjectCoord.coord.t[0] = theBullet->rotation.vx; theBullet->gsObjectCoord.coord.t[1] = theBullet->rotation.vy; theBullet->gsObjectCoord.coord.t[2] = theBullet->rotation.vz; AdvanceModel(&theBullet->gsObjectCoord,&theBullet->rotation,&theBullet->spe ed,256); theBullet->gsObjectCoord.flg = 0; } I call this function when the pad is pressed. -Austin