Как создать shadinggroup и назначить полигон с помощью Maya C ++ API - PullRequest
0 голосов
/ 13 июня 2019

Как создать shadinggroup и назначить полигон с помощью Maya C ++ API

Я создал многоугольник с Maya C ++ API, но это просто преобразование и сетка, он подключается к initialShadingGroup.

Теперь я хочу создать Ламберта, добавить его в полигон, затем создать новую группу шейдинга, добавить Ламберта в группу шейдинга

Я знаю, как назначить группу шейдинга, но не знаю, как ее создать, и могу проверить в Maya.

http://ewertb.mayasound.com/api/api.008.php

вот мой код

    MStatus status;

    MFnDependencyNode fnPolySp;

    MObject objPolySp = fnPolySp.create("polySphere");

    MFnDagNode fnPolyTrans;

    /*
    If a parent is specified, the new node is parented to it, 
    and the new node is returned. If no parent is specified 
    and the new node is a transform, the new node is returned. 
    Otherwise, a transform created and the new node is automatically 
    parented to it. The returned object is the transform, not the new node.
    */
    MObject objPolyTrans = fnPolyTrans.create("transform");

    MFnDagNode fnPolyShape;

    MObject objPolyShp = fnPolyShape.create("mesh", objPolyTrans);


    MDGModifier dgMod;

    MPlug srcPlug = fnPolySp.findPlug("output");

    MPlug destPlug = fnPolyShape.findPlug("inMesh");

    dgMod.connect(srcPlug, destPlug);


    dgMod.doIt();

    MFnDependencyNode sn;
    MDagPath dagPath;
    MObject  component;

    dagPath.getAPathTo(objPolyTrans);
    MObject shadingnode = sn.create("lambert");

    MFnSet fnSG(shadingnode, &status);
    if (fnSG.restriction() != MFnSet::kRenderableOnly)
        return MS::kFailure;

    status = fnSG.addMember(dagPath, objPolyTrans);
    if (status != MS::kSuccess)
    {
        cerr << " ! MShadingGroup::assignToShadingGroup could not add Dag/Component to SG ! " << endl;
    }

    setResult( "MayaPluginWizard1 command executed!\n" );
    MGlobal::displayInfo("MayaPluginWizard1 command redoit!\n");
    return MS::kSuccess;

последнее, что я хочу, просто создать сферу с новым материалом Ламберта просто нажмите на сферу в Maya Shelt.

я знаю, как создать с помощью скрипта Python или Mel или C ++ API использовать Mel / Python.

я просто хочу знать, как это сделать, просто используя c ++ API

Спасибо

...