Detailed Description
The
Material object represents a material property of a
SceneItem object.
You can create a material with SceneItem::AddMaterial.
- Note:
- If you get a material from a
Material
Library, use ProjectItem::GetParent,
not ProjectItem::GetModel,
to get the
Library object (ProjectItem::GetModel
returns an invalid
Model).
- See also:
- Scene::GetActiveMaterialLibrary(),
OGLMaterial
- Example:
using namespace XSI;
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject myCube;
root.AddGeometry( L"Cube",L"MeshSurface",L"" ,myCube );
Material myMaterial;
myCube.AddMaterial(L"Phong",false,L"",myMaterial);
app.LogMessage( CString(L"The material: ") + myMaterial.GetFullName() );
#include <xsi_material.h>
List of all
members.
Constructor & Destructor Documentation
Constructs a
Material object from a
CRef object.
- Parameters:
-
in_ref |
A reference to a material. |
Member Function Documentation
bool IsA |
( |
siClassID |
in_ClassID |
) |
const [virtual] |
Returns True if this object supports the functionality of a
specified class. For example, a
Material is a type of
Property, so a
Material object supports
Property functionality.
- Parameters:
-
in_ClassID |
Test if this object supports this class. |
- Returns:
- True if this object supports the specified class, and false
otherwise.
Reimplemented from Property.
Returns the class ID for this object.
- Returns:
- The class ID.
Reimplemented from Property.
Assigns a
Material object to an existing
Material object.
- Parameters:
-
in_obj |
A
Material object to be copied into this object. |
- Returns:
- The reinitialized
Material object.
Assigns a
CRef to this material. The
Material object is cleared if the
CRef is not a reference to an object that supports the
Material class.
- Parameters:
-
in_ref |
A reference to an object that supports the
Material class. |
- Returns:
- The reinitialized
Material object.
Reimplemented from Property.
Returns the shaders connected to this material.
- Returns:
- An array of references to
Shader objects.
Returns the image clips connected to the material.
- Returns:
- An array of references to
ImageClip objects.
- Since:
- 4.0
Returns the
OGLMaterial for this material. The
OGLMaterial is a read-only object that holds the material
rendering information used by OpenGL.
Returns the ClusterProperty
containing the current UV coordinages used to display the texture
in OpenGL.
Returns the current image clip used for OpenGL display.
- Since:
- 4.0
Texture GetCurrentTexture |
( |
|
) |
const |
Returns the texture using the default UV coordinates used in
OpenGL.
Creates a new texture layer belonging to the container (the
material).
- Parameters:
-
in_strName |
The name of new texture layer. |
in_bAfter |
True to insert the layer after the reference layer
(in_refLayer), and False to insert the layer before the reference
layer. If there is no reference layer, then True adds the layer to
the end of the list, and False adds the layer to the start of the
list. |
in_refLayer |
The reference texture layer. Used to indicate where the new
layer is inserted in the list. |
- Returns:
- The new texture layer.
- Since:
- 4.0
Adds an existing texture layer to the container. The layer
already belongs to at least one other texture layer container
(either a
Shader or a
Material).
- Parameters:
-
in_layer |
The texture layer to add to this container. |
in_bAfter |
True to insert the layer after the reference layer
(in_refLayer), and False to insert the layer before the reference
layer. If there is no reference layer, then True adds the layer to
the end of the list, and False adds the layer to the start of the
list. |
in_refLayer |
The reference texture layer. Used to indicate where the new
layer is inserted in the list. |
- Returns:
-
CStatus::OK if successful
-
CStatus::Fail if the texture layer could not be created.
- Since:
- 4.0
Returns the texture layers owned by the material.
- Returns:
- An array of references to
TextureLayer objects.
- Since:
- 4.0
Removes a texture layer from the container. If this container is
the only owner of the layer, then the layer is deleted from the
scene. Otherwise, the layer is removed from this container
only.
- Parameters:
-
in_layer |
The texture layer to remove from this container. |
- Returns:
-
CStatus::OK if successful
-
CStatus::Fail if the texture layer could not be removed.
- Since:
- 4.0
Returns the owners of this material.
- Returns:
- An array of references to the owners.
- Since:
- 4.0
Tests whether this material is the intended material or a
stand-in.
- Returns:
- True if this material is the intended material, and False
otherwise.
- Since:
- 4.0
CString GetUnresolvedFullname |
( |
|
) |
const |
Returns the full name of the material that this material is
supposed to reference.
- Returns:
- The fullname of the material.
- Since:
- 4.0
Returns the material library that this material belongs to.
- Since:
- 4.0
Returns an array of
CustomProperty objects connected to this material shader. These
cluster properties are mostly UV and Color at Vertices properties.
The function also returns the shader connection points, as
Parameter objects, for each cluster property.
- Return values:
-
out_refArray |
Array of
Parameter objects that connect the cluster properties. |
- Returns:
- Array of Cluster
Property objects.
- See also:
-
CGeometryAccessor::GetMaterials
- Since:
- 5.0
- Example:
using namespace XSI;
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject myCube;
root.AddGeometry( L"Cube",L"MeshSurface",L"" ,myCube );
Material myMaterial;
myCube.AddMaterial(L"Phong",false,L"",myMaterial);
CValueArray args(4L);
CValue outArg;
args[0] = CValue( CString(L"Image") );
args[1] = CValue(myCube.GetRef());
args[2] = CValue((short)1);
args[3] = CValue(false);
app.ExecuteCommand( L"BlendInPresets", args, outArg );
args[0] = myCube.GetRef();
args[1] = (LONG)siTxtPlanarXY;
args[2] = (LONG)siTxtDefaultSpherical;
args[3] = CString(L"Texture_Support");
app.ExecuteCommand( L"CreateTextureSupport", args, outArg );
Primitive prim = myCube.GetActivePrimitive();
PolygonMesh mesh = prim.GetGeometry();
CGeometryAccessor mt = mesh.GetGeometryAccessor();
CRefArray mats = mt.GetMaterials();
LONG nVals = mats.GetCount();
for ( LONG i=0; i<nVals; i++ )
{
Material mat(mats[i]);
CParameterRefArray params;
CRefArray clsProps = mat.GetConnectedClusterProperties(params);
CString str(mat.GetName());
for (LONG j=0; j<clsProps.GetCount(); j++)
{
str += L"\n\t";
ClusterProperty cp(clsProps[j]);
str += cp.GetName();
str += L" type: ";
switch (cp.GetPropertyType())
{
case siClusterPropertyEnvelopeWeightType:
str += L"siClusterPropertyEnvelopeWeightType";
break;
case siClusterPropertyShapeKeyType:
str += L"siClusterPropertyShapeKeyType";
break;
case siClusterPropertyWeightMapType:
str += L"siClusterPropertyWeightMapType";
break;
case siClusterPropertyUVType:
str += L"siClusterPropertyUVType";
break;
case siClusterPropertyVertexColorType:
str += L"siClusterPropertyVertexColorType";
break;
case siClusterPropertyUserNormalType:
str += L"siClusterPropertyUserNormalType";
break;
case siClusterPropertyUserMotionType:
str += L"siClusterPropertyUserMotionType";
break;
};
str += L" elem count: " + CString(cp.GetValueSize());
Parameter param = params[j];
str += L"\n\t\tParameter path: ";
str += param.GetFullName();
str += L"\n";
Texture txt(param.GetParent());
str += L"\t\tParameter parent: ";
str += txt.GetFullName();
str += L"\n";
ImageClip2 clip(txt.GetImageClip());
str += L"\t\tTexture image: ";
str += clip.GetFileName();
}
app.LogMessage( CString(i) + L" : " + str );
}
Returns the input type of a material parameter. Before you
connect a shader to the parameter, use Parameter::GetCapabilities
to make sure that the parameter supports the siTexturable
capability.
- Parameters:
-
in_paramscriptname |
The script name of a parameter. |
- Returns:
- The shader input type.
- siUnknownParameterType if the parameter cannot be connected to
a shader.
- Since:
- 5.0
Returns all shaders that match a
Filter. For example, you can write a custom filter that matches
shaders with texturespace and colormap parameters, and then use
this custom filter with this function.
- Parameters:
-
- Returns:
- Array of shaders that match the filter.
- Since:
- 5.0
Returns a list of shaders nested under this
Material.
- Returns:
-
CRefArray of references to the nested
Shader objects.
- Since:
- 7.0
The documentation for this class was generated from the following
file: