MOHO Classes

class Mesh3DLayer

Member Functions

void SetSourceMesh(path)

Loads a 3D OBJ file from disk as the layer's 3D mesh.

Return value: none
path (string): file path to an OBJ file

string SourceMesh()

Returns the path to the 3D OBJ file used by this layer.

Return value (string): file path to an OBJ file

void SetEdgeOffset(offset)

Sets the edge offset used when drawing the edges of this 3D object.

Return value: none
offset (float): edge offset value

float EdgeOffset()

Returns the edge offset used when drawing the edges of this 3D object.

Return value (float): edge offset value

class Mesh3DOptions

New Feature

class MeshLayer

New feature

class MohoDoc

The MohoDoc class represents the current Moho document object.

Member Functions

int CountLayers()

Returns the number of top-level layers in the document.

Return value (int): the number of top-level layers in the document

MohoLayer Layer(id)

Access an individual layer in the document.

Return value (MohoLayer): a layer in the document
id (int): id number of the layer (0 is the lowest layer in the document)

void PrepUndo(layer)

Mark a point in editing that the user can "undo" to return to. Pass nil as the argument to mark a forthcoming operation as "not undoable".

Return value: none
layer (MohoLayer): the layer that is about to be modified

void SetDirty()

Marks the document as "dirty" or modified, prompting the user to save if they try to quit.

Return value: none

int AnimDuration()

Returns the duration of the document's animation. This is basically the frame number of the last keyframe in the entire document. Depending on the animation, this can be much less or much more than the document's official end frame.

Return value (int): the duration of the document's animation

int Width()

Returns the pixel width of the final rendered output.

Return value (int): pixel width of the final rendered output

int Height()

Returns the pixel height of the final rendered output.

Return value (int): pixel height of the final rendered output

void SetShape(w, h)

Set's the pixel width and height of the final rendered output.

Return value: none
w (int): width
h (int): height

float AspectRatio()

Returns the aspect ratio of the final rendered output.

Return value (float): aspect ratio of the final rendered output

int StartFrame()

Returns the document's start frame (typically 1).

Return value (int): document start frame

void SetStartFrame(frame)

Sets the document's start frame.

Return value: none
frame (int): document start frame

int EndFrame()

Return's the document's end frame.

Return value (int): document end frame

void SetEndFrame(frame)

Sets the document's start frame.

Return value: none
frame (int): document end frame

float Fps()

Returns the frame rate of the document (frames per second).

Return value (float): document fps

bool IsOutsideViewEnabled()

Returns true if the user is orbiting the workspace, and not viewing the scene through the camera.

Return value (bool): true if orbiting, false if viewing through the camera

void GetOutsideViewMatrix(m)

Returns the transformation matrix for viewing the scene from the "orbit" view.

Return value: none
m (LM_Matrix): orbit transform matrix

void DepthSort()

Performs a depth sort on all layers in the document.

Return value: none

Member Variables

fCameraTrack (AnimVec3)

the camera tracking animation channel


fCameraZoom (AnimVal)

the camera zoom animation channel


fCameraRoll (AnimVal)

the camera roll animation channel


fCameraPanTilt (AnimVec2)

the camera pan/tilt animation channel

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 MohoRenderStyle

New Feature

class MohoView

The MohoView class is a script's interface to the Moho editing view.

Member Functions

void Refresh()

Causes the view to refresh, but not perform a full redraw. Not used very often.

Return value: none

void DrawMe()

Causes the view to completely redraw the current scene. Moho scripts use this a lot after making changes to the contents of the document.

Return value: none

LM_Vector2 Point2Vec(where, layerM)

Converts a pixel location to a 2D vector location, given a specific transformation matrix. This is used to convert between mouse coordinates and 2D layer coordinates.

Return value (LM_Vector2): 2D vector point in a layer's coordinate system
where (LM_Point): pixel location on the screen
layerM (LM_Matrix): the transformation matrix for the layer in question

int PickPoint(where)

Picks a point near the given pixel location.

Return value (int): id of an M_Point object in the current vector layer
where (LM_Point): pixel location on the screen

void PickEdge(where, curveID, segID)

Picks an edge near the given pixel location.

Return value: none
where (LM_Point): pixel location on the screen
curveID (int): id of an M_Curve object in the current vector layer, returned by this function
segID (int): which segment on the curve was picked, returned by this function

int PickShape(where, noHigherThan=-1)

Picks a shape near the given pixel location.

Return value (int): id of an M_Shape in the current vector layer
where (LM_Point): pixel location on the screen
noHigherThan (int): id of the highest shape to pick (to allow picking lower, hidden shapes), -1 to ignore this option

int PickBone(where, clickVec, layer, exact)

Picks a bone near the given pixel location.

Return value (int): id of the picked bone
where (LM_Point): pixel location on the screen
clickVec (LM_Vector2): vector location of the click
layer (MohoLayer): the bone layer you wish to pick from
exact (bool): true if only exact picks are accepted, false if the closest bone can be clicked even if not exact

XGraphics Graphics()

Returns a graphics object to use for custom drawing in the view.

Return value (XGraphics): a graphics drawing object

void ResetView(mode)

Reset or zoom in on the view.

Return value: none
mode (int): 0:zoom in on all the points in the layer, 1:zoom in on all the selected points in the layer, 2:zoom out to default view

void PanDown(where)

Return value: none
where (LM_Point):

void PanMoved(where)

Return value: none
where (LM_Point):

void PanUp(where)

Return value: none
where (LM_Point):

void ZoomDown(where)

Return value: none
where (LM_Point):

void ZoomMoved(where)

Return value: none
where (LM_Point):

void ZoomUp(where)

Return value: none
where (LM_Point):

void RotateDown(where)

Return value: none
where (LM_Point):

void RotateMoved(where)

Return value: none
where (LM_Point):

void RotateUp(where)

Return value: none
where (LM_Point):

void OrbitDown(where)

Return value: none
where (LM_Point):

void OrbitMoved(where)

Return value: none
where (LM_Point):

void OrbitUp(where)

Return value: none
where (LM_Point):

void DrawPreviewShape()

Draws a "preview" shape by evaluating the selected points in the current vector layer as a shape, and drawing it in a highlighted mode. This is used by the Create Shape tool to preview a shape before the user hits the spacebar to finalize the shape.

Return value: none

class MouseEvent

The MouseEvent class is provided to your script when a mouse event occurs. It contains information about the event.

Member Variables

view (MohoView)

A reference to the Moho editing view.


pt (LM_Point)

The pixel location of the current mouse event.


startPt (LM_Point)

The pixel location of the initial mouse down event.


vec (LM_Vector2)

The 2D layer location of the current mouse event.


startVec (LM_Vector2)

The 2D layer location of the initial mouse down event.


shiftKey (bool)

True if the shift key is down, otherwise false.


ctrlKey (bool)

True if the ctrl key is down, otherwise false.


altKey (bool)

True if the alt key is down, otherwise false.


penPressure (float)

The current pen pressure (if a drawing tablet is being used). Pen pressure can vary from 0.0 to 1.0. If the user is working with a mouse, and not a drawing tablet, the pen pressure will always be 0.0.

class M_Bone

The M_Bone class represents one bone in a skeleton.

Member Functions

string Name()

Returns the name of the bone.

Return value (string): the name of the bone

void SetName(name)

Sets the name of the bone.

Return value: none
name (string): the name of the bone

Member Variables

fSelected (bool)

true if the bone is selected, otherwise false


fName (LM_String)

the name of the bone


fParent (int)

an id number to the bone's parent bone (-1 if the bone has no parent)


fAngleControlParent (int)

an id number to the bone's angle control bone (-1 if the bone has no angle control)


fAngleControlScale (float)

the scale value for the bone's angle control


fPosControlParent (int)

an id number to the bone's position control bone (-1 if the bone has no position control)


fPosControlScale (LM_Vector2)

the scale value for the bone's position control


fScaleControlParent (int)

an id number to the bone's scale control bone (-1 if the bone has no scale control)


fScaleControlScale (float)

the scale value for the bone's scale control


fLength (float)

the bone's length


fStrength (float)

the bone's strength


fOffset (LM_Vector2)

the bone's 2D offset value


fAnimPos (AnimVec2)

the bone's animated position


fAnimAngle (AnimVal)

the bon'e animated angle


fAnimScale (AnimVal)

the bone's animated scale


fConstraints (bool)

true if the bone has min/max angle constraints, otherwise false


fMinConstraint (float)

minimum angle


fMaxConstraint (float)

maximum angle


fPos (LM_Vector2)

the bone's current position


fAngle (float)

the bone's current angle


fScale (float)

the bone's current scale


fTempPos (LM_Vector2)

a temporary variable to store the position


fTempLength (float)

a temporary variable to store the length


fTempAngle (float)

a temporary variable to store the angle


fTempScale (float)

a temporary variable to store the scale


fIKLock (AnimBool)

the bone's IK lock animation channel


fIKParentTarget (AnimVec2)

the bone's IK target animation channel


fIKGlobalAngle (AnimVal)

the bone's IK angle animation channel


fBoneDynamics (bool)

true if bone dynamics are on for this bone


fTorqueForce (float)

the influence of torque on bone dynamics


fSpringForce (float)

the influence of springiness on bone dynamics


fDampingForce (float)

the influence of damping on bone dynamics


fRestMatrix (LM_Matrix)

the transformation matrix for the bone at rest


fMovedMatrix (LM_Matrix)

the transformation matrix for the bone's current alignment


fPtMatrix (LM_Matrix)

the transformation matrix for the influence the bone has over vector points

class M_Curve

The M_Curve class represents a curve in a vector layer.

Member Functions

int CountPoints()

Returns the number of points that make up the curve.

Return value (int): the number of points that make up the curve

M_Point Point(id)

Returns one of the points making up the curve (use 0 for the first point on the curve).

Return value (M_Point): a point on the curve
id (int): id number of the point

int CountSegments()

Returns the number of segments on the curve. A segment is a section of curve between two control points.

Return value (int): the number of segments on the curve

bool IsSegmentSelected(segID)

Tests whether a segment is selected. (A curve segment is considered selected if the points at either end of it are selected.)

Return value (bool): true if the segment is selected, otherwise false
segID (int): a segment of the curve (starting with 0)

bool IsPointOnSegment(ptID, segID)

Returns true if the given point is on the given curve segment.

Return value (bool): true or false
ptID (int): a point identifier in the underlying mesh
segID (int): a segment of the curve (starting with 0)

bool IsSegmentOn(segID)

Tests whether a given curve segment is on or not. Segments that are "off" do not appear in rendered output.

Return value (bool): true or false
segID (int): segment identifier

void SetSegmentOn(segID, b)

Turns a curve segment on or off.

Return value: none
segID (int): segment identifier
b (bool): true to turn the segment on, false to turn it off

float GetCurvature(ptID, frame)

Returns the curvature through a given point on the curve.

Return value (float): curvature
ptID (int): which point on the curve
frame (int): at what time

void SetCurvature(ptID, curvature, frame)

Sets the curvature through a given point on the curve.

Return value: none
ptID (int): which point on the curve
curvature (float): curvature
frame (int): at what time

LM_Vector2 PointOnSegment(segID, percent)

Returns the location of a point on a segment.

Return value (LM_Vector2): a point located on the segment
segID (int): a segment of the curve (starting with 0)
percent (float): where on the segment to locate the point (from 0 to 1)

Member Variables

fClosed (bool)

true if the curve is closed, otherwise false

class M_Face3D

The M_Face3D class represents a face in a 3D mesh.

Member Variables

numP (int)

The number of points in the face (can be 3 or 4).


p1 (int)

An index to the first point in the mesh that makes up this face.


p2 (int)

An index to the second point in the mesh.


p3 (int)

An index to the third point in the mesh.


p4 (int)

An index to the fourth point in the mesh.


matID (int)

An index to the mesh material that should be used on this face.

class M_Material3D

The M_Material3D class represents the material properties for 3D mesh objects. For now, these properties are extremely basic.

Member Variables

color (rgb_color)

The color of the material.

class M_Mesh

The M_Mesh class is a container for the actual vector shapes in a vector layer. It contains points, curves, and fill and outline shapes.

Member Functions

void Clear()

Completely empties a mesh of all points and curves.

Return value: none

int CountPoints()

Returns the number of points in the mesh.

Return value (int): number of points

int CountCurves()

Returns the number of curves in the mesh.

Return value (int): number of curves

int CountShapes()

Returns the number of shapes in the mesh.

Return value (int): number of shapes

int CountGroups()

Returns the number of point groups in the mesh.

Return value (int): number of point groups

M_Point Point(id)

Access a point in the mesh.

Return value (M_Point): a point object
id (int): point identifier

M_Curve Curve(id)

Access a curve in the mesh.

Return value (M_Curve): a curve object
id (int): curve identifier

M_Shape Shape(id)

Access a shape in the mesh.

Return value (M_Shape): a shape object
id (int): shape identifier

M_PointGroup Group(id)

Access a point group in the mesh.

Return value (M_PointGroup): a point group object
id (int): point group identifier

void AddPoint(pos, attachID, frame)

Add a new point to the mesh.

Return value: none
pos (LM_Vector2): location of the new point
attachID (int): if -1, then start a new curve, otherwise attach the new point to this point id
frame (int): frame number

void AddPoint(pos, attachCurve, attachSeg, frame)

Add a new point to the middle of a curve.

Return value: none
pos (LM_Vector2): location of the new point
attachCurve (int): curve identifier to attach to
attachSeg (int): which segment of the curve
frame (int): frame number

void AddLonePoint(pos, frame)

Adds a lone, unconnected point to the mesh. Lone points are not normally allowed in Moho, so this function must be followed by one or more calls to the AppendPoint function.

Return value: none
pos (LM_Vector2): location of the new point
frame (int): frame number

void AppendPoint(pos, frame)

Adds a new point, connecting it with a curve to either the AddLonePoint point, or the last call to AppendPoint.

Return value: none
pos (LM_Vector2): location of the new point
frame (int): frame number

void DeletePoint(id)

Deletes a point from the mesh.

Return value: none
id (int): point identifier

bool WeldPoints(movingID, solidID, frame)

Welds two points together. The point identified by movingID will move if necessary to line up with solidID. Not all welding operations are allowed, so this function will return the status of the weld.

Return value (bool): true if successful, otherwise false
movingID (int): point identifier
solidID (int): point identifier
frame (int): frame number

bool ArePointsAdjacent(p1, p2)

Tests whether two points are adjacent on a curve.

Return value (bool): true if adjacent, otherwise false
p1 (int): point identifier
p2 (int): point identifier

int ClosestPoint(pos, ignoreID, maxPointID)

Returns the closest point to the given location.

Return value (int): point identifier
pos (LM_Vector2): a 2D location in the layer
ignoreID (int): point identifier - ignore this point when testing for the closest point
maxPointID (int): point identifier - ignore points with identifiers higher than this id

LM_Vector2 SelectedCenter()

Returns the location of the center point of the current group of selected points.

Return value (LM_Vector2): center location

void SelectedBounds(min, max)

Returns the boundaries of the current selection.

Return value: none
min (LM_Vector2): minimum X and Y coordinates
max (LM_Vector2): maximum X and Y coordinates

void PrepMovePoints()

Call this before moving a group of points around.

Return value: none

void TranslatePoints(offset)

Translate the currently selected points.

Return value: none
offset (LM_Vector2): the distance to translate them

void ScalePoints(sx, sy, centerVec)

Scale the currently selected points.

Return value: none
sx (float): x scale
sy (float): y scale
centerVec (LM_Vector2): the center point of the scaling operation

void RotatePoints(angle, centerVec)

Rotate the currently selected points.

Return value: none
angle (float): angle in radians
centerVec (LM_Vector2): the center point of the rotation operation

void SelectNone()

Deselect all points.

Return value: none

void SelectAll()

Select all points.

Return value: none

void SelectInverse()

Invert the current selection.

Return value: none

void SelectConnected()

Select all points that are connected by curves to any currently selected points.

Return value: none

void DeleteEdge(curveID, segID, frame)

Delete an edge of a curve.

Return value: none
curveID (int): curve identifier
segID (int): which segment on the curve to delete
frame (int): frame number

void DeleteShape(id)

Delete a fill or outline shape.

Return value: none
id (int): shape identifier

void LowerShape(id, toBottom)

Lower a shape in the stacking order.

Return value: none
id (int): shape identifier
toBottom (bool): true to lower it to the bottom, false to lower it one step

void RaiseShape(id, toTop)

Raise a shape in the stacking order.

Return value: none
id (int): shape identifier
toTop (bool): true to raise it to the top, false to raise it one step

void AddGroup(name)

Add a new point group, made up of the currently selected points.

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

void SelectGroup(name)

Select all the points in a given group.

Return value: none
name (string): name of the group to select

void DeleteGroup(name)

Delete a point group from the mesh.

Return value: none
name (string): name of the group to delete
<<  1 [23  >>