The terms raycast and parametric mean nothing to me. Vectors I get, but how would I calculate the Shoot_Vector? Other than that, this also makes sense.
A 2D raycast is:
Code:
float final_x = start_x + cosf(angle) * distance;
float final_y = start_y + sinf(angle) * distance;
A 3D raycast in vector form:
Code:
Vector3 final = start + unit_vector * distance;
A unit vector is a vector that has range 0.0f to 1.0f in all three components. This is also known as a normalized vector. You could test final for collision however this is not all that accurate. Actually all you need to do is determine if the unit_vector intersects the bounding volume of the target. Remember that a vector stretches from infinity to infinity so the intersection math works just fine regardless of the magnitude of the vector. If you want to make the bullet 'fly' along the shoot vector you simply normalize the shoot vector and and then multiply it by a distance scalar. The distance traveled is good old distance = rate * time where rate is the speed of the bullet and time is the frame delta or the time it took to render the frame. Keep in mind if you want to 'fly' the bullet to the target you will have to do a completely different collision test to determine if the bullet could hit target X in time interval T. If the interval is infinite then you know the bullet did not hit the target.
Vectors agian? Okay, this is starting to come together! So how does my mouse affect the vector?
The rest I can tackle after theese two.
One way to do it:
Code:
m_pCamera->Yaw(m_pMouse->GetX() * reduction_factor);
m_pCamera->Pitch(m_pMouse->GetY() * reduction_factor);
DirectInput will return mouse coordinates in relative by default so this works fine. If your particular mouse driver or API returns them in absolute you will have to derive the relative via a simple subtraction from the last known mouse x and y.
There are other more sophisticated methods such as converting the mouse x,y to spherical coordinates or mapping them to a unit sphere and then adjusting the up, look, and right vectors accordingly.