/*
Animation Master v7 file format grammar interpreted by Nick Porcino written in pseudo antlr form (www.antlr.org)


July 13 2001, version 0.4 incorporating fixes from Timothy Weber
Added SkeletalChannel and ActionFile
Another correction to CHANNELITEM
Added description of ACTION

July 20 2000, version 0.3
Corrections to CHANNELITEM

July 15 version 0.2
Added MATERIAL tag
Decals in model are optional
Additive is optional
Added CAMERA tag
Added LIGHT tag
DiffuseColor in GROUP is optional
Added MATERIALSHORTCUT
Updated Decals
Added CHORWINDOW
Added CHOR

:=

means is defined as

=

means assign local parsing variable

%

means local variable

[]

means optional

"string"

means a literal string

[]+

means one or more of

[]*

means zero or more of

[]%var

means repeat var times

|

means or

...

means character range

all other syntax is pseudo C++
*/

 

/*
--------------------------------------------------------------
The whole entire file is defined as follows:
*/

projectFile :=

"[PROJECT]" eoln
"ProductVersion=" float eoln
"FPS=" int eoln
owner
images
sounds
materials
objects
actions
choreographies
windows
"[ENDPROJECT]" eoln

or as

actionfile :=

"[ACTIONFILE]" eoln
actions
"[ENDACTIONFILE]" eoln

/*
--------------------------------------------------------------
top level sub sections
*/

images :=

"[IMAGES]" eoln
modexp
[still]*
"[ENDIMAGES]" eoln

sounds :=

"[SOUNDS]" eoln
unknown
"[ENDSOUNDS]" eoln

materials :=

"[MATERIALS]" eoln
modexp
[material]*
"[ENDMATERIALS]" eoln

objects :=

"[OBJECTS]" eoln
modexp
["LinkedModel=" string eoln]
[model | camera | light]*
"[ENDOBJECTS]" eoln

actions :=

"[ACTIONS]" eoln
modexp
[action]*
"[ENDACTIONS]" eoln

choreographies :=

"[CHOREOGRAPHIES]" eoln
modexp
[choreography]*
"[ENDCHOREOGRAPHIES]" eoln

windows :=

"[WINDOWPLACEMENTS]" eoln
[window]*
"[ENDWINDOWPLACEMENTS]" eoln

/*
--------------------------------------------------------------
window definitions
*/

window :=

actionwindow | modelwindow | chorwindow | unknown

actionwindow :=

"[ACTIONWINDOW]" eoln
windowstuff
[ENDWINDOW]

modelwindow :=

"[MODELWINDOW]" eoln
windowstuff
[ENDWINDOW]

chorwindow :=

"[CHORWINDOW]" eoln
windowstuff
[ENDWINDOW]

windowstuff :=

name
["ModelName=" string eoln]
["Time=" int eoln]
"CurrentView=" int eoln // 100 is bird's eye, others correspond to keypad views
"Mode=" int eoln
wireshade
"FrontView=" xyz eoln
"BackView=" xyz eoln
"LeftView=" xyz eoln
"RightView=" xyz eoln
"TopView=" xyz eoln
"BottomView=" xyz eoln
"BirdsEyeView=" xyz float float float eoln // x y z pitch yaw roll
"WindowPosition=" [int]%10 eoln // 0 1 -1 -1 -1 -1 106 73 426 416

/*
--------------------------------------------------------------
still definitions
*/

still :=

"[STILL]" eoln
name
"BackgroundColor=" rgba eoln
"Gamma=" float
modexp
"[ENDSTILL]" eoln

 

/*
--------------------------------------------------------------
material definitions
*/

material :=

"[MATERIAL]" eoln
name
owner
modexp
[attribute]+
"[ENDMATERIAL]" eoln

/* Note: only Hash\Attribute and Hash\Environment Map currently decoded*/

attribute :=

"[ATTRIBUTE]" eoln
"ClassName=" | "PluginName=" %kind =string eoln
if %kind == "Hash\Attribute" hashAttribute
else if %kind == "Hash\Environment Map" hashEnvMap
name
modexp
"[ENDATTRIBUTE]" eoln

hashAttribute :=

["DiffuseColor=" int int int eoln]
["DiffuseFalloff=" float eoln]
["Ambience=" float eoln]

hashEnvMap :=

"Opacity=" int eoln
"X-Repeat=" int eoln
"Y-Repeat=" int eoln
"Sequence=OFF" eoln
"ImageName=" string // This is a relative pathname
"Seamless=OFF" eoln

/*
--------------------------------------------------------------
choreography definitions
*/

choreography :=

"[CHOR]" eoln
name
owner
"Frames=" time eoln
"PlayRange=" time time eoln
"Gravity=" xyz eoln
"Radiosity=" float eoln
"GlowRadius=" int eoln
"GlowStrength=" float eoln
"Marker=" float float eoln
modexp
[camerashortcut | lightshortcut | modelshortcut]*
"[ENDCHOR]" eoln

lightshortcut :=

"[LIGHTSHORTCUT]" eoln
name
"ShortcutToLinked=" string eoln // name of light
wireshade
"LightAll=" truefalse eoln
"AnimateMode=" truefalse eoln
modexp
[camerachoraction]*
"[ENDLIGHTSHORTCUT]" eoln

camerashortcut :=

"[CAMERASHORTCUT]" eoln
name
"ShortcutTo=" string eoln // name of camera
"TvSafe=" truefalse eoln
"TitleSafe=" truefalse eoln
"Visible=" truefalse eoln
"BackgroundColorVisible=" truefalse eoln
"ConeVisible=" truefalse eoln
"OutputName=" string eoln // relative filepath to output file
"OutputFormat=" int eoln
"StartTime=" time eoln
"EndTime=" time eoln
"StepFrame=" time eoln
"RenderQuality=" int eoln
"IsCustomRange=" truefalse eoln
"AlphaBuffer=" truefalse eoln
"DepthBuffer=" truefalse eoln
"NormalBuffer=" truefalse eoln
"DisplayGrid=" truefalse eoln
"AnimateMode=" truefalse eoln
modexp
[camerachoraction]*
"[ENDCAMERASHORTCUT]" eoln

modelshortcut :=

"[MODELSHORTCUT]" eoln
name
"ShortcutTo=" string eoln // name of model
"DrawModeOverride=" truefalse eoln
dws
"FrontProjectionTarget=" truefalse eoln
"FlatShaded=" truefalse eoln
"CastReflections=" truefalse eoln
"CastShadows=" truefalse eoln
"ReceiveShadows=" truefalse eoln
"AnimateMode=" truefalse eoln
modexp
[modelchoraction]*
"[ENDMODELSHORTCUT]" eoln

modelchoraction :=

"[CHORACTION]" eoln
"BlendMethod=CopyReplace" eoln
modexp
[

"[MODELCHORCHANNEL]" eoln
chorchannel
"[ENDMODELCHORCHANNEL]" eoln

]*
"[ENDCHORACTION]" eoln

camerachoraction :=

"[CHORACTION]" eoln
"BlendMethod=CopyReplace" eoln
modexp
[

"[CAMERACHORCHANNEL]" eoln
chorchannel
"[ENDCAMERACHORCHANNEL]" eoln

]*
"[ENDCHORACTION]" eoln

lightchoraction :=

"[CHORACTION]" eoln
"BlendMethod=CopyReplace" eoln
modexp
[

"[LIGHTCHORCHANNEL]" eoln
chorchannel
"[ENDLIGHTCHORCHANNEL]" eoln

]*
"[ENDCHORACTION]" eoln

chorchannel :=

"Range=" time time eoln
"BoneDirection=" xyz eoln
"RollDirection=" xyz eoln
"ParentBoneDir=" xyz eoln
"ParentRollDir=" xyz eoln
"AngleInterp=" angleinterp eoln
name
modexp
[channelitem]*

channelitem :=

"[CHANNELITEM]" eoln
"Name=" channelname eoln
"[SPLINE]" eoln
"CPs=" %cpCount = inteoln
[int // interpolation type - linear, spline, constant? typical is 1
time float // time is the offset of the cp in the channel, and the other float is the value
]%cpCount
"[ENDSPLINE]" eoln
modexp
"[ENDCHANNELITEM]" eoln

channelname :=

"X-Scale" | "Y-Scale" | "Z-Scale" |
"X-Translate" | "Y-Translate" | "Z-Translate" |
"X-Orient" | "Y-Orient" | "Z-Orient" |
"Focal Length" |
unknown

/*
--------------------------------------------------------------
skeletal channel
*/

skeletalchannel :=

"[SKELETALCHANNEL]" eoln
chorchannel
"[ENDSKELETALCHANNEL]" eoln

 

/*
--------------------------------------------------------------
action definitions
*/

action :=

"[ACTION]" eoln
<owner>
"Frames=" time eoln
"PlayRange=" time time eoln
"Gravity=" xyz eoln
"HasStride=" truefalse eoln
"ScaleAction=" truefalse eoln
"DisplayWhileSimulating=" truefalse eoln
"Drag=" float eoln
"Modified=" datetime eoln
skeletalchannel
"[ENDACTION]" eoln

/*
--------------------------------------------------------------
model definitions
*/

model :=

"[MODEL]" eoln
name
owner
modelflags
[mesh patches modexp] [decals]
modexp
[segment]*
[groups]*
"[ENDMODEL]" eoln

camera :=

"[CAMERA]" eoln
name
"Type=PERSPECTIVE" eoln
"BackgroundColor=" rgba eoln
"GlowBackground=" truefalse eoln
"FocalLength=" int eoln
"FocalDistance=" int eoln
"FogStart=" int eoln
"FogEnd=" int eoln
"GlobalAmbiance=" float eoln
"Front Distance=" int eoln
"Fog=" float eoln
"Width=" int eoln
"Height=" int eoln
"Aspect=" float eoln
"Scale=" float eoln
"Gamma=" float eoln
"Apply Gamma=" truefalse eoln
"FilmGrain=" truefalse eoln
"FilmGrainSize=" float eoln
"FilmGrainAmount=" float eoln
"Bloom=" truefalse eoln
"BloomStrength=" float eoln
"BloomThreshold=" float eoln
"BloomRadius=" int eoln
"Soften=" truefalse eoln
"Softness=" int eoln
"ShowReflections=" truefalse eoln
"ReflectionLevels=" int eoln
"MotionBlur=" truefalse eoln
"Shutter=" int eoln
"ToonRender=" truefalse eoln
"ToonLinesOnly=" truefalse eoln
"ToonLineMode=DEFAULT" eoln
"ToonLineThickness=" float eoln
"ToonLineColor=" rgb eoln
"ToonShadingMode=DEFAULT" eoln
"ToonSoftness=" float eoln
"PatchSubdivisions=" int eoln
"FieldRender=" truefalse eoln
"FieldOrder=EVEN" eoln
"Dof=" truefalse eoln
"FilterTextures=" truefalse eoln
"ShowShadows=" truefalse eoln
"FlatShaded=" truefalse eoln
"NTSCSafe=" truefalse eoln
"Dither=" truefalse eoln
"AliasEdges=" truefalse eoln
"ShowDecals=" truefalse eoln
"ShowBackFacing=" truefalse eoln
"Multipass=" truefalse eoln
"NumPasses=" int eoln
"DisplayBones=" truefalse eoln
"DisplayCPS=" truefalse eoln
bone
modexp
"[ENDCAMERA]" eoln

light :=

"[LIGHT]" eoln
name
owner
"Type=BULB" eoln
"CastShadows=" truefalse eoln
"ShadowMap=" truefalse eoln
"ShadowMapResolution=" int eoln
"ShadowMapSoftness=" int eoln
"ShadowMapDarkness=" int eoln
"ShadowMapBias=" int eoln
"ShadowRays=" int eoln
"Color=" rgba eoln
"Intensity=" int eoln
"Width=" int eoln
"WidthSoftness=" int eoln
"Falloff=" int eoln
"FalloffSoftness=" int eoln
"ConeAngle=" int eoln
"Volumetric=" truefalse eoln
"Specular=" truefalse eoln
"Diffuse=" truefalse eoln
"Quality=" int eoln
"Brightness=" int eoln
"Contrast=" int eoln
"IsCreateLensflare=" truefalse eoln
"IsFadeWithDistance=" truefalse eoln
"IsFadeLeavingView=" truefalse eoln
"IsFadeBehindObjectS=" truefalse eoln
"IsFadeWithAim=" truefalse eoln
"FlareGlobalScale=" float float eoln
"FlareGlobalIntesity=" float eoln
"FlareGlobalDistance=" float eoln
"GlowPreset=No Glows" eoln
"BeamPreset=No Beams" eoln
"ReflectPreset=No Lens Reflectis" eoln // sic
bone
modexp
"[ENDLIGHT]" eoln

decals :=

"[DECALS]" eoln
modexp
[decal]*
"[ENDDECALS]" eoln

decal :=

"[DECAL]" eoln
name
"SeeThru=" truefalse eoln
"Position=" float float float float eoln
modexp
[decalimages]
[stamps]
"[ENDDECAL]" eoln

stamps :=

"[STAMPS]" eoln
modexp
[stamp]*
"[ENDSTAMPS]" eoln

stamp :=

"[STAMP]" eoln
name
"View=" [float]%6 eoln
"Position=" [float]%4 eoln
stampdata
"[ENDSTAMP]" eoln

stampdata :=

"[DATA]" eoln
"PatchesHit=" %patches=int eoln
[

cps
[float]%9
[float]%9
[float]%9
[float]%9

]%patches
"[ENDDATA]" eoln

decalimages :=

"[DECALIMAGES]" eoln
modexp
[decalimage]*
"[ENDDECALIMAGES]" eoln

decalimage :=

"[DECALIMAGE]" eoln
name
"ShortcutToLinked=" string eoln // name of image file
"DecalType=" decaltype eoln
"Value=" float eoln
"Repeat=" float float eoln
"Seamless=" truefalse eoln
"ReferenceMap=" truefalse eoln
"ImageShown=" truefalse eoln
"[ENDDECALIMAGE]" eoln

decaltype :=

["Color"]

groups :=

"[GROUPS]" eoln
modexp
[group]*
"[ENDGROUPS]" eoln

group :=

"[GROUP]" eoln
name
[

"RenderAsLines=" truefalse eoln
"HasAttributes=" truefalse eoln
["DiffuseColor=" rgb eoln]

]
"Count=" %cpCount = int eoln
[int]%cpCount
modexp
[materialShortcut]
"[ENDGROUP]" eoln

materialShortcut :=

"[MATERIALSHORTCUT]" eoln
name
"ShortcutTo=" string eoln
"Offset=" xyz eoln
"Scale=" xyz eoln
"Aim=" xyz eoln
"Roll=" float eoln
"GlobalAxis=" truefalse eoln
"[ENDMATERIALSHORTCUT]"eoln

segment := // segments are bones

"[SEGMENT]" eoln
name
"[NONSKINNEDCPS]" eoln
"Count=" %cpCount = int eoln
[int]%cpCount
"[ENDNONSKINNEDCPS]" eoln
bone
modexp
[segment]* // child segments are recursively added here
"[ENDSEGMENT]"eoln

patches :=

"[PATCHES]" eoln
"Version=2" eoln
"Count=" %patchCount = int eoln
[patch]%patchCount
// [%patch5Count = int eoln [patch]%patch5Count] // haven't verified this line
"[ENDPATCHES]" eoln

/*
patch flags:
*/

patch :=

int eoln // patch flag line
cps eoln

cps :=

{[int]%3 eoln} | // 3 sided patch
{[int]%4 eoln} | // 4 sided patch
{[int]%5 eoln} // 5 sided patch

mesh :=

"[MESH]" eoln
"Version=2" eoln
"Splines=" %splinecount = int eoln
[spline]%splinecount
"[ENDMESH]" eoln

spline :=

"CPs=" %cpCount = int eoln
[cp]%cpCount

/*
cp flags are interpreted as follows:

enum ECPFlags
{

kSmooth = 1, // 0 means peaked
kClosed = 4, // 0 means open
kHook = 16 // 0 means no hook

};
The different flags are or'd together.

Note that if the kHook flag is present, it means that a fourth value, hookfrac, will be found on the first line. Hookfrac
can be 0.25, 0.5, 0.75, indicating the points along a spline
where a hook can be attached. (Thanks Orion)
*/

cp :=

%flags = int %kind = int %number = int [%hookfrac = float] eoln
if (%kind == 0)
{
xyz eoln
}
else
{
int eoln // this cp has no x y z, rather it is welded here. Must resolve after reading entire mesh
}
%alpha1 = float // in curve data
if (not eoln)
{
float float eoln // read gamma1 and magnitude1
}
else
{
skip to next line
}
%alpha2 = float // out curve data
if (not eoln)
{
float float eoln // read gamma2 and magnitude2
}
else
{
skip to next line
}

modelflags :=

"BoneColor=" rgba eoln
hidden
bounds
attributes
[[

"SilColor=" rgb eoln
"SilPct=" float eoln
"SilUseObjectColor=" truefalse eoln
"SilThickness=" int eoln
"DetColor=" rgb eoln
"DetPct=" float eoln
"DetUseObjectColor=" truefalse eoln
"DetThickness=" float eoln

] |
[

"Color=" rgb eoln
"Percent=" float eoln
"UseObjectColor=" truefalse eoln
"Thickness=" float eoln
"Softness=" float eoln
"ShadingMode=NORMAL" eoln

]]

HasBooleans=FALSE"

attributes :=

"DiffuseColor=" rgb eoln
"DiffuseFalloff=" float eoln
"Ambiance=" float eoln
"Glow=" truefalse eoln
"Roughness=" float eoln
"RoughnessScale=" float eoln
"Reflectivity=" float eoln
"Transparency=" rgb eoln
["Additive=" truefalse eoln]
"Refraction=" float eoln
"SpecularColor=" rgb eoln
"SpecularSize=" float eoln
"SpecularIntensity=" float eoln

 

/*
--------------------------------------------------------------
basic definitions
*/

bone :=

"Pivot=" xyz eoln
"End=" xyz eoln
"RollHandle=" xyz eoln
"BoneColor=" rgba eoln
dws
"Chained=" truefalse eoln
hidden
bounds

hidden :=

"Hidden=" truefalse eoln

bounds :=

"Bounds=" [int]%24 eoln

dws :=

"DrawMode=" drawmode eoln
wireshade

wireshade :=

"Wireframe=" truefalse eoln
["Shaded=" truefalse eoln]

drawmode :=

"Curved" | unknown

name :=

"Name=" string eoln

rgb :=

int int int

rgba :=

rgb int

xyz :=

float float float


// modexp appears in v7 only it appears to be optional
modexp :=

["Modified=" datetime eoln]
["Selected=" truefalse eoln]
["Expanded=" truefalse eoln]

owner :=

"CreatedBy=" string eoln
"LastModifiedBy=" string eoln

datetime :=

a string indicating time and date

unknown :=

I haven't figured it out yet :-P

truefalse :=

"true" | "false"

eoln :=

"\r\n" | "\r" | "\n"

string :=

zero or more ascii characters until eoln is found but not including the eoln

float :=

[sign] mantissa ["." fractional] [exponent]

sign :=

+ | -

mantissa :=

int

fractional :=

int

exponent :=

e | E [sign] int

time :=

int[":"int]

int :=

[0...9]+

angleinterp :=

"AngleInterp=Euler" | "AngleInter=Quat"