PDA

View Full Version : Milkshape3D MS3D help needed



paul_nicholls
02-07-2009, 12:12 AM
Hi all,
I hope anyone here who is familiar with the Milkshape3D MS3D file format can help me :)

I am trying to create a Pascal MS3D exporter for a project I am working on, and I have a few questions about the structures involved with this format.

I have gotten the specs for the Milkshape3d MS3D 3D file format from here:

http://local.wasp.uwa.edu.au/~pbourke/dataformats/ms3d/ms3dspec.h

Question 1


typedef struct {
byte flags; // SELECTED | SELECTED2 | HIDDEN
float vertex[3]; //
char boneId; // -1 = no bone
byte referenceCount;
} ms3d_vertex_t;

What values do I use for the referenceCount in this structure?

Prior to writing out the vertex to the file, I know what to put into the other three fields, but not this one.

I figure I can use 0 for the flags, vertex is obvious, I can use -1 for boneId (till I decide to do animation support).

I have looked at the source code of some MS3D readers but none of them seem to use this field at all...do I just put 0 for the referenceCount in vertex?

Question 2


typedef struct {
word flags; // SELECTED | SELECTED2 | HIDDEN
word vertexIndices[3]; //
float vertexNormals[3][3]; //
float s[3]; //
float t[3]; //
byte smoothingGroup; // 1 - 32
byte groupIndex; //
} ms3d_triangle_t;


Re: groupIndex field
What values would I use for groupIndex in this structure?

Does every triangle have to belong to a group?

It seems that every triangle that uses a different material needs to belong to a different group, is this correct?

I may have other questions later on, but thanks for your time :)
cheers,
Paul

Brainer
02-07-2009, 05:01 AM
If I may, did you look here (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=31)? ;)

paul_nicholls
02-07-2009, 06:15 AM
If I may, did you look here (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=31)? ;)


Yes, but unless I'm going blind (tm), I can't see it mentioned here either :)

cheers,
Paul

Brainer
02-07-2009, 06:21 AM
Ah, sorry. :) I thought you were looking for an importer. My bad there.:)

It seems the things you asked for are not needed, in my opinion. They might be used by the original Milkshape program for something, they might not have any particular meaning to other programs. Just a speculation, tho'.

noeska
02-07-2009, 09:52 PM
The things you are uncertain about are not mentioned in the milkshape ascii format. So i gues the only have purpose for the milkshape editor. Did you try filling them with zero's and see how the milkshape editor behaves when loading it. As brainer said when using the ms3d file you dont use those properties.

My gues on referencecount is about on in how many faces an vertex is used.
You may go for an group per material way. Alternative you may try to assemble a meaning like a leg or the head. Again i suggest you experiment with that. Again milkshape ascii only knows smoothing groups and does not use groups so they probeably are just convenient ways to quicky select some faces quickly.

I only have finished an milkshape ascii mesh exporter. But have not yet gotten around to export the skeleton with bones and animations yet.

chronozphere
02-07-2009, 11:03 PM
As far as I can tell, triangles belong to groups and each group can have it's own material. This means that you need to have multiple groups if you want multiple materials, but you can use multiple groups that have the same material.



My gues on referencecount is about on in how many faces an vertex is used.


I second that. I don't see why you would have a refcount field inside a vertex struct for any other reaseon. :)

It seems like a very vague part of the fileformat. I think your best shot is to just expiriment and try to make it work. You can always solidify the source if someone eventually comes up with some answers. :)

paul_nicholls
05-07-2009, 01:07 PM
Thanks all for the replies :)

If you are curious, I am making MS3D importer and exporter plugins for DeleD (www.delgine.com) :)

The importer works on vertices, triangles, and UV coordinates...I still have to make it automatically install the texture into DeleD and use the texture in the model.

Currently I have to manually set the texture to the model, but it works when I do this, so some yay.

The exporter doesn't do much yet, except to show usual importer/exporter DeleD plugin GUI :D

cheers,
Paul

chronozphere
06-07-2009, 07:00 AM
Cool.. The more importers/exporters the better. :D

paul_nicholls
06-07-2009, 01:03 PM
Cool.. The more importers/exporters the better. :D


:)

Oh, I forgot to mention...the ms3d importer and exporter is going to support joints if I can wangle things ok...

cheers,
Paul

tpascal
06-07-2009, 04:33 PM
Hi,

I did a ms3d binary file format reader/writer long time ago.

- Refcount should have to be 0, it is used internally by milkshape and it start with that value.
- You need to have at least one group and assign your data to that group;
- smoothgroup should have to be value 1.
- Note that if you want to include MS3D_VertexEX data you have to put propely the subversion value.

This is a copy of my ms3d reader/writer wich include bones and animations with weight vertex; but it discard comments data; I hope it can be usefull for someone.

http://www.dxtre3d.com/temp/ms3dunit.pas

Note that i dont have idea which is today current ms3d filformat version, but Mete was always carefull not to break backward compatibilty so this reader/writer should work with today ms3d files.

good luck with the bones and animations part of your plugins, it is a realy headache to interpret correct that data if you have not experience with skelatal animations.


Good luck
Tp.

paul_nicholls
07-07-2009, 12:22 AM
Hi,

I did a ms3d binary file format reader/writer long time ago.

- Refcount should have to be 0, it is used internally by milkshape and it start with that value.
- You need to have at least one group and assign your data to that group;
- smoothgroup should have to be value 1.
- Note that if you want to include MS3D_VertexEX data you have to put propely the subversion value.

This is a copy of my ms3d reader/writer wich include bones and animations with weight vertex; but it discard comments data; I hope it can be usefull for someone.

http://www.dxtre3d.com/temp/ms3dunit.pas

Note that i dont have idea which is today current ms3d filformat version, but Mete was always carefull not to break backward compatibilty so this reader/writer should work with today ms3d files.

good luck with the bones and animations part of your plugins, it is a realy headache to interpret correct that data if you have not experience with skelatal animations.


Good luck
Tp.



Thanks tpascal!

It should be quite helpful :)

I'm pretty sure I won't be doing MS3D_VertexEX at all...

cheers,
Paul

paul_nicholls
31-07-2009, 01:12 AM
Hi again guys/gals ;)

I have now gotten my ms3d importer working (including textures, but no joints yet), and my ms3d exporter working (including textures and joints), but I still have a problem...

The exporter only SEEMS to export ok to ms3d animated DeleD objects that only contain joint rotations, but as soon as an animation contains joint translations too, then the output animation is screwed up :(

Looking at the ms3d joint structures:


typedef struct // 16 bytes
{
float time; // time in seconds
float rotation[3]; // x, y, z angles
} ms3d_keyframe_rot_t;

typedef struct // 16 bytes
{
float time; // time in seconds
float position[3]; // local position
} ms3d_keyframe_pos_t;

typedef struct
{
byte flags; // SELECTED | DIRTY
char name[32]; //
char parentName[32]; //
float rotation[3]; // local reference matrix
float position[3];

word numKeyFramesRot; //
word numKeyFramesTrans; //

ms3d_keyframe_rot_t keyFramesRot[numKeyFramesRot]; // local animation matrices
ms3d_keyframe_pos_t keyFramesTrans[numKeyFramesTrans]; // local animation matrices
} ms3d_joint_t;

Does anyone know what sort of positional values go in the position field of the ms3d_keyframe_pos_t structure? Are they absolute values, or are they relative to something else...a joint perhaps?

For example, I discovered that the ms3d_joint_t position field is relative to the parent joint.

So this means that this position is absolute if the joint has no parent, but is an offset from the parent joint position if it exists...

Here are two videos I did of two DeleD animated models exported to ms3d:

Jeroen's Lamp (seems to work ok, and includes BOTH animations back-to-back!)
http://fpc4gp2x.eonclash.com/downloads/lamp_animation/lamp_animation.html

Chronozphere's mech (still not working properly due to joint translations)
http://fpc4gp2x.eonclash.com/downloads/mech_animation/mech_animation.html

Any ideas?

cheers,
Paul

chronozphere
31-07-2009, 08:52 AM
Make a DeleD animation of a cube that translates. This would be a good experiment to find out how you should enter the translation in your datastructures. Just tweak your code until that example works. :)

paul_nicholls
31-07-2009, 10:08 AM
Sounds like a good idea, I will try it :)

cheers,
Paul

mckinnley.workman
12-01-2011, 04:31 PM
Hey! I am writing a chess game program simulation and am in need of chess pieces that I can open with milkshape 3d file (.ms3d). Any idea where I can get it or import it, download it, etc? Thanks McKinnley