Skip to content

Version 0.3 (draft)

Xoppa edited this page Feb 15, 2015 · 1 revision

Changes:

  • Overall: allow integer instead of string for enums (e.g. for GL_ values), mostly useful for g3db
  • Attribute: more flexible (allow specify size, type, index etc)
  • Material: move textures to the root (todo: add texture region support)
  • Material: use Material.Attribute alias as key and allow user definable values
  • Animation: add material-animation
<root>:
{
	"version": [<integer>, <integer>]
	("meshes": [(<mesh> (, <mesh>)*)?])?
	("textures": [(<texture> (, <texture>)*)?]?
	("materials": [(<material> (, <material>)*)?])?
	("nodes": [(<node> (, <node>)*)?])?
	("animations": [(<animation> (, <animation>)*)?])?
}

<rgb>:
	[<float>, <float>, <float>]
<rgba>:
	[<float>, <float>, <float>, <float>]
<color>:
	<rgb> | <rgba>
<xyz>:
	[<float>, <float>, <float>]
<xyzw>:
	[<float>, <float>, <float>, <float>]
<quaternion>:
	<xyzw>

<mesh>:
{
	"attributes": [<atribute> (, <attribute>)*],
	"vertices": [(<vertex> (, <vertex>)*)?],	// amount = <vertexcount>
	"parts": [(<meshpart> (, <meshpart>)*)?]
}

<attribute>: 
{
	"usage": <attribute-usage>,
	"size": <integer> // size in number of floats
	("index": <integer>)? // zero-based usage identifier, default: auto-increment on same usage
	("type": <attribute-type>)? // default "FLOAT"
	("components": <integer>)? // default: sizeof(float) * size / sizeof(type)
	("normalize": <bool>)? // default: type != "FLOAT"
}

<attribute-usage>:
	  <integer> // See VertexAttributes.Usage
	| "POSITION" | "NORMAL" | "COLOR" | "COLORPACKED" | "TANGENT" | "BINORMAL" | "TEXCOORD" | "BLENDWEIGHT"
<attribute-type>:
	  <integer> // A GL_ enum value
	| "BYTE" | "UNSIGNED_BYTE" | "SHORT" | "UNSIGNED_SHORT" | "FIXED" | "FLOAT"

<vertex>:
	(<float> (, <float>)*) // amount = <vertexsize>

<mesh-part>:
{
	"id":	<mesh-part-id>,
	"type":	<primitive-type>,
	"indices": [(<index> (, <index>)*)?]
}

<mesh-part-id>: string // unique for all meshparts within the file

<primitive-type>:
	  <integer> // A GL_ enum value
	| "TRIANGLES" | "LINES" | "POINTS" | "TRIANGLE_STRIP" | "LINE_STRIP"

<index>: integer // 0 <= <index> < <vertexcount>

<texture>:
{
	"id": <texture-id>,
	"filename": <string>
}

<texture-id>: string // unique for each texture

<material>:
{
	"id": <material-id>
	(<attribute-alias>: <attribute-value>)*
}

<material-id>: string // unique for all materials within the file

<attribute-alias>: 
	  <blending-attribute>
	| <color-attribute>
	| <cubemap-attribute>
	| <depthtest-attribute>
	| <float-attribute>
	| <int-attribute>
	| <texture-attribute>
	| <string> // user-definable

<attribute-value>: 
	  <blending-attribute-value>
	| <color-attribute-value>
	| <depthtest-attribute-value>
	| <float-attribute-value>
	| <int-attribute-value>
	| <texture-attribute-value>
	| <???> // user-definable value

<blending-attribute>:
	"blended"
<blending-attribute-value>:
{
	("blended": <bool>)? // default: true
	("opacity": <float>)? // default: 1.0
	("source": <blend-function>)? // default SRC_ALPHA
	("destination": <blend-function>)? // default ONE_MINUS_SRC_ALPHA
}
<blend-function>:
	  <integer> // A GL_ enum value
	| "SRC_ALPHA" | "ONE_MINUS_SRC_ALPHA" // FIXME: Add others

<color-attribute>: 
	"diffuseColor" | "specularColor" | "ambientColor" | "emissiveColor" | "reflectionColor"
<color-attribute-value>:
	<color>

<depthtest-attribute>:
	"depthStencil"
<depthtest-attribute-value>:
{
	("function": <depth-function>)? // default LEQUAL
	("near": <float>)? // default: 0.0
	("far": <float>)? // default: 1.0
	("write": <bool>)? // default: true
}
<depth-function>:
	  <integer> // A GL_ enum value
	| "LEQUAL" // FIXME: Add other functions

<float-attribute>:
	"shininess" | "alphaTest"
<float-attribute-value>:
	<float>

<int-attribute>:
	"cullface"
<int-attribute-value>:
	  <integer>
	| "FRONT" | "BACK" | "FRONT_AND_BACK" | "NONE"

<texture-attribute>:
	"diffuseTexture" | "specularTexture" | "bumpTexture" | "normalTexture"
<texture-attribute-value>:
	<texture-id>

<node>:
{
	"id": <node-id>
	("translation": <xyz>)?
	("rotation": <quaternion>)?
	("scale": <xyz>)?
	("mesh": <string>)? // DEPRECATED
	("parts": [(<node-part> (, <node-part>)*)?])?
	("children": [(<node> (, <node>)*)?])?
}

<node-id>: string // unique for each node

<node-part>:
{
	"meshpartid": <mesh-part-id>,
	"materialid": <material-id>
	("bones": [(<bone> (, <bone>)*)?])?
	("uvMapping": [(<uv-mapping> (, <uv-mapping>)*)?])?
}

<bone>:
{
	"node": <nodeid>,
	(, "translation": <xyz>)?
	(, "rotation": <quaternion>)?
	(, "scale": <xyz>)?
}

<uv-mapping>: [(<integer> (, <integer>)*)?])?

<animation>:
{
	"id": <animation-id>
	("nodes": [(<node-animation> (, <node-animation>)*)?])?
	("materials": [(<material-animation> (, <material-animation>)*)?])?
}

<node-animation>:
{
	"node": <node-id>,
	"keyframes": [(<node-keyframe> (, <node-keyframe>)*)?]
}

<node-keyframe>:
{
	"keytime": <float>
	("translation": <xyz>)
	("rotation": <quaternion>)
	("scale": <xyz>)
}

<material-animation>:
{
	"material": <material-id>,
	"keyframes": [(<material-keyframe> (, <material-keyframe>)*)?]
}

<material-keyframe>:
{
	"keytime": <float>
	(<attribute-alias>: <attribute-value>)*
}
Clone this wiki locally