Python & RMS
Repurposing MoCap Data


return to main index



Introduction

The tutorial, Python: Parsing MoCap Data, presented two python classes (MoCapMarker and MoCapDB) that can read and store mocap data. This tutorial presents a super class of MoCapDB, called MoCapRMan, that uses the mocap coordinate data read by the base class to generate rib archives containing RenderMan RiPoint, RiCurves and RiBlobby geometry. Examples of the geometry created by instances of the MoCapRMan class are shown below. The data files used for the illustrations was obtained from the website of the Advanced Computing Center for the Arts and Design, Ohio State University,
      http://accad.osu.edu/research/mocap/data/handspring1TXT.ZIP



Figure 1
343 fields (frames) - one RiPoint per mocap marker.




Figure 2
41 RiCurves - one curve per marker each with 343 cvs.




Figure 3
One RiBlobby - one blob per marker per frame (14063 blobs).


When used with an approriate interface with Maya the primitives generated by MoCapRMan can easily be animated - figure 4. The .rman and .mel scripts that create a GUI for use with MoCapRMan is given later in this tutorial.



Figure 4
Animation with a 'trail' of 15 frames.


Figure 5
Animation with a 'trail' of 160 frames.


Figure 5
Animation of a RiBlobby rendered volumetrically.



Standalone Testing of the MoCapRMan Class

The code for the MoCapRMan class can be found here - MoCapRMan.py. In addition to using MoCapDB, MoCapRMan also uses MayaProjUtils.py. The steps shown below outline the easiest way to test the scripts.


Step 1

The following scripts, MoCapDB.py, MoCapRMan.py and MayaProjUtils.py should be saved in the same directory, for example,

    /Users/jdoe/Documents/mocap_test
Step 2

Download and unzip a sample TXT mocap data file from,
      http://accad.osu.edu/research/mocap/mocap_data.htm
and save the file in the same directory as the python scripts.


Step 3

Make a directory named 'RIB_Archive' in the 'mocap_test' directory. MoCapRMan will expect to save the rib archive files it creates in the 'RIB_Archive' folder.


Step 4

Save the following python script in the 'mocap_test' directory as 'simple_test.py'.


from MoCapRMan import MoCapRMan
  
scale = 0.01
# The following path and name of the mocap TXT will require editing.
datapath = '/Users/jdoe/Documents/mocap_test/handspring.txt'
spread = 1
steps = 1
pnt_width = 0.3
cache = 'Compute'
  
mo = MoCapRMan('anyname', datapath, scale)
rib = mo.writePoints(spread,steps,pnt_width,cache)
print rib

Open simple_test.py in Cutter and choose control+e, alt+e or Apple+e to execute the file. Cutter's Process Monitor window will echo the path to the rib archive file created by 'mo'.
If the archive file contains data then you have confirmed the scripts are working correctly.


Step 5

The following rib file can be used to render the archive.


Display "untitled" "it" "rgba"
Format 640 360 1
Projection "perspective" "fov" 20
ShadingRate 1
  
Translate  0 0 100
Rotate -30 1 0 0
Rotate 0   0 1 0
Scale 1 1 -1
WorldBegin
    ReadArchive "PATH_TO_ARCHIVE"
WorldEnd


MoCapRMan, Maya & RMS

The easiest way to use MoCapRMan with Maya is to create an artist-friendly user interface. This section of the tutorial demonstrates how an interface for use by Pixar's RenderMan Studio (RMS) can be added to Maya - figure 6.



Figure 6


MoCapDB.py, MoCapRMan.py and MayaProjUtils.py should be moved to the directory from which the users custom python scripts are sourced by Maya. The interface is implemented by the following scripts.
      mocapUI.rman
      mocapUI.mel, and
      mocapRI.mel
They should be saved in the directory from which users custom mel scripts are sourced by RMS and Maya. Suggestions about the directory structure to store custom scripts for use with RMS and Maya can be found in the following tutorial,
      RMS: Setup for RiMel, Rman, Slim, Image Tool & Python


Maya Workflow

1.   Create a proxy object, for example, a poly cube.
2.   Select the proxy and run this mel command,
      mocapUI();
3.   Toggle the transform and shape tabs of the proxy to display the interface.
4.   Select the mocap data file and render the scene.

To use another data file frame zero must be rendered. New instance of MoCapRMan are always created when frame zero is rendered.





© 2002- Malcolm Kesson. All rights reserved.