Jump to content

  • Log In with Google      Sign In   
  • Create Account


Aressera

Member Since 25 Mar 2007
Offline Last Active Today, 12:13 AM

Posts I've Made

In Topic: Thesis idea: offline collision detection

19 August 2014 - 06:16 PM

A similar idea was explored by this paper, which samples the high DOF configuration space between an object pair. In practice it doesn't seem to be very robust and requires a long precompute, high storage. Geometric techniques are much more accurate and robust.


In Topic: Matrix to Quaternion calculation instable

13 July 2014 - 02:25 PM

Try this conversion method, it is the same one used in the OGRE engine. Note: totally untested in this form.

/// Create a new quaternion from a 3x3 orthonormal rotation matrix.
/// Quaternion = {a, b, c, d}, Matrix3D = column major
Quaternion( const Matrix3D<T>& m )
{
	// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
	// article "Quaternion Calculus and Fast Animation".
	T fTrace = m.x.x + m.y.y + m.z.z;
	
	if ( fTrace > T(0) )
	{
		// |w| > 1/2, may as well choose w > 1/2
		T fRoot = math::sqrt(fTrace + 1.0f);  // 2w
		a = 0.5f*fRoot;
		fRoot = 0.5f/fRoot;  // 1/(4w)
		
		b = (m.y.z - m.z.y)*fRoot;
		c = (m.z.x - m.x.z)*fRoot;
		d = (m.x.y - m.y.x)*fRoot;
	}
	else
	{
		// |w| <= 1/2
		Index nextIndex[3] = { 1, 2, 0 };
		Index i = 0;
		
		if ( m.y.y > m.x.x )
			i = 1;
		
		if ( m.z.z > m[i][i] )
			i = 2;
		
		Index j = nextIndex[i];
		Index k = nextIndex[j];
		
		T fRoot = math::sqrt( m[i][i] - m[j][j] - m[k][k] + T(1) );
		
		T* apkQuat[3] = { &b, &c, &d };
		*apkQuat[i] = T(0.5)*fRoot;
		
		fRoot = T(0.5)/fRoot;
		
		a = (m[j][k] - m[k][j])*fRoot;
		*apkQuat[j] = (m[i][j] + m[j][i])*fRoot;
		*apkQuat[k] = (m[i][k] + m[k][i])*fRoot;
	}
}

In Topic: Bone parent indices to linked list

06 July 2014 - 11:58 AM

I don't think it is necessary to store any explicit hierarchy of the bones - In my animation system I just have a list of bones, and each bone has an associated parent bone index (in the list). This stores the hierarchy implicitly. Then, when computing the final matrices for each bone, I just iterate through the list and lazily compute the concatenated object-space matrices of each bone (and any parent bones, if they have not yet been computed). There doesn't seem to be any reason to store the skeleton hierarchy in a traditional tree structure.


In Topic: The doubt of a bounding sphere as the bounding volume

28 June 2014 - 02:38 PM

There is rarely one bounding volume to fit them all. You should probably have separate bounding volumes for physics and graphics, since the needs for both are different. The graphics bounding volume can be a little looser because it's only used for culling, while the physics BV should tightly bound the visual representation. You may also use a series of progressively more detailed representations: first test against a bounding sphere, then versus convex hull of the mesh, then versus the actual mesh itself. This avoids checking the detailed representation more often than necessary.


In Topic: Getting the template type from a pointer to it

24 June 2014 - 12:05 PM

Make fooBase a virtual class (add an empty virtual destructor), then you can at least dynamic_cast<fooTemplate<type>*>() to make sure that an object has type fooTemplate<type>. The calling function will still need to know the template type, but at least this adds type safety.

 

There isn't really any way to do better than that in C++, because there is no reflection support. If you want to perform an action on an object like that, the best way (that doesn't use down casting) would be to have a pure virtual function in fooBase that is implemented for each fooTemplate<type>.


PARTNERS