diff --git a/Assets/Editor/Editor.SHConfig b/Assets/Editor/Editor.SHConfig index 37edf50c..9bd51ca8 100644 --- a/Assets/Editor/Editor.SHConfig +++ b/Assets/Editor/Editor.SHConfig @@ -1,4 +1,4 @@ Start Maximized: true -Working Scene ID: 97158628 +Working Scene ID: 86098106 Window Size: {x: 1920, y: 1013} Style: 0 \ No newline at end of file diff --git a/Assets/Materials/ShinyHightlight.shmat b/Assets/Materials/ShinyHightlight.shmat new file mode 100644 index 00000000..bb521519 --- /dev/null +++ b/Assets/Materials/ShinyHightlight.shmat @@ -0,0 +1,8 @@ +- VertexShader: 37048829 + FragmentShader: 45685219 + SubPass: G-Buffer Write + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 57342922 + data.alpha: 0 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/ShinyHightlight.shmat.shmeta b/Assets/Materials/ShinyHightlight.shmat.shmeta new file mode 100644 index 00000000..6ab0ac19 --- /dev/null +++ b/Assets/Materials/ShinyHightlight.shmat.shmeta @@ -0,0 +1,3 @@ +Name: ShinyHightlight +ID: 122370915 +Type: 7 diff --git a/Assets/Materials/Silhouette.shmat b/Assets/Materials/Silhouette.shmat new file mode 100644 index 00000000..912775f0 --- /dev/null +++ b/Assets/Materials/Silhouette.shmat @@ -0,0 +1,8 @@ +- VertexShader: 38847805 + FragmentShader: 42962441 + SubPass: Object VFX Subpass No Depth + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 0 + data.alpha: 0 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/Silhouette.shmat.shmeta b/Assets/Materials/Silhouette.shmat.shmeta new file mode 100644 index 00000000..be1f7bde --- /dev/null +++ b/Assets/Materials/Silhouette.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Silhouette +ID: 126391182 +Type: 7 diff --git a/Assets/Materials/UI/GameIcon.shmat b/Assets/Materials/UI/GameIcon.shmat new file mode 100644 index 00000000..7eb1a6e3 --- /dev/null +++ b/Assets/Materials/UI/GameIcon.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 35983630 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 51158984 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/GameIcon.shmat.shmeta b/Assets/Materials/UI/GameIcon.shmat.shmeta new file mode 100644 index 00000000..905012d7 --- /dev/null +++ b/Assets/Materials/UI/GameIcon.shmat.shmeta @@ -0,0 +1,3 @@ +Name: GameIcon +ID: 126117259 +Type: 7 diff --git a/Assets/Materials/UI/Instruction_01.shmat b/Assets/Materials/UI/Instruction_01.shmat new file mode 100644 index 00000000..bbcb6352 --- /dev/null +++ b/Assets/Materials/UI/Instruction_01.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 35983630 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 62200943 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/Instruction_01.shmat.shmeta b/Assets/Materials/UI/Instruction_01.shmat.shmeta new file mode 100644 index 00000000..a7a5e4d8 --- /dev/null +++ b/Assets/Materials/UI/Instruction_01.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Instruction_01 +ID: 124926341 +Type: 7 diff --git a/Assets/Materials/UI/Instruction_02.shmat b/Assets/Materials/UI/Instruction_02.shmat new file mode 100644 index 00000000..3084049a --- /dev/null +++ b/Assets/Materials/UI/Instruction_02.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 35983630 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 53303669 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/Instruction_02.shmat.shmeta b/Assets/Materials/UI/Instruction_02.shmat.shmeta new file mode 100644 index 00000000..dfc296f8 --- /dev/null +++ b/Assets/Materials/UI/Instruction_02.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Instruction_02 +ID: 128721520 +Type: 7 diff --git a/Assets/Materials/UI/Instruction_03.shmat b/Assets/Materials/UI/Instruction_03.shmat new file mode 100644 index 00000000..b548319f --- /dev/null +++ b/Assets/Materials/UI/Instruction_03.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 35983630 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 61780097 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/Instruction_03.shmat.shmeta b/Assets/Materials/UI/Instruction_03.shmat.shmeta new file mode 100644 index 00000000..46aa5270 --- /dev/null +++ b/Assets/Materials/UI/Instruction_03.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Instruction_03 +ID: 124482180 +Type: 7 diff --git a/Assets/Materials/UI/Instruction_04.shmat b/Assets/Materials/UI/Instruction_04.shmat new file mode 100644 index 00000000..dba0a45d --- /dev/null +++ b/Assets/Materials/UI/Instruction_04.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 35983630 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 59178524 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/Instruction_04.shmat.shmeta b/Assets/Materials/UI/Instruction_04.shmat.shmeta new file mode 100644 index 00000000..728abc0a --- /dev/null +++ b/Assets/Materials/UI/Instruction_04.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Instruction_04 +ID: 129768803 +Type: 7 diff --git a/Assets/Materials/UIMat.shmat b/Assets/Materials/UI/UIMat.shmat similarity index 75% rename from Assets/Materials/UIMat.shmat rename to Assets/Materials/UI/UIMat.shmat index 36c2f66c..b56d1bcb 100644 --- a/Assets/Materials/UIMat.shmat +++ b/Assets/Materials/UI/UIMat.shmat @@ -4,5 +4,5 @@ Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 51995224 - data.alpha: 0 + data.alpha: 1 data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UIMat.shmat.shmeta b/Assets/Materials/UI/UIMat.shmat.shmeta similarity index 100% rename from Assets/Materials/UIMat.shmat.shmeta rename to Assets/Materials/UI/UIMat.shmat.shmeta diff --git a/Assets/Materials/UIMat_LoseScene.shmat b/Assets/Materials/UI/UIMat_LoseScene.shmat similarity index 100% rename from Assets/Materials/UIMat_LoseScene.shmat rename to Assets/Materials/UI/UIMat_LoseScene.shmat diff --git a/Assets/Materials/UIMat_LoseScene.shmat.shmeta b/Assets/Materials/UI/UIMat_LoseScene.shmat.shmeta similarity index 100% rename from Assets/Materials/UIMat_LoseScene.shmat.shmeta rename to Assets/Materials/UI/UIMat_LoseScene.shmat.shmeta diff --git a/Assets/Materials/UIMat_MainMenu.shmat b/Assets/Materials/UI/UIMat_MainMenu.shmat similarity index 75% rename from Assets/Materials/UIMat_MainMenu.shmat rename to Assets/Materials/UI/UIMat_MainMenu.shmat index 0ca4c7a1..ba2069e9 100644 --- a/Assets/Materials/UIMat_MainMenu.shmat +++ b/Assets/Materials/UI/UIMat_MainMenu.shmat @@ -4,5 +4,5 @@ Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54429632 - data.alpha: 0 + data.alpha: 1 data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UIMat_MainMenu.shmat.shmeta b/Assets/Materials/UI/UIMat_MainMenu.shmat.shmeta similarity index 100% rename from Assets/Materials/UIMat_MainMenu.shmat.shmeta rename to Assets/Materials/UI/UIMat_MainMenu.shmat.shmeta diff --git a/Assets/Materials/UI/UIMat_Slider.shmat b/Assets/Materials/UI/UIMat_Slider.shmat new file mode 100644 index 00000000..fc28932a --- /dev/null +++ b/Assets/Materials/UI/UIMat_Slider.shmat @@ -0,0 +1,12 @@ +- VertexShader: 46580970 + FragmentShader: 48832081 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 64651793 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} + data.sliderThreshold: 1 + data.sliderStartColor: {x: 0, y: 1, z: 0, w: 1} + data.sliderEndColor: {x: 1, y: 0, z: 0, w: 1} + data.sliderBarColor: {x: 1, y: 1, z: 1, w: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/UIMat_Slider.shmat.shmeta b/Assets/Materials/UI/UIMat_Slider.shmat.shmeta new file mode 100644 index 00000000..6cd24549 --- /dev/null +++ b/Assets/Materials/UI/UIMat_Slider.shmat.shmeta @@ -0,0 +1,3 @@ +Name: UIMat_Slider +ID: 128676209 +Type: 7 diff --git a/Assets/Materials/UIMat_WinScene.shmat b/Assets/Materials/UI/UIMat_WinScene.shmat similarity index 75% rename from Assets/Materials/UIMat_WinScene.shmat rename to Assets/Materials/UI/UIMat_WinScene.shmat index e9c36f65..786b9b70 100644 --- a/Assets/Materials/UIMat_WinScene.shmat +++ b/Assets/Materials/UI/UIMat_WinScene.shmat @@ -4,5 +4,5 @@ Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 57302694 - data.alpha: 0 + data.alpha: 1 data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UIMat_WinScene.shmat.shmeta b/Assets/Materials/UI/UIMat_WinScene.shmat.shmeta similarity index 100% rename from Assets/Materials/UIMat_WinScene.shmat.shmeta rename to Assets/Materials/UI/UIMat_WinScene.shmat.shmeta diff --git a/Assets/Materials/UIMat_Slider_Textured.shmat b/Assets/Materials/UIMat_Slider_Textured.shmat new file mode 100644 index 00000000..cb09a99e --- /dev/null +++ b/Assets/Materials/UIMat_Slider_Textured.shmat @@ -0,0 +1,9 @@ +- VertexShader: 46580970 + FragmentShader: 43211183 + SubPass: UI + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 51995224 + data.alpha: 1 + data.beta: {x: 1, y: 1, z: 1} + data.sliderThreshold: 1 \ No newline at end of file diff --git a/Assets/Materials/UIMat_Slider_Textured.shmat.shmeta b/Assets/Materials/UIMat_Slider_Textured.shmat.shmeta new file mode 100644 index 00000000..99aec372 --- /dev/null +++ b/Assets/Materials/UIMat_Slider_Textured.shmat.shmeta @@ -0,0 +1,3 @@ +Name: UIMat_Slider_Textured +ID: 127128823 +Type: 7 diff --git a/Assets/Prefabs/====Raccoon====.shprefab b/Assets/Prefabs/====Raccoon====.shprefab new file mode 100644 index 00000000..59b42ef2 --- /dev/null +++ b/Assets/Prefabs/====Raccoon====.shprefab @@ -0,0 +1,147 @@ +- EID: 0 + PrefabID: 117058283 + Name: ====Raccoon==== + IsActive: true + NumberOfChildren: 2 + Components: ~ + Scripts: ~ +- EID: 1 + Name: Player + IsActive: true + NumberOfChildren: 3 + Components: + Transform Component: + Translate: {x: 2.35245037, y: 0.38365531, z: 7.10571432} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 0.999999881, y: 1, z: 0.999999881} + IsActive: true + Renderable Component: + Mesh: 149697411 + Material: 126974645 + IsActive: true + RigidBody Component: + Type: Dynamic + Drag: 0.00999999978 + Angular Drag: 0.100000001 + Use Gravity: false + Interpolate: false + Sleeping Enabled: true + Freeze Position X: false + Freeze Position Y: true + Freeze Position Z: false + Freeze Rotation X: true + Freeze Rotation Y: true + Freeze Rotation Z: true + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 0 + Type: Box + Half Extents: {x: 0.400000006, y: 0.5, z: 0.300000012} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0.25, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true + Scripts: + - Type: PlayerController + Enabled: true + respawnPoint: 239 + currentState: 0 + maxMoveVel: 3 + moveForce: 50 + sprintMultiplier: 1.5 + rotationFactorPerFrame: 5 + maxJumpHeight: 2 + maxJumpTime: 0.75 + fallMultipler: 3 + lightMultiper: 0.899999976 + mediumMultiper: 0.699999988 + heavyMultiper: 0.5 + - Type: PickAndThrow + Enabled: true + throwForce: [10, 8, 10] + cameraArmOffSet: [0.25, 0.600000024, 0.200000003] + delayTimer: 1 + aimingLength: 1 + throwItem: false + rayDistance: 0.75 + rayHeight: 0.100000001 +- EID: 2 + Name: HoldingPoint + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0.899999976, z: 0.200000286} + Rotate: {x: 0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ +- EID: 3 + Name: PlayerCamera + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -5.96046448e-08, z: 0} + Rotate: {x: 0, y: 6.28318548, z: 2.23517329e-08} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Camera Component: + Position: {x: 2.12735963, y: 0.362327784, z: 7.98933029} + Pitch: 0 + Yaw: 360 + Roll: 1.28065994e-06 + Width: 2560 + Near: 0.00999999978 + Far: 10000 + Perspective: true + FOV: 45 + IsActive: true + Camera Arm Component: + Arm Pitch: 0 + Arm Yaw: 0 + Arm Length: 3 + Look At Camera Origin: true + Target Offset: {x: 0, y: 0.75, z: 0} + Camera Collision: true + IsActive: true + Scripts: + - Type: SHADE_Scripting.ThirdPersonCamera + Enabled: true + armLength: 3 + turnSpeedPitch: 0.200000003 + turnSpeedYaw: 0.400000006 + pitchClamp: 45 + inverseXControls: false + inverseYControls: false + lowerClamp: 5 +- EID: 4 + Name: PlayerBag + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -2.98023224e-08, z: 4.76837158e-07} + Rotate: {x: 0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Renderable Component: + Mesh: 144838771 + Material: 123745521 + IsActive: true + Scripts: ~ +- EID: 5 + Name: RespawnPoint + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 2.5, y: 0.660660267, z: 7} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ \ No newline at end of file diff --git a/Assets/Prefabs/====Raccoon====.shprefab.shmeta b/Assets/Prefabs/====Raccoon====.shprefab.shmeta new file mode 100644 index 00000000..8fc77e7e --- /dev/null +++ b/Assets/Prefabs/====Raccoon====.shprefab.shmeta @@ -0,0 +1,3 @@ +Name: ====Raccoon==== +ID: 117058283 +Type: 6 diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 591c386f..4e58a29b 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -8540,6 +8540,7 @@ currCategory: 1 density: 1 dontReturn: false + soundDistance: 10 - EID: 157 Name: Mesh_Meat IsActive: true @@ -8587,6 +8588,7 @@ currCategory: 1 density: 1 dontReturn: false + soundDistance: 10 - EID: 156 Name: Mesh_Meat IsActive: true @@ -8599,7 +8601,7 @@ IsActive: true Renderable Component: Mesh: 136892700 - Material: 131956078 + Material: 122370915 IsActive: true RigidBody Component: Type: Dynamic @@ -8634,6 +8636,7 @@ currCategory: 1 density: 1 dontReturn: false + soundDistance: 10 - EID: 155 Name: Mesh_Cheese IsActive: true @@ -8681,6 +8684,7 @@ currCategory: 2 density: 1 dontReturn: false + soundDistance: 10 - EID: 154 Name: Mesh_Cheese IsActive: true @@ -8728,6 +8732,7 @@ currCategory: 2 density: 1 dontReturn: false + soundDistance: 10 - EID: 153 Name: Mesh_Cheese IsActive: true @@ -8775,6 +8780,7 @@ currCategory: 2 density: 1 dontReturn: false + soundDistance: 10 - EID: 65778 Name: Mesh_Apple IsActive: true @@ -8822,6 +8828,7 @@ currCategory: 0 density: 1 dontReturn: false + soundDistance: 10 - EID: 152 Name: Mesh_Apple IsActive: true @@ -8869,6 +8876,7 @@ currCategory: 0 density: 1 dontReturn: false + soundDistance: 10 - EID: 151 Name: Mesh_Apple IsActive: true @@ -8916,6 +8924,7 @@ currCategory: 0 density: 1 dontReturn: false + soundDistance: 10 - EID: 65686 Name: Watermelon IsActive: true @@ -8967,6 +8976,7 @@ currCategory: 2 density: 1 dontReturn: false + soundDistance: 10 - EID: 131220 Name: Piece1 IsActive: true @@ -9014,6 +9024,7 @@ currCategory: 1 density: 3 dontReturn: false + soundDistance: 10 - EID: 131219 Name: Piece2 IsActive: true @@ -9061,6 +9072,7 @@ currCategory: 1 density: 3 dontReturn: false + soundDistance: 10 - EID: 131221 Name: Piece3 IsActive: true @@ -9108,6 +9120,7 @@ currCategory: 0 density: 3 dontReturn: false + soundDistance: 10 - EID: 145 Name: Piece4 IsActive: true @@ -9155,6 +9168,7 @@ currCategory: 0 density: 3 dontReturn: false + soundDistance: 10 - EID: 196754 Name: Piece5 IsActive: true @@ -9202,6 +9216,7 @@ currCategory: 0 density: 3 dontReturn: false + soundDistance: 10 - EID: 144 Name: Egg IsActive: true @@ -9253,6 +9268,7 @@ currCategory: 0 density: 2 dontReturn: false + soundDistance: 10 - EID: 143 Name: Piece1 IsActive: true @@ -9575,24 +9591,14 @@ gamePauseText: 11 canvas: 10 - EID: 199 - Name: =====Text==== + Name: Gameplay UI Canvas IsActive: true NumberOfChildren: 4 - Components: ~ - Scripts: ~ -- EID: 237 - Name: Score - IsActive: true - NumberOfChildren: 0 Components: - Transform Component: - Translate: {x: -800, y: 400, z: 0} - Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 60, y: 60, z: 60} - IsActive: true - Text Renderer Component: - Text: My name is Brandon. - Font: 176667660 + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false IsActive: true Scripts: ~ - EID: 206 @@ -9609,6 +9615,11 @@ Text: My name is Brandon. Font: 176667660 IsActive: true + UI Component: + Canvas ID: 199 + Hovered: false + Clicked: false + IsActive: true Scripts: ~ - EID: 139 Name: Multiplier @@ -9624,6 +9635,11 @@ Text: TEST Font: 176667660 IsActive: true + UI Component: + Canvas ID: 199 + Hovered: false + Clicked: false + IsActive: true Scripts: ~ - EID: 11 Name: GamePause @@ -9639,6 +9655,51 @@ Text: Game Pause Font: 176667660 IsActive: false + UI Component: + Canvas ID: 199 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 462 + Name: Score BG + IsActive: true + NumberOfChildren: 1 + Components: + Transform Component: + Translate: {x: -850, y: 450, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 400, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + UI Component: + Canvas ID: 199 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 237 + Name: Score Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -0.050249815, y: -0.300000191, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 0.150000006, y: 0.600000024, z: 60} + IsActive: true + Text Renderer Component: + Text: My name is Brandon. + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 199 + Hovered: false + Clicked: false + IsActive: true Scripts: ~ - EID: 198 Name: ====Raccoon==== @@ -9653,7 +9714,7 @@ Components: Transform Component: Translate: {x: 2.35245037, y: 0.38365531, z: 7.10571432} - Rotate: {x: -0, y: 0, z: -0} + Rotate: {x: 0, y: 0.326376587, z: 0.0698131472} Scale: {x: 0.999999881, y: 1, z: 0.999999881} IsActive: true Renderable Component: @@ -9731,7 +9792,7 @@ Components: Transform Component: Translate: {x: 0, y: -5.96046448e-08, z: 0} - Rotate: {x: 0, y: 6.28318548, z: 2.23517329e-08} + Rotate: {x: 0, y: 5.95680904, z: -0.0698131248} Scale: {x: 1, y: 1, z: 1} IsActive: true Camera Component: @@ -9739,8 +9800,7 @@ Pitch: 0 Yaw: 360 Roll: 1.28065994e-06 - Width: 2560 - Height: 1369 + Width: 1055 Near: 0.00999999978 Far: 10000 Perspective: true @@ -10512,14 +10572,14 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 2.70000005, y: 0.100000001, z: -2} + Translate: {x: 0, y: 0, z: -2.64324665} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} - IsActive: false + IsActive: true Renderable Component: Mesh: 140697366 Material: 129495479 - IsActive: false + IsActive: true RigidBody Component: Type: Dynamic Drag: 0.00999999978 @@ -10533,7 +10593,7 @@ Freeze Rotation X: true Freeze Rotation Y: false Freeze Rotation Z: true - IsActive: false + IsActive: true Collider Component: Colliders: - Is Trigger: false @@ -10545,7 +10605,7 @@ Density: 1 Position Offset: {x: 0, y: 0.899999976, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} - IsActive: false + IsActive: true Scripts: - Type: Homeowner1 Enabled: true @@ -10605,6 +10665,7 @@ currCategory: 1 density: 1 dontReturn: false + soundDistance: 10 - EID: 16 Name: JumpPad IsActive: false @@ -10632,13 +10693,14 @@ Enabled: true - EID: 10 Name: Canvas - IsActive: false + IsActive: true NumberOfChildren: 3 Components: Canvas Component: Canvas Width: 1920 Canvas Height: 1080 - IsActive: false + Scale by canvas width: false + IsActive: true Scripts: ~ - EID: 8 Name: ResumeButton @@ -10661,6 +10723,8 @@ IsActive: true UI Component: Canvas ID: 10 + Hovered: false + Clicked: false IsActive: true Scripts: ~ - EID: 0 @@ -10684,6 +10748,8 @@ IsActive: true UI Component: Canvas ID: 10 + Hovered: false + Clicked: false IsActive: true Scripts: ~ - EID: 461 @@ -10707,5 +10773,7 @@ IsActive: true UI Component: Canvas ID: 10 + Hovered: false + Clicked: false IsActive: true Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/MainMenu.shade b/Assets/Scenes/MainMenu.shade index 30ef368a..17fb1a8e 100644 --- a/Assets/Scenes/MainMenu.shade +++ b/Assets/Scenes/MainMenu.shade @@ -1,7 +1,7 @@ - EID: 0 - Name: Canvas + Name: Main Menu Canvas IsActive: true - NumberOfChildren: 3 + NumberOfChildren: 8 Components: Canvas Component: Canvas Width: 1920 @@ -10,18 +10,18 @@ IsActive: true Scripts: ~ - EID: 1 - Name: Background + Name: BackGround IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 0, z: 0} + Translate: {x: 0, y: 0, z: 0.5} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 1920, y: 1080, z: 1} IsActive: true Renderable Component: Mesh: 141771688 - Material: 121834459 + Material: 129138332 IsActive: true UI Component: Canvas ID: 0 @@ -35,9 +35,9 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 75, z: 0} + Translate: {x: -700, y: 100, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 400, y: 200, z: 1} + Scale: {x: 450, y: 100, z: 1} IsActive: true Renderable Component: Mesh: 141771688 @@ -57,15 +57,23 @@ - Type: ChangeSceneButton Enabled: true sceneID: 96668835 + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: "event:/Music/player_undetected\x00���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������" + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 - EID: 6 Name: Quit Game Button IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: -200, z: 0} + Translate: {x: -700, y: -400, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 400, y: 200, z: 1} + Scale: {x: 450, y: 100, z: 1} IsActive: true Renderable Component: Mesh: 141771688 @@ -84,6 +92,183 @@ Scripts: - Type: QuitButton Enabled: true + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: event:/Music/player_undetected + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 +- EID: 7 + Name: Level Select Button + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -700, y: 0, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 450, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 52901020 + Hovered Texture: 62235279 + Clicked Texture: 64722619 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: event:/Music/player_undetected + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 50 +- EID: 9 + Name: How To Play Button + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -700, y: -100, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 450, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 65084899 + Hovered Texture: 58647112 + Clicked Texture: 55758383 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: event:/Music/player_undetected + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 13 +- EID: 10 + Name: Credits Button + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -700, y: -200, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 450, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 52901020 + Hovered Texture: 62235279 + Clicked Texture: 64722619 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: event:/Music/player_undetected + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 46 +- EID: 11 + Name: Options Button + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -700, y: -300, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 450, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 52901020 + Hovered Texture: 62235279 + Clicked Texture: 64722619 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/Music/player_undetected + onHoverExitSound: event:/Music/player_undetected + onClickSound: event:/Music/player_undetected + onReleaseSound: event:/Music/player_undetected + hoverScale: 1.10000002 + clickScale: 0.899999976 + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 19 +- EID: 12 + Name: Game Icon + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -700, y: 350, z: 0.300000012} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 355.756439, y: 355.756439, z: 1.18585491} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 126117259 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ScaleBounce + Enabled: true + minScale: 1 + maxScale: 1.20000005 + duration: 1.5 - EID: 2 Name: Light IsActive: true @@ -113,8 +298,7 @@ Pitch: 0 Yaw: 0 Roll: 0 - Width: 1319 - Height: 622 + Width: 1175 Near: 0.00999999978 Far: 10000 Perspective: true @@ -129,4 +313,870 @@ Scripts: - Type: MainMenu Enabled: true - sceneID: 96668835 \ No newline at end of file + sceneID: 96668835 + obj: 1 +- EID: 8 + Name: TweenManager + IsActive: true + NumberOfChildren: 0 + Components: ~ + Scripts: + - Type: SHADE_Scripting.UI.TweenManager + Enabled: true +- EID: 13 + Name: How To Play Canvas + IsActive: false + NumberOfChildren: 5 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: ~ +- EID: 14 + Name: BackGround + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: true + UI Component: + Canvas ID: 13 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 15 + Name: Instruction Image + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1344, y: 756, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 124926341 + IsActive: true + UI Component: + Canvas ID: 13 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.MultiImageList + Enabled: true + imageAssetList: + - 124926341 + - 128721520 + - 124482180 + - 129768803 +- EID: 16 + Name: NextButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 800, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 13 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.MultiImageListControlButton + Enabled: true + isNext: true + multiImageList: 15 +- EID: 17 + Name: PrevButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -800, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 13 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.MultiImageListControlButton + Enabled: true + isNext: false + multiImageList: 15 +- EID: 18 + Name: BackButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -800, y: 450, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 13 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 0 +- EID: 19 + Name: Options Canvas + IsActive: false + NumberOfChildren: 11 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: ~ +- EID: 20 + Name: BackGround + IsActive: false + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 1} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: false + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: false + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: false + Scripts: ~ +- EID: 21 + Name: BackButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -800, y: 450, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 0 +- EID: 22 + Name: Options Title Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -150, y: 400, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Text Renderer Component: + Text: Options + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 23 + Name: Audio Title Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -900, y: 300, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Text Renderer Component: + Text: Audio + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 25 + Name: Audio Text Group + IsActive: true + NumberOfChildren: 3 + Components: + Transform Component: + Translate: {x: -900, y: 200, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 24 + Name: Master Volume Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: Master + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 26 + Name: SFX Volume Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: SFX + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 27 + Name: BGM Volume Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -200, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: BGM + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 28 + Name: Audio Slider Group + IsActive: true + NumberOfChildren: 3 + Components: + Transform Component: + Translate: {x: 100, y: 225, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 29 + Name: Master Volume Slider + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1000, y: 75, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 128676209 + IsActive: true + Slider Component: + Slider Value: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 30 + Name: SFX Volume Slider + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1000, y: 75, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 128676209 + IsActive: true + Slider Component: + Slider Value: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 31 + Name: BGM Volume Slider + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -200, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1000, y: 75, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 128676209 + IsActive: true + Slider Component: + Slider Value: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 32 + Name: Camera Title Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -900, y: -120, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Text Renderer Component: + Text: Camera + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 33 + Name: Camera Text Group + IsActive: true + NumberOfChildren: 2 + Components: + Transform Component: + Translate: {x: -900, y: -220, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 34 + Name: FOV Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: FOV + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 35 + Name: Sensitivity Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: Sensitivity + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 36 + Name: Camera Slider Group + IsActive: true + NumberOfChildren: 2 + Components: + Transform Component: + Translate: {x: 100, y: -200, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 37 + Name: FOV Slider + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1000, y: 75, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 128676209 + IsActive: true + Slider Component: + Slider Value: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 38 + Name: Sensitivity Slider + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1000, y: 75, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 128676209 + IsActive: true + Slider Component: + Slider Value: 0 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 39 + Name: Audio Slider Text Group + IsActive: true + NumberOfChildren: 3 + Components: + Transform Component: + Translate: {x: 700, y: 200, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 40 + Name: Master Volume Slider Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: 100 + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SliderText + Enabled: true + sliderObj: 29 + minValue: 0 + maxValue: 100 +- EID: 41 + Name: SFX Volume Slider Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: 100 + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SliderText + Enabled: true + sliderObj: 30 + minValue: 0 + maxValue: 100 +- EID: 42 + Name: BGM Volume Slider Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -200, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: 100 + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SliderText + Enabled: true + sliderObj: 31 + minValue: 0 + maxValue: 100 +- EID: 43 + Name: Camera Slider Text Group + IsActive: true + NumberOfChildren: 2 + Components: + Transform Component: + Translate: {x: 700, y: -225, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 44 + Name: FOV Slider Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: 100 + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SliderText + Enabled: true + sliderObj: 37 + minValue: 0 + maxValue: 100 +- EID: 45 + Name: Sensitivity Slider Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -100, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 75, y: 75, z: 1} + IsActive: true + Text Renderer Component: + Text: 100 + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 19 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SliderText + Enabled: true + sliderObj: 38 + minValue: 0 + maxValue: 100 +- EID: 46 + Name: Credits Canvas + IsActive: false + NumberOfChildren: 3 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: ~ +- EID: 47 + Name: BackGround + IsActive: false + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 1} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: false + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: false + UI Component: + Canvas ID: 46 + Hovered: false + Clicked: false + IsActive: false + Scripts: ~ +- EID: 48 + Name: BackButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -800, y: 450, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 46 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 0 +- EID: 49 + Name: Credits Title Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -150, y: 400, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Text Renderer Component: + Text: Credits + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 46 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 50 + Name: Level Select Canvas + IsActive: false + NumberOfChildren: 3 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: ~ +- EID: 51 + Name: BackGround + IsActive: false + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 1} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: false + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: false + UI Component: + Canvas ID: 50 + Hovered: false + Clicked: false + IsActive: false + Scripts: ~ +- EID: 52 + Name: BackButton + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -800, y: 450, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 0 + Hovered Texture: 0 + Clicked Texture: 0 + IsActive: true + UI Component: + Canvas ID: 50 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ChangeCanvasButton + Enabled: true + canvasToActivate: 0 +- EID: 53 + Name: Level Select Title Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -150, y: 400, z: -0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 100, y: 100, z: 1} + IsActive: true + Text Renderer Component: + Text: Level Select + Font: 176667660 + IsActive: true + UI Component: + Canvas ID: 50 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/WinScene.shade b/Assets/Scenes/WinScene.shade index 3edd223b..0727860e 100644 --- a/Assets/Scenes/WinScene.shade +++ b/Assets/Scenes/WinScene.shade @@ -111,6 +111,7 @@ Near: 0.00999999978 Far: 10000 Perspective: true + FOV: 90 IsActive: true Scripts: ~ - EID: 4 diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/Homeowner1.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/Homeowner1.cs index 84c7c485..e37aab36 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/Homeowner1.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/Homeowner1.cs @@ -74,6 +74,9 @@ public partial class Homeowner1 : BehaviourTree private float footstepSFXIntervalMultiplier; private float footstepTimeRemaining; + + //singleton for AI + public static Homeowner1 aiInstance { get; private set; } } //AI tree @@ -111,6 +114,11 @@ public partial class Homeowner1 : BehaviourTree AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps"); AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon"); AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected"); + + if (aiInstance != null && aiInstance != this) + RemoveScript(); + else + aiInstance = this; } //Called every tick @@ -182,4 +190,10 @@ public partial class Homeowner1 : BehaviourTree //Debug.Log("Tree Created"); return root; } + + protected override void onDestroy() + { + if (aiInstance == this) + aiInstance = null; + } } \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Item/SC_Item.cs b/Assets/Scripts/Gameplay/Item/SC_Item.cs index 1109f8f3..e4c264be 100644 --- a/Assets/Scripts/Gameplay/Item/SC_Item.cs +++ b/Assets/Scripts/Gameplay/Item/SC_Item.cs @@ -22,6 +22,10 @@ public class Item : Script private Collider collider; public float density = 1.0f; public bool dontReturn = false; + + + private bool checkSound = false; + public float soundDistance = 10; protected override void awake() @@ -55,10 +59,25 @@ public class Item : Script returnBack = false; } + + + if (checkSound) + { +/* //need to wait for collisionEnter Fix + Vector3 itemPos = transform.LocalPosition; + Vector3 len = Homeowner1.aiInstance.GetComponent().LocalPosition - itemPos; + Debug.Log($"distance: {len.GetSqrMagnitude()}"); + if (len.GetSqrMagnitude() <= soundDistance) + { + //set ai to alert + } + checkSound = false;*/ + } } protected override void onCollisionEnter(CollisionInfo info) { + if (!caputurePos) { firstPostion = transform.LocalPosition; @@ -83,6 +102,7 @@ public class Item : Script protected override void onCollisionExit(CollisionInfo info) { playSound = true; + checkSound = true; } } \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index d5046db1..4132edca 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -26,6 +26,7 @@ public class PickAndThrow : Script private float lastZDir; private bool inRange = false; public bool throwItem = false; + private Vector3 prevTargetOffSet; [Tooltip("Lenght of ray")] public float rayDistance = 1; @@ -56,8 +57,12 @@ public class PickAndThrow : Script } protected override void update() { + if (GameManager.Instance.GamePause) + { + return; + } - if(timer <= delayTimer) + if (timer <= delayTimer) timer += Time.DeltaTimeF; CalculateDir(); @@ -76,6 +81,7 @@ public class PickAndThrow : Script { pc.isAiming = true; pc.camArm.ArmLength = aimingLength; + prevTargetOffSet = pc.camArm.TargetOffset; pc.camArm.TargetOffset = cameraArmOffSet; pc.cam.FOV = aimingFOV; } @@ -86,7 +92,7 @@ public class PickAndThrow : Script itemRidigBody.IsGravityEnabled = true; itemCollider.GetCollisionShape(0).IsTrigger = false; pc.isAiming = false; - pc.camArm.TargetOffset = Vector3.Zero; + pc.camArm.TargetOffset = prevTargetOffSet; pc.cam.FOV = defaultFOV; if (tpc) pc.camArm.ArmLength = tpc.armLength; @@ -109,7 +115,7 @@ public class PickAndThrow : Script { pc.isAiming = false; pc.cam.FOV = defaultFOV; - pc.camArm.TargetOffset = Vector3.Zero; + pc.camArm.TargetOffset = prevTargetOffSet; if (tpc) pc.camArm.ArmLength = tpc.armLength; } @@ -134,6 +140,11 @@ public class PickAndThrow : Script protected override void fixedUpdate() { + if (GameManager.Instance.GamePause) + { + return; + } + if (throwItem && itemRidigBody && pc) { if (itemScript) diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index 202e587e..87e42032 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -124,8 +124,14 @@ public class PlayerController : Script protected override void lateUpdate() { } + protected override void update() { + if (GameManager.Instance.GamePause) + { + return; + } + if (delayTimer <= 1) delayTimer += Time.DeltaTimeF; @@ -158,22 +164,27 @@ public class PlayerController : Script if (tranform) tranform.LocalEulerAngles = new Vector3(0.0f, tranform.LocalEulerAngles.y, 0.0f); + GotCaught(); Rotation(); MoveKey(); Sprint(); Jump(); - GotCaught(); //Debug.Log($"{currentState}"); //Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}"); //Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}"); //Debug.Log(currentState.ToString() + " x:" + rb.LinearVelocity.x.ToString() + " y:" + rb.LinearVelocity.y.ToString() + " z:" + rb.LinearVelocity.z.ToString()); + } protected override void fixedUpdate() { + if (GameManager.Instance.GamePause) + { + return; + } + Move(); Gravity(); - //Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}"); } @@ -234,7 +245,7 @@ public class PlayerController : Script private void Move() { - if (rb != null) + if (rb != null && currentState != RaccoonStates.CAUGHT) { rb.LinearVelocity += new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce) * Time.DeltaTimeF; @@ -286,7 +297,6 @@ public class PlayerController : Script } } - //press and hold jump private void Jump() { if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE) diff --git a/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs b/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs index c3026ce6..f339122e 100644 --- a/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs +++ b/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs @@ -41,6 +41,11 @@ namespace SHADE_Scripting protected override void update() { + if (GameManager.Instance.GamePause) + { + return; + } + CameraArm arm = GetComponent(); if (arm) { diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 6478b5ea..3657904b 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -38,13 +38,11 @@ public class GameManager : Script private Vector3 fontScalar; public static GameManager Instance { get; private set; } - //public static int highScore { get; private set; } maybe need public bool GamePause { get; set; } protected override void start() { - base.start(); AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive"); AudioHandler.audioClipHandlers["BGMAdaptive"].Play(); diff --git a/Assets/Scripts/SC_JumpPad.cs b/Assets/Scripts/Gameplay/SC_JumpPad.cs similarity index 100% rename from Assets/Scripts/SC_JumpPad.cs rename to Assets/Scripts/Gameplay/SC_JumpPad.cs diff --git a/Assets/Scripts/Gameplay/SC_JumpPad.cs.shmeta b/Assets/Scripts/Gameplay/SC_JumpPad.cs.shmeta new file mode 100644 index 00000000..c84294b0 --- /dev/null +++ b/Assets/Scripts/Gameplay/SC_JumpPad.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_JumpPad +ID: 163951275 +Type: 9 diff --git a/Assets/Scripts/UI/EasingHelper.cs b/Assets/Scripts/UI/EasingHelper.cs new file mode 100644 index 00000000..5f8ce4fe --- /dev/null +++ b/Assets/Scripts/UI/EasingHelper.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + + public enum EASING_METHOD + { + EASE_IN_SINE, + EASE_OUT_SINE, + EASE_OUT_BOUNCE, + EASE_IN_BOUNCE, + EASE_INOUT_BOUNCE + } + + public static class EasingHelper + { + + public static float EaseHelp(float value, EASING_METHOD method) + { + switch (method) + { + case EASING_METHOD.EASE_IN_SINE: + { + return EaseInSine(value); + }break; + case EASING_METHOD.EASE_OUT_SINE: + { + return EaseOutSine(value); + }break; + case EASING_METHOD.EASE_OUT_BOUNCE: + { + return EaseOutBounce(value); + }break; + case EASING_METHOD.EASE_IN_BOUNCE: + { + return EaseInBounce(value); + } + break; + case EASING_METHOD.EASE_INOUT_BOUNCE: + { + return EaseInOutBounce(value); + } + break; + default: + return 0.0f; + } + } + + private static float EaseInSine(float value) + { + return (float)(1.0f - Math.Cos((value * Math.PI) / 2.0f)); + } + + private static float EaseOutSine(float value) + { + return (float)(1.0f - Math.Sin(value * Math.PI) / 2.0f); + } + + + private static float EaseOutBounce(float value) + { + const float n1 = 7.5625f; + const float d1 = 2.75f; + if (value < 1.0f / d1) + { + return n1 * value * value; + } else if (value < 2.0f / d1) + { + return n1 * (value -= 2.25f / d1) * value + 0.9375f; + } + else + { + return n1 * (value -= 2.625f / d1) * value + 0.984375f; + + } + } + + private static float EaseInBounce(float value) + { + return 1 - EaseOutBounce(1 - value); + } + + + private static float EaseInOutBounce(float value) + { + return (value < 0.5f) + ?(1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f + : (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f; + } + + } +} diff --git a/Assets/Scripts/UI/EasingHelper.cs.shmeta b/Assets/Scripts/UI/EasingHelper.cs.shmeta new file mode 100644 index 00000000..cd4c2aa3 --- /dev/null +++ b/Assets/Scripts/UI/EasingHelper.cs.shmeta @@ -0,0 +1,3 @@ +Name: EasingHelper +ID: 161000975 +Type: 9 diff --git a/Assets/Scripts/UI/SC_ButtonFX.cs b/Assets/Scripts/UI/SC_ButtonFX.cs new file mode 100644 index 00000000..0e490a35 --- /dev/null +++ b/Assets/Scripts/UI/SC_ButtonFX.cs @@ -0,0 +1,123 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class ButtonFX:Script + { + public string onHoverEnterSound = "event:/Music/player_undetected"; + public string onHoverExitSound = "event:/Music/player_undetected"; + public string onClickSound = "event:/Music/player_undetected"; + public string onReleaseSound = "event:/Music/player_undetected"; + + [NonSerialized] + private AudioClipHandler onHoverEnterACHandler; + [NonSerialized] + private AudioClipHandler onHoverExitACHandler; + [NonSerialized] + private AudioClipHandler onClickACHandler; + [NonSerialized] + private AudioClipHandler onReleaseACHandler; + + [NonSerialized] + private Vector3 defaultScale; + + public float hoverScale = 1.1f; + public float clickScale = 0.9f; + + + [NonSerialized] + private TweenThread thread; + + [NonSerialized] + private bool tweening = false; + [NonSerialized] + private float currentScale = 1.0f; + + protected override void awake() + { + onHoverEnterACHandler = SHADE.Audio.CreateAudioClip(onHoverEnterSound); + onHoverExitACHandler = SHADE.Audio.CreateAudioClip(onHoverExitSound); + onClickACHandler = SHADE.Audio.CreateAudioClip(onClickSound); + onReleaseACHandler = SHADE.Audio.CreateAudioClip(onReleaseSound); + + + + } + + protected override void start() + { + thread = TweenManager.CreateTweenThread(0.1f, 0.9f, 1.0f, EASING_METHOD.EASE_IN_SINE); + + + Transform transform = GetComponent(); + if (transform == null) + return; + defaultScale = transform.LocalScale; + + + UIElement ui = GetComponent(); + if (ui == null) + return; + + + ui.OnClick.RegisterAction(() => + { + if (onClickSound != "") + onClickACHandler.Play(); + tweening = true; + if(thread != null) + thread.Reset(currentScale,clickScale); + }); + + ui.OnRelease.RegisterAction(() => + { + if (onReleaseSound != "") + onReleaseACHandler.Play(); + tweening = true; + if (thread != null) + thread.Reset(currentScale, 1.0f); + }); + + ui.OnHoverEnter.RegisterAction(() => + { + if (onHoverEnterSound != "") + onHoverEnterACHandler.Play(); + tweening = true; + if (thread != null) + thread.Reset(currentScale, hoverScale); + }); + + ui.OnHoverExit.RegisterAction(() => + { + if (onHoverExitSound != "") + onHoverExitACHandler.Play(); + tweening = true; + if (thread != null) + thread.Reset(currentScale, 1.0f); + }); + + } + + protected override void update() + { + Transform transform = GetComponent(); + if (transform == null) + return; + if (tweening == true && thread != null) + { + Debug.Log("Tweening value " + thread.GetValue()); + transform.LocalScale = defaultScale * thread.GetValue(); + currentScale = thread.GetValue(); + if (thread.IsCompleted()) + tweening = false; + } + } + + + } +} diff --git a/Assets/Scripts/UI/SC_ButtonFX.cs.shmeta b/Assets/Scripts/UI/SC_ButtonFX.cs.shmeta new file mode 100644 index 00000000..73e3c1c2 --- /dev/null +++ b/Assets/Scripts/UI/SC_ButtonFX.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_ButtonFX +ID: 163796084 +Type: 9 diff --git a/Assets/Scripts/UI/SC_ChangeCanvasButton.cs b/Assets/Scripts/UI/SC_ChangeCanvasButton.cs new file mode 100644 index 00000000..2c8a5df4 --- /dev/null +++ b/Assets/Scripts/UI/SC_ChangeCanvasButton.cs @@ -0,0 +1,42 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class ChangeCanvasButton:Script + { + + public GameObject canvasToActivate; + + protected override void awake() + { + //if (canvasToActivate.GetComponent() == null) + // return; + UIElement ui = GetComponent(); + ui.OnRelease.RegisterAction(() => + { + Canvas.DeactivateAllCanvas(); + + canvasToActivate.SetActive(true); + + }); + } + + protected override void start() + { + + + } + + protected override void update() + { + + } + + + } +} diff --git a/Assets/Scripts/UI/SC_ChangeCanvasButton.cs.shmeta b/Assets/Scripts/UI/SC_ChangeCanvasButton.cs.shmeta new file mode 100644 index 00000000..e817ba9d --- /dev/null +++ b/Assets/Scripts/UI/SC_ChangeCanvasButton.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_ChangeCanvasButton +ID: 154633292 +Type: 9 diff --git a/Assets/Scripts/UI/SC_ChangeSceneButton.cs b/Assets/Scripts/UI/SC_ChangeSceneButton.cs index 6caba2b1..c0629d0a 100644 --- a/Assets/Scripts/UI/SC_ChangeSceneButton.cs +++ b/Assets/Scripts/UI/SC_ChangeSceneButton.cs @@ -11,8 +11,9 @@ public class ChangeSceneButton : Script UIElement ui = GetComponent(); if (ui != null) { - ui.OnClick.RegisterAction(() => + ui.OnRelease.RegisterAction(() => { + if (sceneID != 0) { Audio.PlaySFXOnce2D("event:/UI/success"); @@ -24,6 +25,7 @@ public class ChangeSceneButton : Script else { Debug.LogError("Failed to register button action for ChangeSceneButton."); + } } protected override void update() diff --git a/Assets/Scripts/UI/SC_MainMenu.cs b/Assets/Scripts/UI/SC_MainMenu.cs index 8af27d64..8c887d3c 100644 --- a/Assets/Scripts/UI/SC_MainMenu.cs +++ b/Assets/Scripts/UI/SC_MainMenu.cs @@ -5,6 +5,10 @@ using SHADE_Scripting.Audio; public class MainMenu : Script { public uint sceneID; + + public GameObject obj; + private Renderable renderable; + protected override void awake() { AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu"); @@ -12,9 +16,31 @@ public class MainMenu : Script AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success"); //Audio.PlayBGMOnce2D("event:/Music/main_menu"); AudioHandler.audioClipHandlers["BGMMainMenu"].Play(); + + renderable = obj.GetComponent(); + } + + protected override void start() + { } protected override void update() { + if (Input.GetKeyDown(Input.KeyCode.K) && obj) + { + if (renderable.Material.GetProperty("data.alpha") == 1) + { + Debug.Log("ALPHA ZERO"); + Debug.Log($"{obj.EntityId}"); + obj.GetComponent().Material.SetProperty("data.alpha", 0); + } + else if (renderable.Material.GetProperty("data.alpha") == 0) + { + Debug.Log("ALPHA ONE"); + Debug.Log($"{obj.EntityId}"); + obj.GetComponent().Material.SetProperty("data.alpha", 1); + } + } + if (Input.GetKeyDown(Input.KeyCode.Space)) { //Audio.PlaySFXOnce2D("event:/UI/mouse_down_element"); diff --git a/Assets/Scripts/UI/SC_MultiImageList.cs b/Assets/Scripts/UI/SC_MultiImageList.cs new file mode 100644 index 00000000..d6f2379c --- /dev/null +++ b/Assets/Scripts/UI/SC_MultiImageList.cs @@ -0,0 +1,51 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class MultiImageList:Script + { + public List imageAssetList = new List(); + [NonSerialized] + private int index = 0; + + + protected override void awake() + { + } + + protected override void start() + { + + } + + public void NextImage() + { + ++index; + if(index >= imageAssetList.Count()) + { + index = 0; + } + + Renderable rend = GetComponent(); + rend.SetMaterial(imageAssetList[index]); + + } + + public void PrevImage() + { + if (index == 0) + index = imageAssetList.Count(); + --index; + + Renderable rend = GetComponent(); + rend.SetMaterial(imageAssetList[index]); + } + + + } +} diff --git a/Assets/Scripts/UI/SC_MultiImageList.cs.shmeta b/Assets/Scripts/UI/SC_MultiImageList.cs.shmeta new file mode 100644 index 00000000..ec795cba --- /dev/null +++ b/Assets/Scripts/UI/SC_MultiImageList.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_MultiImageList +ID: 166320642 +Type: 9 diff --git a/Assets/Scripts/UI/SC_MultiImageListControlButton.cs b/Assets/Scripts/UI/SC_MultiImageListControlButton.cs new file mode 100644 index 00000000..4ec50dd4 --- /dev/null +++ b/Assets/Scripts/UI/SC_MultiImageListControlButton.cs @@ -0,0 +1,40 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class MultiImageListControlButton: Script + { + public bool isNext = true; + public GameObject multiImageList; + + protected override void awake() + { + + UIElement ui = GetComponent(); + if (ui != null) + { + ui.OnRelease.RegisterAction(() => + { + + MultiImageList imageList = multiImageList.GetScript(); + if(imageList != null) + { + + if (isNext) + imageList.NextImage(); + else + imageList.PrevImage(); + + } + + }); + } + } + + } +} diff --git a/Assets/Scripts/UI/SC_MultiImageListControlButton.cs.shmeta b/Assets/Scripts/UI/SC_MultiImageListControlButton.cs.shmeta new file mode 100644 index 00000000..5096e110 --- /dev/null +++ b/Assets/Scripts/UI/SC_MultiImageListControlButton.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_MultiImageListControlButton +ID: 164209885 +Type: 9 diff --git a/Assets/Scripts/UI/SC_PauseMenu.cs b/Assets/Scripts/UI/SC_PauseMenu.cs index eae7aa91..521b48ea 100644 --- a/Assets/Scripts/UI/SC_PauseMenu.cs +++ b/Assets/Scripts/UI/SC_PauseMenu.cs @@ -59,8 +59,7 @@ public class PauseMenu : Script retry.OnClick.RegisterAction(() => { Audio.StopAllSounds(); - //get curr scene - //SceneManager.ChangeScene(); + SceneManager.RestartScene(); }); } else @@ -86,10 +85,6 @@ public class PauseMenu : Script protected override void update() { - if (GameManager.Instance.GamePause) - { - return; - } if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause) { diff --git a/Assets/Scripts/UI/SC_ScaleBounce.cs b/Assets/Scripts/UI/SC_ScaleBounce.cs new file mode 100644 index 00000000..0d5ca381 --- /dev/null +++ b/Assets/Scripts/UI/SC_ScaleBounce.cs @@ -0,0 +1,47 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class ScaleBounce:Script + { + [NonSerialized] + private TweenThread thread; + + public float minScale = 1.0f; + public float maxScale = 1.2f; + public float duration = 1.0f; + + private Vector3 defaultScale; + + + protected override void start() + { + thread = TweenManager.CreateTweenThread(duration, minScale, maxScale, EASING_METHOD.EASE_IN_SINE); + Transform trans = GetComponent(); + if(trans != null) + { + defaultScale = trans.LocalScale; + } + } + + protected override void update() + { + Transform trans = GetComponent(); + if(trans != null) + { + trans.LocalScale = defaultScale * thread.GetValue(); + } + if(thread.IsCompleted()) + { + thread.ResetInvert(); + } + } + + + } +} diff --git a/Assets/Scripts/UI/SC_ScaleBounce.cs.shmeta b/Assets/Scripts/UI/SC_ScaleBounce.cs.shmeta new file mode 100644 index 00000000..04ea3afb --- /dev/null +++ b/Assets/Scripts/UI/SC_ScaleBounce.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_ScaleBounce +ID: 152015842 +Type: 9 diff --git a/Assets/Scripts/UI/SC_SliderText.cs b/Assets/Scripts/UI/SC_SliderText.cs new file mode 100644 index 00000000..54d59f28 --- /dev/null +++ b/Assets/Scripts/UI/SC_SliderText.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class SliderText:Script + { + public GameObject sliderObj; + + public int minValue = 0; + public int maxValue = 0; + + + protected override void update() + { + Slider slider = sliderObj.GetComponent(); + TextRenderable text = GetComponent(); + if(slider != null && text != null) + { + + text.Text = ((int)(slider.GetValue() * (maxValue - minValue) + minValue)).ToString(); + } + } + + + } +} diff --git a/Assets/Scripts/UI/SC_SliderText.cs.shmeta b/Assets/Scripts/UI/SC_SliderText.cs.shmeta new file mode 100644 index 00000000..298bd246 --- /dev/null +++ b/Assets/Scripts/UI/SC_SliderText.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_SliderText +ID: 158412308 +Type: 9 diff --git a/Assets/Scripts/UI/SC_TweenManager.cs b/Assets/Scripts/UI/SC_TweenManager.cs new file mode 100644 index 00000000..bbcc8c8f --- /dev/null +++ b/Assets/Scripts/UI/SC_TweenManager.cs @@ -0,0 +1,120 @@ +using SHADE; +using SHADE_Scripting.Audio; +using System; +using System.Collections.Generic; +using System.Threading; + + +namespace SHADE_Scripting.UI +{ + + public class TweenThread + { + private float timer = 0.0f; + public float duration = 1.0f; + public EASING_METHOD method; + private float value = 0.0f; + public float startValue = 0.0f; + public float endValue = 1.0f; + + + public TweenThread(float duration, float startValue, float endValue, EASING_METHOD method) + { + this.duration = duration; + this.method = method; + this.startValue = startValue; + this.endValue = endValue; + } + + public void Update(float deltaTime) + { + if (timer > duration) + return; + timer += deltaTime; + if (timer > duration) + timer = duration; + + value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ; + } + + public bool IsCompleted() + { + return timer >= duration; + } + + public void Reset() + { + timer = 0.0f; + value = startValue; + } + public void Reset(float startValue, float endValue) + { + Reset(); + this.startValue = startValue; + this.endValue = endValue; + } + public void ResetInvert() + { + Reset(); + float temp = startValue; + startValue = endValue; + endValue = temp; + } + + + public float GetValue() + { + return value; + } + + } + + public class TweenManager : Script + { + public static TweenManager Instance { get; private set; } + + [NonSerialized] + private List threadList; + + protected override void awake() + { + if (Instance != null && Instance != this) + RemoveScript(); + else + Instance = this; + + threadList = new List(); + + } + + protected override void onDestroy() + { + if (Instance == this) + Instance = null; + + } + + protected override void update() + { + + foreach (TweenThread thread in threadList) + { + thread.Update(Time.DeltaTimeF); + } + } + + + public static TweenThread CreateTweenThread(float duration, float startValue, float endValue, EASING_METHOD method) + { + if (Instance == null) + return null; + + + TweenThread thread = new TweenThread(duration, startValue, endValue, method); + Instance.threadList.Add(thread); + thread.Reset(); + return thread; + } + + } +} diff --git a/Assets/Scripts/UI/SC_TweenManager.cs.shmeta b/Assets/Scripts/UI/SC_TweenManager.cs.shmeta new file mode 100644 index 00000000..286387c3 --- /dev/null +++ b/Assets/Scripts/UI/SC_TweenManager.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_TweenManager +ID: 164072799 +Type: 9 diff --git a/Assets/Shaders/DeferredComposite_CS.glsl b/Assets/Shaders/DeferredComposite_CS.glsl index 745b93e0..f17c9d84 100644 --- a/Assets/Shaders/DeferredComposite_CS.glsl +++ b/Assets/Shaders/DeferredComposite_CS.glsl @@ -26,6 +26,7 @@ layout(set = 3, binding = 3, r32ui) uniform uimage2D lightLayerData; layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage; layout(set = 3, binding = 5, rgba8) uniform image2D positionWorldSpace; layout(set = 3, binding = 6, rgba8) uniform image2D targetImage; +layout(set = 3, binding = 7, rgba8) uniform image2D objectVFXImage; layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global) @@ -141,6 +142,9 @@ void main() float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r; fragColor *= ssaoVal; + vec4 objectVFXColor = imageLoad (objectVFXImage, globalThread); + fragColor += objectVFXColor.rgb * objectVFXColor.a; + // store result into result image imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f)); diff --git a/Assets/Shaders/DeferredComposite_CS.shshaderb b/Assets/Shaders/DeferredComposite_CS.shshaderb index ff474e27..e5a0a730 100644 Binary files a/Assets/Shaders/DeferredComposite_CS.shshaderb and b/Assets/Shaders/DeferredComposite_CS.shshaderb differ diff --git a/Assets/Shaders/ShinyHighlight_FS.glsl b/Assets/Shaders/ShinyHighlight_FS.glsl new file mode 100644 index 00000000..92020d9a --- /dev/null +++ b/Assets/Shaders/ShinyHighlight_FS.glsl @@ -0,0 +1,97 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + int textureIndex; + float highlightPosition; +}; + +struct GenericData +{ + //! Delta time + float dt; + + //! Elapsed time of the application + float elapsedTime; + + //! Viewport width of the scene (excluding imgui, that means smaller than window) + uint viewportWidth; + + //! Ditto but for height + uint viewportHeight; +}; + + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + vec4 worldPos; // location = 3 +} In; + +// material stuff +layout(location = 4) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; + vec3 screenSpacePos; + +} In2; + +layout (set = 0, binding = 0) uniform GenericDataBuffer +{ + GenericData data; +} genericDataBuffer; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 position; +layout(location = 1) out uint outEntityID; +layout(location = 2) out uint lightLayerIndices; +layout(location = 3) out vec4 normals; +layout(location = 4) out vec4 albedo; +layout(location = 5) out vec4 worldSpacePosition; +layout(location = 6) out vec4 objectVFX; + +float map (float value, float srcLow, float srcHigh, float dstLow, float dstHigh) +{ + return dstLow + (value - srcLow) * (dstHigh - dstLow) / (srcHigh - srcLow); +} + +void main() +{ + position = In.vertPos; + normals = In.normal; + albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + worldSpacePosition = In.worldPos; + + outEntityID = In2.eid; + lightLayerIndices = In2.lightLayerIndex; + + float vpHeight = (float (In2.screenSpacePos.y) - (genericDataBuffer.data.elapsedTime * 4000.0f * (1.0f - In2.screenSpacePos.z))); + vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight); + float scanlineScale = 2500.0f * (1.0f - In2.screenSpacePos.z); + + float lowerLimit = vpHeight - scanlineScale; + float upperLimit = vpHeight + scanlineScale; + if (gl_FragCoord.y > lowerLimit && gl_FragCoord.y < upperLimit) + { + float opacity = 0.0f; + opacity = map (abs (gl_FragCoord.y - vpHeight), 0.0f, upperLimit - vpHeight, 0.0f, 1.0f); + opacity = 1.0f - clamp (opacity, 0.0f, 1.0f); + + + objectVFX = vec4(opacity); + } + else + objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f); +} \ No newline at end of file diff --git a/Assets/Shaders/ShinyHighlight_FS.shshaderb b/Assets/Shaders/ShinyHighlight_FS.shshaderb new file mode 100644 index 00000000..af550ffe Binary files /dev/null and b/Assets/Shaders/ShinyHighlight_FS.shshaderb differ diff --git a/Assets/Shaders/ShinyHighlight_FS.shshaderb.shmeta b/Assets/Shaders/ShinyHighlight_FS.shshaderb.shmeta new file mode 100644 index 00000000..3c17101d --- /dev/null +++ b/Assets/Shaders/ShinyHighlight_FS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: ShinyHighlight_FS +ID: 45685219 +Type: 2 diff --git a/Assets/Shaders/ShinyHighlight_VS.glsl b/Assets/Shaders/ShinyHighlight_VS.glsl new file mode 100644 index 00000000..c0268737 --- /dev/null +++ b/Assets/Shaders/ShinyHighlight_VS.glsl @@ -0,0 +1,99 @@ +#version 450 +#extension GL_KHR_vulkan_glsl : enable + +layout(location = 0) in vec3 aVertexPos; +layout(location = 1) in vec2 aUV; +layout(location = 2) in vec3 aNormal; +layout(location = 3) in vec3 aTangent; +layout(location = 4) in mat4 worldTransform; +layout(location = 8) in uvec2 integerData; +layout(location = 9) in uvec4 aBoneIndices; +layout(location = 10) in vec4 aBoneWeights; +layout(location = 11) in uint firstBoneIndex; + +layout(location = 0) out struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + vec4 worldPos; // location = 3 + +} Out; + +struct GenericData +{ + //! Delta time + float dt; + + //! Elapsed time of the application + float elapsedTime; + + //! Viewport width of the scene (excluding imgui, that means smaller than window) + uint viewportWidth; + + //! Ditto but for height + uint viewportHeight; +}; + +// material stuff +layout(location = 4) out struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; + vec3 screenSpacePos; + + +} Out2; + +layout(set = 1, binding = 0) uniform CameraData +{ + vec4 position; + mat4 vpMat; + mat4 viewMat; + mat4 projMat; +} cameraData; + +layout (set = 0, binding = 0) uniform GenericDataBuffer +{ + GenericData data; +} genericDataBuffer; + +void main() +{ + Out2.materialIndex = gl_InstanceIndex; + Out2.eid = integerData[0]; + Out2.lightLayerIndex = integerData[1]; + + // for transforming gBuffer position and normal data + mat4 modelViewMat = cameraData.viewMat * worldTransform; + + // gBuffer position will be in view space + Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f); + + Out.worldPos = worldTransform * vec4 (aVertexPos, 1.0f); + + // uvs for texturing in fragment shader + Out.uv = aUV; + + mat3 transposeInv = mat3 (transpose(inverse(modelViewMat))); + + // normals are also in view space + Out.normal.rgb = transposeInv * aNormal.rgb; + Out.normal.rgb = normalize (Out.normal.rgb); + + // Get center of object in world position + vec4 worldPos = vec4(worldTransform[3][0], worldTransform[3][1], worldTransform[3][2], 1.0f); + + // transform to clip space + worldPos = cameraData.vpMat * worldPos; + worldPos.xyz /= worldPos.w; + + // transform to screen space + worldPos.xy = ((worldPos.xy + vec2(1.0f)) * vec2 (0.5f)) * vec2 (genericDataBuffer.data.viewportWidth, genericDataBuffer.data.viewportHeight); + + Out2.screenSpacePos = worldPos.xyz; + + // clip space for rendering + gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f); +} \ No newline at end of file diff --git a/Assets/Shaders/ShinyHighlight_VS.shshaderb b/Assets/Shaders/ShinyHighlight_VS.shshaderb new file mode 100644 index 00000000..98187085 Binary files /dev/null and b/Assets/Shaders/ShinyHighlight_VS.shshaderb differ diff --git a/Assets/Shaders/ShinyHighlight_VS.shshaderb.shmeta b/Assets/Shaders/ShinyHighlight_VS.shshaderb.shmeta new file mode 100644 index 00000000..f036de5a --- /dev/null +++ b/Assets/Shaders/ShinyHighlight_VS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: ShinyHighlight_VS +ID: 37048829 +Type: 2 diff --git a/Assets/Shaders/Silhouette_FS.glsl b/Assets/Shaders/Silhouette_FS.glsl new file mode 100644 index 00000000..292bdfe7 --- /dev/null +++ b/Assets/Shaders/Silhouette_FS.glsl @@ -0,0 +1,67 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + vec4 color; +}; + +struct GenericData +{ + //! Delta time + float dt; + + //! Elapsed time of the application + float elapsedTime; + + //! Viewport width of the scene (excluding imgui, that means smaller than window) + uint viewportWidth; + + //! Ditto but for height + uint viewportHeight; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + vec4 worldPos; // location = 3 +} In; + +// material stuff +layout(location = 4) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout (set = 0, binding = 0) uniform GenericDataBuffer +{ + GenericData data; +} genericDataBuffer; + +layout(location = 0) out vec4 objectVFX; +layout(input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput depthBuffer; + +void main() +{ + // Sample depth buffer using UV and save it + float currentDepth = subpassLoad (depthBuffer).r; + + // Use depth buffer to check against current fragment's depth. If fragment is behind depth buffer, render fragment. + if (currentDepth > gl_FragCoord.z) + discard; + + objectVFX = MatProp.data[In2.materialIndex].color; + +} \ No newline at end of file diff --git a/Assets/Shaders/Silhouette_FS.shshaderb b/Assets/Shaders/Silhouette_FS.shshaderb new file mode 100644 index 00000000..4710b8a6 Binary files /dev/null and b/Assets/Shaders/Silhouette_FS.shshaderb differ diff --git a/Assets/Shaders/Silhouette_FS.shshaderb.shmeta b/Assets/Shaders/Silhouette_FS.shshaderb.shmeta new file mode 100644 index 00000000..e094c1d6 --- /dev/null +++ b/Assets/Shaders/Silhouette_FS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: Silhouette_FS +ID: 42962441 +Type: 2 diff --git a/Assets/Shaders/Silhouette_VS.glsl b/Assets/Shaders/Silhouette_VS.glsl new file mode 100644 index 00000000..1b45c333 --- /dev/null +++ b/Assets/Shaders/Silhouette_VS.glsl @@ -0,0 +1,68 @@ +#version 450 +#extension GL_KHR_vulkan_glsl : enable + +//#include "ShaderDescriptorDefinitions.glsl" + + +layout(location = 0) in vec3 aVertexPos; +layout(location = 1) in vec2 aUV; +layout(location = 2) in vec3 aNormal; +layout(location = 3) in vec3 aTangent; +layout(location = 4) in mat4 worldTransform; +layout(location = 8) in uvec2 integerData; +layout(location = 9) in uvec4 aBoneIndices; +layout(location = 10) in vec4 aBoneWeights; +layout(location = 11) in uint firstBoneIndex; + +layout(location = 0) out struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + vec4 worldPos; // location = 3 + +} Out; + +// material stuff +layout(location = 4) out struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; + +} Out2; + +layout(set = 1, binding = 0) uniform CameraData +{ + vec4 position; + mat4 vpMat; + mat4 viewMat; + mat4 projMat; +} cameraData; + +void main() +{ + Out2.materialIndex = gl_InstanceIndex; + Out2.eid = integerData[0]; + Out2.lightLayerIndex = integerData[1]; + + // for transforming gBuffer position and normal data + mat4 modelViewMat = cameraData.viewMat * worldTransform; + + // gBuffer position will be in view space + Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f); + + Out.worldPos = worldTransform * vec4 (aVertexPos, 1.0f); + + // uvs for texturing in fragment shader + Out.uv = aUV; + + mat3 transposeInv = mat3 (transpose(inverse(modelViewMat))); + + // normals are also in view space + Out.normal.rgb = transposeInv * aNormal.rgb; + Out.normal.rgb = normalize (Out.normal.rgb); + + // clip space for rendering + gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f); +} \ No newline at end of file diff --git a/Assets/Shaders/Silhouette_VS.shshaderb b/Assets/Shaders/Silhouette_VS.shshaderb new file mode 100644 index 00000000..1bb76ec4 Binary files /dev/null and b/Assets/Shaders/Silhouette_VS.shshaderb differ diff --git a/Assets/Shaders/Silhouette_VS.shshaderb.shmeta b/Assets/Shaders/Silhouette_VS.shshaderb.shmeta new file mode 100644 index 00000000..508a8788 --- /dev/null +++ b/Assets/Shaders/Silhouette_VS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: Silhouette_VS +ID: 38847805 +Type: 2 diff --git a/Assets/Shaders/ToSwapchain_FS.glsl b/Assets/Shaders/ToSwapchain_FS.glsl index 3cf1752f..d353c15f 100644 --- a/Assets/Shaders/ToSwapchain_FS.glsl +++ b/Assets/Shaders/ToSwapchain_FS.glsl @@ -3,7 +3,7 @@ #extension GL_ARB_shading_language_420pack : enable #extension GL_EXT_nonuniform_qualifier : require -layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture; +layout (input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput sceneTexture; layout(location = 0) out vec4 fragColor; diff --git a/Assets/Shaders/ToSwapchain_FS.shshaderb b/Assets/Shaders/ToSwapchain_FS.shshaderb index 0bee0ac6..24cb54fe 100644 Binary files a/Assets/Shaders/ToSwapchain_FS.shshaderb and b/Assets/Shaders/ToSwapchain_FS.shshaderb differ diff --git a/Assets/Shaders/UI_FS.glsl b/Assets/Shaders/UI_FS.glsl index 3d40bc14..30b59e48 100644 --- a/Assets/Shaders/UI_FS.glsl +++ b/Assets/Shaders/UI_FS.glsl @@ -5,10 +5,8 @@ struct MatPropData { - vec4 color; int textureIndex; float alpha; - vec3 beta; }; layout(location = 0) in struct @@ -43,6 +41,8 @@ void main() { discard; } + fragColor.a = MatProp.data[In2.materialIndex].alpha; + // fragColor.a = 1.0f; outEntityID = In2.eid; } \ No newline at end of file diff --git a/Assets/Shaders/UI_FS.shshaderb b/Assets/Shaders/UI_FS.shshaderb index 024d0a3d..92f4ed4e 100644 Binary files a/Assets/Shaders/UI_FS.shshaderb and b/Assets/Shaders/UI_FS.shshaderb differ diff --git a/Assets/Shaders/UI_Slider_FS.glsl b/Assets/Shaders/UI_Slider_FS.glsl new file mode 100644 index 00000000..b39f18dd --- /dev/null +++ b/Assets/Shaders/UI_Slider_FS.glsl @@ -0,0 +1,60 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + int textureIndex; + float alpha; + float sliderThreshold; + vec4 sliderStartColor; + vec4 sliderEndColor; + vec4 sliderBarColor; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + +} In; + +// material stuff +layout(location = 3) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; + +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 fragColor; +layout(location = 1) out uint outEntityID; + +void main() +{ + //fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold) + fragColor = MatProp.data[In2.materialIndex].sliderBarColor; + else + fragColor = (1.0f - In.uv.x) * MatProp.data[In2.materialIndex].sliderStartColor + In.uv.x * MatProp.data[In2.materialIndex].sliderEndColor; + //fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + if (fragColor.a < 0.01f) + { + discard; + } + + fragColor.a = MatProp.data[In2.materialIndex].alpha; + + // fragColor.a = 1.0f; + outEntityID = In2.eid; +} \ No newline at end of file diff --git a/Assets/Shaders/UI_Slider_FS.shshaderb b/Assets/Shaders/UI_Slider_FS.shshaderb new file mode 100644 index 00000000..0dcfb62d Binary files /dev/null and b/Assets/Shaders/UI_Slider_FS.shshaderb differ diff --git a/Assets/Shaders/UI_Slider_FS.shshaderb.shmeta b/Assets/Shaders/UI_Slider_FS.shshaderb.shmeta new file mode 100644 index 00000000..51d3222f --- /dev/null +++ b/Assets/Shaders/UI_Slider_FS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: UI_Slider_FS +ID: 48832081 +Type: 2 diff --git a/Assets/Shaders/UI_Slider_Textured_FS.glsl b/Assets/Shaders/UI_Slider_Textured_FS.glsl new file mode 100644 index 00000000..9f7945ce --- /dev/null +++ b/Assets/Shaders/UI_Slider_Textured_FS.glsl @@ -0,0 +1,62 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + int textureIndex; + float alpha; + float sliderThreshold; + vec4 sliderStartColor; + vec4 sliderEndColor; + vec4 sliderBarColor; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + +} In; + +// material stuff +layout(location = 3) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; + +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 fragColor; +layout(location = 1) out uint outEntityID; + +void main() +{ + //fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold) + fragColor = MatProp.data[In2.materialIndex].sliderBarColor; + else + //fragColor = (1.0f - In.uv.x) * MatProp.data[In2.materialIndex].sliderStartColor + In.uv.x * MatProp.data[In2.materialIndex].sliderEndColor; + fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + + if (fragColor.a < 0.01f) + { + discard; + } + + fragColor.a = MatProp.data[In2.materialIndex].alpha; + + // fragColor.a = 1.0f; + outEntityID = In2.eid; +} \ No newline at end of file diff --git a/Assets/Shaders/UI_Slider_Textured_FS.shshaderb b/Assets/Shaders/UI_Slider_Textured_FS.shshaderb new file mode 100644 index 00000000..db7f7c70 Binary files /dev/null and b/Assets/Shaders/UI_Slider_Textured_FS.shshaderb differ diff --git a/Assets/Shaders/UI_Slider_Textured_FS.shshaderb.shmeta b/Assets/Shaders/UI_Slider_Textured_FS.shshaderb.shmeta new file mode 100644 index 00000000..57e0093e --- /dev/null +++ b/Assets/Shaders/UI_Slider_Textured_FS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: UI_Slider_Textured_FS +ID: 43211183 +Type: 2 diff --git a/Assets/Shaders/UI_VS.glsl b/Assets/Shaders/UI_VS.glsl index 8856ca77..bb1ff318 100644 --- a/Assets/Shaders/UI_VS.glsl +++ b/Assets/Shaders/UI_VS.glsl @@ -58,8 +58,11 @@ void main() Out.normal.rgb = transposeInv * aNormal.rgb; Out.normal.rgb = normalize (Out.normal.rgb); + vec3 vert = aVertexPos; + vert.z += 0.1f; + // clip space for rendering - gl_Position = cameraData.projMat * worldTransform * vec4 (aVertexPos, 1.0f); - gl_Position.z += 0.1f; // HAX + gl_Position = cameraData.projMat * worldTransform * vec4 (vert, 1.0f); + // gl_Position.z += 0.1f; // HAX // gl_Position = vec4 (aVertexPos, 1.0f); } \ No newline at end of file diff --git a/Assets/Shaders/UI_VS.shshaderb b/Assets/Shaders/UI_VS.shshaderb index 79d39a82..977252c2 100644 Binary files a/Assets/Shaders/UI_VS.shshaderb and b/Assets/Shaders/UI_VS.shshaderb differ diff --git a/Assets/Texture/UI/RaccoonTransparent.dds b/Assets/Texture/UI/RaccoonTransparent.dds new file mode 100644 index 00000000..f974aaec Binary files /dev/null and b/Assets/Texture/UI/RaccoonTransparent.dds differ diff --git a/Assets/Texture/UI/RaccoonTransparent.shtex b/Assets/Texture/UI/RaccoonTransparent.shtex new file mode 100644 index 00000000..77483a50 Binary files /dev/null and b/Assets/Texture/UI/RaccoonTransparent.shtex differ diff --git a/Assets/Texture/UI/RaccoonTransparent.shtex.shmeta b/Assets/Texture/UI/RaccoonTransparent.shtex.shmeta new file mode 100644 index 00000000..3e28bfd3 --- /dev/null +++ b/Assets/Texture/UI/RaccoonTransparent.shtex.shmeta @@ -0,0 +1,3 @@ +Name: RaccoonTransparent +ID: 51158984 +Type: 3 diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_01.dds b/Assets/Texture/UI/TX_WK10_HowToPlay_01.dds new file mode 100644 index 00000000..cc1d68b6 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_01.dds differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex b/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex new file mode 100644 index 00000000..061d84c8 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex.shmeta b/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex.shmeta new file mode 100644 index 00000000..fcd72302 --- /dev/null +++ b/Assets/Texture/UI/TX_WK10_HowToPlay_01.shtex.shmeta @@ -0,0 +1,3 @@ +Name: TX_WK10_HowToPlay_01 +ID: 62200943 +Type: 3 diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_02.dds b/Assets/Texture/UI/TX_WK10_HowToPlay_02.dds new file mode 100644 index 00000000..38ea5b30 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_02.dds differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex b/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex new file mode 100644 index 00000000..3fa62e86 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex.shmeta b/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex.shmeta new file mode 100644 index 00000000..56e9b58a --- /dev/null +++ b/Assets/Texture/UI/TX_WK10_HowToPlay_02.shtex.shmeta @@ -0,0 +1,3 @@ +Name: TX_WK10_HowToPlay_02 +ID: 53303669 +Type: 3 diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_03.dds b/Assets/Texture/UI/TX_WK10_HowToPlay_03.dds new file mode 100644 index 00000000..ac8adee9 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_03.dds differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex b/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex new file mode 100644 index 00000000..826d87b2 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex.shmeta b/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex.shmeta new file mode 100644 index 00000000..c190e6d8 --- /dev/null +++ b/Assets/Texture/UI/TX_WK10_HowToPlay_03.shtex.shmeta @@ -0,0 +1,3 @@ +Name: TX_WK10_HowToPlay_03 +ID: 61780097 +Type: 3 diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_04.dds b/Assets/Texture/UI/TX_WK10_HowToPlay_04.dds new file mode 100644 index 00000000..66298f3a Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_04.dds differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex b/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex new file mode 100644 index 00000000..3d6504b1 Binary files /dev/null and b/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex differ diff --git a/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex.shmeta b/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex.shmeta new file mode 100644 index 00000000..df21f174 --- /dev/null +++ b/Assets/Texture/UI/TX_WK10_HowToPlay_04.shtex.shmeta @@ -0,0 +1,3 @@ +Name: TX_WK10_HowToPlay_04 +ID: 59178524 +Type: 3 diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index a89fb050..3ebcc904 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -132,16 +132,19 @@ namespace Sandbox SHSystemManager::RegisterRoutine(); SHSystemManager::RegisterRoutine(); - SHSystemManager::RegisterRoutine(); - SHSystemManager::RegisterRoutine(); - SHSystemManager::RegisterRoutine(); - SHSystemManager::RegisterRoutine(); //SHSystemManager::RegisterRoutine(); SHSystemManager::RegisterRoutine(); SHSystemManager::RegisterRoutine(); SHSystemManager::RegisterRoutine(); SHSystemManager::RegisterRoutine(); + + SHSystemManager::RegisterRoutine(); + SHSystemManager::RegisterRoutine(); + SHSystemManager::RegisterRoutine(); + SHSystemManager::RegisterRoutine(); + + SHSystemManager::RegisterRoutine(); #ifdef SHEDITOR diff --git a/SHADE_Engine/src/Assets/Events/SHAssetManagerEvents.h b/SHADE_Engine/src/Assets/Events/SHAssetManagerEvents.h new file mode 100644 index 00000000..d61395e9 --- /dev/null +++ b/SHADE_Engine/src/Assets/Events/SHAssetManagerEvents.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +namespace SHADE +{ + struct SHCompileAssetEvent + { + //! Name of the asset (where applicable) + std::string assetName; + + //! asset ID of the asset + AssetID assetID; + + //! type of the asset + AssetType assetType; + }; +} + diff --git a/SHADE_Engine/src/Assets/Libraries/Compilers/SHShaderSourceCompiler.cpp b/SHADE_Engine/src/Assets/Libraries/Compilers/SHShaderSourceCompiler.cpp index fd1f6d8a..0bde59c7 100644 --- a/SHADE_Engine/src/Assets/Libraries/Compilers/SHShaderSourceCompiler.cpp +++ b/SHADE_Engine/src/Assets/Libraries/Compilers/SHShaderSourceCompiler.cpp @@ -11,6 +11,7 @@ #include "SHpch.h" #include "SHShaderSourceCompiler.h" #include "shaderc/shaderc.hpp" +#include "Events/SHEventManager.hpp" #include #include diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index 363b7829..b7f7fbb4 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -28,6 +28,8 @@ #include "Filesystem/SHFileSystem.h" #include +#include "Assets/Events/SHAssetManagerEvents.h" +#include "Events/SHEventManager.hpp" namespace SHADE { @@ -39,7 +41,7 @@ namespace SHADE std::vector SHAssetManager::loaders(TYPE_COUNT); std::unordered_map SHAssetManager::assetCollection; - std::unordered_map SHAssetManager::assetData; + std::unordered_map SHAssetManager::assetData; /**************************************************************************** @@ -167,6 +169,17 @@ namespace SHADE return {}; } + AssetID SHAssetManager::GetAssetIDFromPath(AssetPath const& path) noexcept + { + for (auto const& pair : assetCollection) + { + if (pair.second.path.stem() == path.stem()) + return pair.first; + } + + return 0; + } + /**************************************************************************** * \brief Create record for new asset. CAN ONLY CREATE FOR CUSTOM * ASSETS CREATED BY THE ENGINE. @@ -438,10 +451,39 @@ namespace SHADE return; } + AssetID target{ 0 }; if (genMeta) { - GenerateNewMeta(newPath); + auto result = GenerateNewMeta(newPath); + target = result.has_value() ? result.value() : 0; } + else + { + target = GetAssetIDFromPath(path); + + //Reload data + auto result = GetAsset(target); + if (result.has_value()) + { + auto const& asset{ result.value() }; + auto newData = loaders[static_cast(asset.type)]->Load(asset.path); + delete assetData[target]; + assetData[target] = newData; + } + else + { + SHLOG_ERROR("[Asset Manager] Critical: reload of existing compiled data failed"); + } + } + + // send compile asset event + SHCompileAssetEvent compileShaderEvent + { + .assetName = newPath.filename().stem().string(), + .assetID = target, + .assetType = AssetType::SHADER, + }; + SHEventManager::BroadcastEvent(compileShaderEvent, SH_ASSET_COMPILE_EVENT); } FolderPointer SHAssetManager::GetRootFolder() noexcept diff --git a/SHADE_Engine/src/Assets/SHAssetManager.h b/SHADE_Engine/src/Assets/SHAssetManager.h index 6cac6c71..e5cd0359 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.h +++ b/SHADE_Engine/src/Assets/SHAssetManager.h @@ -50,7 +50,7 @@ namespace SHADE * \return const& to unordered_map ****************************************************************************/ static std::vector GetAllAssets() noexcept; - static std::optional GetAsset(AssetID id) noexcept; + static std::optional GetAsset(AssetID id) noexcept; static AssetType GetType(AssetID id) noexcept; @@ -97,6 +97,7 @@ namespace SHADE private: + static AssetID GetAssetIDFromPath(AssetPath const& path) noexcept; static void InitLoaders() noexcept; static void LoadAllData() noexcept; static SHAssetData* LoadData(SHAsset const& asset) noexcept; @@ -122,7 +123,7 @@ namespace SHADE // For all resources static std::unordered_map assetCollection; - static std::unordered_map assetData; + static std::unordered_map assetData; }; } diff --git a/SHADE_Engine/src/Camera/SHCameraComponent.cpp b/SHADE_Engine/src/Camera/SHCameraComponent.cpp index 17378d79..da6ad4a4 100644 --- a/SHADE_Engine/src/Camera/SHCameraComponent.cpp +++ b/SHADE_Engine/src/Camera/SHCameraComponent.cpp @@ -10,8 +10,8 @@ namespace SHADE { SHCameraComponent::SHCameraComponent() :yaw(0.0f), pitch(0.0f), roll(0.0f) - , width(1920.0f), height(1080.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f) - , perspProj(true), dirtyView(true), dirtyProj(true) + , width(1920.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f) + , perspProj(true), dirtyView(true), dirtyProj(true), followScreenAR(true) , viewMatrix(), perspProjMatrix(), orthoProjMatrix() , position(), offset() { @@ -122,11 +122,6 @@ namespace SHADE } - void SHCameraComponent::SetHeight(float height) noexcept - { - this->height = height; - dirtyProj = true; - } void SHCameraComponent::SetNear(float znear) noexcept { @@ -154,7 +149,7 @@ namespace SHADE SHVec3 SHCameraComponent::GetPosition() const noexcept { - return position; + return position + offset; } float SHCameraComponent::GetYaw() const noexcept @@ -176,10 +171,7 @@ namespace SHADE return width; } - float SHCameraComponent::GetHeight() const noexcept - { - return height; - } + float SHCameraComponent::GetNear() const noexcept { @@ -191,10 +183,7 @@ namespace SHADE return zFar; } - float SHCameraComponent::GetAspectRatio() const noexcept - { - return width/height; - } + float SHCameraComponent::GetFOV() const noexcept { @@ -251,11 +240,11 @@ RTTR_REGISTRATION .property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw) .property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll) .property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth) - .property("Height", &SHCameraComponent::GetHeight, &SHCameraComponent::SetHeight) .property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear) .property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar) .property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective) - .property("FOV",&SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV); + .property("FOV", &SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV); + } diff --git a/SHADE_Engine/src/Camera/SHCameraComponent.h b/SHADE_Engine/src/Camera/SHCameraComponent.h index b0999fe9..b1b069c3 100644 --- a/SHADE_Engine/src/Camera/SHCameraComponent.h +++ b/SHADE_Engine/src/Camera/SHCameraComponent.h @@ -19,7 +19,6 @@ namespace SHADE float roll; float width; - float height; float zNear; float zFar; float fov; @@ -27,7 +26,6 @@ namespace SHADE bool dirtyView; bool dirtyProj; - SHMatrix viewMatrix; SHMatrix perspProjMatrix; SHMatrix orthoProjMatrix; @@ -45,6 +43,8 @@ namespace SHADE SHCameraComponent(); virtual ~SHCameraComponent(); + bool followScreenAR; + //Getters and setters. void SetYaw(float yaw) noexcept; @@ -57,7 +57,6 @@ namespace SHADE void SetPosition(SHVec3 pos) noexcept; void SetWidth(float width) noexcept; - void SetHeight(float height) noexcept; void SetNear(float znear) noexcept; void SetFar(float zfar) noexcept; void SetFOV(float fov) noexcept; @@ -70,11 +69,9 @@ namespace SHADE float GetRoll() const noexcept; float GetWidth() const noexcept; - float GetHeight() const noexcept; float GetNear() const noexcept; float GetFar() const noexcept; - float GetAspectRatio() const noexcept; float GetFOV() const noexcept; bool GetIsPerspective() const noexcept; diff --git a/SHADE_Engine/src/Camera/SHCameraDirector.cpp b/SHADE_Engine/src/Camera/SHCameraDirector.cpp index 7d5ec6f2..15255ae8 100644 --- a/SHADE_Engine/src/Camera/SHCameraDirector.cpp +++ b/SHADE_Engine/src/Camera/SHCameraDirector.cpp @@ -99,13 +99,13 @@ namespace SHADE return 0.0f; } - float SHCameraDirector::GetHeight() noexcept - { - SHCameraComponent* camComponent = GetMainCameraComponent(); - if (camComponent) - return camComponent->GetHeight(); - else - return 0.0f; - } + //float SHCameraDirector::GetHeight() noexcept + //{ + // SHCameraComponent* camComponent = GetMainCameraComponent(); + // if (camComponent) + // return camComponent->GetHeight(); + // else + // return 0.0f; + //} } diff --git a/SHADE_Engine/src/Camera/SHCameraDirector.h b/SHADE_Engine/src/Camera/SHCameraDirector.h index 381531d6..48e85fc2 100644 --- a/SHADE_Engine/src/Camera/SHCameraDirector.h +++ b/SHADE_Engine/src/Camera/SHCameraDirector.h @@ -31,7 +31,7 @@ namespace SHADE SHMatrix const& GetOrthoMatrix() noexcept; SHMatrix const& GetPerspectiveMatrix() noexcept; float GetWidth() noexcept; - float GetHeight() noexcept; + //float GetHeight() noexcept; private: SHMatrix viewMatrix; diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 59ba7ce9..95a461f8 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -116,7 +116,6 @@ namespace SHADE editorCamera.SetYaw(0.0f); editorCamera.SetRoll(0.0f); editorCamera.SetWidth(1080.0f); - editorCamera.SetHeight(720.0f); editorCamera.SetFar(10000000.0f); editorCamera.movementSpeed = 2.0f; editorCamera.perspProj = true; @@ -144,20 +143,25 @@ namespace SHADE //std::cout << EVENT_DATA->resizeWidth << std::endl; //std::cout << EVENT_DATA->resizeHeight << std::endl; + screenAspectRatio = (float)EVENT_DATA->resizeWidth / (float)EVENT_DATA->resizeHeight; + +#ifdef SHEDITOR + auto editor = SHSystemManager::GetSystem(); + if (editor->editorState != SHEditor::State::PLAY) + return eventPtr->handle; - for (auto director : directorHandleList) +#endif // SHEDITOR + + for (auto& director : directorHandleList) { auto camera = SHComponentManager::GetComponent_s(director->mainCameraEID); if (camera) { camera->SetWidth(EVENT_DATA->resizeWidth); - camera->SetHeight(EVENT_DATA->resizeHeight); } - } - return eventPtr->handle; } @@ -340,7 +344,7 @@ namespace SHADE if (camera.dirtyProj == true) { //Perspective projection matrix. - const float ASPECT_RATIO = (camera.GetAspectRatio()); + const float ASPECT_RATIO = (screenAspectRatio); const float TAN_HALF_FOV = tan(SHMath::DegreesToRadians(camera.fov) * 0.5f); camera.perspProjMatrix = SHMatrix::Identity; camera.perspProjMatrix(0, 0) = 1.0f / (ASPECT_RATIO * TAN_HALF_FOV); @@ -357,7 +361,7 @@ namespace SHADE const float right = camera.GetWidth() * 0.5f; const float left = -right; - const float top = camera.GetHeight() * 0.5f; + const float top = camera.GetWidth() / screenAspectRatio * 0.5f; const float btm = -top; const float n = camera.GetNear(); const float f = camera.GetFar(); @@ -574,11 +578,11 @@ namespace SHADE auto editor = SHSystemManager::GetSystem(); if (editor->editorState != SHEditor::State::PLAY) { - return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetHeight() }; + return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetWidth() / screenAspectRatio }; } else { - return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetHeight() }; + return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetWidth() / screenAspectRatio }; } #else @@ -586,4 +590,9 @@ namespace SHADE #endif } + EntityID SHCameraSystem::GetMainCameraEID() const noexcept + { + return directorHandleList[0]->mainCameraEID; + } + } diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.h b/SHADE_Engine/src/Camera/SHCameraSystem.h index 4d6476bf..e7d06ddc 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.h +++ b/SHADE_Engine/src/Camera/SHCameraSystem.h @@ -21,6 +21,8 @@ namespace SHADE SHCameraComponent editorCamera; SHCameraArmComponent editorCameraArm; + float screenAspectRatio{16.0f/9.0f}; + SHResourceLibrary directorLibrary; std::vector directorHandleList; @@ -63,6 +65,7 @@ namespace SHADE void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept; void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept; void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept; + EntityID GetMainCameraEID() const noexcept; SHVec2 GetCameraWidthHeight(size_t index) noexcept; }; diff --git a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp index 791396df..dce3ffbd 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp @@ -19,6 +19,10 @@ #include "Tools/Utilities/SHStringUtilities.h" #include #include +#include "Assets/Asset Types/SHPrefabAsset.h" +#include "Serialization/SHSerialization.h" +#include +#include "Serialization/Prefab/SHPrefabManager.h" namespace SHADE { @@ -247,6 +251,7 @@ namespace SHADE const ImRect childRect = DrawAsset(file.assetMeta, file.ext); return childRect; } + return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); } ImRect SHAssetBrowser::DrawAsset(SHAsset const* const asset, FileExt const& ext /*= ""*/) noexcept @@ -365,6 +370,35 @@ namespace SHADE } } + if(ImGui::BeginPopupContextItem()) + { + switch (asset->type) + { + case AssetType::INVALID: break; + case AssetType::SHADER: break; + case AssetType::SHADER_BUILT_IN: break; + case AssetType::TEXTURE: break; + case AssetType::MESH: break; + case AssetType::SCENE: + break; + case AssetType::PREFAB: + { + if(ImGui::Selectable("Insert into scene")) + { + auto createdEntitiesList = SHSerialization::DeserializeEntitiesFromString(SHAssetManager::GetData(asset->id)->data); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(createdEntitiesList.begin()->second); + SHPrefabManager::AddEntity(asset->id, createdEntitiesList.begin()->second); + } + } + break; + case AssetType::MATERIAL: break; + case AssetType::SCRIPT: break; + case AssetType::MAX_COUNT: break; + default:; + } + ImGui::EndPopup(); + } + if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index a7e85ad4..cb7e3b12 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -26,6 +26,9 @@ #include "Serialization/SHSerialization.h" #include "Tools/Utilities/SHClipboardUtilities.h" #include "Tools/Utilities/SHStringUtilities.h" +#include "Serialization/Prefab/SHPrefabManager.h" +#include "../SHEditorWindowManager.h" +#include "../AssetBrowser/SHAssetBrowser.h" namespace SHADE @@ -96,30 +99,32 @@ namespace SHADE } ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal); - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A)) + if (!ImGui::IsAnyItemFocused()) { - SelectAllEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C)) - { - CopySelectedEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) - { - PasteEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) - { - if (editor->selectedEntities.size() == 1) + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A)) { - PasteEntities(editor->selectedEntities.back()); + SelectAllEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C)) + { + CopySelectedEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) + { + PasteEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) + { + if (editor->selectedEntities.size() == 1) + { + PasteEntities(editor->selectedEntities.back()); + } + } + if (ImGui::IsKeyReleased(ImGuiKey_Delete)) + { + DeleteSelectedEntities(); } } - if (ImGui::IsKeyReleased(ImGuiKey_Delete)) - { - DeleteSelectedEntities(); - } - } if(ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { @@ -315,7 +320,7 @@ namespace SHADE const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow); //Draw Node - bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str()); + bool isNodeOpen = ImGui::TreeNodeEx((void*)(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str()); if(!filter.empty()) { @@ -388,6 +393,11 @@ namespace SHADE //SHEntityManager::DestroyEntity(eid); DeleteSelectedEntities(); } + if(ImGui::Selectable("Save entity as Prefab")) + { + SHPrefabManager::SaveEntityAsPrefab(eid); + SHEditorWindowManager::GetEditorWindow()->QueueRefresh(); + } if ((currentNode->GetParent() != sceneGraph.GetRoot()) && ImGui::Selectable(std::format("{} Unparent Selected", ICON_MD_NORTH_WEST).data())) { diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index d3fa33fa..9aa5e579 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -47,6 +47,8 @@ namespace SHADE if (SHEditorWindow::Begin()) { //ImGui::ShowDemoWindow(); + if (bindingRenames.size() != SHInputManager::CountBindings()) + resizeVectors(SHInputManager::CountBindings()); //Binding count ImGui::Text("Binding Count: %d", SHInputManager::CountBindings()); @@ -127,6 +129,8 @@ namespace SHADE { SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]); bindingRenames[entryNumber].clear(); + ImGui::End(); + return; } if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str())) diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp index 81882742..391e0be2 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp @@ -22,6 +22,7 @@ #include "UI/SHCanvasComponent.h" #include "UI/SHButtonComponent.h" #include "UI/SHToggleButtonComponent.h" +#include "UI/SHSliderComponent.h" #include "SHEditorComponentView.h" #include "AudioSystem/SHAudioListenerComponent.h" #include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h" @@ -170,6 +171,9 @@ namespace SHADE if (auto toggleButton = SHComponentManager::GetComponent_s(eid)) { DrawComponent(toggleButton); + }if (auto slider = SHComponentManager::GetComponent_s(eid)) + { + DrawComponent(slider); } ImGui::Separator(); // Render Scripts @@ -185,6 +189,7 @@ namespace SHADE DrawAddComponentButton(eid); DrawAddComponentButton(eid); DrawAddComponentButton(eid); + DrawAddComponentButton(eid); // Components that require Transforms diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp index e8c943c2..d0c71265 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp @@ -26,6 +26,8 @@ #include "Serialization/Configurations/SHConfigurationManager.h" #include "Editor/EditorWindow/SHEditorWindowManager.h" #include "Physics/System/SHPhysicsDebugDrawSystem.h" +#include "Camera/SHCameraSystem.h" +#include "Tools/Utilities/SHClipboardUtilities.h" const std::string LAYOUT_FOLDER_PATH{ std::string(ASSET_ROOT) + "/Editor/Layouts" }; @@ -154,7 +156,39 @@ namespace SHADE ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg]); if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags)) { - ImGui::Text("Entity count: %zu", SHEntityManager::GetEntityCount()); + auto camSystem = SHSystemManager::GetSystem(); + std::string editorCamPosText{}; + auto editorCam = camSystem->GetEditorCamera(); + if(editorCam) + { + auto editorCamPos = editorCam->GetPosition(); + editorCamPosText = std::format("Editor Cam [X: {:.3f}, Y: {:.3f}, Z: {:.3f}]", editorCamPos.x, editorCamPos.y, editorCamPos.z); + + //ImGui::Text(editorCamPosText.data()); + } + ImGui::Text("Entity count: %zu %s", SHEntityManager::GetEntityCount(), editorCamPosText.data()); + if(ImGui::BeginPopupContextItem("EditorCamPosContext")) + { + if(editorCam) + { + if(ImGui::Selectable("Copy Editor Cam Pos X")) + { + auto editorCamPos = editorCam->GetPosition(); + SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.x)); + } + if (ImGui::Selectable("Copy Editor Cam Pos Y")) + { + auto editorCamPos = editorCam->GetPosition(); + SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.y)); + } + if (ImGui::Selectable("Copy Editor Cam Pos Z")) + { + auto editorCamPos = editorCam->GetPosition(); + SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.z)); + } + } + ImGui::EndPopup(); + } } ImGui::End(); ImGui::PopStyleColor(); diff --git a/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.cpp b/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.cpp index 8c32b1c5..9b055535 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.cpp @@ -59,7 +59,7 @@ namespace SHADE camSystem->UpdateEditorArm(SHFrameRateController::GetRawDeltaTime(), shouldUpdateCamArm, targetPos); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); if (Begin()) { ImGuizmo::SetDrawlist(); @@ -70,7 +70,8 @@ namespace SHADE beginCursorPos = ImGui::GetCursorScreenPos(); viewportMousePos = { mousePos.x - beginCursorPos.x, mousePos.y - beginCursorPos.y }; gfxSystem->GetMousePickSystem()->SetViewportMousePos(viewportMousePos); - ImGui::Image((ImTextureID)descriptorSet, { beginContentRegionAvailable.x, beginContentRegionAvailable.y }); + SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable); + ImGui::Image((ImTextureID)descriptorSet, { viewportSize.x, viewportSize.y }); if (ImGui::IsWindowHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Right)) { @@ -101,6 +102,7 @@ namespace SHADE } } } + ImGui::PopStyleColor(); ImGuizmo::SetRect(beginCursorPos.x, beginCursorPos.y, beginContentRegionAvailable.x, beginContentRegionAvailable.y); if(editor->editorState != SHEditor::State::PLAY) transformGizmo.Draw(); @@ -121,12 +123,22 @@ namespace SHADE //auto pos = ImGui::GetCursorPos(); //windowCursorPos = {} + if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0) { beginContentRegionAvailable = windowSize; } - gfxSystem->PrepareResize(static_cast(beginContentRegionAvailable.x), static_cast(beginContentRegionAvailable.y)); + + //beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable); + SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable); + gfxSystem->PrepareResize(static_cast(viewportSize.x), static_cast(viewportSize.y)); shouldUpdateCamera = true; + //if (aspectRatio != AspectRatio::FREE && (ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Left))) + //{ + // windowSize = CalculateWindowSize(windowSize); + // beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable); + // ImGui::SetWindowSize(windowName.data(), CalculateWindowSize(windowSize)); + //} } void SHEditorViewport::OnPosChange() @@ -194,13 +206,73 @@ namespace SHADE ImGui::PopStyleColor(); ImGui::EndDisabled(); + //TODO: Shift to constructor + auto arRTTRtype = rttr::type::get(); + auto enumAlign = arRTTRtype.get_enumeration(); + auto names = enumAlign.get_names(); + std::vector arNames; + for (auto const& name : names) + { + arNames.push_back(name.data()); + } + int currentAR = static_cast(aspectRatio); + ImGui::SetNextItemWidth(80.0f); + if (ImGui::Combo("Aspect Ratio", ¤tAR, arNames.data(), arNames.size())) + { + aspectRatio = static_cast(currentAR); + windowSize = CalculateWindowSize(windowSize); + ImGui::SetWindowSize(windowSize); + //beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable); + //OnResize(); + } + auto camSystem = SHSystemManager::GetSystem(); auto editorCamera = camSystem->GetEditorCamera(); //ImGui::SetNextItemWidth(10.0f); SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; }); SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; }); + //if(ImGui::BeginCombo("Aspect Ratio", arNames[(uint8_t)aspectRatio].data())) + //{ + // auto nameIt = names.begin(); + // auto valueIt = values.end(); + // while(nameIt != names.end() && valueIt != values.end()) + // { + // if ImGui::Beg + // } + //} + ImGui::EndMenuBar(); } } + + SHVec2 SHEditorViewport::CalculateWindowSize(SHVec2 const& rhs) noexcept +{ + switch (aspectRatio) + { + case SHADE::SHEditorViewport::AspectRatio::FREE: + return rhs; + case SHADE::SHEditorViewport::AspectRatio::AR16_9: + return SHVec2(rhs.x, rhs.x * 0.5625f); + case SHADE::SHEditorViewport::AspectRatio::AR21_9: + return SHVec2(rhs.x, rhs.x * 0.42857f); + case SHADE::SHEditorViewport::AspectRatio::AR21_10: + return SHVec2(rhs.x, rhs.x * 0.47619f); + default: + return rhs; + } + } + }//namespace SHADE + +RTTR_REGISTRATION +{ + using namespace rttr; + using namespace SHADE; + registration::enumeration("AspectRatio")( + value("FREE", SHEditorViewport::AspectRatio::FREE), + value("16:9", SHEditorViewport::AspectRatio::AR16_9), + value("21:9", SHEditorViewport::AspectRatio::AR21_9), + value("21:10", SHEditorViewport::AspectRatio::AR21_10) + ); +} diff --git a/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.h b/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.h index 8f49c514..d7fb0f39 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.h +++ b/SHADE_Engine/src/Editor/EditorWindow/ViewportWindow/SHEditorViewport.h @@ -16,7 +16,15 @@ namespace SHADE { class SHEditorViewport final : public SHEditorWindow { + public: + enum class AspectRatio : uint8_t + { + FREE, + AR16_9, + AR21_9, + AR21_10 + }; SHEditorViewport(); void Init() override; void Update() override; @@ -27,9 +35,12 @@ namespace SHADE void OnPosChange() override; private: void DrawMenuBar() noexcept; - SHVec2 beginCursorPos; + SHVec2 CalculateWindowSize(SHVec2 const& rhs) noexcept; + bool shouldUpdateCamera = false; bool shouldUpdateCamArm = false; + AspectRatio aspectRatio {AspectRatio::FREE}; + SHVec2 beginCursorPos; SHVec3 targetPos; };//class SHEditorViewport }//namespace SHADE diff --git a/SHADE_Engine/src/Events/SHEventDefines.h b/SHADE_Engine/src/Events/SHEventDefines.h index fffe8b5f..a7447be0 100644 --- a/SHADE_Engine/src/Events/SHEventDefines.h +++ b/SHADE_Engine/src/Events/SHEventDefines.h @@ -29,4 +29,5 @@ constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 }; constexpr SHEventIdentifier SH_BUTTON_RELEASE_EVENT { 21 }; constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 }; constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 }; +constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 }; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp index 31cd0dfc..32a4fa76 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp @@ -345,7 +345,7 @@ namespace SHADE else { // Should be deactivated - static const SHMatrix ZERO_MTX = + static const SHMatrix ZERO_MTX { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.cpp new file mode 100644 index 00000000..b77c20f9 --- /dev/null +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.cpp @@ -0,0 +1,53 @@ +#include "SHpch.h" +#include "SHGraphicsGenericData.h" +#include "Graphics/Devices/SHVkLogicalDevice.h" +#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h" +#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" +#include "Graphics/Buffers/SHVkBuffer.h" + + +namespace SHADE +{ + void SHGraphicsGenericData::Init(Handle logicalDevice, Handle descSet) noexcept + { + alignedGpuStructSize = logicalDevice->PadUBOSize(sizeof (GpuStruct)); + + gpuBuffer = logicalDevice->CreateBuffer(alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Generic Data"); + + std::array gpuBufferArray{ gpuBuffer }; + + // We use index 0 because the descriptor set is standalone created from a single desc set layout. What the driver sees is that this set is at index 0 during updating. + static constexpr uint8_t SET_0 = 0; + + descSet->ModifyWriteDescBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA, std::span>{ gpuBufferArray.data(), gpuBufferArray.size()}, 0, sizeof(GpuStruct)); + + descSet->UpdateDescriptorSetBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA); + + } + + void SHGraphicsGenericData::UpdateBuffer(uint32_t frameIndex) noexcept + { + gpuBuffer->WriteToMemory(&data, sizeof(GpuStruct), 0, alignedGpuStructSize * frameIndex); + } + + void SHGraphicsGenericData::SetDt(float dt) noexcept + { + data.dt = dt; + } + + void SHGraphicsGenericData::UpdateElapsedTime(float dt) noexcept + { + data.elapsedTime += dt; + } + + void SHGraphicsGenericData::SetViewportWidth(uint32_t width) noexcept + { + data.viewportWidth = width; + } + + void SHGraphicsGenericData::SetViewportHeight(uint32_t height) noexcept + { + data.viewportHeight = height; + } + +} \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h b/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h new file mode 100644 index 00000000..a9a590f6 --- /dev/null +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include "Resource/SHHandle.h" + +namespace SHADE +{ + class SHVkDescriptorSetGroup; + class SHVkBuffer; + class SHVkLogicalDevice; + + class SHGraphicsGenericData + { + public: + struct GpuStruct + { + //! Delta time + float dt{ 0.0f }; + + //! Elapsed time of the application + float elapsedTime{ 0.0f }; + + //! Viewport width of the scene (excluding imgui, that means smaller than window) + uint32_t viewportWidth{ 0 }; + + //! Ditto but for height + uint32_t viewportHeight{ 0 }; + }; + private: + + //! This will be access + GpuStruct data; + + //! Buffer to hold the generic data + Handle gpuBuffer; + + //! gpu struct size for GPU to use + uint32_t alignedGpuStructSize; + + public: + void Init (Handle logicalDevice, Handle descSet) noexcept; + void UpdateBuffer(uint32_t frameIndex) noexcept; + + void SetDt (float dt) noexcept; + void UpdateElapsedTime (float dt) noexcept; + void SetViewportWidth(uint32_t width) noexcept; + void SetViewportHeight(uint32_t height) noexcept; + + }; +} + diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp index fd94968e..e079b933 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp @@ -2,11 +2,13 @@ #include "SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/Lights/SHLightingSubSystem.h" #include "Graphics/Commands/SHVkCommandBuffer.h" +#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h" +#include "Graphics/Devices/SHVkLogicalDevice.h" namespace SHADE { - Handle SHGlobalDescriptorSets::staticGlobalDataDescriptorSet; + Handle SHGlobalDescriptorSets::genericAndTextureDataDescSet; Handle SHGlobalDescriptorSets::lightingSubSystem; //void SHGlobalDescriptorSets::BindLightingData(Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept @@ -20,11 +22,13 @@ namespace SHADE lightingSubSystem->BindDescSet(cmdBuffer, setIndex, frameIndex); } - void SHGlobalDescriptorSets::BindStaticGlobalData(Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept + void SHGlobalDescriptorSets::BindGenericAndTextureData(Handle device, Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept { + uint32_t alignedGenericStructSize = device->PadUBOSize(sizeof(SHGraphicsGenericData::GpuStruct)); + // Bind descriptor set for static global data - static std::array TEX_DYNAMIC_OFFSET{ 0 }; - cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); + static std::array TEX_DYNAMIC_OFFSET = { alignedGenericStructSize, }; + cmdBuffer->BindDescriptorSet(genericAndTextureDataDescSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); } /***************************************************************************/ @@ -43,9 +47,9 @@ namespace SHADE lightingSubSystem = system; } - void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle staticGlobalDescSet) noexcept + void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle descSet) noexcept { - staticGlobalDataDescriptorSet = staticGlobalDescSet; + genericAndTextureDataDescSet = descSet; } } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h index 2e2dca7d..4ee09a6a 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h @@ -15,7 +15,7 @@ namespace SHADE private: //! Static global descriptor sets for miscellaneous data and textures - static Handle staticGlobalDataDescriptorSet; + static Handle genericAndTextureDataDescSet; //! Lighting sub system required to get information to bind descriptor sets for light data static Handle lightingSubSystem; @@ -25,7 +25,7 @@ namespace SHADE /* PUBLIC MEMBER FUNCTIONS */ /*-----------------------------------------------------------------------*/ static void BindLightingData (Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept; - static void BindStaticGlobalData (Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept; + static void BindGenericAndTextureData (Handle device, Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept; /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index 63b39c9f..85559bc7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -25,9 +25,10 @@ namespace SHADE { perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings ({ - {SHPredefinedDescriptorTypes::STATIC_DATA, 0}, - {SHPredefinedDescriptorTypes::CAMERA, 1}, - {SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2}, + {SHPredefinedDescriptorTypes::STATIC_DATA, 0}, + {SHPredefinedDescriptorTypes::CAMERA, 1}, + {SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2}, + {SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE, 3}, }); perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descMappings.AddMappings diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h index 38fe9aa3..54b02608 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h @@ -129,11 +129,13 @@ namespace SHADE static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write"; static constexpr std::string_view UI_SUBPASS = "UI"; static constexpr std::string_view VFX_SUBPASS = "VFX"; + static constexpr std::string_view OBJ_VFX_SUBPASS = "Object VFX Subpass No Depth"; static constexpr std::array USABLE_SUBPASSES = { GBUFFER_WRITE_SUBPASS, - UI_SUBPASS + UI_SUBPASS, + OBJ_VFX_SUBPASS }; }; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 297a86ae..f0503741 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -47,6 +47,7 @@ of DigiPen Institute of Technology is prohibited. #include "Events/SHEvent.h" #include "Graphics/MiddleEnd/Lights/SHLightComponent.h" #include "Input/SHInputManager.h" +#include "Assets/Events/SHAssetManagerEvents.h" namespace SHADE { @@ -210,10 +211,11 @@ namespace SHADE renderGraph->Init("World Render Graph", device, swapchain, &resourceManager, renderContextCmdPools); renderGraph->AddResource("Position", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); renderGraph->AddResource("Position World Space", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); + renderGraph->AddResource("Object VFX", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); renderGraph->AddResource("Normals", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); //worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second); - renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint); + renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint); renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc); renderGraph->AddResource("Light Layer Indices", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc); renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second); @@ -235,7 +237,8 @@ namespace SHADE "Depth Buffer", "SSAO", "SSAO Blur", - "Position World Space" + "Position World Space", + "Object VFX" }, {}); // no predecessors @@ -249,9 +252,16 @@ namespace SHADE gBufferSubpass->AddColorOutput("Normals"); gBufferSubpass->AddColorOutput("Albedo"); gBufferSubpass->AddColorOutput("Position World Space"); + gBufferSubpass->AddColorOutput("Object VFX"); gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL); - usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass); + // We add the object VFX render target and depth buffer as input just in case we want to make comparisons + auto objectVfxSubpassNoDepth = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data(), worldViewport, worldRenderer); + objectVfxSubpassNoDepth->AddColorOutput("Object VFX"); + objectVfxSubpassNoDepth->AddInput ("Depth Buffer"); + + usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass); + usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data()), objectVfxSubpassNoDepth); /*-----------------------------------------------------------------------*/ /* SSAO PASS AND DATA INIT */ @@ -297,15 +307,15 @@ namespace SHADE "Albedo", "Scene", "SSAO Blur", - "Position World Space" + "Position World Space", + "Object VFX" }, { SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS .data()}); - /*-----------------------------------------------------------------------*/ /* DEFERRED COMPOSITE SUBPASS INIT */ /*-----------------------------------------------------------------------*/ - auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Position World Space", "Scene"}, {}, SHLightingSubSystem::MAX_SHADOWS); + auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Position World Space", "Scene", "Object VFX"}, {}, SHLightingSubSystem::MAX_SHADOWS); deferredCompositeCompute->AddPreComputeFunction([=](Handle cmdBuffer, uint32_t frameIndex) { lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer); @@ -340,10 +350,17 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* SCREEN SPACE PASS */ /*-----------------------------------------------------------------------*/ - auto screenSpaceNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data(), {"Scene", "Entity ID"}, {SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW.data()}); + auto screenSpaceNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data(), { "Scene", "Entity ID", "Depth Buffer" }, + { + SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(), + SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), + SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW.data(), + SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW_DEPTH_PASS.data() + }); auto uiSubpass = screenSpaceNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS.data(), worldViewport, screenRenderer); uiSubpass->AddColorOutput("Scene"); uiSubpass->AddColorOutput("Entity ID"); + uiSubpass->AddDepthOutput("Depth Buffer"); uiSubpass->AddExteriorDrawCalls([=](Handle cmdBuffer, Handle renderer, uint32_t frameIndex) { textRenderingSubSystem->Render(cmdBuffer, renderer, frameIndex); @@ -409,7 +426,6 @@ namespace SHADE InitRenderGraph(); - // Create Semaphore for (auto& semaHandle : graphSemaphores) { @@ -491,12 +507,34 @@ namespace SHADE void SHGraphicsSystem::InitEvents(void) noexcept { - std::shared_ptr> thisReceiver + std::shared_ptr> lightEnableShadowReceiver { std::make_shared>(this, &SHGraphicsSystem::ReceiveLightEnableShadowEvent) }; - ReceiverPtr receiver = std::dynamic_pointer_cast(thisReceiver); - SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, receiver); + ReceiverPtr lightEnableShadowReceivePtr = std::dynamic_pointer_cast(lightEnableShadowReceiver); + SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, lightEnableShadowReceivePtr); + + std::shared_ptr> compileAssetReceiever + { + std::make_shared>(this, &SHGraphicsSystem::ReceiveCompileAssetEvent) + }; + ReceiverPtr compileAssetReceivePtr = std::dynamic_pointer_cast(compileAssetReceiever); + SHEventManager::SubscribeTo(SH_ASSET_COMPILE_EVENT, compileAssetReceivePtr); + } + + void SHGraphicsSystem::InitGenericDataAndTexturesDescSet(void) noexcept + { + // descriptor set for generic data and textures + genericAndTextureDescSet = descPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA), { SHTextureLibrary::DEFAULT_MAX_TEXTURES }); + + for (auto set : genericAndTextureDescSet->GetVkHandle()) + SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals"); + + SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(genericAndTextureDescSet); + + // Create buffer for generic data and attach to descriptor set + graphicsGenericData.Init(device, genericAndTextureDescSet); + } /*---------------------------------------------------------------------------------*/ @@ -507,6 +545,7 @@ namespace SHADE InitBoilerplate(); InitMiddleEnd(); InitSubsystems(); + InitGenericDataAndTexturesDescSet(); InitBuiltInResources(); InitEvents(); } @@ -536,7 +575,7 @@ namespace SHADE */ /***************************************************************************/ - void SHGraphicsSystem::Run(double) noexcept + void SHGraphicsSystem::Run(double dt) noexcept { if (window->IsMinimized() || renderContext.GetWindowIsDead()) { @@ -572,6 +611,9 @@ namespace SHADE auto cameraSystem = SHSystemManager::GetSystem(); + graphicsGenericData.SetDt(dt); + graphicsGenericData.UpdateElapsedTime(dt); + graphicsGenericData.UpdateBuffer(frameIndex); { #ifdef SHEDITOR @@ -860,6 +902,29 @@ namespace SHADE return eventPtr->handle; } + SHEventHandle SHGraphicsSystem::ReceiveCompileAssetEvent(SHEventPtr eventPtr) noexcept + { + auto const& EVENT_DATA = reinterpret_cast*>(eventPtr.get())->data; + + // check for asset type + if (EVENT_DATA->assetType == AssetType::SHADER) + { + // loop through all shaders + auto denseIterators = SHVkInstance::GetResourceManager().GetDenseAccess(); + for (auto it = denseIterators.first; it != denseIterators.second; ++it) + { + if (it->GetName() == EVENT_DATA->assetName) + { + auto* shaderAsset = SHAssetManager::GetData(EVENT_DATA->assetID); + it->OnChange(shaderAsset->spirvBinary); + break; + } + } + } + + return eventPtr->handle; + } + Handle SHGraphicsSystem::AddMaterial(Handle vertShader, Handle fragShader, Handle subpass) { // Retrieve pipeline from pipeline storage or create if unavailable @@ -980,12 +1045,11 @@ namespace SHADE device->WaitIdle(); texLibrary.BuildTextures ( - device, graphicsTexCmdBuffer, graphicsQueue, descPool + device, graphicsTexCmdBuffer, graphicsQueue, genericAndTextureDescSet ); device->WaitIdle(); graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {}; - SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup()); - + //SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup()); } Handle SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const @@ -1134,6 +1198,10 @@ namespace SHADE resizeWidth = newWidth; resizeHeight = newHeight; + graphicsGenericData.SetViewportWidth(resizeWidth); + graphicsGenericData.SetViewportHeight(resizeHeight); + + renderContext.SetIsResized(true); } @@ -1177,7 +1245,7 @@ namespace SHADE auto cameraSystem = SHSystemManager::GetSystem(); #ifdef SHEDITOR cameraSystem->GetEditorCamera()->SetWidth(static_cast(resizeWidth)); - cameraSystem->GetEditorCamera()->SetHeight(static_cast(resizeHeight)); + //cameraSystem->GetEditorCamera()->SetAspectRatio(static_cast(resizeWidth) / static_cast(resizeHeight)); // Create new event and broadcast it SHWindowResizeEvent newEvent; @@ -1186,8 +1254,14 @@ namespace SHADE SHEventManager::BroadcastEvent(newEvent, SH_WINDOW_RESIZE_EVENT); -#else +#else + // Create new event and broadcast it + SHWindowResizeEvent newEvent; + newEvent.resizeWidth = resizeWidth; + newEvent.resizeHeight = resizeHeight; + + SHEventManager::BroadcastEvent(newEvent, SH_WINDOW_RESIZE_EVENT); #endif } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index 21d18be1..0b98f843 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -37,6 +37,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/MiddleEnd/Interface/SHRenderer.h" #include "Graphics/Events/SHGraphicsEvents.h" #include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.h" +#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h" namespace SHADE { @@ -106,6 +107,7 @@ namespace SHADE void InitSubsystems (void) noexcept; void InitBuiltInResources (void); void InitEvents (void) noexcept; + void InitGenericDataAndTexturesDescSet (void) noexcept; public: class SH_API BeginRoutine final : public SHSystemRoutine @@ -181,6 +183,11 @@ namespace SHADE /*-----------------------------------------------------------------------*/ SHEventHandle ReceiveLightEnableShadowEvent (SHEventPtr eventPtr) noexcept; + /*-----------------------------------------------------------------------*/ + /* Asset Events */ + /*-----------------------------------------------------------------------*/ + SHEventHandle ReceiveCompileAssetEvent (SHEventPtr eventPtr) noexcept; + /*-----------------------------------------------------------------------------*/ /* Material Functions */ /*-----------------------------------------------------------------------------*/ @@ -433,6 +440,7 @@ namespace SHADE SHResourceHub resourceManager; SHMeshLibrary meshLibrary; SHTextureLibrary texLibrary; + SHGraphicsGenericData graphicsGenericData; SHFontLibrary fontLibrary; SHSamplerCache samplerCache; SHMaterialInstanceCache materialInstanceCache; @@ -490,6 +498,8 @@ namespace SHADE Handle debugDrawFilledDepthPipeline; Handle shadowMapPipeline; // initialized only when a shadow map is needed + Handle genericAndTextureDescSet; + // Built-In Textures Handle defaultTexture; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp index e1935634..0452e4e9 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp @@ -14,6 +14,7 @@ #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h" #include "Scene/SHSceneManager.h" +#include "UI/SHUIComponent.h" namespace SHADE { @@ -197,7 +198,7 @@ namespace SHADE cmdBuffer->BindPipeline(pipeline); // Bind global data - SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex); + SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex); // Bind camera data renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex); @@ -209,7 +210,12 @@ namespace SHADE cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0); - cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS); + if (auto* uiComp = SHComponentManager::GetComponent_s(comp.GetEID())) + cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS); + else + cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS); + + cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS); cmdBuffer->SetPushConstantVariable("TestPushConstant.textColor", SHVec3 (1.0f, 1.0f, 1.0f), SH_PIPELINE_TYPE::GRAPHICS); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp index 0578e7a2..fd2f3ac7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp @@ -63,7 +63,7 @@ namespace SHADE isDirty = true; } - void SHTextureLibrary::BuildTextures(Handle device, Handle cmdBuffer, Handle graphicsQueue, Handle descPool) + void SHTextureLibrary::BuildTextures(Handle device, Handle cmdBuffer, Handle graphicsQueue, Handle descSet/*, Handle descPool*/) { // Don't do anything if there are no updates if (!isDirty) @@ -162,27 +162,28 @@ namespace SHADE /* Build Descriptor Set with all the Textures only if there are textures */ if (!texOrder.empty()) { - if (texDescriptors) - { - texDescriptors.Free(); - } - texDescriptors = descPool->Allocate - ( - { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) }, - { static_cast(texOrder.size()) } - ); -#ifdef _DEBUG - for (auto set : texDescriptors->GetVkHandle()) - SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals"); -#endif + +// if (descSet) +// { +// descSet.Free(); +// } +// descSet = descPool->Allocate +// ( +// { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) }, +// { static_cast(texOrder.size()) } +// ); +//#ifdef _DEBUG +// for (auto set : descSet->GetVkHandle()) +// SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals"); +//#endif static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0; - texDescriptors->ModifyWriteDescImage + descSet->ModifyWriteDescImage ( TEX_DESCRIPTOR_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA, combinedImageSamplers ); - texDescriptors->UpdateDescriptorSetImages + descSet->UpdateDescriptorSetImages ( TEX_DESCRIPTOR_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h index 5b7e4914..bbc72a1a 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h @@ -66,6 +66,13 @@ namespace SHADE class SHTextureLibrary { public: + //! This exists because a poor decision was made to place the textures and + //! generic data as 2 bindings in a single layout. Because of this, the recreation + //! of the texture library would mean the recreation of the desc set that also + //! involves the generic data, which is bad bad bad. Solution is to separate the + //! 2 desc sets. + static constexpr uint32_t DEFAULT_MAX_TEXTURES = 2000; + /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/ @@ -112,7 +119,7 @@ namespace SHADE /*! \brief - Finalises all changes to the Texture Library into the GPU buffers. + Finalizes all changes to the Texture Library into the GPU buffers. \param device Device used to create and update the buffers. @@ -123,12 +130,12 @@ namespace SHADE queue. */ /***************************************************************************/ - void BuildTextures(Handle device, Handle cmdBuffer, Handle graphicsQueue, Handle descPool); + void BuildTextures(Handle device, Handle cmdBuffer, Handle graphicsQueue, Handle descSet/*, Handle descPool*/); /*-----------------------------------------------------------------------------*/ /* Getter Functions */ /*-----------------------------------------------------------------------------*/ - Handle GetTextureDescriptorSetGroup() const noexcept { return texDescriptors; } + //Handle GetTextureDescriptorSetGroup() const noexcept { return descSet; } /***************************************************************************/ /*! * @@ -173,8 +180,8 @@ namespace SHADE std::vector> texOrder; // CPU Storage std::vector, Handle, vk::ImageLayout>> combinedImageSamplers; - // GPU Storage - Handle texDescriptors; + //// GPU Storage + //Handle descSet; // Flags bool isDirty = true; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp index 740ffa92..802d085d 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp @@ -164,7 +164,7 @@ namespace SHADE cmdBuffer->BindPipeline(pipeline); // Bind global data - SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex); + SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex); // Bind camera data renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex); diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipeline.cpp b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipeline.cpp index 973ae72f..dd050627 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipeline.cpp +++ b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipeline.cpp @@ -235,6 +235,9 @@ namespace SHADE , pipelineLayout { inPipelineLayout } , created {false} { + if (pipelineLayout) + pipelineLayout->AddCallback([this]() {ConstructPipeline();}); + // We want to create a pipeline if (state != nullptr) { @@ -359,7 +362,10 @@ namespace SHADE { // if it was created before, destroy it if (created) + { + logicalDeviceHdl->WaitIdle(); logicalDeviceHdl->GetVkLogicalDevice().destroyPipeline(vkPipeline, nullptr); + } // Set to false again. If creation succeeds after this, this will be true created = false; diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp index 6a6ef879..fa9bf6bf 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp +++ b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp @@ -298,6 +298,10 @@ namespace SHADE descriptorSetLayoutsAllocate.clear(); + dynamicBufferBindings.clear(); + + descriptorSetLayoutsPipeline.clear(); + // We don't need to use vulkan to destroy descriptor sets here since they are just owned by the container with handles vkDescriptorSetLayoutsAllocate.clear(); vkDescriptorSetLayoutsPipeline.clear(); @@ -450,6 +454,15 @@ namespace SHADE } else SHVulkanDebugUtil::ReportVkSuccess("Successfully created Pipeline Layout. "); + + // Call callbacks + for (auto& callback : onChangeCallbacks) + callback(); + } + + void SHVkPipelineLayout::AddCallback(ChangeCallback&& callback) noexcept + { + onChangeCallbacks.emplace_back(std::move(callback)); } std::vector> const& SHVkPipelineLayout::GetShaderModules(void) const noexcept diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.h b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.h index e2af02a9..a856700b 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.h +++ b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.h @@ -10,6 +10,9 @@ namespace SHADE class SHVkPipelineLayout { + public: + using ChangeCallback = std::function; + private: /*-----------------------------------------------------------------------*/ /* PRIVATE MEMBER VARIABLES */ @@ -51,6 +54,12 @@ namespace SHADE //! Store for pipeline layout recreation std::vector vkDescriptorSetLayoutsPipeline; + //! When pipeline layout needs to be recreated, this container could serve as an event + //! response to call all the functions that need to be called. Specifically + //! pipelines that need to use the new pipeline layout + std::vector onChangeCallbacks; + + /*-----------------------------------------------------------------------*/ /* PRIVATE MEMBER FUNCTIONS */ /*-----------------------------------------------------------------------*/ @@ -73,6 +82,7 @@ namespace SHADE /* PUBLIC MEMBER FUNCTIONS */ /*-----------------------------------------------------------------------*/ void RecreateIfNeeded (void) noexcept; + void AddCallback(ChangeCallback&& callback) noexcept; /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index c312535e..ea650274 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -512,8 +512,9 @@ namespace SHADE uint32_t h = static_cast(resource->GetHeight()); cmdBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); - static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0; - newSubpass->BindInputDescriptorSets (cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex); + //static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0; + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); + newSubpass->BindInputDescriptorSets (cmdBuffer, mappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex); // draw a quad. cmdBuffer->DrawArrays(4, 1, 0, 0); @@ -570,9 +571,10 @@ namespace SHADE auto cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginLabeledSegment(name); - auto batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); + auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); - // Force bind pipeline layout + + // Force bind pipeline layout cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); @@ -584,7 +586,7 @@ namespace SHADE if (node->renderpass) { // bind static global data - SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA)); + SHGlobalDescriptorSets::BindGenericAndTextureData(renderGraphStorage->logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex); // Bind all the buffers required for meshes for (auto& [buffer, bindingPoint] : MESH_DATA) diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp index b0d83172..e5cc231c 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp @@ -184,12 +184,13 @@ namespace SHADE for (auto& inputAtt : subpass->inputReferences) { auto resource = attResources[inputAtt.attachment]; - if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT)) + auto typeFlags = resource->resourceTypeFlags; + if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT)) { - if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) || - resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) + if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) || + typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) colorRead |= (1 << i); - else if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL)) + else if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL) || typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH)) depthRead |= (1 << i); } else @@ -265,6 +266,7 @@ namespace SHADE // initialize input descriptors subpasses[i]->CreateInputDescriptors(); + subpasses[i]->GenerateDummyPipielineLayout(); ++i; } @@ -664,7 +666,7 @@ namespace SHADE commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); // bind static global data - SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA)); + SHGlobalDescriptorSets::BindGenericAndTextureData(graphStorage->logicalDevice, commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex); // bind lighting data SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 96207d7a..d45789ce 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -226,11 +226,15 @@ namespace SHADE commandBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); } + commandBuffer->ForceSetPipelineLayout(dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); if (renderer) renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex); + BindInputDescriptorSets (commandBuffer, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex); + // If companion subpass is not a valid handle, render super batch normally if (!companionSubpass.companion) { @@ -439,6 +443,33 @@ namespace SHADE } } + /***************************************************************************/ + /*! + + \brief + Generates the dummy pipeline layout for subpass; specifically add the + input descriptor set layout if it exists. + + + \return + + */ + /***************************************************************************/ + void SHSubpass::GenerateDummyPipielineLayout(void) noexcept + { + auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); + std::vector newLayouts = batchingSystemData.descSetLayouts; + if (inputDescriptorLayout) + { + newLayouts.push_back(inputDescriptorLayout); + } + + dummyPipelineLayout = graphStorage->logicalDevice->CreatePipelineLayoutDummy + ( + SHPipelineLayoutParamsDummy{ newLayouts } + ); + } + /***************************************************************************/ /*! diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index 811cc70c..1300ee2b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -22,6 +22,7 @@ namespace SHADE class SHRenderer; class SHViewport; class SHVkPipeline; + class SHVkPipelineLayout; class SH_API SHSubpass : public ISelfHandle { @@ -87,6 +88,12 @@ namespace SHADE std::vector> inputSamplers; + //! Dummy pipeline layout for subpass to bind before draw. + //! // IMPORTANT NOTE: After implementing input descriptors, every subpass differs in number input descriptors. + //! Before binding the input descriptors, a pipeline layout containing the desc set layouts + //! for the input descriptors is required, making this umbrella initial dummy bind invalid. + Handle dummyPipelineLayout; + ////! subpass compute image barriers. We do this because every frame has a different ////! swapchain image. If the resource we want to transition is not a swapchain image, @@ -146,6 +153,7 @@ namespace SHADE //void InitComputeBarriers (void) noexcept; void CreateInputDescriptors (void) noexcept; void UpdateWriteDescriptors (void) noexcept; + void GenerateDummyPipielineLayout (void) noexcept; private: /*-----------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp index 74128ec8..89cd2927 100644 --- a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp +++ b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp @@ -40,7 +40,7 @@ namespace SHADE if (SHVkUtil::IsDepthStencilAttachment(vkDescriptions[i].format)) clearColors[i].depthStencil = vk::ClearDepthStencilValue(1.0f, 0); else - clearColors[i].color = { {{0.0f, 0.0f, 0.0f, 1.0f}} }; + clearColors[i].color = { {{0.0f, 0.0f, 0.0f, 0.0f}} }; } diff --git a/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.cpp b/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.cpp index fa6b3182..030909af 100644 --- a/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.cpp +++ b/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.cpp @@ -7,20 +7,16 @@ namespace SHADE { - SHVkShaderModule::SHVkShaderModule(Handle const& inLogicalDeviceHdl, std::vector const& binaryData, std::string inEntryPoint, vk::ShaderStageFlagBits stage, std::string const& name) noexcept - : logicalDeviceHdl {inLogicalDeviceHdl} - , shaderStage {stage} - , entryPoint {inEntryPoint} - , vkShaderModule {nullptr} - , spirvBinary{} - , shaderName {name} - , reflectedData {} + void SHVkShaderModule::Recompile(void) noexcept { + if (vkShaderModule) + logicalDeviceHdl->GetVkLogicalDevice().destroyShaderModule(vkShaderModule, nullptr); + // Prepare the create info vk::ShaderModuleCreateInfo moduleCreateInfo { - .codeSize = binaryData.size() * sizeof (uint32_t), - .pCode = binaryData.data(), + .codeSize = spirvBinary.size() * sizeof(uint32_t), + .pCode = spirvBinary.data(), }; if (auto result = logicalDeviceHdl->GetVkLogicalDevice().createShaderModule(&moduleCreateInfo, nullptr, &vkShaderModule); result != vk::Result::eSuccess) @@ -30,10 +26,18 @@ namespace SHADE } else SHVulkanDebugUtil::ReportVkSuccess("Successfully created shader module."); + } - // TODO: Right now, this is doing a copy, we need to figure out if its better to just move from the resource management (source library) instead. The hope is that - // shader modules only need 1 of themselves. - spirvBinary = binaryData; + SHVkShaderModule::SHVkShaderModule(Handle const& inLogicalDeviceHdl, std::vector const& binaryData, std::string inEntryPoint, vk::ShaderStageFlagBits stage, std::string const& name) noexcept + : logicalDeviceHdl {inLogicalDeviceHdl} + , shaderStage {stage} + , entryPoint {inEntryPoint} + , vkShaderModule {nullptr} + , spirvBinary{binaryData} + , shaderName {name} + , reflectedData {} + { + Recompile(); } SHVkShaderModule::SHVkShaderModule(SHVkShaderModule&& rhs) noexcept @@ -81,13 +85,18 @@ namespace SHADE } } - void SHVkShaderModule::OnChange(void) noexcept + void SHVkShaderModule::OnChange(std::vector const& newBinaryData) noexcept { + // assign new binary data and recompile shader + spirvBinary = newBinaryData; + + Recompile(); + for (auto& callback : onChangeCallbacks) callback(); } - void SHVkShaderModule::AddCallback(SHShaderChangeCallback&& callback) noexcept + void SHVkShaderModule::AddCallback(ChangeCallback&& callback) noexcept { onChangeCallbacks.emplace_back(std::move(callback)); } @@ -112,4 +121,9 @@ namespace SHADE return reflectedData; } + std::string SHVkShaderModule::GetName(void) const noexcept + { + return shaderName; + } + } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.h b/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.h index 492710f2..341b1706 100644 --- a/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.h +++ b/SHADE_Engine/src/Graphics/Shaders/SHVkShaderModule.h @@ -16,7 +16,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* TYPE DEFINITIONS */ /*-----------------------------------------------------------------------*/ - using SHShaderChangeCallback = std::function; + using ChangeCallback = std::function; private: /*-----------------------------------------------------------------------*/ @@ -47,12 +47,13 @@ namespace SHADE //! response to call all the functions that need to be called. Specifically //! pipeline layouts that need to re-parse the newly reflected data and create //! descriptor set layouts and push constant ranges. - std::vector onChangeCallbacks; + std::vector onChangeCallbacks; // #NoteToSelf: From Tomas module, pipeline shader stage create info isn't created here // because the struct allows specialization info which should not be part of a module itself. // This struct should be created in the pipeline instead. + void Recompile (void) noexcept; public: /*-----------------------------------------------------------------------*/ @@ -67,8 +68,8 @@ namespace SHADE /* PUBLIC MEMBER FUNCTIONS */ /*-----------------------------------------------------------------------*/ void Reflect (void) noexcept; - void OnChange (void) noexcept; - void AddCallback (SHShaderChangeCallback&& callback) noexcept; + void OnChange (std::vector const& newBinaryData) noexcept; + void AddCallback (ChangeCallback&& callback) noexcept; /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ @@ -77,6 +78,7 @@ namespace SHADE vk::ShaderStageFlagBits GetShaderStageFlagBits (void) const noexcept; vk::ShaderModule GetVkShaderModule (void) const noexcept; SHShaderReflected const& GetReflectedData (void) const noexcept; + std::string GetName (void) const noexcept; }; } diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index 2f0ab6d6..dd3cfe80 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -14,6 +14,9 @@ #include #include "SHInputManager.h" #include "../Tools/SHException.h" +#include +#include +#include namespace SHADE { @@ -21,6 +24,7 @@ namespace SHADE /* Static defines */ /*------------------------------------------------------------------------*/ + bool SHInputManager::mouseCentering = false; bool SHInputManager::controllerInUse = false; std::map SHInputManager::bindings; @@ -751,6 +755,7 @@ namespace SHADE { ++keyCount; keys[i] = true; + controllerInUse = false; } else keys[i] = false; @@ -801,6 +806,25 @@ namespace SHADE mouseVelocityX = static_cast(mouseScreenX - mouseScreenXLast) / dt; mouseVelocityY = static_cast(mouseScreenY - mouseScreenYLast) / dt; + + //Mouse Centering + if (mouseCentering) + { + uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth(); + uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight(); + SetMouseWindowPosition(width / 2, height / 2); + + //These four lines help a lot + POINT p; + GetCursorPos(&p); + mouseVelocityX -= static_cast(p.x - mouseScreenX) / dt; + mouseVelocityY -= static_cast(p.y - mouseScreenY) / dt; + } + + if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0) + controllerInUse = false; + + //Mouse wheel vertical delta updating mouseWheelVerticalDelta = 0; mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll; diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 1bcafa7d..dcfcdf57 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -1074,6 +1074,18 @@ namespace SHADE SetCursorPos(p.x, p.y); } + //Call to set the flag to start mouse centering every frame + static inline void SetMouseCentering(bool state) noexcept + { + mouseCentering = state; + } + + //Get the flag whether mouse centering is on or not + static inline bool GetMouseCentering() noexcept + { + return mouseCentering; + } + private: /*------------------------------------------------------------------------*/ /* Constants */ @@ -1097,6 +1109,9 @@ namespace SHADE /* Data Members */ /*------------------------------------------------------------------------*/ + //Whether mouse centering will be called every frame or not + static bool mouseCentering; + //If the last input is from controller(s) or KB/M //True if from controller(s), False if from KB/M //Useful for switching control hints between controllers and KB/M diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp index 22c7c12e..bd2cfea5 100644 --- a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp +++ b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp @@ -369,6 +369,27 @@ namespace SHADE return eventData->handle; } + SHEventHandle SHScriptEngine::onUIElementReleased(SHEventPtr eventPtr) + { + auto eventData = reinterpret_cast*>(eventPtr.get()); + csUIElementOnReleased(eventData->data->EID); + return eventData->handle; + } + + SHEventHandle SHScriptEngine::onUIElementOnHoverEntered(SHEventPtr eventPtr) + { + auto eventData = reinterpret_cast*>(eventPtr.get()); + csUIElementOnHoverEntered(eventData->data->EID); + return eventData->handle; + } + + SHEventHandle SHScriptEngine::onUIElementOnHoverExited(SHEventPtr eventPtr) + { + auto eventData = reinterpret_cast*>(eventPtr.get()); + csUIElementOnHoverExited(eventData->data->EID); + return eventData->handle; + } + SHEventHandle SHScriptEngine::onSceneNodeChildrenAdded(SHEventPtr eventPtr) { auto eventData = reinterpret_cast*>(eventPtr.get()); @@ -539,6 +560,24 @@ namespace SHADE DEFAULT_CSHARP_NAMESPACE + ".UIElement", "OnClicked" ); + csUIElementOnReleased = dotNet.GetFunctionPtr + ( + DEFAULT_CSHARP_LIB_NAME, + DEFAULT_CSHARP_NAMESPACE + ".UIElement", + "OnReleased" + ); + csUIElementOnHoverEntered = dotNet.GetFunctionPtr + ( + DEFAULT_CSHARP_LIB_NAME, + DEFAULT_CSHARP_NAMESPACE + ".UIElement", + "OnHoverEntered" + ); + csUIElementOnHoverExited = dotNet.GetFunctionPtr + ( + DEFAULT_CSHARP_LIB_NAME, + DEFAULT_CSHARP_NAMESPACE + ".UIElement", + "OnHoverExited" + ); csEditorRenderScripts = dotNet.GetFunctionPtr ( DEFAULT_CSHARP_LIB_NAME, @@ -608,6 +647,21 @@ namespace SHADE std::make_shared>(this, &SHScriptEngine::onUIElementClicked) }; SHEventManager::SubscribeTo(SH_BUTTON_CLICK_EVENT, std::dynamic_pointer_cast(clickedUIElementEventReceiver)); + std::shared_ptr> releasedUIElementEventReceiver + { + std::make_shared>(this, &SHScriptEngine::onUIElementReleased) + }; + SHEventManager::SubscribeTo(SH_BUTTON_RELEASE_EVENT, std::dynamic_pointer_cast(releasedUIElementEventReceiver)); + std::shared_ptr> hoverEnterUIElementEventReceiver + { + std::make_shared>(this, &SHScriptEngine::onUIElementOnHoverEntered) + }; + SHEventManager::SubscribeTo(SH_BUTTON_HOVER_ENTER_EVENT, std::dynamic_pointer_cast(hoverEnterUIElementEventReceiver)); + std::shared_ptr> hoverExitedUIElementEventReceiver + { + std::make_shared>(this, &SHScriptEngine::onUIElementOnHoverExited) + }; + SHEventManager::SubscribeTo(SH_BUTTON_HOVER_EXIT_EVENT, std::dynamic_pointer_cast(hoverExitedUIElementEventReceiver)); /* SceneGraph */ // Register for SceneNode child added event diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.h b/SHADE_Engine/src/Scripting/SHScriptEngine.h index 9b234d04..b207ae64 100644 --- a/SHADE_Engine/src/Scripting/SHScriptEngine.h +++ b/SHADE_Engine/src/Scripting/SHScriptEngine.h @@ -292,6 +292,9 @@ namespace SHADE CsEventRelayFuncPtr csSceneNodeChildrenChanged = nullptr; CsEventRelayFuncPtr csUIElementOnRemoved = nullptr; CsEventRelayFuncPtr csUIElementOnClicked = nullptr; + CsEventRelayFuncPtr csUIElementOnReleased = nullptr; + CsEventRelayFuncPtr csUIElementOnHoverEntered = nullptr; + CsEventRelayFuncPtr csUIElementOnHoverExited = nullptr; // - Editor CsScriptEditorFuncPtr csEditorRenderScripts = nullptr; CsFuncPtr csEditorUndo = nullptr; @@ -306,6 +309,9 @@ namespace SHADE SHEventHandle onColliderComponentRemoved(SHEventPtr eventPtr); SHEventHandle onUIElementRemoved(SHEventPtr eventPtr); SHEventHandle onUIElementClicked(SHEventPtr eventPtr); + SHEventHandle onUIElementReleased(SHEventPtr eventPtr); + SHEventHandle onUIElementOnHoverEntered(SHEventPtr eventPtr); + SHEventHandle onUIElementOnHoverExited(SHEventPtr eventPtr); SHEventHandle onSceneNodeChildrenAdded(SHEventPtr eventPtr); SHEventHandle onSceneNodeChildrenRemoved(SHEventPtr eventPtr); SHEventHandle onSceneDestroyed(SHEventPtr eventPtr); diff --git a/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.cpp b/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.cpp index 8ab098b8..b19a20df 100644 --- a/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.cpp +++ b/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.cpp @@ -1,13 +1,29 @@ #include "SHpch.h" #include "SHPrefabManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" +#include "Assets/SHAssetManager.h" +#include "Assets/Asset Types/SHPrefabAsset.h" +#include "Serialization/SHSerialization.h" namespace SHADE { SHPrefabManager::PrefabMap SHPrefabManager::prefabMap{}; + AssetID SHPrefabManager::GetPrefabAssetID(EntityID eid) noexcept + { + for(auto const& [assetId, entityList] : prefabMap) + { + if(std::ranges::find(entityList, eid) != entityList.end()) + { + return assetId; + } + } + return 0; + } + void SHPrefabManager::AddPrefab(AssetID const& prefabAssetID) noexcept { - prefabMap.insert({ prefabAssetID, {} }); + prefabMap[prefabAssetID] = {}; } void SHPrefabManager::RemovePrefab(AssetID const& prefabAssetID) noexcept @@ -30,20 +46,30 @@ namespace SHADE void SHPrefabManager::AddEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept { - if (prefabMap.contains(prefabAssetID)) - { - prefabMap[prefabAssetID].insert(eid); - } + + prefabMap[prefabAssetID].push_back(eid); + } void SHPrefabManager::RemoveEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept { if (prefabMap.contains(prefabAssetID)) { - prefabMap[prefabAssetID].erase(eid); + (void)std::ranges::remove(prefabMap[prefabAssetID], eid); } } + void SHPrefabManager::SaveEntityAsPrefab(EntityID const& eid) noexcept + { + SHEntity* const entity = SHEntityManager::GetEntityByID(eid); + AssetID const assetID = SHAssetManager::CreateNewAsset(AssetType::PREFAB, entity->name); + AddEntity(assetID, eid); + auto assetData = SHAssetManager::GetData(assetID); + assetData->data = SHSerialization::SerializeEntityToString(eid); + + SHAssetManager::SaveAsset(assetID); + } + void SHPrefabManager::Clear() noexcept { prefabMap.clear(); diff --git a/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.h b/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.h index 37c317ed..64e8f24f 100644 --- a/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.h +++ b/SHADE_Engine/src/Serialization/Prefab/SHPrefabManager.h @@ -2,7 +2,8 @@ #include "Assets/SHAssetMacros.h" #include "ECS_Base/SHECSMacros.h" -#include +#include "ECS_Base/General/SHFamily.h" +#include "ECS_Base/Components/SHComponent.h" #include @@ -11,18 +12,34 @@ namespace SHADE class SHPrefabManager { public: - using PrefabMap = std::unordered_map>; + + enum class PrefabEntityComponentStatus : uint8_t + { + PES_UNCHANGED = 0, + PES_MODIFIED, + PES_ADDED, + PES_REMOVED + }; + using PrefabMap = std::unordered_map>; + using PrefabEntitiesComponentStatusData = std::unordered_map,PrefabEntityComponentStatus>>; + + static AssetID GetPrefabAssetID(EntityID eid) noexcept; static void AddPrefab(AssetID const& prefabAssetID) noexcept; static void RemovePrefab(AssetID const& prefabAssetID) noexcept; static void ClearPrefab(AssetID const& prefabAssetID) noexcept; static void UpdateAllPrefabEntities(AssetID const& prefabAssetID) noexcept; static void AddEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept; static void RemoveEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept; + static void SaveEntityAsPrefab(EntityID const& eid) noexcept; static void Clear() noexcept; static bool Empty() noexcept; private: static PrefabMap prefabMap; + static PrefabEntitiesComponentStatusData prefabEntitiesComponentStatusData; + + friend class SHSerialization; + friend struct SHSerializationHelper; }; } diff --git a/SHADE_Engine/src/Serialization/SHSerialization.cpp b/SHADE_Engine/src/Serialization/SHSerialization.cpp index febca024..29fb8cd7 100644 --- a/SHADE_Engine/src/Serialization/SHSerialization.cpp +++ b/SHADE_Engine/src/Serialization/SHSerialization.cpp @@ -15,6 +15,7 @@ #include "ECS_Base/Managers/SHSystemManager.h" #include "Scripting/SHScriptEngine.h" #include "Tools/FileIO/SHFileIO.h" +#include "Prefab/SHPrefabManager.h" namespace SHADE { @@ -23,7 +24,7 @@ namespace SHADE auto assetData = SHAssetManager::GetData(sceneAssetID); if(!assetData) { - SHLOG_ERROR("Asset does not exist: {}", sceneAssetID); + SHLOG_ERROR("Serialization: Asset does not exist: {}", sceneAssetID); return false; } YAML::Emitter out; @@ -45,7 +46,7 @@ namespace SHADE auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); auto root = sceneGraph.GetRoot(); - SHASSERT(root != nullptr, "Root is null. Failed to serialize scene to node."); + SHASSERT(root != nullptr, "Serialization: Root is null. Failed to serialize scene to node."); auto const& children = root->GetChildren(); out << YAML::BeginSeq; @@ -62,6 +63,7 @@ namespace SHADE EntityID eid{MAX_EID}, oldEID{MAX_EID}; if (!node) return eid; + if (node[EIDNode]) oldEID = eid = node[EIDNode].as(); std::string name = "UnnamedEntitiy"; @@ -105,7 +107,7 @@ namespace SHADE auto assetData = SHAssetManager::GetData(sceneAssetID); if(!assetData) { - SHLOG_ERROR("Attempted to load scene that doesn't exist {}", sceneAssetID) + SHLOG_ERROR("Serialization: Attempted to load scene that doesn't exist {}", sceneAssetID) SHSceneManager::SetCurrentSceneAssetID(0); return NewSceneName.data(); } @@ -119,7 +121,7 @@ namespace SHADE } if (createdEntities.empty()) { - SHLOG_ERROR("Failed to create entities from deserializaiton") + SHLOG_ERROR("Serialization: Failed to create entities from deserialization") return NewSceneName.data(); } auto entityVecIt = createdEntities.begin(); @@ -139,13 +141,16 @@ namespace SHADE return assetData->name; } - void SHSerialization::EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out) + void SHSerialization::EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out, bool isPrefab /*= false*/, EntityID* entityIndex /*= nullptr*/) { - out << SerializeEntityToNode(entityNode); + out << SerializeEntityToNode(entityNode, isPrefab, entityIndex); + if(isPrefab) + ++(*entityIndex); + auto const& children = entityNode->GetChildren(); for (auto const& child : children) { - EmitEntity(child, out); + EmitEntity(child, out, isPrefab, entityIndex); } } @@ -155,6 +160,7 @@ namespace SHADE YAML::Node node; auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); out << YAML::BeginSeq; + EntityID entityIndex = 0; for (auto const& eid : entities) { auto entityNode = sceneGraph.GetNode(eid); @@ -164,6 +170,21 @@ namespace SHADE return std::string(out.c_str()); } + std::string SHSerialization::SerializeEntityToString(EntityID eid) noexcept + { + YAML::Emitter out; + YAML::Node node; + auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); + out << YAML::BeginSeq; + EntityID entityIndex = 0; + + auto entityNode = sceneGraph.GetNode(eid); + EmitEntity(entityNode, out, true, &entityIndex); + + out << YAML::EndSeq; + return std::string(out.c_str()); + } + //void SHSerialization::SerializeEntityToFile(std::filesystem::path const& path) //{ //} @@ -179,8 +200,11 @@ namespace SHADE } } - YAML::Node SHSerialization::SerializeEntityToNode(SHSceneNode* sceneNode) + YAML::Node SHSerialization::SerializeEntityToNode(SHSceneNode* sceneNode, bool isPrefab /*= false*/, EntityID* entityIndex /*= nullptr*/) { + if(!sceneNode) + return YAML::Node(); + YAML::Node node; auto eid = sceneNode->GetEntityID(); auto entity = SHEntityManager::GetEntityByID(eid); @@ -190,7 +214,15 @@ namespace SHADE return node; } node.SetStyle(YAML::EmitterStyle::Block); - node[EIDNode] = eid; + + node[EIDNode] = (entityIndex) ? *entityIndex : eid; + + AssetID prefabAssetID = SHPrefabManager::GetPrefabAssetID(eid); + if(prefabAssetID != 0) + { + node[PrefabID] = prefabAssetID; + } + node[EntityNameNode] = entity->name; node[IsActiveNode] = sceneNode->IsActive(); auto const& children = sceneNode->GetChildren(); @@ -209,6 +241,7 @@ namespace SHADE AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); + AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); @@ -236,7 +269,7 @@ namespace SHADE } if (createdEntities.empty()) { - SHLOG_ERROR("Failed to create entities from deserializaiton") + SHLOG_ERROR("Failed to create entities from deserialization") return createdEntities; } //auto entityVecIt = createdEntities.begin(); @@ -269,6 +302,7 @@ namespace SHADE AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); + AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); @@ -353,6 +387,7 @@ namespace SHADE SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); + SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); diff --git a/SHADE_Engine/src/Serialization/SHSerialization.h b/SHADE_Engine/src/Serialization/SHSerialization.h index dd487662..c8971f84 100644 --- a/SHADE_Engine/src/Serialization/SHSerialization.h +++ b/SHADE_Engine/src/Serialization/SHSerialization.h @@ -24,6 +24,7 @@ namespace SHADE constexpr const char* IsActiveNode = "IsActive"; constexpr const char* NumberOfChildrenNode = "NumberOfChildren"; constexpr const char* ScriptsNode = "Scripts"; + constexpr const char* PrefabID = "PrefabID"; class SH_API SHSerialization { @@ -37,12 +38,13 @@ namespace SHADE static std::string DeserializeSceneFromFile(AssetID const& sceneAssetID) noexcept; - - static void EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out); + static void EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out, bool isPrefab = false, EntityID* entityIndex = nullptr); static std::string SerializeEntitiesToString(std::vector const& entities) noexcept; + + static std::string SerializeEntityToString(EntityID eid) noexcept; //static void SerializeEntityToFile(std::filesystem::path const& path); - static YAML::Node SerializeEntityToNode(SHSceneNode* sceneNode); + static YAML::Node SerializeEntityToNode(SHSceneNode* sceneNode, bool isPrefab = false, EntityID* entityIndex = nullptr); static CreatedEntitiesList DeserializeEntitiesFromString(std::string const& data, EntityID const& parentEID = MAX_EID) noexcept; diff --git a/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp b/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp index 08f1262f..a4936528 100644 --- a/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp +++ b/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp @@ -135,6 +135,7 @@ namespace SHADE } } + return YAML::Node(); } template diff --git a/SHADE_Engine/src/UI/SHButtonComponent.cpp b/SHADE_Engine/src/UI/SHButtonComponent.cpp index cbc36ce3..5cc31841 100644 --- a/SHADE_Engine/src/UI/SHButtonComponent.cpp +++ b/SHADE_Engine/src/UI/SHButtonComponent.cpp @@ -28,16 +28,19 @@ namespace SHADE void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept { defaultTexture = texture; + SHResourceManager::LoadOrGet(texture); } void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept { hoveredTexture = texture; + SHResourceManager::LoadOrGet(texture);\ } void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept { clickedTexture = texture; + SHResourceManager::LoadOrGet(texture); } diff --git a/SHADE_Engine/src/UI/SHSliderComponent.cpp b/SHADE_Engine/src/UI/SHSliderComponent.cpp index 56d1d89b..d25fbb6f 100644 --- a/SHADE_Engine/src/UI/SHSliderComponent.cpp +++ b/SHADE_Engine/src/UI/SHSliderComponent.cpp @@ -4,7 +4,7 @@ namespace SHADE { SHSliderComponent::SHSliderComponent() - :size(1.0f), isHovered(false), isClicked(false), value(0.0f) + :value(0.0f) { } diff --git a/SHADE_Engine/src/UI/SHSliderComponent.h b/SHADE_Engine/src/UI/SHSliderComponent.h index bdc57c7e..1eb64205 100644 --- a/SHADE_Engine/src/UI/SHSliderComponent.h +++ b/SHADE_Engine/src/UI/SHSliderComponent.h @@ -17,8 +17,6 @@ namespace SHADE SHSliderComponent(); virtual ~SHSliderComponent() = default; - SHVec2 size; - float GetValue() const noexcept; @@ -29,8 +27,7 @@ namespace SHADE friend class SHUISystem; private: - bool isHovered; - bool isClicked; + float value; diff --git a/SHADE_Engine/src/UI/SHToggleButtonComponent.cpp b/SHADE_Engine/src/UI/SHToggleButtonComponent.cpp index 1ae0e9e0..546a2a26 100644 --- a/SHADE_Engine/src/UI/SHToggleButtonComponent.cpp +++ b/SHADE_Engine/src/UI/SHToggleButtonComponent.cpp @@ -1,6 +1,7 @@ #include "SHpch.h" #include "SHToggleButtonComponent.h" - +#include "Resource/SHResourceManager.h" +#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h" namespace SHADE { @@ -28,11 +29,13 @@ namespace SHADE void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept { defaultTexture = texture; + SHResourceManager::LoadOrGet(texture); } void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept { toggledTexture = texture; + SHResourceManager::LoadOrGet(texture); } void SHToggleButtonComponent::SetValue(bool value) noexcept diff --git a/SHADE_Engine/src/UI/SHUISystem.cpp b/SHADE_Engine/src/UI/SHUISystem.cpp index 3552e47b..05bd9ab5 100644 --- a/SHADE_Engine/src/UI/SHUISystem.cpp +++ b/SHADE_Engine/src/UI/SHUISystem.cpp @@ -204,6 +204,7 @@ namespace SHADE SHButtonClickEvent clickEvent; clickEvent.EID = comp.GetEID(); SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_ENTER_EVENT); + //SHLOG_INFO("C++ BROADCASTED HOVER ENTER EVENT EID: {}", clickEvent.EID); } comp.isHovered = true; @@ -312,7 +313,8 @@ namespace SHADE { auto material = renderable->GetModifiableMaterial(); comp.currentTexture = textureID; - material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet(textureID)); + material->SetProperty("data.textureIndex", SHResourceManager::Get(textureID)->TextureArrayIndex); + } @@ -366,7 +368,8 @@ namespace SHADE { auto material = renderable->GetModifiableMaterial(); comp.currentTexture = textureID; - material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet(textureID)); + material->SetProperty("data.textureIndex", SHResourceManager::Get(textureID)->TextureArrayIndex); + } @@ -374,10 +377,83 @@ namespace SHADE } + void SHUISystem::UpdateSliderComponent(SHSliderComponent& comp) noexcept + { + + + if (!SHComponentManager::HasComponent(comp.GetEID())) + { + return; + } + auto cameraSystem = SHSystemManager::GetSystem(); + auto uiComp = SHComponentManager::GetComponent(comp.GetEID()); + //auto canvasComp = SHComponentManager::GetComponent_s(uiComp->canvasID); + + float tempValue = comp.GetValue(); + + CheckButtonHoveredOrClicked(*uiComp); + + if (uiComp->GetIsClicked() == true) + { + SHVec4 topExtent4 = SHMatrix::Translate(-uiComp->size.x * 0.5f, uiComp->size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); + SHVec4 btmExtent4 = SHMatrix::Translate(uiComp->size.x * 0.5f, -uiComp->size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); + + + SHVec2 topExtent{ topExtent4.x,topExtent4.y }; + SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y }; + auto cameraSystem = SHSystemManager::GetSystem(); + SHVec2 mousePos; + SHVec2 windowSize; +#ifdef SHEDITOR + windowSize = SHEditorWindowManager::GetEditorWindow()->beginContentRegionAvailable; + mousePos = SHEditorWindowManager::GetEditorWindow()->viewportMousePos; + mousePos /= windowSize; +#else + int x, y; + SHInputManager::GetMouseScreenPosition(&x, &y); + mousePos.x = x; + mousePos.y = y; + auto ws = SHSystemManager::GetSystem()->GetWindow()->GetWindowSize(); + windowSize = { static_cast(ws.first), static_cast(ws.second) }; + mousePos /= windowSize; +#endif + + SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) }; + //SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y) + + topExtent = CanvasToScreenPoint(topExtent, true); + btmExtent = CanvasToScreenPoint(btmExtent, true); + + + comp.value = (mousePos.x - topExtent.x) / (btmExtent.x - topExtent.x); + + if (comp.GetValue() > 1.0f) + comp.value = 1.0f; + if (comp.GetValue() < 0.0f) + comp.value = 0.0f; + } + + if (comp.GetValue() != tempValue) + { + //Set shader value. + + auto renderable = SHComponentManager::GetComponent_s(comp.GetEID()); + //auto texture = SHResourceManager::Get(comp.GetDefaultTexture()); + auto material = renderable->GetModifiableMaterial(); + + material->SetProperty("data.sliderThreshold", comp.GetValue()); + + } + + } + + void SHUISystem::UpdateButtonsRoutine::Execute(double dt) noexcept { SHUISystem* system = (SHUISystem*)GetSystem(); auto& dense = SHComponentManager::GetDense(); + //We ensure that the textures are loaded before we do the update. + SHResourceManager::FinaliseChanges(); for (auto& comp : dense) { if (SHSceneManager::CheckNodeAndComponentsActive(comp.GetEID())) @@ -390,6 +466,13 @@ namespace SHADE if (SHSceneManager::CheckNodeAndComponentsActive(comp.GetEID())) system->UpdateToggleButtonComponent(comp); } + + auto& sliderDense = SHComponentManager::GetDense(); + for (auto& comp : sliderDense) + { + if (SHSceneManager::CheckNodeAndComponentsActive(comp.GetEID())) + system->UpdateSliderComponent(comp); + } } SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept @@ -410,6 +493,17 @@ namespace SHADE return result; } + void SHUISystem::HideActiveCanvas() noexcept + { + auto& dense = SHComponentManager::GetDense(); + for (auto& canvas : dense) + { + if (SHSceneManager::CheckNodeAndComponentsActive(canvas.GetEID())) + { + SHSceneManager::GetCurrentSceneGraph().SetActive(canvas.GetEID(), false); + } + } + } diff --git a/SHADE_Engine/src/UI/SHUISystem.h b/SHADE_Engine/src/UI/SHUISystem.h index 3b2bb2cf..70308f3d 100644 --- a/SHADE_Engine/src/UI/SHUISystem.h +++ b/SHADE_Engine/src/UI/SHUISystem.h @@ -66,13 +66,17 @@ namespace SHADE void Init(); void Exit(); + void HideActiveCanvas() noexcept; + private: + bool loadTexture{false}; + void UpdateUIComponent(SHUIComponent& comp) noexcept; void UpdateButtonComponent(SHButtonComponent& comp) noexcept; void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept; void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept; - + void UpdateSliderComponent(SHSliderComponent& comp) noexcept; //returns true on button release. bool CheckButtonHoveredOrClicked(SHUIComponent& comp) noexcept; diff --git a/SHADE_Managed/src/Components/Camera.cxx b/SHADE_Managed/src/Components/Camera.cxx index 0d0dbced..22eb2124 100644 --- a/SHADE_Managed/src/Components/Camera.cxx +++ b/SHADE_Managed/src/Components/Camera.cxx @@ -13,7 +13,6 @@ namespace SHADE } - float Camera::Pitch::get() { return (GetNativeComponent()->GetPitch()); @@ -50,15 +49,8 @@ namespace SHADE { GetNativeComponent()->SetWidth(val); } - float Camera::Height::get() - { - return (GetNativeComponent()->GetHeight()); - } + - void Camera::Height::set(float val) - { - GetNativeComponent()->SetHeight(val); - } float Camera::Near::get() { return (GetNativeComponent()->GetNear()); @@ -133,4 +125,10 @@ namespace SHADE } + Camera^ Camera::GetMainCamera() + { + auto system = SHSystemManager::GetSystem(); + return ECS::GetComponent(system->GetMainCameraEID()); + } + } \ No newline at end of file diff --git a/SHADE_Managed/src/Components/Camera.hxx b/SHADE_Managed/src/Components/Camera.hxx index c6afeb6d..babf2c28 100644 --- a/SHADE_Managed/src/Components/Camera.hxx +++ b/SHADE_Managed/src/Components/Camera.hxx @@ -15,6 +15,9 @@ namespace SHADE Camera(Entity entity); public: + + + property float Pitch { float get(); @@ -35,11 +38,7 @@ namespace SHADE float get(); void set(float val); } - property float Height - { - float get(); - void set(float val); - } + property float Near { float get(); @@ -60,6 +59,7 @@ namespace SHADE Vector3 get(); void set(Vector3 val); } + void SetMainCamera(size_t directorIndex); @@ -68,5 +68,8 @@ namespace SHADE Vector3 GetForward(); Vector3 GetRight(); + + static Camera^ GetMainCamera(); + }; } \ No newline at end of file diff --git a/SHADE_Managed/src/Components/Canvas.cxx b/SHADE_Managed/src/Components/Canvas.cxx new file mode 100644 index 00000000..146b58f7 --- /dev/null +++ b/SHADE_Managed/src/Components/Canvas.cxx @@ -0,0 +1,27 @@ +// Precompiled Headers +#include "SHpch.h" +// Primary Header +#include "Canvas.hxx" +#include "Assets/NativeAsset.hxx" +#include "Utility/Convert.hxx" +#include "Utility/Debug.hxx" + + +#include "ECS_Base/Managers/SHSystemManager.h" +#include "UI/SHUISystem.h" + + +namespace SHADE +{ + Canvas::Canvas(Entity entity) + : Component(entity) + {} + + void Canvas::DeactivateAllCanvas() + { + auto system = SHSystemManager::GetSystem(); + system->HideActiveCanvas(); + } + + +} diff --git a/SHADE_Managed/src/Components/Canvas.hxx b/SHADE_Managed/src/Components/Canvas.hxx new file mode 100644 index 00000000..a17d4bb2 --- /dev/null +++ b/SHADE_Managed/src/Components/Canvas.hxx @@ -0,0 +1,49 @@ +/************************************************************************************//*! +\file Canvas.hxx +\author Daniel Chua, 2001877 +\par email: yeechendaniel/@digipen.edu +\date Feb 26, 2023 +\brief Contains the definition of the managed Canvas class with the + declaration of functions for working with it. + + Note: This file is written in C++17/CLI. + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +// Project Includes +#include "Components/Component.hxx" +#include "Math/Vector3.hxx" +#include "Math/Quaternion.hxx" +// External Dependencies +#include "UI/SHCanvasComponent.h" + +namespace SHADE +{ + /// + /// CLR version of the SHADE Engine's SHCanvasComponent. + /// + public ref class Canvas : public Component + { + internal: + /*-----------------------------------------------------------------------------*/ + /* Constructors */ + /*-----------------------------------------------------------------------------*/ + /// + /// Constructs a Canvas Component that represents a native SHCanvasComponent + /// tied to the specified Entity. + /// + /// Entity that this Component will be tied to. + Canvas(Entity entity); + + public: + + static void DeactivateAllCanvas(); + + + }; +} + diff --git a/SHADE_Managed/src/Components/Slider.cxx b/SHADE_Managed/src/Components/Slider.cxx new file mode 100644 index 00000000..163a33a3 --- /dev/null +++ b/SHADE_Managed/src/Components/Slider.cxx @@ -0,0 +1,26 @@ +// Precompiled Headers +#include "SHpch.h" +// Primary Header +#include "Slider.hxx" +#include "Assets/NativeAsset.hxx" +#include "Utility/Convert.hxx" +#include "Utility/Debug.hxx" + + +#include "ECS_Base/Managers/SHSystemManager.h" +#include "UI/SHUISystem.h" + + +namespace SHADE +{ + Slider::Slider(Entity entity) + : Component(entity) + {} + + float Slider::GetValue() + { + return GetNativeComponent()->GetValue(); + } + + +} diff --git a/SHADE_Managed/src/Components/Slider.hxx b/SHADE_Managed/src/Components/Slider.hxx new file mode 100644 index 00000000..7f0efa1e --- /dev/null +++ b/SHADE_Managed/src/Components/Slider.hxx @@ -0,0 +1,49 @@ +/************************************************************************************//*! +\file Slider.hxx +\author Daniel Chua, 2001877 +\par email: yeechendaniel/@digipen.edu +\date Feb 26, 2023 +\brief Contains the definition of the managed Slider class with the + declaration of functions for working with it. + + Note: This file is written in C++17/CLI. + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +// Project Includes +#include "Components/Component.hxx" +#include "Math/Vector3.hxx" +#include "Math/Quaternion.hxx" +// External Dependencies +#include "UI/SHSliderComponent.h" + +namespace SHADE +{ + /// + /// CLR version of the SHADE Engine's SHSliderComponent. + /// + public ref class Slider : public Component + { + internal: + /*-----------------------------------------------------------------------------*/ + /* Constructors */ + /*-----------------------------------------------------------------------------*/ + /// + /// Constructs a Slider Component that represents a native SHSliderComponent + /// tied to the specified Entity. + /// + /// Entity that this Component will be tied to. + Slider(Entity entity); + + public: + + float GetValue(); + + + }; +} + diff --git a/SHADE_Managed/src/Components/UIElement.cxx b/SHADE_Managed/src/Components/UIElement.cxx index d76d6d42..8e6134e1 100644 --- a/SHADE_Managed/src/Components/UIElement.cxx +++ b/SHADE_Managed/src/Components/UIElement.cxx @@ -28,6 +28,18 @@ namespace SHADE : Component(entity) {} + void UIElement::ClearStaticEventData() + { + if (onClickEventMap != nullptr) + onClickEventMap->Clear(); + if (onReleasedEventMap != nullptr) + onReleasedEventMap->Clear(); + if (onHoverEnterEventMap != nullptr) + onHoverEnterEventMap->Clear(); + if (onHoverExitEventMap != nullptr) + onHoverExitEventMap->Clear(); + } + /*---------------------------------------------------------------------------------*/ /* Properties */ /*---------------------------------------------------------------------------------*/ @@ -37,7 +49,7 @@ namespace SHADE if (onClickEventMap == nullptr) { onClickEventMap = gcnew System::Collections::Generic::Dictionary(); - } + } // Create event if it wasn't before if (!onClickEventMap->ContainsKey(owner.EntityId)) @@ -48,6 +60,57 @@ namespace SHADE // Return the event return onClickEventMap[owner.EntityId]; } + CallbackEvent^ UIElement::OnRelease::get() + { + // Create map if it wasn't before + if (onReleasedEventMap == nullptr) + { + onReleasedEventMap = gcnew System::Collections::Generic::Dictionary(); + } + + // Create event if it wasn't before + if (!onReleasedEventMap->ContainsKey(owner.EntityId)) + { + onReleasedEventMap->Add(owner.EntityId, gcnew CallbackEvent()); + } + + // Return the event + return onReleasedEventMap[owner.EntityId]; + } + CallbackEvent^ UIElement::OnHoverEnter::get() + { + // Create map if it wasn't before + if (onHoverEnterEventMap == nullptr) + { + onHoverEnterEventMap = gcnew System::Collections::Generic::Dictionary(); + } + + // Create event if it wasn't before + if (!onHoverEnterEventMap->ContainsKey(owner.EntityId)) + { + onHoverEnterEventMap->Add(owner.EntityId, gcnew CallbackEvent()); + } + + // Return the event + return onHoverEnterEventMap[owner.EntityId]; + } + CallbackEvent^ UIElement::OnHoverExit::get() + { + // Create map if it wasn't before + if (onHoverExitEventMap == nullptr) + { + onHoverExitEventMap = gcnew System::Collections::Generic::Dictionary(); + } + + // Create event if it wasn't before + if (!onHoverExitEventMap->ContainsKey(owner.EntityId)) + { + onHoverExitEventMap->Add(owner.EntityId, gcnew CallbackEvent()); + } + + // Return the event + return onHoverExitEventMap[owner.EntityId]; + } /*---------------------------------------------------------------------------------*/ /* Event Handling Functions */ @@ -60,6 +123,18 @@ namespace SHADE { onClickEventMap->Remove(entity); } + if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity)) + { + onReleasedEventMap->Remove(entity); + } + if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity)) + { + onHoverEnterEventMap->Remove(entity); + } + if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity)) + { + onHoverExitEventMap->Remove(entity); + } SAFE_NATIVE_CALL_END("UIElement.OnComponentRemoved") } void UIElement::OnClicked(EntityID entity) @@ -72,4 +147,34 @@ namespace SHADE } SAFE_NATIVE_CALL_END("UIElement.OnClicked") } + void UIElement::OnReleased(EntityID entity) + { + SAFE_NATIVE_CALL_BEGIN + // Remove the event if it contained an event + if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity)) + { + onReleasedEventMap[entity]->Invoke(); + } + SAFE_NATIVE_CALL_END("UIElement.OnReleased") + } + void UIElement::OnHoverEntered(EntityID entity) + { + SAFE_NATIVE_CALL_BEGIN + // Remove the event if it contained an event + if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity)) + { + onHoverEnterEventMap[entity]->Invoke(); + } + SAFE_NATIVE_CALL_END("UIElement.OnHoverEntered") + } + void UIElement::OnHoverExited(EntityID entity) + { + SAFE_NATIVE_CALL_BEGIN + // Remove the event if it contained an event + if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity)) + { + onHoverExitEventMap[entity]->Invoke(); + } + SAFE_NATIVE_CALL_END("UIElement.OnHoverExited") + } } diff --git a/SHADE_Managed/src/Components/UIElement.hxx b/SHADE_Managed/src/Components/UIElement.hxx index a969e4b5..d8f741d2 100644 --- a/SHADE_Managed/src/Components/UIElement.hxx +++ b/SHADE_Managed/src/Components/UIElement.hxx @@ -50,6 +50,39 @@ namespace SHADE { CallbackEvent^ get(); } + /// + /// Event that is raised when this UIElement is released. + /// + property CallbackEvent^ OnRelease + { + CallbackEvent^ get(); + } + /// + /// Event that is raised on the first frame when this UIElement is hovered over. + /// + property CallbackEvent^ OnHoverEnter + { + CallbackEvent^ get(); + } + /// + /// Event that is raised on the first frame when this UIElement is no longer + /// hovered over. + /// + property CallbackEvent^ OnHoverExit + { + CallbackEvent^ get(); + } + + + + internal: + /*-----------------------------------------------------------------------------*/ + /* Static Clear Functions */ + /*-----------------------------------------------------------------------------*/ + /// + /// Disposes static event data which may contains data from SHADE_Scripting. + /// + static void ClearStaticEventData(); private: /*-----------------------------------------------------------------------------*/ @@ -65,11 +98,32 @@ namespace SHADE /// /// The entity which was clicked. static void OnClicked(EntityID entity); + /// + /// To be called from native code when this component is released from clicking. + /// + /// The entity which was clicked. + static void OnReleased(EntityID entity); + /// + /// To be called from native code on the first frame that this component is + /// hovered on. + /// + /// The entity which was clicked. + static void OnHoverEntered(EntityID entity); + /// + /// To be called from native code on the first frame that this component is + /// no longer hovered on. + /// + /// The entity which was clicked. + static void OnHoverExited(EntityID entity); /*-----------------------------------------------------------------------------*/ /* Static Data Members */ /*-----------------------------------------------------------------------------*/ + // As these hold references to code in SHADE_Scripting, we must remember to dispose of them when changing scenes static System::Collections::Generic::Dictionary^ onClickEventMap; + static System::Collections::Generic::Dictionary^ onReleasedEventMap; + static System::Collections::Generic::Dictionary^ onHoverEnterEventMap; + static System::Collections::Generic::Dictionary^ onHoverExitEventMap; }; } diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index ecd3784d..38596010 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -30,18 +30,24 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics\MiddleEnd\Interface\SHRenderable.h" #include "Graphics\MiddleEnd\TextRendering\SHTextRenderableComponent.h" #include "UI\SHUIComponent.h" +#include "UI\SHSliderComponent.h" +#include "UI\SHCanvasComponent.h" // Project Headers #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" -#include "Components/Transform.hxx" -#include "Components/RigidBody.hxx" -#include "Components/Collider.hxx" -#include "Components/Camera.hxx" -#include "Components/CameraArm.hxx" -#include "Components/Light.hxx" +#include "Components\Transform.hxx" +#include "Components\RigidBody.hxx" +#include "Components\Collider.hxx" +#include "Components\Camera.hxx" +#include "Components\CameraArm.hxx" +#include "Components\Light.hxx" #include "Components\Renderable.hxx" #include "Components\TextRenderable.hxx" #include "Components\UIElement.hxx" +#include "Components\Canvas.hxx" +#include "Components\Slider.hxx" + + namespace SHADE { @@ -327,6 +333,8 @@ namespace SHADE componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); + componentMap.Add(createComponentSet()); + componentMap.Add(createComponentSet()); } /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Engine/ECS.hxx b/SHADE_Managed/src/Engine/ECS.hxx index 18acf30d..64207f72 100644 --- a/SHADE_Managed/src/Engine/ECS.hxx +++ b/SHADE_Managed/src/Engine/ECS.hxx @@ -51,7 +51,7 @@ namespace SHADE /// specified Component. /// generic where T : BaseComponent - static T GetComponent(EntityID entity); + static T GetComponent(EntityID entity); /// /// Retrieves the first Component from the specified GameObject's children that /// matches the specified type. diff --git a/SHADE_Managed/src/Engine/EngineInterface.cxx b/SHADE_Managed/src/Engine/EngineInterface.cxx index 2009b2e5..50f8fbc2 100644 --- a/SHADE_Managed/src/Engine/EngineInterface.cxx +++ b/SHADE_Managed/src/Engine/EngineInterface.cxx @@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited. #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" #include "Scripts/ScriptStore.hxx" +#include "Components/UIElement.hxx" namespace SHADE { @@ -43,6 +44,9 @@ namespace SHADE oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll"; ScriptStore::Exit(); + // Unload static data of components that have access to the assembly + UIElement::ClearStaticEventData(); + // Unload the script scriptContext->Unload(); scriptContext = nullptr; diff --git a/SHADE_Managed/src/Input/Input.cxx b/SHADE_Managed/src/Input/Input.cxx index f0ea0edc..ee628523 100644 --- a/SHADE_Managed/src/Input/Input.cxx +++ b/SHADE_Managed/src/Input/Input.cxx @@ -30,10 +30,29 @@ namespace SHADE { return SHInputManager::GetMouseWheelVerticalDelta(); } + bool Input::ControllerInUse::get() + { + return SHInputManager::GetControllerInUse(); + } /*---------------------------------------------------------------------------------*/ /* Usage Functions */ /*---------------------------------------------------------------------------------*/ + bool Input::AnyKey() + { + return SHInputManager::AnyKey(); + } + + bool Input::AnyKeyDown() + { + return SHInputManager::AnyKeyDown(); + } + + bool Input::AnyKeyUp() + { + return SHInputManager::AnyKeyUp(); + } + bool Input::GetKey(KeyCode key) { return SHInputManager::GetKey(static_cast(key)); @@ -64,6 +83,50 @@ namespace SHADE return SHInputManager::GetKeyUp(static_cast(mouseButton)); } + bool Input::AnyControllerInput() + { + return SHInputManager::AnyControllerInput(); + } + bool Input::AnyControllerInputDown() + { + return SHInputManager::AnyControllerInputDown(); + } + bool Input::AnyControllerInputUp() + { + return SHInputManager::AnyControllerInputUp(); + } + bool Input::AnyControllerButton() + { + return SHInputManager::AnyControllerButton(); + } + bool Input::AnyControllerButtonDown() + { + return SHInputManager::AnyControllerButtonDown(); + } + bool Input::AnyControllerButtonUp() + { + return SHInputManager::AnyControllerButtonUp(); + } + + bool Input::GetControllerInput(Input::ControllerCode code) + { + return SHInputManager::GetControllerInput(static_cast(code)); + } + double Input::GetControllerInputNormalisedValue(Input::ControllerCode code) + { + double toReturn = 0.0; + SHInputManager::GetControllerInput(static_cast(code), &toReturn); + return toReturn; + } + bool Input::GetControllerInputDown(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputDown(static_cast(code)); + } + bool Input::GetControllerInputUp(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputUp(static_cast(code)); + } + /*---------------------------------------------------------------------------------*/ /* Cursor Functions */ /*---------------------------------------------------------------------------------*/ @@ -76,6 +139,24 @@ namespace SHADE ); } + Vector2 Input::GetMousePosition() + { + int x = 0; + int y = 0; + SHInputManager::GetMouseWindowPosition(&x, &y); + return Convert::ToCLI(SHVec2{ (float)x,(float)y }); + } + + void Input::SetMouseCentering(bool state) + { + SHInputManager::SetMouseCentering(state); + } + + bool Input::GetMouseCentering() + { + return SHInputManager::GetMouseCentering(); + } + /*---------------------------------------------------------------------------------*/ /* Time Functions */ /*---------------------------------------------------------------------------------*/ @@ -106,4 +187,220 @@ namespace SHADE return Convert::ToCLI(SHVec2{ (float)velX,(float)velY }); } + + double Input::GetControllerInputHeldTime(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputHeldTime(static_cast(code)); + } + double Input::GetControllerInputReleasedTime(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputReleasedTime(static_cast(code)); + } + + /*-----------------------------------------------------------------------------*/ + /* Binding Functions */ + /*-----------------------------------------------------------------------------*/ + void Input::SaveBindings() + { + SHInputManager::SaveBindings(); + } + + void Input::SaveBindings(System::String^ targetFile) + { + SHInputManager::SaveBindings(Convert::ToNative(targetFile)); + } + + void Input::LoadBindings() + { + SHInputManager::LoadBindings(); + } + + void Input::LoadBindings(System::String^ sourceFile) + { + SHInputManager::LoadBindings(Convert::ToNative(sourceFile)); + } + + bool Input::GetBindingInverted(System::String^ bindingName) + { + return SHInputManager::GetBindingInverted(Convert::ToNative(bindingName)); + } + void Input::SetBindingInverted(System::String^ bindingName, bool newValue) + { + SHInputManager::SetBindingInverted(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingGravity(System::String^ bindingName) + { + return SHInputManager::GetBindingGravity(Convert::ToNative(bindingName)); + } + void Input::SetBindingGravity(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingGravity(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingDead(System::String^ bindingName) + { + return SHInputManager::GetBindingDead(Convert::ToNative(bindingName)); + } + void Input::SetBindingDead(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingDead(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingSensitivity(System::String^ bindingName) + { + return SHInputManager::GetBindingSensitivity(Convert::ToNative(bindingName)); + } + void Input::SetBindingSensitivity(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingSensitivity(Convert::ToNative(bindingName), newValue); + } + bool Input::GetBindingSnap(System::String^ bindingName) + { + return SHInputManager::GetBindingSnap(Convert::ToNative(bindingName)); + } + void Input::SetBindingSnap(System::String^ bindingName, bool newValue) + { + SHInputManager::SetBindingSnap(Convert::ToNative(bindingName), newValue); + } + + + System::Collections::Generic::HashSet^ Input::GetBindingPositiveKeyCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingPositiveKeyCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd) + { + SHInputManager::AddBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove) + { + SHInputManager::RemoveBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingPositiveKeyCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingPositiveKeyCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingNegativeKeyCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingNegativeKeyCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd) + { + SHInputManager::AddBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove) + { + SHInputManager::RemoveBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingNegativeKeyCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingNegativeKeyCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingPositiveControllerCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingPositiveControllerCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd) + { + SHInputManager::AddBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove) + { + SHInputManager::RemoveBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingPositiveControllerCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingPositiveControllerCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingNegativeControllerCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingNegativeControllerCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd) + { + SHInputManager::AddBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove) + { + SHInputManager::RemoveBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingNegativeControllerCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingNegativeControllerCodes(Convert::ToNative(bindingName)); + } + + double Input::GetBindingAxis(System::String^ bindingName) + { + return SHInputManager::GetBindingAxis(Convert::ToNative(bindingName)); + } + double Input::GetBindingAxisRaw(System::String^ bindingName) + { + return SHInputManager::GetBindingAxisRaw(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButton(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButton(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButton(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButton(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButtonDown(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButtonDown(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButtonDown(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButtonDown(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButtonUp(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButtonUp(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButtonUp(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButtonUp(Convert::ToNative(bindingName)); + } + + double Input::GetBindingPositiveHeldTime(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveHeldTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingNegativeHeldTime(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeHeldTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingPositiveReleasedTime(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveReleasedTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingNegativeReleasedTime(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeReleasedTime(Convert::ToNative(bindingName)); + } } \ No newline at end of file diff --git a/SHADE_Managed/src/Input/Input.hxx b/SHADE_Managed/src/Input/Input.hxx index 875054cc..f62e0cab 100644 --- a/SHADE_Managed/src/Input/Input.hxx +++ b/SHADE_Managed/src/Input/Input.hxx @@ -181,7 +181,6 @@ namespace SHADE //Break //Menu //Mouse buttons use mouse codes, which are enums declared later - //TODO Controller input #if 0 Space = static_cast(SHInputManager::SH_KEYCODE::SPACE), //Apostrophe = static_cast(SHInputManager::SH_KEYCODE::APOSTROPHE), @@ -355,6 +354,35 @@ namespace SHADE Button3 = static_cast(SHInputManager::SH_KEYCODE::XMB1), Button4 = static_cast(SHInputManager::SH_KEYCODE::XMB2) }; + enum class ControllerCode : int + { + DpadUp = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_UP), + DpadDown = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_DOWN), + DpadLeft = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_LEFT), + DpadRight = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_RIGHT), + Start = static_cast(SHInputManager::SH_CONTROLLERCODE::START), + Back = static_cast(SHInputManager::SH_CONTROLLERCODE::BACK), + LeftThumbstickButton = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK), + RightThumbstickButton = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_THUMBSTICK), + LeftShoulder = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_SHOULDER), + RightShoulder = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_SHOULDER), + AButton = static_cast(SHInputManager::SH_CONTROLLERCODE::A), + BButton = static_cast(SHInputManager::SH_CONTROLLERCODE::B), + XButton = static_cast(SHInputManager::SH_CONTROLLERCODE::X), + YButton = static_cast(SHInputManager::SH_CONTROLLERCODE::Y), + LeftTrigger = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_TRIGGER), + RightTrigger = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_TRIGGER), + LeftThumbStickX = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_X), + LeftThumbStickY = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y) + }; + + enum class BindingType : int + { + KbMbController = static_cast(SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER), + mouseX = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_X), + mouseY = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_Y), + mouseScroll = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_SCROLL) + }; /*-----------------------------------------------------------------------------*/ /* Properites */ @@ -376,9 +404,25 @@ namespace SHADE int get(); } + static property bool ControllerInUse + { + bool get(); + } + /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/ + + /// + /// Checks if any key is being held down. + /// This will also be true if GetKeyDown() is true. + /// + /// KeyCode of the first key that was detected to be pressed. + /// True while the user holds down the key specified. + static bool AnyKey(); + static bool AnyKeyDown(); + static bool AnyKeyUp(); + /// /// Checks if a specified key is being held down. /// This will also be true if GetKeyDown() is true. @@ -427,6 +471,20 @@ namespace SHADE /// True during the frame the user releases the given mouse button. /// static bool GetMouseButtonUp(MouseCode mouseButton); + + //For controller + + static bool AnyControllerInput(); + static bool AnyControllerInputDown(); + static bool AnyControllerInputUp(); + static bool AnyControllerButton(); + static bool AnyControllerButtonDown(); + static bool AnyControllerButtonUp(); + + static bool GetControllerInput(ControllerCode code); + static double GetControllerInputNormalisedValue(ControllerCode code); + static bool GetControllerInputDown(ControllerCode code); + static bool GetControllerInputUp(ControllerCode code); /*-----------------------------------------------------------------------------*/ /* Cursor Functions */ @@ -440,6 +498,11 @@ namespace SHADE /// static void SetMousePosition(Vector2 pos); + static Vector2 GetMousePosition(); + + static void SetMouseCentering(bool state); + static bool GetMouseCentering(); + /*-----------------------------------------------------------------------------*/ /* Timing Functions */ /*-----------------------------------------------------------------------------*/ @@ -472,6 +535,66 @@ namespace SHADE /// Time in seconds that the key was held. static double GetMouseReleasedTime(MouseCode mouseButton); + static double GetControllerInputHeldTime(ControllerCode code); + static double GetControllerInputReleasedTime(ControllerCode code); + static Vector2 GetMouseVelocity(); + + /*-----------------------------------------------------------------------------*/ + /* Binding Functions */ + /*-----------------------------------------------------------------------------*/ + static void SaveBindings(); //To default file + static void SaveBindings(System::String^ targetFile); + static void LoadBindings(); //From default file + static void LoadBindings(System::String^ sourceFile); + + static bool GetBindingInverted(System::String^ bindingName); + static void SetBindingInverted(System::String^ bindingName, bool newValue); + static double GetBindingGravity(System::String^ bindingName); + static void SetBindingGravity(System::String^ bindingName, double newValue); + static double GetBindingDead(System::String^ bindingName); + static void SetBindingDead(System::String^ bindingName, double newValue); + static double GetBindingSensitivity(System::String^ bindingName); + static void SetBindingSensitivity(System::String^ bindingName, double newValue); + static bool GetBindingSnap(System::String^ bindingName); + static void SetBindingSnap(System::String^ bindingName, bool newValue); + + static System::Collections::Generic::HashSet^ GetBindingPositiveKeyCodes(System::String^ bindingName); + static void AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd); + static void RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove); + static void ClearBindingPositiveKeyCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingNegativeKeyCodes(System::String^ bindingName); + static void AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd); + static void RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove); + static void ClearBindingNegativeKeyCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingPositiveControllerCodes(System::String^ bindingName); + static void AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd); + static void RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove); + static void ClearBindingPositiveControllerCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingNegativeControllerCodes(System::String^ bindingName); + static void AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd); + static void RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove); + static void ClearBindingNegativeControllerCodes(System::String^ bindingName); + + //Binding states + + static double GetBindingAxis(System::String^ bindingName); + static double GetBindingAxisRaw(System::String^ bindingName); + static bool GetBindingPositiveButton(System::String^ bindingName); + static bool GetBindingNegativeButton(System::String^ bindingName); + static bool GetBindingPositiveButtonDown(System::String^ bindingName); + static bool GetBindingNegativeButtonDown(System::String^ bindingName); + static bool GetBindingPositiveButtonUp(System::String^ bindingName); + static bool GetBindingNegativeButtonUp(System::String^ bindingName); + + //Binding times + + static double GetBindingPositiveHeldTime(System::String^ bindingName); + static double GetBindingNegativeHeldTime(System::String^ bindingName); + static double GetBindingPositiveReleasedTime(System::String^ bindingName); + static double GetBindingNegativeReleasedTime(System::String^ bindingName); }; } \ No newline at end of file diff --git a/SHADE_Managed/src/Scene/SceneManager.cxx b/SHADE_Managed/src/Scene/SceneManager.cxx index 1e139a95..a0ebc3a8 100644 --- a/SHADE_Managed/src/Scene/SceneManager.cxx +++ b/SHADE_Managed/src/Scene/SceneManager.cxx @@ -22,4 +22,12 @@ namespace SHADE { SHSceneManager::RestartScene(sceneAssetID); } + void SceneManager::RestartScene() + { + SHSceneManager::RestartScene(); + } + AssetID SceneManager::GetCurrentSceneID() + { + return SHSceneManager::GetCurrentSceneAssetID(); + } } \ No newline at end of file diff --git a/SHADE_Managed/src/Scene/SceneManager.hxx b/SHADE_Managed/src/Scene/SceneManager.hxx index e1e1ec0a..712b203c 100644 --- a/SHADE_Managed/src/Scene/SceneManager.hxx +++ b/SHADE_Managed/src/Scene/SceneManager.hxx @@ -23,5 +23,7 @@ namespace SHADE { public : static void ChangeScene(AssetID sceneAssetID); + static void RestartScene(); + static AssetID GetCurrentSceneID(); }; } diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index 62bfc383..aba63eb2 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -482,11 +482,20 @@ namespace SHADE { SAFE_NATIVE_CALL_BEGIN // Clear the awake queue - for each (Script^ script in awakeList) + for each (Script ^ script in awakeList) { - script->Awake(); + if (script->Owner.IsActiveInHierarchy) + { + script->Awake(); + } + else + { + inactiveAwakeList.Add(script); + } } awakeList.Clear(); + awakeList.UnionWith(%inactiveAwakeList); + inactiveAwakeList.Clear(); // Clear the start queue for each (Script^ script in startList) @@ -501,10 +510,7 @@ namespace SHADE } } startList.Clear(); - for each (Script ^ script in startList) - { - startList.Add(script); - } + startList.UnionWith(%inactiveStartList); inactiveStartList.Clear(); SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore") diff --git a/SHADE_Managed/src/Scripts/ScriptStore.hxx b/SHADE_Managed/src/Scripts/ScriptStore.hxx index e59e3a7f..4734b474 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.hxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.hxx @@ -353,6 +353,7 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ static ScriptDictionary scripts; static ScriptSet awakeList; + static ScriptSet inactiveAwakeList; static ScriptSet startList; static ScriptSet inactiveStartList; static ScriptSet disposalQueue;