/// <summary> /// Configure FbxCameras from GameCamera /// </summary> private static void ConfigureGameCamera(FbxCamera fbxCamera, Camera unityCamera) { // Configure FilmBack settings as a 35mm TV Projection (0.816 x 0.612) float aspectRatio = unityCamera.aspect; float apertureHeightInInches = 0.612f; float apertureWidthInInches = aspectRatio * apertureHeightInInches; FbxCamera.EProjectionType projectionType = unityCamera.orthographic ? FbxCamera.EProjectionType.eOrthogonal : FbxCamera.EProjectionType.ePerspective; fbxCamera.ProjectionType.Set(projectionType); fbxCamera.FilmAspectRatio.Set(aspectRatio); fbxCamera.SetApertureWidth(apertureWidthInInches); fbxCamera.SetApertureHeight(apertureHeightInInches); fbxCamera.SetApertureMode(FbxCamera.EApertureMode.eVertical); // Focal Length double focalLength = fbxCamera.ComputeFocalLength(unityCamera.fieldOfView); fbxCamera.FocalLength.Set(focalLength); // Field of View fbxCamera.FieldOfView.Set(unityCamera.fieldOfView); // NearPlane fbxCamera.SetNearPlane(unityCamera.nearClipPlane.Meters().ToCentimeters()); // FarPlane fbxCamera.SetFarPlane(unityCamera.farClipPlane.Meters().ToCentimeters()); return; }
public FbxCamera.EProjectionType EvaluateValue() { FbxCamera.EProjectionType ret = (FbxCamera.EProjectionType)NativeMethods.FbxPropertyEProjectionType_EvaluateValue__SWIG_2(swigCPtr); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
public FbxCamera.EProjectionType EvaluateValue(FbxTime pTime, bool pForceEval) { FbxCamera.EProjectionType ret = (FbxCamera.EProjectionType)NativeMethods.FbxPropertyEProjectionType_EvaluateValue__SWIG_0(swigCPtr, FbxTime.getCPtr(pTime), pForceEval); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
public FbxPropertyEProjectionType Set(FbxCamera.EProjectionType pValue) { FbxPropertyEProjectionType ret = new FbxPropertyEProjectionType(NativeMethods.FbxPropertyEProjectionType_Set(swigCPtr, (int)pValue), false); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
/// <summary> /// Configure FbxCameras from a Physical Camera /// </summary> private static void ConfigurePhysicalCamera(FbxCamera fbxCamera, Camera unityCamera) { Debug.Assert(unityCamera.usePhysicalProperties); // Configure FilmBack settings float apertureHeightInInches = unityCamera.sensorSize.y.Millimeters().ToInches(); float apertureWidthInInches = unityCamera.sensorSize.x.Millimeters().ToInches(); float aspectRatio = apertureWidthInInches / apertureHeightInInches; FbxCamera.EProjectionType projectionType = unityCamera.orthographic ? FbxCamera.EProjectionType.eOrthogonal : FbxCamera.EProjectionType.ePerspective; // NOTE: it is possible to match some of the sensor sizes to the // predefined EApertureFormats : e16mmTheatrical, eSuper16mm, // e35mmFullAperture, eIMAX. However the round in the sizes is not // consistent between Unity and FBX so we choose // to leave the values as a eCustomAperture setting. fbxCamera.ProjectionType.Set(projectionType); fbxCamera.FilmAspectRatio.Set(aspectRatio); Vector2 gameViewSize = GetSizeOfMainGameView(); fbxCamera.SetAspect(FbxCamera.EAspectRatioMode.eFixedRatio, gameViewSize.x / gameViewSize.y, 1.0); fbxCamera.SetApertureWidth(apertureWidthInInches); fbxCamera.SetApertureHeight(apertureHeightInInches); // Fit the resolution gate horizontally within the film gate. fbxCamera.GateFit.Set(s_mapGateFit[unityCamera.gateFit]); // Lens Shift ( Film Offset ) as a percentage 0..1 // FBX FilmOffset is in inches fbxCamera.FilmOffsetX.Set(apertureWidthInInches * Mathf.Clamp(Mathf.Abs(unityCamera.lensShift.x), 0f, 1f) * Mathf.Sign(unityCamera.lensShift.x)); fbxCamera.FilmOffsetY.Set(apertureHeightInInches * Mathf.Clamp(Mathf.Abs(unityCamera.lensShift.y), 0f, 1f) * Mathf.Sign(unityCamera.lensShift.y)); // Focal Length fbxCamera.SetApertureMode(FbxCamera.EApertureMode.eFocalLength); double focalLength = (double)unityCamera.focalLength; fbxCamera.FocalLength.Set(focalLength); /* in millimeters */ // NearPlane fbxCamera.SetNearPlane((double)unityCamera.nearClipPlane.Meters().ToCentimeters()); // FarPlane fbxCamera.SetFarPlane((float)unityCamera.farClipPlane.Meters().ToCentimeters()); return; }
/// <summary> /// Exports camera component /// </summary> protected FbxCamera ExportCamera(Camera unityCamera, FbxScene fbxScene, FbxNode fbxNode) { FbxCamera fbxCamera = FbxCamera.Create(fbxScene.GetFbxManager(), unityCamera.name); bool perspective = unityCamera.orthographic != true; float aspectRatio = unityCamera.aspect; // Configure FilmBack settings: 35mm TV Projection (0.816 x 0.612) float apertureHeightInInches = 0.612f; float apertureWidthInInches = aspectRatio * apertureHeightInInches; FbxCamera.EProjectionType projectionType = perspective ? FbxCamera.EProjectionType.ePerspective : FbxCamera.EProjectionType.eOrthogonal; fbxCamera.ProjectionType.Set(projectionType); fbxCamera.SetAspect(FbxCamera.EAspectRatioMode.eFixedRatio, aspectRatio, 1.0f); fbxCamera.FilmAspectRatio.Set(aspectRatio); fbxCamera.SetApertureWidth(apertureWidthInInches); fbxCamera.SetApertureHeight(apertureHeightInInches); fbxCamera.SetApertureMode(FbxCamera.EApertureMode.eFocalLength); // FOV / Focal Length fbxCamera.FocalLength.Set(fbxCamera.ComputeFocalLength(unityCamera.fieldOfView)); // NearPlane fbxCamera.SetNearPlane(unityCamera.nearClipPlane); // FarPlane fbxCamera.SetFarPlane(unityCamera.farClipPlane); // Export backgroundColor as a custom property // NOTE: export on fbxNode so that it will show up in Maya ExportColorProperty(fbxNode, unityCamera.backgroundColor, MakeName("backgroundColor"), "The color with which the screen will be cleared."); // Export clearFlags as a custom property // NOTE: export on fbxNode so that it will show up in Maya ExportIntProperty(fbxNode, (int)unityCamera.clearFlags, MakeName("clearFlags"), "How the camera clears the background."); return(fbxCamera); }