#include <MMaterial.h>
This method is obsolete.
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.
Public Types | |
enum | MtextureChannel { kColor = 0, kTransparency, kAmbientColor, kIncandescence, kBumpMap, kDiffuse, kTransluscence, kRoughness, kHighlightSize, kWhiteness, kCosinePower, kEccentricity, kSpecularRollOff, kSpecularColor, kReflectivity, kReflectedColor } |
Channels which can be queried. More... | |
Public Member Functions | |
MMaterial () | |
Constructor. | |
MMaterial (const MMaterial &in) | |
Copy constructor. More... | |
MMaterial (const MObject &, MStatus *ReturnStatus=NULL) | |
Constructor from shader set MObject. More... | |
~MMaterial () | |
Destructor. | |
MStatus | evaluateMaterial (M3dView &, const MDagPath &) |
Evaluate a material. More... | |
MStatus | evaluateShininess () |
Perform necessary evaluation to be able to get shininess back. More... | |
MStatus | evaluateDiffuse () |
Perform necessary evaluation to be able to get diffuse back. More... | |
MStatus | evaluateEmission () |
Perform necessary evaluation to be able to get emission back. More... | |
MStatus | evaluateSpecular () |
Perform necessary evaluation to be able to get specular back. More... | |
MStatus | evaluateTexture (MDrawData &data) |
Evaluate texturing related information. More... | |
bool | materialIsTextured () const |
Do we have a texture (evaluated or not). More... | |
MStatus | setMaterial (const MDagPath &, bool hasTransparency) |
Set the current GL material. More... | |
MStatus | getShininess (float &) |
Get the GL shininess. More... | |
MStatus | getDiffuse (MColor &) |
Get the GL diffuse color. More... | |
MStatus | getEmission (MColor &) |
Get the GL emission color. More... | |
MStatus | getSpecular (MColor &) |
Get the GL specular color. More... | |
MStatus | getHasTransparency (bool &) |
Determine if material or texture has transparency. More... | |
MStatus | getTextureTransformation (const MDrawData &data, MMatrix &texXform) |
Get the current textures transformation. More... | |
MStatus | getTextureTransformation (const MDrawData &data, float &rotateUV, float &scaleU, float &scaleV, float &translateU, float &translateV, float &rotateFrame) |
Get the current textures transformation. More... | |
void | applyTexture (M3dView &, const MDrawData &) |
For materials that have texture, this method must be used before the OpenGL drawing to apply the texture to the current view. More... | |
MStatus | textureImage (MImage &image, MColor &color, MtextureChannel chan, bool &mapped, MDagPath &dagPath, int xRes=-1, int yRes=-1) |
For materials that have texture, this method will attempt to retrieve the pixel map for a given mapped channel of that material. More... | |
MPxHwShaderNode * | getHwShaderNode (MStatus *ReturnStatus=NULL) |
Get the hardware shader node. More... | |
MObject | shadingEngine () |
Get the shading engined associated with this material. More... | |
MStatus | evaluateTextureTransformation () |
This method is obsolete. More... | |
MStatus | getTextureTransformation (float &scaleU, float &scaleV, float &translateU, float &translateV, float &rotate) |
This method is obsolete. More... | |
Static Public Member Functions | |
static MMaterial | defaultMaterial () |
Get the default material. More... | |
static const char * | className () |
Returns the name of this class. More... | |
enum MtextureChannel |
Channels which can be queried.
Only Lambert, Phong, PhongE, Blinn, and Anisotropic are supported
Constructor from shader set MObject.
[in] | shaderSet | An MObject representing a shader set (e.g. from MFnMesh::getConnectedShaders()) from which to get the material |
[out] | ReturnStatus | The return status. |
Evaluate a material.
Must be called before evaluating or getting any material properties.
[in] | view | the view |
[in] | path | path to the object |
MStatus evaluateShininess | ( | ) |
Perform necessary evaluation to be able to get shininess back.
MStatus evaluateDiffuse | ( | ) |
Perform necessary evaluation to be able to get diffuse back.
MStatus evaluateEmission | ( | ) |
Perform necessary evaluation to be able to get emission back.
MStatus evaluateSpecular | ( | ) |
Perform necessary evaluation to be able to get specular back.
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.
[in] | data | draw request data to carry the texture information |
bool materialIsTextured | ( | ) | const |
Do we have a texture (evaluated or not).
Set the current GL material.
[in] | path | path to the object |
[in] | hasTransparency | whether the material has transparency |
MStatus getShininess | ( | float & | value | ) |
Get the GL shininess.
[out] | value | storage for shininess |
Get the GL diffuse color.
[out] | color | storage for the diffuse color |
Get the GL emission color.
[out] | color | storage for the emission color |
Get the GL specular color.
[out] | color | storage for the specular color |
MStatus getHasTransparency | ( | bool & | value | ) |
Determine if material or texture has transparency.
[out] | value | True if material or texture has transparency, false otherwise. |
Get the current textures transformation.
[in] | data | the draw data from the draw request |
[out] | texXform | storage for the texture transformation |
MStatus getTextureTransformation | ( | const MDrawData & | data, |
float & | rotateUV, | ||
float & | scaleU, | ||
float & | scaleV, | ||
float & | translateU, | ||
float & | translateV, | ||
float & | rotateFrame | ||
) |
Get the current textures transformation.
The transformations should applied in the following order:
[in] | data | the draw data from the draw request |
[out] | rotateUV | storage for rotatation value of the UV coordinates |
[out] | scaleU | storage for u scale value |
[out] | scaleV | storage for v scale value |
[out] | translateU | storage for u translation value |
[out] | translateV | storage for v translation value |
[out] | rotateFrame | storage for rotatation value of the frame coordinates |
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.
[in] | view | the view in which the textured drawing is to take place |
[in] | data | the draw data from the draw request |
MStatus textureImage | ( | MImage & | image, |
MColor & | color, | ||
MtextureChannel | chan, | ||
bool & | mapped, | ||
MDagPath & | dagPath, | ||
int | xRes = -1 , |
||
int | yRes = -1 |
||
) |
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:
Currently only channels mapped to single file textures is supported.
[out] | image | The image retrieved. If no image could be retrieve, the value will not change. |
[out] | color | 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. |
[in] | chan | Texture channel to check. |
[out] | mapped | Whether the channel is mapped or not (true or false) |
[in] | dagPath | Optional dag path to object. An object path is required to produce texture maps from non-2D procedural textures. |
[in] | 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. |
[in] | 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. |
MPxHwShaderNode * getHwShaderNode | ( | MStatus * | ReturnStatus = NULL | ) |
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.
[out] | ReturnStatus | Status code |
|
static |
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.
MObject shadingEngine | ( | ) |
Get the shading engined associated with this material.
|
static |
Returns the name of this class.
MStatus evaluateTextureTransformation | ( | ) |
This method is obsolete.
MStatus getTextureTransformation | ( | float & | scaleU, |
float & | scaleV, | ||
float & | translateU, | ||
float & | translateV, | ||
float & | rotate | ||
) |
This method is obsolete.
[out] | scaleU | storage for u scale value |
[out] | scaleV | storage for v scale value |
[out] | translateU | storage for u translation value |
[out] | translateV | storage for v translation value |
[out] | rotate | storage for rotate value |