Milkshape Model

Well, I got a milkshape model loaded with materials and all, things are still VERY rough, so I’m not going to be committing it for a bit longer. But just thought I’d show a teaser, the model loaded with a light running around it.

wel…im feeling two fold!! :smiley: for seeing a model again in jME and :frowning: for not being able to use it yet!!

Ok, getting closer. Model is being loaded and set to a TriMesh now. Having a bit of an issue with bounding volumes. The model is being culled at times when it should still be visible.

Does anyone have any milkshape ASCII models? All I have is the one in the demo and I need to test against multiple. Please let me know!

Ok, initial check in of the milkshape loader is in:


test is com.jme.renderer.TestMilkshapeASCII

No animations yet. Still trying to figure out how to handle that in terms of controllers, etc.

VERY little testing done, I am without models. Please, please use all the models you can and let me know if it blows up on something.

This is a very rough cut, has a bit of a ways to go. But it should give you guys an idea on how the loaders will work.


Node modelScene = MyModelLoader.load(“Model”);

that easy.

Each component of the model is it’s own Node/TriMesh group. Meaning the model is automatically placed into a tree and individual sections can be culled. This is important for very large models where you might only see a small section at a time.

Which leads me into my next topic…

Custom loader.

I want to make a custom format for jME. It will be XML based, and allow the loading of a model. But the model can be any size, in fact, an entire scene in desired. I need people who are good with XML and parsing.

I’d also love to be able to save a scene (at any level) as this custom format.

Then sometime in the future maybe write a Milkshape 3D importer/exporter, so you can work on the custom models in that tool.

can i assume that i can call model.setLocalTranslation(Vector3f) to set the model’s location?

Yes, you’d do something like:

//Get model
Node soldier = MilkshapeASCIILoader.load("data/model/msascii/run.txt");

You can treat it like you would any other node.

do you have an article or something for me to learn about Quateranian (or something similar, excuse the spelling)?

because you need that for rotations dont you?

There is already a Quaternion class in com.jme.math. It was requested for the ODE physics stuff. So you can look there for an implementation. If you want to learn about it, there are a few math books out there that have good articles about it.

I think the first lesson I took was probably this:

then I read about it in various books.

So, the Quaternions are there for the slerping (spherical linear interpolation), which allows the joints to rotate smoothly. I just need to set up the keyframes/joints and inverse kinematic system.

kewlies, i just want to know how can I rotate my models with it?

kewlies, i just want to know how can I rotate my models with it?

Node rotations are via Matrix3f. You can create quaternion rotations and convert to Matrix3f. For creating rotations via Quaternions look at:

fromAngles(float[]). Takes 3 float values (3 angles (x,y,z)). So if you wanted to rotate 30 degrees on x, 45 on y, and 0 on z.

float angles[] = {30,45,0};

fromAngleAxis(float, Vector3f) allows you to define an axis to rotate about and an angle to rotate. So if I wanted to rotate 30 degrees about the (1,1,1) axis:

quaternion.fromAngleAxis(30, new Vector3f(1,1,1));

You can also "slerp" between two quaternions to allow for smooth rotations.

Let say you have a quaternion (q1) of the models current orientation, and have a destination rotation (q2). You can find any quaternion between q1 and q2 (q1 == 0, and q2 == 1).

float amount = timePassed / timeForRotation;
Quaternion currentQ = q1.slerp(q1,q2,amount);

Let me know if you need any more info.

Also, I suppose I am going to go ahead and keep working with MilkshapeASCIILoader and get animations working. My original plan was to get all the loaders loading static models first then hit animation, but I might as well get one loader all the way complete first.