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
OpenMayaUI.MMaterial.__init__
(
)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Member Function Documentation
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
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.
OpenMayaUI.MMaterial.evaluateDiffuse
(
)
evaluateDiffuse() -> self
Perform necessary evaluation to be able to get diffuse back.
OpenMayaUI.MMaterial.evaluateEmission
(
)
evaluateEmission() -> self
Perform necessary evaluation to be able to get emission back.
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
OpenMayaUI.MMaterial.evaluateShininess
(
)
evaluateShininess() -> self
Perform necessary evaluation to be able to get shininess back.
OpenMayaUI.MMaterial.evaluateSpecular
(
)
evaluateSpecular() -> self
Perform necessary evaluation to be able to get specular back.
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
OpenMayaUI.MMaterial.getDiffuse
(
)
getDiffuse() -> MColor
Get the GL diffuse color.
OpenMayaUI.MMaterial.getEmission
(
)
getEmission() -> MColor
Get the GL emission color.
OpenMayaUI.MMaterial.getHasTransparency
(
)
getHasTransparency() -> bool
Returns True if material or texture has transparency, False otherwise.
OpenMayaUI.MMaterial.getHwShaderNode
(
)
getHwShaderNode() -> MPxHwShaderNode
Get the hardware shader node.
OpenMayaUI.MMaterial.getShininess
(
)
getShininess() -> float
Get the GL shininess.
OpenMayaUI.MMaterial.getSpecular
(
)
getSpecular() -> MColor
Get the GL specular color.
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
OpenMayaUI.MMaterial.materialIsTextured
(
)
materialIsTextured() -> bool
Returns True if the material is textured, False otherwise.
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
OpenMayaUI.MMaterial.shadingEngine
(
)
shadingEngine() -> MObject
Get the shading engined associated with this material.
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