How to add your knowledge

iv_setCamera()

    Table of contents
    1. 1. Synopsis
    2. 2. Syntax
    3. 3. Example 1
    4. 4. Example 2 

    Version as of 00:36, 25 May 2013

    to this version.

    Return to Version archive.

    View current version

    Synopsis

    Sets the various camera parameters in the specified View of the Document.

    Syntax

    iv_setCamera ( document As Part, _
                   viewNo As Integer, _
                   cameraFit? As Boolean, _
                   cameraViewOrientation As Name, _
                   cameraPerspective? As Boolean, _
                   cameraPerspectiveAngle As Number, _
                   cameraEye As Point, _
                   cameraTarget As Point, _
                   cameraUpVector As Vector, _
                   cameraWidth As Number, _
                   cameraHeight As Number, _
                   cameraUseTransition? As Boolean ) As List 
    Argument Type Description
    document part Handle of the document owning the camera.
    viewNo integer Specifies the view number to use
    cameraFit? boolean If set, the scene will be fit into the view
    cameraViewOrientation name One of the predefined orientations:

    :Front, :Top, :Right, :Back, :Bottom, :Left, :IsoTopRight, :IsoTopLeft,:IsoBottomRight, :IsoBottomLeft,

    or

    :Arbitrary

    cameraPerspective? boolean Specifies Perspective or Parallel projection type
    cameraPerspectiveAngle number Specifies the angle of the projection, for the perspective camera type
    cameraEye point Position of the camera center. If Novalue, the current position is used
    cameraTarget point Point the camera is looking at. If NoValue, this parameter is ignored
    cameraUpVector vector Specifies the camera rotation along its axis. If NoValue, the current angle is used
    cameraWidth number Width of the camera extent. Can be NoValue
    cameraHeight number Height of the camera extent. Can be NoValue
    cameraUseTransitions? boolean If set, the transitions (animation) will be used to set the camera.

    Example 1

    The Camera parameters on an Assembly document are the same as the arguments to iv_setCamera().

    Example 2 

    The sample design CameraObject below demonstrates use of camera functions. The design when instantiated creates the snapshot using current camera settings. The settings are also saved. The setcamera rule  in the design can called to restore the camera settings from stored values. For simplicity only three value Camera Eye,Target and UpVector are saved in dynamic rule.

     

     
    Design CameraObject : Your_ApplicationRoot IvComponentGroup
    
        Rule cameraOrientation As Name  = :Front
        Rule perspective? As Boolean = False
        Rule perspectiveAngle As Number =0
        Rule cameraEye As Point = Point(0,0,0)
        Rule cameraTarget As Point = Point(0,0,0)
        Rule cameraUpVector As Vector = Vector(0,0,1)
        Rule cameraWidth As Number =0
        Rule cameraHeight As Number =0
    
        Uncached Rule setcamera As Boolean = setcameramethod() 
    
    Method setcameramethod() As Boolean 
         iv_setCamera ( root, _
                   1, _
                   False, _
                   cameraOrientation, _
                   perspective? , _
                   perspectiveAngle, _
                   cameraEye , _
                   cameraTarget, _
                   cameraUpVector, _
                   cameraWidth , _
                   cameraheight , _
                   True ) 
      
          Return True 
    End Method 
    
    Method PostCreateSelf() As List
        Dim _cameraEye As Point = second(second(root.getcamera()))
        Dim _cameraTarget As Point=second( nth(7,root.getcamera()))
        Dim _cameraUpVector As Vector  = second( nth(8,root.getcamera()))
        Dim _cameraWidth As Number =second(third(root.getcamera()))
        Dim _cameraHeight As Number =second(nth(4,root.getcamera()))
        Dim _perspective? As Boolean = second(nth(5,root.getcamera()))
        Dim _perspectiveAngle As Number =second(nth(6,root.getcamera()))
        Dim _cameraOrientation As Name  = second( nth(9,root.getcamera()))
        'Create snapshot when camera object is created
        iv_SaveImage(root,_
                False,_
                _cameraOrientation,_
                _perspective? ,_
                _perspectiveAngle, _
                _cameraEye,_
                _cameraTarget,_
                _cameraUpVector,_
                _cameraWidth,_
                _cameraHeight,_
                "c:\temp\image1.jpg",_
                1024,_
                768, _
                "default",_
                "default" _
                )
        Dim s1 As String ="Point_("  + stringValue(getx(_cameraEye)) + "," _
                                     + stringValue(gety(_cameraEye)) + "," _
                                     + stringValue(getz(_cameraEye)) _
                                     + ",worldFrame())"
                                 
        Dim s2 As String ="Point_("  + stringValue(getx(_cameraTarget)) + "," _
                                     + stringValue(gety(_cameraTarget)) + "," _
                                     + stringValue(getz(_cameraTarget)) _
                                     + ",worldFrame())"
                                 
        Dim s3 As String ="Vector_(" + stringValue(getx(_cameraUpVector)) + "," _
                                     + stringValue(gety(_cameraUpVector)) + "," _
                                     + stringValue(getz(_cameraUpVector)) _
                                     + ",worldFrame())"
        Return { _
        {:action, :CreateDynamicRule, _
         :part, self(), _
         :name, :cameraEye, _
         :formula, s1 _
        }, _
        {:action, :CreateDynamicRule, _
         :part, self(), _
         :name, :cameraTarget, _
         :formula, s2 _ 
         }, _
        {:action, :CreateDynamicRule, _
         :part, self(), _
         :name, :cameraUpVector, _
         :formula, s3 _
         } _
        } 
     End Method
     
    End Design