本文整理汇总了C++中SubMesh::setMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh::setMaterial方法的具体用法?C++ SubMesh::setMaterial怎么用?C++ SubMesh::setMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubMesh
的用法示例。
在下文中一共展示了SubMesh::setMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractPolygons
//.........这里部分代码省略.........
}
}
}
submesh.addVertex(vertex1);
submesh.addVertex(vertex2);
submesh.addVertex(vertex3);
}
}
}
{
Material material;
{
MObjectArray shaders;
MIntArray indices;
fnMesh.getConnectedShaders(0, shaders, indices);
unsigned int shaderCount = shaders.length();
MPlugArray connections;
MFnDependencyNode shaderGroup(shaders[compi]);
MPlug shaderPlug = shaderGroup.findPlug("surfaceShader");
shaderPlug.connectedTo(connections, true, false);
for(unsigned int u = 0; u < connections.length(); u++) {
if(connections[u].node().hasFn(MFn::kLambert)) {
MFnLambertShader lambertShader(connections[u].node());
MPlugArray plugs;
lambertShader.findPlug("color").connectedTo(plugs, true, false);
for (unsigned int p = 0; p < plugs.length(); p++) {
MPlug object = plugs[p];
if (!object.isNull()) {
MObject node = object.node();
if (node.hasFn(MFn::kFileTexture)) {
MFnDependencyNode* diffuseMapNode = new MFnDependencyNode(node);
MPlug filenamePlug = diffuseMapNode->findPlug ("fileTextureName");
MString mayaFileName;
filenamePlug.getValue (mayaFileName);
std::string diffuseMapFileName = mayaFileName.asChar();
std::string diffuseMapAssetPath = extractAssetPath(diffuseMapFileName);
material.addTexture("ColorMap", diffuseMapAssetPath);
}
}
}
MColor color = lambertShader.color();
MString materialNameRaw = lambertShader.name();
std::string materialName = materialNameRaw.asChar();
material.setName(materialName);
Vector4MaterialParameter* diffuseColorParameter = new Vector4MaterialParameter("DiffuseColor");
diffuseColorParameter->value.x = color.r;
diffuseColorParameter->value.y = color.g;
diffuseColorParameter->value.z = color.b;
diffuseColorParameter->value.w = color.a;
material.addParameter(diffuseColorParameter);
}
}
}
{
if (material.hasTextures()) {
material.setEffect("shaders/deferred_render_colormap_normal_depth.cg");
}
else {
material.setEffect("shaders/deferred_render_color_normal_depth.cg");
}
}
{
FloatMaterialParameter* specularPowerParameter = new FloatMaterialParameter("SpecularPower");
specularPowerParameter->value = 1.0;
material.addParameter(specularPowerParameter);
}
{
FloatMaterialParameter* specularIntensityParameter = new FloatMaterialParameter("SpecularIntensity");
specularIntensityParameter->value = 1.0f;
material.addParameter(specularIntensityParameter);
}
{
FloatMaterialParameter* diffusePowerParameter = new FloatMaterialParameter("DiffusePower");
diffusePowerParameter->value = 1.0f;
material.addParameter(diffusePowerParameter);
}
submesh.setMaterial(material);
}
model->addSubMesh(submesh);
}
}
}