Cmaterial

C++Python
Cmaxwell::CmaterialCmaxwellMaterial

Describes a Maxwell material.

Inherits from

Cpointer.

Sub-classes

Citerator.

Enumerations

BLENDING_MODES.

Methods

NameDescription
createCopyCreates a full copy of the material and returns it.
freeRemoves the material from the scene and destroys it.
extractRemoves the material from the scene.
getVersionReturns the version of the material.
setNameSets material name.
getNameGets material name.
setReferenceSets the path to the MXM file referenced by this material.
getReferenceGets the path to the MXM file referenced by this material.
setDescriptionSets user description of the material.
getDescriptionGets user description of the material.
setUuidSets unique user ID for the material.
getUuidGets unique user ID for the material.
setDirtyInternal use.
isDirtyInternal use.
forceToWriteIntoSceneForce the material to be writed ni the MXS scene file.
belongToSceneChecks whether the material belongs to a scene.
isEmptyChecks whether the material is empty (no layers).
setEmptyRemove all layers from the material.
readReads a MXM material from file.
writeWrites the material to a MXM file.
Render parameters
setDispersionSets dispersion on/off.
getDispersionGets dispersion state.
setMatteSets matte on/off.
getMatteGets matte state.
setMatteShadowSets matte shadow on/off.
getMatteShadowGet matte shadow state.
addLayerAdds a new layer to the material returning a reference to it.
getNumLayersGets the number of layers in the material.
getLayerGets a reference of a specific layer in the material.
setLayerDisplacementSets the layer index that owns the active displacement.
getLayerDisplacementChecks whether a layer have the active displacement.
setColorSets the global bump of the material.
getColorGets the global bump of the material.
setActiveColorSets the active bump of the material.
getActiveColorGets the active bump of the material.
setNormalMapStateEnables/disables normal mapping for the global bump parameter.
getNormalMapStateGets normal mapping state.
setColorIDSets the color ID used by this material in the Material ID render channel.
getColorIDGets the color ID used by this material in the Material ID render channel.
Preview
setPreviewSets the preview image stored in the material.
getPreviewGets the preview image stored in the material.
setTextureActiveSets the active texture shown in the viewport of Maxwell Studio.
getTextureActiveGets the active texture shown in the viewport of Maxwell Studio.
getNumberOfChannelsNeededReturns the number of UV channels needed for using this material.
getMapsReturns an array with all the Cmaps used in this material.
getDepencencies

Gets an array of strings with all the extern dependencies.

Static Methods

NameDescription
getVersionReturns the version of the material.

Inherited Methods

isNull.

BLENDING_MODES

Blending modes available for multiple layers.

ID
BLENDING_NORMAL
BLENDING_ADDITIVE


createCopy

Creates a full copy of the material and returns it. The copy doesn't belong to the scene.

LanguageSyntax
C++Cmaxwell::Cmaterial createCopy()
PythonCmaxwellMaterial createCopy()

free

Removes the material from the scene and destroys it.

LanguageSyntax
C++byte free()
Pythonint free()

Return value

0 = Error removing from the scene or destroying the material.

1 = Success.

extract

Removes the material from the scene.

LanguageSyntax
C++byte extract()
Pythonint extract()

Return value

0 = Error removing from the material from the scene..

1 = Success.

setName

Sets material name.

LanguageSyntax
C++byte setName( const char* pName )
Pythonint setName( str name )

Return value

0 = Error setting material name.

1 = Success.

getName

Gets material name.

LanguageSyntax
C++const char* getName()
Pythonstr getName()

setReference

Sets the path to the MXM file referenced by this material. By default materials are not referenced but embeded in the scene.

LanguageSyntax
C++byte setReference( const byte& enabled, const char* mxmPath )
Pythonint setReference( int enabled, str mxmPath )

Parameters

TypeNameIn/OutDescription
const byte&enabledin1 (referenced) or 0 (embeded in the scene, default).
const char*mxmPathinPath to the MXM material file, only if the material is a reference.

Return value

0 = Error setting reference path.

1 = Success.

getReference

Gets the path to the MXM file referenced by this material. By default materials are not referenced but embeded in the scene.

LanguageSyntax
C++const char* getReference( byte& enabled )
Python(mxmPath,enabled) getReference()

Parameters

TypeNameIn/OutDescription
const byte&enabledout1 (referenced) or 0 (embeded in the scene, default).

Return value

C++

Path to the MXM file.

Python

Tuple containing 2 values: the path to the MXM file, and the reference state (0 or 1).

setDescription

Sets user description of the material.

LanguageSyntax
C++byte setDescription( const char* pDescription )
Pythonint setDescription( str description )

Return value

0 = Error setting description.

1 = Success.

getDescription

Gets user description of the material.

LanguageSyntax
C++const char* getDescription()
Pythonstr setDescription()

Return value

0 = Error setting description.

1 = Success.

setUuid

Uuid that can be used for custom purposes.

LanguageSyntax
C++byte setUuid( const char* pUuid )
Pythonint setUuid( str Uuid )

Return value

0 = Error setting Uuid.

1 = Success.

getUuid

Uuid that can be used for custom purposes.

LanguageSyntax
C++

const char* getUuid()

Pythonstr setUuid()

forceToWriteIntoScene

Write this material into the scene it belongs.

LanguageSyntax
C++byte forceToWriteIntoScene()
Pythonint forceToWriteIntoScene()

Return value

0 = Error forcing to write into scene.

1 = Success.

belongToScene

Checks whether the material belongs to the scene.

LanguageSyntax
C++byte belongToScene( bool& belong )
Pythonbool belongToScene()

Return value

C++

0 = Error checking material belongs to scene.

1 = Success.

Python

True or False (belongs to the scene or not).

isEmpty

Checks whether the material is empty (no layers).

LanguageSyntax
C++byte isEmpty( byte& empty )
Pythonint isEmpty()

Return value

C++

0 = Error checking material is empty.

1 = Success.

Python

True or False (material is empty or not).

setEmpty

Sets material empty (not null but without layers).

LanguageSyntax
C++byte setEmpty()
Pythonint setEmpty()

Return value

0 = Error setting material empty.

1 = Success.

read

Reads a material from disk. pFileName is the full path to the MXM file.

LanguageSyntax
C++byte read( const char* pFileName )
Pythonint read( str filename )

Return value

0 = Error reading MXM material.

1 = Success.

write

Writes the material to disk. pFileName is the full path to the MXM file.

LanguageSyntax
C++byte write( const char* pFileName )
Pythonint write( str filename )

Return value

0 = Error writting MXM material.

1 = Success.

setDispersion

Sets dispersion state (Off by default).

LanguageSyntax
C++byte setDispersion( bool enabled )
Pythonint setDispersion( bool enabled )

Return value

0 = Error setting dispersion state.

1 = Success.

getDispersion

Gets dispersion state.

LanguageSyntax
C++

byte getDispersion( bool& state )

Pythonbool getDispersion()

Return value

C++

0 = Error getting dispersion state.

1 = Success.

Python

True or False (dispersion is enabled or not).

setMatte

Sets matte state (Off by default).

LanguageSyntax
C++byte setMatte( bool enabled )
Pythonint setMatte( bool enabled )

Return value

0 = Error setting matte state.

1 = Success.

getMatte

Gets matte state.

LanguageSyntax
C++

byte getMatte( bool& state )

Pythonbool getMatte()

Return value

C++

0 = Error getting matte state.

1 = Success.

Python

True or False (matte is enabled or not).

setMatteShadow

Sets matte shadow state (Off by default).

LanguageSyntax
C++byte setMatteShadow( bool enabled )
Pythonint setMatteShadow( bool enabled )

Return value

0 = Error setting matte shadow state.

1 = Success.

Examples

See the Python example Set shadows on.

getMatteShadow

Gets matte shadow state.

LanguageSyntax
C++

byte getMatteShadow( bool& state )

Pythonbool getMatteShadow()

Return value

C++

0 = Error getting matte shadow state.

1 = Success.

Python

True or False (matte shadow is enabled or not).

addLayer

Adds a layer to the material.

LanguageSyntax
C++

Cmaxwell::CmaterialLayer addLayer()

PythonCmaterialLayer addLayer()

Return value

Reference to the Cmaxwell::CmaterialLayer created.

getNumLayers

Return the number of layers in the material.

LanguageSyntax
C++

byte getNumLayers( byte& nLayers )

Pythonint addLayer()

Return value

C++

0 = Error getting number of layers.

1 = Success.

Python

Number of layers in the material.

getLayer

Returns layer with the given index.

LanguageSyntax
C++

Cmaxwell::CmaterialLayer getLayer( byte index )

PythonCmaterialLayer addLayer( int index )

Return value

Reference to the Cmaxwell::CmaterialLayer requested.

setLayerDisplacement

Sets the layer that owns the active displacement.

LanguageSyntax
C++

byte setLayerDisplacement( dword index )

Pythonint setLayerDisplacement( int index )

Return value

0 = Error setting the layer that owns the active displacement.

1 = Success.

getLayerDisplacement

Gets the layer that owns the active displacement. getLayerDisplacement returns also a boolean that says if the index is valid. displacementOk returns true if the displacement of the layer with index "index" is valid, otherwise displacementOk returns false if there is not displacement in the layer or the map is NULL.

LanguageSyntax
C++byte getLayerDisplacement( dword& index, bool& displacementOk )
Python(int index, bool displacementOk) getLayerDisplacement()

Return value

C++

0 = Error getting displacement layer.

1 = Success.

Python

Tuple containing 'index' and 'displacementOk' values.

setColor

Sets the global bump of the material.

LanguageSyntax
C++byte setColor( const char* pID, Cmaxwell::Cmultivalue::Cmap& map )
Pythonint setColor( str pID, Cmap map )

Parameters

TypeNameIn/OutDescription
const char*pIDinOnly one valid value: "bump"
Cmaxwell::Cmultivalue::Cmap&mapinmap.type must be: MAP_TYPE_VALUE or MAP_TYPE_BITMAP .

Return value

0 = Error setting color.

1 = Success.

Examples

Set the bump as a numeric value (not a texture)

getColor

Gets the global bump of the material.

LanguageSyntax
C++byte getColor( const char* pID, Cmaxwell::CmultiValue::Cmap& map )
PythonCmap getColor( str pID )

Parameters

TypeNameIn/OutDescription
const char*pIDinOnly one valid value: "bump"
Cmaxwell::Cmultivalue::Cmap&mapoutmap.type will be: MAP_TYPE_VALUE or MAP_TYPE_BITMAP .

Return value

C++

0 = Error getting global bump.

1 = Success.

Python

Cmap containing the global bump.

setActiveColor

Sets the active global bump of the material.

LanguageSyntax
C++byte setActiveColor( const char* pID, Cmaxwell::Cmultivalue::Cmap& map )
Pythonint setActiveColor( str pID, Cmap map )

Parameters

TypeNameIn/OutDescription
const char*pIDinOnly one valid value: "bump"
Cmaxwell::Cmultivalue::Cmap&mapinmap.type must be: MAP_TYPE_VALUE or MAP_TYPE_BITMAP.

Return value

0 = Error setting active color.

1 = Success.

Examples

Set the bump as a numeric value (not a texture)

getActiveColor

Gets the active global bump of the material.

LanguageSyntax
C++byte getActiveColor( const char* pID, Cmaxwell::CmultiValue::Cmap& map )
PythonCmap getActiveColor( str pID )

Parameters

TypeNameIn/OutDescription
const char*pIDinOnly one valid value: "bump"
Cmaxwell::Cmultivalue::Cmap&mapoutmap.type will be: MAP_TYPE_VALUE or MAP_TYPE_BITMAP .

Return value

C++

0 = Error getting active global bump.

1 = Success.

Python

Cmap containing the active global bump.

setNormalMapState

Enables/disables normal mapping for the global bump parameter.

LanguageSyntax
C++byte setNormalMapState( bool enabled )
Pythonint setNormalMapState( bool enabled )

Return value

0 = Error setting normal map state.

1 = Success.

getNormalMapState

Gets normal mapping state for the global bump parameter.

LanguageSyntax
C++

byte getNormalMapState( bool& state )

Pythonbool getNormalMapState()

Return value

C++

0 = Error getting normal map state.

1 = Success.

Python

True or False (normal map is enabled or not).

setColorID

Sets the color used by this material in the Material ID render channel.

LanguageSyntax
C++

byte setColorID( const Crgb& color )

Pythonbyte setColorID( Crgb color )

Return value

0 = Error setting the color ID.

1 = Success.

getColorID

Gets the color used by this material in the Material ID render channel.

LanguageSyntax
C++

byte getColorID( Crgb& color )

PythonCrgb getColorID()

Return value

C++

0 = Error getting the color ID.

1 = Success.

Python

Crgb  color ID.

setPreview

Sets the preview image stored in the material.

LanguageSyntax
C++byte setPreview( dword xRes, dword yRes, Crgb8* pRGB )
Pythonbool setPreview( array image )

Parameters

TypeNameIn/OutDescription
dwordxResin(C++) Image width.
dwordyResin(C++) Image height.
Crgb8*pRGBin(C++) Image buffer.
imagearrayin(Python) NumPy ubyte array. Shape must be (width,height,3).

Return value

0 = Error setting scene preview image.

1 = Success.

getPreview

Gets the preview image stored in the material.

LanguageSyntax
C++Crgb8* getPreview( dword& xRes, dword& yRes )
Pythonarray getPreview()

Parameters

TypeNameIn/OutDescription
dwordxResoutPreview image width.
dwordyResoutPreview image height.

Return value

C++

Crgb8 pointer to the preview image. The memory pointed belongs to the material, so the programmer must not free it.

Python

NumPy array containing the RGB image. Array dimensions: (height, width, 3).

setTextureActive

Sets the active texture shown in the viewport of Maxwell Studio.

LanguageSyntax
C++byte setTextureActive( const Cmaxwell::Cmultivalue::Cmap& map )
Pythonint setTextureActive( Cmap map )

Return value

0 = Error setting the active texture.

1 = Success.

getTextureActive

Gets the active texture shown in the viewport of Maxwell Studio. If there is no active texture, the SDK returns the first map found. If there are no maps in the material, map.pFileName returns NULL.

LanguageSyntax
C++byte getTextureActive( Cmaxwell::Cmultivalue::Cmap& map )
PythonCmap getTextureActive()

Return value

C++

0 = Error getting the active texture.

1 = Success.

Python

Cmap  containing the active texture.

getNumberOfChannelsNeeded

Returns the number of UV channels needed for using this material.

LanguageSyntax
C++dword getNumberOfChannelsNeeded()
Pythonint getNumberOfChannelsNeeded()

getMaps

Returns an array with all the Cmaps used in this material. Internally it allocates an array of size nMaps. It is responsibility of the caller to destroy it later to avoid leaks (C++). If this material has a reference to another material, it does not take into account Cmaps of the referenced MXM. If addOnlyMapsWithBitmapsUsed is true, maps that contain bitmaps that are not used won't be added to the list (i.e if the active reflectance is set as a rgb color instead of as a bitmap, it won't be added to the list of maps).

LanguageSyntax
C++Cmaxwell::CmultiValue::Cmap* getMaps( dword& nMaps, bool addOnlyMapsWithBitmapsUsed )
Pythonlist getMaps( bool addOnlyMapsWithBitmapsUsed )

Return value

C++

Cmaxwell::CmultiValue::Cmap array with nMaps elements.

Python

Cmap list.

getDependencies

Returns (by reference) an array of strings with all the extern depencencies of the material (textures, ior files, etc).

LanguageSyntax
C++byte getDependencies( dword& numDependencies, char**& paths, const bool& searchInsideReferences = true )
Pythonstr[] getDependencies( bool searchInsideReferences = true )

Parameters

TypeNameIn/OutDescription
dword&numDependenciesoutNumber of dependencies returned.
char**&pathsoutDependency paths array.
const bool&searchInsideReferencesinIf true the function search for dependencies also in the referenced MXM path if exists. True by default.

Return value

C++

0 = Error getting the dependencies.

1 = Success.

Python

str list containing the dependencies.

getVersion

Returns the version number of the material in the MXM file.

LanguageSyntax
C++static byte getVersion( const char* pFilename, float& version )
Pythonfloat getVersion( str filename )

Return value

C++

0 = Error getting version from MXM file.

1 = Success.

Python

Material version.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • No labels