/* static */
bool
UsdMayaTranslatorCamera::ReadToCamera(
        const UsdGeomCamera& usdCamera,
        MFnCamera& cameraObject)
{
    UsdMayaJobImportArgs defaultJobArgs =
            UsdMayaJobImportArgs::CreateFromDictionary(
                UsdMayaJobImportArgs::GetDefaultDictionary());
    UsdMayaPrimReaderArgs args(usdCamera.GetPrim(), defaultJobArgs);
    return _ReadToCamera(usdCamera, cameraObject, args, nullptr);
}
/* static */
bool
UsdMayaTranslatorCamera::Read(
        const UsdGeomCamera& usdCamera,
        MObject parentNode,
        const UsdMayaPrimReaderArgs& args,
        UsdMayaPrimReaderContext* context)
{
    if (!usdCamera) {
        return false;
    }

    const UsdPrim& prim = usdCamera.GetPrim();
    const SdfPath primPath = prim.GetPath();

    MStatus status;

    // Create the transform node for the camera.
    MObject transformObj;
    if (!UsdMayaTranslatorUtil::CreateTransformNode(prim,
                                                       parentNode,
                                                       args,
                                                       context,
                                                       &status,
                                                       &transformObj)) {
        return false;
    }

    // Create the camera shape node.
    MDagModifier dagMod;
    MObject cameraObj = dagMod.createNode(_tokens->MayaCameraTypeName.GetText(),
                                          transformObj,
                                          &status);
    CHECK_MSTATUS_AND_RETURN(status, false);
    status = dagMod.doIt();
    CHECK_MSTATUS_AND_RETURN(status, false);
    TF_VERIFY(!cameraObj.isNull());

    MFnCamera cameraFn(cameraObj, &status);
    CHECK_MSTATUS_AND_RETURN(status, false);
    const std::string cameraShapeName = prim.GetName().GetString() +
        _tokens->MayaCameraShapeNameSuffix.GetString();
    cameraFn.setName(cameraShapeName.c_str(), &status);
    CHECK_MSTATUS_AND_RETURN(status, false);
    if (context) {
        const SdfPath shapePrimPath = primPath.AppendChild(TfToken(cameraShapeName));
        context->RegisterNewMayaNode(shapePrimPath.GetString(), cameraObj);
    }

    return _ReadToCamera(usdCamera, cameraFn, args, context);
}
示例#3
0
/* static */
bool 
PxrUsdMayaTranslatorCamera::ReadToCamera(
        const UsdGeomCamera& usdCamera,
        MFnCamera& cameraObject)
{
    JobImportArgs defaultJobArgs;
    PxrUsdMayaPrimReaderArgs args(
            usdCamera.GetPrim(), 
            defaultJobArgs.shadingMode,
            defaultJobArgs.defaultMeshScheme,
            defaultJobArgs.readAnimData,
            defaultJobArgs.useCustomFrameRange,
            defaultJobArgs.startTime,
            defaultJobArgs.endTime);

    return _ReadToCamera(usdCamera, cameraObject, args, NULL);
}