GLBasic forum

Main forum => Off Topic => Topic started by: Kitty Hello on 2009-Jan-08

Title: 3D file format for skeletal animations
Post by: Kitty Hello on 2009-Jan-08
Hi,

please write which file format you prefer, and why.
- Where can you get models from?
- What programs have export filters, that support animation for this format?
- Is there an open source viewer for this format?

Thank you
Title: Re: 3D file format for skeletal animations
Post by: D2O on 2009-Jan-08
Hi Gernot,

das .b3d format oder kompatible ;)
Es gibt viel Plugins für Modeller, Blender, Milkshape, Cinema4D exporter.....
Das format ist weit verbreitet und man findet immer irgendwo was um es zu erstellen

Fileformat:
Code (glbasic) Select
************************************************************************************
*                             Blitz3d file format V0.01                            *
************************************************************************************

This document and the information contained within is placed in the Public Domain.

Please visit http://www.blitzbasic.co.nz for the latest version of this document.

Please contact marksibly@blitzbasic.co.nz for more information and general inquiries.



************************************************************************************
*                                   Introduction                                   *
************************************************************************************

The Blitz3D file format specifies a format for storing texture, brush and entity descriptions for
use with the Blitz3D programming language.

The rationale behind the creation of this format is to allow for the generation of much richer and
more complex Blitz3D scenes than is possible using established file formats - many of which do not
support key features of Blitz3D, and all of which miss out on at least some features!

A Blitz3D (.b3d) file is split up into a sequence of 'chunks', each of which can contain data
and/or other chunks.

Each chunk is preceded by an eight byte header:

char tag[4] ;4 byte chunk 'tag'
int length ;4 byte chunk length (not including *this* header!)

If a chunk contains both data and other chunks, the data always appears first and is of a fixed
length.

A file parser should ignore unrecognized chunks.

Blitz3D files are stored little endian (intel) style.

Many aspects of the file format are not quite a 'perfect fit' for the way Blitz3D works. This has
been done mainly to keep the file format simple, and to make life easier for the authors of third
party importers/exporters.



************************************************************************************
*                                   Chunk Types                                    *
************************************************************************************

This lists the types of chunks that can appear in a b3d file, and the data they contain.

Color values are always in the range 0 to 1.

string (char[]) values are 'C' style null terminated strings.

Quaternions are used to specify general orientations. The first value is the quaternion 'w' value,
the next 3 are the quaternion 'vector'. A 'null' rotation should be specified as 1,0,0,0.

Anything that is referenced 'by index' always appears EARLIER in the file than anything that
references it.

brush_id references can be -1: no brush.

In the following descriptions, {} is used to signify 'repeating until end of chunk'. Also, a chunk
name enclosed in '[]' signifies the chunk is optional.

Here we go!


BB3D
  int version                 ;file format version: default=1
  [TEXS]                      ;optional textures chunk
  [BRUS]                      ;optional brushes chunk
  [NODE]                      ;optional node chunk

The BB3D chunk appears first in a b3d file, and its length contains the rest of the file.

Version is in major*100+minor format. To check the version, just divide by 100 and compare it with
the major version your software supports, eg:

if file_version/100>my_version/100
   RuntimeError "Can't handle this file version!"
EndIf

if file_version Mod 100>my_version Mod 100
   ;file is a more recent version, but should still be backwardly compatbile with what we can
handle!
EndIf


TEXS
  {
char file[]                 ;texture file name
  int flags,blend             ;blitz3D TextureFLags and TextureBlend: default=1,2
float x_pos,y_pos           ;x and y position of texture: default=0,0
float x_scale,y_scale       ;x and y scale of texture: default=1,1
float rotation              ;rotation of texture (in radians): default=0
  }

The TEXS chunk contains a list of all textures used in the file.

The flags field value can conditional an additional flag value of '65536'. This is used to indicate that the texture uses secondary UV values, ala the TextureCoords command. Yes, I forgot about this one.


BRUS
  int n_texs
  {
  char name[]                 ;eg "WATER" - just use texture name by default
  float red,green,blue,alpha  ;Blitz3D Brushcolor and Brushalpha: default=1,1,1,1
  float shininess             ;Blitz3D BrushShininess: default=0
  int blend,fx                ;Blitz3D Brushblend and BrushFX: default=1,0
  int texture_id[n_texs]      ;textures used in brush
  }

The BRUS chunk contains a list of all brushes used in the file.


VRTS:
  int flags                   ;1=normal values present, 2=rgba values present
  int tex_coord_sets          ;texture coords per vertex (eg: 1 for simple U/V) max=8
  int tex_coord_set_size      ;components per set (eg: 2 for simple U/V) max=4
  {
  float x,y,z                 ;always present
  float nx,ny,nz              ;vertex normal: present if (flags&1)
  float red,green,blue,alpha  ;vertex color: present if (flags&2)
  float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords
  }

The VRTS chunk contains a list of vertices. The 'flags' value is used to indicate how much extra
data (normal/color) is stored with each vertex, and the tex_coord_sets and tex_coord_set_size
values describe texture coordinate information stored with each vertex.


TRIS:
  int brush_id                ;brush applied to these TRIs: default=-1
  {
  int vertex_id[3]            ;vertex indices
  }

The TRIS chunk contains a list of triangles that all share a common brush.


MESH:
  int brush_id                ;'master' brush: default=-1
  VRTS                        ;vertices
  TRIS[,TRIS...]              ;1 or more sets of triangles

The MESH chunk describes a mesh. A mesh only has one VRTS chunk, but potentially many TRIS chunks.


BONE:
  {
  int vertex_id               ;vertex affected by this bone
  float weight                ;how much the vertex is affected
  }

The BONE chunk describes a bone. Weights are applied to the mesh described in the enclosing ANIM -
in 99% of cases, this will simply be the MESH contained in the root NODE chunk.


KEYS:
  int flags                 ;1=position, 2=scale, 4=rotation
  {
  int frame                   ;where key occurs
  float position[3]           ;present if (flags&1)
  float scale[3]              ;present if (flags&2)
  float rotation[4]           ;present if (flags&4)
  }

The KEYS chunk is a list of animation keys. The 'flags' value describes what kind of animation
info is stored in the chunk - position, scale, rotation, or any combination of.


ANIM:
  int flags                   ;unused: default=0
  int frames                  ;how many frames in anim
  float fps                   ;default=60

The ANIM chunk describes an animation.


NODE:
  char name[]                 ;name of node
  float position[3]           ;local...
  float scale[3]              ;coord...
  float rotation[4]           ;system...
  [MESH|BONE]                 ;what 'kind' of node this is - if unrecognized, just use a Blitz3D
pivot.
  [KEYS[,KEYS...]]            ;optional animation keys
  [NODE[,NODE...]]            ;optional child nodes
  [ANIM]                      ;optional animation

The NODE chunk describes a Blitz3D Entity. The scene hierarchy is expressed by the nesting of NODE
chunks.

NODE kinds are currently mutually exclusive - ie: a node can be a MESH, or a BONE, but not both!
However, it can be neither...if no kind is specified, the node is just a 'null' node - in Blitz3D
speak, a pivot.

The presence of an ANIM chunk in a NODE indicates that an animation starts here in the hierarchy.
This allows animations of differing speeds/lengths to be potentially nested.

There are many more 'kind' chunks coming, including camera, light, sprite, plane etc. For now, the
use of a Pivot in cases where the node kind is unknown will allow for backward compatibility.



************************************************************************************
*                                    Examples                                      *
************************************************************************************

A typical b3d file will contain 1 TEXS chunk, 1 BRUS chunk and 1 NODE chunk, like this:

BB3D
  1
  TEXS
    ...list of textures...
  BRUS
    ...list of brushes...
  NODE
    ...stuff in the node...

A simple, non-animating, non-textured etc mesh might look like this:

BB3D
  1                           ;version
  NODE
    "root_node"               ;node name
    0,0,0                     ;position
    1,1,1                     ;scale
    1,0,0,0                   ;rotation
    MESH                      ;the mesh
      -1                      ;brush: no brush
      VRTS                    ;vertices in the mesh
        0                     ;no normal/color info in verts
        0,0                   ;no texture coords in verts
        {x,y,z...}            ;vertex coordinates
      TRIS                    ;triangles in the mesh
        -1                    ;no brush for this triangle
        {v0,v1,v2...}         ;vertices


A more complex 'skinned mesh' might look like this (only chunks shown):

BB3D
  TEXS                        ;texture list
  BRUS                        ;brush list
  NODE                        ;root node
    MESH                      ;mesh - the 'skin'
    ANIM                      ;anim
    NODE                      ;first child of root node -  eg: "pelvis"
      BONE                    ;vertex weights for pelvis
      KEYS                    ;anim keys for pelvis
      NODE                    ;first child of pelvis - eg: "left-thigh"
        BONE                  ;bone
        KEYS                  ;anim keys for left-thigh
      NODE                    ;second child of pelvis - eg: "right-thigh"
        BONE                  ;vertex weights for right-thigh
        KEYS                  ;anim keys for right-thigh

...and so on.



Ansonsten ist ja eigendlich das .3ds format schon standart.

MD2, hat aber keine Bones

Das Mikshape eigene Formad .ms3d
exportier auch einen ASCII Code.
http://chumbalum.swissquake.ch/ms3d/download.html (http://chumbalum.swissquake.ch/ms3d/download.html)

Wie schauts mit dem AC3d format, kann das Bones ?? (nutz aber kein andere Modeller)
Title: Re: 3D file format for skeletal animations
Post by: doimus on 2009-Jan-08
FBX and Collada are basically industry standard these days.

Title: Re: 3D file format for skeletal animations
Post by: mathux on 2009-Jan-08
Yes, I second FBX or Collada but afaik they can be a real pain to support right (and Collada seems more like a information preserving file format for 3D modells and not like a optimized format for ingame use but I may be mistaken).
Of course, the B3D is pretty often used in the Blitzers scene, other than that there would be the gmf file format from the Leadwerks engine but I don't know if that is good (there is a UU3D exporter and a b3d2gmf tool and the author of Leadwerks is currently working on a FBX->GMF converter).

Links:

FBX: http://www.autodesk.de/adsk/servlet/index?siteID=403786&id=6962322 (http://www.autodesk.de/adsk/servlet/index?siteID=403786&id=6962322)
Collada: http://www.collada.org/mediawiki/index.php/Main_Page (http://www.collada.org/mediawiki/index.php/Main_Page)
B3D: http://www.blitzbasic.com/sdkspecs/sdkspecs.php (http://www.blitzbasic.com/sdkspecs/sdkspecs.php)
GMF: http://www.leadwerks.com/wiki/index.php?title=Game_Model_Format#Specification (http://www.leadwerks.com/wiki/index.php?title=Game_Model_Format#Specification)
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2009-Jan-08
OK, it seems there's just no proper file format for games. I'll go for b3d then.

Can someone please make me a program, that loads a "test.b3d" file, displays it, and advances the animation keyframes with the left/right cursor keys, please? I need the .exe for checking what I get and what it should be like.

Thank you.
Title: Re: 3D file format for skeletal animations
Post by: mathux on 2009-Jan-08
Well, I would do that if I just had Blitz3D  :zzz:
Title: Re: 3D file format for skeletal animations
Post by: Schranz0r on 2009-Jan-08
Hmm... nimm 3ds!
Ist sehr verbreitet, kann sogut wie jedes Modelierungsprogramm impotieren und exportieren
z.B Programme wie Blender und Anim8or(freeware) !
Das als Astreine interne Ladefunktion mit Keyframe oder sogar Boneanimation und 3D in GLB geht gleich auf einen ganz anderen Level, glaubs mir!
Wenn du Hilfe brauchst, ich helfe dir gerne :)
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2009-Jan-08
3ds hat keine bones, oder?
Title: Re: 3D file format for skeletal animations
Post by: D2O on 2009-Jan-08
Ich hab mal etwas zusammen geklickt  :whistle:
Ich hoffe das hift Dir etwas, ich selber bin halt einfach ein 3D noob  :S

Das Modell ist aus dem Internuversum :)

Mit der Pfeiltasten oben/unten   wird gedreht.
Mit links/rechts die Animation gestartet.

www.deuteriumoxid.com/glbasic/b3d.zip (http://www.deuteriumoxid.com/glbasic/b3d.zip)
Title: Re: 3D file format for skeletal animations
Post by: bigsofty on 2009-Jan-09
Milkshape 3D (.MS3D)is quite a good boned format.

   1. Mesh geometry with vertex normals and vertex uv texture coordinates
   2. Materials
   3. Texture maps
   4. Skeletons (bones)
   5. Mesh skinning weights and associations (deformation of meshes by bones)
   6. Animation

It has an ASCI version and well as a binary version. I would say it has slightly better support than B3D.


Title: Re: 3D file format for skeletal animations
Post by: Schranz0r on 2009-Jan-09
Ohhhhhh... 3DS has no bones, right!

@ bigsofty:

MS3D, good idea! :zzz:
Title: Re: 3D file format for skeletal animations
Post by: bigsofty on 2009-Jan-09
A simple solution would simply be to add support for the AssImp library (http://assimp.sourceforge.net/lib_html/index.html).

QuoteASSIMP is a library to load and process geometric scenes from various data formats. It is taylored at typical game scenarios by supporting a node hierarchy, static or skinned meshes, materials, bone animations and potential texture data.

ASSIMP is able to import the following file formats into your application:
3D Studio Max 3DS ( *.3ds )
3D Studio Max ASE ( *.ase )
Wavefront Object ( *.obj )
Stanford Polygon Library ( *.ply )
Milkshape 3D ( *.ms3d ) 1
AutoCAD DXF ( *.dxf ) 2
Neutral File Format ( *.nff )
LightWave ( *.lwo )
Valve Model ( *.smd,*.vta ) 3
Quake I ( *.mdl )
Quake II ( *.md2 )
Quake III ( *.md3 )
Return to Castle Wolfenstein ( *.mdc )
EliteForce II ( *.mdr )1
Doom 3 ( *.md5 ) 3
DirectX X ( *.x ).
3D GameStudio ( *.mdl )
3D GameStudio Terrain ( *.hmp )
(All sub versions of 3D GameStudio models/terrains are supported: mdl2, mdl3, mdl4, mdl5, mdl7, hmp4, hmp5, hmp7)

1 Under development, but not included in the current beta release
2 Limited support
3 Animation support untested

Its quite a good library, being used by a few engines.

Title: Re: 3D file format for skeletal animations
Post by: bigsofty on 2009-Jan-09
Meant to say SVN version has full .B3D support too. ;)
Title: Re: 3D file format for skeletal animations
Post by: Hemlos on 2009-Jan-10
I thought 3d studio max has bones .3ds ..

research:
http://www.spoono.com/3ds/tutorials/tutorial.php?id=7

Also, 3ds is a common export model type for many 3d modelling programs, including some free ones like 'anim8or'.

Title: Re: 3D file format for skeletal animations
Post by: FutureCow on 2009-Jan-13
Do you still need that program Gernot?
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2009-Jan-13
Might be good to have it, yes.
Although you should not expect it to be available too soon. I've got lots of other stuff on my desk, too.
Title: Re: 3D file format for skeletal animations
Post by: FutureCow on 2009-Jan-13
Hmmm... I've got very little 3d experiencel but thought this would be a simple one.

It appears that B3d has the capability to play a full animation sequence and to stop an in-progress animation sequence, but not to advance frame by frame through it.
I could create a program to load multiple single frame animations and then play each animation sequence (ie a single frame) in order when you pressed a key.
Would that work?
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2009-Jan-13
yes, great. I just need it to see if I swapped arms and legs by coincident.
Title: Re: 3D file format for skeletal animations
Post by: FutureCow on 2009-Jan-19
Sorry Gernot, I'm not getting much time on the computer at home. I'll do this when I can.
Title: Re: 3D file format for skeletal animations
Post by: jessejohnston on 2010-May-08
Do you still need this? I can help you
Title: Re: 3D file format for skeletal animations
Post by: NRasool on 2010-May-21
Hi Kitty

Any chance of letting us know if .b3d is going to be supported soon? Like Kurgan I also have a lot of b3d files, so it would be great if you added support for .b3d  =D
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2010-May-31
No, not in close future. Use blender to convert.
Title: Re: 3D file format for skeletal animations
Post by: toprngr on 2010-Aug-11
I would have to say that there are actually a quite a number of file formats that could support what you are doing here. But there are quite a few common ones and there is no specific file format that is specifically assigned to this task of yours. In fact, b3d is one of the file formats that are commonly used. I recommend you to start working on that first and see how it work out later.
Title: Re: 3D file format for skeletal animations
Post by: sluff-bucket on 2010-Dec-20
Any news on this B3D support? I'm asking because I am planning my second game and so far would like to use GLbasic - but the lack of skeletal animation is an awful restriction :(
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2010-Dec-20
I won't get skeletons in that quickly, sorry.
Title: Re: 3D file format for skeletal animations
Post by: sluff-bucket on 2010-Dec-20
Thanks for the swift reply, but what do you mean by 'that quickly'? Is the work to implement B3D a reality? Is it happening now? If so, can you give me a rough estimate (be generous) for when you think it might be ready?

I'm sorry to gnaw at you like this - but I'm dithering about what to do, which way to go and how etc. right now, and I have a big publisher snapping at my heels for a new game after publishing the first. Blitz3D has stagnated and Bmax is too much hassle for cross platform 3D (as well as too thinly spread out) for a small developer. Not that this is of interest to you I suppose, but I'd like you to know where I'm coming from. GLbasic seems to be very, very impressive.

I need to hammer out a plan and schedule.
Title: Re: 3D file format for skeletal animations
Post by: Kitty Hello on 2010-Dec-20
I can't make any promise on that. I'm really sorry.
Is bone animation really such a must feature for you?
Title: Re: 3D file format for skeletal animations
Post by: sluff-bucket on 2010-Dec-20
It's an almost vital part where animations are concerned yes.. I need to find bones, attach objects, spawn particles etc.

The characters for the game I'm planning are very simple by normal standards, but even so - direct control over bones really simplifies things. Accurate bipedal collisions will be needed in some situations.

I can imagine how I can make work arounds, but I can also see the workload becomes exponential and really slows the whole development process down the more control and access I 'might' require to animated meshes.

Bones really helped me in my previous project - from picking things up to putting on new boots. Again my new game will be a simpler for more cross-platform compatabilty,  but to know at any moment further down the development road I can access any skeletal hierachy and do stuff to it is a hefty weight off anybody's mind I think. This MD2 type of frame by frame stuff is very limited from what I can see - also, the anim files in B3D are so compact!

Anyhow - I'm not knocking GLbasic at all, it seems to be a fantastic - in fact a breath-taking indie game language from what I've seen so far. Animations seem very limited without skeletons that's all. I can see lots of people here have no problems with it, but for me, to turn around and tell this publisher that I can't blend anims or access an animated hierarchy with out some memory & time consuming work arounds (as far as I know presently)... well they won't understand.

Still, that's my problem and I respect the fact you can't give everybody everything they whine about :)
Title: Re: 3D file format for skeletal animations
Post by: Vampire on 2011-May-25
Was ist daraus geworden, Gernot?
haste völlig abgehakt?