Loading Milkshape model in Java

Has anyone written a Milkshape model file loader in Java and be willing to share? Does anyone know of Java code to load Milkshape files? There are lots of examples of loading Milkshape ascii and binary formats but they are all written in C++. This in combination with my poor understanding of the milkshape format is making my head hurt. :slight_smile:

Darrel

Here’s all NEHE and Gametutorials.com tutorials ported to java. It’s Java4GL, but it’s no problem converting it to JOGL:

http://web.hypersurf.com/~sully/OpenGL/DemoBox.html

There’s a milkshape loader in there somewhere

Thanks. I also found this for Java3d which may work for me:

http://www.j3d.org/utilities/loaders/milkshape/lindamood.html

Darrel

I looked into MilkLoader, the program in my previous post. It loads a Milkshape model into a com.sun.j3d.loaders.Scene object. I know very little about Java3D, but I’m assuming this is some big gnarly object that chews up lots of memory but holds your scene graph. I’m wondering if it makes any sense to use it in a JOGL program. Would I get any benefit from loading my scene into Java3D objects, or is it a dumb thing to do?

You could always try AgentFX: www.agency9.se. We support .ms3d.

Cheers
// Tomas

I’ve managed to load all the data in a milkshape ascii export file, and use the vertex, normal, triangle, and material info to render it in a JOGL program. Fun stuff, most enjoyment I’ve gotten from coding in long long time :smiley:

Now I’d like to get the milkshape bone animation info rendering in a JOGL program. Has anyone done this? I understand all the data in the bone section of the export, but not sure of the the matrix and opengl operations I need to do to get the animation going on the screen. ???

Have no fear. I’m almost done with an example of milkshape loading/animation with seperate skeletal animations.
It uses my own milkshape exporter (which is free + source) but the principle behind the animation was taken straight (almost) from the ASCII example so you can probably use it out of the box :slight_smile:

And there will be an easy to use class if you’re lazy and don’t mind using my exporter ;D

Great! When can I get my paws on it?

I’m actually doing the same thing. I have animation working for just one joint with linear interpolation based on frame rate. Maybe I’ll get it working for multiple joints today.

I can’t get multiple joints working. :frowning:

I’m o so close, I just need a little more hand holding on the matrix math. I’ve computed the rotation matrix for all the joints. When I just rotate the root, I can make it work. However, if I try to rotate another joint at the same time, bad things happen. Someone from over on the Nehe forum gave me the following algorithm, I’m unclear about a few things:

for each vertex

  1. determine its owner joint. (I’m clear on this step)

  2. transform the vertex by the correct joint’s matrix.

I assume that means multiply the vertex vector by the owner joints rotation matrix. I’m a bit confused on how keyframes would affect this operation. If I’m not on the intial keyframe, do I need to do some additional matrix operations to get it into position? Lets call this resulting vertex vector ‘vprime’.

3)transform the vertex by the joint’s parent matrices.

I assume this means multiply vprime by the result of multiplying all the ancestor joint rotation matrices together. Do I pre or post multiply? And how would not being on initial keyframe affect this?

Tx for any help on this.

I’m still working on it. I got the animation and skeleton loaded and can draw the mesh based on the skeletal base pose. I hope to have the animation done sometime next week as I’m very busy :slight_smile:

I finally got my milkshape models animating with JOGL. I was close, but I just could not get the matrix math correct for multiple joints. :-[ Then I found this link.

http://mypage.iu.edu/~natjohns/najgl/

I think it and a lot of other code eventually evolved into JMonkey jME. Anyway, it was very easy to port to JOGL.

Darrel

Hi. I’m needing the same thing as you did at the beginning of the posts: a Milkshake model loader, and I’m working on a project using JOGL (no J3D nor LWJGL).
Could you be so king as to send me the loader. I just need to load a static model, so maybe you could send me the first application you mentioned wich doesn’t do animation.

Thanks.

izunino@gmail.com