Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Dec 2001
Offline Last Active Dec 10 2015 11:55 AM

Topics I've Started


29 June 2005 - 09:20 AM

I am trying to use quaternions for my animations, but I can't really get them working correctly. I made a plugin for maya, which gets the quaternion from the items transformation matrix. Most of the time this seems to work fine, but especially if I try to blend between multiply animations, it sometimes gives very weird results. I think the problem has something to do with the fact that you can represent each rotation by 2 diffent quaternions.
I did a little test with a cube which rotates only around it's x axis. This is a part of the quaternion keyframes I got, and there is indead a flip of signs:

<key t = "5" value = ".7330, -.6801, 0, 0"/>
<key t = "6" value = ".6234, -.7818, 0, 0"/>
<key t = "7" value = "-.4999, .8660, 0, 0"/>
<key t = "8" value = "-.3653, .9308, 0, 0"/>

Is there a way to get the quaternions in a way that those sign flips won't occur?

This is my matrix to quaternion code
Quaternion Matrix4::ToQuaternion() const
	float trace = m[0][0] + m[1][1] + m[2][2];
	if(trace > 0)
		float root = sqrtf(trace + 1);

		Quaternion ret;
		ret.w = root * .5f;
		root = .5f / root;
		ret.x = (m[2][1] - m[1][2]) * root;
		ret.y = (m[0][2] - m[2][0]) * root;
		ret.z = (m[1][0] - m[0][1]) * root;
		return ret;
		const int next[] = {1,2,0};
		int i = 0;
		if(m[1][1] > m[0][0])
			i = 1;
		if(m[2][2] > m[i][i])
			i = 2;
		int j = next[i];
		int k = next[j];

		float root = sqrtf(m[i][i] - m[j][j] - m[k][k] + 1);

		Quaternion ret;
		ret.vec[i] = root * .5f;
		root = .5f / root;
		ret.w = (m[k][j] - m[j][k]) * root;
		ret.vec[j] = (m[j][i] + m[i][j]) * root;
		ret.vec[k] = (m[k][i] + m[i][k]) * root;
		return ret;

Maya coordinates?

22 May 2005 - 11:26 PM

Maya is driving me nuts. I am writing an exporter plugin. According to the documentation maya uses centimeters for all it's units, and most of the time, this seems to be the case. But on some objects, it suddenly seems to be using meters, and so my object comes out 100 times smaller than it is in maya. Does anyone know what I could be doing wrong?

sampling twice from the same texture

22 December 2004 - 11:13 PM

In my pixel shader, i want to sample from the same texture twice, with different texture coordinates. I can only use pixel shaders 1.3. I tried to move a different texture coordinate to t0, and then sample again, but that shader didn't compile. I could try to bind the same texture to two sampler stages, but i'm not sure if that will work/is safe. What is the best way to do this?

maya plugins with shaders

09 December 2004 - 10:18 PM

I am programming an exporter plugin for maya, and I need to export the textures used in the shaders too. I can get the shaders used by the object, but the lambert shader class only has functions to get the colour data, nothin about the textures that are used. How should I get the textures that are used in the shader?

[.net] Swapping two variables

28 November 2004 - 09:59 PM

I just started with C#, and I need two swap to variables. I can create my own swap function, but I'm sure there must be one in the standard library already, but I couldn't find it. Does .net have a swap function, or do I have to make one myself? [Edited by - quasar3d on December 11, 2004 10:43:57 AM]