using NativeEngine;
using System;
namespace Sandbox;
///
/// Renders a skybox within a .
///
public class SceneSkyBox : SceneObject
{
CSceneSkyBoxObject skyboxNative;
public enum FogType
{
None,
Distance,
Angular
}
public struct FogParamInfo
{
public FogType FogType;
public float FogMinStart;
public float FogMinEnd;
public float FogMaxStart;
public float FogMaxEnd;
}
public struct SkyLightInfo
{
public Vector3 LightColor;
public Vector3 LightDirection;
}
internal SceneSkyBox() { }
internal SceneSkyBox( HandleCreationData _ ) { }
public SceneSkyBox( SceneWorld world, Material skyMaterial )
{
Assert.NotNull( skyMaterial );
Assert.IsValid( world );
using ( var h = IHandle.MakeNextHandle( this ) )
{
CSceneSystem.CreateSkyBox( skyMaterial.native, world );
}
}
internal override void OnNativeInit( CSceneObject ptr )
{
base.OnNativeInit( ptr );
skyboxNative = (CSceneSkyBoxObject)ptr;
}
internal override void OnNativeDestroy()
{
skyboxNative = default;
base.OnNativeDestroy();
}
///
/// The skybox material. Typically it should use the "Sky" shader.
///
public Material SkyMaterial
{
set => skyboxNative.SetMaterial( value?.native ?? default );
}
///
/// Skybox color tint.
///
public Color SkyTint
{
get => skyboxNative.GetSkyTint();
set => skyboxNative.SetSkyTint( value );
}
///
/// Controls the skybox specific fog.
///
public FogParamInfo FogParams
{
get => new()
{
FogType = (FogType)skyboxNative.GetFogType(),
FogMinStart = skyboxNative.GetFogMinStart(),
FogMinEnd = skyboxNative.GetFogMinEnd(),
FogMaxStart = skyboxNative.GetFogMaxStart(),
FogMaxEnd = skyboxNative.GetFogMaxEnd()
};
set
{
skyboxNative.SetFogType( (int)value.FogType );
skyboxNative.SetAngularFogParams( value.FogMinStart, value.FogMinEnd, value.FogMaxStart, value.FogMaxEnd );
}
}
[Obsolete]
public void SetSkyLighting( Vector3 ConstantSkyLight )
{
}
}