# -------------------------------------------------------------------------- 
# MHX (MakeHuman eXchange format) specification.
# Thomas Larsson
# email: thomas_larsson_01@hotmail.com
# -------------------------------------------------------------------------- 
# ***** BEGIN GPL LICENSE BLOCK ***** 
# 
# This program is free software; you can redistribute it and/or 
# modify it under the terms of the GNU General Public License 
# as published by the Free Software Foundation; either version 2 
# of the License, or (at your option) any later version. 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the 
# GNU General Public License for more details. 
# 
# You should have received a copy of the GNU General Public License 
# along with this program; if not, write to the Free Software Foundation, 
# Inc., 59 Temple Place - Suite 330, Boston, MA	02111-1307, USA. 
# 
# ***** END GPL LICENCE BLOCK ***** 
# -------------------------------------------------------------------------- 


The purpose of the MHX format is to allow transfer of information between MakeHuman and Blender.
More generally, it can be used to export and import Blender scenes for use with any external
application. Ultimately the goal is to make MHX into a .blend file in Ascii format.


Syntax:

MHX allows for the following syntactic constructs:

# A comment (ignored).

A-one-line statement with-four-items separated-by-blanks ;

A-multi-line statement
   ...
   ...
end A-multi-line


Semantics:

An MHX file contains the following information from the Blender file:
	groups
	ipos
	actions
	textures
	materials
	objects
It is important that the items appear in this order.
An object is listed as two blocks: data, object.

The information is encoded in the following language constructs, which hopefully are self-explanatory.
"Other variables" have the same names and values as the corresponding Blender instance variables, 
cf. the Blender documentation.


MHX MajorVersion MinorVersion ;
Identifies the MHX version. Current version is 0 2. It is not compatible with previous versions.

#
#	Group
#

group Name
	object ObjectName ;
	...
	object ObjectName ;
	Other variables
end group

#
#	Ipo and action
#

ipo Type Name
	Icu
	...
	Icu
end ipo

icu Name Extend Interpolation
	bz2 Point (= H1x H1y Px Py H2x H2y)
	...
	bz2 Point
	Other variables
end icu

action Name
	ipo IpoName
	...
	ipo IpoName
end action

#
#	Material and texture
#

material Name
	MTex
	...
	MTex
	Colorband Diffuse
	Colorband Specular
	Other variables
end material

mtex Index TextureName
	Other variables
end mtex

texture Type Name
	Image 
	Colorband
	Other variables
end texture

image Name
	filename FileName ;
	Other variables
end image

#
#	Mesh
#

mesh Name ObjectName
	material MaterialName ;
	...
	material MaterialName ;

	v X Y Z ; (vertex coordinate)
	...
	v X Y Z ;

	vt X Y ; (UV coordinate)
	...
	vt X Y ;

	f V1 V2 V3 V4 ; (face vert numbers)
or	f V1 V2 V3 ;
or	f V1/VT1 V2/VT2 V3/VT3 V4/VT4 ; (face and UV vert numbers)
or	f V1/VT1 V2/VT2 V3/VT3 ;
	...
	f V1... ;

	ft FaceIndex Flag, Mode, Transp, Mat, Smooth ; (for textured faces)
	...
	ft FaceIndex Flag, Mode, Transp, Mat, Smooth ;
or	ftall Flag, Mode, Transp, Mat, Smooth ; (assign to all faces)

	fx FaceIndex Mat, Smooth ; (for untextured faces)
	...
	fx FaceIndex Mat, Smooth ;
or	fxall Mat, Smooth ; (assign to all faces)
	
	e V1 V2 ; (edge.v1 and edge.v2)
	...
	e V1 V2 ;
	
	VertGroup
	...
	VertGroup

	ShapeKey
	...
	ShapeKey

	Other variables
end mesh

shapekey Name SliderMin SliderMax VertgroupName
	sv VertIndex dX dY dZ ;
	...
	sv VertIndex dX dY dZ ;
end shapekey
	
vertgroup Name
	wv VertIndex Weight ;
	...
	wv VertIndex Weight ;
end vertgroup

#
#	Armature and pose
#

armature ArmatureName ObjectName
	Bone 
	...
	Bone
	Other variables
end armature

bone Name ParentName Flags LayerMask
	head X Y Z
or	head joint JointName
or	head joint JointName + DX DY DZ
	tail X Y Z
or	tail joint JointName
or	tail joint JointName + DX DY DZ
	Other variables
end bone

joints
	j JointName X Y Z ;
	...
	j JointName X Y Z ;
end joints

pose Name
	Posebone
	...
	Posebone
end pose

posebone Name Flags
	Other variables
	Constraint
	...
	Constraint
end posebone

#
#	Other data types
#

lattice Name
	partitions X Y Z ;
	keytypes X Y Z ;
	Other variables
end lattice

lamp Type Name
	texture Index TextureName ;
	...
	texture Index TextureName ;
	Other variables
end lamp

camera Type Name
	Other variables
end camera

curve Name
	Nurb
	...
	Nurb
	Material MaterialName ;
	...
	Material MaterialName ;
	Other variables
end curve

nurb poly/bezier/nurbs
	pt X Y Z W Tilt (poly) ;
or	pt H1x H1y H1z Px Py Pz H2x H2y H2z (bezier) ;
or	pt X Y Z W Tilt (nurbs) ;
	...
	pt ...
end nurb

text Name
	line String ;
	...
	line String ;
	Other variables
end text

key Name
	Block
	...
	Block
	Other variables
end key

block Name
end block

#
#	Object
#

object Name Type DataName
	layers Layer1-10 Layer11-20 ;
	parent ParentObject ParentType ParentBone/ParentVerts/None ;
	ipo IpoName ;
	Other variables
	Constraints
	Particles
	Modifiers
end object

particle Name
	Other variables
	material MaterialName ;
	vertgroup Affects Name ;
	...
	vertgroup Affects Name ;
end particle

constraint Type Name Influence
	Setting ValueType Value ;
	...
	Setting ValueType Value ;
end constraint

modifier Type Name Influence
	Setting ValueType Value ;
	...
	Setting ValueType Value ;
end modifier

Setting is one of Blender.Constraint.Settings and Value its value. 
ValueType Value can be one of 
	list Nelts ValueType1 Value1 ... ValueTypeN ValueN
	int Int
	hex Int
	float Float
	bool true/false
	str String
	vec X Y Z
	obj ObjectName
	ipo IpoName
	act ActionName
	tex TextureName
	text TextName	
	
	

This specification is subject to changes without notice. However, the MHX format is approaching 
its final form and the main features are not expected to change so much in the future.








