Compare commits

...

59 Commits

Author SHA1 Message Date
Glence 799cac0924 Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-04 21:28:19 +08:00
Glence 7ad0ca6183 scene changes 2023-03-04 20:47:39 +08:00
Diren D Bharwani 02b21f2694 Fixed auto mass serialisation and colliders not recomputing mass on size change 2023-03-04 20:28:09 +08:00
Diren D Bharwani 9b2c5a1804 Added math helpers for checking if a number is infinity or invalid 2023-03-04 19:50:53 +08:00
Diren D Bharwani 5a2401bec2 Reverted tolerances for ConvexVSConvex 2023-03-04 17:42:47 +08:00
Glence 90dc4ef750 Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-04 17:33:57 +08:00
Diren D Bharwani 20fe6c4877 Fixed incorrect distances for AABB raycast results 2023-03-04 17:32:05 +08:00
Diren D Bharwani e293094b6d Another attempt to fix invalid error bias 2023-03-04 17:31:50 +08:00
Glence ab4a874bb1 Merge remote-tracking branch 'origin/PlayerControllerWIthNewPhysics' into PlayerControllerWIthNewPhysics 2023-03-04 17:30:14 +08:00
Brandon Mak 4530c96ffc Merge remote-tracking branch 'origin/PlayerControllerWIthNewPhysics' into PlayerControllerWIthNewPhysics 2023-03-04 15:49:51 +08:00
Brandon Mak c7c8e0046d Updated shiny effect shader 2023-03-04 15:49:41 +08:00
Glence 59eb2d767f Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-04 15:20:20 +08:00
Diren D Bharwani ea97dc3b50 Fixed Managed vector3 forward & back 2023-03-04 15:17:29 +08:00
Glence 9a7ad8ee17 Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-04 15:17:20 +08:00
Diren D Bharwani b9c9f30ce0 Fixed heap corruption caused by out-of-sync collider active states 2023-03-04 14:31:07 +08:00
Diren D Bharwani a691d2ff28 Fixed imgui error caused by merge 2023-03-04 13:50:10 +08:00
Diren D Bharwani 15bbf6892f Merge branch 'main' into SP3-2-Physics 2023-03-04 13:44:53 +08:00
Diren D Bharwani e2d96569b5 Collision shapes will only be added to broadphase if the collider is active 2023-03-04 13:30:29 +08:00
Glence c6f49e45e4 Merge branch 'main' into PlayerControllerWIthNewPhysics 2023-03-04 13:16:38 +08:00
Sri Sham Haran 51d4b26e3d off mouse centering on pause/stop 2023-03-04 10:37:01 +08:00
Sri Sham Haran fff2c73994 editor set mouse visibility 2023-03-04 10:27:51 +08:00
Brandon Mak 90dd589430 No editor rendering fix 2023-03-04 01:20:27 +08:00
Glence ac99eb9ba0 Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-04 00:27:38 +08:00
Glence 0c4f154c24 Merge remote-tracking branch 'origin/PlayerControllerWIthNewPhysics' into PlayerControllerWIthNewPhysics 2023-03-04 00:05:34 +08:00
Glence daad6699f1 fix raycast for player 2023-03-04 00:05:26 +08:00
Xiao Qi c4d2091b99 Camera system update for line without editor 2023-03-03 23:54:16 +08:00
Diren D Bharwani 6200e3f533 Fixed bug where collision & trigger state were called more than once 2023-03-03 23:47:39 +08:00
SHAM-DP 98d0021b32 sheditor ifdef checks 2023-03-03 21:57:20 +08:00
Diren D Bharwani 446db133d2 Fixed errors with publish build in physics debug draw 2023-03-03 21:39:59 +08:00
Diren D Bharwani 8743ae52fa Fixed errors with publish build in physics debug draw 2023-03-03 21:38:57 +08:00
Diren D Bharwani 337ec82dbf Removed random commented code 2023-03-03 21:19:49 +08:00
Glence ebf2bb8d85 Merge branch 'main' into PlayerControllerWIthNewPhysics 2023-03-03 21:19:00 +08:00
Diren D Bharwani 5cb4c54757 I didn't commit the change oop 2023-03-03 21:16:44 +08:00
Diren D Bharwani 5c38244ce4 Changed casts 2023-03-03 21:16:18 +08:00
Diren D Bharwani 74c32457a8 Merge branch 'main' into Revert-Revert-SHPhysics 2023-03-03 21:07:59 +08:00
Diren D Bharwani 5c803105b2 Merge branch 'SP3-2-Physics' into Revert-Revert-SHPhysics 2023-03-03 20:10:11 +08:00
Diren D Bharwani 4047699544 Auto stash before revert of "Revert "Implemented a custom physics engine"" 2023-03-03 20:09:59 +08:00
XiaoQiDigipen fc0d7ad052 Revert "Revert "Implemented a custom physics engine""
This reverts commit 3ff2e6bb92.
2023-03-03 20:09:46 +08:00
Glence cae0061ac3 minor fix 2023-03-03 18:10:03 +08:00
Glence eba64126f8 Merge branch 'SP3-2-Physics' into PlayerControllerWIthNewPhysics 2023-03-03 17:48:41 +08:00
Diren D Bharwani c9ebe73a7a Merge branch 'main' into SHPhysics 2023-03-03 16:46:54 +08:00
Glence 46c99f31f9 Merge branch 'main' into PlayerController 2023-03-03 16:45:26 +08:00
Diren D Bharwani a80089c893 pointless changes 2023-03-03 15:55:43 +08:00
Glence 27b00a6c4a end cutscene done 2023-03-03 14:28:10 +08:00
Glence 81da3e501d fix minor preview level bug 2023-03-03 00:40:16 +08:00
Diren D Bharwani 87d2afbd9a Merge branch 'main' into SHPhysics 2023-03-02 16:26:49 +08:00
Diren D Bharwani e43089e6ff Fixed bug where box colliders weren't being deleted on scene destroy 2023-03-02 13:52:54 +08:00
Diren D Bharwani 991912f7b4 Fixed bug where reduced manifold would attempt to grab an invalid contact 2023-03-02 07:09:14 +08:00
Diren D Bharwani 199a9aa025 Fixed infinite positional error bias 2023-03-02 07:08:45 +08:00
Diren D Bharwani f4b7618fc2 Fixed incorrect edge preference for convex vs convex 2023-03-02 05:23:08 +08:00
Diren D Bharwani aebf1fc6ec Reverted some changes 2023-03-02 04:27:07 +08:00
Diren D Bharwani f7ea42f58e Reverted computing point offsets in local space
Force is applied in world space, so contact points should also be in world space
2023-03-02 04:15:40 +08:00
Diren D Bharwani 2d2c8a1b20 Fixed clipping of contacts against reference planes 2023-03-01 21:30:00 +08:00
Diren D Bharwani 0e3a84a06b Fixed bug where changing scenes would not clear drawn colliders 2023-03-01 04:34:20 +08:00
Diren D Bharwani 3a454953ce Solved Sphere VS Convex in local space 2023-03-01 04:34:06 +08:00
Diren D Bharwani f620ef226e Fixed bug where AABB nodes were not updating on collider size change 2023-03-01 02:58:05 +08:00
Diren D Bharwani abdf614083 Contacts are solved locally on each body 2023-03-01 00:55:44 +08:00
Diren D Bharwani 9d8d1ee19d Fixed edge-edge contact points being beyond the range of the edge 2023-01-26 01:17:14 +08:00
Diren D Bharwani 6b9a64233e Ray direction are automatically normalised 2023-01-26 01:11:57 +08:00
188 changed files with 18796 additions and 7730 deletions

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 51238312
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: CutScene_04a
ID: 130935405
Type: 7

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 61471971
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: CutScene_04b
ID: 122461516
Type: 7

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 58217538
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: CutScene_04c
ID: 124507864
Type: 7

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 61980534
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: CutScene_05a
ID: 118069989
Type: 7

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 51561286
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: CutScene_05b
ID: 132945336
Type: 7

View File

@ -0,0 +1,334 @@
- EID: 1
Name: Canvas4
IsActive: true
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 10
Name: CutScene4
IsActive: true
NumberOfChildren: 3
Components:
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 2
Name: pic1
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -1275, y: 255, z: 0.5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1313, y: 544, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 130935405
IsActive: true
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 65542
Name: pic2
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1600, y: 150, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 640, y: 661, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 122461516
IsActive: true
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 5
Name: pic3
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -1000, y: -275, z: 0.300000012}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1848, y: 575, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 124507864
IsActive: true
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 11
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.699999988}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1920, y: 1080, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 117531460
IsActive: true
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 12
Name: Text
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 250, y: -500, z: 0.100000001}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 50, y: 50, z: 50}
IsActive: true
Text Renderer Component:
Text: Press Space to contiune
Font: 176667660
Color: {x: 0, y: 0, z: 0, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 1
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 3
Name: Camera
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Camera Component:
Position: {x: 0, y: 0, z: 0}
Pitch: 0
Yaw: 0
Roll: 0
Width: 1920
Near: 0.00999999978
Far: 10000
Perspective: true
FOV: 90
IsActive: true
Scripts: ~
- EID: 7
Name: CutsceneManager
IsActive: true
NumberOfChildren: 0
Components: ~
Scripts:
- Type: CutsceneEnd
Enabled: true
nextScene: 0
duration: 1
skipDuration: 0.100000001
cutscene4Points: 4
cutscene4Pics: 10
cutscene5Points: 21
cutscene5Pics: 15
canvas4: 1
canvas5: 14
- EID: 4
Name: CutScene4Points
IsActive: true
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 9
Name: Pic1Point
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -275, y: 255, z: 0.5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~
- EID: 8
Name: Pic2Point
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 600, y: 150, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~
- EID: 65549
Name: Pic3Point
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -275, z: 0.300000012}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~
- EID: 14
Name: Canvas5
IsActive: false
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: false
Scripts: ~
- EID: 15
Name: CutScene5
IsActive: true
NumberOfChildren: 2
Components:
UI Component:
Canvas ID: 14
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 16
Name: pic1
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -600, y: 1000, z: 0.5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 634, y: 1027, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 118069989
IsActive: true
UI Component:
Canvas ID: 14
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 17
Name: pic2
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 250, y: -1000, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1337, y: 1028, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 132945336
IsActive: true
UI Component:
Canvas ID: 14
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 19
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.699999988}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1920, y: 1080, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 117531460
IsActive: true
UI Component:
Canvas ID: 14
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 20
Name: Text
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 250, y: -500, z: 0.100000001}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 50, y: 50, z: 50}
IsActive: true
Text Renderer Component:
Text: Press Space to contiune
Font: 176667660
Color: {x: 0, y: 0, z: 0, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: false
UI Component:
Canvas ID: 14
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 21
Name: CutScene5Points
IsActive: true
NumberOfChildren: 2
Components: ~
Scripts: ~
- EID: 22
Name: Pic1Point
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -600, y: 0, z: 0.5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~
- EID: 23
Name: Pic2Point
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 250, y: 0, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~

View File

@ -0,0 +1,3 @@
Name: CutSceneEnd
ID: 84606951
Type: 5

View File

@ -113,6 +113,8 @@
Text Renderer Component:
Text: Press Space to contiune
Font: 176667660
Color: {x: 0, y: 0, z: 0, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 1
@ -148,9 +150,11 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: Cutscene
- Type: CutsceneIntro
Enabled: true
duration: 2
nextScene: 96668835
duration: 1
skipDuration: 0.100000001
cutscene1Points: 4
cutscene1Pics: 10
cutscene2Points: 20
@ -314,6 +318,8 @@
Text Renderer Component:
Text: Press Space to contiune
Font: 176667660
Color: {x: 0, y: 0, z: 0, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 13
@ -448,7 +454,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -1425, y: -200, z: 0.5}
Translate: {x: -1800, y: -200, z: 0.5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1299, y: 575, z: 1}
IsActive: true
@ -515,6 +521,8 @@
Text Renderer Component:
Text: Press Space to contiune
Font: 176667660
Color: {x: 0, y: 0, z: 0, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: false
UI Component:
Canvas ID: 24

View File

@ -1004,7 +1004,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Collision Tag: 1
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
@ -4106,7 +4106,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Collision Tag: 1
Type: Box
Half Extents: {x: 20, y: 0.100000001, z: 20}
Friction: 0.400000006
@ -4158,9 +4158,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4267,9 +4270,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
@ -4318,9 +4324,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
@ -4369,9 +4378,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
@ -4420,9 +4432,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
@ -4473,9 +4488,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4535,9 +4553,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4597,9 +4618,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4659,9 +4683,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4721,9 +4748,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
@ -4875,9 +4905,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.100000001}
Translate: {x: 0, y: 0, z: 0.300000012}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1920, y: 1080, z: 1}
IsActive: true
@ -49,7 +49,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Translate: {x: 0, y: 75, z: 0.200000003}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 100, z: 1}
IsActive: true
@ -85,7 +85,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Translate: {x: 0, y: -200, z: 0.200000003}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 100, z: 1}
IsActive: true
@ -154,3 +154,39 @@
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 65982
Name: Transition
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.100000001}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 2500, y: 1080, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 120016136
IsActive: true
UI Component:
Canvas ID: 450
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.SceneFadeInOut
Enabled: true
alphaValue: 1
fadeInTime: 0.5
fadeOutTime: 0.5

View File

@ -97,7 +97,7 @@
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 96668835
sceneID: 91947920
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
@ -587,6 +587,8 @@
Text Renderer Component:
Text: Options
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -607,6 +609,8 @@
Text Renderer Component:
Text: Audio
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -643,6 +647,8 @@
Text Renderer Component:
Text: Master
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -663,6 +669,8 @@
Text Renderer Component:
Text: SFX
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -683,6 +691,8 @@
Text Renderer Component:
Text: BGM
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -788,6 +798,8 @@
Text Renderer Component:
Text: Camera
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -824,6 +836,8 @@
Text Renderer Component:
Text: FOV
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -844,6 +858,8 @@
Text Renderer Component:
Text: Sensitivity
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -942,6 +958,8 @@
Text Renderer Component:
Text: 100
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -967,6 +985,8 @@
Text Renderer Component:
Text: 100
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -992,6 +1012,8 @@
Text Renderer Component:
Text: 100
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -1033,6 +1055,8 @@
Text Renderer Component:
Text: 100
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -1058,6 +1082,8 @@
Text Renderer Component:
Text: 100
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 19
@ -1146,6 +1172,8 @@
Text Renderer Component:
Text: Credits
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: false
UI Component:
Canvas ID: 46
@ -1225,6 +1253,8 @@
Text Renderer Component:
Text: Level Select
Font: 174412429
Color: {x: 1, y: 1, z: 1, w: 1}
Text Size: {x: 1, y: 1, z: 1}
IsActive: true
UI Component:
Canvas ID: 50
@ -1232,3 +1262,39 @@
Clicked: false
IsActive: true
Scripts: ~
- EID: 450
Name: TransitionCanvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 65982
Name: Transition
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.100000001}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 2500, y: 1080, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 120016136
IsActive: true
UI Component:
Canvas ID: 450
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.SceneFadeInOut
Enabled: true
alphaValue: 1
fadeInTime: 0.5
fadeOutTime: 0.5

View File

@ -10,9 +10,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
@ -75,10 +78,10 @@
Yaw: 0
Roll: 0
Width: 1920
Height: 1080
Near: 0.00999999978
Far: 10000
Perspective: true
FOV: 90
IsActive: true
Scripts: ~
- EID: 65539
@ -185,9 +188,12 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false

View File

@ -0,0 +1,874 @@
- EID: 0
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Camera Component:
Position: {x: 0, y: 10, z: 0}
Pitch: -90
Yaw: 0
Roll: 0
Width: 1920
Near: 0.00999999978
Far: 10000
Perspective: true
FOV: 90
IsActive: true
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Ambient
Direction: {x: 0, y: 0, z: 1}
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 1
IsActive: true
Scripts: ~
- EID: 1
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -5.3379097, y: 5, z: -0.258950353}
Rotate: {x: -0, y: 0, z: 1.57079601}
Scale: {x: 9.99821568, y: 0.999887228, z: 10}
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 131077
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.00715482235, y: 0, z: 0}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 10, y: 0.999998808, z: 10}
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 8
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0296445489, y: 5.5, z: 5.51512575}
Rotate: {x: 1.57079601, y: 0, z: -0}
Scale: {x: 9.99866009, y: 0.999816775, z: 9.9984293}
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 65543
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 5.43979311, y: 5, z: 0.0634104013}
Rotate: {x: -0, y: 0, z: 1.57079601}
Scale: {x: 9.99855232, y: 0.999908268, z: 10}
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 131074
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0296445489, y: 5.5, z: -5.14873552}
Rotate: {x: 1.57079601, y: 0, z: -0}
Scale: {x: 9.99866009, y: 0.999806404, z: 9.99826336}
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 131076
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -2.60022187, y: 5, z: -3.02165651}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999999702, y: 0.999999702, z: 1}
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
Auto Mass: false
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 65542
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1.58913052, y: 4.99788427, z: 1.11987209}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999999702, y: 0.999999702, z: 1}
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
Auto Mass: false
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 9
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.48236442, y: 5, z: -3.18853354}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999999702, y: 0.999999702, z: 1}
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
Auto Mass: false
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 10
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 5, z: 2.37419057}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999999702, y: 0.999999702, z: 1}
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
Auto Mass: false
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 1, y: 2, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
IsActive: true
NumberOfChildren: 2
Components: ~
Scripts: ~
- EID: 197
Name: Player
IsActive: true
NumberOfChildren: 5
Components:
Transform Component:
Translate: {x: 2.35245037, y: 1.35601735, z: 2.30057287}
Rotate: {x: -0, y: 0.0872664601, 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
Auto Mass: false
Mass: 0.0599999875
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
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: 1
Type: Box
Half Extents: {x: 0.400000006, y: 0.5, z: 0.300000012}
Friction: 0.800000012
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
jumpPadMultiplayer: 1.20000005
lightMultiper: 0.899999976
mediumMultiper: 0.699999988
heavyMultiper: 0.5
silhouettePlayer: 462
silhouetteBag: 465
- Type: PickAndThrow
Enabled: true
throwForce: [10, 8, 10]
cameraArmOffSet: [0.25, 0.600000024, 0.200000003]
delayTimer: 1
aimingLength: 1
throwItem: false
rayDistance: 1
rayOffSet: [0, 0.100000001, 0]
aimingFOV: 50
defaultFOV: 45
- EID: 196
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: 195
Name: PlayerCamera
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -5.96046448e-08, z: 0}
Rotate: {x: 0, y: 6.19591904, 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: 1920
Near: 0.00999999978
Far: 10000
Perspective: true
FOV: 45
IsActive: true
Camera Arm Component:
Arm Pitch: 20
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
inverseXControls: true
inverseYControls: false
pitchUpperClamp: 45
pitchLowerClamp: 5
- EID: 194
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: 462
Name: SilouettePlayer
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.38418579e-07, y: -2.98023224e-08, z: -2.98023224e-07}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126391182
IsActive: true
Scripts: ~
- EID: 465
Name: SilouetteBag
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: 126391182
IsActive: true
Scripts: ~
- EID: 239
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: ~
- EID: 240
Name: ====ItemPool====
IsActive: true
NumberOfChildren: 2
Components: ~
Scripts: ~
- EID: 464
Name: Watermelon
IsActive: true
NumberOfChildren: 5
Components:
Transform Component:
Translate: {x: -2.9657383, y: 1.34320831, z: 2.66521454}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999979734, y: 1, z: 0.999979734}
IsActive: true
Renderable Component:
Mesh: 134305891
Material: 122370915
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 0.0654498488
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Sphere
Radius: 0.5
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts:
- Type: Breakable
Enabled: true
threshHold: 4
ignoreRaccoon: true
breakClipHandlerName: SFXWatermelonBreak464
breakClipPath: event:/Props/impact_watermelon_break
- Type: Item
Enabled: true
Score: 500
currCategory: 2
density: 1
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 463
Name: Piece1
IsActive: false
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.0218036175, y: 5.38527966e-05, z: 0.202852726}
Rotate: {x: 0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: false
Renderable Component:
Mesh: 144023586
Material: 122370915
IsActive: false
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.400000006, y: 0.300000012, z: 0.300000012}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0.164060935, y: 0, z: 0}
IsActive: false
Scripts:
- Type: Item
Enabled: true
Score: 50
currCategory: 1
density: 3
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 466
Name: Piece2
IsActive: false
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.0812162161, y: 0.0825212598, z: -0.0991339684}
Rotate: {x: 0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: false
Renderable Component:
Mesh: 142132679
Material: 122370915
IsActive: false
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.300000012, y: 0.200000003, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: -0.34906584}
IsActive: false
Scripts:
- Type: Item
Enabled: true
Score: 50
currCategory: 1
density: 3
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 467
Name: Piece3
IsActive: false
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0350502729, y: -0.210244894, z: -0.0336794853}
Rotate: {x: 0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: false
Renderable Component:
Mesh: 138231239
Material: 122370915
IsActive: false
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.200000003, y: 0.0799999982, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: -0.261799395}
IsActive: false
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
density: 3
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 468
Name: Piece4
IsActive: false
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.230162144, y: -0.0580062866, z: -0.00789308548}
Rotate: {x: 0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: false
Renderable Component:
Mesh: 135293480
Material: 122370915
IsActive: false
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.200000003, y: 0.0500000007, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: -1.04719758}
IsActive: false
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
density: 3
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 469
Name: Piece5
IsActive: false
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.129600644, y: 0.219047099, z: 0.0484838486}
Rotate: {x: 0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: false
Renderable Component:
Mesh: 146157335
Material: 122370915
IsActive: false
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.25, y: 0.0500000007, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0.436332315}
IsActive: false
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
density: 3
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25
- EID: 176
Name: Mesh_Apple
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.959606349, y: 3.52014041, z: 4.99207687}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
Mesh: 144128170
Material: 122370915
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 0.00800000038
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Gravity Scale: 1
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 2
Type: Box
Half Extents: {x: 0.200000003, y: 0.200000003, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
density: 1
dontReturn: false
soundDistance: 10
highlightSpeed: 300
highlightThickness: 250
highlightLowerClamp: 0.25

View File

@ -0,0 +1,3 @@
Name: SS_Playground
ID: 92914350
Type: 5

View File

@ -29,7 +29,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.100000001}
Translate: {x: 0, y: 0, z: 0.300000012}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1920, y: 1080, z: 1}
IsActive: true
@ -49,7 +49,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Translate: {x: 0, y: 75, z: 0.200000003}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 100, z: 1}
IsActive: true
@ -85,7 +85,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Translate: {x: 0, y: -200, z: 0.200000003}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 100, z: 1}
IsActive: true
@ -154,3 +154,39 @@
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 65982
Name: Transition
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0.100000001}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 2500, y: 1080, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 120016136
IsActive: true
UI Component:
Canvas ID: 450
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.SceneFadeInOut
Enabled: true
alphaValue: 1
fadeInTime: 0.5
fadeOutTime: 0.5

View File

@ -1,4 +1,4 @@
/*********************************************************************
/*********************************************************************
* \file Homeowner1.cs
* \author Ryan Wang Nian Jing
* \brief The implemented behaviour tree for the homeowner

View File

@ -1,4 +1,4 @@
/*********************************************************************
/*********************************************************************
* \file LeafAttack.cs
* \author Ryan Wang Nian Jing
* \brief Leaf node implementation for AI attacking the player

View File

@ -1,4 +1,4 @@
/*********************************************************************
/*********************************************************************
* \file LeafChase.cs
* \author Ryan Wang Nian Jing
* \brief Leaf node implementation for AI chasing the player

View File

@ -1,4 +1,4 @@
/*********************************************************************
/*********************************************************************
* \file LeafPatrol.cs
* \author Ryan Wang Nian Jing
* \brief Leaf node implementation for patrolling AI

View File

@ -1,4 +1,4 @@
/*********************************************************************
/*********************************************************************
* \file LeafSearch.cs
* \author Ryan Wang Nian Jing
* \brief Leaf node implementation for AI searching for player

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using SHADE_Scripting.Audio;
using System;
public class Item : Script
@ -54,7 +54,8 @@ public class Item : Script
protected override void start()
{
GameManager.Instance.totalItemCount += 1;
if(GameManager.Instance)
GameManager.Instance.totalItemCount += 1;
if (rend)
{

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using SHADE_Scripting;
using SHADE_Scripting.Audio;
using System;
@ -32,7 +32,7 @@ public class PickAndThrow : Script
public float rayDistance = 1;
[Tooltip("Height of ray")]
public float rayHeight = 0.1f;
public Vector3 rayOffSet = new Vector3(0, -0.1f, 0);
[Tooltip("FOV when you aim")]
public float aimingFOV = 50;
@ -59,7 +59,7 @@ public class PickAndThrow : Script
}
protected override void update()
{
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
if ((GameManager.Instance && (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)))
{
return;
}
@ -142,7 +142,7 @@ public class PickAndThrow : Script
protected override void fixedUpdate()
{
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
if ((GameManager.Instance && (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)))
{
return;
}
@ -225,13 +225,15 @@ public class PickAndThrow : Script
{
if (pc != null)
{
/* List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);*/
Vector3 dirNor = pc.tranform.Forward;
Vector3 playerRayPos = pc.tranform.GlobalPosition;
playerRayPos.y += rayHeight;
dirNor.Normalise();
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
Vector3 test = new Vector3(-dirNor.x, -dirNor.y, -dirNor.z);
List<RaycastHit> rayList1 = Physics.ColliderRaycast(GameObject, new Ray(rayOffSet, Vector3.RotateY(test, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.ColliderRaycast(GameObject, new Ray(rayOffSet, Vector3.RotateY(test, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.ColliderRaycast(GameObject, new Ray(rayOffSet, test), rayDistance, false, (ushort)65535);
if (rayList1.Count > 0)
{
@ -262,8 +264,10 @@ public class PickAndThrow : Script
{
if (ray.Hit)
{
Debug.Log("RAY HIT");
if (ray.Other.Value.GetScript<Item>() && !pc.holdItem)
{
Debug.Log("RAY HIT ITEM");
item = ray.Other.Value;
return true;
}

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using System;
using System.Collections.Generic;
using static Item;
@ -22,7 +22,7 @@ public class PlayerController : Script
public Camera cam { get; set; }
public CameraArm camArm { get; set; }
private PickAndThrow pat;
public StateMachine stateMachine;
public StateMachine stateMachine { get; set; }
public bool holdItem { get; set; }
public bool isAiming { get; set; }
@ -78,9 +78,9 @@ public class PlayerController : Script
//silhouette=====================================================================
public GameObject silhouettePlayer;
public Renderable silhouettePlayerRend;
private Renderable silhouettePlayerRend;
public GameObject silhouetteBag;
public Renderable silhouetteBagRend;
private Renderable silhouetteBagRend;
protected override void awake()
{
@ -139,7 +139,7 @@ public class PlayerController : Script
protected override void update()
{
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
if ((GameManager.Instance && (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)))
{
return;
}
@ -189,7 +189,7 @@ public class PlayerController : Script
protected override void fixedUpdate()
{
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
if ((GameManager.Instance && (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)))
{
return;
}
@ -258,7 +258,9 @@ public class PlayerController : Script
{
if (rb != null && currentState != RaccoonStates.CAUGHT)
{
rb.LinearVelocity += new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce) * Time.DeltaTimeF;
//rb.LinearVelocity += new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce) * Time.DeltaTimeF;
rb.AddForce(new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce));
//Debug.Log($"X: {axisMove.x} Y:{axisMove.y} velx: {rb.LinearVelocity.x} vely: {rb.LinearVelocity.z}");
if (isMoveKeyPress && rb)
{
@ -344,11 +346,10 @@ public class PlayerController : Script
private void Rotation()
{
tranform.LocalEulerAngles = new Vector3(0.0f, tranform.LocalEulerAngles.y, 0.0f);
if (isMoveKeyPress && tranform && !isAiming)
{
Quaternion currentRotation = tranform.LocalRotation;
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(axisMove.x, 0.0f, axisMove.y), Vector3.Up);
Quaternion targetRotation = Quaternion.Euler(0.0f,MathF.Atan2(axisMove.x,axisMove.y), 0.0f);
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
}
else if (camArm && tranform && isAiming)

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -41,7 +41,7 @@ namespace SHADE_Scripting
protected override void update()
{
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
if ((GameManager.Instance && (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)))
{
return;
}

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using SHADE_Scripting.Audio;
using SHADE_Scripting.UI;
using System;

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using SHADE_Scripting.Audio;
using System;

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
@ -56,10 +56,11 @@ namespace SHADE_Scripting.UI
return;
}
if (Input.GetKeyUp(Input.KeyCode.Space))
if (Input.GetKeyUp(Input.KeyCode.Space) && !point3Done)
{
skip = true;
point1Done = true;
point3Done = true;
SceneFadeInOut.Instance.CallFadeIn();
SceneFadeInOut.Instance.alphaValue = 0.01f;
}

View File

@ -0,0 +1,81 @@
using SHADE;
using System;
using System.Collections.Generic;
using static Item;
public class MovementTest : Script
{
public Transform tf { get; set; }
public RigidBody body { get; set; }
// Movement input booleans
internal bool move = false;
internal bool[] rotate = new bool[2];
internal Vector3[] rotateVec = new Vector3[2]
{
Vector3.Up,
Vector3.Down
};
internal Input.KeyCode[] rotateInputKeys = new Input.KeyCode[2]
{
Input.KeyCode.J,
Input.KeyCode.L
};
public float forceAmount = 50.0f;
public float torqueAmount = 100.0f;
public float rayDistance = 1.0f;
public float rayYOffset = -0.1f;
protected override void awake()
{
tf = GetComponent<Transform>();
body = GetComponent<RigidBody>();
for (int i = 0; i < 2; ++i)
rotate[i] = false;
}
protected override void update()
{
if (Input.GetKey(Input.KeyCode.W))
move = true;
for (int i = 0; i < 2; ++i)
{
if (Input.GetKeyDown(rotateInputKeys[i]))
rotate[i] = true;
}
Vector3 dirNor = tf.Forward;
Vector3 offset = new Vector3(0.0f, rayYOffset, 0.0f);
List<RaycastHit> rayList1 = Physics.ColliderRaycast(GameObject, new Ray(offset, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.ColliderRaycast(GameObject, new Ray(offset, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.ColliderRaycast(GameObject, new Ray(offset, dirNor), rayDistance, false, (ushort)65535);
}
protected override void fixedUpdate()
{
if (move)
{
// Apply force in the direction the box is facing
// AKA Transform's forward
body.AddForce(tf.Forward * forceAmount);
move = false;
}
for (int i = 0; i < 2; ++i)
{
bool shouldRotate = rotate[i];
if (shouldRotate)
{
body.AddTorque(rotateVec[i] * torqueAmount);
rotate[i] = false;
}
}
}
}

View File

@ -0,0 +1,3 @@
Name: MovementTest
ID: 164554656
Type: 9

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using System;
using System.Collections.Generic;
using static Item;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection.Metadata.Ecma335;
using SHADE;
using SHADE_Scripting.UI;

View File

@ -0,0 +1,317 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SHADE;
public class CutsceneEnd : Script
{
public uint nextScene;
public float duration = 3.0f;
public float skipDuration = 0.1f;
private float oldDuration = 0.0f;
private Renderable pic4aRenderable;
private Renderable pic4bRenderable;
private Renderable pic4cRenderable;
private Renderable pic5aRenderable;
private Renderable pic5bRenderable;
private Transform pic4aTran;
private Transform pic4bTran;
private Transform pic4cTran;
private Transform pic5aTran;
private Transform pic5bTran;
private float alphaIn = 0.0f;
private float time = 0.0f;
private bool showPic4a = true;
private bool showPic4b = false;
private bool showPic4c = false;
private bool showPic5a = true;
private bool showPic5b = false;
private bool skip = false;
public GameObject cutscene4Points;
private List<Transform> listOfCutscene4Points;
public GameObject cutscene4Pics;
private List<Renderable> listOfCutscene4Pics;
public GameObject cutscene5Points;
private List<Transform> listOfCutscene5Points;
public GameObject cutscene5Pics;
private List<Renderable> listOfCutscene5Pics;
private TextRenderable text4;
private TextRenderable text5;
public GameObject canvas4;
public GameObject canvas5;
private bool cutscene4Done = false;
private bool cutscene5Done = false;
protected override void awake()
{
initCutscene4();
initCutscene5();
}
protected override void update()
{
Canvas4();
Canvas5();
if (Input.GetKeyDown(Input.KeyCode.Space) && !skip && (!cutscene4Done || !cutscene5Done))
{
skip = true;
oldDuration = duration;
duration = skipDuration;
}
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene4Done && canvas4.IsActiveSelf)
{
canvas4.SetActive(false);
canvas5.SetActive(true);
duration = oldDuration;
skip = false;
}
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene5Done && canvas5.IsActiveSelf)
{
SceneManager.ChangeScene(nextScene);
}
}
private void Canvas4()
{
if (canvas4.IsActiveSelf)
{
if (showPic4a)
{
if (time < duration)
{
pic4aTran.LocalPosition = Vector3.Lerp(pic4aTran.LocalPosition, listOfCutscene4Points[0].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic4aTran.LocalPosition = listOfCutscene4Points[0].LocalPosition;
alphaIn = 1.0f;
}
pic4aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic4a = false;
showPic4b = true;
time = 0;
alphaIn = 0;
}
}
if (showPic4b)
{
if (time < duration)
{
pic4bTran.LocalPosition = Vector3.Lerp(pic4bTran.LocalPosition, listOfCutscene4Points[1].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic4bTran.LocalPosition = listOfCutscene4Points[1].LocalPosition;
alphaIn = 1.0f;
}
pic4bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic4b = false;
showPic4c = true;
time = 0;
alphaIn = 0;
}
}
if (showPic4c)
{
if (time < duration)
{
pic4cTran.LocalPosition = Vector3.Lerp(pic4cTran.LocalPosition, listOfCutscene4Points[2].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic4cTran.LocalPosition = listOfCutscene4Points[2].LocalPosition;
alphaIn = 1.0f;
}
pic4cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic4c = false;
cutscene4Done = true;
text4.Enabled = true;
time = 0;
alphaIn = 0;
}
}
}
}
private void Canvas5()
{
if (canvas5.IsActiveSelf)
{
if (showPic5a)
{
if (time < duration)
{
pic5aTran.LocalPosition = Vector3.Lerp(pic5aTran.LocalPosition, listOfCutscene5Points[0].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic5aTran.LocalPosition = listOfCutscene5Points[0].LocalPosition;
alphaIn = 1.0f;
}
pic5aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic5a = false;
showPic5b = true;
time = 0;
alphaIn = 0;
}
}
if (showPic5b)
{
if (time < duration)
{
pic5bTran.LocalPosition = Vector3.Lerp(pic5bTran.LocalPosition, listOfCutscene5Points[1].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic5bTran.LocalPosition = listOfCutscene5Points[1].LocalPosition;
alphaIn = 1.0f;
}
pic5bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic5b = false;
text5.Enabled = true;
cutscene5Done = true;
time = 0;
alphaIn = 0;
}
}
}
}
private void initCutscene4()
{
if (cutscene4Points)
listOfCutscene4Points = cutscene4Points.GetComponentsInChildren<Transform>().ToList();
else
Debug.LogError("Cutscene4Points Missing");
if (listOfCutscene4Points.Count == 0)
Debug.LogError("Cutscene4Points Empty");
listOfCutscene4Pics = cutscene4Pics.GetComponentsInChildren<Renderable>().ToList();
if (listOfCutscene4Pics.Count == 0)
Debug.LogError("Cutscene4Pics Empty");
if (listOfCutscene4Pics[0])
{
pic4aRenderable = listOfCutscene4Pics[0].GetComponent<Renderable>();
pic4aTran = listOfCutscene4Pics[0].GetComponent<Transform>();
pic4aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 4 PIC1 MISSING");
if (listOfCutscene4Pics[1])
{
pic4bRenderable = listOfCutscene4Pics[1].GetComponent<Renderable>();
pic4bTran = listOfCutscene4Pics[1].GetComponent<Transform>();
pic4bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 4 PIC2 MISSING");
if (listOfCutscene4Pics[2])
{
pic4cRenderable = listOfCutscene4Pics[2].GetComponent<Renderable>();
pic4cTran = listOfCutscene4Pics[2].GetComponent<Transform>();
pic4cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 1 PIC3 MISSING");
if (canvas4)
{
text4 = canvas4.GetComponentInChildren<TextRenderable>();
text4.Enabled = false;
}
else
Debug.LogError("Canvas 4 missing");
}
private void initCutscene5()
{
if (cutscene5Points)
listOfCutscene5Points = cutscene5Points.GetComponentsInChildren<Transform>().ToList();
else
Debug.LogError("cutscene5Points Missing");
if (listOfCutscene5Points.Count == 0)
Debug.LogError("Cutscene5Points Empty");
listOfCutscene5Pics = cutscene5Pics.GetComponentsInChildren<Renderable>().ToList();
if (listOfCutscene5Pics.Count == 0)
Debug.LogError("Cutscene5Pics Empty");
if (listOfCutscene5Pics[0])
{
pic5aRenderable = listOfCutscene5Pics[0].GetComponent<Renderable>();
pic5aTran = listOfCutscene5Pics[0].GetComponent<Transform>();
pic5aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 5 PIC1 MISSING");
if (listOfCutscene5Pics[1])
{
pic5bRenderable = listOfCutscene5Pics[1].GetComponent<Renderable>();
pic5bTran = listOfCutscene5Pics[1].GetComponent<Transform>();
pic5bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 5 PIC2 MISSING");
if (canvas5)
{
text5 = canvas5.GetComponentInChildren<TextRenderable>();
text5.Enabled = false;
canvas5.SetActive(false);
}
else
Debug.LogError("Canvas 5 missing");
}
}

View File

@ -0,0 +1,3 @@
Name: SC_CutSceneEnd
ID: 153706859
Type: 9

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using SHADE;

View File

@ -0,0 +1,584 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SHADE;
public class CutsceneIntro : Script
{
public uint nextScene;
public float duration = 3.0f;
public float skipDuration = 0.1f;
private float oldDuration = 0.0f;
private Renderable pic1aRenderable;
private Renderable pic1bRenderable;
private Renderable pic1cRenderable;
private Renderable pic2aRenderable;
private Renderable pic2bRenderable;
private Renderable pic2cRenderable;
private Renderable pic3aRenderable;
private Renderable pic3bRenderable;
private Renderable pic3cRenderable;
private Renderable pic3dRenderable;
private Renderable pic3eRenderable;
private Transform pic1aTran;
private Transform pic1bTran;
private Transform pic1cTran;
private Transform pic2aTran;
private Transform pic2bTran;
private Transform pic2cTran;
private Transform pic3aTran;
private Transform pic3bTran;
private Transform pic3cTran;
private Transform pic3dTran;
private Transform pic3eTran;
private float alphaIn = 0.0f;
private float time = 0.0f;
private bool showPic1a = true;
private bool showPic1b = false;
private bool showPic1c = false;
private bool showPic2a = true;
private bool showPic2b = false;
private bool showPic2c = false;
private bool showPic3a = true;
private bool showPic3b = false;
private bool showPic3c = false;
private bool showPic3e = false;
private bool showPic3d = false;
private bool skip = false;
public GameObject cutscene1Points;
private List<Transform> listOfCutscene1Points;
public GameObject cutscene1Pics;
private List<Renderable> listOfCutscene1Pics;
public GameObject cutscene2Points;
private List<Transform> listOfCutscene2Points;
public GameObject cutscene2Pics;
private List<Renderable> listOfCutscene2Pics;
public GameObject cutscene3Points;
private List<Transform> listOfCutscene3Points;
public GameObject cutscene3Pics;
private List<Renderable> listOfCutscene3Pics;
private TextRenderable text1;
private TextRenderable text2;
private TextRenderable text3;
public GameObject canvas1;
public GameObject canvas2;
public GameObject canvas3;
private bool cutscene1Done = false;
private bool cutscene2Done = false;
private bool cutscene3Done = false;
protected override void awake()
{
initCutscene1();
initCutscene2();
initCutscene3();
}
protected override void update()
{
Canvas1();
Canvas2();
Canvas3();
if (Input.GetKeyDown(Input.KeyCode.Space) && !skip && (!cutscene1Done || !cutscene2Done || !cutscene3Done))
{
skip = true;
oldDuration = duration;
duration = skipDuration;
}
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene1Done && canvas1.IsActiveSelf)
{
canvas1.SetActive(false);
canvas2.SetActive(true);
duration = oldDuration;
skip = false;
}
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene2Done && canvas2.IsActiveSelf)
{
canvas2.SetActive(false);
canvas3.SetActive(true);
duration = oldDuration;
skip = false;
}
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene3Done && canvas3.IsActiveSelf)
{
SceneManager.ChangeScene(nextScene);
}
}
private void Canvas1()
{
if (canvas1.IsActiveSelf)
{
if (showPic1a)
{
if (time < duration)
{
pic1aTran.LocalPosition = Vector3.Lerp(pic1aTran.LocalPosition, listOfCutscene1Points[0].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic1aTran.LocalPosition = listOfCutscene1Points[0].LocalPosition;
alphaIn = 1.0f;
}
pic1aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic1a = false;
showPic1b = true;
time = 0;
alphaIn = 0;
}
}
if (showPic1b)
{
if (time < duration)
{
pic1bTran.LocalPosition = Vector3.Lerp(pic1bTran.LocalPosition, listOfCutscene1Points[1].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic1bTran.LocalPosition = listOfCutscene1Points[1].LocalPosition;
alphaIn = 1.0f;
}
pic1bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic1b = false;
showPic1c = true;
time = 0;
alphaIn = 0;
}
}
if (showPic1c)
{
if (time < duration)
{
pic1cTran.LocalPosition = Vector3.Lerp(pic1cTran.LocalPosition, listOfCutscene1Points[2].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic1cTran.LocalPosition = listOfCutscene1Points[2].LocalPosition;
alphaIn = 1.0f;
}
pic1cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic1c = false;
cutscene1Done = true;
text1.Enabled = true;
time = 0;
alphaIn = 0;
}
}
}
}
private void Canvas2()
{
if (canvas2.IsActiveSelf)
{
if (showPic2a)
{
if (time < duration)
{
pic2aTran.LocalPosition = Vector3.Lerp(pic2aTran.LocalPosition, listOfCutscene2Points[0].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic2aTran.LocalPosition = listOfCutscene2Points[0].LocalPosition;
alphaIn = 1.0f;
}
pic2aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic2a = false;
showPic2b = true;
time = 0;
alphaIn = 0;
}
}
if (showPic2b)
{
if (time < duration)
{
pic2bTran.LocalPosition = Vector3.Lerp(pic2bTran.LocalPosition, listOfCutscene2Points[1].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic2bTran.LocalPosition = listOfCutscene2Points[1].LocalPosition;
alphaIn = 1.0f;
}
pic2bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic2b = false;
showPic2c = true;
time = 0;
alphaIn = 0;
}
}
if (showPic2c)
{
if (time < duration)
{
pic2cTran.LocalPosition = Vector3.Lerp(pic2cTran.LocalPosition, listOfCutscene2Points[2].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic2cTran.LocalPosition = listOfCutscene2Points[2].LocalPosition;
alphaIn = 1.0f;
}
pic2cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic2c = false;
cutscene2Done = true;
text2.Enabled = true;
time = 0;
alphaIn = 0;
}
}
}
}
private void Canvas3()
{
if (canvas3.IsActiveSelf)
{
if (showPic3a)
{
if (time < duration)
{
pic3aTran.LocalPosition = Vector3.Lerp(pic3aTran.LocalPosition, listOfCutscene3Points[0].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic3aTran.LocalPosition = listOfCutscene3Points[0].LocalPosition;
alphaIn = 1.0f;
}
pic3aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic3a = false;
showPic3b = true;
time = 0;
alphaIn = 0;
}
}
if (showPic3b)
{
if (time < duration)
{
pic3bTran.LocalPosition = Vector3.Lerp(pic3bTran.LocalPosition, listOfCutscene3Points[1].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic3bTran.LocalPosition = listOfCutscene3Points[1].LocalPosition;
alphaIn = 1.0f;
}
pic3bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic3b = false;
showPic3c = true;
time = 0;
alphaIn = 0;
}
}
if (showPic3c)
{
if (time < duration)
{
pic3cTran.LocalPosition = Vector3.Lerp(pic3cTran.LocalPosition, listOfCutscene3Points[2].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic3cTran.LocalPosition = listOfCutscene3Points[2].LocalPosition;
alphaIn = 1.0f;
}
pic3cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic3c = false;
showPic3d = true;
time = 0;
alphaIn = 0;
}
}
if (showPic3d)
{
if (time < duration)
{
pic3dTran.LocalPosition = Vector3.Lerp(pic3dTran.LocalPosition, listOfCutscene3Points[3].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic3dTran.LocalPosition = listOfCutscene3Points[3].LocalPosition;
alphaIn = 1.0f;
}
pic3dRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic3d = false;
showPic3e = true;
time = 0;
alphaIn = 0;
}
}
if (showPic3e)
{
if (time < duration)
{
pic3eTran.LocalPosition = Vector3.Lerp(pic3eTran.LocalPosition, listOfCutscene3Points[4].LocalPosition, time / duration);
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
time += Time.DeltaTimeF;
}
else
{
pic3eTran.LocalPosition = listOfCutscene3Points[4].LocalPosition;
alphaIn = 1.0f;
}
pic3eRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
if (alphaIn >= 1.0f)
{
showPic3e = false;
cutscene3Done = true;
text3.Enabled = true;
time = 0;
alphaIn = 0;
}
}
}
}
private void initCutscene1()
{
if(cutscene1Points)
listOfCutscene1Points = cutscene1Points.GetComponentsInChildren<Transform>().ToList();
else
Debug.LogError("Cutscene1Points Missing");
if (listOfCutscene1Points.Count == 0)
Debug.LogError("Cutscene1Points Empty");
listOfCutscene1Pics = cutscene1Pics.GetComponentsInChildren<Renderable>().ToList();
if (listOfCutscene1Pics.Count == 0)
Debug.LogError("Cutscene1Pics Empty");
if (listOfCutscene1Pics[0])
{
pic1aRenderable = listOfCutscene1Pics[0].GetComponent<Renderable>();
pic1aTran = listOfCutscene1Pics[0].GetComponent<Transform>();
pic1aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 1 PIC1 MISSING");
if (listOfCutscene1Pics[1])
{
pic1bRenderable = listOfCutscene1Pics[1].GetComponent<Renderable>();
pic1bTran = listOfCutscene1Pics[1].GetComponent<Transform>();
pic1bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 1 PIC2 MISSING");
if (listOfCutscene1Pics[2])
{
pic1cRenderable = listOfCutscene1Pics[2].GetComponent<Renderable>();
pic1cTran = listOfCutscene1Pics[2].GetComponent<Transform>();
pic1cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 1 PIC3 MISSING");
if (canvas1)
{
text1 = canvas1.GetComponentInChildren<TextRenderable>();
text1.Enabled = false;
}
else
Debug.LogError("Canvas 1 missing");
}
private void initCutscene2()
{
if(cutscene2Points)
listOfCutscene2Points = cutscene2Points.GetComponentsInChildren<Transform>().ToList();
else
Debug.LogError("cutscene2Points Missing");
if (listOfCutscene2Points.Count == 0)
Debug.LogError("Cutscene2Points Empty");
listOfCutscene2Pics = cutscene2Pics.GetComponentsInChildren<Renderable>().ToList();
if (listOfCutscene2Pics.Count == 0)
Debug.LogError("Cutscene2Pics Empty");
if (listOfCutscene2Pics[0])
{
pic2aRenderable = listOfCutscene2Pics[0].GetComponent<Renderable>();
pic2aTran = listOfCutscene2Pics[0].GetComponent<Transform>();
pic2aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 2 PIC1 MISSING");
if (listOfCutscene2Pics[1])
{
pic2bRenderable = listOfCutscene2Pics[1].GetComponent<Renderable>();
pic2bTran = listOfCutscene2Pics[1].GetComponent<Transform>();
pic2bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 2 PIC2 MISSING");
if (listOfCutscene2Pics[2])
{
pic2cRenderable = listOfCutscene2Pics[2].GetComponent<Renderable>();
pic2cTran = listOfCutscene2Pics[2].GetComponent<Transform>();
pic2cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 2 PIC3 MISSING");
if (canvas2)
{
text2 = canvas2.GetComponentInChildren<TextRenderable>();
text2.Enabled = false;
canvas2.SetActive(false);
}
else
Debug.LogError("Canvas 2 missing");
}
private void initCutscene3()
{
if(cutscene3Points)
listOfCutscene3Points = cutscene3Points.GetComponentsInChildren<Transform>().ToList();
else
Debug.LogError("cutscene3Points Missing");
if (listOfCutscene3Points.Count == 0)
Debug.LogError("Cutscene3Points Empty");
listOfCutscene3Pics = cutscene3Pics.GetComponentsInChildren<Renderable>().ToList();
if (listOfCutscene3Pics.Count == 0)
Debug.LogError("Cutscene3Pics Empty");
if (listOfCutscene3Pics[0])
{
pic3aRenderable = listOfCutscene3Pics[0].GetComponent<Renderable>();
pic3aTran = listOfCutscene3Pics[0].GetComponent<Transform>();
pic3aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 3 PIC1 MISSING");
if (listOfCutscene3Pics[1])
{
pic3bRenderable = listOfCutscene3Pics[1].GetComponent<Renderable>();
pic3bTran = listOfCutscene3Pics[1].GetComponent<Transform>();
pic3bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 3 PIC2 MISSING");
if (listOfCutscene3Pics[2])
{
pic3cRenderable = listOfCutscene3Pics[2].GetComponent<Renderable>();
pic3cTran = listOfCutscene3Pics[2].GetComponent<Transform>();
pic3cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 3 PIC3 MISSING");
if (listOfCutscene3Pics[3])
{
pic3dRenderable = listOfCutscene3Pics[3].GetComponent<Renderable>();
pic3dTran = listOfCutscene3Pics[3].GetComponent<Transform>();
pic3dRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 3 PIC4 MISSING");
if (listOfCutscene3Pics[4])
{
pic3eRenderable = listOfCutscene3Pics[4].GetComponent<Renderable>();
pic3eTran = listOfCutscene3Pics[4].GetComponent<Transform>();
pic3eRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
}
else
Debug.LogError("SCENE 2 PIC5 MISSING");
if (canvas3)
{
text3 = canvas3.GetComponentInChildren<TextRenderable>();
text3.Enabled = false;
canvas3.SetActive(false);
}
else
Debug.LogError("Canvas 3 missing");
}
}

View File

@ -0,0 +1,3 @@
Name: SC_CutsceneIntro
ID: 154967292
Type: 9

View File

@ -1,4 +1,4 @@
using System;
using System;
using SHADE;
using SHADE_Scripting.Audio;
using SHADE_Scripting.UI;

View File

@ -1,4 +1,4 @@
using System;
using System;
using SHADE;
using SHADE_Scripting.Audio;
using SHADE_Scripting.UI;
@ -30,17 +30,6 @@ public class MainMenu : Script
}
protected override void update()
{
/* if (Input.GetKeyDown(Input.KeyCode.K) && obj)
{
if (testRenderable.Material.GetProperty<float>("data.alpha") == 1)
{
testRenderable.Material.SetProperty<float>("data.alpha", 0);
}
else if (testRenderable.Material.GetProperty<float>("data.alpha") == 0)
{
testRenderable.Material.SetProperty<float>("data.alpha", 1);
}
}*/
if (Input.GetKeyDown(Input.KeyCode.Space))
{

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,4 +1,4 @@
using System;
using System;
using SHADE;
using SHADE_Scripting.Audio;

View File

@ -1,4 +1,4 @@
using SHADE;
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,4 +1,4 @@
using System;
using System;
using SHADE;
namespace SHADE_Scripting.UI

View File

@ -78,8 +78,14 @@ void main()
outEntityID = In2.eid;
lightLayerIndices = In2.lightLayerIndex;
float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition;
vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight);
// float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition;
// bring the frame of reference to the object's screen space pos
int scale = 470;
float vpHeight = float (In2.screenSpacePos.y);
float relativePos = float(int (-MatProp.data[In2.materialIndex].highlightPosition) % scale) - float (scale / 2);
vpHeight += relativePos;
// vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight);
float scanlineScale = MatProp.data[In2.materialIndex].thickness * (1.0f - In2.screenSpacePos.z) * 100.0f;
float lowerLimit = vpHeight - scanlineScale;

View File

@ -3,7 +3,7 @@
#extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require
layout (input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput sceneTexture;
layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture;
layout(location = 0) out vec4 fragColor;

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: TX_cutscene_04a
ID: 51238312
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: TX_cutscene_04b
ID: 61471971
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: TX_cutscene_04c
ID: 58217538
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: TX_cutscene_05a
ID: 61980534
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: TX_cutscene_05b
ID: 51561286
Type: 3

View File

@ -40,8 +40,6 @@
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Math/Transform/SHTransformComponent.h"
#include "Scenes/SBTestScene.h"
#include "Assets/SHAssetManager.h"
#include "Scenes/SBMainScene.h"
#include "Serialization/Configurations/SHConfigurationManager.h"

View File

@ -1,249 +0,0 @@
#include "SBpch.h"
#include "SBTestScene.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Graphics/MiddleEnd/Meshes/SHPrimitiveGenerator.h"
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "Scripting/SHScriptEngine.h"
#include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Physics/Interface/SHRigidBodyComponent.h"
#include "Physics/Interface/SHColliderComponent.h"
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
#include "Assets/SHAssetManager.h"
#include "Camera/SHCameraComponent.h"
#include "Math/SHColour.h"
#include "Resource/SHResourceManager.h"
#include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h"
#include "Tools/SHDebugDraw.h"
using namespace SHADE;
namespace Sandbox
{
void SBTestScene::WindowFocusFunc([[maybe_unused]] void* window, int focused)
{
if (focused)
{
}
else
{
}
}
void SBTestScene::Load()
{
}
void SBTestScene::Init()
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
// Create temp meshes
const auto CUBE_MESH = SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
//Test Racoon mesh
std::vector<Handle<SHMesh>> handles;
std::vector<Handle<SHTexture>> texHandles;
for (const auto& asset : SHAssetManager::GetAllAssets())
{
switch (asset.type)
{
case AssetType::MESH:
if (asset.name == "Raccoon")
handles.emplace_back(SHResourceManager::LoadOrGet<SHMesh>(asset.id));
break;
case AssetType::TEXTURE:
if (asset.name == "RaccoonPreTexturedVer1_Base9")
texHandles.emplace_back(SHResourceManager::LoadOrGet<SHTexture>(asset.id));
break;
}
}
SHResourceManager::FinaliseChanges();
// Create Materials
auto baseRaccoonMat = graphicsSystem->AddOrGetBaseMaterialInstance();
auto baseRaccoonMatInstant = graphicsSystem->AddMaterialInstanceCopy(baseRaccoonMat);
baseRaccoonMatInstant->SetProperty("data.color", SHVec4(1.0f, 1.0f, 1.0f, 1.0f));
baseRaccoonMatInstant->SetProperty("data.textureIndex", 0);
baseRaccoonMatInstant->SetProperty("data.alpha", 0.1f);
auto baseFloorMatInstant = graphicsSystem->AddMaterialInstanceCopy(baseRaccoonMat);
baseFloorMatInstant->SetProperty("data.color", SHVec4(1.0f, 1.0f, 1.0f, 1.0f));
baseFloorMatInstant->SetProperty("data.textureIndex", 0);
baseFloorMatInstant->SetProperty("data.alpha", 0.1f);
auto dummy = SHEntityManager::CreateEntity<>();
auto floor = SHEntityManager::CreateEntity<SHTransformComponent,SHRenderable, SHRigidBodyComponent, SHColliderComponent>();
auto& floorRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(floor);
auto& floorTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(floor);
auto& floorRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(floor);
auto& floorCollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(floor);
floorRenderable.SetMesh(CUBE_MESH);
floorRenderable.SetMaterial(graphicsSystem->GetDefaultMaterialInstance());
floorTransform.SetWorldScale({ 17.5f, 0.5f, 17.5f });
floorTransform.SetWorldPosition({ 0.0f, -3.0f, -5.0f });
floorRigidBody.SetType(SHRigidBodyComponent::Type::STATIC);
//floorCollider.AddBoundingBox();
// Create blank entity with a script
//testObj = SHADE::SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
//auto& testObjRenderable = *SHComponentManager::GetComponent<SHRenderable>(testObj);
//testObjRenderable.Mesh = CUBE_MESH;
//testObjRenderable.SetMaterial(matInst);
//raccoon =======================================================================================================================
auto racoon = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "Player");
auto& racoonRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(racoon);
auto& racoonTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(racoon);
auto& racoonRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(racoon);
auto& racoonCollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(racoon);
racoonRenderable.SetMesh(handles.front());
racoonRenderable.SetMaterial(baseRaccoonMatInstant);
racoonTransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
racoonTransform.SetWorldPosition({ -3.0f, -2.0f, -5.0f });
//racoonCollider.AddBoundingBox();
racoonCollider.GetCollisionShape(0).SetPositionOffset(SHVec3(0.0f,0.5f,0.0f));
//racoonCollider.GetCollisionShape(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
auto racoonItemLocation = SHEntityManager::CreateEntity<SHTransformComponent>();
auto& racoonItemLocationTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(racoonItemLocation);
SHSceneManager::GetCurrentSceneGraph().SetParent(racoonItemLocation, racoon);
auto racoonCamera = SHEntityManager::CreateEntity<SHTransformComponent>();
SHSceneManager::GetCurrentSceneGraph().SetParent(racoonCamera, racoon);
//================================================================================================================================
//item ===========================================================================================================================
auto item = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "item");
auto& itemRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(item);
auto& itemTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(item);
auto& itemRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(item);
auto& itemCollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(item);
itemRenderable.SetMesh(handles.front());
itemRenderable.SetMaterial(baseRaccoonMatInstant);
itemTransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
itemTransform.SetWorldPosition({ 0.0f, -2.0f, -5.0f });
//itemCollider.AddBoundingBox();
//itemCollider.AddBoundingBox(SHVec3(2.0f,2.0f,2.0f));
itemCollider.GetCollisionShape(1).SetIsTrigger(true);
itemCollider.GetCollisionShape(0).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
//itemCollider.GetCollisionShape(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
itemCollider.GetCollisionShape(1).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
//itemCollider.GetCollisionShape(1).SetBoundingBox(SHVec3(1.0f, 1.0f, 1.0f));
itemRigidBody.SetInterpolate(false);
itemRigidBody.SetFreezeRotationX(true);
itemRigidBody.SetFreezeRotationY(true);
itemRigidBody.SetFreezeRotationZ(true);
//================================================================================================================================
//AI =============================================================================================================================
auto AI = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "AI");
auto& AIRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(AI);
auto& AITransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(AI);
auto& AIRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(AI);
auto& AICollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(AI);
AIRenderable.SetMesh(handles.front());
AIRenderable.SetMaterial(baseRaccoonMatInstant);
AITransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
AITransform.SetWorldPosition({ -8.0f, -2.0f, 2.5f });
//AICollider.AddBoundingBox();
AICollider.GetCollisionShape(0).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
//AICollider.GetCollisionShape(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
AIRigidBody.SetInterpolate(false);
AIRigidBody.SetFreezeRotationX(true);
AIRigidBody.SetFreezeRotationY(true);
AIRigidBody.SetFreezeRotationZ(true);
//================================================================================================================================
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
scriptEngine->AddScript(racoon, "PlayerController");
scriptEngine->AddScript(racoon, "PickAndThrow");
scriptEngine->AddScript(racoonCamera, "ThirdPersonCamera");
scriptEngine->AddScript(AI, "AIPrototype");
scriptEngine->AddScript(item, "Item");
auto raccoonShowcase = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
auto& renderableShowcase = *SHComponentManager::GetComponent_s<SHRenderable>(raccoonShowcase);
auto& transformShowcase = *SHComponentManager::GetComponent_s<SHTransformComponent>(raccoonShowcase);
renderableShowcase.SetMesh(handles.front());
renderableShowcase.SetMaterial(baseRaccoonMatInstant);
renderableShowcase.GetModifiableMaterial()->SetProperty("data.color", SHVec4(1.0f, 1.0f, 1.0f, 1.0f));
renderableShowcase.GetModifiableMaterial()->SetProperty("data.alpha", 1.0f);
renderableShowcase.GetModifiableMaterial()->SetProperty("data.textureIndex", 0);
transformShowcase.SetWorldPosition({ 3.0f, -1.0f, -1.0f });
transformShowcase.SetLocalScale({ 5.0f, 5.0f, 5.0f });
scriptEngine->AddScript(raccoonShowcase, "RaccoonShowcase");
SHComponentManager::AddComponent<SHCameraComponent>(0);
SHComponentManager::AddComponent<SHLightComponent>(0);
SHComponentManager::RemoveComponent <SHRigidBodyComponent>(0);
SHComponentManager::RemoveComponent <SHColliderComponent>(0);
auto ambientLight = SHEntityManager::CreateEntity<SHLightComponent>();
SHComponentManager::GetComponent<SHLightComponent>(ambientLight)->SetColor(SHColour::WHITE);
SHComponentManager::GetComponent<SHLightComponent>(ambientLight)->SetStrength(0.25f);
SHComponentManager::GetComponent<SHLightComponent>(ambientLight)->SetType(SH_LIGHT_TYPE::AMBIENT);
}
void SBTestScene::Update(float dt)
{
static float rotation = 0.0f;
SHVec3 direction{0.0f, 0.0f, 1.0f};
direction = SHVec3::RotateY(direction, rotation);
auto* lightComp =SHComponentManager::GetComponent<SHLightComponent>(0);
lightComp->SetDirection (direction);
rotation += 0.005f;
//auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testObj);
//transform.SetWorldPosition({1.0f, 1.0f, -1.0f});
//transform.SetWorldRotation(0.0f, 0.0f + rotation, 0.0f);
//rotation += dt * 0.2f;
// Destroy entity if space is pressed
if (GetKeyState(VK_SPACE) & 0x8000)
{
rotation = 0.0f;
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
scriptEngine->RemoveAllScripts(testObj);
}
}
void SBTestScene::Render()
{
}
void SBTestScene::Unload()
{
}
void SBTestScene::Free()
{
//SHSerialization::SerializeScene("resources/scenes/Scene01.SHADE");
}
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "Scene/SHScene.h"
#include "Scene/SHSceneManager.h"
namespace Sandbox
{
class SBTestScene : public SHADE::SHScene
{
private:
EntityID camera;
EntityID testObj;
std::vector<EntityID> stressTestObjects;
public:
virtual void Load();
virtual void Init();
virtual void Update(float dt);
virtual void Render();
virtual void Free();
virtual void Unload();
//TODO: Change to new window DO IT IN CPP TOO
void WindowFocusFunc(void* window, int focused);
SBTestScene(void) = default;
};
}

View File

@ -13,7 +13,7 @@
#include "Math/SHRay.h"
#include "Physics/System/SHPhysicsSystem.h"
#include "Graphics/Events/SHGraphicsEvents.h"
#include "Physics/Collision/CollisionTags/SHCollisionTagMatrix.h"
namespace SHADE
{
@ -217,7 +217,7 @@ namespace SHADE
SHVec3 cameraTarget = camera->position;
SHRaycaster::RaycastInfo info;
SHCollisionSpace::RaycastInfo info;
info.layers = (uint16_t)(SHCollisionTagMatrix::GetTag("Camera")->GetMask());
info.distance = pivot.armLength;
@ -230,7 +230,6 @@ namespace SHADE
{
if (hitResult.distance < pivot.armLength)
{
SHVec3 newOffset{ 0.0f,0.0f, 1.0f };
newOffset = SHVec3::RotateX(newOffset, -(SHMath::DegreesToRadians(pivot.GetPitch())));
newOffset = SHVec3::RotateY(newOffset, (SHMath::DegreesToRadians(pivot.GetYaw())));
@ -559,7 +558,7 @@ namespace SHADE
}
#else
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetHeight() };
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetWidth() / screenAspectRatio };
#endif
}

View File

@ -15,6 +15,7 @@
#include "Editor/SHEditorWidgets.hpp"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
#include "Physics/Interface/SHRigidBodyComponent.h"
#include "Physics/Interface/SHColliderComponent.h"
#include "Reflection/SHReflectionMetadata.h"
#include "Resource/SHResourceManager.h"
@ -262,31 +263,34 @@ namespace SHADE
if(rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
{
SHEditorWidgets::CheckBox("Use Gravity", [component]{return component->IsGravityEnabled();}, [component](bool const& value){component->SetGravityEnabled(value);}, "Gravity");
//SHEditorWidgets::DragFloat("Mass", [component] {return component->GetMass(); }, [component](float const& value) {component->SetMass(value); }, "Mass");
SHEditorWidgets::CheckBox("Use Gravity", [component]{return component->IsGravityEnabled();}, [component](bool const& value){component->SetIsGravityEnabled(value);}, "Whether Gravity is enabled for this body");
SHEditorWidgets::DragFloat("Gravity Scale", [component] { return component->GetGravityScale(); }, [component](float const& value) { component->SetGravityScale(value); }, "Per-object Gravity Scale", 0.1f, 0.0f);
SHEditorWidgets::CheckBox("Auto Mass", [component]{return component->GetAutoMass();}, [component](bool const& value){component->SetAutoMass(value);}, "If mass should be automatically computed. Setting mass will turn this off.");
SHEditorWidgets::DragFloat("Mass", [component] {return component->GetMass(); }, [component](float const& value) {component->SetMass(value); }, "Mass");
}
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
{
SHEditorWidgets::DragFloat("Drag", [component] {return component->GetDrag(); }, [component](float const& value) {component->SetDrag(value); }, "Drag");
SHEditorWidgets::DragFloat("Angular Drag", [component] {return component->GetAngularDrag(); }, [component](float const& value) {component->SetAngularDrag(value); }, "Angular Drag");
SHEditorWidgets::DragFloat("Drag", [component] {return component->GetDrag(); }, [component](float const& value) {component->SetDrag(value); }, "Drag", 0.1f, 0.0f);
SHEditorWidgets::DragFloat("Angular Drag", [component] {return component->GetAngularDrag(); }, [component](float const& value) {component->SetAngularDrag(value); }, "Angular Drag", 0.1f, 0.0f);
SHEditorWidgets::CheckBox("Interpolate", [component] {return component->IsInterpolating(); }, [component](bool const& value) {component->SetInterpolate(value); }, "Interpolate");
SHEditorWidgets::CheckBox("Interpolate", [component] {return component->IsInterpolating(); }, [component](bool const& value) {component->SetInterpolate(value); }, "If the position between frames should be interpolated.");
SHEditorWidgets::BeginPanel(std::format("{} Constraints", ICON_FA_LOCK).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
SHEditorWidgets::TextLabel("Freeze Position");
ImGui::PushID("FreezePos");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezePositionX(); }, [component](bool const& value) {component->SetFreezePositionX(value); }, "Freeze Position - X"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezePositionY(); }, [component](bool const& value) {component->SetFreezePositionY(value); }, "Freeze Position - Y"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezePositionZ(); }, [component](bool const& value) {component->SetFreezePositionZ(value); }, "Freeze Position - Z");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezePositionX(); }, [component](bool const& value) {component->SetFreezePositionX(value); }, "Stops any displacement along the X-axis."); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezePositionY(); }, [component](bool const& value) {component->SetFreezePositionY(value); }, "Stops any displacement along the Y-axis."); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezePositionZ(); }, [component](bool const& value) {component->SetFreezePositionZ(value); }, "Stops any displacement along the Z-axis.");
ImGui::PopID();
SHEditorWidgets::TextLabel("Freeze Rotation");
ImGui::PushID("FreezeRot");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezeRotationX(); }, [component](bool const& value) {component->SetFreezeRotationX(value); }, "Freeze Rotation - X"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezeRotationY(); }, [component](bool const& value) {component->SetFreezeRotationY(value); }, "Freeze Rotation - Y"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezeRotationZ(); }, [component](bool const& value) {component->SetFreezeRotationZ(value); }, "Freeze Rotation - Z");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezeRotationX(); }, [component](bool const& value) {component->SetFreezeRotationX(value); }, "Stops any rotation about the X-axis."); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezeRotationY(); }, [component](bool const& value) {component->SetFreezeRotationY(value); }, "Stops any rotation about the Y-axis."); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezeRotationZ(); }, [component](bool const& value) {component->SetFreezeRotationZ(value); }, "Stops any rotation about the Z-axis.");
ImGui::PopID();
SHEditorWidgets::EndPanel();
@ -297,7 +301,14 @@ namespace SHADE
{
SHEditorWidgets::DragFloat("Mass", [component] { return component->GetMass(); }, [](float value){}, "Mass", 0.1f, 0.0f, std::numeric_limits<float>::infinity(), "%.3f", ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [component] {return component->GetPosition(); }, [](SHVec3 const& value) {}, false, "Position", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" }, [component] {return component->GetRotation(); }, [](SHVec3 const& value) {}, false, "Rotation", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" }, [component]
{
// Convert it to degrees...
auto rot = component->GetRotation();
for (size_t i = 0; i < SHVec3::SIZE; ++i)
rot[i] = SHMath::RadiansToDegrees(rot[i]);
return rot;
}, [](SHVec3 const& value) {}, false, "Rotation", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
{
SHEditorWidgets::DragVec3("Velocity", { "X", "Y", "Z" }, [component] {return component->GetLinearVelocity(); }, [](SHVec3 const& value) {}, false, "Linear Velocity", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
@ -341,64 +352,65 @@ namespace SHADE
SHEditorWidgets::CheckBox("Draw Colliders", [component] { return component->GetDebugDrawState(); }, [component](bool value) { component->SetDebugDrawState(value); });
auto& colliders = component->GetCollisionShapes();
int const size = static_cast<int>(colliders.size());
ImGui::BeginChild("Collision Shapes", { 0.0f, colliders.empty() ? 1.0f : 250.0f }, true);
auto* collisionShapes = component->GetCollisionShapes();
int const size = collisionShapes ? static_cast<int>(collisionShapes->size()) : 0;
ImGui::BeginChild("Collision Shapes", { 0.0f, collisionShapes->empty() ? 1.0f : 250.0f }, true);
std::optional<int> colliderToDelete{ std::nullopt };
for (int i{}; i < size; ++i)
{
ImGui::PushID(i);
SHCollisionShape* collisionShape = &component->GetCollisionShape(i);
SHCollisionShape* shape = component->GetCollisionShape(i);
auto cursorPos = ImGui::GetCursorPos();
if (collisionShape->GetType() == SHCollisionShape::Type::BOX)
if (shape->GetType() == SHCollisionShape::Type::BOX)
{
SHEditorWidgets::BeginPanel(std::format("{} Box #{}", ICON_FA_CUBE, i).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
auto* boxShape = dynamic_cast<SHBox*>(collisionShape);
auto* box = reinterpret_cast<SHBox*>(shape);
SHEditorWidgets::DragVec3
(
"Half Extents", { "X", "Y", "Z" },
[boxShape] { return boxShape->GetRelativeExtents(); },
[boxShape](SHVec3 const& vec) { boxShape->SetRelativeExtents(vec); });
[box] { return box->GetRelativeExtents(); },
[box](SHVec3 const& vec) { box->SetRelativeExtents(vec); });
}
else if (collisionShape->GetType() == SHCollisionShape::Type::SPHERE)
else if (shape->GetType() == SHCollisionShape::Type::SPHERE)
{
SHEditorWidgets::BeginPanel(std::format("{} Sphere #{}", ICON_MD_CIRCLE, i).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
auto* sphereShape = dynamic_cast<SHSphere*>(collisionShape);
auto* sphere = reinterpret_cast<SHSphere*>(shape);
SHEditorWidgets::DragFloat
(
"Radius",
[sphereShape] { return sphereShape->GetRelativeRadius(); },
[sphereShape](float const& value) { sphereShape->SetRelativeRadius(value); });
[sphere] { return sphere->GetRelativeRadius(); },
[sphere](float const& value) { sphere->SetRelativeRadius(value); });
}
//else if (collisionShape->GetType() == SHCollisionShape::Type::CAPSULE)
//{
else if (shape->GetType() == SHCollisionShape::Type::CAPSULE)
{
//}
}
{
SHEditorWidgets::CheckBox("Is Trigger", [collisionShape] { return collisionShape->IsTrigger(); }, [collisionShape](bool value) { collisionShape->SetIsTrigger(value); });
SHEditorWidgets::ComboBox("Tag", collisionTagNames, [collisionShape]{return SHCollisionTagMatrix::GetTagIndex(collisionShape->GetCollisionTag().GetName());}, [collisionShape](int const& value){collisionShape->SetCollisionTag(SHCollisionTagMatrix::GetTag(value));});
SHEditorWidgets::CheckBox("Is Trigger", [shape] { return shape->IsTrigger(); }, [shape](bool value) { shape->SetIsTrigger(value); });
SHEditorWidgets::ComboBox("Tag", collisionTagNames, [shape]{return SHCollisionTagMatrix::GetTagIndex(shape->GetCollisionTag().GetName());}, [shape](int const& value){shape->SetCollisionTag(SHCollisionTagMatrix::GetTag(value));});
if(ImGui::CollapsingHeader("Physics Material"))
{
SHEditorWidgets::DragFloat("Friction", [collisionShape] { return collisionShape->GetFriction(); }, [collisionShape](float value) { collisionShape->SetFriction(value); }, "Friction", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Bounciness", [collisionShape] { return collisionShape->GetBounciness(); }, [collisionShape](float value) { collisionShape->SetBounciness(value); }, "Bounciness", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Mass Density", [collisionShape] { return collisionShape->GetDensity(); }, [collisionShape](float value) { collisionShape->SetDensity(value); }, "Mass Density", 0.1f, 0.0f);
SHEditorWidgets::DragFloat("Friction", [shape] { return shape->GetFriction(); }, [shape](float value) { shape->SetFriction(value); }, "Friction", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Bounciness", [shape] { return shape->GetBounciness(); }, [shape](float value) { shape->SetBounciness(value); }, "Bounciness", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Mass Density", [shape] { return shape->GetDensity(); }, [shape](float value) { shape->SetDensity(value); }, "Mass Density", 0.1f, 0.0f);
}
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [collisionShape] {return collisionShape->GetPositionOffset(); }, [collisionShape](SHVec3 const& vec) {collisionShape->SetPositionOffset(vec); });
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&shape] {return shape->GetPositionOffset(); }, [&shape](SHVec3 const& vec) {shape->SetPositionOffset(vec); });
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
[collisionShape]
[&shape]
{
auto offset = collisionShape->GetRotationOffset();
auto offset = shape->GetRotationOffset();
return offset;
},
[collisionShape](SHVec3 const& vec)
[&shape](SHVec3 const& vec)
{
collisionShape->SetRotationOffset(vec);
shape->SetRotationOffset(vec);
}, true);
SHEditorWidgets::EndPanel();
}
@ -413,36 +425,31 @@ namespace SHADE
}
if (colliderToDelete.has_value())
{
component->RemoveCollisionShape(colliderToDelete.value());
component->GetCollider()->RemoveCollisionShape(colliderToDelete.value());
}
ImGui::EndChild();
// TODO: Handle differences between composite & hull collider
if (ImGui::BeginMenu("Add Collider"))
{
int newColl = -1;
if (ImGui::Selectable("Box Collider"))
{
newColl = component->AddBoxCollisionShape(SHVec3::One);
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddBoxCollisionShape(SHVec3::One);
}
if (ImGui::Selectable("Sphere Collider"))
{
newColl = component->AddSphereCollisionShape(1.0f);
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddSphereCollisionShape(1.0f);
}
//No idea why this doesn't work
//if (newColl > 0)
//{
// auto newCollisionShape = component->GetCollisionShape(newColl);
// auto prevCollisionShapeInSeq = component->GetCollisionShape(newColl - 1);
// newCollisionShape.SetCollisionTag(SHCollisionTagMatrix::GetTag(prevCollisionShapeInSeq.GetCollisionTag().GetName()));
//}
ImGui::EndMenu();
}
}
else DrawContextMenu(component);
else
{
DrawContextMenu(component);
}
ImGui::PopID();
}

View File

@ -372,9 +372,14 @@ namespace SHADE
bool drawRays = physicsDebugDraw->GetFlagState(SHPhysicsDebugDrawSystem::DebugDrawFlags::RAYCASTS);
if (ImGui::Checkbox("Draw Rays", &drawRays))
physicsDebugDraw->SetFlagState(SHPhysicsDebugDrawSystem::DebugDrawFlags::RAYCASTS, drawRays);
bool drawBroadphase = physicsDebugDraw->GetFlagState(SHPhysicsDebugDrawSystem::DebugDrawFlags::BROADPHASE);
if (ImGui::Checkbox("Draw Broadphase", &drawBroadphase))
physicsDebugDraw->SetFlagState(SHPhysicsDebugDrawSystem::DebugDrawFlags::BROADPHASE, drawBroadphase);
}
ImGui::EndMenu();
}
}
}//namespace SHADE

View File

@ -55,6 +55,7 @@
#include "Scene/SHSceneManager.h"
#include "Serialization/SHSerialization.h"
#include "Tools/SHDebugDraw.h"
#include "Input/SHInputManager.h"
RTTR_REGISTRATION
{
@ -618,6 +619,7 @@ namespace SHADE
}
else if (editorState == State::PAUSE)
{
SHWindow::SetMouseVisible(prevMouseVisibility);
editorState = State::PLAY;
}
}
@ -626,11 +628,14 @@ namespace SHADE
{
if (editorState == State::PAUSE)
return;
prevMouseVisibility = SHWindow::GetMouseVisible();
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
{
.previousState = editorState
};
editorState = State::PAUSE;
SHWindow::SetMouseVisible(true);
SHInputManager::SetMouseCentering(false);
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PAUSE_EVENT);
}
@ -643,6 +648,8 @@ namespace SHADE
.previousState = editorState
};
editorState = SHEditor::State::STOP;
SHWindow::SetMouseVisible(true);
SHInputManager::SetMouseCentering(false);
SHCommandManager::SwapStacks();
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);

View File

@ -154,7 +154,7 @@ namespace SHADE
SHEventHandle onEditorStateChanged(SHEventPtr eventPtr);
bool isUnsavedChangesPromptOpen = false;
bool prevMouseVisibility = true;
static constexpr std::string_view sceneNamePromptName = "Save scene as...";
static constexpr std::string_view unsavedChangesPromptName = "Unsaved Changes";

View File

@ -512,9 +512,9 @@ namespace SHADE
uint32_t h = static_cast<uint32_t>(resource->GetHeight());
cmdBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
//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);
static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0;
//auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
newSubpass->BindInputDescriptorSets(cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex);
// draw a quad.
cmdBuffer->DrawArrays(4, 1, 0, 0);

View File

@ -21,7 +21,7 @@ namespace SHADE
void SHRenderToSwapchainImageSystem::ConstructPipelines(Handle<SHVkLogicalDevice> logicalDevice) noexcept
{
auto pipelineLayout = logicalDevice->CreatePipelineLayout(SHPipelineLayoutParams
pipelineLayout = logicalDevice->CreatePipelineLayout(SHPipelineLayoutParams
{
.shaderModules = {shaderModules.first, shaderModules.second},
.predefinedDescSetLayouts = {}

View File

@ -0,0 +1,224 @@
/****************************************************************************************
* \file SHAABB.cpp
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Implementation for a 3-Dimensional Axis Aligned Bounding Box
*
* \copyright Copyright (C) 2022 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.
****************************************************************************************/
#include <SHpch.h>
// Primary Header
#include "SHAABB.h"
// Project Headers
#include "Math/SHMathHelpers.h"
#include "Math/SHRay.h"
using namespace DirectX;
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/
SHAABB::SHAABB() noexcept
{
Extents = SHVec3::One * 0.5f;
}
SHAABB::SHAABB(const SHVec3& c, const SHVec3& hE) noexcept
{
Center = c;
Extents = hE;
}
SHAABB::SHAABB(const SHAABB& rhs) noexcept
{
if (this == &rhs)
return;
Center = rhs.Center;
Extents = rhs.Extents;
}
SHAABB::SHAABB(SHAABB&& rhs) noexcept
{
Center = rhs.Center;
Extents = rhs.Extents;
}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
SHAABB& SHAABB::operator=(const SHAABB& rhs) noexcept
{
if (this != &rhs)
{
Center = rhs.Center;
Extents = rhs.Extents;
}
return *this;
}
SHAABB& SHAABB::operator=(SHAABB&& rhs) noexcept
{
Center = rhs.Center;
Extents = rhs.Extents;
return *this;
}
/*-----------------------------------------------------------------------------------*/
/* Getter Function Definitions */
/*-----------------------------------------------------------------------------------*/
SHVec3 SHAABB::GetCenter() const noexcept
{
return Center;
}
SHVec3 SHAABB::GetExtents() const noexcept
{
return Extents;
}
SHVec3 SHAABB::GetMin() const noexcept
{
return SHVec3{ Center.x - Extents.x, Center.y - Extents.y, Center.z - Extents.z };
}
SHVec3 SHAABB::GetMax() const noexcept
{
return SHVec3{ Center.x + Extents.x, Center.y + Extents.y, Center.z + Extents.z };
}
/*-----------------------------------------------------------------------------------*/
/* Setter Function Definitions */
/*-----------------------------------------------------------------------------------*/
void SHAABB::SetCenter(const SHVec3& newCenter) noexcept
{
Center = newCenter;
}
void SHAABB::SetExtents(const SHVec3& newHalfExtents) noexcept
{
Extents = newHalfExtents;
}
void SHAABB::SetMin(const SHVec3& min) noexcept
{
const SHVec3 MAX = GetMax();
Center = SHVec3::Lerp(min, MAX, 0.5f);
Extents = SHVec3::Abs((MAX - min) * 0.5f);
}
void SHAABB::SetMax(const SHVec3& max) noexcept
{
const SHVec3 MIN = GetMin();
Center = SHVec3::Lerp(MIN, max, 0.5f);
Extents = SHVec3::Abs((max - MIN) * 0.5f);
}
void SHAABB::SetMinMax(const SHVec3& min, const SHVec3& max) noexcept
{
Center = SHVec3::Lerp(min, max, 0.5f);
Extents = SHVec3::Abs((max - min) * 0.5f);
}
std::vector<SHVec3> SHAABB::GetVertices() const noexcept
{
std::vector<SHVec3> vertices{ 8 };
GetCorners(vertices.data());
return vertices;
}
/*-----------------------------------------------------------------------------------*/
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHAABB::TestPoint(const SHVec3& point) const noexcept
{
return BoundingBox::Contains(point);
}
SHRaycastResult SHAABB::Raycast(const SHRay& ray) const noexcept
{
SHRaycastResult result;
result.hit = Intersects(ray.position, ray.direction, result.distance);
// Negative distances are invalid, therefore false
if (result.distance < 0.0f)
result.hit = false;
if (result.hit)
{
result.position = ray.position + ray.direction * result.distance;
result.angle = SHVec3::Angle(ray.position, result.position);
// TODO: Compute normal
}
return result;
}
bool SHAABB::Contains(const SHAABB& rhs) const noexcept
{
return BoundingBox::Contains(rhs) == CONTAINS;
}
float SHAABB::Volume() const noexcept
{
return 8.0f * (Extents.x * Extents.y * Extents.z);
}
float SHAABB::SurfaceArea() const noexcept
{
return 8.0f * ((Extents.x * Extents.y)
+ (Extents.x * Extents.z)
+ (Extents.y * Extents.z));
}
/*-----------------------------------------------------------------------------------*/
/* Static Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
SHAABB SHAABB::Combine(const SHAABB& lhs, const SHAABB& rhs) noexcept
{
SHAABB result;
CreateMerged(result, lhs, rhs);
return result;
}
bool SHAABB::Intersect(const SHAABB& lhs, const SHAABB& rhs) noexcept
{
return lhs.Intersects(rhs);
}
SHAABB SHAABB::BuildFromBoxes(const SHAABB* boxes, size_t numBoxes) noexcept
{
SHAABB result;
for (size_t i = 1; i < numBoxes; ++i)
CreateMerged(result, boxes[i - 1], boxes[i]);
return result;
}
SHAABB SHAABB::BuildFromVertices(const SHVec3* vertices, size_t numVertices, size_t stride) noexcept
{
SHAABB result;
CreateFromPoints(result, numVertices, vertices, stride);
return result;
}
} // namespace SHADE

View File

@ -0,0 +1,173 @@
/****************************************************************************************
* \file SHAABB.h
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Interface for a 3-Dimensional Axis Aligned Bounding Box
*
* \copyright Copyright (C) 2022 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
#include <DirectXCollision.h>
// Project Headers
#include "Math/SHRay.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
/**
* @brief
* Encapsulates a 3D Axis-Aligned Bounding Box.
*/
class SH_API SHAABB : private DirectX::BoundingBox
{
public:
/*---------------------------------------------------------------------------------*/
/* Static Data Members */
/*---------------------------------------------------------------------------------*/
static constexpr size_t NUM_VERTICES = 8;
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
~SHAABB () noexcept = default;
SHAABB () noexcept;
SHAABB (const SHVec3& center, const SHVec3& halfExtents) noexcept;
SHAABB (const SHAABB& rhs) noexcept;
SHAABB (SHAABB&& rhs) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
SHAABB& operator= (const SHAABB& rhs) noexcept;
SHAABB& operator= (SHAABB&& rhs) noexcept;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHVec3 GetCenter () const noexcept;
[[nodiscard]] SHVec3 GetExtents () const noexcept;
[[nodiscard]] SHVec3 GetMin () const noexcept;
[[nodiscard]] SHVec3 GetMax () const noexcept;
[[nodiscard]] std::vector<SHVec3> GetVertices () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Setter Functions */
/*---------------------------------------------------------------------------------*/
void SetCenter (const SHVec3& newCenter) noexcept;
void SetExtents (const SHVec3& newHalfExtents) noexcept;
void SetMin (const SHVec3& min) noexcept;
void SetMax (const SHVec3& max) noexcept;
void SetMinMax (const SHVec3& min, const SHVec3& max) noexcept;
/*---------------------------------------------------------------------------------*/
/* Member Functions */
/*---------------------------------------------------------------------------------*/
/**
* @brief
* Checks if a point is inside the aabb.
* @param point
* The point to check.
* @return
* True if the point is inside the aabb.
*/
[[nodiscard]] bool TestPoint (const SHVec3& point) const noexcept;
/**
* @brief
* Casts a ray against the aabb.
* @param ray
* The ray to cast.
* @return
* The result of the raycast. <br/>
* See the corresponding header for the contents of the raycast result object.
*/
[[nodiscard]] SHRaycastResult Raycast (const SHRay& ray) const noexcept;
/**
* @brief
* Checks if an entire other aabb is contained by this aabb.
* @param rhs
* The aabb to check.
* @return
* True if the other sphere is completely contained by this aabb.
*/
[[nodiscard]] bool Contains (const SHAABB& rhs) const noexcept;
/**
* @brief
* Calculates the volume of the aabb.
*/
[[nodiscard]] float Volume () const noexcept;
/**
* @brief
* Calculates the surface area of the aabb.
*/
[[nodiscard]] float SurfaceArea () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Member Functions */
/*---------------------------------------------------------------------------------*/
/**
* @brief
* Combines two aabbs to form a larger aabb.
* If one aabb is completely contained by the other, the result is the larger aabb.
* @return
* The combined aabb.
*/
[[nodiscard]] static SHAABB Combine (const SHAABB& lhs, const SHAABB& rhs) noexcept;
/**
* @brief
* Checks if two aabbs are intersecting.
* @return
* True if they are intersecting.
*/
[[nodiscard]] static bool Intersect (const SHAABB& lhs, const SHAABB& rhs) noexcept;
/**
* @brief
* Builds a single aabb from multiple aabbs.
* @param spheres
* The set of aabbs to build from.
* @param numSpheres
* The number of aabbs in the set to build from.
* @return
* An aabb that contains all the spheres in the set.
*/
[[nodiscard]] static SHAABB BuildFromBoxes (const SHAABB* boxes, size_t numBoxes) noexcept;
/**
* @brief
* Builds a aabb from a set of vertices.
* @param vertices
* The vertices to build a aabb from.
* @param numVertices
* The number of vertices in the set to build from.
* @param stride
* The stride between each vertex, in the instance there is data in between each
* vertex that does not define the geometry of the object.
* @return
* An aabb that contains all the vertices in the set.
*/
[[nodiscard]] static SHAABB BuildFromVertices (const SHVec3* vertices, size_t numVertices, size_t stride = 0) noexcept;
};
} // namespace SHADE

View File

@ -0,0 +1,141 @@
/****************************************************************************************
* \file SHPlane.cpp
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Implementation for a plane.
*
* \copyright Copyright (C) 2022 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.
****************************************************************************************/
#include <SHpch.h>
#include <DirectXMath.h>
// Primary Header
#include "SHPlane.h"
#include "Input/SHInputManager.h"
#include "Math/SHMathHelpers.h"
using namespace DirectX;
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/
SHPlane::SHPlane() noexcept
: planeEquation { SHVec3::One }
{
planeEquation.w = 0.0f;
}
SHPlane::SHPlane(const SHVec3& point, const SHVec3& normal) noexcept
{
XMStoreFloat4(&planeEquation, XMPlaneFromPointNormal(point, normal));
}
SHPlane::SHPlane(float a, float b, float c, float d) noexcept
: planeEquation { a, b, c, d }
{}
SHPlane::SHPlane(const SHVec3& normal, float distance) noexcept
: planeEquation { normal }
{
planeEquation.w = distance;
}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHPlane::operator==(const SHPlane& rhs) const noexcept
{
return XMPlaneEqual(planeEquation, rhs.planeEquation);
}
bool SHPlane::operator!=(const SHPlane& rhs) const noexcept
{
return XMPlaneNotEqual(planeEquation, rhs.planeEquation);
}
/*-----------------------------------------------------------------------------------*/
/* Getter Function Definitions */
/*-----------------------------------------------------------------------------------*/
SHVec3 SHPlane::GetNormal() const noexcept
{
return SHVec3{ planeEquation.x, planeEquation.y, planeEquation.z };
}
float SHPlane::GetDistance() const noexcept
{
return planeEquation.w;
}
/*-----------------------------------------------------------------------------------*/
/* Setter Function Definitions */
/*-----------------------------------------------------------------------------------*/
void SHPlane::SetNormal(const SHVec3& normal) noexcept
{
planeEquation.x = normal.x;
planeEquation.y = normal.y;
planeEquation.z = normal.z;
}
void SHPlane::SetDistance(float distance) noexcept
{
planeEquation.w = distance;
}
/*-----------------------------------------------------------------------------------*/
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHPlane::TestPoint(const SHVec3& point) const noexcept
{
const float DISTANCE = SignedDistance(point);
return SHMath::CompareFloat(DISTANCE, 0.0f);
}
SHRaycastResult SHPlane::Raycast(const SHRay& ray) const noexcept
{
SHRaycastResult result;
const SHVec3 N = GetNormal();
// Check if ray is parallel to plane
const float N_DOT_D = N.Dot(ray.direction);
if (SHMath::CompareFloat(N_DOT_D, 0.0f))
{
result.hit = false;
return result;
}
const float DIST = (planeEquation.w - N.Dot(ray.position)) / N_DOT_D;
if (DIST < 0.0f || !SHMath::CompareFloat(DIST, 0.0f))
{
result.hit = false;
return result;
}
result.hit = true;
result.distance = DIST;
result.position = ray.position + ray.direction * DIST;
result.angle = SHVec3::Angle(ray.position, result.position);
// The normal is either the plane's normal or the reverse if the ray came from below
result.normal = N_DOT_D < 0.0f ? -N : N;
return result;
}
float SHPlane::SignedDistance(const SHVec3& point) const noexcept
{
return XMVectorGetX(XMPlaneDotCoord(planeEquation, point));
}
} // namespace SHADE

View File

@ -0,0 +1,121 @@
/****************************************************************************************
* \file SHPlane.h
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Interface for a plane.
*
* \copyright Copyright (C) 2022 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 Headers
#include "Math/SHRay.h"
#include "Math/Vector/SHVec4.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
/**
* @brief
* Encapsulates a 3D plane in point-normal form.
*/
class SH_API SHPlane
{
public:
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
~SHPlane () noexcept = default;
SHPlane (const SHPlane& rhs) noexcept = default;
SHPlane (SHPlane&& rhs) noexcept = default;
SHPlane () noexcept;
SHPlane (const SHVec3& point, const SHVec3& normal) noexcept;
SHPlane (float a, float b, float c, float d) noexcept;
SHPlane (const SHVec3& normal, float distance) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
SHPlane& operator= (const SHPlane& rhs) noexcept = default;
SHPlane& operator= (SHPlane&& rhs) noexcept = default;
bool operator== (const SHPlane& rhs) const noexcept;
bool operator!= (const SHPlane& rhs) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHVec3 GetNormal () const noexcept;
[[nodiscard]] float GetDistance () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Setter Functions */
/*---------------------------------------------------------------------------------*/
void SetNormal (const SHVec3& normal) noexcept;
void SetDistance (float distance) noexcept;
/*---------------------------------------------------------------------------------*/
/* Member Functions */
/*---------------------------------------------------------------------------------*/
/**
* @brief
* Checks if a point is on the plane.
* @param point
* The point to check.
* @return
* True if the point is on the plane.
*/
[[nodiscard]] bool TestPoint (const SHVec3& point) const noexcept;
/**
* @brief
* Casts a ray against the plane.
* @param ray
* The ray to cast.
* @return
* The result of the raycast. <br/>
* See the corresponding header for the contents of the raycast result object.
*/
[[nodiscard]] SHRaycastResult Raycast (const SHRay& ray) const noexcept;
/**
* @brief
* Gets the signed distance from a point to the plane.
* @param point
* The point to check.
* @return
* The signed distance of the point to a plane. <br/>
* If the signed distance is negative, the point is behind the plane. <br/>
* If the signed distance is zero, the point is on the plane. <br/>
* If the signed distance is positive, the point is in front of the plane. <br/>
*/
[[nodiscard]] float SignedDistance (const SHVec3& point) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Member Functions */
/*---------------------------------------------------------------------------------*/
/*
* TODO:
* Transform plane
* Intersection Tests
*/
private:
SHVec4 planeEquation;
};
} // namespace SHADE

View File

@ -260,6 +260,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -274,6 +276,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -288,6 +292,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -302,6 +308,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}

View File

@ -46,14 +46,16 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/** Standard Epsilon value for comparing Single-Precision Floating-Point values. */
static constexpr float EPSILON = 0.001f;
static constexpr float EPSILON = 0.0001f;
/** Single-Precision Floating-Point value of infinity */
static constexpr float INF = std::numeric_limits<float>::infinity();
static constexpr float INF = std::numeric_limits<float>::infinity();
static constexpr float PI = std::numbers::pi_v<float>;
static constexpr float HALF_PI = PI * 0.5f;
static constexpr float TWO_PI = 2.0f * PI;
static constexpr float PI = std::numbers::pi_v<float>;
static constexpr float HALF_PI = PI * 0.5f;
static constexpr float TWO_PI = 2.0f * PI;
static constexpr float EULER_CONSTANT = std::numbers::egamma_v<float>;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
@ -103,6 +105,12 @@ namespace SHADE
template <IsFloatingPoint T = float>
[[nodiscard]] static bool CompareFloat (T lhs, T rhs, T absTolerance = EPSILON, T relTolerance = EPSILON);
template <IsArithmetic T>
[[nodiscard]] static bool IsInfinity (T value);
template <IsArithmetic T>
[[nodiscard]] static bool IsNaN (T value);
private:
/*---------------------------------------------------------------------------------*/
/* Static Data Members */

View File

@ -126,4 +126,21 @@ namespace SHADE
return std::fabs(lhs - rhs) <= Max(absTolerance, RTOL);
}
template <IsArithmetic T>
bool SHMath::IsInfinity(T value)
{
const float MAX_VALUE = std::numeric_limits<T>::max();
const float MIN_VALUE = std::numeric_limits<T>::min();
return !(MIN_VALUE <= value && value <= MAX_VALUE);
}
template <IsArithmetic T>
bool SHMath::IsNaN(T value)
{
return value != value;
}
} // namespace SHADE

View File

@ -34,6 +34,14 @@ namespace SHADE
0.0f, 0.0f, 0.0f, 1.0f
};
const SHMatrix SHMatrix::Zero
{
SHVec4::Zero
, SHVec4::Zero
, SHVec4::Zero
, SHVec4::Zero
};
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/

View File

@ -45,6 +45,7 @@ namespace SHADE
static constexpr size_t NUM_COLS = 4U;
static const SHMatrix Identity;
static const SHMatrix Zero;
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */

View File

@ -40,18 +40,12 @@ namespace SHADE
: XMFLOAT4( vec4.x, vec4.y, vec4.z, vec4.w )
{}
SHQuaternion::SHQuaternion(float _x, float _y, float _z, float _w) noexcept
: XMFLOAT4( _x, _y, _z, _w )
SHQuaternion::SHQuaternion(const XMFLOAT4& xmfloat4) noexcept
: XMFLOAT4( xmfloat4 )
{}
SHQuaternion::SHQuaternion(const reactphysics3d::Vector3& rp3dEuler) noexcept
: XMFLOAT4( 0.0f, 0.0f, 0.0f, 1.0f )
{
XMStoreFloat4(this, XMQuaternionRotationRollPitchYawFromVector(SHVec3 { rp3dEuler }));
}
SHQuaternion::SHQuaternion(const reactphysics3d::Quaternion& rp3dQuat) noexcept
: XMFLOAT4( rp3dQuat.x, rp3dQuat.y, rp3dQuat.z, rp3dQuat.w )
SHQuaternion::SHQuaternion(float _x, float _y, float _z, float _w) noexcept
: XMFLOAT4( _x, _y, _z, _w )
{}
/*-----------------------------------------------------------------------------------*/
@ -141,16 +135,6 @@ namespace SHADE
return XMQuaternionNotEqual(*this, rhs);
}
SHQuaternion::operator reactphysics3d::Quaternion() const noexcept
{
return reactphysics3d::Quaternion{ x, y, z, w };
}
SHQuaternion::operator reactphysics3d::Vector3() const noexcept
{
return reactphysics3d::Vector3{ ToEuler() };
}
SHQuaternion::operator XMVECTOR() const noexcept
{
return XMLoadFloat4(this);

View File

@ -11,7 +11,6 @@
#pragma once
#include <DirectXMath.h>
#include <reactphysics3d/mathematics/Quaternion.h>
#include <string>
@ -48,14 +47,10 @@ namespace SHADE
SHQuaternion (const SHQuaternion& rhs) = default;
SHQuaternion (SHQuaternion&& rhs) = default;
SHQuaternion () noexcept;
SHQuaternion (const SHVec4& vec4) noexcept;
SHQuaternion (float x, float y, float z, float w) noexcept;
// Conversion from other math types
SHQuaternion (const reactphysics3d::Vector3& rp3dEuler) noexcept;
SHQuaternion (const reactphysics3d::Quaternion& rp3dQuat) noexcept;
SHQuaternion () noexcept;
SHQuaternion (const SHVec4& vec4) noexcept;
SHQuaternion (const XMFLOAT4& xmfloat4) noexcept;
SHQuaternion (float x, float y, float z, float w) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
@ -82,8 +77,6 @@ namespace SHADE
// Conversion to other math types used by SHADE
operator reactphysics3d::Quaternion () const noexcept;
operator reactphysics3d::Vector3 () const noexcept;
operator DirectX::XMVECTOR () const noexcept;
/*---------------------------------------------------------------------------------*/

View File

@ -29,14 +29,12 @@ namespace SHADE
SHRay::SHRay(const SHVec3& pos, const SHVec3& dir) noexcept
: position { pos }
, direction { dir }
{}
SHRay::SHRay(const reactphysics3d::Ray& rp3dRay) noexcept
: position { rp3dRay.point1 }
, direction { SHVec3::Normalise(rp3dRay.point2 - rp3dRay.point1) }
{}
{
if (dir.LengthSquared() > 1.0f)
direction = SHVec3::Normalise(dir);
else
direction = dir;
}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
@ -64,12 +62,6 @@ namespace SHADE
return XMVector3NotEqual(LHS_POS, RHS_POS) || XMVector3NotEqual(LHS_DIR, RHS_DIR);
}
SHRay::operator reactphysics3d::Ray() const noexcept
{
// We use 2km. Temp solution.
return reactphysics3d::Ray{ position, position + (direction * MAX_RAYCAST_DIST) };
}
SHRaycastResult::operator bool() const noexcept
{
return hit;

View File

@ -10,10 +10,7 @@
#pragma once
#include <reactphysics3d/mathematics/Ray.h>
// Project Headers
#include "SH_API.h"
#include "Vector/SHVec3.h"
/*-------------------------------------------------------------------------------------*/
@ -45,7 +42,6 @@ namespace SHADE
SHRay () noexcept;
SHRay (const SHVec3& pos, const SHVec3& dir) noexcept;
SHRay (const reactphysics3d::Ray& rp3dRay) noexcept;
SHRay (const SHRay&) noexcept = default;
SHRay (SHRay&& ) noexcept = default;
@ -60,8 +56,6 @@ namespace SHADE
[[nodiscard]] bool operator==(const SHRay& rhs) const noexcept;
[[nodiscard]] bool operator!=(const SHRay& rhs) const noexcept;
operator reactphysics3d::Ray() const noexcept;
};
struct SH_API SHRaycastResult

View File

@ -50,10 +50,6 @@ namespace SHADE
: XMFLOAT2( _x, _y )
{}
SHVec2::SHVec2(const reactphysics3d::Vector2& rp3dVec2) noexcept
: XMFLOAT2( rp3dVec2.x, rp3dVec2.y )
{}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
@ -165,6 +161,8 @@ namespace SHADE
{
case 0: return x;
case 1: return y;
// This will never hit
default: return x;
}
}
@ -177,6 +175,8 @@ namespace SHADE
{
case 0: return x;
case 1: return y;
// This will never hit
default: return x;
}
}
@ -189,6 +189,8 @@ namespace SHADE
{
case 0: return x;
case 1: return y;
// This will never hit
default: return x;
}
}
@ -201,14 +203,11 @@ namespace SHADE
{
case 0: return x;
case 1: return y;
// This will never hit
default: return x;
}
}
SHVec2::operator reactphysics3d::Vector2() const noexcept
{
return reactphysics3d::Vector2{ x, y };
}
SHVec2 operator* (float lhs, const SHVec2& rhs) noexcept
{
SHVec2 result;

View File

@ -11,7 +11,6 @@
#pragma once
#include <DirectXMath.h>
#include <reactphysics3d/mathematics/Vector2.h>
#include <string>
#include <initializer_list>
@ -59,10 +58,6 @@ namespace SHADE
SHVec2 (float n) noexcept;
SHVec2 (float x, float y) noexcept;
// Conversion from other math types to SHADE
SHVec2 (const reactphysics3d::Vector2& rp3dVec2) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
@ -73,7 +68,6 @@ namespace SHADE
// Conversion to other math types used by SHADE
operator DirectX::XMVECTOR () const noexcept;
operator reactphysics3d::Vector2 () const noexcept;
SHVec2& operator+= (const SHVec2& rhs) noexcept;
SHVec2& operator-= (const SHVec2& rhs) noexcept;

View File

@ -57,14 +57,6 @@ namespace SHADE
: XMFLOAT3( _x, _y, _z )
{}
SHVec3::SHVec3(const reactphysics3d::Vector3& rp3dVec3) noexcept
: XMFLOAT3( rp3dVec3.x, rp3dVec3.y, rp3dVec3.z )
{}
SHVec3::SHVec3(const reactphysics3d::Quaternion& rp3dVec3) noexcept
: XMFLOAT3( SHQuaternion{rp3dVec3}.ToEuler() )
{}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
@ -179,6 +171,8 @@ namespace SHADE
case 0: return x;
case 1: return y;
case 2: return z;
// This will never hit
default: return x;
}
}
@ -192,6 +186,8 @@ namespace SHADE
case 0: return x;
case 1: return y;
case 2: return z;
// This will never hit
default: return x;
}
}
@ -205,6 +201,8 @@ namespace SHADE
case 0: return x;
case 1: return y;
case 2: return z;
// This will never hit
default: return x;
}
}
@ -218,19 +216,11 @@ namespace SHADE
case 0: return x;
case 1: return y;
case 2: return z;
// This will never hit
default: return x;
}
}
SHVec3::operator reactphysics3d::Vector3() const noexcept
{
return reactphysics3d::Vector3{ x, y , z };
}
SHVec3::operator reactphysics3d::Quaternion() const noexcept
{
return reactphysics3d::Quaternion::fromEulerAngles(x, y, z);
}
SHVec3 operator* (float lhs, const SHVec3& rhs) noexcept
{
SHVec3 result;
@ -382,6 +372,30 @@ namespace SHADE
return lhs.Cross(rhs);
}
SHMatrix SHVec3::OuterProduct(const SHVec3& lhs, const SHVec3& rhs) noexcept
{
/*
* Outer product is a matrix multiplication u * vT
* 3x1 * 1x3 = 3x3
*
* | u1 | | v1 v2 v3 | | u1v1 u1v2 u1v3 |
* | u2 | = | u2v1 u2v2 u2v3 |
* | u3 | | u3v1 u3v2 u3v3 |
*/
SHMatrix u = SHMatrix::Zero;
SHMatrix vT = SHMatrix::Zero;
for (int i = 0; i < SIZE; ++i)
{
u.m[0][i] = lhs[i];
vT.m[i][0] = rhs[i];
}
return u * vT;
}
SHVec3 SHVec3::Project(const SHVec3& v, const SHVec3& u) noexcept
{
SHVec3 result;

View File

@ -11,8 +11,6 @@
#pragma once
#include <DirectXMath.h>
#include <reactphysics3d/mathematics/Vector3.h>
#include <reactphysics3d/mathematics/Quaternion.h>
#include <string>
#include <initializer_list>
@ -69,9 +67,6 @@ namespace SHADE
// Conversion from other math types to SHADE
SHVec3 (const reactphysics3d::Vector3& rp3dVec3) noexcept;
SHVec3 (const reactphysics3d::Quaternion& rp3dVec3) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
@ -81,8 +76,6 @@ namespace SHADE
// Conversion to other math types used by SHADE
operator reactphysics3d::Vector3 () const noexcept;
operator reactphysics3d::Quaternion () const noexcept;
operator DirectX::XMVECTOR () const noexcept;
SHVec3& operator+= (const SHVec3& rhs) noexcept;
@ -122,27 +115,28 @@ namespace SHADE
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] static SHVec3 Normalise (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Abs (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Min (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Max (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Clamp (const SHVec3& v, const SHVec3& vMin, const SHVec3& vMax) noexcept;
[[nodiscard]] static SHVec3 Lerp (const SHVec3& a, const SHVec3& b, float t) noexcept;
[[nodiscard]] static SHVec3 ClampedLerp (const SHVec3& a, const SHVec3& b, float t, float tMin = 0.0f, float tMax = 1.0f) noexcept;
[[nodiscard]] static SHVec3 Normalise (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Abs (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Min (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Max (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Clamp (const SHVec3& v, const SHVec3& vMin, const SHVec3& vMax) noexcept;
[[nodiscard]] static SHVec3 Lerp (const SHVec3& a, const SHVec3& b, float t) noexcept;
[[nodiscard]] static SHVec3 ClampedLerp (const SHVec3& a, const SHVec3& b, float t, float tMin = 0.0f, float tMax = 1.0f) noexcept;
[[nodiscard]] static float Distance (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float DistanceSquared (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float Angle (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float Dot (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static SHVec3 Cross (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static SHVec3 Project (const SHVec3& v, const SHVec3& u) noexcept;
[[nodiscard]] static SHVec3 Reflect (const SHVec3& v, const SHVec3& normal) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHVec3& axis, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHQuaternion& q) noexcept;
[[nodiscard]] static SHVec3 RotateX (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateY (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateZ (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 Transform (const SHVec3& v, const SHMatrix& transformMtx) noexcept;
[[nodiscard]] static float Distance (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float DistanceSquared (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float Angle (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static float Dot (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static SHVec3 Cross (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static SHMatrix OuterProduct (const SHVec3& lhs, const SHVec3& rhs) noexcept;
[[nodiscard]] static SHVec3 Project (const SHVec3& v, const SHVec3& u) noexcept;
[[nodiscard]] static SHVec3 Reflect (const SHVec3& v, const SHVec3& normal) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHVec3& axis, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHQuaternion& q) noexcept;
[[nodiscard]] static SHVec3 RotateX (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateY (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateZ (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 Transform (const SHVec3& v, const SHMatrix& transformMtx) noexcept;
};
SHVec3 operator* (float lhs, const SHVec3& rhs) noexcept;

View File

@ -164,6 +164,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -178,6 +180,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -192,6 +196,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}
@ -206,6 +212,8 @@ namespace SHADE
case 1: return y;
case 2: return z;
case 3: return w;
// This will never hit
default: return x;
}
}

View File

@ -0,0 +1,647 @@
/****************************************************************************************
* \file SHDynamicAABBTree.cpp
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Implementation for a Dynamic AABB Tree for broadphase collision detection.
*
* \copyright Copyright (C) 2022 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.
****************************************************************************************/
#include <SHpch.h>
#include <stack>
// Primary Header
#include "SHDynamicAABBTree.h"
// Project Headers
#include "Math/SHMathHelpers.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/
SHAABBTree::SHAABBTree() noexcept
: root { NULL_NODE }
, nodes { nullptr }
, nodeCount { 0 }
, capacity { 1024 }
, freeList { NULL_NODE }
{
// Build initial tree
nodes = new Node[1024];
addToFreeList(0);
}
SHAABBTree::~SHAABBTree() noexcept
{
delete[] nodes;
}
SHAABBTree::Node::Node() noexcept
: id { MAX_EID, std::numeric_limits<uint32_t>::max() }
, parent { NULL_NODE }
, left { NULL_NODE }
, right { NULL_NODE }
, height { NULL_NODE }
{}
SHAABBTree::Node::Node(const Node& rhs) noexcept
: AABB { rhs.AABB }
, id { rhs.id }
, next { rhs.next }
, left { rhs.left }
, right { rhs.right }
, height { rhs.height }
{}
SHAABBTree::Node::Node(Node&& rhs) noexcept
: AABB { rhs.AABB }
, id { rhs.id }
, next { rhs.next }
, left { rhs.left }
, right { rhs.right }
, height { rhs.height }
{}
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
SHAABBTree::Node& SHAABBTree::Node::operator=(const Node& rhs) noexcept
{
if (this == &rhs)
return *this;
AABB = rhs.AABB;
id = rhs.id;
parent = rhs.parent;
next = rhs.next;
left = rhs.left;
right = rhs.right;
height = rhs.height;
return *this;
}
SHAABBTree::Node& SHAABBTree::Node::operator=(Node&& rhs) noexcept
{
AABB = std::move(rhs.AABB);
id = std::move(rhs.id);
parent = rhs.parent;
next = rhs.next;
left = rhs.left;
right = rhs.right;
height = rhs.height;
return *this;
}
/*-----------------------------------------------------------------------------------*/
/* Getter Functions Definitions */
/*-----------------------------------------------------------------------------------*/
const std::vector<SHAABB>& SHAABBTree::GetAABBs() const noexcept
{
static AABBs aabbs;
static std::stack<int32_t> nodeIndices;
aabbs.clear();
nodeIndices.push(root);
while (!nodeIndices.empty())
{
// Pop the top node
const int INDEX = nodeIndices.top();
nodeIndices.pop();
// Skip null nodes
if (INDEX == NULL_NODE)
continue;
const Node& CURRENT_NODE = nodes[INDEX];
aabbs.emplace_back(CURRENT_NODE.AABB);
if (!isLeaf(INDEX))
{
nodeIndices.push(CURRENT_NODE.left);
nodeIndices.push(CURRENT_NODE.right);
}
}
return aabbs;
}
/*-----------------------------------------------------------------------------------*/
/* Public Member Functions Definitions */
/*-----------------------------------------------------------------------------------*/
void SHAABBTree::Insert(SHCollisionShapeID id, const SHAABB& AABB)
{
const int32_t NEW_INDEX = allocateNode();
if (!nodeMap.emplace(id, NEW_INDEX).second)
{
// Attempted to add a duplicate node
freeNode(NEW_INDEX);
return;
}
Node& newNode = nodes[NEW_INDEX];
newNode.AABB = AABB;
newNode.id = id;
newNode.height = 0;
// Fatten the AABB
const SHVec3 EXTENSION{ AABB_EXTENSION };
const SHVec3 newMin = newNode.AABB.GetMin() - EXTENSION;
const SHVec3 newMax = newNode.AABB.GetMax() + EXTENSION;
newNode.AABB.SetMin(newMin);
newNode.AABB.SetMax(newMax);
insertLeaf(NEW_INDEX);
}
void SHAABBTree::Update(SHCollisionShapeID id, const SHAABB& newAABB)
{
// Get node index
const int32_t INDEX_TO_UPDATE = nodeMap[id];
Node& nodeToUpdate = nodes[INDEX_TO_UPDATE];
// Update the AABB directly
const SHAABB OLD_AABB = nodeToUpdate.AABB;
nodeToUpdate.AABB = newAABB;
// Fatten the AABB
const SHVec3 EXTENSION{ AABB_EXTENSION };
const SHVec3 newMin = nodeToUpdate.AABB.GetMin() - EXTENSION;
const SHVec3 newMax = nodeToUpdate.AABB.GetMax() + EXTENSION;
nodeToUpdate.AABB.SetMin(newMin);
nodeToUpdate.AABB.SetMax(newMax);
// If new AABB has not moved enough, skip.
// We only modify the position &/ size, but the AABB remains within this space.
if (OLD_AABB.Contains(nodeToUpdate.AABB))
return;
// Re-insert the node to find it's new neighbour
removeLeaf(INDEX_TO_UPDATE);
insertLeaf(INDEX_TO_UPDATE);
}
void SHAABBTree::Remove(SHCollisionShapeID id) noexcept
{
// Get node index
const int32_t INDEX_TO_REMOVE = nodeMap[id];
removeLeaf(INDEX_TO_REMOVE);
freeNode(INDEX_TO_REMOVE);
nodeMap.erase(id);
}
const std::vector<SHCollisionShapeID>& SHAABBTree::Query(SHCollisionShapeID id, const SHAABB& AABB) const noexcept
{
static std::vector<SHCollisionShapeID> potentialCollisions;
static std::stack<int32_t> nodeIndices;
potentialCollisions.clear();
// We use this to ignore shapes on the same entity
const EntityID EID = id.GetEntityID();
nodeIndices.push(root);
while (!nodeIndices.empty())
{
const int32_t INDEX = nodeIndices.top();
nodeIndices.pop();
if (INDEX == NULL_NODE)
continue;
const Node& NODE = nodes[INDEX];
if (!SHAABB::Intersect(AABB, NODE.AABB))
continue;
// Avoid checking against shapes of the same composite collider (and itself)
if (isLeaf(INDEX) && NODE.id.GetEntityID() != EID)
{
potentialCollisions.emplace_back(NODE.id);
}
else
{
nodeIndices.push(NODE.left);
nodeIndices.push(NODE.right);
}
}
return potentialCollisions;
}
const std::vector<SHCollisionShapeID>& SHAABBTree::Query(const SHRay& ray, float distance) const noexcept
{
static std::vector<SHCollisionShapeID> potentialHits;
static std::stack<int32_t> nodeIndices;
potentialHits.clear();
nodeIndices.push(root);
while (!nodeIndices.empty())
{
const int32_t INDEX = nodeIndices.top();
nodeIndices.pop();
if (INDEX == NULL_NODE)
continue;
const Node& NODE = nodes[INDEX];
const auto& RESULT = NODE.AABB.Raycast(ray);
if (!RESULT || RESULT.distance > distance)
continue;
if (isLeaf(INDEX))
{
potentialHits.emplace_back(NODE.id);
}
else
{
// Non-leaf nodes need to be traversed further
nodeIndices.push(NODE.left);
nodeIndices.push(NODE.right);
}
}
return potentialHits;
}
/*-----------------------------------------------------------------------------------*/
/* Private Member Functions Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHAABBTree::isLeaf(int32_t index) const noexcept
{
const Node& NODE = nodes[index];
return NODE.left == NULL_NODE && NODE.right == NULL_NODE;
}
int32_t SHAABBTree::allocateNode()
{
if (freeList == NULL_NODE)
{
// No more free nodes available, so we need to resize the tree for more nodes
capacity *= 2;
Node* newNodes = new Node[capacity];
// Copy all the nodes manually. I do this instead of memcpy to guarantee it copies properly.
for (int32_t i = 0; i < nodeCount; ++i)
{
newNodes[i].AABB = nodes[i].AABB;
newNodes[i].id = nodes[i].id;
newNodes[i].parent = nodes[i].parent;
newNodes[i].left = nodes[i].left;
newNodes[i].right = nodes[i].right;
newNodes[i].height = nodes[i].height;
}
delete[] nodes;
nodes = newNodes;
addToFreeList(nodeCount);
}
const int32_t FREE_NODE = freeList;
freeList = nodes[FREE_NODE].next;
// Set node to default
Node& newNode = nodes[FREE_NODE];
newNode.parent = NULL_NODE;
newNode.left = NULL_NODE;
newNode.right = NULL_NODE;
newNode.height = NULL_NODE;
++nodeCount;
return FREE_NODE;
}
void SHAABBTree::freeNode(int32_t index) noexcept
{
SHASSERT(index >= 0 && index < capacity, "Trying to free an invalid AABB Tree node!")
nodes[index].next = freeList;
nodes[index].height = NULL_NODE;
// Put it back on the free list
freeList = index;
--nodeCount;
}
void SHAABBTree::insertLeaf(int32_t index)
{
// If there is no root, the first insert must make the root
if (root == NULL_NODE)
{
root = index;
nodes[root].parent = NULL_NODE;
return;
}
// Find best sibling for new leaf
// Utilise Surface Area Heuristic
const SHAABB& LEAF_AABB = nodes[index].AABB;
uint32_t searchIndex = root;
while (!isLeaf(searchIndex))
{
const SHAABB COMBINED_AABB = SHAABB::Combine(LEAF_AABB, nodes[searchIndex].AABB);
const float COMBINED_AREA = COMBINED_AABB.SurfaceArea();
const float INHERITED_COST = 2.0f * (COMBINED_AREA - nodes[searchIndex].AABB.SurfaceArea());
const int32_t LEFT_INDEX = nodes[searchIndex].left;
const int32_t RIGHT_INDEX = nodes[searchIndex].right;
float leftCost = 0.0f;
float rightCost = 0.0f;
const float LEFT_COMBINED_AREA = SHAABB::Combine(LEAF_AABB, nodes[LEFT_INDEX].AABB).SurfaceArea();
const float RIGHT_COMBINED_AREA = SHAABB::Combine(LEAF_AABB, nodes[RIGHT_INDEX].AABB).SurfaceArea();
// Compute cost for descending into the left
if (isLeaf(LEFT_INDEX))
leftCost = LEFT_COMBINED_AREA + INHERITED_COST;
else
leftCost = LEFT_COMBINED_AREA - nodes[LEFT_INDEX].AABB.SurfaceArea() + INHERITED_COST;
// Compute cost for descending into the right
if (isLeaf(RIGHT_INDEX))
rightCost = RIGHT_COMBINED_AREA + INHERITED_COST;
else
rightCost = RIGHT_COMBINED_AREA - nodes[RIGHT_INDEX].AABB.SurfaceArea() + INHERITED_COST;
// Early out
const float BRANCH_COST = 2.0f * COMBINED_AREA;
if (BRANCH_COST < leftCost && BRANCH_COST < rightCost)
break;
// Traverse
searchIndex = leftCost < rightCost ? LEFT_INDEX : RIGHT_INDEX;
}
const int32_t BEST_SIBLING = searchIndex;
// Create a new parent for the leaf
const int32_t OLD_PARENT = nodes[BEST_SIBLING].parent;
const int32_t NEW_PARENT = allocateNode();
Node& newParent = nodes[NEW_PARENT];
newParent.parent = OLD_PARENT;
newParent.id = SHCollisionShapeID{ MAX_EID, std::numeric_limits<uint32_t>::max() };
newParent.AABB = SHAABB::Combine(LEAF_AABB, nodes[BEST_SIBLING].AABB);
newParent.height = nodes[BEST_SIBLING].height + 1;
newParent.left = BEST_SIBLING;
newParent.right = index;
nodes[BEST_SIBLING].parent = NEW_PARENT;
nodes[index].parent = NEW_PARENT;
// If sibling was the root
if (OLD_PARENT == NULL_NODE)
root = NEW_PARENT;
else
(nodes[OLD_PARENT].left == BEST_SIBLING ? nodes[OLD_PARENT].left : nodes[OLD_PARENT].right) = NEW_PARENT;
syncHierarchy(NEW_PARENT);
}
void SHAABBTree::removeLeaf(int32_t index)
{
if (index == root)
{
root = NULL_NODE;
return;
}
const int32_t PARENT = nodes[index].parent;
if (PARENT == NULL_NODE)
{
freeNode(index);
return;
}
const int32_t GRANDPARENT = nodes[PARENT].parent;
const int32_t SIBLING = nodes[PARENT].left == index ? nodes[PARENT].right : nodes[PARENT].left;
if (GRANDPARENT != NULL_NODE)
{
// Replace parent with sibling
(nodes[GRANDPARENT].left == PARENT ? nodes[GRANDPARENT].left : nodes[GRANDPARENT].right) = SIBLING;
nodes[SIBLING].parent = GRANDPARENT;
}
else
{
// Parent was root
root = SIBLING;
nodes[SIBLING].parent = NULL_NODE;
}
freeNode(PARENT);
syncHierarchy(GRANDPARENT);
}
void SHAABBTree::syncHierarchy(int32_t index)
{
while (index != NULL_NODE)
{
index = balance(index);
const int32_t LEFT_INDEX = nodes[index].left;
const Node& LEFT_NODE = nodes[LEFT_INDEX];
const int32_t RIGHT_INDEX = nodes[index].right;
const Node& RIGHT_NODE = nodes[RIGHT_INDEX];
nodes[index].height = 1 + SHMath::Max(LEFT_NODE.height, RIGHT_NODE.height);
nodes[index].AABB = SHAABB::Combine(LEFT_NODE.AABB, RIGHT_NODE.AABB);
// Sync up to the root
index = nodes[index].parent;
}
}
int32_t SHAABBTree::balance(int32_t index)
{
if (isLeaf(index) || nodes[index].height == 1)
return index;
Node& nodeA = nodes[index];
const int32_t LEFT = nodeA.left;
const int32_t RIGHT = nodeA.right;
const int32_t DIFF = nodes[RIGHT].height - nodes[LEFT].height;
if (DIFF > 1)
return rotateLeft(index);
if (DIFF < -1)
return rotateRight(index);
return index;
}
int32_t SHAABBTree::rotateLeft(int32_t index)
{
/****************************
A C
/ \ / \
B C --> A F/G
/ \ / \
F G B G/F
****************************/
// Promote C
Node& nodeA = nodes[index];
const int32_t B = nodeA.left;
const int32_t C = nodeA.right;
Node& nodeB = nodes[B];
Node& nodeC = nodes[C];
const int32_t F = nodeC.left;
const int32_t G = nodeC.right;
Node& nodeF = nodes[F];
Node& nodeG = nodes[G];
if (nodeA.parent != NULL_NODE)
(nodes[nodeA.parent].left == index ? nodes[nodeA.parent].left : nodes[nodeA.parent].right) = C;
else
root = C;
nodeC.left = index;
nodeC.parent = nodeA.parent;
nodeA.parent = C;
if (nodeF.height > nodeG.height)
{
nodeC.right = F;
nodeA.right = G;
nodeG.parent = index;
nodeA.AABB = SHAABB::Combine(nodeB.AABB, nodeG.AABB);
nodeC.AABB = SHAABB::Combine(nodeA.AABB, nodeF.AABB);
nodeA.height = 1 + SHMath::Max(nodeB.height, nodeG.height);
nodeC.height = 1 + SHMath::Max(nodeA.height, nodeF.height);
}
else
{
nodeC.right = G;
nodeA.right = F;
nodeF.parent = index;
nodeA.AABB = SHAABB::Combine(nodeB.AABB, nodeF.AABB);
nodeC.AABB = SHAABB::Combine(nodeA.AABB, nodeG.AABB);
nodeA.height = 1 + SHMath::Max(nodeB.height, nodeF.height);
nodeC.height = 1 + SHMath::Max(nodeA.height, nodeG.height);
}
return C;
}
int32_t SHAABBTree::rotateRight(int32_t index)
{
/*************************
A B
/ \ / \
B C --> D/E A
/ \ / \
D E E/D C
*************************/
// Promote B
Node& nodeA = nodes[index];
const int32_t B = nodeA.left;
const int32_t C = nodeA.right;
Node& nodeB = nodes[B];
Node& nodeC = nodes[C];
const int32_t D = nodeB.left;
const int32_t E = nodeB.right;
Node& nodeD = nodes[D];
Node& nodeE = nodes[E];
if (nodeA.parent != NULL_NODE)
(nodes[nodeA.parent].left == index ? nodes[nodeA.parent].left : nodes[nodeA.parent].right) = B;
else
root = B;
nodeB.right = index;
nodeB.parent = nodeA.parent;
nodeA.parent = B;
if (nodeD.height > nodeE.height)
{
nodeB.left = D;
nodeA.left = E;
nodeE.parent = index;
nodeA.AABB = SHAABB::Combine(nodeC.AABB, nodeE.AABB);
nodeB.AABB = SHAABB::Combine(nodeA.AABB, nodeD.AABB);
nodeA.height = 1 + SHMath::Max(nodeC.height, nodeE.height);
nodeB.height = 1 + SHMath::Max(nodeA.height, nodeD.height);
}
else
{
nodeB.left = E;
nodeA.left = D;
nodeD.parent = index;
nodeA.AABB = SHAABB::Combine(nodeC.AABB, nodeD.AABB);
nodeB.AABB = SHAABB::Combine(nodeA.AABB, nodeE.AABB);
nodeA.height = 1 + SHMath::Max(nodeC.height, nodeD.height);
nodeB.height = 1 + SHMath::Max(nodeA.height, nodeE.height);
}
return B;
}
void SHAABBTree::addToFreeList(int32_t index) noexcept
{
for (int32_t i = index; i < capacity; ++i)
{
nodes[i].next = i + 1;
nodes[i].height = NULL_NODE;
}
nodes[capacity - 1].next = NULL_NODE;
nodes[capacity - 1].height = NULL_NODE;
freeList = index;
}
} // namespace SHADE

View File

@ -0,0 +1,156 @@
/****************************************************************************************
* \file SHDynamicAABBTree.h
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Interface for a Dynamic AABB Tree for broadphase collision detection.
*
* \copyright Copyright (C) 2022 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
#include <unordered_map>
// Project Headers
#include "Physics/Collision/Shapes/SHCollisionShape.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
/**
* @brief
* Encapsulates a dynamic AABB Tree for collision detection.
*/
class SH_API SHAABBTree
{
public:
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
/*---------------------------------------------------------------------------------*/
using AABBs = std::vector<SHAABB>;
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
static constexpr int NULL_NODE = -1;
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHAABBTree () noexcept;
~SHAABBTree () noexcept;
SHAABBTree(const SHAABBTree& other) = delete;
SHAABBTree(SHAABBTree&& other) noexcept = delete;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
SHAABBTree& operator=(const SHAABBTree& other) = delete;
SHAABBTree& operator=(SHAABBTree&& other) noexcept = delete;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] const AABBs& GetAABBs () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Member Functions */
/*---------------------------------------------------------------------------------*/
void Insert (SHCollisionShapeID id, const SHAABB& AABB);
void Update (SHCollisionShapeID id, const SHAABB& AABB);
void Remove (SHCollisionShapeID id) noexcept;
[[nodiscard]] const std::vector<SHCollisionShapeID>& Query(SHCollisionShapeID id, const SHAABB& AABB) const noexcept;
[[nodiscard]] const std::vector<SHCollisionShapeID>& Query(const SHRay& ray, float distance) const noexcept;
private:
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
/*---------------------------------------------------------------------------------*/
struct Node
{
public:
/*-------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*-------------------------------------------------------------------------------*/
Node () noexcept;
Node (const Node& rhs) noexcept;
Node (Node&& rhs) noexcept;
~Node () noexcept = default;
/*-------------------------------------------------------------------------------*/
/* Operator Overloads */
/*-------------------------------------------------------------------------------*/
Node& operator=(const Node& rhs) noexcept;
Node& operator=(Node&& rhs) noexcept;
/*-------------------------------------------------------------------------------*/
/* Data Members */
/*-------------------------------------------------------------------------------*/
SHAABB AABB;
SHCollisionShapeID id; // Used to lookup the collision shape & entity for culling against itself
union
{
int32_t parent;
int32_t next;
};
int32_t left;
int32_t right;
int32_t height; // Leaves have a height of 0. Free nodes have a height of -1
};
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
static constexpr float AABB_EXTENSION = 0.2f;
// For quick access
std::unordered_map<SHCollisionShapeID, int32_t, SHCollisionShapeIDHash> nodeMap;
int32_t root;
Node* nodes; // Dynamically allocated array of nodes. I use dynamic allocation as in the past, using a vector causes weird issues.
int32_t nodeCount;
int32_t capacity; // Used for resizing the tree.
int32_t freeList; // Stores the next available node on the free list.
/*---------------------------------------------------------------------------------*/
/* Member Functions */
/*---------------------------------------------------------------------------------*/
bool isLeaf (int32_t index) const noexcept;
int32_t allocateNode ();
void freeNode (int32_t index) noexcept;
void insertLeaf (int32_t index);
void removeLeaf (int32_t index);
void syncHierarchy (int32_t index);
int32_t balance (int32_t index);
int32_t rotateLeft (int32_t index);
int32_t rotateRight (int32_t index);
void addToFreeList (int32_t index) noexcept;
};
}

Some files were not shown because too many files have changed in this diff Show More