Milkshape Animation

Started by
11 comments, last by Nairb 22 years, 8 months ago
Hey, I''ve loaded up a Milkshape model and it draws fine. Now, however, I can''t figure out how to animate it with the bones. Someobdy helped me on this once, but it was a long time ago and I still haven''t figured it out. I was hoping someone could look at my code and tell me what I''m doing wrong / post a fix. Any help would be greatly appreciated... The code is at: http://prodigygames.homestead.com/files/glMilkshapeASCII.txt Thanks, --Nairb
Advertisement
Too late for me to digest this right now
What exactly is the problem with it? IT looks like a good start.
Also, please refer to the MsViewer.zip in the downloads at Milkshape''s homepage (ASCII MS3D bones animation), and my tutorial on the topic at http://rsn.gamedev.net.
Happy to answer any questions you have after that (when I''ve had some sleep

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Hi,
The problem is, it''s not changing...The model shows up, but there''s no animation.
I looked at MsViewer and the RSN tutorial, but they both use outside libraries, and that''s something I was trying to avoid if at all possible ( although lately I''ve been pondering just ripping code straight from MsViewer ). I know basic matrix and vector stuff, but MsViewer is using functions like AngleMatrix that I''ve never heard of...

--Nairb
My tutorial doesn''t use any outside libraries....

Portalib uses libPNG, but that''s avoidable by writing a simple BMP loader.

AngleMatrix etc are defined in the math cpp file in MsViewer. This is actually ripped from a Half-Life example

I wrote my own Matrix code, that''s what is in the tut. You are welcome to substitute your own

Good luck...

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Of everything sacred!
I''m using my own code to load the model in from the ASCII format because, well, I''m just too lazy to load in the binary format ;-)

I got your code brett, and I''m using your stuff for matrices, vectors, quaternions, and animation ( once I learn the math better I''m going to rewrite it to better suit my needs ).
I basically copied the animation code verbatim... but now there''s a very cruel error.

The string comparisons to find the array index of the parent bone is crashing my program! Here''s just a little snippet so you understand what I''m saying:

//My joint class
struct MSJoint
{
... All necessary stuff...
string name;
string parentName;
int parentID;
}

//In the loading routine...
void glMilkshapeASCII::Load( char *fileName )
{
... Load the beginnings of the file...
while ( buffer != "Bones:" )
fileOpen >> buffer;
fileOpen >> numJoints;
Joints = new MSJoint[ numJoints ]; //Create joints array
for ( counter = 0; counter < numJoints; counter++ )
{
getline( fileOpen, Joints[ counter ].name );
getline( fileOpen, Joints[ counter ].parentName );

int counter2 = 0;
if ( Joints[ counter ].parentName.length() > 2 )
while ( Joints[ counter ].parentName != Joints[ counter2 ].name )
counter2++;
else
counter2 = -1;
Joints[ counter ].parentID = counter2;
}
....Proceed to load file....

}

Well, there''s the problem area. I''ve tried using char* for strings and using the comparing functions, but nothings working. The program keeps crashing there, and the debugger won''t show me the values of the variables. Maybe you can help me with just that? Or perhaps I can send you my code and you can scope out what''s wrong?

Thanks for all your help so far and any help you can give me in the future...
--Nairb

Brett''s code works flawlessly.... even one of the creators of MS3D said so (Mete Ciragan). check out the portalib threads to see how to ge animation, and specific frame animation running.

Uthman Apatira
www.WiZ3Domain.com
"a low level aho master like you couldn't kill me even if I let you"
Nairb,

My guess is you didn''t allocate any memory for "buffer". Hence you are putting characters into some random location in memory and trashing something that doesn''t belong to you.

Also, buffer != "text" will not work. "text" will be a pointer to a string in memory, buffer a pointer to some other string in memory. You are looking for strcmp( buffer, "text" ) != 0

I''d recommend you brush up on some basic C/C++ before tackling this. Strings vs. char arrays are always a sticking point.

Hope this helps!

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Hey,
Uthman: I have no doubt that brett''s code works. It''s just not working for me yet ;-)

Brett: That''s just it... I''m not using standard char*, I''m using Microsoft''s string class. buffer is a string, so I should be able to directly compare them. I''m using it to find things in the file and it works fine, but for some reason it won''t work to let me find the parent id. When I tried using char* and strcmp, I was still getting errors, but not in the string class.
Something''s spoony... ^-^ But anyhow, no need to trouble yourself with it, I''m sure I''ll figure it out eventually.

Thanks for all your help thus far,
--Nairb
sorry, I saw char * for filename and made an assumption

Have you tried the string::compare function instead?
I''ve never trusted operator overloading since I took up Java and tried string != string2 and got burnt by that whole object reference thing, before it finally clicked

You might also try strcmp( buffer.c_str(), "name" )

I''m stumped Good luck!


~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Hey,
I figured out the string problem...
I should have put a fileOpen.ignore( 100, ''\n'' ); before my getlines.
That''s fixed... but when I rewrote my loader ( to make it more efficient ), everything got screwed up, and now I''m arguing with the dynamic memory... :-(

So... I''ll keep working on this and keep you updated. See ya later.

--Nairb

This topic is closed to new replies.

Advertisement