Quote:Original post by Buckeye
The first bytes in a data file should specifiy the format. For consistency, use four unsigned character bytes and use ASCII. Format specific information like version numbers, etc., can come after that. That supports a more universal and quick check if the file being loaded is the format expected.
Good point, I will add that in.
Quote:If this is to support cross-platform use, you should define whether it uses big-endian or little-endian storage, either as part of the spec or as a flag in the file itself.
I was going to leave that for later, but you're right. Do you think it should be big-endian or little-endian?
Quote:Also, if cross-platform is intended, you need to define all data types in terms of number of bytes. E.g., you didn't define "ushort."
Agreed, I'll correct this.
Quote:Probably not important: You should define whether wide-character support is supported or not or just make the flat statement that all characters are ASCII.
OK, I think I'll stick to just ascii at this point.
Quote:Is there a reason to specify all counts as signed integers? In particular, if you specify "signed" for all indices, then you can't take full advantage of 32-bit index buffers.
By "counts" I meant the number of indices (and verices, materials, etc.) not the indices themselves. I decided on signed ints because that is the type used most often by most programmers, so I figured I would use it unless I have a really good reason not to.
By the way, I was going to use 16-bit indices, but you're right that using 32-bit would be more flexible. I think I'll also add a flag indicating if the indices are 16-bit or not.
Quote:You need to specify whether the model is in a right-hand or left-hand system. There have been no end of problems with mesh file formats in this regard. SMD and several other formats, for instance, are right-handed. X-files are left-handed (one of the few).
Right-hand and left-hand would apply to how matrices are to be handled, also.
Good point. Since I'm using D3D (and I think the way the data is arranged is more D3D friendly than OpenGL) I'll use a left-handed system and the D3D matrix layout.
Quote:for each vertex
If the intent is to support static meshes, or for quick testing, you should add a color to each vertex.
OK.
Quote:By specifying "ubyte" for the bone indices, you're restricting the influences to the first 256 bones. That's probably sufficient[ATTENTION] [SMILE] but for a consistent format, the bone index data-type should match the "num bones" data-type.
I'm not sure why that would be more consistent, but are saying I should change the type of "num bones" or the bone indices themselves?
Quote:It appears that you're limiting the max bone influences per vertex to 4. That's probably sufficient but not flexible. See next comment.
I've just always heard that 4 is enough in practice, but I guess it wouldn't hurt to change this.
Quote:You need something to indicate the number of bone influences for a vertex, even if you require the storage space for unused influences. Otherwise, it will require unnecessary testing or looping. If you intend that bone weights will be 0 to flag "non-influences," then either the loading code will have to count the number of bone weights > 0 to determine the number of bone influences, or the animation loop will have to access bone matrices it's not going to use and do a lot of multiplications by 0.
But that's exactly what "num bone influences" is for?
Quote:num indices
See comment above about matching data-types. "num indices" is signed int, actual indices are ushort. "num indices" and actual indices should probably be unsigned 32bit if you want to support 32bit index buffers.
About the indices, I agree, but I'm not sure why it's important that "num indices" be unsigned as well?
Quote:num parts
Are these subsets of the mesh? If so:
If you intend that the format supports indexed meshes, then you shouldn't specify start index and count for vertices and indices. This forces duplicate vertices which might be a good thing to avoid. Many vertices will be shared between subsets in an indexed mesh.
A subset need only be defined by vertex indices and a material. Those indices will not be in serial order.
Maybe:
for each part: number of indices, list of indices
OK, I'll remove the offset and count for the vertices. I just used them since they are specified in D3DXATTRIBUTERANGE, but I guess there's no real need for them.
By the way, should I store all indices in one big list and specify an offset and a count for each part, or should each part contain a list of its indices?
Quote:num bone influences
Why not just "0" or "1" as a flag? The number of influences is per-vertex anyway.
Are you saying that each vertex should be able to have a different number of bone influences? Wouldn't that make vertex blending much slower? Actually wouldn't it require VS 3.0 to implement?
Quote:num palette entries and num bones
Any reason to have these separate?
Yes - the former is sometimes smaller than the latter. At least it has been for all the models I tried. I guess the reason for this is that not all bones are indexed by vertices. They only exist to serve as parents for other bones or to allow objects (like a weapon) to be attached to the model.
Quote:If they're separate, it'll require the loading code to do string searches to match up offsets with locals, etc. In general, the format should support minimizing loading code burden. The file is created once but it may be loaded many times.
Yes, but if my previous comment is correct, this is unavoidable.
Quote:How about adding a "parent" index for each bone? That will allow more flexibility in the loading and animation code. I.e., if I want to determine the combined matrix of a bone, I would otherwise have to search all bones to find the bone that has that bone as a child. That, also, relieves some of the burden from the application.
But each bone always stores its associated combined transform (in the runtime structures, not in the file), and it's always up to date because you recursively update the bone hierarchy before using any of the bones. Unless having a parent index can be useful for something else?
Quote:animation frames
You separate all the quats from the vectors, etc. It's true that supports a minimization of storage but requires bookkeeping on the part of the loading app to keep track of 3 different lerps that may or may not have the same time key. Putting all the information for each time-step in one structure requires more storage but simplifies the animation code.
That's what I wanted to do. But looking at the keyframe data for some of the models I used, some of the quat keyframes had a different timestamp than the vector keyframes, so I can't really collapse them into one structure with just one timestamp.
Quote:Quote:Should there be an offset table specifying the offset to the vertices/indices/etc. from the beginning of the file?
I wouldn't think that would be useful. It'll just put more burden on the loading code and allow additional errors.
It would be handy if you wanted to load just the skeleton data or just the animation data.
Quote:Quote:Should the data be stored in several files?
You might want to consider having an "animation-only" flag for the file so animations could be stored and loaded separately. Animations can be applied to different meshes (provided the meshes were developed with the same bone hierarchy, which is common).
That's why I wanted to use the offset table. I'm not sure how you would do this using just a flag.
BTW, I also need to come up with an extension for the file name. I thought about SAM (Simple Animated Model), but I'd love to hear some other suggestions.
Also, I'd love to hear more opinions about what material properties I should store, and if I should store them in a separate file or not.