Jump to content

  • Log In with Google      Sign In   
  • Create Account

Milkshape Animation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 08 August 2001 - 03:52 AM

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

Sponsor:

#2 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 August 2001 - 11:24 PM

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


#3 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 09 August 2001 - 03:09 AM

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


#4 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 August 2001 - 12:05 AM

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


#5 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 12 August 2001 - 08:15 AM

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



#6 Uthman   Members   -  Reputation: 480

Like
Likes
Like

Posted 12 August 2001 - 10:38 PM

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

#7 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 August 2001 - 12:12 AM

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


#8 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 13 August 2001 - 06:48 AM

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


#9 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 August 2001 - 12:14 AM

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


#10 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 14 August 2001 - 03:49 AM

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

#11 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 August 2001 - 01:07 AM

Try mmgr

(see www.flipcode.com''s ask midnight column. It is implemented in PortaLib at http://rsn.gamedev.net - its just an #include - and there is a FAQ there on how to use it).


~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL


#12 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 15 August 2001 - 07:20 AM

Hey,
I''m sure it is fully functional in PortaLib... I''ve read all your tutorials, most of which you seem to base off PortaLib ;-) But I, stubborn as I am, am forcing myself to learn it the hard way... guess work. :-) ( That''s more or less how I loaded the model, ''cause I didn''t have a reference off the file format handy... ). Animation, however, I''m nearly copying off of you... there was no way I could have guessed all the crap I had to do ;-)
Anyway... should I ever get something working, I''ll post some pretty pictures. :-D

--Nairb

#13 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 August 2001 - 01:13 AM



I use Portalib as a reference for everything because it basically grew out of tutorials. It started out as a rewrite for NeHe''s base code. In the space of 5 days I had added the first model loader, fonts, textures, and window creation and it had outgrown that and I decided to launch it separately. Unforutunately, its been pretty slow since

Anyway, best of luck. No problem writing your own code for things - it is the best way to learn it. Use Portalib as a reference, and if you find yourself doing things not included, contribute it. Its really a toolkit, that''s all it was ever meant to be and ever will be.

Definitely try the memory manager. Paul Nettle''s articles explain it enough without needing to dig into my code

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS