using Sandbox.UI;
namespace Sandbox;
///
/// Renders a panel in a scene world. You are probably looking for WorldPanel.
///
internal sealed class ScenePanelObject : SceneCustomObject
{
///
/// Global scale for panel rendering within a scene world.
///
public const float ScreenToWorldScale = 0.05f;
///
/// The panel that will be rendered.
///
public RootPanel Panel { get; private set; }
public ScenePanelObject( SceneWorld world, RootPanel Panel ) : base( world )
{
this.Panel = Panel;
}
public override void RenderSceneObject()
{
Graphics.Attributes.SetCombo( "D_WORLDPANEL", 1 );
//
// This converts it to front left up (instead of right, down, whatever)
// and we apply a sensible enough default scale.
//
Matrix mat = Matrix.CreateRotation( Rotation.From( 0, 90, 90 ) );
mat *= Matrix.CreateScale( ScreenToWorldScale );
Graphics.Attributes.Set( "WorldMat", mat );
Panel?.Render();
}
}