プリミティブのアトリビュートとグループを転写する

プリミティブのアトリビュートを転写する

//
// アトリビュートのコピー
//
// RunOver:Primitive
//

int targetPrim = 0; // コピー先のインデックス
int sourceInput = 1; // 参照するインプット

string primAttribs[] = detailintrinsic(sourceInput, 'primitiveattributes');
for(int i = 0; i < len(primAttribs); i++)
{
    int type = primattribtype(sourceInput, primAttribs[i]);
    int size = primattribsize(sourceInput, primAttribs[i]);
    
    // int
    if(type == 0)
    {
        int value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // float
    else if(type == 1 && size == 1)
    {
        float value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // 2-float vector
    else if(type == 1 && size == 2)
    {
        vector2 value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // 3-float vector
    else if(type == 1 && size == 3)
    {
        vector value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // 4-float vector
    else if(type == 1 && size == 4)
    {
        vector4 value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // 3x3 matrix
    else if(type == 1 && size == 9)
    {
        matrix3 value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // 4x4 matrix
    else if(type == 1 && size == 16)
    {
        matrix value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // string
    else if(type == 2)
    {
        string value = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // int array
    else if(type == 3)
    {
        int value[] = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // float array
    else if(type == 4)
    {
        float value[] = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
    // string array
    else if(type == 5)
    {
        string value[] = primattrib(sourceInput, primAttribs[i], targetPrim, 0);
        setprimattrib(0, primAttribs[i], @primnum, value);
    }
}

プリミティブのグループを転写する

//
// グループの値を転写
//
// RunOver:Primitive
//
int targetPrimnum = 0; // コピー先のインデックス
int sourceInput = 1; // 参照するインプット

// グループ名を配列で取得する
string primgrps[] = detailintrinsic(sourceInput, "primitivegroups");
for(int i = 0; i < len(primgrps); i++)
{
    // グループの値を取得
    int ingroup = inprimgroup(sourceInput, primgrps[i], 0);
    // グループに値を割り当てる
    setprimgroup(targetPrimnum, primgrps[i], @primnum, ingroup);
}
タイトルとURLをコピーしました