unsigned
SOP_PrimGroupCentroid::disableParms()
{
    fpreal                      t = CHgetEvalTime();
    unsigned                    changed;
    int                         mode;

    OP_Node                     *bind_input;

    // Partitioning mode.
    mode = MODE(t);

    // Try to get the 2nd input.
    bind_input = getInput(1);

    // Only use the 'group' parm when doing a group operation.
    changed = enableParm("group", mode == 0 && bind_input == NULL);

    // Enable the 'store' parm when there is no 2nd input.
    changed += enableParm("store", bind_input == NULL);

    // Enable thavior' parm when there is a 2nd input.
    changed += enableParm("behavior", bind_input != NULL);

    changed += enableParm("attributes", bind_input == NULL);
    changed += enableParm("bind_attributes", bind_input != NULL);

    return changed;
}
void
SOP_PrimGroupCentroid::buildMenu(void *data,
                                 PRM_Name *menu,
                                 int list_size,
                                 const PRM_SpareData *,
                                 const PRM_Parm *)
{
    fpreal                      t = CHgetEvalTime();
    int                         input_index, mode;

    GA_AttributeOwner           owner;

    OP_Node                     *bind_input;

    // Get the instance of the operator.
    SOP_PrimGroupCentroid *me = (SOP_PrimGroupCentroid *)data;

    // Get the operation mode.
    mode = me->MODE(t);

    // Try to get the 2nd input.
    bind_input = me->getInput(1);

    // Not binding, so use primitive attributes from input 0.
    if (bind_input == NULL)
    {
        owner = GEO_PRIMITIVE_DICT;
        input_index = 0;
    }
    // We are binding, so use point attributes from input 1.
    else
    {
        owner = GEO_POINT_DICT;
        input_index = 1;
    }

    // Populate the menu with the selected attributes.
    me->fillAttribNameMenu(menu,
                           100,
                           owner,
                           input_index,
                           &SOP_PrimGroupCentroid::validateAttrib,
                           &mode);
}
示例#3
0
bool
GusdOBJ_usdcamera::_EvalCamVariable(fpreal& val, int idx, int thread)
{
    UT_ASSERT_P(idx >= 0 && idx < NUM_VARS);
    
    const fpreal t = CHgetEvalTime(thread);
    
    if(UsdGeomCamera cam = _LoadCamera(t, thread))
    {
        float frame = evalFloatT(_frameIdx, 0, t, thread);
        switch(idx)
        {
        case VAR_SCREENASPECT:
            {
                val = cam.GetCamera(frame).GetAspectRatio();
                return true;
            }
        case VAR_YRES:
            {
                // XXX This is redundant since resy can be set to
                //     "ch(\"resx\")/$SCREENASPECT" in runCreateScript,
                //     however it's needed to get around a Houdini bug
                //     (see bug 94389)
                const float screenAspect =
                    cam.GetCamera(frame).GetAspectRatio();
                float xRes = evalFloatT("res", 0, t, thread);
                val = xRes / screenAspect;
                return true;
            }
        case VAR_PROJECTION:
            {
                TfToken proj;
                if(cam.GetProjectionAttr().Get(&proj) &&
                   proj == UsdGeomTokens->orthographic)
                    val = OBJ_PROJ_ORTHO;
                else
                    val = OBJ_PROJ_PERSPECTIVE;
                return true;
            }
        case VAR_FOCAL:
            {
                float focal = 50;
                cam.GetFocalLengthAttr().Get(&focal, frame);
                val = focal;
                return true;
            }
        case VAR_HAPERTURE:
            {
                float aperture = 41.2136;
                cam.GetHorizontalApertureAttr().Get(&aperture, frame);
                val = aperture;
                return true;
            }
        case VAR_VAPERTURE:
            {
                float aperture = 41.2136;
                cam.GetVerticalApertureAttr().Get(&aperture, frame);
                val = aperture;
                return true;
            }
        case VAR_NEAR:
            {
                GfVec2f clipping;
                val = cam.GetClippingRangeAttr().Get(&clipping, frame) ?
                    clipping[0] : 0.001;
                return true;
            }
        case VAR_FAR:
            {
                GfVec2f clipping;
                val = cam.GetClippingRangeAttr().Get(&clipping, frame) ?
                    clipping[1] : 10000;
                return true;
            }
        case VAR_FOCUS:
            {
                float focus = 5;
                cam.GetFocusDistanceAttr().Get(&focus, frame);
                val = focus;
                return true;
            }
        case VAR_FSTOP:
            {
                float fstop = 5.6;
                cam.GetFStopAttr().Get(&fstop, frame);
                val = fstop;
                return true;
            }
        case VAR_HAPERTUREOFFSET:
            {
                float apertureOffset = 41.2136;
                cam.GetHorizontalApertureOffsetAttr().Get(&apertureOffset, frame);
                val = apertureOffset;
                return true;
            }
        // for backwards compatibility with old stereo attributes {

        // XXX:-matthias
        // We are just writing out dummy values so that old assets do not
        // break.
        // The following code together with the definitions of
        // VAR_ISSTEREO, ... should eventually be removed.

        case VAR_ISSTEREO:
            {
                bool isStereo = false;
                val = isStereo;
                return true;
            }
        case VAR_CONVERGENCEDISTANCE:
            {
                float convergenceDistance = 1000;
                val = convergenceDistance;
                return true;
            }
        case VAR_INTEROCULARDISTANCE:
            {
                float interocularDistance = 50;
                val = interocularDistance;
                return true;
            }
        case VAR_LEFTEYEBIAS:
            {
                float leftEyeBias = 0.0;
                val = leftEyeBias;
                return true;
            }
        // }
        };
    }

    /* Couldn't load a camera. Just return defaults.*/
    switch(idx)
    {
    case VAR_SCREENASPECT:          val = 1.0; break;
    case VAR_YRES:                  val = 1080; break;
    case VAR_PROJECTION:            val = OBJ_PROJ_PERSPECTIVE; break;
    case VAR_FOCAL:                 val = 50; break;
    case VAR_HAPERTURE:             val = 41.2136; break;
    case VAR_VAPERTURE:             val = 41.2136; break;
    case VAR_NEAR:                  val = 0.001; break;
    case VAR_FAR:                   val = 10000; break;
    case VAR_FOCUS:                 val = 5; break;
    case VAR_FSTOP:                 val = 5.6; break;
    case VAR_HAPERTUREOFFSET:       val = 41.2136;
    // for backwards compatibility with old stereo attributes
    case VAR_ISSTEREO:              val = 0; break;
    case VAR_CONVERGENCEDISTANCE:   val = 1000; break;
    case VAR_INTEROCULARDISTANCE:   val = 50; break;
    case VAR_LEFTEYEBIAS:           val = 0.0; break;
    };
    /* Return true so that the variables are still considered valid,
       even in the absence of the camera. This is done to prevent
       evaluation errors during saves.*/
    return true;
}