class MohoLayer

The MohoLayer class is the base class for all Moho layer types. All actual layers in Moho are sub-classes of MohoLayer (vector layers, image layers, group layers, etc.), but the MohoLayer class provides some basic properties that they all have in common.

Member Functions

int LayerType()

Use this function to find out what type of layer you're dealing with. See the layer type constants.

Return value (int): a layer type identifier

bool IsGroupType()

Test whether a layer is a group layer, or sub-type of group layer (bone, particle, or switch).

Return value (bool): true if a group sub-type, otherwise false

bool IsBoneType()

Test whether a layer is a bone layer, or sub-type of bone layer (switch).

Return value (bool): true if a bone sub-type, otherwise false

string Name()

Returns the name of the layer.

Return value (string): name of the layer

void SetName(name)

Sets a layer's name.

Return value: none
name (string): the new name

void ShowConstructionCurves(b)

Toggle whether to display construction curves for this layer.

Return value: none
b (bool): true to display construction curves, false to hide them

void UpdateCurFrame(extended)

Recalculates animated properties for this layer. Use this when you've made a lot fo changes that need to be re-processed.

Return value: none
extended (bool): perform an extended update

LM_Vector2 Origin()

Get the origin point of the layer.

Return value (LM_Vector2): the origin point of the layer

void SetOrigin(origin)

Set the origin point of the layer.

Return value: none
origin (LM_Vector2): the origin point of the layer

GroupLayer Parent()

Get the layer's parent layer (if any).

Return value (GroupLayer): the layer's parent (nil if the layer is a top-level layer with no parent)

int LayerParentBone()

Get the id number of the layer's controlling parent bone.

Return value (int): id number of bone, -1 for none, or -2 for flexi-binding

void SetLayerParentBone(id)

Set the id number of the layer's controlling parent bone.

Return value: none
id (int): id number of bone, -1 for none, or -2 for flexi-binding

void DeleteParentBone(boneID)

Call this function before deleting a bone in a parent bone layer.

Return value: none
boneID (int): the id of the bone you're about to delete

bool IsRenderOnly()

Return value (bool):

void SetRenderOnly(b)

Return value: none
b (bool):

bool IsEditOnly()

Return value (bool):

void SetEditOnly(b)

Return value: none
b (bool):

bool HasScaleCompensation()

Return value (bool):

void SetScaleCompensation(b)

Return value: none
b (bool):

bool DoesRotateToFollow()

Return value (bool):

void SetRotateToFollow(b)

Return value: none
b (bool):

bool DoesFaceCamera()

Return value (bool):

void SetFaceCamera(b)

Return value: none
b (bool):

int MaskingMode()

Get the layer's masking mode. See the masking mode constants.

Return value (int): the layer's masking mode

void SetMaskingMode(mode)

Set the layer's masking mode. See the masking mode constants.

Return value: none
mode (int): the layer's masking mode

int BlendingMode()

Get the layer's blending mode. See the blending mode constants.

Return value (int): the layer's blending mode

void SetBlendingMode(mode)

Set the layer's blending mode. See the blending mode constants.

Return value: none
mode (int): the layer's blending mode

bool IsImmuneToCamera()

Return value (bool):

void SetImmuneToCamera(b)

Return value: none
b (bool):

bool IsImmuneToDof()

Tests whether the layer is immune to depth of field effects.

Return value (bool):

void SetImmuneToDof(b)

Sets whether the layer is immune to depth of field effects.

Return value: none
b (bool):

string HsvImage()

Returns a file path to the layer's HSV modifier image.

Return value (string): file path

void SetHsvImage()

Sets the file path to the layer's HSV modifier image.

Return value: none
path (string): file path

void GetLayerTransform()

Gets the layer's transformation at a given frame. The layer transform includes things like layer scale, rotation, and translation.

Return value: none
frame (int): frame number
matrix (LM_Matrix): transform matrix to fill in
doc (MohoDoc): the document object

void GetFullTransform()

Gets the layer's complete transformation at a given frame, including the effects of its parent layers.

Return value: none
frame (int): frame number
matrix (LM_Matrix): transform matrix to fill in
doc (MohoDoc): the document object

void GetParentTransform()

Gets the parent layer's transformation at a given frame.

Return value: none
frame (int): frame number
matrix (LM_Matrix): transform matrix to fill in
doc (MohoDoc): the document object

string CurrentAction()

Returns the name of the current action being edited.

Return value (string): the name of the current action

void ActivateAction(name)

Activates an action for editing. If the named action does not exist, it is first created.

Return value: none
name (string): the name of the action to edit

void InsertAction(name, frame, byReference)

Inserts an action into the main timeline.

Return value: none
name (string): the name of the action to insert
frame (int): which frame to insert it at
byReference (bool): true if by reference, false if by copy

Member Variables

fTranslation (AnimVec3)

the layer's translation animation channel


fScale (AnimVec3)

the layer's scale animation channel


fRotationX (AnimVal)

the layer's X rotation animation channel


fRotationY (AnimVal)

the layer's Y rotation animation channel


fRotationZ (AnimVal)

the layer's Z rotation animation channel


fFlipH (AnimBool)

the layer's horizontal flip animation channel


fFlipV (AnimBool)

the layer's vertical flip animation channel


fShear (AnimVec3)

the layer's shear animation channel


fVisibility (AnimBool)

the layer's visibility animation channel


fBlur (AnimVal)

the layer's blur animation channel


fAlpha (AnimVal)

the layer's alpha animation channel


fLayerShadow (AnimBool)

the layer's shadow on/off animation channel


fShadowAngle (AnimVal)


fShadowOffset (AnimVal)


fShadowBlur (AnimVal)


fShadowExpansion (AnimVal)


fShadowColor (AnimColor)


fLayerShading (AnimBool)

the layer's shading on/off animation channel


fShadingAngle (AnimVal)


fShadingOffset (AnimVal)


fShadingBlur (AnimVal)


fShadingContraction (AnimVal)


fShadingColor (AnimColor)


fMotionBlur (AnimBool)

the layer's motion blur on/off animation channel


fMotionBlurFrames (AnimVal)


fMotionBlurSkip (AnimVal)


fMotionBlurAlphaStart (AnimVal)


fMotionBlurAlphaEnd (AnimVal)


fMotionBlurRadius (AnimVal)

class MohoLayer {
  MohoLayer();
  ~MohoLayer();
 
  int32 LayerType();
  bool IsGroupType();
  bool IsBoneType();
  bool IsAudioType();
 
  void SetSecondarySelection(bool sel);
  bool SecondarySelection();
 
  const char *Name();
  void SetName(const char *name);
 
  const char *UUID();
 
  void ShowConstructionCurves(bool b);
 
  int32 CurFrame();
  void UpdateCurFrame(bool extended = false);
 
  bool HasAnimatedLayerEffects();
  void SetAnimatedLayerEffects(bool b);
 
  LM_Vector2 Origin();
  void SetOrigin(LM_Vector2 origin);
  void SetOriginWithTransformCorrection(LM_Vector2 origin);
 
  GroupLayer *Parent();
  SwitchLayer *AncestorSwitchLayer();
  MohoLayer *AncestorSwitchChild();
 
  int32 LayerParentBone();
  void SetLayerParentBone(int32 id);
  void DeleteParentBone(int32 boneID);
 
  bool IsVisible();
  void SetVisible(bool vis);
 
  bool IsRenderOnly();
  void SetRenderOnly(bool b);
 
  bool IsEditOnly();
  void SetEditOnly(bool b);
 
  bool HasScaleCompensation();
  void SetScaleCompensation(bool b);
 
  bool DoesRotateToFollow();
  void SetRotateToFollow(bool b);
 
  bool DoesFaceCamera();
  int32 FaceCameraMode();
  void SetFaceCamera(bool b, int32 mode = 2);
 
  int32 MaskingMode();
  void SetMaskingMode(int32 mode);
  bool MaskExpansion();
  void SetMaskExpansion(bool b);
 
  int32 BlendingMode();
  void SetBlendingMode(int32 mode);
 
  bool IsImmuneToCamera();
  void SetImmuneToCamera(bool b);
 
  bool IsImmuneToDof();
  void SetImmuneToDof(bool b);
 
  const char *HsvImage();
  void SetHsvImage(const char *path);
 
  int32 TimingOffset();
  void SetTimingOffset(int32 timingOffset);
  int32 TotalTimingOffset();
 
  const char *LayerScript();
  void SetLayerScript(const char *path);
  void RunLayerScript();
 
  void GetLayerTransform(int frame, LM_Matrix *matrix, MohoDoc *doc);
  void GetFullTransform(int frame, LM_Matrix *matrix, MohoDoc *doc);
  void GetParentTransform(int frame, LM_Matrix *matrix, MohoDoc *doc);
  void GetParentBoneTransform(int32 frame, LM_Matrix *matrix, MohoDoc *doc);
 
  void AlignWithCamera(int32 frame, MohoDoc *doc);
 
  LM_BBox Bounds(int32 frame);
 
  int32 AnimDuration();
  int32 LayerDuration();
  void ClearAnimation(bool recursive, int32 fromFrame, bool before);
  void DeleteKeysAtFrame(bool recursive, int32 frame);
  void ResetAnimation(bool recursive, bool animatedChannelsOnly = false);
  void AddKey(int32 frame, bool recursive, bool animatedChannelsOnly);
  void ClearLayerKeyCount();
  int32 CountLayerKeys();
  int32 GetLayerKeyWhen(int32 keyID);
 
  int32 NumChannels @ CountChannels();
  void GetChannelInfo(int32 id, MohoLayerChannel *channelInfo);
  AnimChannel *Channel(int32 id, int32 subID, MohoDoc *doc);
 
  void CopyFrame(int32 fromFrame, int32 toFrame, bool recursive);
  void DeleteFrame(int32 frame, bool recursive);
 
  int32 CountPoses @ CountActions();
  const char *PoseName @ ActionName(int32 id);
  const char *CurrentPose @ CurrentAction();
  bool HasPose @ HasAction(const char *name);
  int32 GetPoseID @ ActionID(const char *name);
  bool IsSmartBonePose @ IsSmartBoneAction(const char *name);
  void ActivatePose @ ActivateAction(const char *name);
  void InsertPose @ InsertAction(const char *name, int32 frame, bool byReference);
  void RenamePose @ RenameAction(const char *oldName, const char *newName);
  void DeletePose @ DeleteAction(const char *name);
  void ReorderPose @ ReorderAction(const char *moveName, const char *placeAfterName);
  int32 PoseDuration @ ActionDuration(const char *name);
  void BlendPoses @ BlendActions(int32 frame, bool relativeToDefault, int32 numToBlend, LM_String names[numToBlend], real percentages[numToBlend]);
  void BlendPosesWithMode @ BlendActions(int32 frame, int32 blendMode, int32 numToBlend, LM_String names[numToBlend], real percentages[numToBlend], int32 frames[numToBlend]);
 
  void SetFollowingCurve(MohoLayer *layer, M_Curve *curve, real startingCurvePercentage, bool bendWithCurve);
  MohoLayer *GetFollowingLayer();
  M_Curve *GetFollowingCurve();
 
  bool IsPhysicsInEffect(int32 frame);
  GroupLayer *PhysicsParent(int32 frame);
  MohoPhysicsOptions *PhysicsOptions();
 
  void SetLocked(bool b);
  bool IsLocked();
  LM_Message *Metadata();
 
  // transforms
  AnimVec3  fTranslation;
  AnimVec3  fScale;
  AnimVal    fRotationX;
  AnimVal    fRotationY;
  AnimVal    fRotationZ;
  AnimBool  fFlipH;
  AnimBool  fFlipV;
  AnimVec3  fShear;
  AnimVal    fFollowing;
  AnimVec2  fPhysicsNudge;
 
  // layer effects
  AnimBool  fVisibility;
  AnimVal    fBlur;
  AnimVal    fAlpha;
 
  // layer shadow
  AnimBool  fLayerShadow;
  AnimVal    fShadowAngle;
  AnimVal    fShadowOffset;
  AnimVal    fShadowBlur;
  AnimVal    fShadowExpansion;
  AnimColor  fShadowColor;
  AnimVal    fShadowNoiseAmp, fShadowNoiseScale;
 
  // layer shading
  AnimBool  fLayerShading;
  AnimVal    fShadingAngle;
  AnimVal    fShadingOffset;
  AnimVal    fShadingBlur;
  AnimVal    fShadingContraction;
  AnimColor  fShadingColor;
  AnimVal    fShadingNoiseAmp, fShadingNoiseScale;
 
  // perspective shadow
  AnimBool  fPerspectiveShadow;
  AnimVal    fPerspectiveBlur;
  AnimVal    fPerspectiveScale;
  AnimVal    fPerspectiveShear;
  AnimColor  fPerspectiveColor;
 
  // motion blur
  AnimBool  fMotionBlur;
  AnimVal    fMotionBlurFrames;
  AnimVal    fMotionBlurSkip;
  AnimVal    fMotionBlurAlphaStart;
  AnimVal    fMotionBlurAlphaEnd;
  AnimVal    fMotionBlurRadius;
 
  // layer outline
  AnimBool  fLayerOutline;
  AnimVal    fOutlineWidth;
  AnimColor  fOutlineColor;
};