Realtime Camera Recording in Maya

Real-time Camera Motion Recording in Maya for under $50:
Using a SpaceNavigator for Maya Camera Flythroughs

a tutorial from cgspeed.com
v1.02 last update June 29, 2008

BONUS: I've made a 15-minute supplementary video tutorial that walks through most of the steps of this written tutorial. You can view it at www.dailymotion.com/bmhahne/video/10013312 or as part of the original blog announcement of this tutorial. However, you should still read this tutorial since it's difficult to read some of the small print in the video version.

DISCLAIMER and heads up: One of the steps in this HowTo requires you to make minor modifications to a MEL script. If you're not comfortable editing a text file within Windows, then this tutorial probably isn't for you. This tutorial is provided on an as-is basis and isn't guaranteed to work on your system, or in fact on any system except mine. :-)

Determining and setting up your camera moves in a 3D scene can be a tedious task in many animation applications, because the application typically expects you to keyframe the camera moves, and to do so in a non-realtime fashion. The traditional keyframing approach can make it difficult to product smooth camera flythroughs and flybys in which the camera both moves (translates) and rotates in a professional and smooth manner. For faster shot camera positioning and animation, we need a method that allows us to move our camera in realtime, with Maya recording both the position and rotation of the camera so that we can play it back later. The Craft Observercam plugin can do this, however it comes with a $500 price tag.

Thankfully, there's a much lower-cost solution that allows you to easily move a camera through a scene in realtime, and record the camera's position over time with automatic keyframe generation. The 3dConnexion SpaceNavigator is a 6-degree-of-freedom USB navigation device designed to allow animators to easily move around and rotate a virtual camera in 3D space. The basic ("Personal Edition") version of the SpaceNavigator sells for under $50 street price, and its driver installation .exe file includes a special Maya plug-in that provides a variety of features, including real-time camera recording.

Picture: a SpaceNavigator input device

Here's what you need to do to set up 3D camera capture via a SpaceNavigator in Maya:

Context:

Windows XP SP2, 32-bit

Maya 8.0

CPU: AMD Athlon64 4600 dual-core

3dConnexion SpaceNavigator PE with driver release 3.6.6 (most current as of June 2008)

1. Install the Windows SpaceNavigator driver per the instructions that ship with the SpaceNavigator.

This should simply require you to run a single .exe file, which should also auto-detect your Maya installation and allow you to install the Maya plug-in.

2. Get accustomed to moving around with the SpaceNavigator.

Before you do any camera capture, you need to get used to navigating a scene with the SpaceNavigator. Practice moving around a scene in a smooth way, with in-flight turns and other moderately complex camera moves.

3. Find the plug-in control window.

The SpaceNavigator driver should have created a new Maya tab in your Maya shelf, near the top of the Maya window, called "Navigation". Find this tab. You might need to use "display-->UI elements-->shelf" to show the shelf if you don't have it displayed by default. In the Navigation tab, you should see two purple-and-green icons: one that looks like a cube, the other like a question mark. These are new icons created by the SpaceNavigator Maya plugin. Click on the SpaceNavigator cube icon to bring up a pop-up 3dConnexion window that shows the settings options for the plug-in. Experiment with some of the settings, and/or read the built-in help, so that you start to understand what you can do with the SpaceNavigator control window within Maya.

4. Find the MagellanStartup MEL script. Quit Maya, then within Windows find your Maya startup scripts directory, which will generally be at a path such as C:\program files\alias\maya8.0\scripts\startup

In this Maya scripts directory, you should find several new MEL scripts that the 3dConnexion installer put there, including:

MagellanStartup.mel

C3DxButtonEditor.mel

C3DxControlPanel.mel

C3DxMapping.mel

Most of the heavy lifting of the SpaceNavigator's Maya software is in the MagellanStartup.mel file.

5. Fix the recording speed in the MagellanStartup MEL script.

When I try to do camera-move recording on my Athlon 4600 machine using the default MagellanStartup settings, 3dConnexion's MEL script records too fast -- the playback/recording timer moves significantly faster than real-time, making it difficult to get the camera moves that I want at the speed I want. To fix this, do the following:

5.1 Make a backup copy of the MagellanStartup.mel file, such as by copying it and renaming the copy "MagellanStartup-bak.mel".

5.2 Using Windows Notepad/Wordpad, edit the original MagellanStartup.mel file, then find the three calls to the subroutine called IncrementTimeLine. What you're looking for are lines that look like this:

IncrementTimeLine(500);

You should find three of them.

5.3 In each (all three) of the IncrementTimeLine(500) calls, change the 500 to 250. This slows down the rate at which MagellanStartup.mel will record your camera moves. On my machine, a value of 250 works well, but you might need to change the value to something lower or higher than 250. I haven't tested yet whether the appropriate value is CPU-dependent or not.

5.4 Save the modified MagellanStartup.mel file, maintaining the name MagellanStartup.mel

6. Set up Maya and the SpaceNavigator plug-in for camera motion capture

6.1 Start Maya again, then create a new camera and name it "shotcam". Don't start moving it around yet - first do step 6.2 below.

6.2 This part is important. Bring up the Maya attribute editor for the camera's transform node. This node is not the node of type "camera", rather it's a node of type "transform" which should have a "Transform Attributes" attibute section at the top. In the Transform Attributes section, change "rotate order" from the default of "xyz" to "yzx". This change is to prevent a variety of nasty rotational whipsawing that 3dConnexion's plug-in will do to you camera keyframes if you simply take the default.

6.3 Put a few pieces of 3D geometry into the scene if you like, so that you have a small set that you can fly around in.

6.4 Set the total number of animation frames in your scene to something that will give you a reasonable amount of camera recording time, such as 300 frames.

6.5 Make sure that you presently have Maya auto-keyframing turned OFF. To confirm this, look in the very bottom right of the Maya interface for the key icon. The key should be black, which means that you presently have auto-keyframing off. If the key is red, click the key once to turn it back to black.

6.6 Set your current frame to 1, and make sure that Maya is set to play the full range of frames from 1-300 if you were to hit the play button.

6.7 View your scene through your new camera "shotcam". To do this, you select "panels --> perspective --> shotcam" from within your scene window.

6.8 Use the SpaceNavigator to position shotcam where you want it to be at the start of the camera animation.

6.9 Bring up the 3DConnexion Maya control window -- this is the window that you found in step 3 of this tutorial -- and set it up as follows:

View: Camera

Rotation Pivot: Camera / View

Fly Mode: checked (this is default)

Disable Rolling: checked (or uncheck it if you're really, really good with your SpaceNavigator)

Options:

3DView Lock: unchecked

Enable Object Movement: unchecked

Enable Autokey Animation: checked (this is not the default - you need to check it)

Device Settings: all options unchecked

6.10. Engage keyframe recording mode

Take your hand OFF of the SpaceNavigator, because you don't want to trigger the recording right away. Using your mouse, click the auto-keyframe button in the lower right of Maya's interface to turn auto-keyframing ON. The key should turn red. The playback slider should, however stay at frame 1 for the moment, because you aren't touching the SpaceNavigator. As soon as you move the SpaceNavigator to start moving your camera, 3DConnexion's script will start to record keyframes for the camera and you should see the playback slider start to increment, hopefully in something resembling real-time.

6. 11 Move your camera using the SpaceNavigator. Your Maya playback slider should increment, and the current-time counter near the playback slider will similarly show you what frame you're at. The auto-keyframe icon will actually change from red to black during your camera recording session, but that's just an artifact of how the MagellanStartup MEL script records the frames.

6.12 When you're done with your camera motion, or when your timeline has hit the last frame available to you, take your hand off of the SpaceNavigator. Recording should stop and the auto-keyframe "key" icon should turn red again. Using your mouse, click the auto-keyframe icon to turn it black, which turns off auto-keyframing.

6.13 Move your timeline slider all the way to the left (frame 1), then hit the play button to see if your shotcam moves. It should have keyframes on it now, which you can examine using the graph editor, edit, etc.

That's all! It might take you a couple of takes to get the exact camera motion that you want, but once you've practiced a bit at using the SpaceNavigator for Maya scene navigation, you should be able to quickly produce rather complex camera moves in real-time, with no need to manually keyframe anything or set up camera motion paths.

Comments, suggestions, improvements, or sample videos that use this techique? Feel free to email me -- see my email address in the copyright note below.

(CHALLENGE to Blender fans: is a similar camera recording process possible in Blender? If yes and you'd like to write up the process to a level of detail similar to what I've posted here for Maya, drop me a note and I can work with you to edit and publish a Blender camera flythrough tutorial here at cgspeed.com.)

__________________________________________________________________________

This tutorial is copyright (c) 2008 by Bruce Hahne (hahne at io dot com). Non-profit, non-commercial redistribution permitted and encouraged. For other forms of redistribution or publication, please contact the author.