Added basic shading and support for up to 100 lights of any color; By default now, states with no lights are dark
This commit is contained in:
parent
dff0d86558
commit
5c10fdc1a4
Binary file not shown.
After Width: | Height: | Size: 190 KiB |
BIN
DevScreenshots/7. Arbitrary Amount of Lights of Any Color.png
Normal file
BIN
DevScreenshots/7. Arbitrary Amount of Lights of Any Color.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 KiB |
@ -21,4 +21,6 @@ void MainState::render(nf::Renderer& renderer) {
|
|||||||
|
|
||||||
void MainState::onExit() {
|
void MainState::onExit() {
|
||||||
Log("MainState onExit!");
|
Log("MainState onExit!");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -13,4 +13,5 @@ public:
|
|||||||
void onExit() override;
|
void onExit() override;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
@ -9,32 +9,38 @@ v -1.000000 -1.000000 1.000000
|
|||||||
v -1.000000 1.000000 1.000000
|
v -1.000000 1.000000 1.000000
|
||||||
v 1.000000 -1.000000 1.000000
|
v 1.000000 -1.000000 1.000000
|
||||||
v 1.000000 1.000000 1.000000
|
v 1.000000 1.000000 1.000000
|
||||||
vt 0.375961 -0.006421
|
vt 0.380883 0.000961
|
||||||
vt 0.625961 0.243579
|
vt 0.630883 0.250961
|
||||||
vt 0.375961 0.243579
|
vt 0.380883 0.250961
|
||||||
vt 0.880422 0.750500
|
vt 0.875500 0.748039
|
||||||
vt 0.630422 0.500500
|
vt 0.625500 0.498039
|
||||||
vt 0.880422 0.500500
|
vt 0.875500 0.498039
|
||||||
vt 0.630422 0.750500
|
vt 0.625500 0.748039
|
||||||
vt 0.380422 0.500500
|
vt 0.375500 0.498039
|
||||||
vt 0.380422 0.750500
|
vt 0.375500 0.748039
|
||||||
vt 0.130422 0.500500
|
vt 0.125500 0.498039
|
||||||
vt 0.380422 0.250500
|
vt 0.375500 0.248039
|
||||||
vt 0.630422 0.250500
|
vt 0.625500 0.248039
|
||||||
vt 0.630422 1.000500
|
vt 0.625500 0.998039
|
||||||
vt 0.625961 -0.006421
|
vt 0.630883 0.000961
|
||||||
vt 0.130422 0.750500
|
vt 0.125500 0.748039
|
||||||
vt 0.380422 1.000500
|
vt 0.375500 0.998039
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn -1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
s off
|
s off
|
||||||
f 2/1 3/2 1/3
|
f 2/1/1 3/2/1 1/3/1
|
||||||
f 4/4 7/5 3/6
|
f 4/4/2 7/5/2 3/6/2
|
||||||
f 8/7 5/8 7/5
|
f 8/7/3 5/8/3 7/5/3
|
||||||
f 6/9 1/10 5/8
|
f 6/9/4 1/10/4 5/8/4
|
||||||
f 7/5 1/11 3/12
|
f 7/5/5 1/11/5 3/12/5
|
||||||
f 4/13 6/9 8/7
|
f 4/13/6 6/9/6 8/7/6
|
||||||
f 2/1 4/14 3/2
|
f 2/1/1 4/14/1 3/2/1
|
||||||
f 4/4 8/7 7/5
|
f 4/4/2 8/7/2 7/5/2
|
||||||
f 8/7 6/9 5/8
|
f 8/7/3 6/9/3 5/8/3
|
||||||
f 6/9 2/15 1/10
|
f 6/9/4 2/15/4 1/10/4
|
||||||
f 7/5 5/8 1/11
|
f 7/5/5 5/8/5 1/11/5
|
||||||
f 4/13 2/16 6/9
|
f 4/13/6 2/16/6 6/9/6
|
||||||
|
BIN
NFPackCreator/AssetBuild/CubeTest/textures/texture2.png
Normal file
BIN
NFPackCreator/AssetBuild/CubeTest/textures/texture2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -99,66 +99,100 @@ vt 0.550447 0.383337
|
|||||||
vt 0.580294 0.419706
|
vt 0.580294 0.419706
|
||||||
vt 0.616663 0.449553
|
vt 0.616663 0.449553
|
||||||
vt 0.658156 0.471731
|
vt 0.658156 0.471731
|
||||||
s off
|
vn 0.0000 0.4472 -0.8944
|
||||||
f 1/1 33/2 2/3
|
vn 0.0000 1.0000 0.0000
|
||||||
f 2/3 33/2 3/4
|
vn 0.1745 0.4472 -0.8772
|
||||||
f 3/4 33/2 4/5
|
vn 0.3423 0.4472 -0.8263
|
||||||
f 4/5 33/2 5/6
|
vn 0.4969 0.4472 -0.7437
|
||||||
f 5/6 33/2 6/7
|
vn 0.6325 0.4472 -0.6325
|
||||||
f 6/7 33/2 7/8
|
vn 0.7437 0.4472 -0.4969
|
||||||
f 7/8 33/2 8/9
|
vn 0.8263 0.4472 -0.3423
|
||||||
f 8/9 33/2 9/10
|
vn 0.8772 0.4472 -0.1745
|
||||||
f 9/10 33/2 10/11
|
vn 0.8944 0.4472 0.0000
|
||||||
f 10/11 33/2 11/12
|
vn 0.8772 0.4472 0.1745
|
||||||
f 11/12 33/2 12/13
|
vn 0.8263 0.4472 0.3423
|
||||||
f 12/13 33/2 13/14
|
vn 0.7437 0.4472 0.4969
|
||||||
f 13/14 33/2 14/15
|
vn 0.6325 0.4472 0.6325
|
||||||
f 14/15 33/2 15/16
|
vn 0.4969 0.4472 0.7437
|
||||||
f 15/16 33/2 16/17
|
vn 0.3423 0.4472 0.8263
|
||||||
f 16/17 33/2 17/18
|
vn 0.1745 0.4472 0.8772
|
||||||
f 17/18 33/2 18/19
|
vn -0.0000 0.4472 0.8944
|
||||||
f 18/19 33/2 19/20
|
vn -0.1745 0.4472 0.8772
|
||||||
f 19/20 33/2 20/21
|
vn -0.3423 0.4472 0.8263
|
||||||
f 20/21 33/2 21/22
|
vn -0.4969 0.4472 0.7437
|
||||||
f 21/22 33/2 22/23
|
vn -0.6325 0.4472 0.6325
|
||||||
f 22/23 33/2 23/24
|
vn -0.7437 0.4472 0.4969
|
||||||
f 23/24 33/2 24/25
|
vn -0.8263 0.4472 0.3423
|
||||||
f 24/25 33/2 25/26
|
vn -0.8772 0.4472 0.1745
|
||||||
f 25/26 33/2 26/27
|
vn -0.8944 0.4472 0.0000
|
||||||
f 26/27 33/2 27/28
|
vn -0.8772 0.4472 -0.1745
|
||||||
f 27/28 33/2 28/29
|
vn -0.8263 0.4472 -0.3423
|
||||||
f 28/29 33/2 29/30
|
vn -0.7437 0.4472 -0.4969
|
||||||
f 29/30 33/2 30/31
|
vn -0.6325 0.4472 -0.6325
|
||||||
f 30/31 33/2 31/32
|
vn -0.4969 0.4472 -0.7437
|
||||||
f 8/33 16/34 24/35
|
vn -0.3423 0.4472 -0.8263
|
||||||
f 31/32 33/2 32/36
|
vn 0.0000 -1.0000 0.0000
|
||||||
f 32/36 33/2 1/1
|
vn -0.1745 0.4472 -0.8772
|
||||||
f 32/37 1/38 2/39
|
s 1
|
||||||
f 2/39 3/40 4/41
|
f 1/1/1 33/2/2 2/3/3
|
||||||
f 4/41 5/42 6/43
|
f 2/3/3 33/2/2 3/4/4
|
||||||
f 6/43 7/44 8/33
|
f 3/4/4 33/2/2 4/5/5
|
||||||
f 8/33 9/45 10/46
|
f 4/5/5 33/2/2 5/6/6
|
||||||
f 10/46 11/47 12/48
|
f 5/6/6 33/2/2 6/7/7
|
||||||
f 12/48 13/49 14/50
|
f 6/7/7 33/2/2 7/8/8
|
||||||
f 14/50 15/51 16/34
|
f 7/8/8 33/2/2 8/9/9
|
||||||
f 16/34 17/52 18/53
|
f 8/9/9 33/2/2 9/10/10
|
||||||
f 18/53 19/54 20/55
|
f 9/10/10 33/2/2 10/11/11
|
||||||
f 20/55 21/56 22/57
|
f 10/11/11 33/2/2 11/12/12
|
||||||
f 22/57 23/58 24/35
|
f 11/12/12 33/2/2 12/13/13
|
||||||
f 24/35 25/59 26/60
|
f 12/13/13 33/2/2 13/14/14
|
||||||
f 26/60 27/61 24/35
|
f 13/14/14 33/2/2 14/15/15
|
||||||
f 27/61 28/62 24/35
|
f 14/15/15 33/2/2 15/16/16
|
||||||
f 28/62 29/63 30/64
|
f 15/16/16 33/2/2 16/17/17
|
||||||
f 30/64 31/65 28/62
|
f 16/17/17 33/2/2 17/18/18
|
||||||
f 31/65 32/37 28/62
|
f 17/18/18 33/2/2 18/19/19
|
||||||
f 32/37 2/39 8/33
|
f 18/19/19 33/2/2 19/20/20
|
||||||
f 2/39 4/41 8/33
|
f 19/20/20 33/2/2 20/21/21
|
||||||
f 4/41 6/43 8/33
|
f 20/21/21 33/2/2 21/22/22
|
||||||
f 8/33 10/46 12/48
|
f 21/22/22 33/2/2 22/23/23
|
||||||
f 12/48 14/50 8/33
|
f 22/23/23 33/2/2 23/24/24
|
||||||
f 14/50 16/34 8/33
|
f 23/24/24 33/2/2 24/25/25
|
||||||
f 16/34 18/53 24/35
|
f 24/25/25 33/2/2 25/26/26
|
||||||
f 18/53 20/55 24/35
|
f 25/26/26 33/2/2 26/27/27
|
||||||
f 20/55 22/57 24/35
|
f 26/27/27 33/2/2 27/28/28
|
||||||
f 24/35 28/62 32/37
|
f 27/28/28 33/2/2 28/29/29
|
||||||
f 32/37 8/33 24/35
|
f 28/29/29 33/2/2 29/30/30
|
||||||
|
f 29/30/30 33/2/2 30/31/31
|
||||||
|
f 30/31/31 33/2/2 31/32/32
|
||||||
|
f 8/33/33 16/34/33 24/35/33
|
||||||
|
f 31/32/32 33/2/2 32/36/34
|
||||||
|
f 32/36/34 33/2/2 1/1/1
|
||||||
|
f 32/37/33 1/38/33 2/39/33
|
||||||
|
f 2/39/33 3/40/33 4/41/33
|
||||||
|
f 4/41/33 5/42/33 6/43/33
|
||||||
|
f 6/43/33 7/44/33 8/33/33
|
||||||
|
f 8/33/33 9/45/33 10/46/33
|
||||||
|
f 10/46/33 11/47/33 12/48/33
|
||||||
|
f 12/48/33 13/49/33 14/50/33
|
||||||
|
f 14/50/33 15/51/33 16/34/33
|
||||||
|
f 16/34/33 17/52/33 18/53/33
|
||||||
|
f 18/53/33 19/54/33 20/55/33
|
||||||
|
f 20/55/33 21/56/33 22/57/33
|
||||||
|
f 22/57/33 23/58/33 24/35/33
|
||||||
|
f 24/35/33 25/59/33 26/60/33
|
||||||
|
f 26/60/33 27/61/33 24/35/33
|
||||||
|
f 27/61/33 28/62/33 24/35/33
|
||||||
|
f 28/62/33 29/63/33 30/64/33
|
||||||
|
f 30/64/33 31/65/33 28/62/33
|
||||||
|
f 31/65/33 32/37/33 28/62/33
|
||||||
|
f 32/37/33 2/39/33 8/33/33
|
||||||
|
f 2/39/33 4/41/33 8/33/33
|
||||||
|
f 4/41/33 6/43/33 8/33/33
|
||||||
|
f 8/33/33 10/46/33 12/48/33
|
||||||
|
f 12/48/33 14/50/33 8/33/33
|
||||||
|
f 14/50/33 16/34/33 8/33/33
|
||||||
|
f 16/34/33 18/53/33 24/35/33
|
||||||
|
f 18/53/33 20/55/33 24/35/33
|
||||||
|
f 20/55/33 22/57/33 24/35/33
|
||||||
|
f 24/35/33 28/62/33 32/37/33
|
||||||
|
f 32/37/33 8/33/33 24/35/33
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Blender v2.93.3 OBJ File: ''
|
# Blender v2.93.3 OBJ File: ''
|
||||||
# www.blender.org
|
# www.blender.org
|
||||||
o Cube_Cube.001
|
o Cube_Cube.002
|
||||||
v -1.000000 -1.000000 1.000000
|
v -1.000000 -1.000000 1.000000
|
||||||
v -1.000000 1.000000 1.000000
|
v -1.000000 1.000000 1.000000
|
||||||
v -1.000000 -1.000000 -1.000000
|
v -1.000000 -1.000000 -1.000000
|
||||||
@ -23,16 +23,22 @@ vt 0.125000 0.500000
|
|||||||
vt 0.875000 0.500000
|
vt 0.875000 0.500000
|
||||||
vt 0.625000 1.000000
|
vt 0.625000 1.000000
|
||||||
vt 0.875000 0.750000
|
vt 0.875000 0.750000
|
||||||
|
vn -1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
s off
|
s off
|
||||||
f 2/1 3/2 1/3
|
f 2/1/1 3/2/1 1/3/1
|
||||||
f 4/4 7/5 3/2
|
f 4/4/2 7/5/2 3/2/2
|
||||||
f 8/6 5/7 7/5
|
f 8/6/3 5/7/3 7/5/3
|
||||||
f 6/8 1/9 5/7
|
f 6/8/4 1/9/4 5/7/4
|
||||||
f 7/5 1/10 3/11
|
f 7/5/5 1/10/5 3/11/5
|
||||||
f 4/12 6/8 8/6
|
f 4/12/6 6/8/6 8/6/6
|
||||||
f 2/1 4/4 3/2
|
f 2/1/1 4/4/1 3/2/1
|
||||||
f 4/4 8/6 7/5
|
f 4/4/2 8/6/2 7/5/2
|
||||||
f 8/6 6/8 5/7
|
f 8/6/3 6/8/3 5/7/3
|
||||||
f 6/8 2/13 1/9
|
f 6/8/4 2/13/4 1/9/4
|
||||||
f 7/5 5/7 1/10
|
f 7/5/5 5/7/5 1/10/5
|
||||||
f 4/12 2/14 6/8
|
f 4/12/6 2/14/6 6/8/6
|
||||||
|
@ -195,128 +195,162 @@ vt 0.550447 0.383337
|
|||||||
vt 0.580294 0.419706
|
vt 0.580294 0.419706
|
||||||
vt 0.616663 0.449553
|
vt 0.616663 0.449553
|
||||||
vt 0.658156 0.471731
|
vt 0.658156 0.471731
|
||||||
s off
|
vn 0.0000 0.0000 -1.0000
|
||||||
f 2/1 3/2 1/3
|
vn 0.1951 0.0000 -0.9808
|
||||||
f 4/4 5/5 3/2
|
vn 0.3827 0.0000 -0.9239
|
||||||
f 6/6 7/7 5/5
|
vn 0.5556 0.0000 -0.8315
|
||||||
f 8/8 9/9 7/7
|
vn 0.7071 0.0000 -0.7071
|
||||||
f 10/10 11/11 9/9
|
vn 0.8315 0.0000 -0.5556
|
||||||
f 12/12 13/13 11/11
|
vn 0.9239 0.0000 -0.3827
|
||||||
f 14/14 15/15 13/13
|
vn 0.9808 0.0000 -0.1951
|
||||||
f 16/16 17/17 15/15
|
vn 1.0000 0.0000 0.0000
|
||||||
f 18/18 19/19 17/17
|
vn 0.9808 0.0000 0.1951
|
||||||
f 20/20 21/21 19/19
|
vn 0.9239 0.0000 0.3827
|
||||||
f 22/22 23/23 21/21
|
vn 0.8315 0.0000 0.5556
|
||||||
f 24/24 25/25 23/23
|
vn 0.7071 0.0000 0.7071
|
||||||
f 26/26 27/27 25/25
|
vn 0.5556 0.0000 0.8315
|
||||||
f 28/28 29/29 27/27
|
vn 0.3827 0.0000 0.9239
|
||||||
f 30/30 31/31 29/29
|
vn 0.1951 0.0000 0.9808
|
||||||
f 32/32 33/33 31/31
|
vn 0.0000 0.0000 1.0000
|
||||||
f 34/34 35/35 33/33
|
vn -0.1951 0.0000 0.9808
|
||||||
f 36/36 37/37 35/35
|
vn -0.3827 0.0000 0.9239
|
||||||
f 38/38 39/39 37/37
|
vn -0.5556 0.0000 0.8315
|
||||||
f 40/40 41/41 39/39
|
vn -0.7071 0.0000 0.7071
|
||||||
f 42/42 43/43 41/41
|
vn -0.8315 0.0000 0.5556
|
||||||
f 44/44 45/45 43/43
|
vn -0.9239 0.0000 0.3827
|
||||||
f 46/46 47/47 45/45
|
vn -0.9808 0.0000 0.1951
|
||||||
f 48/48 49/49 47/47
|
vn -1.0000 0.0000 0.0000
|
||||||
f 50/50 51/51 49/49
|
vn -0.9808 0.0000 -0.1951
|
||||||
f 52/52 53/53 51/51
|
vn -0.9239 0.0000 -0.3827
|
||||||
f 54/54 55/55 53/53
|
vn -0.8315 0.0000 -0.5556
|
||||||
f 56/56 57/57 55/55
|
vn -0.7071 0.0000 -0.7071
|
||||||
f 58/58 59/59 57/57
|
vn -0.5556 0.0000 -0.8315
|
||||||
f 60/60 61/61 59/59
|
vn -0.3827 0.0000 -0.9239
|
||||||
f 54/62 38/63 22/64
|
vn 0.0000 1.0000 -0.0000
|
||||||
f 62/65 63/66 61/61
|
vn -0.1951 0.0000 -0.9808
|
||||||
f 64/67 1/68 63/66
|
vn 0.0000 -1.0000 0.0000
|
||||||
f 15/69 31/70 47/71
|
s 1
|
||||||
f 2/1 4/4 3/2
|
f 2/1/1 3/2/2 1/3/1
|
||||||
f 4/4 6/6 5/5
|
f 4/4/2 5/5/3 3/2/2
|
||||||
f 6/6 8/8 7/7
|
f 6/6/3 7/7/4 5/5/3
|
||||||
f 8/8 10/10 9/9
|
f 8/8/4 9/9/5 7/7/4
|
||||||
f 10/10 12/12 11/11
|
f 10/10/5 11/11/6 9/9/5
|
||||||
f 12/12 14/14 13/13
|
f 12/12/6 13/13/7 11/11/6
|
||||||
f 14/14 16/16 15/15
|
f 14/14/7 15/15/8 13/13/7
|
||||||
f 16/16 18/18 17/17
|
f 16/16/8 17/17/9 15/15/8
|
||||||
f 18/18 20/20 19/19
|
f 18/18/9 19/19/10 17/17/9
|
||||||
f 20/20 22/22 21/21
|
f 20/20/10 21/21/11 19/19/10
|
||||||
f 22/22 24/24 23/23
|
f 22/22/11 23/23/12 21/21/11
|
||||||
f 24/24 26/26 25/25
|
f 24/24/12 25/25/13 23/23/12
|
||||||
f 26/26 28/28 27/27
|
f 26/26/13 27/27/14 25/25/13
|
||||||
f 28/28 30/30 29/29
|
f 28/28/14 29/29/15 27/27/14
|
||||||
f 30/30 32/32 31/31
|
f 30/30/15 31/31/16 29/29/15
|
||||||
f 32/32 34/34 33/33
|
f 32/32/16 33/33/17 31/31/16
|
||||||
f 34/34 36/36 35/35
|
f 34/34/17 35/35/18 33/33/17
|
||||||
f 36/36 38/38 37/37
|
f 36/36/18 37/37/19 35/35/18
|
||||||
f 38/38 40/40 39/39
|
f 38/38/19 39/39/20 37/37/19
|
||||||
f 40/40 42/42 41/41
|
f 40/40/20 41/41/21 39/39/20
|
||||||
f 42/42 44/44 43/43
|
f 42/42/21 43/43/22 41/41/21
|
||||||
f 44/44 46/46 45/45
|
f 44/44/22 45/45/23 43/43/22
|
||||||
f 46/46 48/48 47/47
|
f 46/46/23 47/47/24 45/45/23
|
||||||
f 48/48 50/50 49/49
|
f 48/48/24 49/49/25 47/47/24
|
||||||
f 50/50 52/52 51/51
|
f 50/50/25 51/51/26 49/49/25
|
||||||
f 52/52 54/54 53/53
|
f 52/52/26 53/53/27 51/51/26
|
||||||
f 54/54 56/56 55/55
|
f 54/54/27 55/55/28 53/53/27
|
||||||
f 56/56 58/58 57/57
|
f 56/56/28 57/57/29 55/55/28
|
||||||
f 58/58 60/60 59/59
|
f 58/58/29 59/59/30 57/57/29
|
||||||
f 60/60 62/65 61/61
|
f 60/60/30 61/61/31 59/59/30
|
||||||
f 6/72 4/73 62/74
|
f 54/62/32 38/63/32 22/64/32
|
||||||
f 4/73 2/75 62/74
|
f 62/65/31 63/66/33 61/61/31
|
||||||
f 2/75 64/76 62/74
|
f 64/67/33 1/68/1 63/66/33
|
||||||
f 62/74 60/77 58/78
|
f 15/69/34 31/70/34 47/71/34
|
||||||
f 58/78 56/79 62/74
|
f 2/1/1 4/4/2 3/2/2
|
||||||
f 56/79 54/62 62/74
|
f 4/4/2 6/6/3 5/5/3
|
||||||
f 54/62 52/80 50/81
|
f 6/6/3 8/8/4 7/7/4
|
||||||
f 50/81 48/82 46/83
|
f 8/8/4 10/10/5 9/9/5
|
||||||
f 46/83 44/84 42/85
|
f 10/10/5 12/12/6 11/11/6
|
||||||
f 42/85 40/86 38/63
|
f 12/12/6 14/14/7 13/13/7
|
||||||
f 38/63 36/87 34/88
|
f 14/14/7 16/16/8 15/15/8
|
||||||
f 34/88 32/89 30/90
|
f 16/16/8 18/18/9 17/17/9
|
||||||
f 30/90 28/91 26/92
|
f 18/18/9 20/20/10 19/19/10
|
||||||
f 26/92 24/93 22/64
|
f 20/20/10 22/22/11 21/21/11
|
||||||
f 22/64 20/94 18/95
|
f 22/22/11 24/24/12 23/23/12
|
||||||
f 18/95 16/96 14/97
|
f 24/24/12 26/26/13 25/25/13
|
||||||
f 14/97 12/98 10/99
|
f 26/26/13 28/28/14 27/27/14
|
||||||
f 10/99 8/100 6/72
|
f 28/28/14 30/30/15 29/29/15
|
||||||
f 54/62 50/81 38/63
|
f 30/30/15 32/32/16 31/31/16
|
||||||
f 50/81 46/83 38/63
|
f 32/32/16 34/34/17 33/33/17
|
||||||
f 46/83 42/85 38/63
|
f 34/34/17 36/36/18 35/35/18
|
||||||
f 38/63 34/88 30/90
|
f 36/36/18 38/38/19 37/37/19
|
||||||
f 30/90 26/92 38/63
|
f 38/38/19 40/40/20 39/39/20
|
||||||
f 26/92 22/64 38/63
|
f 40/40/20 42/42/21 41/41/21
|
||||||
f 22/64 18/95 6/72
|
f 42/42/21 44/44/22 43/43/22
|
||||||
f 18/95 14/97 6/72
|
f 44/44/22 46/46/23 45/45/23
|
||||||
f 14/97 10/99 6/72
|
f 46/46/23 48/48/24 47/47/24
|
||||||
f 6/72 62/74 54/62
|
f 48/48/24 50/50/25 49/49/25
|
||||||
f 6/72 54/62 22/64
|
f 50/50/25 52/52/26 51/51/26
|
||||||
f 62/65 64/67 63/66
|
f 52/52/26 54/54/27 53/53/27
|
||||||
f 64/67 2/101 1/68
|
f 54/54/27 56/56/28 55/55/28
|
||||||
f 63/102 1/103 3/104
|
f 56/56/28 58/58/29 57/57/29
|
||||||
f 3/104 5/105 7/106
|
f 58/58/29 60/60/30 59/59/30
|
||||||
f 7/106 9/107 11/108
|
f 60/60/30 62/65/31 61/61/31
|
||||||
f 11/108 13/109 15/69
|
f 6/72/32 4/73/32 62/74/32
|
||||||
f 15/69 17/110 19/111
|
f 4/73/32 2/75/32 62/74/32
|
||||||
f 19/111 21/112 23/113
|
f 2/75/32 64/76/32 62/74/32
|
||||||
f 23/113 25/114 27/115
|
f 62/74/32 60/77/32 58/78/32
|
||||||
f 27/115 29/116 31/70
|
f 58/78/32 56/79/32 62/74/32
|
||||||
f 31/70 33/117 35/118
|
f 56/79/32 54/62/32 62/74/32
|
||||||
f 35/118 37/119 39/120
|
f 54/62/32 52/80/32 50/81/32
|
||||||
f 39/120 41/121 43/122
|
f 50/81/32 48/82/32 46/83/32
|
||||||
f 43/122 45/123 47/71
|
f 46/83/32 44/84/32 42/85/32
|
||||||
f 47/71 49/124 51/125
|
f 42/85/32 40/86/32 38/63/32
|
||||||
f 51/125 53/126 47/71
|
f 38/63/32 36/87/32 34/88/32
|
||||||
f 53/126 55/127 47/71
|
f 34/88/32 32/89/32 30/90/32
|
||||||
f 55/127 57/128 59/129
|
f 30/90/32 28/91/32 26/92/32
|
||||||
f 59/129 61/130 55/127
|
f 26/92/32 24/93/32 22/64/32
|
||||||
f 61/130 63/102 55/127
|
f 22/64/32 20/94/32 18/95/32
|
||||||
f 63/102 3/104 15/69
|
f 18/95/32 16/96/32 14/97/32
|
||||||
f 3/104 7/106 15/69
|
f 14/97/32 12/98/32 10/99/32
|
||||||
f 7/106 11/108 15/69
|
f 10/99/32 8/100/32 6/72/32
|
||||||
f 15/69 19/111 23/113
|
f 54/62/32 50/81/32 38/63/32
|
||||||
f 23/113 27/115 15/69
|
f 50/81/32 46/83/32 38/63/32
|
||||||
f 27/115 31/70 15/69
|
f 46/83/32 42/85/32 38/63/32
|
||||||
f 31/70 35/118 47/71
|
f 38/63/32 34/88/32 30/90/32
|
||||||
f 35/118 39/120 47/71
|
f 30/90/32 26/92/32 38/63/32
|
||||||
f 39/120 43/122 47/71
|
f 26/92/32 22/64/32 38/63/32
|
||||||
f 47/71 55/127 63/102
|
f 22/64/32 18/95/32 6/72/32
|
||||||
f 63/102 15/69 47/71
|
f 18/95/32 14/97/32 6/72/32
|
||||||
|
f 14/97/32 10/99/32 6/72/32
|
||||||
|
f 6/72/32 62/74/32 54/62/32
|
||||||
|
f 6/72/32 54/62/32 22/64/32
|
||||||
|
f 62/65/31 64/67/33 63/66/33
|
||||||
|
f 64/67/33 2/101/1 1/68/1
|
||||||
|
f 63/102/34 1/103/34 3/104/34
|
||||||
|
f 3/104/34 5/105/34 7/106/34
|
||||||
|
f 7/106/34 9/107/34 11/108/34
|
||||||
|
f 11/108/34 13/109/34 15/69/34
|
||||||
|
f 15/69/34 17/110/34 19/111/34
|
||||||
|
f 19/111/34 21/112/34 23/113/34
|
||||||
|
f 23/113/34 25/114/34 27/115/34
|
||||||
|
f 27/115/34 29/116/34 31/70/34
|
||||||
|
f 31/70/34 33/117/34 35/118/34
|
||||||
|
f 35/118/34 37/119/34 39/120/34
|
||||||
|
f 39/120/34 41/121/34 43/122/34
|
||||||
|
f 43/122/34 45/123/34 47/71/34
|
||||||
|
f 47/71/34 49/124/34 51/125/34
|
||||||
|
f 51/125/34 53/126/34 47/71/34
|
||||||
|
f 53/126/34 55/127/34 47/71/34
|
||||||
|
f 55/127/34 57/128/34 59/129/34
|
||||||
|
f 59/129/34 61/130/34 55/127/34
|
||||||
|
f 61/130/34 63/102/34 55/127/34
|
||||||
|
f 63/102/34 3/104/34 15/69/34
|
||||||
|
f 3/104/34 7/106/34 15/69/34
|
||||||
|
f 7/106/34 11/108/34 15/69/34
|
||||||
|
f 15/69/34 19/111/34 23/113/34
|
||||||
|
f 23/113/34 27/115/34 15/69/34
|
||||||
|
f 27/115/34 31/70/34 15/69/34
|
||||||
|
f 31/70/34 35/118/34 47/71/34
|
||||||
|
f 35/118/34 39/120/34 47/71/34
|
||||||
|
f 39/120/34 43/122/34 47/71/34
|
||||||
|
f 47/71/34 55/127/34 63/102/34
|
||||||
|
f 63/102/34 15/69/34 47/71/34
|
||||||
|
@ -9,6 +9,7 @@ vt 1.000000 0.000000
|
|||||||
vt 0.000000 1.000000
|
vt 0.000000 1.000000
|
||||||
vt 0.000000 0.000000
|
vt 0.000000 0.000000
|
||||||
vt 1.000000 1.000000
|
vt 1.000000 1.000000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
s off
|
s off
|
||||||
f 2/1 3/2 1/3
|
f 2/1/1 3/2/1 1/3/1
|
||||||
f 2/1 4/4 3/2
|
f 2/1/1 4/4/1 3/2/1
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,65 @@
|
|||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
in vec3 normals;
|
||||||
|
in vec3 fragPos;
|
||||||
|
|
||||||
uniform sampler2D tex;
|
struct Camera {
|
||||||
|
vec3 pos;
|
||||||
|
};
|
||||||
|
|
||||||
out vec4 color;
|
struct Material {
|
||||||
|
float shininess;
|
||||||
|
//Do I want a specular color here?
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Light {
|
||||||
|
//Directional = 1, Point = 2, Spotlight = 3
|
||||||
|
int type;
|
||||||
|
vec3 pos;
|
||||||
|
vec3 direction;
|
||||||
|
vec3 color;
|
||||||
|
|
||||||
|
float falloffConstant;
|
||||||
|
float falloffLinear;
|
||||||
|
float falloffQuad;
|
||||||
|
|
||||||
|
float cutoff;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform sampler2D modelTexture;
|
||||||
|
uniform Camera camera;
|
||||||
|
uniform Material material;
|
||||||
|
uniform Light light[100];
|
||||||
|
uniform int numberOfLights;
|
||||||
|
|
||||||
|
out vec4 outColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
color = texture(tex, texCoord);
|
vec4 texColor = texture(modelTexture, texCoord);
|
||||||
|
|
||||||
|
vec3 color = vec3(0.0);
|
||||||
|
|
||||||
|
for (int i = 0; i < numberOfLights; i++) {
|
||||||
|
float ambientStrength = 0.2f;
|
||||||
|
vec3 ambient = ambientStrength * texColor.rgb;
|
||||||
|
if (i == numberOfLights - 1 && numberOfLights == 1) {
|
||||||
|
color += ambient;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 norm = normalize(normals);
|
||||||
|
vec3 lightDir = normalize(light[i].pos - fragPos);
|
||||||
|
float diff = max(dot(norm, lightDir), 0.0);
|
||||||
|
vec3 diffuse = light[i].color * (diff * texColor.rgb);
|
||||||
|
|
||||||
|
vec3 viewDir = normalize(camera.pos - fragPos);
|
||||||
|
vec3 reflectDir = reflect(-lightDir, norm);
|
||||||
|
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess * 32.0f);
|
||||||
|
vec3 specular = light[i].color * spec;
|
||||||
|
|
||||||
|
color += (ambient + diffuse + specular);
|
||||||
|
}
|
||||||
|
|
||||||
|
outColor = vec4(color, texColor.a);
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,20 @@
|
|||||||
|
|
||||||
layout(location = 0) in vec3 pos;
|
layout(location = 0) in vec3 pos;
|
||||||
layout(location = 1) in vec2 texCoords;
|
layout(location = 1) in vec2 texCoords;
|
||||||
|
layout(location = 2) in vec3 normal;
|
||||||
|
|
||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
uniform mat4 proj;
|
uniform mat4 proj;
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
|
out vec3 normals;
|
||||||
|
out vec3 fragPos;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = proj * view * model * vec4(pos, 1.0);
|
|
||||||
texCoord = texCoords;
|
texCoord = texCoords;
|
||||||
|
normals = mat3(transpose(inverse(model))) * normal;
|
||||||
|
fragPos = vec3(model * vec4(pos, 1.0));
|
||||||
|
|
||||||
|
gl_Position = proj * view * model * vec4(pos, 1.0);
|
||||||
}
|
}
|
@ -202,6 +202,7 @@
|
|||||||
<ClCompile Include="src\Renderer\Camera.cpp" />
|
<ClCompile Include="src\Renderer\Camera.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\Drawable.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\Drawable.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\Entity.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\Entity.cpp" />
|
||||||
|
<ClCompile Include="src\Renderer\Drawable\Light.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\Model.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\Model.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\Text.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\Text.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\UIElement.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\UIElement.cpp" />
|
||||||
@ -225,6 +226,7 @@
|
|||||||
<ClInclude Include="src\include\IndexBuffer.h" />
|
<ClInclude Include="src\include\IndexBuffer.h" />
|
||||||
<ClInclude Include="src\include\IntroGamestate.h" />
|
<ClInclude Include="src\include\IntroGamestate.h" />
|
||||||
<ClInclude Include="src\include\Input.h" />
|
<ClInclude Include="src\include\Input.h" />
|
||||||
|
<ClInclude Include="src\include\Light.h" />
|
||||||
<ClInclude Include="src\include\Model.h" />
|
<ClInclude Include="src\include\Model.h" />
|
||||||
<ClInclude Include="src\include\NothinFancy.h" />
|
<ClInclude Include="src\include\NothinFancy.h" />
|
||||||
<ClInclude Include="src\include\Renderer.h" />
|
<ClInclude Include="src\include\Renderer.h" />
|
||||||
|
@ -69,6 +69,9 @@
|
|||||||
<ClCompile Include="src\Renderer\Drawable\UITexture.cpp">
|
<ClCompile Include="src\Renderer\Drawable\UITexture.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Drawable\Light.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\include\Config.h">
|
<ClInclude Include="src\include\Config.h">
|
||||||
@ -134,6 +137,9 @@
|
|||||||
<ClInclude Include="src\include\UITexture.h">
|
<ClInclude Include="src\include\UITexture.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\include\Light.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Natvis Include="NatvisFile.natvis" />
|
<Natvis Include="NatvisFile.natvis" />
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace nf {
|
namespace nf {
|
||||||
Camera::Camera(Application* app) :
|
Camera::Camera(Application* app) :
|
||||||
m_app(app),
|
m_app(app),
|
||||||
m_type(Type::NF_CAMERA_UI),
|
m_type(Type::UI),
|
||||||
m_position(0.0),
|
m_position(0.0),
|
||||||
m_front(0.0, 0.0, -1.0),
|
m_front(0.0, 0.0, -1.0),
|
||||||
m_yaw(-90.0f),
|
m_yaw(-90.0f),
|
||||||
@ -20,7 +20,7 @@ namespace nf {
|
|||||||
void Camera::setType(Type cameraType) {
|
void Camera::setType(Type cameraType) {
|
||||||
if (cameraType != m_type) {
|
if (cameraType != m_type) {
|
||||||
m_type = cameraType;
|
m_type = cameraType;
|
||||||
if (m_type == Type::NF_CAMERA_FIRST_PERSON || m_type == Type::NF_CAMERA_ORBIT)
|
if (m_type == Type::FIRST_PERSON || m_type == Type::ORBIT)
|
||||||
m_app->trackMouse(true);
|
m_app->trackMouse(true);
|
||||||
else
|
else
|
||||||
m_app->trackMouse(false);
|
m_app->trackMouse(false);
|
||||||
@ -63,15 +63,19 @@ namespace nf {
|
|||||||
m_position = position;
|
m_position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Vec3& Camera::getPosition() {
|
||||||
|
return m_position;
|
||||||
|
}
|
||||||
|
|
||||||
void Camera::bind(Shader* shader) {
|
void Camera::bind(Shader* shader) {
|
||||||
glm::mat4 view;
|
glm::mat4 view;
|
||||||
|
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case Type::NF_CAMERA_UI: {
|
case Type::UI: {
|
||||||
view = glm::mat4(1.0);
|
view = glm::mat4(1.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::NF_CAMERA_FIRST_PERSON: {
|
case Type::FIRST_PERSON: {
|
||||||
int mouseDiffx = 0;
|
int mouseDiffx = 0;
|
||||||
int mouseDiffy = 0;
|
int mouseDiffy = 0;
|
||||||
m_app->getMouseDiff(mouseDiffx, mouseDiffy);
|
m_app->getMouseDiff(mouseDiffx, mouseDiffy);
|
||||||
@ -94,16 +98,17 @@ namespace nf {
|
|||||||
view = glm::lookAt(position, position + rotation, up);
|
view = glm::lookAt(position, position + rotation, up);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::NF_CAMERA_ORBIT: {
|
case Type::ORBIT: {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::NF_CAMERA_FIXED: {
|
case Type::FIXED: {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glm::vec3 pos(m_position.x, m_position.y, m_position.z);
|
||||||
|
shader->setUniform("camera.pos", pos);
|
||||||
shader->setUniform("view", view);
|
shader->setUniform("view", view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,9 @@ namespace nf {
|
|||||||
std::vector<unsigned int> ib;
|
std::vector<unsigned int> ib;
|
||||||
size_t ibCount = 0;
|
size_t ibCount = 0;
|
||||||
std::vector<float> tc;
|
std::vector<float> tc;
|
||||||
parseOBJ(obj, vb, ib, ibCount, tc);
|
std::vector<float> vn;
|
||||||
m_model->create(&vb[0], vb.size() * sizeof(float), &ib[0], ibCount, &tc[0], tc.size() * sizeof(float), &texture);
|
parseOBJ(obj, vb, ib, ibCount, tc, vn);
|
||||||
|
m_model->create(&vb[0], vb.size() * sizeof(float), &ib[0], ibCount, &vn[0], vn.size() * sizeof(float), &tc[0], tc.size() * sizeof(float), &texture);
|
||||||
model.alreadyLoaded = true;
|
model.alreadyLoaded = true;
|
||||||
model.loadedModel = m_model;
|
model.loadedModel = m_model;
|
||||||
}
|
}
|
||||||
|
87
NothinFancy/src/Renderer/Drawable/Light.cpp
Normal file
87
NothinFancy/src/Renderer/Drawable/Light.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include "Light.h"
|
||||||
|
|
||||||
|
#include "Shader.h"
|
||||||
|
|
||||||
|
namespace nf {
|
||||||
|
Light::Light() :
|
||||||
|
m_type(Type::POINT),
|
||||||
|
m_constructed(false),
|
||||||
|
m_strength(1.0f)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Light::create(const Vec3& position, const Vec3& color, Type type, float strength) {
|
||||||
|
m_constructed = true;
|
||||||
|
m_position = position;
|
||||||
|
m_color = color;
|
||||||
|
m_type = type;
|
||||||
|
m_strength = strength;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Light::isConstructed() {
|
||||||
|
return m_constructed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Light::setPosition(const Vec3& position) {
|
||||||
|
m_position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Light::setColor(const Vec3& color) {
|
||||||
|
m_color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Light::bind(Shader* shader, unsigned int lightNumber) {
|
||||||
|
glm::vec3 pos(m_position.x, m_position.y, m_position.z);
|
||||||
|
glm::vec3 color(m_color.x, m_color.y, m_color.z);
|
||||||
|
std::string stringPos = "light[";
|
||||||
|
std::string stringLocation = std::to_string(lightNumber);
|
||||||
|
stringPos += stringLocation;
|
||||||
|
stringPos += "].";
|
||||||
|
std::string lightPos = stringPos + (std::string)"pos";
|
||||||
|
std::string lightColor = stringPos + (std::string)"color";
|
||||||
|
shader->setUniform(lightPos, pos);
|
||||||
|
shader->setUniform(lightColor, color);
|
||||||
|
//switch (m_type) {
|
||||||
|
// case Type::DIRECTIONAL: {
|
||||||
|
// shader->setUniform(lightType.c_str(), 1);
|
||||||
|
// std::string lightConsant = light + (std::string)"falloffConstant";
|
||||||
|
// std::string lightLinear = light + (std::string)"falloffLinear";
|
||||||
|
// std::string lightQuad = light + (std::string)"falloffQuad";
|
||||||
|
// shader->setUniform(lightConsant.c_str(), 1.0f);
|
||||||
|
// shader->setUniform(lightLinear.c_str(), 0.7f);
|
||||||
|
// shader->setUniform(lightQuad.c_str(), 1.8f);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case Type::POINT: {
|
||||||
|
// //shader->setUniform(lightType.c_str(), 2);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case Type::SPOTLIGHT: {
|
||||||
|
// shader->setUniform(lightType.c_str(), 3);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
Light::Type Light::getType() {
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vec3& Light::getPosition() {
|
||||||
|
return m_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vec3& Light::getColor() {
|
||||||
|
return m_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float Light::getStrength() {
|
||||||
|
return m_strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
Light::~Light() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ namespace nf {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount, const void* textureCoordinatesBufferData, size_t textureCoordinatesBufferSize, ATexture* texture) {
|
void Model::create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount, const void* normalsBufferData, size_t normalsBufferSize, const void* textureCoordinatesBufferData, size_t textureCoordinatesBufferSize, ATexture* texture) {
|
||||||
m_vao = new VertexArray;
|
m_vao = new VertexArray;
|
||||||
m_vao->addBuffer(vertexBufferData, vertexBufferSize);
|
m_vao->addBuffer(vertexBufferData, vertexBufferSize);
|
||||||
m_vao->push<float>(3);
|
m_vao->push<float>(3);
|
||||||
@ -21,6 +21,9 @@ namespace nf {
|
|||||||
m_vao->addBuffer(textureCoordinatesBufferData, textureCoordinatesBufferSize);
|
m_vao->addBuffer(textureCoordinatesBufferData, textureCoordinatesBufferSize);
|
||||||
m_vao->push<float>(2);
|
m_vao->push<float>(2);
|
||||||
m_vao->finishBufferLayout();
|
m_vao->finishBufferLayout();
|
||||||
|
m_vao->addBuffer(normalsBufferData, normalsBufferSize);
|
||||||
|
m_vao->push<float>(3);
|
||||||
|
m_vao->finishBufferLayout();
|
||||||
if (texture->alreadyLoaded) {
|
if (texture->alreadyLoaded) {
|
||||||
m_texture = texture->loadedTexture;
|
m_texture = texture->loadedTexture;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace nf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Text::create(const std::string& string, const Vec2& position, const Vec3& color, unsigned int size, Asset* font) {
|
void Text::create(const std::string& string, const Vec2& position, const Vec3& color, unsigned int size, Asset* font) {
|
||||||
|
m_constructed = true;
|
||||||
m_string = string;
|
m_string = string;
|
||||||
m_position = position;
|
m_position = position;
|
||||||
m_color = color;
|
m_color = color;
|
||||||
|
@ -24,6 +24,10 @@ namespace nf {
|
|||||||
m_centeredY = y;
|
m_centeredY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UIElement::isConstructed() {
|
||||||
|
return m_constructed;
|
||||||
|
}
|
||||||
|
|
||||||
void UIElement::render(Shader* shader, unsigned int windowWidth, unsigned int windowHeight) {
|
void UIElement::render(Shader* shader, unsigned int windowWidth, unsigned int windowHeight) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace nf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UITexture::create(Asset* texture, const Vec2& position, double scale) {
|
void UITexture::create(Asset* texture, const Vec2& position, double scale) {
|
||||||
|
m_constructed = true;
|
||||||
ATexture* tex = (ATexture*)texture;
|
ATexture* tex = (ATexture*)texture;
|
||||||
m_position = position;
|
m_position = position;
|
||||||
m_scale = (float)scale;
|
m_scale = (float)scale;
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
|
#include "Light.h"
|
||||||
|
#include "Entity.h"
|
||||||
#include "UIElement.h"
|
#include "UIElement.h"
|
||||||
|
#include "Camera.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
@ -56,55 +59,68 @@ namespace nf {
|
|||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
baseAP.load("base.nfpack");
|
m_baseAP.load("base.nfpack");
|
||||||
const char* entityVertex = baseAP["entityVertex.shader"]->data;
|
const char* entityVertex = m_baseAP["entityVertex.shader"]->data;
|
||||||
const char* entityFragment = baseAP["entityFragment.shader"]->data;
|
const char* entityFragment = m_baseAP["entityFragment.shader"]->data;
|
||||||
m_entityShader = new Shader(entityVertex, entityFragment);
|
m_entityShader = new Shader(entityVertex, entityFragment);
|
||||||
const char* textVertex = baseAP["textVertex.shader"]->data;
|
const char* textVertex = m_baseAP["textVertex.shader"]->data;
|
||||||
const char* textFragment = baseAP["textFragment.shader"]->data;
|
const char* textFragment = m_baseAP["textFragment.shader"]->data;
|
||||||
m_textShader = new Shader(textVertex, textFragment);
|
m_textShader = new Shader(textVertex, textFragment);
|
||||||
const char* uiTextureVertex = baseAP["uiTextureVertex.shader"]->data;
|
const char* uiTextureVertex = m_baseAP["uiTextureVertex.shader"]->data;
|
||||||
const char* uiTextureFragment = baseAP["uiTextureFragment.shader"]->data;
|
const char* uiTextureFragment = m_baseAP["uiTextureFragment.shader"]->data;
|
||||||
m_uiTextureShader = new Shader(uiTextureVertex, uiTextureFragment);
|
m_uiTextureShader = new Shader(uiTextureVertex, uiTextureFragment);
|
||||||
|
|
||||||
BaseAssets::cube = (AModel*)baseAP["cube.obj"];
|
BaseAssets::cube = (AModel*)m_baseAP["cube.obj"];
|
||||||
BaseAssets::plane = (AModel*)baseAP["plane.obj"];
|
BaseAssets::plane = (AModel*)m_baseAP["plane.obj"];
|
||||||
BaseAssets::sphere = (AModel*)baseAP["sphere.obj"];
|
BaseAssets::sphere = (AModel*)m_baseAP["sphere.obj"];
|
||||||
BaseAssets::cone = (AModel*)baseAP["cone.obj"];
|
BaseAssets::cone = (AModel*)m_baseAP["cone.obj"];
|
||||||
BaseAssets::cylinder = (AModel*)baseAP["cylinder.obj"];
|
BaseAssets::cylinder = (AModel*)m_baseAP["cylinder.obj"];
|
||||||
BaseAssets::torus = (AModel*)baseAP["torus.obj"];
|
BaseAssets::torus = (AModel*)m_baseAP["torus.obj"];
|
||||||
BaseAssets::defaultFont = (AFont*)baseAP["default.ttf"];
|
BaseAssets::defaultFont = (AFont*)m_baseAP["default.ttf"];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::render(Entity& in) {
|
void Renderer::render(Entity& in) {
|
||||||
if (&in == nullptr)
|
if (in.getModel() == nullptr)
|
||||||
Error("Tried to render Entity before being created!");
|
Error("Tried to render Entity before being created!");
|
||||||
m_lGame.push_back(&in);
|
m_lGame.push_back(&in);
|
||||||
//TODO: Sort transparent objects by distance; Farthest first
|
//TODO: Sort transparent objects by distance; Farthest first
|
||||||
}
|
}
|
||||||
void Renderer::render(UIElement& in) {
|
void Renderer::render(UIElement& in) {
|
||||||
if (&in == nullptr)
|
if (in.isConstructed() == false)
|
||||||
Error("Tried to render Entity before being created!");
|
Error("Tried to render a UI element before being created!");
|
||||||
m_lUI.push_back(&in);
|
m_lUI.push_back(&in);
|
||||||
//TODO: Sort transparent objects by distance; Farthest first
|
}
|
||||||
|
void Renderer::render(Light& in) {
|
||||||
|
if (in.isConstructed() == false)
|
||||||
|
Error("Tried to render a light before being created!");
|
||||||
|
m_lights.push_back(&in);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::doFrame(Camera* camera) {
|
void Renderer::doFrame(Camera* camera) {
|
||||||
glViewport(0, 0, m_app->getConfig().width, m_app->getConfig().height);
|
glViewport(0, 0, m_app->getConfig().width, m_app->getConfig().height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
//Draw Entities (3D models)
|
||||||
glm::mat4 proj = glm::perspective(glm::radians(45.0f), (float)m_app->getConfig().width / (float)m_app->getConfig().height, 0.1f, 100000.0f);
|
glm::mat4 proj = glm::perspective(glm::radians(45.0f), (float)m_app->getConfig().width / (float)m_app->getConfig().height, 0.1f, 100000.0f);
|
||||||
|
m_entityShader->bind();
|
||||||
|
m_entityShader->setUniform("proj", proj);
|
||||||
for (Entity* draw : m_lGame) {
|
for (Entity* draw : m_lGame) {
|
||||||
Entity& curr = *draw;
|
Entity& curr = *draw;
|
||||||
curr.bind(m_entityShader);
|
curr.bind(m_entityShader);
|
||||||
m_entityShader->setUniform("proj", proj);
|
|
||||||
camera->bind(m_entityShader);
|
camera->bind(m_entityShader);
|
||||||
//TODO: Clean this up a bit
|
//TODO: Clean this up a bit
|
||||||
|
m_entityShader->setUniform("numberOfLights", (int)m_lights.size() + 1);
|
||||||
|
for (unsigned int i = 0; i < m_lights.size(); i++) {
|
||||||
|
m_lights[i]->bind(m_entityShader, i);
|
||||||
|
}
|
||||||
|
//TODO: Bind and draw every material here
|
||||||
|
m_entityShader->setUniform("material.shininess", 1.0f);
|
||||||
glDrawElements(GL_TRIANGLES, curr.getModel()->getIndexCount(), GL_UNSIGNED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, curr.getModel()->getIndexCount(), GL_UNSIGNED_INT, nullptr);
|
||||||
}
|
}
|
||||||
m_lGame.clear();
|
m_lGame.clear();
|
||||||
|
m_lights.clear();
|
||||||
|
|
||||||
|
//Draw UI elements
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
proj = glm::ortho(0.0f, (float)m_app->getConfig().width, 0.0f, (float)m_app->getConfig().height);
|
proj = glm::ortho(0.0f, (float)m_app->getConfig().width, 0.0f, (float)m_app->getConfig().height);
|
||||||
for (UIElement* draw : m_lUI) {
|
for (UIElement* draw : m_lUI) {
|
||||||
@ -122,6 +138,7 @@ namespace nf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_lUI.clear();
|
m_lUI.clear();
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
SwapBuffers(m_hdc);
|
SwapBuffers(m_hdc);
|
||||||
|
|
||||||
|
@ -47,19 +47,29 @@ namespace nf {
|
|||||||
glUseProgram(m_id);
|
glUseProgram(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::setUniform(const char* name, glm::mat4& data) {
|
void Shader::setUniform(const std::string& name, glm::mat4& data) {
|
||||||
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
||||||
getUniformLocation(name);
|
getUniformLocation(name);
|
||||||
glUniformMatrix4fv(m_uniformLocations[name], 1, GL_FALSE, glm::value_ptr(data));
|
glUniformMatrix4fv(m_uniformLocations[name], 1, GL_FALSE, glm::value_ptr(data));
|
||||||
}
|
}
|
||||||
void Shader::setUniform(const char* name, glm::vec3& data) {
|
void Shader::setUniform(const std::string& name, glm::vec3& data) {
|
||||||
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
||||||
getUniformLocation(name);
|
getUniformLocation(name);
|
||||||
glUniform3fv(m_uniformLocations[name], 1, glm::value_ptr(data));
|
glUniform3fv(m_uniformLocations[name], 1, glm::value_ptr(data));
|
||||||
}
|
}
|
||||||
|
void Shader::setUniform(const std::string& name, int data) {
|
||||||
|
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
||||||
|
getUniformLocation(name);
|
||||||
|
glUniform1i(m_uniformLocations[name], data);
|
||||||
|
}
|
||||||
|
void Shader::setUniform(const std::string& name, float data) {
|
||||||
|
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
||||||
|
getUniformLocation(name);
|
||||||
|
glUniform1f(m_uniformLocations[name], data);
|
||||||
|
}
|
||||||
|
|
||||||
void Shader::getUniformLocation(const char* uniformName) {
|
void Shader::getUniformLocation(const std::string& uniformName) {
|
||||||
unsigned int loc = glGetUniformLocation(m_id, uniformName);
|
unsigned int loc = glGetUniformLocation(m_id, uniformName.c_str());
|
||||||
if (loc == -1)
|
if (loc == -1)
|
||||||
Error("Uniform \"" + (std::string)uniformName + "\" does not exist!");
|
Error("Uniform \"" + (std::string)uniformName + "\" does not exist!");
|
||||||
m_uniformLocations[uniformName] = loc;
|
m_uniformLocations[uniformName] = loc;
|
||||||
|
@ -20,7 +20,7 @@ namespace nf {
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_id);
|
glBindTexture(GL_TEXTURE_2D, m_id);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_x, m_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
|
glTexImage2D(GL_TEXTURE_2D, 0, nChannels == 3 ? GL_RGB : GL_RGBA, m_x, m_y, 0, nChannels == 3 ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, texture);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
stbi_image_free(texture);
|
stbi_image_free(texture);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "glm/glm.hpp"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
@ -111,13 +112,13 @@ namespace nf {
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseOBJ(std::string& in, std::vector<float>& vbOut, std::vector<unsigned int>& ibOut, size_t& ibCountOut, std::vector<float>& tcOut) {
|
void parseOBJ(std::string& in, std::vector<float>& vbOut, std::vector<unsigned int>& ibOut, size_t& ibCountOut, std::vector<float>& tcOut, std::vector<float>& vnOut) {
|
||||||
std::string file = in;
|
std::string file = in;
|
||||||
std::vector<float> vbRaw, tcRaw;
|
std::vector<float> vbRaw, tcRaw, vnRaw;
|
||||||
std::vector<unsigned int> vertexIndices, uvIndices, normalIndices;
|
std::vector<unsigned int> vertexIndices, uvIndices, vnIndices;
|
||||||
std::vector<float> tempVertices;
|
std::vector<float> tempVertices, tempTC, tempVN;
|
||||||
std::vector<float> tempTC;
|
|
||||||
|
|
||||||
|
bool tcPresent = false, vnPresent = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
char line[500];
|
char line[500];
|
||||||
int remove = 0;
|
int remove = 0;
|
||||||
@ -133,41 +134,66 @@ namespace nf {
|
|||||||
tempVertices.push_back(z);
|
tempVertices.push_back(z);
|
||||||
}
|
}
|
||||||
else if (std::strcmp(line, "vt") == 0) {
|
else if (std::strcmp(line, "vt") == 0) {
|
||||||
|
tcPresent = true;
|
||||||
float u = 0.0, v = 0.0;
|
float u = 0.0, v = 0.0;
|
||||||
sscanf_s(file.c_str(), "\nvt %f %f\n", &u, &v);
|
sscanf_s(file.c_str(), "\nvt %f %f\n", &u, &v);
|
||||||
remove = 18;
|
remove = 18;
|
||||||
tempTC.push_back(u);
|
tempTC.push_back(u);
|
||||||
tempTC.push_back(v);
|
tempTC.push_back(v);
|
||||||
}
|
}
|
||||||
|
if (std::strcmp(line, "vn") == 0) {
|
||||||
|
vnPresent = true;
|
||||||
|
float x = 0.0, y = 0.0, z = 0.0;
|
||||||
|
sscanf_s(file.c_str(), "\nvn %f %f %f\n", &x, &y, &z);
|
||||||
|
remove = 20;
|
||||||
|
tempVN.push_back(x);
|
||||||
|
tempVN.push_back(y);
|
||||||
|
tempVN.push_back(z);
|
||||||
|
}
|
||||||
else if (std::strcmp(line, "f") == 0) {
|
else if (std::strcmp(line, "f") == 0) {
|
||||||
unsigned int vertexIndex[3], uvIndex[3];
|
unsigned int vertexIndex[3], uvIndex[3], vnIndex[3];
|
||||||
sscanf_s(file.c_str(), "\nf %d/%d %d/%d %d/%d\n", &vertexIndex[0], &uvIndex[0], &vertexIndex[1], &uvIndex[1], &vertexIndex[2], &uvIndex[2]);
|
sscanf_s(file.c_str(), "\nf %d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &uvIndex[0], &vnIndex[0], &vertexIndex[1], &uvIndex[1], &vnIndex[1], &vertexIndex[2], &uvIndex[2], &vnIndex[2]);
|
||||||
remove = 12;
|
remove = 15;
|
||||||
vertexIndices.push_back(vertexIndex[0]);
|
vertexIndices.push_back(vertexIndex[0]);
|
||||||
vertexIndices.push_back(vertexIndex[1]);
|
vertexIndices.push_back(vertexIndex[1]);
|
||||||
vertexIndices.push_back(vertexIndex[2]);
|
vertexIndices.push_back(vertexIndex[2]);
|
||||||
uvIndices.push_back(uvIndex[0]);
|
uvIndices.push_back(uvIndex[0]);
|
||||||
uvIndices.push_back(uvIndex[1]);
|
uvIndices.push_back(uvIndex[1]);
|
||||||
uvIndices.push_back(uvIndex[2]);
|
uvIndices.push_back(uvIndex[2]);
|
||||||
|
vnIndices.push_back(vnIndex[0]);
|
||||||
|
vnIndices.push_back(vnIndex[1]);
|
||||||
|
vnIndices.push_back(vnIndex[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int pos = file.find(line) + strlen(line) + remove;
|
unsigned int pos = file.find(line) + strlen(line) + remove;
|
||||||
file = file.substr(pos);
|
file = file.substr(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tcPresent)
|
||||||
|
Error("No texture coordinates found in model!");
|
||||||
|
if (!vnPresent)
|
||||||
|
Error("No normals found in model!");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < vertexIndices.size(); i++) {
|
for (unsigned int i = 0; i < vertexIndices.size(); i++) {
|
||||||
unsigned int vertexIndex = vertexIndices[i];
|
unsigned int vertexIndex = vertexIndices[i];
|
||||||
unsigned int uvIndex = uvIndices[i];
|
unsigned int uvIndex = uvIndices[i];
|
||||||
|
unsigned int vnIndex = vnIndices[i];
|
||||||
float vertexX = tempVertices[(vertexIndex - 1) * 3];
|
float vertexX = tempVertices[(vertexIndex - 1) * 3];
|
||||||
float vertexY = tempVertices[(vertexIndex - 1) * 3 + 1];
|
float vertexY = tempVertices[(vertexIndex - 1) * 3 + 1];
|
||||||
float vertexZ = tempVertices[(vertexIndex - 1) * 3 + 2];
|
float vertexZ = tempVertices[(vertexIndex - 1) * 3 + 2];
|
||||||
float vertexU = tempTC[(uvIndex - 1) * 2];
|
float vertexU = tempTC[(uvIndex - 1) * 2];
|
||||||
float vertexV = tempTC[(uvIndex - 1) * 2 + 1];
|
float vertexV = tempTC[(uvIndex - 1) * 2 + 1];
|
||||||
|
float vnX = tempVN[(vnIndex - 1) * 3];
|
||||||
|
float vnY = tempVN[(vnIndex - 1) * 3 + 1];
|
||||||
|
float vnZ = tempVN[(vnIndex - 1) * 3 + 2];
|
||||||
vbRaw.push_back(vertexX);
|
vbRaw.push_back(vertexX);
|
||||||
vbRaw.push_back(vertexY);
|
vbRaw.push_back(vertexY);
|
||||||
vbRaw.push_back(vertexZ);
|
vbRaw.push_back(vertexZ);
|
||||||
tcRaw.push_back(vertexU);
|
tcRaw.push_back(vertexU);
|
||||||
tcRaw.push_back(vertexV);
|
tcRaw.push_back(vertexV);
|
||||||
|
vnRaw.push_back(vnX);
|
||||||
|
vnRaw.push_back(vnY);
|
||||||
|
vnRaw.push_back(vnZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
@ -178,13 +204,17 @@ namespace nf {
|
|||||||
float u;
|
float u;
|
||||||
float v;
|
float v;
|
||||||
|
|
||||||
|
float vnX;
|
||||||
|
float vnY;
|
||||||
|
float vnZ;
|
||||||
|
|
||||||
bool operator<(const Vertex other) const {
|
bool operator<(const Vertex other) const {
|
||||||
return std::memcmp((void*)this, (void*)&other, sizeof(Vertex)) > 0;
|
return std::memcmp((void*)this, (void*)&other, sizeof(Vertex)) > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::map<Vertex, unsigned int> vertexMap;
|
std::map<Vertex, unsigned int> vertexMap;
|
||||||
for (unsigned int i = 0; i * 3 < vbRaw.size(); i++) {
|
for (unsigned int i = 0; i * 3 < vbRaw.size(); i++) {
|
||||||
Vertex curr = { vbRaw[(i * 3)], vbRaw[(i * 3) + 1], vbRaw[(i * 3) + 2], tcRaw[(i * 2)], tcRaw[(i * 2) + 1] };
|
Vertex curr = { vbRaw[(i * 3)], vbRaw[(i * 3) + 1], vbRaw[(i * 3) + 2], tcRaw[(i * 2)], tcRaw[(i * 2) + 1], vnRaw[(i * 3)], vnRaw[(i * 3) + 1], vnRaw[(i * 3) + 2] };
|
||||||
bool found = false;
|
bool found = false;
|
||||||
found = vertexMap.find(curr) != vertexMap.end();
|
found = vertexMap.find(curr) != vertexMap.end();
|
||||||
if (found) {
|
if (found) {
|
||||||
@ -198,6 +228,9 @@ namespace nf {
|
|||||||
vbOut.push_back(curr.z);
|
vbOut.push_back(curr.z);
|
||||||
tcOut.push_back(curr.u);
|
tcOut.push_back(curr.u);
|
||||||
tcOut.push_back(curr.v);
|
tcOut.push_back(curr.v);
|
||||||
|
vnOut.push_back(curr.vnX);
|
||||||
|
vnOut.push_back(curr.vnY);
|
||||||
|
vnOut.push_back(curr.vnZ);
|
||||||
unsigned int index = (vbOut.size() / 3) - 1;
|
unsigned int index = (vbOut.size() / 3) - 1;
|
||||||
ibOut.push_back(index);
|
ibOut.push_back(index);
|
||||||
vertexMap[curr] = index;
|
vertexMap[curr] = index;
|
||||||
|
@ -8,10 +8,10 @@ namespace nf {
|
|||||||
class Camera {
|
class Camera {
|
||||||
public:
|
public:
|
||||||
enum class Type {
|
enum class Type {
|
||||||
NF_CAMERA_UI,
|
UI,
|
||||||
NF_CAMERA_FIRST_PERSON,
|
FIRST_PERSON,
|
||||||
NF_CAMERA_ORBIT,
|
ORBIT,
|
||||||
NF_CAMERA_FIXED
|
FIXED
|
||||||
};
|
};
|
||||||
Camera(Application* app);
|
Camera(Application* app);
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ namespace nf {
|
|||||||
void moveLeft(double speed);
|
void moveLeft(double speed);
|
||||||
void setPosition(double x, double y, double z);
|
void setPosition(double x, double y, double z);
|
||||||
void setPosition(const Vec3& position);
|
void setPosition(const Vec3& position);
|
||||||
|
const Vec3& getPosition();
|
||||||
|
|
||||||
void bind(Shader* shader);
|
void bind(Shader* shader);
|
||||||
|
|
||||||
|
36
NothinFancy/src/include/Light.h
Normal file
36
NothinFancy/src/include/Light.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
|
namespace nf {
|
||||||
|
class Shader;
|
||||||
|
|
||||||
|
class Light {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
DIRECTIONAL,
|
||||||
|
POINT,
|
||||||
|
SPOTLIGHT
|
||||||
|
};
|
||||||
|
Light();
|
||||||
|
|
||||||
|
void create(const Vec3& position, const Vec3& color, Type type = Type::POINT, float strength = 1.0f);
|
||||||
|
bool isConstructed();
|
||||||
|
void setPosition(const Vec3& position);
|
||||||
|
void setColor(const Vec3& color);
|
||||||
|
|
||||||
|
void bind(Shader* shader, unsigned int lightNumber);
|
||||||
|
|
||||||
|
Type getType();
|
||||||
|
const Vec3& getPosition();
|
||||||
|
const Vec3& getColor();
|
||||||
|
const float getStrength();
|
||||||
|
|
||||||
|
~Light();
|
||||||
|
private:
|
||||||
|
bool m_constructed;
|
||||||
|
Type m_type;
|
||||||
|
Vec3 m_position;
|
||||||
|
Vec3 m_color;
|
||||||
|
float m_strength;
|
||||||
|
};
|
||||||
|
}
|
@ -10,7 +10,7 @@ namespace nf {
|
|||||||
public:
|
public:
|
||||||
Model();
|
Model();
|
||||||
|
|
||||||
void create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount, const void* textureCoordinates, size_t textureCoordinatesBufferSize, ATexture* texture);
|
void create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount, const void* textureCoordinatesBufferData, size_t textureCoordinatesBufferSize, const void* normalsBufferData, size_t normalsBufferSize, ATexture* texture);
|
||||||
void bind() override;
|
void bind() override;
|
||||||
|
|
||||||
~Model();
|
~Model();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
#include "IntroGamestate.h"
|
#include "IntroGamestate.h"
|
||||||
#include "Assets.h"
|
#include "Assets.h"
|
||||||
|
#include "Light.h"
|
||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
#include "UITexture.h"
|
#include "UITexture.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
@ -52,6 +53,7 @@ namespace nf {
|
|||||||
|
|
||||||
void render(Entity& in);
|
void render(Entity& in);
|
||||||
void render(UIElement& in);
|
void render(UIElement& in);
|
||||||
|
void render(Light& in);
|
||||||
|
|
||||||
void doFrame(Camera* camera);
|
void doFrame(Camera* camera);
|
||||||
|
|
||||||
@ -62,12 +64,14 @@ namespace nf {
|
|||||||
HDC m_hdc;
|
HDC m_hdc;
|
||||||
HGLRC m_hglrc;
|
HGLRC m_hglrc;
|
||||||
|
|
||||||
AssetPack baseAP;
|
AssetPack m_baseAP;
|
||||||
|
|
||||||
|
std::vector<Light*> m_lights;
|
||||||
std::vector<Entity*> m_lGame;
|
std::vector<Entity*> m_lGame;
|
||||||
std::vector<UIElement*> m_lUI;
|
std::vector<UIElement*> m_lUI;
|
||||||
Shader* m_entityShader;
|
Shader* m_entityShader;
|
||||||
Shader* m_textShader;
|
Shader* m_textShader;
|
||||||
|
Shader* m_uiTextureShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Application {
|
class Application {
|
||||||
|
@ -2,12 +2,15 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Assets.h"
|
||||||
#include "Camera.h"
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class Application;
|
class Application;
|
||||||
|
class Shader;
|
||||||
|
class Entity;
|
||||||
class UIElement;
|
class UIElement;
|
||||||
|
class Light;
|
||||||
|
class Camera;
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
@ -15,7 +18,7 @@ namespace nf {
|
|||||||
|
|
||||||
void render(Entity& in);
|
void render(Entity& in);
|
||||||
void render(UIElement& in);
|
void render(UIElement& in);
|
||||||
//TODO: Create second render function for UIElements
|
void render(Light& in);
|
||||||
|
|
||||||
void doFrame(Camera* camera);
|
void doFrame(Camera* camera);
|
||||||
|
|
||||||
@ -26,8 +29,9 @@ namespace nf {
|
|||||||
HDC m_hdc;
|
HDC m_hdc;
|
||||||
HGLRC m_hglrc;
|
HGLRC m_hglrc;
|
||||||
|
|
||||||
AssetPack baseAP;
|
AssetPack m_baseAP;
|
||||||
|
|
||||||
|
std::vector<Light*> m_lights;
|
||||||
std::vector<Entity*> m_lGame;
|
std::vector<Entity*> m_lGame;
|
||||||
std::vector<UIElement*> m_lUI;
|
std::vector<UIElement*> m_lUI;
|
||||||
Shader* m_entityShader;
|
Shader* m_entityShader;
|
||||||
|
@ -9,14 +9,16 @@ namespace nf {
|
|||||||
Shader(const char* vertexSource, const char* fragmentSource);
|
Shader(const char* vertexSource, const char* fragmentSource);
|
||||||
|
|
||||||
void bind();
|
void bind();
|
||||||
void setUniform(const char* name, glm::mat4& data);
|
void setUniform(const std::string& name, glm::mat4& data);
|
||||||
void setUniform(const char* name, glm::vec3& data);
|
void setUniform(const std::string& name, glm::vec3& data);
|
||||||
|
void setUniform(const std::string& name, int data);
|
||||||
|
void setUniform(const std::string& name, float data);
|
||||||
|
|
||||||
~Shader();
|
~Shader();
|
||||||
private:
|
private:
|
||||||
void getUniformLocation(const char* uniformName);
|
void getUniformLocation(const std::string& uniformName);
|
||||||
|
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
std::unordered_map<const char*, unsigned int> m_uniformLocations;
|
std::unordered_map<std::string, unsigned int> m_uniformLocations;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -14,10 +14,12 @@ namespace nf {
|
|||||||
void setPosition(float x, float y);
|
void setPosition(float x, float y);
|
||||||
void setPosition(const Vec2& position);
|
void setPosition(const Vec2& position);
|
||||||
void centered(bool x, bool y = false);
|
void centered(bool x, bool y = false);
|
||||||
|
bool isConstructed();
|
||||||
virtual void render(Shader* shader, unsigned int windowWidth, unsigned int windowHeight);
|
virtual void render(Shader* shader, unsigned int windowWidth, unsigned int windowHeight);
|
||||||
|
|
||||||
~UIElement();
|
~UIElement();
|
||||||
protected:
|
protected:
|
||||||
|
bool m_constructed;
|
||||||
Vec2 m_position;
|
Vec2 m_position;
|
||||||
bool m_centeredX;
|
bool m_centeredX;
|
||||||
bool m_centeredY;
|
bool m_centeredY;
|
||||||
|
@ -84,5 +84,5 @@ std::exit(-1);}
|
|||||||
void writeFile(const std::string& filename, const std::string& in, bool encrypted = false);
|
void writeFile(const std::string& filename, const std::string& in, bool encrypted = false);
|
||||||
std::string readFile(const std::string& filename);
|
std::string readFile(const std::string& filename);
|
||||||
|
|
||||||
void parseOBJ(std::string& in, std::vector<float>& vbOut, std::vector<unsigned int>& ibOut, size_t& ibCountOut, std::vector<float>& tcOut);
|
void parseOBJ(std::string& in, std::vector<float>& vbOut, std::vector<unsigned int>& ibOut, size_t& ibCountOut, std::vector<float>& tcOut, std::vector<float>& vnOut);
|
||||||
}
|
}
|
Reference in New Issue
Block a user