Tag Archives: maya 2012

mayaScript

Automatically set Default Settings for Maya

Usually one could simply store and recall the Maya Preferences File. Here is a simple script if you want to enable default settings.

import pymel.core as pm


def manage_default_options(**kwargs):
    """
    Sets Various Default options for Maya
    
    viewmManip : Default Hide the manipulator Cube
    gradient: Default Hide the Background gradient
    autosave: Default Enable Autosave
    mentalray: Default Enable mr as Default Render Engine
    interactiveCreation: Enables Disables Interactive Creation Mode for Primitive Objects
     
    hardware2: Optional Enable Hardware Renderer 2.0 as Default Render Engine
    
    """
    
    #Disable View Cube
    pm.viewManip(visible=kwargs.get("viewManip", False))
    
    #Disable Background Gradient
    pm.displayPref(displayGradient=kwargs.get("gradient", False))
    
    #Infinite Undo
    pm.undoInfo(state = True, infinity = kwargs.get("infiniteUndo", True))
    
    #Enable Autosave, max Versions 10, interval 15min
    pm.autoSave(enable=kwargs.get("autosave", True), maxBackups=kwargs.get("maxBackups", 10), interval=kwargs.get("interval", 900))
    
    #Activate Mental Ray
    if kwargs.get("mentalray", True):
        enable_mr_plugin()
    
    #Sets Hardwarerenderer 2.0 as Default
    if kwargs.get("hardware2", False):
        pm.PyNode("defaultRenderGlobals").currentRenderer.set("mayaHardware2")
    
    #Expose Mental Ray Production Nodes
    pm.optionVar["MIP_SHD_EXPOSE"] = 1
    
    #Disable Interactive Creation
    set_interactive_creation(kwargs.get("interactiveCreation", False))
    

def set_interactive_creation(enabled=False):
    """
    Enables or Disables Interactive Creation
    """
    pm.optionVar['createNurbsPrimitiveAsTool'] = enabled
    pm.ui.CommandMenuItem("MayaWindow|mainCreateMenu|menuItem285|toggleCreateNurbsPrimitivesAsToolItem").setCheckBox(enabled)
    
    pm.optionVar['createPolyPrimitiveAsTool'] = enabled
    pm.ui.CommandMenuItem("MayaWindow|mainCreateMenu|polyPrimitivesItem|toggleCreatePolyPrimitivesAsToolItem").setCheckBox(enabled)


def enable_mr_plugin():
    """
    loads and sets the mental Ray Plugin as default
    """
    load_plugin('Mayatomr')
    pm.PyNode("defaultRenderGlobals").currentRenderer.set("mentalRay")
    print ('# Result: mental ray Plugin loaded #')
    

def load_plugin(plugin_name):
    """
    if the plugin is not loaded, it is loaded and set to autoload
    
    pluginName: name of the plugin to be loaded
    """
    if not pm.pluginInfo(plugin_name, q=True, loaded=True):
        pm.loadPlugin(plugin_name)
        pm.pluginInfo(plugin_name, edit=True, autoload=True)

if __name__ == "__main__":
    manage_default_options()

Maya 2012: Create static meshes for UDK

The easiest way to export meshes from Maya 2012 to UDK is using the FBX-Workflow.

The steps are:

  1. Prepare the Material
  2. Prepare the Model
  3. Export the Model and Material
  4. Import the Model and Material

The ActorX plugin has been retired and is replaced by the FBX-workflow.

Setup FBX Plugin

Currently UDK supports the Format FBX 2012. You can get the latest version from Autodesk (free):

http://usa.autodesk.com/adsk/servlet/pc/item?id=10775855&siteID=123112

  1. Open Window > Preferences > Plugin-Manager
  2. Activate fbxmaya.mll (loaded and auto load)
  3. Check the version by clicking on the “i” (PluginVersion 2012.2)

Prepare Materials

Only the Standard Shaders Anisotropic,Blinn,Lambert,Phong,Phong E are supported.

UDK Map/Texture Maya Setup
Diffuse Color > File
Emissive Incandescence > File
Specular Specular Color > File
Specular Power Cosine Power > File
Normal Map Bump > File
  1.  UV-Mapping: All UV-Mapping will be transferred to UDK.
  2. All Material names will be transferred to UDK
  3. Make sure all Textures are in a .tga format for easy transfer to UDK

Prepare Model

  1. Name your Object something meaningful.
  2. Make sure that the scale fits for the UDK Gridsize (e.g use the jbUDK Tools)
  3. On exported Object the Pivot Point is always set to (0,0,0) position the geometry correctly
  4. UDK only accepts geometry that has been Triangulated. Select the Meshes and use Mesh > Triangulate. If problems occur you have to redraw the topology by hand with the split polygon tool.
  5. Convert Nurbs Geometry to PolyGeometry (Modify > Convert > Nurbs to Polygons) in the Options select Triangles.
  6. In UDK Static meshes are limited to 65535 vertices. Higher Polycounts cannot be imported. Check your Polycount by activating Display > Heads up Display > Polycount. (Using Normal Maps can help to reduce the Polycount)

Create Collision Model

The collision Model can be created manually in Maya or calculated with a feature within UDK. However creating a correct collision model in Maya saves a lot of time, and gives you more control over how the collision model will look like.

Maya

  1. Manually Create a simplified Mesh for the Collisions
  2. Collision meshes are identified by the importer based on their name. The collision naming syntax should be:
    •  UBX_[RenderMeshName] - Boxes are created with the Box objects type with the Cube polygonal primitive in Maya. You can’t move the vertices around or deform it in any way to make it something other than a rectangular prism, or else it won’t work.
    • USP_[RenderMeshName] - Spheres are created with the Sphere object type. The sphere does not need to have many segments (8 is a good number) at all because it is converted into a true sphere for collision. Like boxes, you shouldn’t move the individual vertices around.
    • UCX_[RenderMeshName] - Convex objects can be any completely closed convex 3D shape. For example, a box can also be a convex object.

UDK Static Mesh Editor

  1. In the Contentbrowser RMB on the Mesh and select “Edit with Static Mesh Editor
  2. In the Collision Menu select the proper Collision Model. Most of them are Boxes with various sides.

FBX Export

  1. Check again if all Objects have a proper Name.
  2. Select the Objects for Export
  3. File > Export Selection (FileType FBX Export)

FBX Import

  1. Open a Explorer Window and navigate to the exported file
  2. Open UDK and the ContentBrowser and drag the file from the Explorer to UDK
  3. In the Options scroll down to Materials and activate “Import Materials”, “Import Textures”
  4. In the ContentBrowser select the Static Mesh and RMB > Edit with Static Mesh Editor
  5. In the Static Mesh Editor you can change the Camera Position with RMB-Drag. When you found a meaningful angle Tool > Save Thumbnail Angle.

Further Reading:

http://udn.epicgames.com/Three/FBXStaticMeshPipeline.html

http://udn.epicgames.com/Three/FBXMaterialPipeline.html

maya-logo-small

Maya 2012: Bonus Tools Update

Für Maya 2012 wurden die Bonustools seit langer Zeit nochmals neu angeordnet und verbessert.

Die genauen Informationen und Hinweise zu den neuen Tools findet man unter:

http://area.autodesk.com/blogs/stevenr/bonustools

Das Hauptvideo kann man überspringen, im Prinzip sagt es nur das man für manche Tools sich Python installieren/konfigureren muss.

Update (21.5.11): Die Bonus-Tools können jetzt unter http://area.autodesk.com/bonus_tools runtergeladen werden