A tough one, Game
Posted on 2000-04-17
I've got a networked driving game that drives cars around a 3D(DirectX) arena bounded by a wall. The problem is that while I can detect if one of the corners of the has hit a wall I can't figure out the maths of what how the car reacts afterwards.
All I can do successfully a straight bounce so that the reflected angle equals the incident angle. The problem lies in the left-hand co-ordinate system, which puts 90degrees to the left, but by calculation sin(90) is to the right as normal.
This is the code so far.
//Calculate the incidint angle
D3DVALUE iAngle = (1.570796f - 6.28318f - m_pBoids.fYaw - d3dApp.wallAngles[wallID]);
//calculate new angle
m_pBoids.fYaw += iAngle *2 ;
m_pBoids.fYaw = m_pBoids.fYaw - 6.28318f * (int)(m_pBoids.fYaw / 6.28318f);
if(m_pBoids.fYaw < 0)
m_pBoids.fYaw += 6.28318f;
There are 120 panels in the wall, and the angle of the panel hit is gotten using wallID.
The m_pBoids array is the array of cars.
A D3DVALUE is the same as a float.
The constants you see here are radian values e.g. 6.28318f = 360degrees
How do I calculate the angle car will end up in giving rough car collision dynamics and physics?
Please, no roundabout web addresses.