Home | School

LunarLander using the Maya API


Create a custom Maya plugin to produce an accurate (research) Lunar Lander landscape with First Order Nurbs Curves on the XY plane. The terrain should contructed from equally spaced spans/sections and be customizable using a dialog box for data input, for example:

  • number of sections (512, 256, 128, 64, 32).
  • y length of section (float value)
  • Skill level (easy medium hard)
  • number of landing pads

Add custom attributes ( gradient and intersect values for each line segment) for later collision detection with the Lunar Module. Think about how the terrain will behave in the finished version of the game.


This game will be played using Maya as a game engine, thereforeÉ Maya will be launched and the user will use a MEL script file to initialize the game. The user will be presented with a dialog box to set specific game settings.

The MEL script will create necessary nodes and connect them. It will also open a new view window to present the terrain and general game play window to the user.

The player will then use the connected joystick/controller to move the lander around the landscape. If the lander collides with the terrain the game is over and the lander disappears from view. If the user lands the lander on the flat part of the terrain the user wins the game.


GenTerrain Command

The GenTerrain plug-in makes available a command that can be called from the command line and/or MEL to generate terrain for the Lunar Lander to navigate. The GenTerrain command has undo and redo abilities and accepts the following arguments.

  • -spans, -s:
    describes the number of spans in the terrain
  • -maxHeight, -mx:
    describes the height variation in the terrain curve
  • -minHeight,-mn:
    describes how shallow or steep the curve is (slope)
  • -length, -l:
    describes the total length of the terrain curve
  • -pads, -p:
    sets how many landing pads will be generated on the terrain
  • -plength, -pl:
    sets the length of the landing pad
  • -fHeight:
    output attribute to send the height of the terrain at a specific point
  • -craftX:
    input connection attribute to accept the current x coordinate of the lander

When the GenTerrain Command is called, it parses the command-line arguments, builds and draws a nurbs curve on the x/z plane to be used as terrain.

Lander Node

The LanderNode plug-in is a DAG Node that is derived from the MPxLocatorNode class. This is a custom locator that has a specified appearance, attributes and abilities. Using OpenGL the locator is given itŐs Lunar Lander shape. The draw function also handles collision animation, thruster fire and player HUD type statistic updates. The following custom attributes have been added to the Lander node:

  • Height:
    This attribute tracks the landerŐs height above the terrain
  • State:
    The state attribute keeps track of when the lander has crashed or is out of fuel
  • DirControl:
    This attribute is used to track horizontal motion of the lander
  • UpControl:
    This attribute is used to track vertical motion of the lander

Joystick Node

The joystick node connects maya to the joystick device.

  • -m_xaxis:
    the current x-axis input value from the joystick
  • -m_yaxis:
    the current y-axis input value from the joystick
  • -m_zaxis:
    the current z-axis input value from the joystick

User Interface (MEL)

The MEL script builds the UI, creates the nodes and connects them through script generated expressions.

(Hypergraph InputOutput)


Testing was done mainly though creating each node separately and calling the terrain function on itŐs own with out the lander. The joystick plugin was tested by connecting it to a sphere in a blank scene first. Modifications were made before "gluing" everything together with the final MEL command.


Challenges were building HUD elements and connecting them to the lander.