<?xml version="1.0" encoding="UTF-8"?>
<!-- Command for SMBLevelWorkshop docs: specformatter <dash><dash>table-class table stagedefFormat2.xml stagedefFormat2.html -->
<!-- But of course, replace <dash><dash> with two dashes - XML has a compatibility rule preventing <dash><dash> from being in comments -->
<specSheet>
    <spec id="stagedefFormat2" name="SMB 2 StageDef Format (Formerly .lz.raw)" linkImage="Link.png">
        <note>All values are in big endian for SMB 2, or little endian for SMB Deluxe</note>
        <note>The StageDef file is compressed using a variation of LZSS</note>
        <note>All strings are null terminated ASCII strings</note>
        <note>Try to keep things 4 byte aligned if possible (based on the specs, it seems to be built like this)</note>
        <note>Object names need to be put somewhere in the file</note>
        <note>Rotation is given in 2 bytes, ranging from 0x0000 being 0 deg, and 0xFFFF being 359.995 (rounded to 3 d.p.) deg</note>
        <note>Rotation is Z then Y then X</note>
        <note>The collision is split into a grid and is used for optimization</note>
        <note>Which triangles are tested against for collision depends on which grid tile the player is in</note>
        <note>By dividing the triangles into spatial sections, it allows the game to not test every triangle every frame</note>
        <note>The grid spans from startX, startZ to startX + stepX * stepXCount, startZ + stepZ * stepZCount</note>
        <note>startX/Z: -256, stepX/Z: 32, stepX/ZCount: 16 is known to work</note>
        <note>For clarification as to how a collision triangle is stored, the first coordinate is (X1, Y1, Z1), the second coordinate is calculated as (X1 + DX2X1, Y1 + DY2Y1, Z1) then rotated about first point by Z, then Y, then X. The third coordinate is calculated similarly, from (X1 + DX3X1, Y1 + DY3Y1, Z1), rotated by the same angles</note>
        <note>The collision grid pointers should point to different triangle lists, even if they have the same contents</note>
        <note>If not optimizing, all triangle lists can list all triangles</note>
        <note>Animations can be grouped with the animation group ID value in the collision header - This allows a single switch to trigger multiple animations</note>
        <note>Level model instances are typically not used unless duplication of a specific model is needed - for example, in Entangled Path, the LEECH_A_LOD model is duplicated, rather than having multiple of the same model in the GMA/TPL</note>
        <note>The first collision header cannot contain animation (Unless you like the idea of animating only the display of party balls/bananas, not collision)</note>
        <note>The center of rotation in the collision header may not work as one may expect. Setting the center of rotation will translate the object(s) by the negative of what was set (Effectively making the object appear to jump to 0, 0, 0 usually). Position keyframes are then used to move the object back to its desired location.</note>
        <flag id="n" info="Ok to be left as null" image="NullOk.png" />
        <flag id="N" info="Ok to be left as null if the number of objects is 0/referenced item is not set" image="NullOkIf.png" />
        <flag id="i" info="4 byte integer" image="Int32.png" />
        <flag id="f" info="4 byte float" image="Float32.png" />
        <flag id="s" info="2 byte short" image="Short16.png" />
        <flag id="o" info="4 byte file offset" image="Offset32.png" />
        <flag id="u" info="Unknown" image="Unknown.png" />

        <section id="fileHeader" name="File Header">
            <entry length="8" flags="" info="0x00000000447A0000" />
            <entry length="4" flags="in" info="Number of collision headers" link="#spec-stagedefFormat2-section-collisionHeader" />
            <entry length="4" flags="oN" info="Offset to the collision header list" link="#spec-stagedefFormat2-section-collisionHeader" />
            <entry length="4" flags="o" info="Offset to start position data" link="#spec-stagedefFormat2-section-startPosition" />
            <entry length="4" flags="o" info="Offset to fallout position data" link="#spec-stagedefFormat2-section-falloutPosition" />
            <entry length="4" flags="in" info="Number of goals" link="#spec-stagedefFormat2-section-goal" />
            <entry length="4" flags="oN" info="Offset to the goal list" link="#spec-stagedefFormat2-section-goal" />
            <entry length="4" flags="in" info="Number of bumpers" link="#spec-stagedefFormat2-section-bumper" />
            <entry length="4" flags="oN" info="Offset to the bumper list" link="#spec-stagedefFormat2-section-bumper" />
            <entry length="4" flags="in" info="Number of jamabars" link="#spec-stagedefFormat2-section-jamabar" />
            <entry length="4" flags="oN" info="Offset to the jamabar list" link="#spec-stagedefFormat2-section-jamabar" />
            <entry length="4" flags="in" info="Number of bananas" link="#spec-stagedefFormat2-section-banana" />
            <entry length="4" flags="oN" info="Offset to the banana list" link="#spec-stagedefFormat2-section-banana" />
            <entry length="4" flags="in" info="Number of cone collision objects" link="#spec-stagedefFormat2-section-coneCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the cone collision object list" link="#spec-stagedefFormat2-section-coneCollisionObject" />
            <entry length="4" flags="in" info="Number of sphere collision objects" link="#spec-stagedefFormat2-section-sphereCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the sphere collision object list" link="#spec-stagedefFormat2-section-sphereCollisionObject" />
            <entry length="4" flags="in" info="Number of cylinder collision objects" link="#spec-stagedefFormat2-section-cylinderCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the cylinder collision object list" link="#spec-stagedefFormat2-section-cylinderCollisionObject" />
            <entry length="4" flags="in" info="Number of fallout volumes" link="#spec-stagedefFormat2-section-falloutVolume" />
            <entry length="4" flags="oN" info="Offset to the fallout volume list" link="#spec-stagedefFormat2-section-falloutVolume" />
            <entry length="4" flags="in" info="Number of background models" link="#spec-stagedefFormat2-section-backgroundModel" />
            <entry length="4" flags="oN" info="Offset to the background model list" link="#spec-stagedefFormat2-section-backgroundModel" />
            <entry length="4" flags="in" info="Number of foreground models" link="#spec-stagedefFormat2-section-foregroundModel" />
            <entry length="4" flags="oN" info="Offset to the foreground model list" link="#spec-stagedefFormat2-section-foregroundModel" />
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="" info="0x00000001" />
            <entry length="4" flags="in" info="Number of reflective level models" link="#spec-stagedefFormat2-section-reflectiveLevelModel" />
            <entry length="4" flags="oN" info="Offset to the reflective level model list" link="#spec-stagedefFormat2-section-reflectiveLevelModel" />
            <entry length="12" flags="un" info="Unknown/Null" />
            <entry length="4" flags="in" info="Number of level model instances (For use with duplicated level models)" link="#spec-stagedefFormat2-section-levelModelInstance" />
            <entry length="4" flags="oN" info="Offset to the level model instance list" link="#spec-stagedefFormat2-section-levelModelInstance" />
            <entry length="4" flags="in" info="Number of level models" link="#spec-stagedefFormat2-section-levelModelPointerTypeA" />
            <entry length="4" flags="oN" info="Offset to the level model pointer type A list" link="#spec-stagedefFormat2-section-levelModelPointerTypeA" />
            <entry length="4" flags="in" info="Number of level models" link="#spec-stagedefFormat2-section-levelModelPointerTypeB" />
            <entry length="4" flags="oN" info="Offset to the level model pointer type B list" link="#spec-stagedefFormat2-section-levelModelPointerTypeB" />
            <entry length="12" flags="un" info="Unknown/Null" />
            <entry length="4" flags="in" info="Number of switches" link="#spec-stagedefFormat2-section-switch" />
            <entry length="4" flags="oN" info="Offset to the switch list" link="#spec-stagedefFormat2-section-switch" />
            <entry length="4" flags="on" info="Offset to the fog animation header" link="#spec-stagedefFormat2-section-fogAnimationHeader" />
            <entry length="4" flags="in" info="Number of wormholes" link="#spec-stagedefFormat2-section-wormhole" />
            <entry length="4" flags="oN" info="Offset to the wormhole list" link="#spec-stagedefFormat2-section-wormhole" />
            <entry length="4" flags="on" info="Offset to fog" link="#spec-stagedefFormat2-section-fog" />
            <entry length="20" flags="n" info="Unknown/Null" />
            <entry length="4" flags="on" info="Offset to mystery 3" link="#spec-stagedefFormat2-section-mystery3" />
            <entry length="1988" flags="un" info="Unknown/Null" />
        </section>

        <section id="startPosition" name="Start Position">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
        </section>

        <section id="falloutPosition" name="Fallout Position">
            <entry length="4" flags="f" info="Y position" />
        </section>

        <section id="goal" name="Goal">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="s" info="Type of goal (Blue: 0x0001, Green: 0x0101, Red: 0x0201)" />
        </section>

        <section id="bumper" name="Bumper">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="X Scale" />
            <entry length="4" flags="f" info="Y Scale" />
            <entry length="4" flags="f" info="Z Scale" />
        </section>

        <section id="jamabar" name="Jamabar">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="X Scale" />
            <entry length="4" flags="f" info="Y Scale" />
            <entry length="4" flags="f" info="Z Scale" />
        </section>

        <section id="banana" name="Banana">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="4" flags="i" info="Type of banana (Single: 0x00000000, Bunch: 0x00000001)" />
        </section>

        <section id="falloutVolume" name="Fallout Volume">
            <entry length="4" flags="f" info="Center X position" />
            <entry length="4" flags="f" info="Center Y position" />
            <entry length="4" flags="f" info="Center Z position" />
            <entry length="4" flags="f" info="X size" />
            <entry length="4" flags="f" info="Y size" />
            <entry length="4" flags="f" info="Z size" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
        </section>

        <section id="switch" name="Switch">
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="s" info="Switch type (Play: 0x0000, Pause: 0x0001, Play backwards: 0x0002, Fast forward: 0x0003, Rewind: 0x0004)" />
            <entry length="2" flags="s" info="Animation group IDs affected" link="#spec-stagedefFormat2-section-collisionHeader" />
            <entry length="2" flags="n" info="Null" />
        </section>

        <section id="wormhole" name="Wormhole">
            <entry length="4" flags="" info="0x00000001" />
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="o" info="Offset to destination wormhole" link="#spec-stagedefFormat2-section-wormhole" />
        </section>

        <section id="collisionHeader" name="Collision Header">
            <entry length="4" flags="fn" info="Center of rotation X position (Center of rotation may not work as you may expect - see notes for more info)" />
            <entry length="4" flags="fn" info="Center of rotation Y position (Center of rotation may not work as you may expect - see notes for more info)" />
            <entry length="4" flags="fn" info="Center of rotation Z position (Center of rotation may not work as you may expect - see notes for more info)" />
            <entry length="2" flags="sn" info="Initial X rotation" />
            <entry length="2" flags="sn" info="Initial Y rotation" />
            <entry length="2" flags="sn" info="Initial Z rotation" />
            <entry length="2" flags="s" info="Animation loop type/seesaw (Looping animation: 0x0000, Play once animation: 0x0001, Seesaw: 0x0002 - Seesaws rotate around the Z axis if not rotated)" />
            <entry length="4" flags="on" info="Offset to animation header (Animation does not work with the first collision header - see notes for details)" link="#spec-stagedefFormat2-section-animationHeader" />
            <entry length="4" flags="fn" info="Conveyor X speed" />
            <entry length="4" flags="fn" info="Conveyor Y speed" />
            <entry length="4" flags="fn" info="Conveyor Z speed" />
            <entry length="4" flags="o" info="Offset to the collision triangle list" link="#spec-stagedefFormat2-section-collisionTriangle" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list pointer" link="#spec-stagedefFormat2-section-collisionGridTriangleListPointer" />
            <entry length="4" flags="f" info="Collision grid start X" />
            <entry length="4" flags="f" info="Collision grid start Z" />
            <entry length="4" flags="f" info="Collision grid step X" />
            <entry length="4" flags="f" info="Collision grid step Z" />
            <entry length="4" flags="i" info="Collision grid step X count" />
            <entry length="4" flags="i" info="Collision grid step Z count" />
            <entry length="4" flags="in" info="Number of goals" link="#spec-stagedefFormat2-section-goal" />
            <entry length="4" flags="oN" info="Offset to the goal list (Null is not ok if this is the first collision header - if the first collision header contains no goals, it still must point to a goal list, else the points glitch will occur and finishing will crash a console)" link="#spec-stagedefFormat2-section-goal" />
            <entry length="4" flags="in" info="Number of bumpers" link="#spec-stagedefFormat2-section-bumper" />
            <entry length="4" flags="oN" info="Offset to the bumper list" link="#spec-stagedefFormat2-section-bumper" />
            <entry length="4" flags="in" info="Number of jamabars" link="#spec-stagedefFormat2-section-jamabar" />
            <entry length="4" flags="oN" info="Offset to the jamabar list" link="#spec-stagedefFormat2-section-jamabar" />
            <entry length="4" flags="in" info="Number of bananas" link="#spec-stagedefFormat2-section-banana" />
            <entry length="4" flags="oN" info="Offset to the banana list" link="#spec-stagedefFormat2-section-banana" />
            <entry length="4" flags="in" info="Number of cone collision objects" link="#spec-stagedefFormat2-section-coneCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the cone collision object list" link="#spec-stagedefFormat2-section-coneCollisionObject" />
            <entry length="4" flags="in" info="Number of sphere collision objects" link="#spec-stagedefFormat2-section-sphereCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the sphere collision object list" link="#spec-stagedefFormat2-section-sphereCollisionObject" />
            <entry length="4" flags="in" info="Number of cylinder collision objects" link="#spec-stagedefFormat2-section-cylinderCollisionObject" />
            <entry length="4" flags="oN" info="Offset to the cylinder collision object list" link="#spec-stagedefFormat2-section-cylinderCollisionObject" />
            <entry length="4" flags="in" info="Number of fallout volumes" link="#spec-stagedefFormat2-section-falloutVolume" />
            <entry length="4" flags="oN" info="Offset to the fallout volume list" link="#spec-stagedefFormat2-section-falloutVolume" />
            <entry length="4" flags="in" info="Number of reflective level models" link="#spec-stagedefFormat2-section-reflectiveLevelModel" />
            <entry length="4" flags="oN" info="Offset to the reflective level model list" link="#spec-stagedefFormat2-section-reflectiveLevelModel" />
            <entry length="4" flags="in" info="Number of level model instances (For use with duplicated level models)" link="#spec-stagedefFormat2-section-levelModelInstance" />
            <entry length="4" flags="oN" info="Offset to the level model instance list" link="#spec-stagedefFormat2-section-levelModelInstance" />
            <entry length="4" flags="in" info="Number of level models" link="#spec-stagedefFormat2-section-falloutVolume" />
            <entry length="4" flags="oN" info="Offset to the level model pointer type B list" link="#spec-stagedefFormat2-section-levelModelPointerTypeB" />
            <entry length="8" flags="un" info="Unknown/Null" />
            <entry length="2" flags="sn" info="Animation group ID (For use with switches - Must be non-zero if you want to assign a group ID)" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="in" info="Number of switches" link="#spec-stagedefFormat2-section-switch" />
            <entry length="4" flags="oN" info="Offset to the switch list" link="#spec-stagedefFormat2-section-switch" />
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="on" info="Offset to mystery 5" link="#spec-stagedefFormat2-section-mystery5" />
            <entry length="4" flags="fN" info="Seesaw sensitivity (Higher is more sensitive, negative makes the seesaw reversed)" />
            <entry length="4" flags="fN" info="Seesaw friction (Lower is looser)" />
            <entry length="4" flags="fN" info="Seesaw spring (0 prevents the seesaw from resetting)" />
            <entry length="4" flags="in" info="Number of wormholes" link="#spec-stagedefFormat2-section-wormhole" />
            <entry length="4" flags="oN" info="Offset to the wormhole list" link="#spec-stagedefFormat2-section-wormhole" />
            <entry length="4" flags="in" info="Initial animation state (Playing: 0x00000000, Paused: 0x00000001, Playing backwards: 0x00000002, Fast forward: 0x00000003, Rewind: 0x00000004 - Same as switch types - A play once animation should not be initially playing)" />
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="f" info="Animation loop point (Seconds - Set to a large value to &quot;disable&quot; looping)" />
            <entry length="4" flags="on" info="Offset to texture scroll data" link="#spec-stagedefFormat2-section-textureScroll" />
            <entry length="960" flags="un" info="Unknown/Null" />
        </section>

        <section id="levelModelPointerTypeA" name="Level Model Pointer Type A">
            <entry length="8" flags="" info="0x0000000000000001" />
            <entry length="4" flags="o" info="Offset to level model Type A" link="#spec-stagedefFormat2-section-levelModel" />
        </section>

        <section id="levelModel" name="Level Model">
            <entry length="4" flags="n" info="Null" />
            <entry length="4" flags="o" info="Offset to the model name to use" />
            <entry length="8" flags="n" info="Null" />
        </section>

        <section id="levelModelPointerTypeB" name="Level Model Pointer Type B">
            <entry length="4" flags="o" info="Offset to level model pointer Type A" link="#spec-stagedefFormat2-section-levelModelPointerTypeA" />
        </section>

        <section id="levelModelInstance" name="Level Model Instance">
            <entry length="4" flags="oN" info="Offset to the level model pointer type A" link="#spec-stagedefFormat2-section-levelModelPointerTypeA" />
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="X Scale" />
            <entry length="4" flags="f" info="Y Scale" />
            <entry length="4" flags="f" info="Z Scale" />
        </section>

        <section id="reflectiveLevelModel" name="Reflective Level Model">
            <entry length="4" flags="o" info="Offset to the model name to use" />
            <entry length="8" flags="n" info="Null" />
        </section>

        <section id="backgroundModel" name="Background Model">
            <entry length="4" flags="" info="0x0000001F" />
            <entry length="4" flags="o" info="Offset to the model name to use" />
            <entry length="4" flags="n" info="Null" />
            <entry length="4" flags="f" info="X position" />
            <entry length="4" flags="f" info="Y position" />
            <entry length="4" flags="f" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="X Scale" />
            <entry length="4" flags="f" info="Y Scale" />
            <entry length="4" flags="f" info="Z Scale" />
            <entry length="4" flags="on" info="Offset to the background animation header" link="#spec-stagedefFormat2-section-backgroundAnimationHeader" />
            <entry length="4" flags="on" info="Offset to the background/foreground animation header 2" link="#spec-stagedefFormat2-section-backgroundAnimationHeader2" />
            <entry length="4" flags="on" info="Offset to the effect header" link="#spec-stagedefFormat2-section-effectHeader" />
        </section>

        <section id="foregroundModel" name="Foreground model">
            <entry length="4" flags="" info="Unknown - typically 0x0000001F, sometimes 0x00000007 or 0x0000000F" />
            <entry length="4" flags="o" info="Offset to the model name to use" />
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="fu" info="X position" />
            <entry length="4" flags="fu" info="Y position" />
            <entry length="4" flags="fu" info="Z position" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="X Scale" />
            <entry length="4" flags="f" info="Y Scale" />
            <entry length="4" flags="f" info="Z Scale" />
            <entry length="4" flags="un" info="Unknown" />
            <entry length="4" flags="on" info="Offset to the background/foreground animation header 2" link="#spec-stagedefFormat2-section-backgroundAnimationHeader2" />
            <entry length="4" flags="on" info="Unknown" />
        </section>

        <section id="collisionTriangle" name="Collision Triangle">
            <entry length="4" flags="f" info="X1 position" />
            <entry length="4" flags="f" info="Y1 position" />
            <entry length="4" flags="f" info="Z1 position" />
            <entry length="4" flags="f" info="X normal" />
            <entry length="4" flags="f" info="Y normal" />
            <entry length="4" flags="f" info="Z normal" />
            <entry length="2" flags="s" info="X rotation from XY plane" />
            <entry length="2" flags="s" info="Y rotation from XY plane" />
            <entry length="2" flags="s" info="Z rotation from XY plane" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="DX2X1 (Delta X position for the 2nd triangle point from the 1st point, before rotation is applied)" />
            <entry length="4" flags="f" info="DY2Y1" />
            <entry length="4" flags="f" info="DX3X1" />
            <entry length="4" flags="f" info="DY3Y1" />
            <entry length="4" flags="f" info="X tangent" />
            <entry length="4" flags="f" info="Y tangent" />
            <entry length="4" flags="f" info="X bitangent" />
            <entry length="4" flags="f" info="Y bitangent" />
        </section>

        <section id="collisionGridTriangleList" name="Collision Grid Triangle List">
            <entry length="2" flags="s" info="Triangle index" link="#spec-stagedefFormat2-section-collisionTriangle" />
            <entry length="0" flags="s" info="... (Triangle index is repeated)" />
            <entry length="2" flags="s" info="0xFFFF to terminate a list" />
        </section>

        <section id="collisionGridTriangleListPointer" name="Collision Grid Triangle List Pointer">
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 0, 0)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 1, 0)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 2, 0)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="0" flags="o" info="..." link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 15, 0)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 0, 1)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="4" flags="o" info="Offset to the collision grid triangle list (Grid tile 1, 1)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
            <entry length="0" flags="o" info="... Repeat this for however many collision grid tiles there are (The above is an example of grid with 16 tiles along the X axis)" link="#spec-stagedefFormat2-section-collisionGridTriangleList" />
        </section>

        <section id="coneCollisionObject" name="Cone Collision Object">
            <entry length="4" flags="f" info="X position (Center of cone base)" />
            <entry length="4" flags="f" info="Y position (Center of cone base)" />
            <entry length="4" flags="f" info="Z position (Center of cone base)" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
            <entry length="4" flags="f" info="Cone radius" />
            <entry length="4" flags="f" info="Cone height" />
            <entry length="4" flags="f" info="Cone radius" />
        </section>

        <section id="sphereCollisionObject" name="Sphere Collision Object">
            <entry length="4" flags="f" info="X position (Center of sphere)" />
            <entry length="4" flags="f" info="Y position (Center of sphere)" />
            <entry length="4" flags="f" info="Z position (Center of sphere)" />
            <entry length="4" flags="f" info="Sphere radius" />
            <entry length="4" flags="un" info="Unknown/Null" />
        </section>

        <section id="cylinderCollisionObject" name="Cylinder Collision Object">
            <entry length="4" flags="f" info="X position (Center of cylinder)" />
            <entry length="4" flags="f" info="Y position (Center of cylinder)" />
            <entry length="4" flags="f" info="Z position (Center of cylinder)" />
            <entry length="4" flags="f" info="Cylinder radius" />
            <entry length="4" flags="f" info="Cylinder height" />
            <entry length="2" flags="s" info="X rotation" />
            <entry length="2" flags="s" info="Y rotation" />
            <entry length="2" flags="s" info="Z rotation" />
            <entry length="2" flags="n" info="Null" />
        </section>

        <section id="animationHeader" name="Animation Header">
            <entry length="4" flags="in" info="Number of X rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of X translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="16" flags="un" info="Unknown/Null" />
        </section>

        <section id="backgroundAnimationHeader" name="Background Animation Header">
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="f" info="Animation loop point (Seconds - Set to a large value to &quot;disable&quot; looping)" />
            <entry length="8" flags="un" info="Unknown/Null" />
            <entry length="4" flags="in" info="Number of X rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of X translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="16" flags="un" info="Unknown/Null" />
        </section>

        <section id="backgroundAnimationHeader2" name="Background/Foreground Animation Header 2">
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="f" info="Animation loop point (Seconds - Set to a large value to &quot;disable&quot; looping)" />
            <entry length="4" flags="in" info="Number of X scale keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X scale keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y scale keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y scale keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z scale keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z scale keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of X rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z rotation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z rotation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of X translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the X translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Y translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Y translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of Z translation keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the Z translation keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="inu" info="Number of unknown [Set 10] keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oNu" info="Offset to the unknown [Set 10] keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="inu" info="Number of unknown [Set 11] keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oNu" info="Offset to the unknown [Set 11] keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
        </section>

        <section id="fogAnimationHeader" name="Fog Animation Header">
            <entry length="4" flags="in" info="Number of start distance keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the start distance keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of end distance keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the end distance keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of red color value keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the red color value keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of green color value keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the green color value keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="in" info="Number of blue color value keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oN" info="Offset to the blue color value keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="inu" info="Number of unknown keyframes" link="#spec-stagedefFormat2-section-animationKeyframe" />
            <entry length="4" flags="oNu" info="Offset to the unknown keyframe list" link="#spec-stagedefFormat2-section-animationKeyframe" />
        </section>

        <section id="animationKeyframe" name="Animation Keyframe">
            <entry length="4" flags="i" info="Easing (Constant: 0x00000000, Linear: 0x00000001, Ease: 0x00000002)" />
            <entry length="4" flags="f" info="Time (Seconds)" />
            <entry length="4" flags="f" info="Value (Translation, rotation, or R/G/B amount, depending on where the keyframe is referenced from)" />
            <entry length="4" flags="f" info="Tangent in (left tangent handle for eased interpolation) - leave at 0 for a flat tangent" />
            <entry length="4" flags="f" info="Tangent out (right tangent handle for eased interpolation) - leave at 0 for a flat tangent" />
        </section>

        <section id="fog" name="Fog">
            <entry length="1" flags="" info="Fog type (Usually 0x04, although this can be any from _GXFogType - NONE: 0x00, LIN: 0x02, EXP: 0x04, EXP2: 0x05, REVEXP: 0x06, REVEXP2: 0x07)" />
            <entry length="3" flags="n" info="Null" />
            <entry length="4" flags="f" info="Fog start distance" />
            <entry length="4" flags="f" info="Fog end distance" />
            <entry length="4" flags="f" info="Amount of red (From 0 - 1)" />
            <entry length="4" flags="f" info="Amount of green (From 0 - 1)" />
            <entry length="4" flags="f" info="Amount of blue (From 0 - 1)" />
            <entry length="12" flags="un" info="Unknown/Null" />
        </section>

        <section id="effectHeader" name="Effect Header">
            <entry length="4" flags="in" info="Number of effect 1 keyframes" link="#spec-stagedefFormat2-section-effect1" />
            <entry length="4" flags="oN" info="Offset to the effect 1 list" link="#spec-stagedefFormat2-section-effect1" />
            <entry length="4" flags="in" info="Number of effect 2 keyframes" link="#spec-stagedefFormat2-section-effect2" />
            <entry length="4" flags="oN" info="Offset to the effect 2 list" link="#spec-stagedefFormat2-section-effect2" />
            <entry length="4" flags="on" info="Offset to the texture scroll" link="#spec-stagedefFormat2-section-textureScroll" />
            <entry length="28" flags="un" info="Unknown/Null" />
        </section>

        <section id="effect1" name="Effect 1 (Likely used for animated textures, such as the silhouettes in Night)">
            <entry length="4" flags="iu" info="Unknown" />
            <entry length="4" flags="iu" info="Unknown" />
            <entry length="4" flags="iu" info="Unknown" />
            <entry length="2" flags="su" info="Unknown" />
            <entry length="2" flags="su" info="Unknown" />
            <entry length="2" flags="su" info="Unknown" />
            <entry length="2" flags="u" info="Unknown" />
        </section>

        <section id="effect2" name="Effect 2 (May be used for the flames in Storm?)">
            <entry length="4" flags="fu" info="Unknown" />
            <entry length="4" flags="fu" info="Unknown" />
            <entry length="4" flags="fu" info="Unknown" />
            <entry length="1" flags="u" info="Unknown" />
            <entry length="3" flags="n" info="Null" />
        </section>

        <section id="textureScroll" name="Texture Scroll">
            <entry length="4" flags="f" info="U (Texture X) scroll speed" />
            <entry length="4" flags="f" info="V (Texture Y) scroll speed" />
        </section>

        <section id="mystery3" name="Mystery 3">
            <entry length="4" flags="fu" info="Unknown float (Probably)" />
            <entry length="4" flags="fu" info="Unknown float (Probably)" />
            <entry length="4" flags="fu" info="Unknown float (Probably)" />
            <entry length="2" flags="n" info="Null" />
            <entry length="2" flags="u" info="Some marker" />
            <entry length="20" flags="n" info="Null" />
        </section>

        <section id="mystery5" name="Mystery 5">
            <entry length="4" flags="un" info="Unknown/Null" />
            <entry length="4" flags="fu" info="Unknown float" />
            <entry length="4" flags="fu" info="Unknown float" />
            <entry length="4" flags="fu" info="Unknown float" />
            <entry length="4" flags="fu" info="Unknown float" />
        </section>
    </spec>
</specSheet>

