The hitching is most likely something trying to revert your angle changes
(I.e. in prediction). Have you tried disabling prediction?

On Thursday, March 1, 2012, Craig Louie wrote:

> Hello Coders,
>
> I'm trying to create a space flight combat game with the Source SDK.
> Currently, I am trying to achieve rotation around the player's local axes
> for airplane-like pitch, yaw and roll. Below is the code I'm using to try
> to implement full 3D rotation. I'm running into a problem where the
> player's view twists and hitches unsmoothly when the player looks straight
> up or straight down. I think this may be because of the inherent problem of
> aliasing/Gimbal-lock when using Euler angles. Any advise?
>
> //#########################################
> //Take the Euler angles for the player's orientation (viewangles) and
> convert them to vectors.
> Vector vec_for, vec_rt, vec_up, vec_for_out, vec_rt_out, vec_up_out;
> AngleVectors(viewangles, &vec_for, &vec_rt, &vec_up);
>
> //Take the resulting vectors and the desired rotation amounts and convert
> them to Quaternions.
> Quaternion turn_q, look_q, roll_q;
> // NOTE: Assumes axis is a unit vector, non-unit vectors will bias the
> resulting rotation angle (but not the axis)
> VectorNormalize(vec_up);
> AxisAngleQuaternion(vec_up, turn_angle, turn_q);
>
> VectorNormalize(vec_rt);
> AxisAngleQuaternion(vec_rt, look_angle, look_q);
>
> VectorNormalize(vec_for);
> AxisAngleQuaternion(vec_for, roll_angle, roll_q);
>
> //Convert the quaternions to matrices.
> matrix3x4_t xform0, xform1, xform2;
> QuaternionMatrix(turn_q, xform0);
> QuaternionMatrix(look_q, xform1);
> QuaternionMatrix(roll_q, xform2);
>
> //Combine matrices.
> matrix3x4_t xformA, xformB;
> MatrixMultiply(xform0, xform1, xformA);
> MatrixMultiply(xformA, xform2, xformB);
>
> //Rotate the vectors with our combined rotation matrix.
> VectorRotate(vec_for, xformB, vec_for_out);
> VectorRotate(vec_rt, xformB, vec_rt_out);
> VectorRotate(vec_up, xformB, vec_up_out);
>
> //Determine the new viewangles based on our rotated vectors.
> VectorAngles(vec_for_out, vec_up_out, viewangles);
> //#########################################
>
> I put this code into in_joystick.cpp in the JoyStickMove( float frametime,
> CUserCmd *cmd ) function.
>
>
> Thanks!
>
>
>

-- 


Kind regards,
*Saul Rennison*
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders

Reply via email to