mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-15 09:49:23 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
104 lines
2.0 KiB
C#
104 lines
2.0 KiB
C#
using NativeEngine;
|
|
using System;
|
|
|
|
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Renders a skybox within a <see cref="SceneWorld"/>.
|
|
/// </summary>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The skybox material. Typically it should use the "Sky" shader.
|
|
/// </summary>
|
|
public Material SkyMaterial
|
|
{
|
|
set => skyboxNative.SetMaterial( value?.native ?? default );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Skybox color tint.
|
|
/// </summary>
|
|
public Color SkyTint
|
|
{
|
|
get => skyboxNative.GetSkyTint();
|
|
set => skyboxNative.SetSkyTint( value );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Controls the skybox specific fog.
|
|
/// </summary>
|
|
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 )
|
|
{
|
|
}
|
|
}
|