- ' ------------------------------------------------------------------
- ' ********************
- ' *** Licht-Engine ***
- ' ********************
- ' * Allgemeines Licht festlegen *
- Public Sub SetzeAllgemeinesLicht(ByVal AmbientFarbe As System.Drawing.Color)
- ' Allgemeines Licht festlegen
- MYDEVICE.RenderState.Ambient = AmbientFarbe
- End Sub
- ' * Erstelle Duration Licht*
- Public Sub ErstelleDurationLicht(ByVal Nummer As Byte, ByVal XR As Short, ByVal YR As Single, ByVal Farbe As System.Drawing.Color)
- ' Übergabe
- Dim DirectionalLightDirectionX As Double
- Dim DirectionalLightDirectionY As Single
- Dim DirectionalLightDirectionZ As Double
- ' Var & Rotate
- Dim BlickX As Double = 100 * Math.Cos(Geometry.DegreeToRadian(XR))
- Dim BlickZ As Double = 100 * Math.Sin(Geometry.DegreeToRadian(XR))
- ' Direction
- DirectionalLightDirectionX = BlickX * -1
- DirectionalLightDirectionY = YR
- DirectionalLightDirectionZ = BlickZ
- ' Erstellen Licht
- LightBuffer(Nummer) = New Light
- ' Übergebe Licht
- LightBuffer(Nummer).Type = LightType.Directional
- LightBuffer(Nummer).Ambient = Farbe
- LightBuffer(Nummer).Diffuse = Farbe
- LightBuffer(Nummer).Specular = Farbe
- LightBuffer(Nummer).XDirection = DirectionalLightDirectionX
- LightBuffer(Nummer).YDirection = DirectionalLightDirectionY
- LightBuffer(Nummer).ZDirection = DirectionalLightDirectionZ
- End Sub
- ' * Erstelle Point Licht*
- Public Sub ErstellePointLicht(ByVal Nummer As Byte, ByVal X As Single, ByVal Y As Single, ByVal Z As Single, ByVal Farbe As System.Drawing.Color, ByVal Weite As Single)
- ' Erstellen Licht
- LightBuffer(Nummer) = New Light
- ' Übergebe Licht
- LightBuffer(Nummer).Type = LightType.Point
- LightBuffer(Nummer).Ambient = Farbe
- LightBuffer(Nummer).Diffuse = Farbe
- LightBuffer(Nummer).Specular = Farbe
- LightBuffer(Nummer).Attenuation0 = 0
- LightBuffer(Nummer).Attenuation1 = 1
- LightBuffer(Nummer).Attenuation2 = 0
- LightBuffer(Nummer).Range = Weite
- LightBuffer(Nummer).XPosition = X
- LightBuffer(Nummer).YPosition = Y
- LightBuffer(Nummer).ZPosition = Z
- End Sub
- ' * Erstelle Spot Licht*
- Public Sub ErstelleSpotLicht(ByVal Nummer As Byte, ByVal X As Single, ByVal Y As Single, ByVal Z As Single, ByVal XR As Short, ByVal YR As Single, ByVal KA As Integer, ByVal KI As Integer, ByVal Farbe As System.Drawing.Color, ByVal Weite As Single)
- ' Übergabe
- Dim DirectionalLightDirectionX As Double
- Dim DirectionalLightDirectionY As Single
- Dim DirectionalLightDirectionZ As Double
- ' Var & Rotate
- Dim BlickX As Double = 100 * Math.Cos(Geometry.DegreeToRadian(XR))
- Dim BlickZ As Double = 100 * Math.Sin(Geometry.DegreeToRadian(XR))
- ' Direction
- DirectionalLightDirectionX = BlickX * -1
- DirectionalLightDirectionY = YR
- DirectionalLightDirectionZ = BlickZ
- ' Erstellen Licht
- LightBuffer(Nummer) = New Light
- ' Übergebe Licht
- LightBuffer(Nummer).Type = LightType.Spot
- LightBuffer(Nummer).Ambient = Farbe
- LightBuffer(Nummer).Diffuse = Farbe
- LightBuffer(Nummer).Specular = Farbe
- LightBuffer(Nummer).Attenuation0 = 0
- LightBuffer(Nummer).Attenuation1 = 2
- LightBuffer(Nummer).Attenuation2 = 0
- LightBuffer(Nummer).Range = Weite
- LightBuffer(Nummer).XPosition = X
- LightBuffer(Nummer).YPosition = Y
- LightBuffer(Nummer).ZPosition = Z
- LightBuffer(Nummer).XDirection = DirectionalLightDirectionX
- LightBuffer(Nummer).YDirection = DirectionalLightDirectionY
- LightBuffer(Nummer).ZDirection = DirectionalLightDirectionZ
- LightBuffer(Nummer).OuterConeAngle = KA / 57.296
- LightBuffer(Nummer).InnerConeAngle = KI / 57.296
- LightBuffer(Nummer).Falloff = 1
- End Sub
- ' * Setze Licht *
- Public Sub SetzeLicht(ByVal LichtNummer As Integer, ByVal LichtBuffer As Byte)
- ' Licht setzen
- MYDEVICE.Lights(LichtNummer).Type() = LightBuffer(LichtBuffer).Type
- MYDEVICE.Lights(LichtNummer).Ambient = LightBuffer(LichtBuffer).Ambient
- MYDEVICE.Lights(LichtNummer).Diffuse = LightBuffer(LichtBuffer).Diffuse
- MYDEVICE.Lights(LichtNummer).Specular = LightBuffer(LichtBuffer).Specular
- MYDEVICE.Lights(LichtNummer).Attenuation0 = LightBuffer(LichtBuffer).Attenuation0
- MYDEVICE.Lights(LichtNummer).Attenuation1 = LightBuffer(LichtBuffer).Attenuation1
- MYDEVICE.Lights(LichtNummer).Attenuation2 = LightBuffer(LichtBuffer).Attenuation2
- MYDEVICE.Lights(LichtNummer).XPosition = LightBuffer(LichtBuffer).XPosition
- MYDEVICE.Lights(LichtNummer).YPosition = LightBuffer(LichtBuffer).YPosition
- MYDEVICE.Lights(LichtNummer).ZPosition = LightBuffer(LichtBuffer).ZPosition
- MYDEVICE.Lights(LichtNummer).XDirection = LightBuffer(LichtBuffer).XDirection
- MYDEVICE.Lights(LichtNummer).YDirection = LightBuffer(LichtBuffer).YDirection
- MYDEVICE.Lights(LichtNummer).ZDirection = LightBuffer(LichtBuffer).ZDirection
- MYDEVICE.Lights(LichtNummer).Range = LightBuffer(LichtBuffer).Range
- MYDEVICE.Lights(LichtNummer).OuterConeAngle = LightBuffer(LichtBuffer).OuterConeAngle()
- MYDEVICE.Lights(LichtNummer).InnerConeAngle = LightBuffer(LichtBuffer).InnerConeAngle()
- MYDEVICE.Lights(LichtNummer).Falloff = LightBuffer(LichtBuffer).Falloff()
- ' Für Duration-Licht ?!?
- MYDEVICE.Lights(LichtNummer).Commit()
- ' Licht ein oder ausschalten
- MYDEVICE.Lights(LichtNummer).Enabled = True
- End Sub
- ' * Freigabe Licht *
- Public Sub FreigabeLicht(ByVal Nummer As Byte)
- ' Freigeben Licht
- LightBuffer(Nummer) = Nothing
- End Sub
- ' * Setze LichtSchalter *
- Public Sub SetzeLichtSchalter(ByVal LichtNummer As Integer, ByVal Schalter As Boolean)
- ' Licht ein oder ausschalten
- MYDEVICE.Lights(LichtNummer).Enabled = Schalter
- End Sub
- ' * Setze Specular-Schalter *
- Public Sub SetzeSpecularSchalter(ByVal Schalter As Boolean)
- ' Alpha-Blend-Modus ein bzw. ausschalten
- MYDEVICE.RenderState.SpecularEnable = Schalter
- End Sub
- ' ------------------------------------------------------------------