C++ MD5 implementation

C++ MD5 implementation

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

C++ MD5 implementation

Post by Agon »

Hello,

I'm working on a MD5 (currently md5mesh only) implementation for spring.

I have some problems to figure out what is what in S3DModel (3DModel.h) and how the "UnitModel-interface" works.
Mainly it is due the lag of comments/documentation (yeah again docs and I know less docs/comments = better programmer) for 3DModel.h and related files...

Due gits log jk wrote this. Jk could you please add more comments or explain me how I can implement my MD5 data structure to the abstract S3DModel?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: C++ MD5 implementation

Post by Kloot »

S3DModel is the common base for 3DO and S3O models. There are no "3DOModel" or "S3OModel" structures because both formats are piece hierarchies (trees), instead the specialization is present in S3DOPiece and SS3OPiece which extend S3DModelPiece (hence the S3DModelPiece* rootobject). MD5 models, being flat lists of meshes that have no parent / child relationships, do not fit in that design so well, so you'll probably want to insert some higher layer of abstraction above it. (For my own implementation I didn't care to do that part.)
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

Re: C++ MD5 implementation

Post by Agon »

Oh did not know that you implemented MD5 in spring, too.
Is it written in Lua or C++?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: C++ MD5 implementation

Post by imbaczek »

for the record, RTCW used piece trees IIRC, and it was using md3, so it's not unexplored ground.
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

Re: C++ MD5 implementation

Post by Agon »

Well so we need a general abstraction level which could be used for flat based model formats like MD5 and for trees/hierarchies like 3DO, S3O...
Or two abstraction levels.... :roll:

Hm, need to study some 3D stuff, thought.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: C++ MD5 implementation

Post by jK »

I don't think we need a new abstraction, AFAIK md5 uses bones which are nothing else than pieces.

But animations need a new system and I don't think adding those is possible with cob. So someone has to code a lua animation system to replace cob. :(
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

Re: C++ MD5 implementation

Post by Agon »

jK wrote:I don't think we need a new abstraction, AFAIK md5 uses bones which are nothing else than pieces.
Hm, I don't understand the construction of "struct S3DModelPiece", atm.

My vector math is a bit rusty (basically general math, too :cry: ) and this also does not help.
I need to relearn it anyway so I will do it next week at work :mrgreen: .

Could someone give me a list of thinks which I need to know like:
- Vector
- Quaternions
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: C++ MD5 implementation

Post by jK »

S3DModelPiece doesn't do any math, it just contains the piece information (max/min dims, offset to parent piece, is empty piece) loaded from the file.
The math is done in LocalModelPiece. It is a local instance of the ModelPiece and contains per unit information of the piece instance (position, rotation, hidden, LODs).
Also it doesn't use Quaternions, it uses simple radians for the rotations.
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

Re: C++ MD5 implementation

Post by Agon »

jK wrote:S3DModelPiece doesn't do any math, it just contains the piece information (max/min dims, offset to parent piece, is empty piece) loaded from the file.
The math is done in LocalModelPiece. It is a local instance of the ModelPiece and contains per unit information of the piece instance (position, rotation, hidden, LODs).
Also it doesn't use Quaternions, it uses simple radians for the rotations.
I know that S3DModel(Piece) contains only informations and don't do any math.
But I need math to turn md5 flat structure to a tree structure.
MD5 uses quaternions.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: C++ MD5 implementation

Post by Kloot »

jK wrote:I don't think we need a new abstraction, AFAIK md5 uses bones which are nothing else than pieces.
Joints actually, the bones are implicit. But each joint only knows its parent joint (not vice versa), so the transformations cannot be applied the same way as in 3DO/S3O.
jK wrote: But animations need a new system and I don't think adding those is possible with cob. So someone has to code a lua animation system to replace cob. :(
Indeed, animation control is the big sticking point. Making a player for them isn't so difficult (mine is mostly done, IIRC I had only blending left to add), but feeding it commands from the simulation would take more effort.


Agon: it's in C++, with a small quaternion library (which I'll integrate into Spring if you plan on continuing your work).
User avatar
Agon
Posts: 527
Joined: 16 May 2007, 18:33

Re: C++ MD5 implementation

Post by Agon »

Kloot wrote: ...
Agon: it's in C++, with a small quaternion library (which I'll integrate into Spring if you plan on continuing your work).
If you already started work on MD5 for spring in C++ I don't need to add another implementation. It would be more efficient to help you or continue your work.
How much did you finished?
Yes, I plan to continue the work, the library would help.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: C++ MD5 implementation

Post by imbaczek »

Kloot wrote:Indeed, animation control is the big sticking point. Making a player for them isn't so difficult (mine is mostly done, IIRC I had only blending left to add), but feeding it commands from the simulation would take more effort.
If I understand correctly, from what little I know a call lua_*-like hack from COB could work... e.g. call md5anim_do_stuff()
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: C++ MD5 implementation

Post by imbaczek »

http://fabiensanglard.net/bumpMapping/index.php

sources include an md5 c++ class.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: C++ MD5 implementation

Post by jK »

instead of such island solutions i would support this:

http://assimp.sourceforge.net/
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: C++ MD5 implementation

Post by imbaczek »

oooh shiny.

that link was posted on reddit, so i only copypasted it here. never doubted there are better options out there ^^ edit: it's BSD...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: C++ MD5 implementation

Post by jK »

License page says:
"ASSIMP is released as Open Source under the terms of a 3-clause BSD license."

the "3-clause BSD license" is a modified BSD license, which is GPL compatible ^-^
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: C++ MD5 implementation

Post by imbaczek »

tried to google it and it wasn't so clear to me, but if it really is compatible, then "^_^" indeed 8)

anyway, how's Kloot's work on md5? did it go out of lua stage?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: C++ MD5 implementation

Post by lurker »

BSD is the one that lets you do anything, even pull it into closed source...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: C++ MD5 implementation

Post by jK »

still the original BSD license is GPL incompatible ;)
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: C++ MD5 implementation

Post by lurker »

But how common is it?
Post Reply

Return to “Engine”