Games Development 2 Maya Embedded Language MEL - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Games Development 2 Maya Embedded Language MEL

Description:

Artists use MEL to create shortcuts, access advanced features and add custom controls ... Using Maya- General- MEL and Expressions. Using Maya- General- Python ... – PowerPoint PPT presentation

Number of Views:152
Avg rating:3.0/5.0
Slides: 14
Provided by: lauren80
Category:

less

Transcript and Presenter's Notes

Title: Games Development 2 Maya Embedded Language MEL


1
Games Development 2Maya Embedded Language (MEL)
  • CO3301
  • Week 14

2
Contents
  • MEL Introduction
  • Alternatives
  • MEL Language Overview
  • Objects, Nodes Attributes

3
Introduction X-files
  • So far we have imported meshes almost exclusively
    using Microsoft .X files
  • However, we have seen the limitations of the
    format
  • Only a single texture per material
  • No normal maps, gloss maps etc.
  • No implicit support for advanced vertex data
  • E.g. tangents, binormals
  • Also no support for custom data
  • Specialised vertex, polygon or material
    information
  • For unusual shaders

4
Introduction Scripted Export
  • In the 2nd year we noted these limitations and
    those of other file formats
  • Concluded that no existing file format is
    flexible enough for the majority of game needs
  • Suggested the possibility of writing custom
    exporters
  • In the modelling tool - Maya or 3ds Max
  • As well as exporting mesh data, could export
    other game data
  • Lights, cameras, paths
  • Physics info, object stats such as HP, etc.
  • AI waypoints, game logic triggers etc.

5
Maya MEL Scripting
  • In this session we introduce the Maya Embedded
    Language (MEL)
  • This scripting language is at the core of the
    Maya user interface
  • The entire GUI is written in the language
  • All Maya content and features can be accessed /
    controlled with the language
  • Artists use MEL to create shortcuts, access
    advanced features and add custom controls
  • But we are interested mainly in accessing
    exporting the scene contents

6
Alternatives to MEL
  • Maya also has a C API
  • Internal access to Maya
  • High performance, but more complex than MEL
  • Latest versions also support Python scripting
  • Similar interface and commands to MEL
  • Most MEL commands have Python versions
  • Further information in Maya documentation
  • Using Maya-gtGeneral-gtMEL and Expressions
  • Using Maya-gtGeneral-gtPython
  • Developer Resources-gtAPI Guide

7
MEL Language Overview
  • MEL is similar to the language Perl
  • With a similar command line style at times
  • As such it traces its roots to C
  • So it should feel reasonably familiar
  • MEL scripts / functions act as new Maya commands
  • Can be run from the Maya command line
  • Or attached to new buttons or menus in the
    interface
  • Export scripts lend themselves well to this

8
MEL Types and Variables
  • All variable names must begin with the symbol
  • Thereafter follow usual C conventions
  • Including case-sensitivity
  • E.g. value1 or New_Variable
  • Have the usual data types
  • Integer (int), floating point (float) and string
  • Variable sized (1D) arrays
  • A vector type - a triple of floats
  • Matrices (matrix), a fixed-size 2D table of
    floats
  • The latter two are particularly useful for 3D
    data

9
MEL Using Variables
  • Variable declarations
  • int a 5
  • float b 3.456
  • vector v ltlt1.2, 3.4, 6.5gtgt
  • float ar 1.2, 3.4, 4.5 // Array of floats
  • matrix mtx32 // A 3x2 matrix of floats
  • No bool type, although true 1 and false 0
  • Note the usual C comment style
  • Assignment variations as C
  • , , -, /, , , --, etc.
  • Conditions same too
  • , gt, gt, lt, lt, !, etc.

10
MEL Arrays
  • Arrays automatically expand as needed
  • int scores // Declared as a zero element
    array scores150 3 // Now a 151 element
    array
  • scores200 5 // Now a 201 element array
  • Memory is allocated as this happens, beware
  • int askingForTrouble
  • askingForTrouble123456789 2
  • Can find size of arrays and clear them
  • string hats "blue", "red", "black
  • print( size(hats) ) // 3
  • clear( hats )
  • print( size(hats) ) // 0

11
MEL Control
  • Blocks and most control structures also as C,
    e.g
  • if (a b)
  • ...
  • else
  • ...
  • while (a lt size(arr))
  • ...
  • for loops the same, plus a for-in version
  • string arr3 "red","green","blue"
  • for (k in arr)
  • print(k)

12
MEL Procedures (functions)
  • Create procedures using the following syntax
  • global proc float SquareAndAdd(float x, float
    y)
  • return x x y
  • Without global the procedure is only available in
    the script file in which it is defined
  • Not from Maya command line / interface
  • No void, just leave out the return value if you
    dont want one

13
MEL Vectors Matrices
  • Vector reading
  • vector test ltlt3.0, 7.7, 9.1gtgt
  • print(test.y) // 7.7
  • Cant write to individual vector elements
  • (test.y) 5.5 // Error
  • vector test ltlt3.0, 7.7, 9.1gtgt // Instead...
  • test ltlttest.x, 5.5, test.zgtgt // OK
  • Matrix reading and writing straightforward
  • matrix a322 ltlt2.5, 4.5 1.12, 1.3gtgt
  • a310 9.2
  • print(a311 )
Write a Comment
User Comments (0)
About PowerShow.com