Object Hierarchy | 関連する C++クラス:Camera
Camera
v1.0
Camera オブジェクトは、シーン内の Softimage カメラです。Camera オブジェクトを作成すると、シーンの 3D ワールドの原点に注視点が必ず作成されます。カメラは、X3DObject.AddCameraまたはX3DObject.AddCameraRigを使用して作成できます。
以下の 1 番目の例に示すように、X3DObject.FindChildrenメソッドを使用してシーン内のカメラをすべて検索できます。
Field of View Angle(fov)やProjection Type(proj)など、Camera オブジェクトの最も重要な属性は、Primitiveを呼び出すと戻されるX3DObject.ActivePrimitiveのParameterオブジェクトとして表示されます。
'vbscript example demonstrating how to access all Cameras in the
'scene.
'Create a sample scene with different cameras
NewScene ,false
GetPrimCamera
GetPrimCamera "Telephoto.Preset", "Telephoto"
GetPrimCamera "Orthographic.Preset", "Ortho"
'Put the orthographic camera inside a model
CreateModel
GetPrimCamera "Wide_Angle.Preset", "WideAngle"
'Hide one of the cameras underneath a cone
GetPrim "Cone"
CopyPaste "WideAngle_Root", ,"cone", 1
GetPrimCamera "Wide_Angle.Preset", "WideAngle"
'Perform a recursive search for all the cameras in the scene
set oCamerasCollection = ActiveSceneRoot.FindChildren( ,siCameraFilter )
'Print out some information about the Cameras in the scene
logmessage "The scene contains " & oCamerasCollection.count & " cameras"
for i = 0 to oCamerasCollection.count - 1
set oCamera = oCamerasCollection.Item( i )
PrintCameraInfo oCamera
next
sub PrintCameraInfo( in_obj )
dim oCamera
set oCamera = in_obj
logmessage "-----------------------Camera " & i & "------------------------"
logmessage "Camera Name: " & oCamera.Name
logmessage "Camera Root: " & oCamera.Parent
logmessage "Camera Primitive: " & oCamera.ActivePrimitive
'The Interest a "sibling" of the Camera so
'we find it via the parent
set oChildrenOfParent = oCamera.Parent.Children
dim oInterest
for each o in oChildrenOfParent
if ( o.type = "CameraInterest" ) then
set oInterest = o
exit for
end if
next
logmessage "Camera Interest: " & oInterest
'Many aspects of the camera can be manipulated by reading and
'writing the parameters on these various objects
if ( oCamera.ActivePrimitive.Parameters("proj").Value = 1 ) then
logmessage "Projection: Perspective"
else
logmessage "Projection: Orthographic"
end if
logmessage "Field of View: " & oCamera.ActivePrimitive.Parameters("fov").Value
'Although these parameters actual belong to the local kinematic property,
'these shortforms are available to vbscript to make it even more convenient
logmessage "Interest Pos(local): (" & oInterest.posx.Value & _
"," & oInterest.posy.Value & _
"," & oInterest.posz.Value & ")"
set oGlobalKine = oInterest.Kinematics.Global
logmessage "Interest Pos(global): (" & oGlobalKine.Parameters("posx").Value & _
"," & oGlobalKine.Parameters("posy").Value & _
"," & oGlobalKine.Parameters("posz").Value & ")"
end sub
'This is part of the output from running this example:
'INFO : "-----------------------Camera 2------------------------"
'INFO : "Camera Name: Telephoto"
'INFO : "Camera Root: Telephoto_Root"
'INFO : "Camera Primitive: Telephoto.camera"
'INFO : "Camera Interest: Telephoto_Interest"
'INFO : "Projection: Perspective"
'INFO : "Field of View: 6.662"
'INFO : "Interest Pos(local): (0,-2,-20)"
'INFO : "Interest Pos(global): (0,0,0)"
'INFO : "-----------------------Camera 3------------------------"
'INFO : "Camera Name: Ortho"
'INFO : "Camera Root: Model.Ortho_Root"
'INFO : "Camera Primitive: Model.Ortho.camera"
'INFO : "Camera Interest: Model.Ortho_Interest"
'INFO : "Projection: Orthographic"
'INFO : "Field of View: 53.638"
'INFO : "Interest Pos(local): (0,-2,-20)"
'INFO : "Interest Pos(global): (0,0,0)"
'etc..... |
'VBScript example : display the properties of a camera Option Explicit CreateCamera() sub CreateCamera() dim oCam set oCam = ActiveProject.ActiveScene.Root.AddCameraRig( "Camera" ).camera LogMessage "camera interest" LogMessage oCam.name & ".interest.name: " & oCam.interest.name LogMessage "camera parameters" oCam.near.value = oCam.near.value * 2 oCam.far.value = oCam.far.value * 2 oCam.orthoheight.value = oCam.orthoheight.value * 2 oCam.fov.value = oCam.fov.value * 2 LogMessage oCam & ".near: " & oCam.near.value LogMessage oCam & ".far: " & oCam.far.value LogMessage oCam & ".orthoheight: " & oCam.orthoheight.value LogMessage oCam & ".fov: " & oCam.fov.value LogMessage "camera marking" oCam.near.marked = true oCam.far.marked = true oCam.orthoheight.marked = true oCam.fov.marked = true LogMessage oCam & ".near.marked: " & oCam.near.marked LogMessage oCam & ".far.marked: " & oCam.far.marked LogMessage oCam & ".orthoheight.marked: " & oCam.orthoheight.marked LogMessage oCam & ".fov.marked: " & oCam.fov.marked LogMessage "camera capabilities" LogMessage oCam & ".near.capabilities: " & oCam.near.capabilities LogMessage oCam & ".far.capabilities: " & oCam.far.capabilities LogMessage oCam & ".orthoheight.capabilities: " & oCam.orthoheight.capabilities LogMessage oCam & ".fov.capabilities: " & oCam.fov.capabilities LogMessage "camera kinematics position" oCam.posx.value = oCam.posx.value * 2 oCam.posy.value = oCam.posy.value * 2 oCam.posz.value = oCam.posz.value * 2 LogMessage oCam & ".posx: " & oCam.posx.value LogMessage oCam & ".posy: " & oCam.posy.value LogMessage oCam & ".posz: " & oCam.posz.value LogMessage "camera kinematics rotation" oCam.rotx.value = oCam.rotx.value * 2 oCam.roty.value = oCam.roty.value * 2 oCam.rotz.value = oCam.rotz.value * 2 LogMessage oCam & ".rotx: " & oCam.rotx.value LogMessage oCam & ".roty: " & oCam.roty.value LogMessage oCam & ".rotz: " & oCam.rotz.value LogMessage "camera kinematics scaling" oCam.sclx.value = oCam.sclx.value * 2 oCam.scly.value = oCam.scly.value * 2 oCam.sclz.value = oCam.sclz.value * 2 LogMessage oCam & ".sclx: " & oCam.sclx.value LogMessage oCam & ".scly: " & oCam.scly.value LogMessage oCam & ".sclz: " & oCam.sclz.value LogMessage "camera kinematics constrained transfo" oCam.cnsscl.value = false oCam.cnsori.value = false oCam.cnspos.value = false LogMessage oCam & ".cnsscl: " & oCam.cnsscl.value LogMessage oCam & ".cnsori: " & oCam.cnsori.value LogMessage oCam & ".cnspos: " & oCam.cnspos.value end sub |