david-cattermole / mayaMatchMoveSolver

A Bundle Adjustment solver for MatchMove related tasks.
https://david-cattermole.github.io/mayaMatchMoveSolver/
Other
102 stars 27 forks source link

Maya Tools - Project Marker Bundles on Mesh - On Multiple Frames #177

Closed david-cattermole closed 3 years ago

david-cattermole commented 3 years ago

Feature

Users wish to project a Marker's Bundle onto a mesh, across multiple frames.

Usually with mmSolver it's better to project on a single frame, and solve another transform, or sometimes it's better to solve the bundle's animated translate values. Nevertheless some users still want to project (ray-cast) onto a mesh on multiple frames.

There is currently no tool to do this.

The single frame tool is documented here: https://david-cattermole.github.io/mayaMatchMoveSolver/tools_markertools.html#project-marker-on-mesh-ray-cast

Example Function This function, when run in the Maya Script Editor, with mmSolver installed, will perform "Project Marker on Mesh" for each frame in the "inner" Maya frame range bar (not the "outer" frame range).

import mmSolver.utils.time
import mmSolver.api as mmapi
import mmSolver.tools.raycastmarker.tool as raycast_marker

BND_ATTRS = ['translateX', 'translateY', 'translateZ']

def main():
    cur_frame = maya.cmds.currentTime(query=True)
    frame_range = mmSolver.utils.time.get_maya_timeline_range_inner()
    sel = maya.cmds.ls(selection=True, long=True) or []
    for f in range(frame_range.start, frame_range.end + 1):
        maya.cmds.currentTime(f, edit=True, update=True)
        maya.cmds.select(sel, replace=True)
        raycast_marker.main()
        out_nodes = maya.cmds.ls(selection=True, long=True) or []
        bnd_nodes = [n for n in out_nodes if mmapi.get_object_type(n) == mmapi.OBJECT_TYPE_BUNDLE]
        if len(bnd_nodes):
            maya.cmds.setKeyframe(bnd_nodes, attribute=BND_ATTRS)
    maya.cmds.currentTime(cur_frame, edit=True, update=True)
    return

main()

Usage Steps

  1. Select at least one Marker node.
  2. (Optional) Add-select one or more meshes to force specific meshes to be considered.
    • If no meshes are selected, all meshes in the scene are considered.
  3. Run tool.
  4. The bundles for all selected Markers will be keyframed for each frame that could project/ray-cast on to a mesh.

Software Versions

david-cattermole commented 3 years ago

I've added a UI with controls for changing the frame range, and the ability to turn on/off the auto bundle attribute unlocking/relocking.

Also, I have changed the selection logic of the tool, now Markers and/or Bundles can be selected. The marker connected to each bundle will be projected. If a a bundle has multiple markers, the active viewport camera (or selected camera) will be used to decide which marker to use.

This will be released in v0.3.11.