Archived

This topic is now archived and is closed to further replies.

BlackScar

MilkShape 3d Joints

Recommended Posts

After reading Brett's tutorial on Nehe about MilkShape model loading and his skeletal animation tutorial, I have written my own loader from his. Everything loads correctly, but there's a few things that aren't setting up correctly. In his tutorial he uses his Matrix routines to bind the mesh's verticies to the skeleton, I'm trying to convert that into mine with no luck. 1. I get each joint from the buffer. 2. I convert the joint's rotation to degrees pNameList.m_localRotation[0] *= 180.0/PI; pNameList[i].m_localRotation[1] *= 180.0/PI; pNameList[i].m_localRotation[2] *= 180.0/PI; I added everything I needed to know about the joint to pNameList, since I will be using Trees and not arrays. I also check to make sure that pNL[i].m_localRotation[0-2] isn't over 360 nor under 0. 3. I get the inverse of each joint's rotation pNL[i].m_localRotation[0] = 360 - pNL[i].m_localRotation[0]; pNL[i].m_localRotation[1] = 360 - pNL[i].m_localRotation[1]; pNL[i].m_localRotation[2] = 360 - pNL[i].m_localRotation[2]; Btw, pNL = pNameList. 4. I show each joint by calling the Root node and traversing the list. tJNT *Temp = Children; // Accumulate the rotations Temp->FinalRot[0] = Temp->LocalRot[0] + FinalRot[0]; Temp->FinalRot[1] = Temp->LocalRot[1] + FinalRot[1]; Temp->FinalRot[2] = Temp->LocalRot[2] + FinalRot[2]; // Make sure the rotation isn't going over 360 // I do that here. // Get the vector distance from the parent bone Temp->FinalTrans[0] = Temp->LocalTrans[0]; Temp->FinalTrans[1] = Temp->LocalTrans[1]; Temp->FinalTrans[2] = Temp->LocalTrans[2]; // Rotates the local translation by it's parent's final rotation rotate_point( &Temp->FinalTrans[0], &Temp->FinalTrans[1], &Temp->FinalTrans[2], FinalRot[0], FinalRot[1], FinalRot[2] ); // Add the parent's position to this joint's position Temp->FinalTrans[0] += FinalTrans[0]; Temp->FinalTrans[1] += FinalTrans[1]; Temp->FinalTrans[2] += FinalTrans[2]; // Shows the joint glBegin( GL_POINTS ); glVertex3f( Temp->FinalTrans[0], Temp->FinalTrans[1], Temp->FinalTrans[2] ); glEnd(); 5. For the rotate_point function, I create sin/cos look up tables. Here's the function void rotate_point(float *fX,float *fY,float *fZ,int RadX,int RadY,int RadZ) { float xtemp,ytemp,ztemp; float cosx,cosy,cosz; float sinx,siny,sinz; cosx=ctable[RadX]; cosy=ctable[RadY]; cosz=ctable[RadZ]; sinx=stable[RadX]; siny=stable[RadY]; sinz=stable[RadZ]; xtemp = *fX * cosz + *fY * sinz; ytemp = *fY * cosz - *fX * sinz; *fY = ytemp * cosx + *fZ * sinx; ztemp = *fZ * cosx - ytemp * sinx; *fX = xtemp * cosy + ztemp * siny; *fZ = ztemp * cosy - xtemp * siny; } ------------------------------------------------ I have NO clue what's wrong here. :/ Can somebody please help? MANY thanks in advance! ~-=-=-=-=-=-=~ ~Justin Eslinger~ ~.."BlackScar"..~ ~-=-=-=-=-=-=~ Edited by - BlackScar on June 25, 2001 2:13:51 AM

Share this post


Link to post
Share on other sites
Hi Brett, thanks for replying

Well, here's a side comparison picture of my engine and MilkeShape 3d.

The joints circled in white are the ones that are out of line. It's like the first few turn out ok from the root joint and then they go all crazy! It's insane!

I hope you can help. I've been fighting this for a few days now with no luck. :/

I've also uploaded the class if you want to look at it.

Go to my website here for picture and source for the class. I hate free web services.

Thanks in advance.


~-=-=-=-=-=-=~
~Justin Eslinger~
~.."BlackScar"..~
~-=-=-=-=-=-=~

Edited by - BlackScar on June 25, 2001 4:13:03 PM

Edited by - BlackScar on June 25, 2001 4:24:46 PM

Share this post


Link to post
Share on other sites