class MMaterial

Jump to documentation

Hardware shading material class used in MPxSurfaceShapeUI (OpenMayaUI) (OpenMayaUI.py)

public members:

MMaterial ()
MMaterial ( const MMaterial & in )
~MMaterial ()
MStatus evaluateMaterial ( M3dView &, const MDagPath & )
MStatus evaluateShininess ()
MStatus evaluateDiffuse ()
MStatus evaluateEmission ()
MStatus evaluateSpecular ()
MStatus evaluateTexture ( MDrawData & data )
MStatus evaluateTextureTransformation ()
bool materialIsTextured () const
MStatus setMaterial (const MDagPath &, bool hasTransparency)
MStatus getShininess ( float & )
MStatus getDiffuse ( MColor & )
MStatus getEmission ( MColor & )
MStatus getSpecular ( MColor & )
MStatus getHasTransparency ( bool & )
MStatus getTextureTransformation (float& scaleU, float& scaleV, float& translateU, float& translateV, float& rotate)
void applyTexture ( M3dView &, MDrawData & )
MPxHwShaderNode * getHwShaderNode ( MStatus * ReturnStatus = NULL )

Documentation

Hardware shading material class used in MPxSurfaceShapeUI (OpenMayaUI) (OpenMayaUI.py)
Description

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

Functions

MMaterial:: MMaterial ()

Description

Constructor.

MMaterial:: MMaterial ( const MMaterial & other )

Description

Copy constructor.

Arguments

  • other

MMaterial:: ~MMaterial ()

Description

Destructor.

MStatus MMaterial:: evaluateMaterial ( M3dView & view, const MDagPath & path )

Description

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

Arguments

  • view the view
  • path path to the object

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateShininess ()

Description

Perform necessary evaluation to be able to get shininess back.

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateDiffuse ()

Description

Perform necessary evaluation to be able to get diffuse back.

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateEmission ()

Description

Perform necessary evaluation to be able to get emission back.

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateSpecular ()

Description

Perform necessary evaluation to be able to get emission back.

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateTexture ( MDrawData &data )

Description

Do texture evaluation and set a flag to tell if the texture is transparent.

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.

Arguments

  • data draw request data to carry the texture information

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

MStatus MMaterial:: evaluateTextureTransformation ()

Description

Perform necessary evaluation to be able to get the texture transformation information back.

Return Value

  • MS::kSuccess the evaluate was successfull
  • MS::kFailure the evaluate failed

bool MMaterial:: materialIsTextured () const

Description

Do we have a texture (evaluated or not).

Return Value

  • MS::true the material is textured
  • MS::false the material is not textured

MStatus MMaterial:: setMaterial (const MDagPath & path, bool hasTransparency)

Description

Set the current GL material.

Arguments

  • path path to the object
  • hasTransparency whether the material has transparency

Return Value

  • MS::kSuccess the method was successfull
  • MS::kFailure the method failed

MStatus MMaterial:: getShininess ( float & value )

Description

Get the GL shininess.

Arguments

  • value storage for shininess

Return Value

  • MS::kSuccess got valid shininess value
  • MS::kFailure failed to get valid shininess value

MStatus MMaterial:: getDiffuse ( MColor & color )

Description

Get the GL diffuse color.

Arguments

  • color storage for the diffuse color

Return Value

  • MS::kSuccess got valid diffuse color
  • MS::kFailure failed to get valid diffuse color

MStatus MMaterial:: getEmission ( MColor & color )

Description

Get the GL emission color.

Arguments

  • color storage for the emission color

Return Value

  • MS::kSuccess got valid emission color
  • MS::kFailure failed to get valid emission color

MStatus MMaterial:: getSpecular ( MColor & color )

Description

Get the GL specular color.

Arguments

  • color storage for the specular color

Return Value

  • MS::kSuccess got valid specular color
  • MS::kFailure failed to get valid specular color

MStatus MMaterial:: getHasTransparency ( bool & value )

Description

Get flag to determine if material or texture has transparency.

Arguments

  • value flag to return

Return Value

  • MS::kSuccess got valid transparency flag
  • MS::kFailure failed to get valid transparency flag

MStatus MMaterial:: getTextureTransformation (float& scaleU, float& scaleV, float& translateU, float& translateV, float& rotate)

Description

Get the current textures transformation.

Arguments

  • scaleU storage for u scale value
  • scaleV storage for v scale value
  • translateU storage for u translation value
  • translateV storage for v translation value
  • rotate storage for rotate value

Return Value

  • MS::kSuccess got valid transformation values.
  • MS::kFailure failed to get valid transformation values.

void MMaterial:: applyTexture ( M3dView & view, MDrawData & data )

Description

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.

Arguments

  • view the view in which the textured drawing is to take place
  • data the draw data from the draw request

MStatus MMaterial:: textureImage ( MImage &image, MColor &color, MtextureChannel chan, bool &mapped, MDagPath &dagPath, int xRes, int yRes)

Description

For materials that have texture, this method will attempt to retrieve the pixel map for a given mapped channel of that material. If the channel is not mapped than a status of failure will be returned.

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

Currently only channels mapped to single file textures is supported.

Arguments

  • image The image retrieved. If no image could be retrieve, the value will not change.
  • color Either the mapped or unmapped color. If the channel is mapped than an RGBA value of (1,1,1,1) will be returned, otherwise the unmapped channel's current color value will be returned.
  • mapped Whether the channel is mapped or not (true or false)
  • dagPath Optional dag path to object. An object path is required to produce texture maps from non-2D procedural textures.
  • xRes 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 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.

Return Value

  • Mstatus::sSuccess If the channel exists on the material.
  • Mstatus::sFailure If the channel does not exist on the material

MPxHwShaderNode * MMaterial:: getHwShaderNode ( MStatus * ReturnStatus )

Description

Get the hardware shader node. If this material has a hardware shader, a pointer to it will be returned in hwShader. If there is no hardware shader, hwShader will be set to NULL.

Arguments

  • hwShader a pointer to an MPxHwShaderNode.

Return Value

  • MS::kSuccess successfully returned a pointer or NULL
  • MS::kFailure failed for some reason

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright