Python API 2.0 Reference
OpenMayaUI.MMaterial Class Reference
+ Inheritance diagram for OpenMayaUI.MMaterial:

Public Member Functions

def __init__ ()
 
def applyTexture ()
 
def evaluateDiffuse ()
 
def evaluateEmission ()
 
def evaluateMaterial ()
 
def evaluateShininess ()
 
def evaluateSpecular ()
 
def evaluateTexture ()
 
def getDiffuse ()
 
def getEmission ()
 
def getHasTransparency ()
 
def getHwShaderNode ()
 
def getShininess ()
 
def getSpecular ()
 
def getTextureTransformation ()
 
def materialIsTextured ()
 
def setMaterial ()
 
def shadingEngine ()
 
def textureImage ()
 

Static Public Member Functions

def __new__ ()
 
def defaultMaterial ()
 

Static Public Attributes

int kAmbientColor = 2
 
int kBumpMap = 4
 
int kColor = 0
 
int kCosinePower = 10
 
int kDiffuse = 5
 
int kEccentricity = 11
 
int kHighlightSize = 8
 
int kIncandescence = 3
 
int kReflectedColor = 15
 
int kReflectivity = 14
 
int kRoughness = 7
 
int kSpecularColor = 13
 
int kSpecularRollOff = 12
 
int kTransluscence = 6
 
int kTransparency = 1
 
int kWhiteness = 9
 

Detailed Description

This class is used in the draw functions of user defined shapes (see MPxSurfaceShapeUI) for setting up and querying materials in shaded mode drawing.

Constructor & Destructor Documentation

def OpenMayaUI.MMaterial.__init__ ( )
Initialize self.  See help(type(self)) for accurate signature.

Member Function Documentation

def OpenMayaUI.MMaterial.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMayaUI.MMaterial.applyTexture ( )
applyTexture(view, data) -> self

For materials that have texture, this method must be used before the OpenGL drawing to apply the texture to the current view.
This method should be called from within your MPxSurfaceShapeUI.draw() method.

* view (M3dView) - the view in which the textured drawing is to take place
* data (MDrawData) - the draw data from the draw request
def OpenMayaUI.MMaterial.defaultMaterial ( )
static
defaultMaterial() -> MMaterial

Get the default material. There will always be a default material in the scene and therefore the result of this function should always succeed.  The default material will correspond to the initialShadingGroup node that is in the scene.
def OpenMayaUI.MMaterial.evaluateDiffuse ( )
evaluateDiffuse() -> self

Perform necessary evaluation to be able to get diffuse back.
def OpenMayaUI.MMaterial.evaluateEmission ( )
evaluateEmission() -> self

Perform necessary evaluation to be able to get emission back.
def OpenMayaUI.MMaterial.evaluateMaterial ( )
evaluateMaterial(view, path) -> self

Evaluate a material. Must be called before evaluating or getting any material properties.

* view (M3dView) - the view
* path (MDagPath) - path to the object
def OpenMayaUI.MMaterial.evaluateShininess ( )
evaluateShininess() -> self

Perform necessary evaluation to be able to get shininess back.
def OpenMayaUI.MMaterial.evaluateSpecular ( )
evaluateSpecular() -> self

Perform necessary evaluation to be able to get specular back.
def OpenMayaUI.MMaterial.evaluateTexture ( )
evaluateTexture(data) -> self

Evaluate texturing related information. Must be called before getting any texture properties such as getHasTransparency(), getTextureTransformation() and applyTexture().

This method should be called from MPxSurfaceShapeUI.getDrawRequests().
The draw data argument is the MDrawData for the request that will carry the texture information to the MPxSurfaceShapeUI.draw() method.

* data (MDrawData) - draw request data to carry the texture information
def OpenMayaUI.MMaterial.getDiffuse ( )
getDiffuse() -> MColor

Get the GL diffuse color.
def OpenMayaUI.MMaterial.getEmission ( )
getEmission() -> MColor

Get the GL emission color.
def OpenMayaUI.MMaterial.getHasTransparency ( )
getHasTransparency() -> bool

Returns True if material or texture has transparency, False otherwise.
def OpenMayaUI.MMaterial.getHwShaderNode ( )
getHwShaderNode() -> MPxHwShaderNode

Get the hardware shader node.
def OpenMayaUI.MMaterial.getShininess ( )
getShininess() -> float

Get the GL shininess.
def OpenMayaUI.MMaterial.getSpecular ( )
getSpecular() -> MColor

Get the GL specular color.
def OpenMayaUI.MMaterial.getTextureTransformation ( )
getTextureTransformation(data, texXform) -> self
getTextureTransformation(data) -> [float, float, float, float, float, float]

Get the current textures transformation.

* data (MDrawData) - the draw data from the draw request
* texXform [OUT] (MMatrix) - storage for the texture transformation

Or
* data (MDrawData) - the draw data from the draw request
Returns the transformations values:
   rotateUV (float) - storage for rotatation value of the UV coordinates
   scaleU (float) - storage for u scale value
   scaleV (float) - storage for v scale value
   translateU (float) - storage for u translation value
   translateV (float) - storage for v translation value
   rotateFrame (float) - storage for rotatation value of the frame coordinates
def OpenMayaUI.MMaterial.materialIsTextured ( )
materialIsTextured() -> bool

Returns True if the material is textured, False otherwise.
def OpenMayaUI.MMaterial.setMaterial ( )
setMaterial(path, hasTransparency) -> self

Set the current GL material.

* path (MDagPath) - path to the object
* hasTransparency (bool) - whether the material has transparency
def OpenMayaUI.MMaterial.shadingEngine ( )
shadingEngine() -> MObject

Get the shading engined associated with this material.
def OpenMayaUI.MMaterial.textureImage ( )
textureImage(image, color, chan, dagPath, xRes=-1, yRes=-1) -> self

For materials that have texture, this method will attempt to retrieve the pixel map for a given mapped channel of that material.
Will fails If the channel is not mapped.

The material types that can be queried include:
  - Lambert
  - Phong
  - PhongE
  - Anisotropic
  - Blinn

Currently only channels mapped to single file textures is supported.

* image [OUT] (MImage) - The image retrieved. If no image could be retrieve, the value will not change.
* color [OUT] (MColor) - Either the mapped or unmapped color. If the channel is mapped then an RGBA value of (1,1,1,1) will be returned, otherwise the unmapped channel's current color value will be returned.
* chan (int) - Texture channel to check.
* dagPath (MDagPath) - Optional dag path to object. An object path is required to produce texture maps from non-2D procedural textures.
* xRes (int) - Optional width of image to create. The minimal allowed value is 2. This parameter only applies to procedural textures. The dimension in X will be 128 by default, if a value less than 2 is specified.
* yRes (int) - Optional height of image to create. The minimal allowed value is 2. This parameter only applies to procedural textures. The dimension in Y will be 128 by default, if a value less than 2 is specified.

Valid Texture channel:
  kColor
  kTransparency
  kAmbientColor
  kIncandescence
  kBumpMap
  kDiffuse
  kTransluscence
  kRoughness           PhongE only
  kHighlightSize       PhongE only
  kWhiteness           PhongE only
  kCosinePower         Phong only
  kEccentricity        Blinn only
  kSpecularRollOff     Blinn only
  kSpecularColor       Blinn and Phong(E) only
  kReflectivity        Blinn and Phong(E) only
  kReflectedColor      Blinn and Phong(E) only