-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #525 from fragcolor-xyz/guus/virtual-ui
Virtual UI panels
- Loading branch information
Showing
43 changed files
with
1,426 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
This shards defines a single world space UI panel. This shard needs to be placed within a [Spatial.UI](../UI)'s Contents block. | ||
|
||
This size of the panels defined using virtual UI points/units/pixels. How these virtual points map to world coordinates is controlled by the UI's Scale parameter. For example if the UI's scale is set to 200; 200 virtual points will be equal to 1 unit in world space. | ||
|
||
A panel's position and orientation in the world is controlled by the `Transform` parameter, which is a standard 4x4 transformation matrix. | ||
|
||
!!! danger | ||
Applying scaling on this transform is not recommended and may result in undefined behavior. | ||
|
||
The Panels' contents should be placed in the `Contents` parameter, similar to the screen space [UI](../../General/UI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This shard defines the starting point for creating interactive world space UI elements. | ||
|
||
Every instance of [Spatial.Panel](../Panel) should be placed within this shards's Contents parameter. | ||
|
||
The draw commands for the UI elements are added to the Queue that is passed in. In contrast to the screen space [UI](../../General/UI) shard, they do not need to be rendered using a [GFX.UIPass](../../GFX/UIPass) | ||
|
||
!!! note | ||
When rendering the draw commands, the sorting mode should be set to [SortMode.Queue](../../../enums/SortMode) so they are drawn in the correct order. | ||
The [BuiltinFeatureId.Transform](../../GFX/BuiltinFeature/#transform) feature should be used |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
(Setup | ||
(GFX.DrawQueue) >= .queue | ||
|
||
; Create render steps | ||
(GFX.BuiltinFeature :Id BuiltinFeatureId.Transform) >> .features | ||
{:Features .features :Queue .queue :Sort SortMode.Queue} (GFX.DrawablePass) >> .render-steps | ||
|
||
; Panel transforms | ||
15.0 (Math.DegreesToRadians) (Math.AxisAngleY) (Math.Rotation) >= .tmp | ||
(Float3 -1.0 0.0 0.0) (Math.Translation) (Math.MatMul .tmp) >= .panel-t-0 | ||
-15.0 (Math.DegreesToRadians) (Math.AxisAngleY) (Math.Rotation) >= .tmp | ||
(Float3 1.0 0.0 0.0) (Math.Translation) (Math.MatMul .tmp) >= .panel-t-1 | ||
5.0 (Math.DegreesToRadians) (Math.AxisAngleX) (Math.Rotation) >= .tmp | ||
(Float3 0.0 1.2 0.0) (Math.Translation) (Math.MatMul .tmp) >= .panel-t-2 | ||
|
||
; Camera | ||
{:Position (Float3 1 2 8) :Target (Float3 0 0 0)} (Math.LookAt) >= .view-transform | ||
(GFX.View :View .view-transform) >= .view) | ||
|
||
(GFX.MainWindow | ||
:Title "World space UI" :Width 1280 :Height 720 | ||
:Contents | ||
(-> | ||
.queue (GFX.ClearQueue) | ||
(Spatial.UI | ||
:Queue .queue :View .view :Scale 100.0 :Contents | ||
(-> | ||
(Spatial.Panel | ||
:Transform .panel-t-0 :Size (Float2 100 100) :Contents | ||
(-> | ||
(UI.CentralPanel | ||
(-> | ||
"Left panel" (UI.Label) | ||
(UI.Button :Label "Button"))))) | ||
(Spatial.Panel | ||
:Transform .panel-t-1 :Size (Float2 100 100) :Contents | ||
(-> | ||
(UI.CentralPanel | ||
(-> | ||
"Right panel" (UI.Label) | ||
(UI.Button :Label "Button"))))) | ||
(Spatial.Panel | ||
:Transform .panel-t-2 :Size (Float2 300 60) :Contents | ||
(-> | ||
(UI.CentralPanel | ||
(-> | ||
"Wide panel" (UI.Label) | ||
(Setup | ||
(LoadImage "../../assets/ShardsLogo.png") (GFX.Texture) >= .button-texture) | ||
(UI.Horizontal (-> | ||
.button-texture (UI.ImageButton :Scale (Float2 0.01)) | ||
.button-texture (UI.ImageButton :Scale (Float2 0.01)) | ||
.button-texture (UI.ImageButton :Scale (Float2 0.01)))))))))) | ||
|
||
(GFX.Render :Steps .render-steps :View .view))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
![Image](../assets/render_output.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.