Skip to main content
GameDev.net gamedev.net
🔒 Locked

smoother rotations techniques

Started by _gamedev8_ Sep 17, 2005 at 8:33 PM 5 replies 1.2k views
Original Post
_gamedev8_
_gamedev8_
for rotating a first person camera by mouse what are some good methods for making rotations smooth?... Im having the best results with quaternions slerp/squad so far... but it still seems a little choppy
but what is the very best method?
timw
timw
given two orientations, interpolation of quaternions is the best way to get from one orientation to another, that is it takes the smallest path. can you describe the choppyness better? if your implimenting some sort of acceleration you should make sure that the acceleration curve is continuous. what I'm saying is perhaps it's not how you handle the rotation(ie quaternions) but how you specify angle given mouse deltas.

Tim
timw
timw
Tim <--- born and raised english speaker. hard to tell huh? lol
FERNANDO-BRASIL
FERNANDO-BRASIL
I'm not sure, but I think smoothness depends on how much you rotate in determined bunch of time.

I think the refresh rate also takes influence, because internally you can do a very good smooth rotation, but if the user is seeing the rotation with 5 frames per second, the rotation would be some kind of unsmoothness from the user perspective.
_gamedev8_
_gamedev8_
thanks for the responses guys... i took both into considerartion and fixed it
ajas95
ajas95
The problems with the methods people have described is that they don't take the current angular velocity into account. What you want is a method that brings you to your desired orientation in a given amount of time that takes into account velocity and is smooth across all higher derivatives.

Here is what I do. damp_spring() is a method that uses a damp spring to move a point to a target point in a desired amount of time. Then I use that on the "facing vector" of the camera to produce a new facing vector (in my case, the camera looks down the -z axis), and regenerate a new orientation for the camera (with y-up).

// use a damped spring to move v0 towards target given a current velocity, // time over which the spring would cover 90% of the distance from rest; // and dt, the change in time.template<typename T>inline void damp_spring(T& v0, const T& target, T& vel, float time_90, float dt){	const float c0 = dt * 3.75f / time_90;	if(c0 >= 1.0f)	{		v0 = target;		vel = T(0.0f);		return;	}	const T delta = target - v0;	const T force = delta - 2.0f * vel;	v0 += vel * c0;	vel += force * c0;}void Frame::spring_facing(float dt, float spring){	vec4 z(m_ornt.z_axis());	damp_spring<vec4>(z, m_target_z, m_zvel, spring, dt);		// now make sure that normalizing z preserves the y coord.	// linearly interpolating the z-axis is an approximation, 	// and the y distortion is most noticeable.	const float D = 1.0f - z.y * z.y;	const float L = z.x * z.x + z.z * z.z;	const float mult = sqrtf(D / L);	z.x *= mult;	z.z *= mult;	m_ornt.face(-z);}


It's that simple!
_gamedev8_
_gamedev8_
i changed it and made two variables the user can adjust in the settings... a 'multiplyier' on the change in mouse movement, and a 'multiplyier' on the interpolation, it seems ok now, but i will give your idea a try

thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.