DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
Change global lights

API method: ILDXVisualScene5.GlobalLights

Treename: Sheets.Scene.Lights.

6 code examples follow.

Example 1: Set up global lights: Volcano

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Volcano")>
 Public Shared Sub Lights_Ambient(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If lights.Count = 0 Then
         ' disable predefined lights
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplNone

         Dim light As DigiPara.LDX.LDXVisualSceneLight

         ' add red ambient light from below
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 0)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 0)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 255)
         light.Direction.X = 0
         light.Direction.Y = 0
         light.Direction.Z = -1

         ' make it an ambient light
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmAmblient
     Else
         ResetToDefault(visualScene)
     End If
 End Sub

Example 2: Set up global lights: Shadow

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Shadow")>
 Public Shared Sub Lights_Shadow(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If lights.Count = 0 Then
         ' disable predefined lights
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplNone

         Dim light As DigiPara.LDX.LDXVisualSceneLight
         ' bright light from above, right, front
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 255)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 255)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 255)
         light.Direction.X = 1
         light.Direction.Y = -1
         light.Direction.Z = 1

         ' make it cast a shadow
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmShadows
     Else
         ResetToDefault(visualScene)
     End If
 End Sub

Example 3: Set up global lights: Co-rotating

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Co-rotating")>
 Public Shared Sub Lights_Corotate(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If lights.Count = 0 Then
         ' disable predefined lights
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplNone

         Dim light As DigiPara.LDX.LDXVisualSceneLight
         ' bright light from the front directly
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 255)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 255)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 255)
         light.Direction.X = 0
         light.Direction.Y = -1
         light.Direction.Z = 0

         ' make it rotate with the camera
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmRotateWithCamera
     Else
         ResetToDefault(visualScene)
     End If
 End Sub

Example 4: Set up global lights: Default

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Default")>
 Public Shared Sub Lights_Default(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If lights.Count = 0 Then
         ' disable predefined lights
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplNone

         ' set up lights like the default lights you get if you do not do anything
         ' nothing should happen if you activate this sample; use it as a base for when
         ' you want the default lighting, but slightly altered
         Dim light As DigiPara.LDX.LDXVisualSceneLight

         ' bright light coming from the right and top, rotating with the camera
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 180)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 180)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 180)
         light.Direction.X = 0.5
         light.Direction.Y = -1
         light.Direction.Z = 0.5
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmRotateWithCamera

         ' softer light coming from the left and bottom, also corotating
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 80)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 80)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 80)
         light.Direction.X = -2
         light.Direction.Y = -1
         light.Direction.Z = -0.5
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmRotateWithCamera

         ' blue ambient light from above
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 72)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 80)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 96)
         light.Direction.X = 0
         light.Direction.Y = 0
         light.Direction.Z = 1
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmAmblient

         ' brownish light from below
         light = lights.Add()
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtRed, 32)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtGreen, 16)
         light.ChangeColorComponent(DigiPara.LDX.CompOGLType.ogtBlue, 0)
         light.Direction.X = 0
         light.Direction.Y = 0
         light.Direction.Z = -1
         light.VSL_MODE = DigiPara.LDX.VisualSceneLightModes.vslmAmblient
     Else
         ResetToDefault(visualScene)
     End If
 End Sub

Example 5: Set up global lights: Predefined Floodlight

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Predefined Floodlight")>
 Public Shared Sub Lights_Flood(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplDefault Then
         ' enable one specific predefined light
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplFloodlight
     Else
         ResetToDefault(visualScene)
     End If
 End Sub

Example 6: Set up global lights: Predefined combination

 ' from Samples/Src/LDXAPIExamples/Example_LDXVisualScene.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.Scene.Lights.", "LDXVisualScene~GlobalLights", "Set up global lights: Predefined combination")>
 Public Shared Sub Lights_PredefinedCombination(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     Dim visualScene As DigiPara.LDX.LDXVisualScene = ldxDocument.Sheets.VisualScene
     Dim lights As DigiPara.LDX.LDXVisualSceneLights = visualScene.GlobalLights

     If visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplDefault Then
         ' enable a combination of lights; for the result to not be oversaturated, we need to decrease the strength
         visualScene.PredefinedLights = DigiPara.LDX.VisualScenePredefinedLights.vsplAmbientDefault Or DigiPara.LDX.VisualScenePredefinedLights.vsplShadowLeft Or DigiPara.LDX.VisualScenePredefinedLights.vsplStrongRight Or DigiPara.LDX.VisualScenePredefinedLights.vsplStrongLeft
         visualScene.GlobalLightStrength = 0.5
     Else
         ResetToDefault(visualScene)
     End If
 End Sub