SCML Format Specification
Copyright (c) 2012, BrashMonkey, LLC.
All rights reserved.
The Scml Format (right column - below)
is published under the Modified BSD License. (details)
Note From BrashMonkey:
Since xml cannot be compiled into an
executable, the binary clause does not apply, and you may create
projects that load and process scml for free or commercial use with
no restrictions. The license applies to the specification and
description of the scml format itself only.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of BrashMonkey, LLC nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BRASHMONKEY, LLC
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
// Fill a SpatialInfo class with the
// x,y,angle,etc of this character in game
// To avoid distortion the character keep
// scaleX and scaleY values equal
// Make scaleX or scaleY negative to flip on that axis
// Examples (scaleX,scaleY)
// (1,1) Normal size
// (-2.5,2.5) 2.5x the normal size, and flipped on the x axis
}
Ref
{
int parent=-1; // -1==no parent - uses ScmlObject spatialInfo as parentInfo int timeline; int key; }
// edittime features
// -----------------
// Sometimes an implementation is for a development tool with a visual editor.
// When levels are editted visually in the target environment, and you want
// to allow users to position a visual Spriter character, but full animation
// and bone support may be overkill.
// Sometimes the editor runs on a separate engine from the game runtime,
// is written by a different developer, or written in a different language.
// The abs_ values in the first mainline key of each animation are there
// to provide developers of edittime support a way to draw the first frame
// of each animation with minimal parsing of the scml, and without having
// to worry about things like default pivot points or bone transformations.
// First fill a dom with the <folder> and <file> 'name's
Folder folders[]; // <folder>
Folder
{
string fileNames[]; // <filename="">
}
// the first <mainline><key> in each <animation>
void drawAtEdittime()
{
for(o in <object_ref>)
{
if(<object_ref>[o] contains attribute 'folder')
{
// using the image from the file at <folder>[folder].fileNames[file]
// draw the image using a pivot of abs_pivot_x,abs_pivot_y
// at abs_x,abs_y,abs_angle(counter clockwise)
// draw the image at it's original width * abs_scale_x
// and it's original height * abs_scale_y
// and with an opacity of abs_a (0.0 - 1.0)==(transparent - opaque)
}
}
}
}
BoneTimelineKey : SpatialTimelineKey
{
// unimplemented in Spriter
int length=200;
int height=10;
// override paint if you want debug visuals for bones
void paint()
{
if(paintDebugBones)
{
float drawLength=length*scaleX;
float drawHeight=height*scaleY;
// paint debug bone representation
// e.g. line starting at x,y,at angle,
// of length drawLength, and height drawHeight
}
}
// keyB must be BoneTimelineKeys
{
BoneTimelineKey returnKey=this;
returnKey.info=linear(info,keyB.info,spin,t);
if(paintDebugBones)
{
returnKey.length=linear(length,keyB.length,t);
returnKey.width=linear(width,keyB.width,t);
}
return returnKey;
}
}
SpriteTimelineKey : SpatialTimelineKey
{
int folder; // index of the folder within the ScmlObject int file; bool useDefaultPivot; // true if missing pivot_x and pivot_y in object tag float pivot_x=0; float pivot_y=1;
void paint()
{
int paintPivotX;
int paintPivotY;
if(useDefaultPivot)
{
paintPivotX=ScmlObject.activeCharacterMap[folder].files[file].pivotX;
paintPivotY=ScmlObject.activeCharacterMap[folder].files[file].pivotY;
}
else
{
paintPivotX=pivot_x;
paintPivotY=pivot_y;
}
// paint image represented by
// ScmlObject.activeCharacterMap[folder].files[file],fileReference
// at x,y,angle (counter-clockwise), offset by paintPivotX,paintPivotY
}