Difference between revisions of "IC Python API:RLPy RICamera"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
Line 7: | Line 7: | ||
This class is used to access camera objects in the scene. A camera can be divided into 3 main parts: the device body, camera lens, and viewing area. Therefore, the interfaces available are: aperture, focal length, angle of view, depth of field, near / far plane settings, and viewport fitting. | This class is used to access camera objects in the scene. A camera can be divided into 3 main parts: the device body, camera lens, and viewing area. Therefore, the interfaces available are: aperture, focal length, angle of view, depth of field, near / far plane settings, and viewport fitting. | ||
− | + | See Also: [[IC_Python_API:RLPy_RCameraDofData|RCameraDofData]], [[IC_Python_API:RLPy_RScene|RScene]]. | |
=== Inheritance === | === Inheritance === | ||
Line 15: | Line 15: | ||
=== Examples === | === Examples === | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
Line 64: | Line 64: | ||
:Failure - RLPy.RStatus.Failure | :Failure - RLPy.RStatus.Failure | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
# Add a DOF key | # Add a DOF key | ||
new_data = RLPy.RCameraDofData() | new_data = RLPy.RCameraDofData() | ||
Line 87: | Line 87: | ||
:The camera's angle of view - float | :The camera's angle of view - float | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.GetAngleOfView(RLPy.RGlobal.GetTime()) | camera.GetAngleOfView(RLPy.RGlobal.GetTime()) | ||
Line 104: | Line 104: | ||
:Failure - RLPy.RStatus.Failure | :Failure - RLPy.RStatus.Failure | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
# Get the camera aperture | # Get the camera aperture | ||
width = 0 | width = 0 | ||
Line 121: | Line 121: | ||
:Camera DOF data - [[IC_Python_API:RLPy_RCameraDofData|RCameraDofData]] | :Camera DOF data - [[IC_Python_API:RLPy_RCameraDofData|RCameraDofData]] | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
# Grab camera DOF data | # Grab camera DOF data | ||
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
Line 145: | Line 145: | ||
:The camera's far clipping plane distance - int | :The camera's far clipping plane distance - int | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
far_clipping_plane = camera.GetFarClippingPlane() | far_clipping_plane = camera.GetFarClippingPlane() | ||
Line 163: | Line 163: | ||
:*RLPy.ECameraFitResolution_None | :*RLPy.ECameraFitResolution_None | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
fov_type = camera.GetFitRenderRegionType() | fov_type = camera.GetFitRenderRegionType() | ||
Line 182: | Line 182: | ||
:*RLPy.ECameraFitResolution_None | :*RLPy.ECameraFitResolution_None | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
type = camera.GetFitRenderRegionType() | type = camera.GetFitRenderRegionType() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 196: | Line 196: | ||
:Camera's focal length distance at a given time, in millimeters (2.5 mm to 3,500 mm) - float | :Camera's focal length distance at a given time, in millimeters (2.5 mm to 3,500 mm) - float | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.GetFocalLength(RLPy.RTime(60)) # get focal length | camera.GetFocalLength(RLPy.RTime(60)) # get focal length | ||
Line 208: | Line 208: | ||
:The Near Clipping Plane distance (always a positive value) - int | :The Near Clipping Plane distance (always a positive value) - int | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.GetNearClippingPlane() | camera.GetNearClippingPlane() | ||
Line 224: | Line 224: | ||
:Failure - RLPy.RStatus.Failure | :Failure - RLPy.RStatus.Failure | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.SetFarClippingPlane(RLPy.RTime(60), 1000.0) | camera.SetFarClippingPlane(RLPy.RTime(60), 1000.0) | ||
Line 242: | Line 242: | ||
:Failure - RLPy.RStatus.Failure | :Failure - RLPy.RStatus.Failure | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.SetFocalLength(RLPy.RTime(60), 100.0) | camera.SetFocalLength(RLPy.RTime(60), 100.0) | ||
Line 258: | Line 258: | ||
:Failure - RLPy.RStatus.Failure | :Failure - RLPy.RStatus.Failure | ||
− | <syntaxhighlight lang="python"> | + | <syntaxhighlight lang="python" line='line'> |
camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera") | ||
camera.SetNearClippingPlane(RLPy.RTime(60), 10.0) | camera.SetNearClippingPlane(RLPy.RTime(60), 10.0) | ||
print(camera.GetNearClippingPlane()) | print(camera.GetNearClippingPlane()) | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 00:05, 15 April 2020
Contents
- 1 Description
- 2 Member Functions
- 2.1 AddDofKey ( self, kKey, kDofData )
- 2.2 GetAngleOfView ( self, kTime )
- 2.3 GetAperture ( self, fWidth, fHeight )
- 2.4 GetDOFData ( self )
- 2.5 GetFarClippingPlane ( self )
- 2.6 GetFitFovType ( self )
- 2.7 GetFitRenderRegionType ( self )
- 2.8 GetFocalLength ( self, kTime )
- 2.9 GetNearClippingPlane ( self )
- 2.10 SetFarClippingPlane ( self, nFarPlane )
- 2.11 SetFocalLength ( self, kTime, fFocalLength )
- 2.12 SetNearClippingPlane ( self, nNearPlane )
- Main article: Modules.
- Last modified: 04/15/2020
Description
This class is used to access camera objects in the scene. A camera can be divided into 3 main parts: the device body, camera lens, and viewing area. Therefore, the interfaces available are: aperture, focal length, angle of view, depth of field, near / far plane settings, and viewport fitting.
See Also: RCameraDofData, RScene.
Inheritance
RIBase > RIObject > RICamera
Examples
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2
3 # Set the camera transform values
4 control = camera.GetControl("Transform")
5 transform = RLPy.RTransform.IDENTITY
6 transform.T().x = -75.0
7 transform.T().y = -150.0
8 transform.T().z = 250.0
9 time = RLPy.RTime(0)
10 control.SetValue(time, transform)
11 # update after adding a key
12 camera.Update()
13
14 # Set the camera name
15 camera.SetName( "new_name" )
16
17 # Get camera bounds
18 ret_max = RLPy.RVector3()
19 ret_center = RLPy.RVector3()
20 ret_min = RLPy.RVector3()
21 ret = camera.GetBounds( ret_max, ret_center, ret_min )
22 print(ret)
23
24 # Get the camera pivot transform values
25 ret_pos = RLPy.RVector3()
26 ret_rot = RLPy.RVector3()
27 camera.GetPivot( ret_pos, ret_rot )
28 print(ret)
29
30 # Check whether or the camera is selected
31 RLPy.RScene.SelectObject(camera)
32 print(camera.IsSelected()) #True
Member Functions
AddDofKey ( self, kKey, kDofData )
Key the camera's Depth of Field (DOF) at a given time. Use RCameraDofData to adjust the DOF settings.
Parameters
- kKey [IN] Designated time - RKey
- kDofData [IN] DOF settings - RCameraDofData
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 # Add a DOF key
2 new_data = RLPy.RCameraDofData()
3 new_data.SetEnable( True )
4 new_data.SetFocus(20)
5 data.SetRange(80)
6 dof_key = RLPy.RKey()
7 dof_key.SetTime(RLPy.RTime(66))
8 dof_key.SetTransitionType(RLPy.ETransitionType_Linear)
9 dof_key.SetTransitionStrength(50)
10 camera.AddDofKey(dof_key, new_data)
GetAngleOfView ( self, kTime )
Get the camera's Angle of View (AOV) at a given time, in degrees (1° to 165°).
Parameters
- kTime [IN] Time at which to get the AOV value - RTime
Returns
- The camera's angle of view - float
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.GetAngleOfView(RLPy.RGlobal.GetTime())
GetAperture ( self, fWidth, fHeight )
Get the camera's aperture dimensions, i.e. the width and height of the photo-sensitive capture plate.
Parameters
- fWidth [IN] Width of the camera aperture - float
- fHeight [IN] Height of the camera aperture - float
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 # Get the camera aperture
2 width = 0
3 height = 0
4 result = camera.GetAperture(width,height)
5 print(result[0])
6 print(result[1])
7 print(result[2])
GetDOFData ( self )
Get the camera's Depth of Field (DOF) data.
Returns
- Camera DOF data - RCameraDofData
1 # Grab camera DOF data
2 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
3 data = camera.GetDOFData()
4 if data is not None:
5 print(data.GetEnable())
6 print(data.GetFocus())
7 print(data.GetRange())
8 print(data.GetNearTransitionRegion())
9 print(data.GetFarTransitionRegion())
10 print(data.GetNearBlurScale())
11 print(data.GetFarBlurScale())
12 print(data.GetMinBlendDistance())
13 print(data.GetCenterColorWeight())
14 print(data.GetEdgeDecayPower())
GetFarClippingPlane ( self )
Get the camera's Far Clipping Plane distance.
Returns
- The camera's far clipping plane distance - int
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 far_clipping_plane = camera.GetFarClippingPlane()
GetFitFovType ( self )
Get the camera's Fit value for the Field of View. The possible values are the following:
- RLPy.ECameraFitResolution_Horizontal - use the horizontal width value for fitting.
- RLPy.ECameraFitResolution_Vertical - use the vertical height value for fitting.
Returns
- the type of setting ( Horizontal / Vertical ) - RLPy.ECameraFitResolution
- RLPy.ECameraFitResolution_Horizontal
- RLPy.ECameraFitResolution_Vertical
- RLPy.ECameraFitResolution_None
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 fov_type = camera.GetFitRenderRegionType()
3 print(fov_type)
GetFitRenderRegionType ( self )
Get the camera's Fit Resolution setting. The possible values are the following:
- RLPy.ECameraFitResolution_Horizontal - use the horizontal width value for fitting.
- RLPy.ECameraFitResolution_Vertical - use the vertical height value for fitting.
Returns
- The camera's Fit Type ( Horizontal / Vertical ) - RLPy.ECameraFitResolution
- RLPy.ECameraFitResolution_Horizontal
- RLPy.ECameraFitResolution_Vertical
- RLPy.ECameraFitResolution_None
1 type = camera.GetFitRenderRegionType()
GetFocalLength ( self, kTime )
Get the camera's Focal Length distance at a given time.
Parameters
- kTime [IN] Time at which to get the Focal Length distance - RTime
Returns
- Camera's focal length distance at a given time, in millimeters (2.5 mm to 3,500 mm) - float
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.GetFocalLength(RLPy.RTime(60)) # get focal length
GetNearClippingPlane ( self )
Get the camera's Near Clipping Plane distance.
Returns
- The Near Clipping Plane distance (always a positive value) - int
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.GetNearClippingPlane()
SetFarClippingPlane ( self, nFarPlane )
Set the Far Clipping Plane distance. This value must be larger than the Near Clipping Plane distance.
Parameters
- nFarPlane [IN] Far Clipping Plane distance - int
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.SetFarClippingPlane(RLPy.RTime(60), 1000.0)
3 print(camera.GetFarClippingPlane())
SetFocalLength ( self, kTime, fFocalLength )
Set the camera's Focal Length at a given point in time. The possible values lie between 2.5 and 3,500 mm. If the value set lies outside of this range, then the original Focal Length value remains unchanged.
Parameters
- kTime [IN] Time for setting the focal length - RTime
- fFocalLength [IN] Target distance for the focal length in millimeters - float
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.SetFocalLength(RLPy.RTime(60), 100.0)
SetNearClippingPlane ( self, nNearPlane )
Set the Near Clipping Plane distance, must be smaller than the Far Clipping Plane distance.
Parameters
- nNearPlane [IN] The Near Clipping Plane distance - int
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "Camera")
2 camera.SetNearClippingPlane(RLPy.RTime(60), 10.0)
3 print(camera.GetNearClippingPlane())