DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
Perspective views

API method: ILDXSheetFrame5.ViewFrustum

Treename: Sheets.LdvSheet1.LdvFrame2.

 ' from Samples/Src/LDXAPIExamples/Example_LDXSheetFrame.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.LdvSheet1.LdvFrame2.", "LDXSheetFrame~ViewFrustum", "Perspective views")>
 Public Shared Sub PerspectiveView(ByRef ldxDocument As DigiPara.LDX.LDXDocument)

     If ldxDocument.GetObject("Sheets.LdvSheet1.LdvFrame2.") Is Nothing Then
         MsgBox("Desired sheet frame not found! Please reload the relevant .ld3 file.")
         Exit Sub
     End If

     With DirectCast(ldxDocument.GetLDXObject("Sheets.LdvSheet1.LdvFrame2.").LDXType, DigiPara.LDX.LDXSheetFrame)
         If (.FrameMode2 And DigiPara.LDX.SheetFrameModes2.shfrm2CentralProjection) <> DigiPara.LDX.SheetFrameModes2.shfrm2CentralProjection Then
             ' activate 3D view
             .Reset(DigiPara.LDX.SheetFrameViewType.shfvt3D, DigiPara.LDX.SheetFrameViewDirections.shfvdToFromTop, DigiPara.LDX.SheetFrameResetOptions.shfrrstNone)
             .Scale = 1 / 50.0

             ' for LD 22.0.105 and earlier, a rebuild is required here
             '.CalculateModelBarrierAcquire()

             ' with central projection
             .FrameMode2 = .FrameMode2 Or DigiPara.LDX.SheetFrameModes2.shfrm2CentralProjection

             ' central projection needs some more data than parallel projection. You need to pick a camera target, here the car center:
             .CameraTarget._Set = ldxDocument.Shaft.Car.Comp.WorldMatrix.R

             ' and a camera position, here some offset from the target:
             .CameraPosition.X = .CameraTarget.X - 5000
             .CameraPosition.Y = .CameraTarget.Y - 5000
             .CameraPosition.Z = .CameraTarget.Z + 2000

             ' in case there is any visible geometry not in front of the camera position, you also need to set up frustum culling.
             .FrameMode2 = .FrameMode2 Or DigiPara.LDX.SheetFrameModes2.shfrm2FrustumCulling

             '(That porperty is a convencience wrapper for 1/.ViewFrustum.PtMax.Z, because camera math is confusing)
             ' left/right/top/bottom cutoffs are here:
             ' all the values set are in project units, so mm here. They represent the cutoff distances at the camera target point.
             With .ViewFrustum
                 .PtMax.X = 3000
                 .PtMax.Y = 4000
                 .PtMin.X = -3000
                 .PtMin.Y = -2000
             End With

             ' This is the nearest an object can be to the camera to be visible, in project options:
             .ViewFrustumZNear = 0.01
             ' ZNear is measured in units of (.CameraPosition - .CameraTarget).Length().

             ' disable some components to make the view less busy
             .VisibleProductGroups = .VisibleProductGroups And Not DigiPara.LDX.SheetFrameProductGroups.shfpCarInterior And Not DigiPara.LDX.SheetFrameProductGroups.shfpShaft And Not DigiPara.LDX.SheetFrameProductGroups.shfpRefugeSpaces
         Else
             ' back to plan view
             .Reset(DigiPara.LDX.SheetFrameViewType.shfvtPlan, DigiPara.LDX.SheetFrameViewDirections.shfvdToFromTop, DigiPara.LDX.SheetFrameResetOptions.shfrrstNone)
         End If
     End With
 End Sub