Skip to content

Version 0.2 (draft)

Xoppa edited this page Feb 15, 2015 · 13 revisions

Changes compared to version 0.1: focuses solely on better animation support.

  • Node animations are separated in keyframes per component.

The G3DB and G3DJ file format, version 0.2

<root>:
{
	"version": [<majorversion>, <minorversion>]
	(, "meshes": [(<mesh> (, <mesh>)*)?])?
	(, "materials": [(<material> (, <material>)*)?])?
	(, "nodes": [(<node> (, <node>)*)?])?
	(, "animations": [(<animation> (, <animation>)*)?])?
}

<majorversion>: integer // always 0

<minorversion>: integer // always 2

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

<attribute>: "POSITION"	| "NORMAL" | "COLOR" | "COLORPACKED" | "TANGENT" | "BINORMAL" | "TEXCOORD" | "BLENDWEIGHT"

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

<meshpart>:
{
	"id":	<meshpartid>,
	"type":	<primitivetype>,
	"indices": [(<index> (, <index>)*)?]
}

<meshpartid>: string // unique for all meshparts within the file

<primitivetype>: "TRIANGLES" | "LINES" | "POINTS" | "TRIANGLE_STRIP" | "LINE_STRIP"

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

<material>:
{
	"id": <materialid>
	(, "diffuse": <rgb>)?
	(, "ambient": <rgb>)?
	(, "emissive": <rgb>)?
	(, "specular": <rgb>)?
	(, "reflection": <rgb>)?
	(, "shininess": <float>)?
	(, "opacity": <float>)?
	(, "textures": [(<texture> (, <texture>)*)?])?
}

<materialid>: string // unique for all materials within the file

<rgb>: [<float>, <float>, <float>]

<texture>:
{
	"id": <textureid>,
	"filename": <string>,
	"type": <texturetype>
	(, "uvTranslation": [<float>, <float>])?
	(, "uvScaling": [<float>, <float>])?
}

<textureid>: string // unique for each texture-file

<texturetype>: "AMBIENT" | "BUMP" | "DIFFUSE" | "EMISSIVE" | "NONE" | "NORMAL" | "REFLECTION" | "SHININESS" | "SPECULAR" | "TRANSPARENCY"

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

<nodeid>: string // unique for each node

<xyz>: [<float>, <float>, <float>]

<quaternion>: [<float>, <float>, <float>, <float>]

<nodepart>:
{
	"meshpartid": <meshpartid>,
	"materialid": <materialid>
	(, "bones": [(<bone> (, <bone>)*)?])?
	(, "uvMapping": [(<uvmapping> (, <uvmapping>)*)?])?
}

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

<uvmapping>: [(<integer> (, <integer>)*)?])?

<animation>:
{
	"id": <animationid>
	(, "bones": [(<nodeanimation> (, <nodeanimation>)*)?])?
}

<nodeanimation>:
{
	"boneId": <nodeid>
	(, "translation": [(<keyframe3> (, <keyframe3>)*)?])
	(, "rotation": [(<keyframe4> (, <keyframe4>)*)?])
	(, "scaling": [(<keyframe3> (, <keyframe3>)*)?])
}

<keyframe3>:
{
	("keytime": <float>) // may be omitted in which case 0 is assumed
	(, "value": <xyz>) // may be omitted in which case the node default is used
}

<keyframe4>:
{
	("keytime": <float>) // may be omitted in which case 0 is assumed
	(, "value": <quaternion>) // may be omitted in which case the node default is used
}
Clone this wiki locally