diff --git a/Bin/Content/Shaders/DebugCameraVertex.cso b/Bin/Content/Shaders/DebugCameraVertex.cso
deleted file mode 100644
index 20c23e0c..00000000
Binary files a/Bin/Content/Shaders/DebugCameraVertex.cso and /dev/null differ
diff --git a/Bin/Content/Shaders/DebugPixel.cso b/Bin/Content/Shaders/DebugPixel.cso
deleted file mode 100644
index da6e4513..00000000
Binary files a/Bin/Content/Shaders/DebugPixel.cso and /dev/null differ
diff --git a/Bin/Content/Shaders/LightPass.cso b/Bin/Content/Shaders/LightPass.cso
deleted file mode 100644
index c5573288..00000000
Binary files a/Bin/Content/Shaders/LightPass.cso and /dev/null differ
diff --git a/Bin/Content/Shaders/PixelGatherData.cso b/Bin/Content/Shaders/PixelGatherData.cso
deleted file mode 100644
index 70eba698..00000000
Binary files a/Bin/Content/Shaders/PixelGatherData.cso and /dev/null differ
diff --git a/Bin/Content/Shaders/TextureDebug.cso b/Bin/Content/Shaders/TextureDebug.cso
deleted file mode 100644
index 51c99d22..00000000
Binary files a/Bin/Content/Shaders/TextureDebug.cso and /dev/null differ
diff --git a/Bin/Content/Shaders/VertexGatherData.cso b/Bin/Content/Shaders/VertexGatherData.cso
deleted file mode 100644
index e105bdbc..00000000
Binary files a/Bin/Content/Shaders/VertexGatherData.cso and /dev/null differ
diff --git a/Bin/Content/crate.obj b/Bin/Content/crate.obj
new file mode 100644
index 00000000..027fd2cd
--- /dev/null
+++ b/Bin/Content/crate.obj
@@ -0,0 +1,233 @@
+# This file uses centimeters as units for non-parametric coordinates.
+
+mtllib crate.mtl
+g default
+v -0.500000 -0.500000 0.500000
+v 0.500000 -0.500000 0.500000
+v -0.500000 0.500000 0.500000
+v 0.500000 0.500000 0.500000
+v -0.500000 0.500000 -0.500000
+v 0.500000 0.500000 -0.500000
+v -0.500000 -0.500000 -0.500000
+v 0.500000 -0.500000 -0.500000
+v -0.500000 -0.500000 0.500000
+v 0.500000 -0.500000 0.500000
+v 0.500000 0.500000 0.500000
+v -0.500000 0.500000 0.500000
+v 0.500000 0.500000 -0.500000
+v -0.500000 0.500000 -0.500000
+v 0.500000 -0.500000 -0.500000
+v -0.500000 -0.500000 -0.500000
+v -0.479379 0.522314 0.479379
+v 0.479379 0.522314 0.479379
+v 0.479379 0.522314 -0.479379
+v -0.479379 0.522314 -0.479379
+v -0.470939 -0.528599 -0.470939
+v 0.470939 -0.528599 -0.470939
+v 0.470939 -0.528599 0.470939
+v -0.470939 -0.528599 0.470939
+v 0.520103 -0.460610 -0.460610
+v 0.520103 -0.460610 0.460610
+v 0.520103 0.460610 -0.460610
+v 0.520103 0.460610 0.460610
+v -0.522559 -0.464751 -0.464751
+v -0.522559 -0.464751 0.464751
+v -0.522559 0.464751 0.464751
+v -0.522559 0.464751 -0.464751
+v -0.460954 -0.460954 0.522335
+v 0.460954 -0.460954 0.522335
+v 0.460954 0.460954 0.522335
+v -0.460954 0.460954 0.522335
+v -0.466507 0.466507 -0.525017
+v 0.466507 0.466507 -0.525017
+v 0.466507 -0.466507 -0.525017
+v -0.466507 -0.466507 -0.525017
+vt 0.995838 0.004695
+vt 0.999640 -0.003712
+vt 0.003809 -0.000160
+vt -0.000796 1.000526
+vt 0.003809 0.003892
+vt 0.999640 0.995671
+vt 0.003809 0.007944
+vt 0.999640 0.999723
+vt 0.003809 1.003774
+vt 0.999640 1.003774
+vt 0.995035 0.004695
+vt 0.995035 1.000526
+vt 0.000007 0.004695
+vt 0.000007 1.000526
+vt 0.999640 0.007944
+vt -0.000796 0.004695
+vt 0.003809 0.999723
+vt 0.003809 -0.003712
+vt 0.999640 0.003892
+vt 0.003809 0.995671
+vt 0.999640 0.992119
+vt 0.999640 -0.000160
+vt 0.003809 0.992119
+vt 0.995838 1.000526
+vt 0.003809 -0.003712
+vt 0.999640 -0.003712
+vt 0.999640 0.992119
+vt 0.003809 0.992119
+vt 0.003809 -0.000160
+vt 0.999640 -0.000160
+vt 0.999640 0.995671
+vt 0.003809 0.995671
+vt 0.003809 0.003892
+vt 0.999640 0.003892
+vt 0.999640 0.999723
+vt 0.003809 0.999723
+vt 0.003809 0.007944
+vt 0.999640 0.007944
+vt 0.999640 1.003774
+vt 0.003809 1.003774
+vt -0.000796 0.004695
+vt 0.995035 0.004695
+vt 0.995035 1.000526
+vt -0.000796 1.000526
+vt 0.000007 0.004695
+vt 0.995838 0.004695
+vt 0.995838 1.000526
+vt 0.000007 1.000526
+vt 0.003809 -0.000160
+vt 0.999640 -0.000160
+vt 0.999640 0.995671
+vt 0.003809 0.995671
+vt 0.003809 0.007944
+vt 0.999640 0.007944
+vt 0.999640 1.003774
+vt 0.003809 1.003774
+vt -0.000796 0.004695
+vt 0.995035 0.004695
+vt 0.995035 1.000526
+vt -0.000796 1.000526
+vt 0.000007 0.004695
+vt 0.995838 0.004695
+vt 0.995838 1.000526
+vt 0.000007 1.000526
+vt 0.003809 -0.003712
+vt 0.999640 -0.003712
+vt 0.999640 0.992119
+vt 0.003809 0.992119
+vt 0.003809 0.003892
+vt 0.999640 0.003892
+vt 0.999640 0.999723
+vt 0.003809 0.999723
+vn -0.031209 -0.033799 0.998941
+vn 0.033799 -0.031209 0.998941
+vn -0.033799 0.031209 0.998941
+vn 0.031209 0.033799 0.998941
+vn -0.030245 0.999045 0.031527
+vn 0.031527 0.999045 0.030245
+vn -0.031527 0.999045 -0.030245
+vn 0.030245 0.999045 -0.031527
+vn -0.034614 0.037052 -0.998714
+vn 0.037051 0.034614 -0.998714
+vn -0.037051 -0.034614 -0.998714
+vn 0.034614 -0.037052 -0.998714
+vn -0.038824 -0.998397 -0.041174
+vn 0.041174 -0.998397 -0.038824
+vn -0.041174 -0.998397 0.038824
+vn 0.038824 -0.998397 0.041174
+vn 0.999134 -0.030589 0.028224
+vn 0.999134 -0.028224 -0.030589
+vn 0.999134 0.028224 0.030589
+vn 0.999134 0.030589 -0.028224
+vn -0.998933 -0.033811 -0.031470
+vn -0.998933 -0.031470 0.033811
+vn -0.998933 0.031470 -0.033811
+vn -0.998933 0.033811 0.031470
+vn 0.577350 0.577350 -0.577350
+vn 0.577350 -0.577350 -0.577350
+vn -0.577350 0.577350 -0.577350
+vn -0.577350 -0.577350 -0.577350
+vn 0.577350 -0.577350 0.577350
+vn -0.577350 -0.577350 0.577350
+vn 0.577350 0.577350 0.577350
+vn -0.577350 0.577350 0.577350
+vn -0.608285 0.469952 0.639637
+vn 0.633500 0.454555 0.626145
+vn 0.657522 0.474071 -0.585595
+vn -0.626276 0.491669 -0.605013
+vn -0.608373 -0.534484 -0.586694
+vn 0.635292 -0.520408 -0.570596
+vn 0.616200 -0.500955 0.607735
+vn -0.589957 -0.516183 0.620891
+s 1
+g meshCrate
+usemtl matCrateSG
+f 33/65/1 34/66/2 36/68/3
+f 36/68/3 34/66/2 35/67/4
+f 17/49/5 18/50/6 20/52/7
+f 20/52/7 18/50/6 19/51/8
+f 37/69/9 38/70/10 40/72/11
+f 40/72/11 38/70/10 39/71/12
+f 21/53/13 22/54/14 24/56/15
+f 24/56/15 22/54/14 23/55/16
+f 26/57/17 25/58/18 28/60/19
+f 28/60/19 25/58/18 27/59/20
+f 29/61/21 30/62/22 32/64/23
+f 32/64/23 30/62/22 31/63/24
+s 7
+f 1/25/25 3/28/26 2/26/27
+f 2/26/27 3/28/26 4/27/28
+f 3/29/26 5/32/29 4/30/28
+f 4/30/28 5/32/29 6/31/30
+f 5/33/29 7/36/31 6/34/30
+f 6/34/30 7/36/31 8/35/32
+f 7/37/31 1/40/25 8/38/32
+f 8/38/32 1/40/25 2/39/27
+f 2/41/27 4/44/28 8/42/32
+f 8/42/32 4/44/28 6/43/30
+f 7/45/31 5/48/29 1/46/25
+f 1/46/25 5/48/29 3/47/26
+s 1
+f 12/3/33 11/22/34 17/49/5
+f 17/49/5 11/22/34 18/50/6
+f 11/22/34 13/6/35 18/50/6
+f 18/50/6 13/6/35 19/51/8
+f 13/6/35 14/20/36 19/51/8
+f 19/51/8 14/20/36 20/52/7
+f 14/20/36 12/3/33 20/52/7
+f 20/52/7 12/3/33 17/49/5
+f 16/7/37 15/15/38 21/53/13
+f 21/53/13 15/15/38 22/54/14
+f 15/15/38 10/10/39 22/54/14
+f 22/54/14 10/10/39 23/55/16
+f 10/10/39 9/9/40 23/55/16
+f 23/55/16 9/9/40 24/56/15
+f 9/9/40 16/7/37 24/56/15
+f 24/56/15 16/7/37 21/53/13
+f 10/16/39 15/11/38 26/57/17
+f 26/57/17 15/11/38 25/58/18
+f 15/11/38 13/12/35 25/58/18
+f 25/58/18 13/12/35 27/59/20
+f 13/12/35 11/4/34 27/59/20
+f 27/59/20 11/4/34 28/60/19
+f 11/4/34 10/16/39 28/60/19
+f 28/60/19 10/16/39 26/57/17
+f 16/13/37 9/1/40 29/61/21
+f 29/61/21 9/1/40 30/62/22
+f 9/1/40 12/24/33 30/62/22
+f 30/62/22 12/24/33 31/63/24
+f 12/24/33 14/14/36 31/63/24
+f 31/63/24 14/14/36 32/64/23
+f 14/14/36 16/13/37 32/64/23
+f 32/64/23 16/13/37 29/61/21
+f 9/18/40 10/2/39 33/65/1
+f 33/65/1 10/2/39 34/66/2
+f 10/2/39 11/21/34 34/66/2
+f 34/66/2 11/21/34 35/67/4
+f 11/21/34 12/23/33 35/67/4
+f 35/67/4 12/23/33 36/68/3
+f 12/23/33 9/18/40 36/68/3
+f 36/68/3 9/18/40 33/65/1
+f 14/5/36 13/19/35 37/69/9
+f 37/69/9 13/19/35 38/70/10
+f 13/19/35 15/8/38 38/70/10
+f 38/70/10 15/8/38 39/71/12
+f 15/8/38 16/17/37 39/71/12
+f 39/71/12 16/17/37 40/72/11
+f 16/17/37 14/5/36 40/72/11
+f 40/72/11 14/5/36 37/69/9
diff --git a/Bin/Content/tex_crate.png b/Bin/Content/tex_crate.png
new file mode 100644
index 00000000..a7b0b1ef
Binary files /dev/null and b/Bin/Content/tex_crate.png differ
diff --git a/Code/DanBias.sln b/Code/DanBias.sln
index 32915f21..90a7843f 100644
--- a/Code/DanBias.sln
+++ b/Code/DanBias.sln
@@ -57,6 +57,7 @@ Global
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Release|x64
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Debug|x64
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -68,6 +69,7 @@ Global
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Release|x64
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.Build.0 = Debug|Win32
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Debug|x64
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Debug|x64
{F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -79,6 +81,7 @@ Global
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.Build.0 = Release|x64
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.Build.0 = Debug|Win32
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.ActiveCfg = Debug|x64
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.Build.0 = Debug|x64
{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -90,6 +93,7 @@ Global
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.Build.0 = Release|x64
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.ActiveCfg = Debug|Win32
+ {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.Build.0 = Debug|Win32
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.ActiveCfg = Debug|x64
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.Build.0 = Debug|x64
{34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -101,6 +105,7 @@ Global
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.Build.0 = Release|x64
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.Build.0 = Debug|Win32
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.ActiveCfg = Debug|x64
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.Build.0 = Debug|x64
{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -124,6 +129,7 @@ Global
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Release|x64
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64
{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -157,6 +163,7 @@ Global
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64
@@ -168,6 +175,7 @@ Global
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Release|Win32
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Release|Win32
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.Build.0 = Debug|x64
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -185,6 +193,7 @@ Global
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -196,6 +205,7 @@ Global
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -207,6 +217,7 @@ Global
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -218,6 +229,7 @@ Global
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.Build.0 = Debug|Win32
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.ActiveCfg = Debug|x64
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.Build.0 = Debug|x64
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -229,6 +241,7 @@ Global
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64
{460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32
@@ -240,6 +253,7 @@ Global
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.Build.0 = Debug|Win32
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.ActiveCfg = Debug|x64
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.Build.0 = Debug|x64
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.ActiveCfg = Release|Win32
diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj
index 255f03bf..76a7554e 100644
--- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj
+++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj
@@ -71,15 +71,15 @@
$(SolutionDir)..\Bin\DLL\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)D
- $(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
- $(SolutionDir)..\External\Include\;$(IncludePath)
+ $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)
+ $(SolutionDir)Network/NetworkAPI;$(IncludePath)
true
$(SolutionDir)..\Bin\DLL\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)D
- C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)
$(SolutionDir)..\External\Include\;$(IncludePath)
@@ -87,7 +87,7 @@
$(SolutionDir)..\Bin\DLL\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)
- C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)
$(SolutionDir)..\External\Include\;$(IncludePath)
@@ -95,7 +95,7 @@
$(SolutionDir)..\Bin\DLL\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)
- C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)
$(SolutionDir)..\External\Include\;$(IncludePath)
@@ -106,7 +106,7 @@
Disabled
DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
- $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
+ $(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)
Windows
@@ -123,12 +123,12 @@
Disabled
DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
- $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
+ $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
Windows
true
- OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)
+ GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)
OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)
@@ -142,14 +142,14 @@
true
DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
- $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
+ $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
Windows
true
true
true
- OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)
+ GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)
OysterGraphics_x86.dll;%(DelayLoadDLLs)
@@ -163,14 +163,14 @@
true
DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
- $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
+ $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)
Windows
true
true
true
- OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)
+ GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)
OysterGraphics_x86.dll;%(DelayLoadDLLs)
@@ -178,16 +178,41 @@
{7e3990d2-3d94-465c-b58d-64a74b3ecf9b}
+
+ {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}
+
+
+ {460d625f-2ac9-4559-b809-0ba89ceaedf4}
+
{0ec83e64-230e-48ef-b08c-6ac9651b4f82}
+
+ {f10cbc03-9809-4cba-95d8-327c287b18ee}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
index 09fa36b8..e38b8cc9 100644
--- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
+++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
@@ -1,17 +1,55 @@
#define NOMINMAX
#include
#include "Include\DanBiasGame.h"
+#include "DllInterfaces/GFXAPI.h"
+#include "GameClientState/GameClientState.h"
+#include "GameClientState\GameState.h"
+#include "GameClientState\LobbyState.h"
+#include "PlayerProtocols.h"
+#include "NetworkClient.h"
+
+#include "L_inputClass.h"
+#include "vld.h"
namespace DanBias
{
__int64 DanBiasGame::cntsPerSec = 0;
__int64 DanBiasGame::prevTimeStamp = 0;
float DanBiasGame::secsPerCnt = 0;
- InputClass* DanBiasGame::inputObj = NULL;
HINSTANCE DanBiasGame::g_hInst = NULL;
HWND DanBiasGame::g_hWnd = NULL;
#pragma region Game Data
+
+
+ struct MyRecieverObject // :public PontusRecieverObject
+ {
+ Oyster::Network::NetworkClient nwClient;
+
+ static void ProtocolRecieved(Network::CustomNetProtocol* p)
+ {
+ int pType = ((*p)[0]).value.netInt;
+ switch (pType)
+ {
+ case protocol_PlayerNavigation:
+
+ break;
+ case protocol_PlayerPosition:
+ //int x = ((*p)[1]).value.netInt;
+ //int y = ((*p)[2]).value.netInt;
+ //int z = ((*p)[3]).value.netInt;
+ break;
+
+
+ case protocol_ObjectPosition:
+ // DanBiasGame::protocolRecived();
+ break;
+
+ default:
+ break;
+ }
+ }
+ };
class DanBiasGamePrivateData
{
@@ -26,10 +64,23 @@ namespace DanBias
}
public:
+ Client::GameClientState* gameClientState;
+ InputClass* inputObj;
+ GameLogic::Protocol_PlayerMovement player_move;
+ //Oyster::Network::NetworkClient nwClient;
+ MyRecieverObject r;
+
+ // gameClient;
} data;
#pragma endregion
+
+ DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
+ void DanBiasGame::protocolRecived()
+ {
+ //m_data->gameClientState.setPos()
+ }
//--------------------------------------------------------------------------------------
// Interface API functions
//--------------------------------------------------------------------------------------
@@ -41,7 +92,7 @@ namespace DanBias
if( FAILED( InitDirect3D() ) )
return DanBiasClientReturn_Error;
- if( FAILED( InitGame() ) )
+ if( FAILED( InitInput() ) )
return DanBiasClientReturn_Error;
cntsPerSec = 0;
@@ -51,6 +102,10 @@ namespace DanBias
prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
+
+ // Start in lobby state
+ m_data->gameClientState = new Client::LobbyState();
+ m_data->gameClientState->Init();
return DanBiasClientReturn_Sucess;
}
@@ -72,8 +127,10 @@ namespace DanBias
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
//render
- Update(dt);
- Render(dt);
+ if(Update(dt) != S_OK)
+ return DanBiasClientReturn_Error;
+ if(Render(dt) != S_OK)
+ return DanBiasClientReturn_Error;
prevTimeStamp = currTimeStamp;
}
@@ -145,48 +202,76 @@ namespace DanBias
}
//--------------------------------------------------------------------------------------
- // Init the input and the game
+ // Init the input
//-------------------------------------------------------------------------------------
- HRESULT DanBiasGame::InitGame()
+ HRESULT DanBiasGame::InitInput()
{
- inputObj = new InputClass;
- if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
+ m_data->inputObj = new InputClass;
+ if(!m_data->inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
{
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
return E_FAIL;
}
-
return S_OK;
}
HRESULT DanBiasGame::Update(float deltaTime)
{
- inputObj->Update();
+ m_data->inputObj->Update();
+ DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
+ state = m_data->gameClientState->Update(deltaTime, m_data->inputObj);
+
+ if(state != Client::GameClientState::ClientState_Same)
+ {
+ m_data->gameClientState->Release();
+ delete m_data->gameClientState;
+ m_data->gameClientState = NULL;
+
+ switch (state)
+ {
+ case Client::GameClientState::ClientState_Lobby:
+ m_data->gameClientState = new Client::LobbyState();
+ break;
+ case Client::GameClientState::ClientState_Game:
+ m_data->gameClientState = new Client::GameState();
+ break;
+ default:
+ return E_FAIL;
+ break;
+ }
+ m_data->gameClientState->Init(); // send game client
+
+ }
return S_OK;
}
HRESULT DanBiasGame::Render(float deltaTime)
{
int isPressed = 0;
- if(inputObj->IsKeyPressed(DIK_A))
+ if(m_data->inputObj->IsKeyPressed(DIK_A))
{
isPressed = 1;
}
-
- Oyster::Graphics::API::NewFrame(Oyster::Math3D::Float4x4::null, Oyster::Math3D::Float4x4::null);
-
+
wchar_t title[255];
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
SetWindowText(g_hWnd, title);
-
- Oyster::Graphics::API::EndFrame();
+
+ m_data->gameClientState->Render();
return S_OK;
}
HRESULT DanBiasGame::CleanUp()
{
+ m_data->gameClientState->Release();
+ delete m_data->gameClientState;
+ delete m_data->inputObj;
+ delete m_data;
+
+
+ Oyster::Graphics::API::Clean();
return S_OK;
}
diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.cpp b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp
new file mode 100644
index 00000000..840e6267
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp
@@ -0,0 +1,4 @@
+#include "C_Object.h"
+using namespace DanBias::Client;
+
+
diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h
new file mode 100644
index 00000000..8bfecdb9
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h
@@ -0,0 +1,28 @@
+#ifndef DANBIAS_CLIENT_COBJECT_H
+#define DANBIAS_CLIENT_COBJECT_H
+#include "DllInterfaces/GFXAPI.h"
+namespace DanBias
+{
+ namespace Client
+ {
+
+ struct ModelInitData
+ {
+ std::wstring modelPath;
+ Oyster::Math::Float4x4 world;
+ bool visible;
+ };
+
+class C_Object
+{
+private:
+
+public:
+
+ virtual void Init(ModelInitData modelInit) = 0;
+ virtual void setPos() = 0;
+
+ virtual void Render() = 0;
+ virtual void Release() = 0;
+};};};
+#endif
diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp
new file mode 100644
index 00000000..1fffc85e
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp
@@ -0,0 +1,12 @@
+#include "GameClientState.h"
+
+using namespace DanBias::Client;
+
+GameClientState::GameClientState(void)
+{
+}
+
+
+GameClientState::~GameClientState(void)
+{
+}
diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h
new file mode 100644
index 00000000..5277996d
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h
@@ -0,0 +1,32 @@
+#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H
+#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
+
+#define NOMINMAX
+#include "L_inputClass.h"
+
+namespace DanBias
+{
+namespace Client
+{
+
+class GameClientState
+{
+public:
+ enum ClientState
+ {
+ ClientState_Lobby,
+ ClientState_Game,
+ ClientState_Same,
+ };
+
+public:
+ GameClientState(void);
+ virtual ~GameClientState(void);
+ virtual bool Init() = 0;
+ virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
+ virtual bool Render() = 0;
+ virtual bool Release() = 0;
+};
+};
+};
+#endif
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
new file mode 100644
index 00000000..a95b6798
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
@@ -0,0 +1,129 @@
+#include "GameState.h"
+#include "DllInterfaces/GFXAPI.h"
+#include "Obj/C_Player.h"
+#include "Obj/C_DynamicObj.h"
+
+using namespace DanBias::Client;
+
+struct GameState::myData
+{
+ myData(){}
+ Oyster::Math3D::Float4x4 view;
+ Oyster::Math3D::Float4x4 proj;
+ C_Object* object[3];
+ int modelCount;
+ //Oyster::Network::NetworkClient* nwClient;
+ gameStateState state;
+}privData;
+
+GameState::GameState(void)
+{
+}
+
+
+GameState::~GameState(void)
+{
+
+}
+bool GameState::Init()
+{
+ // load models
+ privData = new myData();
+ privData->state = gameStateState_loading;
+ privData->state = LoadGame();
+ return true;
+}
+GameState::gameStateState GameState::LoadGame()
+{
+ LoadModels(L"map");
+ InitCamera(Oyster::Math::Float3(0,0,5.4f));
+ return gameStateState_playing;
+}
+bool GameState::LoadModels(std::wstring mapFile)
+{
+ // open file
+ // read file
+ // init models
+ privData->modelCount = 2;
+
+ ModelInitData modelData;
+
+ modelData.world = Oyster::Math3D::Float4x4::identity;
+ modelData.visible = true;
+ modelData.modelPath = L"worldDummy";
+ // load models
+ privData->object[0] = new C_Player();
+ privData->object[0]->Init(modelData);
+
+ Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
+ modelData.world = modelData.world * translate;
+ modelData.modelPath = L"crate";
+
+ privData->object[1] = new C_DynamicObj();
+ privData->object[1]->Init(modelData);
+ return true;
+}
+bool GameState::InitCamera(Oyster::Math::Float3 startPos)
+{
+ privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
+ //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
+ Oyster::Graphics::API::SetProjection(privData->proj);
+
+ privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
+ privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
+ return true;
+}
+
+GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
+{
+ switch (privData->state)
+ {
+ case gameStateState_loading:
+ // load map
+ // wait for all players
+ LoadGame();
+ privData->state = gameStateState_playing;
+ break;
+ case gameStateState_playing:
+ // read server data
+ // update objects
+ // Client.send(obj);
+
+ if(KeyInput->IsKeyPressed(DIK_L))
+ privData->state = GameState::gameStateState_end;
+ break;
+ case gameStateState_end:
+ return ClientState_Lobby;
+ break;
+ default:
+ break;
+ }
+
+ // send key input to server.
+ return ClientState_Same;
+}
+bool GameState::Render()
+{
+ Oyster::Graphics::API::SetView(privData->view);
+ Oyster::Graphics::API::SetProjection(privData->proj);
+ Oyster::Graphics::API::NewFrame();
+ for (int i = 0; i < privData->modelCount; i++)
+ {
+ privData->object[i]->Render();
+ }
+ Oyster::Graphics::API::EndFrame();
+ return true;
+}
+bool GameState::Release()
+{
+ for (int i = 0; i < privData->modelCount; i++)
+ {
+ privData->object[i]->Release();
+ delete privData->object[i];
+ privData->object[i] = NULL;
+ }
+
+ delete privData;
+ privData = NULL;
+ return true;
+}
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h
new file mode 100644
index 00000000..5ae6aa49
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/GameState.h
@@ -0,0 +1,36 @@
+#ifndef DANBIAS_CLIENT_GAMESTATE_H
+#define DANBIAS_CLIENT_GAMESTATE_H
+#include "GameClientState.h"
+#include "OysterMath.h"
+#include
+namespace DanBias
+{
+namespace Client
+{
+class GameState : public GameClientState
+{
+ enum gameStateState
+ {
+ gameStateState_loading,
+ gameStateState_playing,
+ gameStateState_end,
+ };
+private:
+
+ struct myData;
+ myData* privData;
+public:
+ GameState(void);
+ ~GameState(void);
+ bool Init();
+ GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput);
+ bool LoadModels(std::wstring mapFile);
+ bool InitCamera(Oyster::Math::Float3 startPos);
+ gameStateState LoadGame();
+
+ bool Render();
+ bool Release();
+};
+};
+};
+#endif
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp
new file mode 100644
index 00000000..b107883f
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp
@@ -0,0 +1,121 @@
+#include "LobbyState.h"
+#include "DllInterfaces/GFXAPI.h"
+#include "OysterMath.h"
+#include "Obj/C_Player.h"
+#include "Obj/C_StaticObj.h"
+#include "Obj/C_DynamicObj.h"
+
+using namespace DanBias::Client;
+
+struct LobbyState::myData
+{
+ myData(){}
+ Oyster::Math3D::Float4x4 view;
+ Oyster::Math3D::Float4x4 proj;
+ C_Object* object[2];
+ int modelCount;
+ // UI object
+ // game client*
+}privData;
+
+LobbyState::LobbyState(void)
+{
+
+}
+
+LobbyState::~LobbyState(void)
+{
+
+}
+
+bool LobbyState::Init()
+{
+ privData = new myData();
+
+ // load models
+ LoadModels(L"UImodels.txt");
+ InitCamera(Oyster::Math::Float3(0,0,5.4f));
+ return true;
+}
+bool LobbyState::LoadModels(std::wstring file)
+{
+ // open file
+ // read file
+ // init models
+ privData->modelCount = 2;
+
+ ModelInitData modelData;
+
+ modelData.world = Oyster::Math3D::Float4x4::identity;
+ modelData.visible = true;
+ modelData.modelPath = L"crate";
+ // load models
+ privData->object[0] = new C_StaticObj();
+ privData->object[0]->Init(modelData);
+
+ Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
+ modelData.world = modelData.world * translate;
+
+ privData->object[1] = new C_DynamicObj();
+ privData->object[1]->Init(modelData);
+ return true;
+}
+
+bool LobbyState::InitCamera(Oyster::Math::Float3 startPos)
+{
+ privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
+ //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
+ Oyster::Graphics::API::SetProjection(privData->proj);
+
+ privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
+ privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
+ return true;
+}
+GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput)
+{
+ // picking
+ // mouse events
+ // different menus
+ // play sounds
+ // update animation
+ // send data to server
+ // check data from server
+
+ if( KeyInput->IsKeyPressed(DIK_G))
+ return ClientState_Game;
+ return ClientState_Same;
+}
+bool LobbyState::Render()
+{
+
+ Oyster::Graphics::API::SetView(privData->view);
+ Oyster::Graphics::API::SetProjection( privData->proj);
+
+
+ Oyster::Graphics::API::NewFrame();
+ // render objects
+ for (int i = 0; i < privData->modelCount; i++)
+ {
+ privData->object[i]->Render();
+ }
+
+ // render effects
+
+ // render lights
+
+ Oyster::Graphics::API::EndFrame();
+ return true;
+}
+bool LobbyState::Release()
+{
+ for (int i = 0; i < privData->modelCount; i++)
+ {
+ privData->object[i]->Release();
+ delete privData->object[i];
+ privData->object[i] = NULL;
+ }
+
+ delete privData;
+ privData = NULL;
+ return true;
+}
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h
new file mode 100644
index 00000000..7498d448
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h
@@ -0,0 +1,36 @@
+#ifndef DANBIAS_CLIENT_LOBBYSTATE_H
+#define DANBIAS_CLIENT_LOBBYSTATE_H
+
+#include "GameClientState.h"
+#include "OysterMath.h"
+#include
+namespace DanBias
+{
+ namespace Client
+ {
+
+class LobbyState : public GameClientState
+{
+private:
+ struct myData;
+ myData* privData;
+public:
+ LobbyState(void);
+ ~LobbyState(void);
+ bool Init();
+ bool LoadModels(std::wstring file);
+ bool InitCamera(Oyster::Math::Float3 startPos);
+ ClientState Update(float deltaTime, InputClass* KeyInput);
+ // create session lobby
+ // join session lobby
+ // set name
+ // set rules
+ // set map
+ // ready
+ // chat
+ // kick
+
+ bool Render();
+ bool Release();
+};};};
+#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H
diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h
index d1adba92..deaafdb9 100644
--- a/Code/Game/DanBiasGame/Include/DanBiasGame.h
+++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h
@@ -10,8 +10,7 @@
#define NOMINMAX
#include
-#include "DllInterfaces/GFXAPI.h"
-#include "L_inputClass.h"
+
namespace DanBias
{
@@ -24,6 +23,8 @@ namespace DanBias
DanBiasClientReturn_Sucess,
};
+
+
struct DanBiasGameDesc
{
//Stuff goes here...
@@ -33,7 +34,7 @@ namespace DanBias
};
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-
+ class DanBiasGamePrivateData;
class DANBIAS_GAME_DLL DanBiasGame
{
public:
@@ -48,18 +49,21 @@ namespace DanBias
static HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow);
static HRESULT InitDirect3D();
- static HRESULT InitGame();
+ static HRESULT InitInput();
static HRESULT Update(float deltaTime);
static HRESULT Render(float deltaTime);
static HRESULT CleanUp();
+
+ static void protocolRecived();
private:
static __int64 cntsPerSec;
static __int64 prevTimeStamp;
static float secsPerCnt;
- static InputClass* inputObj;
+
static HINSTANCE g_hInst;
static HWND g_hWnd;
+ static DanBiasGamePrivateData* m_data;
};
diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj
index 0e97666f..e99b1754 100644
--- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj
+++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj
@@ -71,32 +71,32 @@
$(SolutionDir)..\Bin\Executable\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)D
- $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)
- $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Include\;$(IncludePath)
+ $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\Bin\DLL;
true
$(SolutionDir)..\Bin\Executable\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)D
- $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)
- $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Include\;$(IncludePath)
+ $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\Bin\DLL;
false
$(SolutionDir)..\Bin\Executable\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)
- $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)
- $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Include\;$(IncludePath)
+ $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\Bin\DLL;
false
$(SolutionDir)..\Bin\Executable\
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
$(ProjectName)_$(PlatformShortName)
- $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath)
- $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;
+ $(SolutionDir)..\External\Include\;$(IncludePath)
+ $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\Bin\DLL;
@@ -105,13 +105,13 @@
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
- $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
+ $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
Windows
true
DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)
- Input_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)
+ DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)
@@ -121,13 +121,13 @@
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
- $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
+ $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
Windows
true
- GameLogic_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)
- Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)
+ DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)
+ DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)
@@ -139,15 +139,15 @@
true
true
WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
- $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
+ $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
Windows
true
true
true
- GameLogic_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)
- Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)
+ DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)
+ DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)
@@ -159,36 +159,21 @@
true
true
WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
- $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
+ $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include
Windows
true
true
true
- GameLogic_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)
- Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)
+ DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)
+ DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)
-
- {104fa3e9-94d9-4e1d-a941-28a03bc8a095}
-
-
- {7e3990d2-3d94-465c-b58d-64a74b3ecf9b}
-
-
- {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}
-
-
- {0ec83e64-230e-48ef-b08c-6ac9651b4f82}
-
-
- {f10cbc03-9809-4cba-95d8-327c287b18ee}
-
{2a1bc987-af42-4500-802d-89cd32fc1309}
diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp
index 7e54fcee..636b152c 100644
--- a/Code/Game/GameLogic/Game.cpp
+++ b/Code/Game/GameLogic/Game.cpp
@@ -71,7 +71,9 @@ void Game::Update(keyInput keyPressed, float pitch, float yaw)
}
void Game::Render()
{
- Oyster::Graphics::API::NewFrame(camera->View(), camera->Proj());
+ Oyster::Graphics::API::SetView(camera->View());
+ Oyster::Graphics::API::SetProjection(camera->Proj());
+ Oyster::Graphics::API::NewFrame();
player->Render();
box->Render();
}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h
index b3ac07c3..708c01e3 100644
--- a/Code/Game/GameLogic/Game.h
+++ b/Code/Game/GameLogic/Game.h
@@ -5,6 +5,7 @@
#include "Player.h"
#include "IGame.h"
#include "Camera.h"
+#include "DynamicObject.h"
namespace GameLogic
{
diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj
index 8f77f0d6..03430feb 100644
--- a/Code/Game/GameLogic/GameLogic.vcxproj
+++ b/Code/Game/GameLogic/GameLogic.vcxproj
@@ -172,7 +172,6 @@
-
diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj
index 629ecf72..a7ebcca0 100644
--- a/Code/Game/GameProtocols/GameProtocols.vcxproj
+++ b/Code/Game/GameProtocols/GameProtocols.vcxproj
@@ -154,6 +154,7 @@
+
diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h
new file mode 100644
index 00000000..32a86259
--- /dev/null
+++ b/Code/Game/GameProtocols/ObjectProtocols.h
@@ -0,0 +1,67 @@
+#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
+#define GAMELOGIC_PLAYER_PROTOCOLS_H
+
+#include
+#include "ProtocolIdentificationID.h"
+
+
+
+namespace GameLogic
+{
+ struct Protocol_ObjectPosition :public Network::CustomProtocolObject
+ {
+ float worldMatrix[16];
+ // look at dir
+
+ Protocol_ObjectPosition()
+ {
+ this->protocol[0].value = protocol_PlayerPosition;
+ this->protocol[0].type = Network::NetAttributeType_Int;
+
+ this->protocol[1].type = Network::NetAttributeType_Float;
+ this->protocol[2].type = Network::NetAttributeType_Float;
+ this->protocol[3].type = Network::NetAttributeType_Float;
+ this->protocol[4].type = Network::NetAttributeType_Float;
+ this->protocol[5].type = Network::NetAttributeType_Float;
+ this->protocol[6].type = Network::NetAttributeType_Float;
+ this->protocol[7].type = Network::NetAttributeType_Float;
+ this->protocol[8].type = Network::NetAttributeType_Float;
+ this->protocol[9].type = Network::NetAttributeType_Float;
+ this->protocol[10].type = Network::NetAttributeType_Float;
+ this->protocol[11].type = Network::NetAttributeType_Float;
+ this->protocol[12].type = Network::NetAttributeType_Float;
+ this->protocol[13].type = Network::NetAttributeType_Float;
+ this->protocol[14].type = Network::NetAttributeType_Float;
+ this->protocol[15].type = Network::NetAttributeType_Float;
+ this->protocol[16].type = Network::NetAttributeType_Float;
+
+ }
+ Network::CustomNetProtocol* GetProtocol() override
+ {
+
+ this->protocol[1].value = worldMatrix[0];
+ this->protocol[2].value = worldMatrix[1];
+ this->protocol[3].value = worldMatrix[2];
+ this->protocol[4].value = worldMatrix[4];
+ this->protocol[5].value = worldMatrix[5];
+ this->protocol[6].value = worldMatrix[6];
+ this->protocol[7].value = worldMatrix[7];
+ this->protocol[8].value = worldMatrix[8];
+ this->protocol[9].value = worldMatrix[9];
+ this->protocol[10].value = worldMatrix[10];
+ this->protocol[11].value = worldMatrix[11];
+ this->protocol[12].value = worldMatrix[12];
+ this->protocol[13].value = worldMatrix[13];
+ this->protocol[14].value = worldMatrix[14];
+ this->protocol[15].value = worldMatrix[15];
+ this->protocol[16].value = worldMatrix[16];
+ return &protocol;
+ }
+
+ private:
+ Network::CustomNetProtocol protocol;
+ };
+
+}
+
+#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
\ No newline at end of file
diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h
index b091ba34..3375a87c 100644
--- a/Code/Game/GameProtocols/PlayerProtocols.h
+++ b/Code/Game/GameProtocols/PlayerProtocols.h
@@ -1,7 +1,7 @@
#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
#define GAMELOGIC_PLAYER_PROTOCOLS_H
-#include "CustomNetProtocol.h"
+#include
#include "ProtocolIdentificationID.h"
@@ -20,24 +20,24 @@ namespace GameLogic
Protocol_PlayerMovement()
{
- protocol[0]->value = ProtocolID = protocol_PlayerNavigation;
+ this->protocol[0].value = ProtocolID = protocol_PlayerNavigation;
- protocol[0]->type = Network::NetAttributeType_Int;
- protocol[1]->type = Network::NetAttributeType_Bool;
- protocol[2]->type = Network::NetAttributeType_Bool;
- protocol[3]->type = Network::NetAttributeType_Bool;
- protocol[4]->type = Network::NetAttributeType_Bool;
- protocol[5]->type = Network::NetAttributeType_Bool;
- protocol[6]->type = Network::NetAttributeType_Bool;
+ this->protocol[0].type = Network::NetAttributeType_Int;
+ this->protocol[1].type = Network::NetAttributeType_Bool;
+ this->protocol[2].type = Network::NetAttributeType_Bool;
+ this->protocol[3].type = Network::NetAttributeType_Bool;
+ this->protocol[4].type = Network::NetAttributeType_Bool;
+ this->protocol[5].type = Network::NetAttributeType_Bool;
+ this->protocol[6].type = Network::NetAttributeType_Bool;
}
Network::CustomNetProtocol* GetProtocol() override
{
- protocol[1]->value = bForward;
- protocol[2]->value = bBackward;
- protocol[3]->value = bTurnLeft;
- protocol[4]->value = bTurnRight;
- protocol[5]->value = bStrafeRight;
- protocol[6]->value = bStrafeRight;
+ this->protocol[1].value = bForward;
+ this->protocol[2].value = bBackward;
+ this->protocol[3].value = bTurnLeft;
+ this->protocol[4].value = bTurnRight;
+ this->protocol[5].value = bStrafeRight;
+ this->protocol[6].value = bStrafeRight;
return &protocol;
}
@@ -45,6 +45,35 @@ namespace GameLogic
private:
Network::CustomNetProtocol protocol;
};
+
+ struct Protocol_PlayerPosition :public Network::CustomProtocolObject
+ {
+ float position[3];
+ // look at dir
+
+ Protocol_PlayerPosition()
+ {
+ this->protocol[0].value = protocol_PlayerPosition;
+ this->protocol[0].type = Network::NetAttributeType_Int;
+
+ this->protocol[1].type = Network::NetAttributeType_Float;
+ this->protocol[2].type = Network::NetAttributeType_Float;
+ this->protocol[3].type = Network::NetAttributeType_Float;
+
+ }
+ Network::CustomNetProtocol* GetProtocol() override
+ {
+
+ this->protocol[1].value = position[0];
+ this->protocol[2].value = position[1];
+ this->protocol[3].value = position[2];
+ return &protocol;
+ }
+
+ private:
+ Network::CustomNetProtocol protocol;
+ };
+
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h
index 1af8c920..46a1b72f 100644
--- a/Code/Game/GameProtocols/ProtocolIdentificationID.h
+++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h
@@ -3,6 +3,8 @@
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
-#define protocol_PlayerNavigation 0;
+#define protocol_PlayerNavigation 0
+#define protocol_PlayerPosition 1
+#define protocol_ObjectPosition 2
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H
diff --git a/Code/Misc/Resource/OResourceHandler.cpp b/Code/Misc/Resource/OResourceHandler.cpp
index f86c434c..918ecd1d 100644
--- a/Code/Misc/Resource/OResourceHandler.cpp
+++ b/Code/Misc/Resource/OResourceHandler.cpp
@@ -120,11 +120,12 @@ void OysterResource::Clean()
//Remove all the references
while (!OResource::Release(i->second));
- const wchar_t* temp = i->second->GetResourceFilename();
+ std::wstring temp = i->second->GetResourceFilename();
delete resourcePrivate.resources[temp];
- resourcePrivate.resources.erase(temp);
+
}
+ resourcePrivate.resources.clear();
}
void OysterResource::ReleaseResource(const OHRESOURCE& resourceData)
{
@@ -133,7 +134,7 @@ void OysterResource::ReleaseResource(const OHRESOURCE& resourceData)
{
if(OResource::Release(t))
{
- const wchar_t* temp = t->GetResourceFilename();
+ std::wstring temp = t->GetResourceFilename();
delete resourcePrivate.resources[temp];
resourcePrivate.resources.erase(temp);
}
@@ -146,7 +147,7 @@ void OysterResource::ReleaseResource(const wchar_t filename[])
{
if(OResource::Release(t))
{
- const wchar_t* temp = t->GetResourceFilename();
+ std::wstring temp = t->GetResourceFilename();
delete resourcePrivate.resources[temp];
resourcePrivate.resources.erase(temp);
}
diff --git a/Code/Misc/ThreadSafeQueue.h b/Code/Misc/ThreadSafeQueue.h
index d0125f71..eedd9fd9 100644
--- a/Code/Misc/ThreadSafeQueue.h
+++ b/Code/Misc/ThreadSafeQueue.h
@@ -46,7 +46,7 @@ namespace Oyster
Node *front;
Node *back;
int nrOfNodes;
- OysterMutex mutex;
+ std::mutex stdMutex;
};
@@ -68,7 +68,7 @@ namespace Oyster
template < typename Type >
ThreadSafeQueue::~ThreadSafeQueue()
{
- this->mutex.LockMutex();
+ stdMutex.lock();
if(this->front != NULL)
{
@@ -87,16 +87,16 @@ namespace Oyster
this->back = NULL;
}
- this->mutex.UnlockMutex();
+ stdMutex.unlock();
}
template < typename Type >
void ThreadSafeQueue::Push(Type item)
{
+ stdMutex.lock();
Node *e = new Node(item);
- mutex.LockMutex();
if(this->front != NULL)
{
this->back->next = e;
@@ -111,91 +111,86 @@ namespace Oyster
this->nrOfNodes++;
- mutex.UnlockMutex();
+ stdMutex.unlock();
}
template < typename Type >
Type ThreadSafeQueue::Pop()
{
- mutex.LockMutex();
- if(this->front != NULL)
- {
- Type item = this->front->item;
- Node *destroyer = this->front;
- this->front = front->next;
+ stdMutex.lock();
- delete destroyer;
- this->nrOfNodes--;
+ Type item = this->front->item;
+ Node *destroyer = this->front;
+ this->front = front->next;
+
+ delete destroyer;
+ this->nrOfNodes--;
- if(nrOfNodes == 0)
- {
- this->front = NULL;
- this->back = NULL;
- }
- return item;
+ if(nrOfNodes == 0)
+ {
+ this->front = NULL;
+ this->back = NULL;
}
- mutex.UnlockMutex();
-
- return NULL;
+ stdMutex.unlock();
+ return item;
}
template < typename Type >
Type ThreadSafeQueue::Front()
{
- mutex.LockMutex();
- if(front != NULL)
- {
- return this->front->item;
- }
- mutex.UnlockMutex();
-
- return NULL;
+ stdMutex.lock();
+ Type temp = this->front->item;
+ stdMutex.unlock();
+
+ return temp;
+
}
template < typename Type >
Type ThreadSafeQueue::Back()
{
- mutex.LockMutex();
- if(back != NULL)
- {
- return this->back->item;
- }
- mutex.UnlockMutex();
+ stdMutex.lock();
+ Type temp = this->back->item;
+ stdMutex.unlock();
- return NULL;
+ return temp;
+
}
template < typename Type >
int ThreadSafeQueue::Size()
{
- //? behövs denna låsas?
- mutex.LockMutex();
- return this->nrOfNodes;
- mutex.UnlockMutex();
+ stdMutex.lock();
+ int size = this->nrOfNodes;
+ stdMutex.unlock();
+
+ return size;
+
}
template < typename Type >
bool ThreadSafeQueue::IsEmpty()
{
- mutex.LockMutex();
- if(nrOfNodes == 0 && this->front == NULL)
+ stdMutex.lock();
+ if(nrOfNodes == 0 || this->front == NULL)
{
- mutex.UnlockMutex();
+ stdMutex.unlock();
return true;
}
else
{
- mutex.UnlockMutex();
+ stdMutex.unlock();
}
+
return false;
}
template < typename Type >
void ThreadSafeQueue::Swap(IQueue &queue )
{
- mutex.LockMutex();
+ stdMutex.lock();
int prevNrOfNodes = this->nrOfNodes;
int size = queue.Size();
@@ -208,7 +203,7 @@ namespace Oyster
{
queue.Push(this->Pop());
}
- mutex.UnlockMutex();
+ stdMutex.unlock();
}
diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h
index ec8b0229..6112bea1 100644
--- a/Code/Misc/Utilities.h
+++ b/Code/Misc/Utilities.h
@@ -216,7 +216,7 @@ namespace Utility
T* operator-> ();
operator T* ();
operator bool();
-
+
/**
* Returns the connected pointer
*/
diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.cpp b/Code/Network/NetworkAPI/CustomNetProtocol.cpp
new file mode 100644
index 00000000..b636a475
--- /dev/null
+++ b/Code/Network/NetworkAPI/CustomNetProtocol.cpp
@@ -0,0 +1,58 @@
+/////////////////////////////////////////////////////////////////////
+// Created by [Dennis Andersen] [2013]
+/////////////////////////////////////////////////////////////////////
+#include "CustomNetProtocol.h"
+#include
diff --git a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters
index 74cb9a56..3189aba4 100644
--- a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters
+++ b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters
@@ -2,30 +2,33 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/Code/Network/NetworkDependencies/OysterByte.cpp b/Code/Network/NetworkDependencies/OysterByte.cpp
index ef7aa434..db343e29 100644
--- a/Code/Network/NetworkDependencies/OysterByte.cpp
+++ b/Code/Network/NetworkDependencies/OysterByte.cpp
@@ -16,18 +16,38 @@ OysterByte::OysterByte(int cap)
byteArray = new unsigned char[capacity];
}
+OysterByte::OysterByte(const OysterByte& obj)
+{
+ //delete[] this->byteArray;
+ this->byteArray = new unsigned char[obj.capacity];
+
+ for(int i = 0; i < (int)obj.size; i++)
+ {
+ this->byteArray[i] = obj.byteArray[i];
+ }
+ this->size = obj.size;
+ this->capacity = obj.capacity;
+}
+
OysterByte::~OysterByte()
{
delete[] byteArray;
}
-void OysterByte::Clear(unsigned int cap)
+void OysterByte::Clear()
{
- delete[] byteArray;
- byteArray = new unsigned char[cap];
size = 0;
}
+void OysterByte::Resize(unsigned int cap)
+{
+ if(capacity < cap)
+ {
+ delete[] byteArray;
+ byteArray = new unsigned char[cap];
+ }
+}
+
int OysterByte::GetSize()
{
return size;
@@ -60,6 +80,21 @@ void OysterByte::SetSize(unsigned int size)
this->size = size;
}
+OysterByte& OysterByte::operator =(const OysterByte& obj)
+{
+ delete[] this->byteArray;
+ this->byteArray = new unsigned char[obj.capacity];
+
+ for(int i = 0; i < (int)obj.size; i++)
+ {
+ this->byteArray[i] = obj.byteArray[i];
+ }
+ this->size = obj.size;
+ this->capacity = obj.capacity;
+
+ return *this;
+}
+
OysterByte::operator char*()
{
return (char*)byteArray;
diff --git a/Code/Network/NetworkDependencies/OysterByte.h b/Code/Network/NetworkDependencies/OysterByte.h
index 87a0103c..99629bfc 100644
--- a/Code/Network/NetworkDependencies/OysterByte.h
+++ b/Code/Network/NetworkDependencies/OysterByte.h
@@ -16,9 +16,11 @@ namespace Oyster
public:
OysterByte();
OysterByte(int cap);
+ OysterByte(const OysterByte& obj);
virtual ~OysterByte();
- void Clear(unsigned int cap);
+ void Clear(); //Resets size to 0
+ void Resize(unsigned int cap); //Resizes the array with, it does not keep anything in it.
int GetSize();
unsigned char* GetByteArray();
@@ -27,6 +29,8 @@ namespace Oyster
void SetBytes(unsigned char* bytes);
void SetSize(unsigned int size); //Only sets the private variable 'size'
+ OysterByte& operator =(const OysterByte& obj);
+
operator char*();
operator const char*();
operator unsigned char*();
diff --git a/Code/Network/NetworkDependencies/Packing.cpp b/Code/Network/NetworkDependencies/Packing.cpp
index 7adc395c..405cd5e6 100644
--- a/Code/Network/NetworkDependencies/Packing.cpp
+++ b/Code/Network/NetworkDependencies/Packing.cpp
@@ -87,7 +87,7 @@ namespace Oyster
//floating point (32, 64-bit)
void Pack(unsigned char buffer[], float i)
{
- int tempFloat = Pack754(i, 32, 8);
+ int tempFloat = (int)Pack754(i, 32, 8);
Pack(buffer, tempFloat);
}
@@ -100,7 +100,7 @@ namespace Oyster
//string
void Pack(unsigned char buffer[], char str[])
{
- short len = strlen(str);
+ short len = (short)strlen(str);
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str, len);
@@ -108,7 +108,7 @@ namespace Oyster
void Pack(unsigned char buffer[], std::string& str)
{
- short len = str.length();
+ short len = (short)str.length();
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str.c_str(), len);
@@ -153,7 +153,7 @@ namespace Oyster
fnorm = fnorm - 1.0;
// calculate the binary form (non-float) of the significand data
- significand = fnorm * ((1LL << significandbits) + 0.5f);
+ significand = (long long)(fnorm * ((1LL << significandbits) + 0.5f));
// get the biased exponent
exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias
@@ -169,7 +169,7 @@ namespace Oyster
//bool (1-bit)
bool Unpackb(unsigned char buffer[])
{
- return (bool)buffer;
+ return buffer;
}
//char (8-bit)
@@ -305,7 +305,7 @@ namespace Oyster
return 0.0;
// pull the significand
- result = (i&((1LL << significandbits) - 1)); // mask
+ result = (long double)(i&((1LL << significandbits) - 1)); // mask
result /= (1LL << significandbits); // convert back to float
result += 1.0f; // add the one back on
diff --git a/Code/Network/NetworkDependencies/PostBox.h b/Code/Network/NetworkDependencies/PostBox.h
index b2e553f8..f6db2c44 100644
--- a/Code/Network/NetworkDependencies/PostBox.h
+++ b/Code/Network/NetworkDependencies/PostBox.h
@@ -23,7 +23,7 @@ namespace Oyster
virtual ~PostBox();
virtual void PostMessage(T& message);
- virtual void FetchMessage(T& message);
+ virtual bool FetchMessage(T& message);
virtual bool IsFull();
private:
@@ -49,13 +49,14 @@ namespace Oyster
}
template
- void PostBox::FetchMessage(T& message)
+ bool PostBox::FetchMessage(T& message)
{
if(IsFull())
{
- message = messages.Front();
- messages.Pop();
+ message = messages.Pop();
+ return true;
}
+ return false;
}
template
diff --git a/Code/Network/NetworkDependencies/Protocols.h b/Code/Network/NetworkDependencies/Protocols.h
index 8defcfb3..adf7154e 100644
--- a/Code/Network/NetworkDependencies/Protocols.h
+++ b/Code/Network/NetworkDependencies/Protocols.h
@@ -22,7 +22,7 @@ namespace Oyster
PackageType_header,
PackageType_test,
PackageType_input,
- PackageType_update_position
+ PackageType_player_pos,
};
struct ProtocolHeader
@@ -45,6 +45,16 @@ namespace Oyster
virtual ~ProtocolTest() { delete[] f; }
};
+ struct ProtocolPlayerPos : public ProtocolHeader
+ {
+ int ID;
+ unsigned int nrOfFloats;
+ float *matrix;
+
+ ProtocolPlayerPos() { this->packageType = PackageType_player_pos; }
+ virtual ~ProtocolPlayerPos() { delete[] matrix; }
+ };
+
//Holding every protocol in an union.
//Used because we now don't have to type case our protocol when we recieve them.
@@ -56,6 +66,7 @@ namespace Oyster
{
ProtocolHeader* pHeader;
ProtocolTest *pTest;
+ ProtocolPlayerPos *pPlayerPos;
}Protocol;
@@ -75,6 +86,12 @@ namespace Oyster
delete Protocol.pTest;
}
break;
+ case PackageType_player_pos:
+ if(Protocol.pPlayerPos)
+ {
+ delete Protocol.pPlayerPos;
+ }
+ break;
}
}
};
diff --git a/Code/Network/NetworkDependencies/ThreadedClient.cpp b/Code/Network/NetworkDependencies/ThreadedClient.cpp
new file mode 100644
index 00000000..a49caabd
--- /dev/null
+++ b/Code/Network/NetworkDependencies/ThreadedClient.cpp
@@ -0,0 +1,143 @@
+#include "ThreadedClient.h"
+#include "OysterByte.h"
+
+#include
+using namespace Oyster::Network;
+using namespace Oyster::Thread;
+using namespace Utility::DynamicMemory;
+
+ThreadedClient::ThreadedClient()
+{
+ this->connection = new Connection();
+ this->sendPostBox = new PostBox>();
+ this->recvPostBox = NULL;
+
+ connection->SetBlockingMode(false);
+}
+
+ThreadedClient::ThreadedClient(unsigned int socket)
+{
+ this->connection = new Connection(socket);
+ this->sendPostBox = new PostBox>();
+ this->recvPostBox = NULL;
+
+ connection->SetBlockingMode(false);
+
+ thread.Create(this, true);
+}
+
+ThreadedClient::ThreadedClient(IPostBox>* postBox, unsigned int socket)
+{
+ this->connection = new Connection(socket);
+ this->sendPostBox = new PostBox>;
+ this->recvPostBox = postBox;
+
+ connection->SetBlockingMode(false);
+
+ thread.Create(this, true);
+}
+
+ThreadedClient::~ThreadedClient()
+{
+ thread.Terminate();
+ delete this->connection;
+ this->connection = NULL;
+ this->recvPostBox = NULL;
+
+ if(sendPostBox != NULL)
+ {
+ delete sendPostBox;
+ this->sendPostBox = NULL;
+ }
+}
+
+void ThreadedClient::Send(SmartPointer& byte)
+{
+ this->sendPostBox->PostMessage(byte);
+}
+
+int ThreadedClient::Send()
+{
+ int errorCode = 0;
+
+ if(sendPostBox->IsFull())
+ {
+ SmartPointer temp = new OysterByte;
+ sendPostBox->FetchMessage(temp);
+ errorCode = this->connection->Send(temp);
+ }
+
+ return errorCode;
+}
+
+int ThreadedClient::Recv()
+{
+ int errorCode = -1;
+
+ SmartPointer temp = new OysterByte;
+ errorCode = this->connection->Recieve(temp);
+
+ if(errorCode == 0)
+ {
+ stdMutex.lock();
+ recvPostBox->PostMessage(temp);
+ stdMutex.unlock();
+ }
+
+ return errorCode;
+}
+
+void ThreadedClient::ThreadEntry()
+{
+ std::cout<< "Client Thread started" << std::endl;
+}
+
+void ThreadedClient::ThreadExit()
+{
+ std::cout << "Client Thread exit" << std::endl;
+}
+
+#include
+
+bool ThreadedClient::DoWork()
+{
+ int errorCode;
+ errorCode = Send();
+ /*if(errorCode != 0)
+ {
+ return false;
+ }*/
+
+ errorCode = Recv();
+ /*if(errorCode != 0)
+ {
+ return false;
+ }*/
+ Sleep(1);
+ return true;
+}
+
+int ThreadedClient::Connect(unsigned short port, const char serverName[])
+{
+ int errorCode;
+
+ if((errorCode = connection->InitiateClient()) != 0)
+ {
+ return errorCode;
+ }
+
+ else if((errorCode = connection->Connect(port, serverName)) != 0)
+ {
+ return errorCode;
+ }
+
+ thread.Create(this, true);
+ return 0;
+}
+
+void ThreadedClient::setRecvPostBox(IPostBox> *postBox)
+{
+ stdMutex.lock();
+ this->recvPostBox = postBox;
+ stdMutex.unlock();
+}
\ No newline at end of file
diff --git a/Code/Network/NetworkDependencies/ThreadedClient.h b/Code/Network/NetworkDependencies/ThreadedClient.h
new file mode 100644
index 00000000..ae026a61
--- /dev/null
+++ b/Code/Network/NetworkDependencies/ThreadedClient.h
@@ -0,0 +1,55 @@
+#ifndef NETWORK_DEPENDENCIES_THREADED_CLIENT_H
+#define NETWORK_DEPENDENCIES_THREADED_CLIENT_H
+
+//////////////////////////////////
+// Created by Sam Svensson 2013 //
+//////////////////////////////////
+
+#include "../../Misc/Thread/IThreadObject.h"
+#include "PostBox.h"
+#include "Connection.h"
+#include "../../Misc/Thread/OysterThread.h"
+#include "../../Misc/Thread/OysterMutex.h"
+#include "../../Misc/Utilities.h"
+
+#include
+
+namespace Oyster
+{
+ namespace Network
+ {
+ class OysterByte;
+ class ThreadedClient : public Thread::IThreadObject
+ {
+ public:
+ ThreadedClient();
+ ThreadedClient(unsigned int socket);
+ ThreadedClient(IPostBox> *postBox, unsigned int socket);
+ virtual ~ThreadedClient();
+
+ void Send(Utility::DynamicMemory::SmartPointer& byte);
+
+ int Connect(unsigned short port, const char serverName[]);
+
+ void setRecvPostBox(IPostBox> *postBox);
+
+ private:
+ virtual int Send();
+ virtual int Recv();
+
+ virtual void ThreadEntry();
+ virtual void ThreadExit();
+ virtual bool DoWork();
+
+ private:
+ Connection* connection;
+ IPostBox> *sendPostBox;
+ IPostBox> *recvPostBox;
+ Oyster::Thread::OysterThread thread;
+ std::mutex stdMutex;
+
+ };
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Code/Network/NetworkDependencies/Translator.cpp b/Code/Network/NetworkDependencies/Translator.cpp
index 4bb739ca..94f66d62 100644
--- a/Code/Network/NetworkDependencies/Translator.cpp
+++ b/Code/Network/NetworkDependencies/Translator.cpp
@@ -4,7 +4,7 @@ using namespace Oyster::Network;
using namespace ::Protocols;
using namespace ::Messages;
-void Translator::Pack( ProtocolHeader &header, OysterByte& bytes )
+void Translator::Pack( ProtocolHeader &header, Utility::DynamicMemory::SmartPointer &bytes )
{
MessageHeader *message = NULL;
@@ -17,23 +17,27 @@ void Translator::Pack( ProtocolHeader &header, OysterByte& bytes )
case PackageType_test:
message = new MessageTest();
break;
+
+ case PackageType_player_pos:
+ message = new MessagePlayerPos();
+ break;
}
if(message != NULL)
{
- message->Pack(header, bytes);
+ message->Pack(header, *bytes);
delete message;
message = NULL;
}
}
-void Translator::Unpack(ProtocolSet* set, OysterByte& bytes )
+void Translator::Unpack(ProtocolSet* set, Utility::DynamicMemory::SmartPointer &bytes)
{
ProtocolHeader *header = new ProtocolHeader();
MessageHeader *message = new MessageHeader();
- message->Unpack(bytes, *header);
+ message->Unpack(*bytes, *header);
delete message;
message = NULL;
@@ -44,13 +48,19 @@ void Translator::Unpack(ProtocolSet* set, OysterByte& bytes )
case PackageType_header:
message = new MessageHeader();
set->Protocol.pHeader = new ProtocolHeader;
- message->Unpack(bytes, *set->Protocol.pHeader);
+ message->Unpack(*bytes, *set->Protocol.pHeader);
break;
case PackageType_test:
message = new MessageTest();
set->Protocol.pTest = new ProtocolTest;
- message->Unpack(bytes, *set->Protocol.pTest);
+ message->Unpack(*bytes, *set->Protocol.pTest);
+ break;
+
+ case PackageType_player_pos:
+ message = new MessagePlayerPos();
+ set->Protocol.pPlayerPos = new ProtocolPlayerPos;
+ message->Unpack(*bytes, *set->Protocol.pPlayerPos);
break;
}
diff --git a/Code/Network/NetworkDependencies/Translator.h b/Code/Network/NetworkDependencies/Translator.h
index 56459f72..94c88457 100644
--- a/Code/Network/NetworkDependencies/Translator.h
+++ b/Code/Network/NetworkDependencies/Translator.h
@@ -20,8 +20,8 @@ namespace Oyster
Translator () { };
~Translator() { };
- void Pack (Protocols::ProtocolHeader &header, OysterByte& bytes );
- void Unpack (Protocols::ProtocolSet* set, OysterByte& bytes );
+ void Pack (Protocols::ProtocolHeader &header, Utility::DynamicMemory::SmartPointer &bytes );
+ void Unpack (Protocols::ProtocolSet* set, Utility::DynamicMemory::SmartPointer &bytes );
private:
diff --git a/Code/Network/NetworkDependencies/WinsockFunctions.cpp b/Code/Network/NetworkDependencies/WinsockFunctions.cpp
index ea3c3b00..772fc6ec 100644
--- a/Code/Network/NetworkDependencies/WinsockFunctions.cpp
+++ b/Code/Network/NetworkDependencies/WinsockFunctions.cpp
@@ -17,14 +17,14 @@ std::wstring GetErrorMessage(int errorCode)
LPWSTR lpMessage;
std::wstring retVal(L"Succesful");
- DWORD bufLen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS ,
+ DWORD bufLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS ,
NULL,
errorCode ,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) ,
(LPWSTR)&lpMessage,
0 ,
NULL );
-
+
if(bufLen)
{
retVal = lpMessage;
diff --git a/Code/Network/NetworkDependencies/main.cpp b/Code/Network/NetworkDependencies/main.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/Code/Network/OysterNetworkClient/Client.cpp b/Code/Network/OysterNetworkClient/Client.cpp
deleted file mode 100644
index daffe9b6..00000000
--- a/Code/Network/OysterNetworkClient/Client.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "Client.h"
-
-using namespace Oyster::Network::Client;
-
-Client::Client()
-{
- connection = new Connection();
-}
-
-Client::~Client()
-{
- delete this->connection;
- connection = 0;
-}
-
-int Client::Connect(unsigned int port, char filename[])
-{
- int errorCode;
-
- if((errorCode = connection->InitiateClient()) != 0)
- {
- return errorCode;
- }
-
- if((errorCode = connection->Connect(port, filename)) != 0)
- {
- return errorCode;
- }
-
- return 0;
-}
-
-void Client::Send(Oyster::Network::OysterByte& bytes)
-{
- connection->Send(bytes);
-}
-
-void Client::Recv(Oyster::Network::OysterByte& bytes)
-{
- connection->Recieve(bytes);
-}
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkClient/Client.h b/Code/Network/OysterNetworkClient/Client.h
deleted file mode 100644
index 6e69e657..00000000
--- a/Code/Network/OysterNetworkClient/Client.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef NETWORK_CLIENT_CLIENT_H
-#define NETWORK_CLIENT_CLIENT_H
-
-/////////////////////////////////////
-// Created by Pontus Fransson 2013 //
-/////////////////////////////////////
-
-#include "../NetworkDependencies/Connection.h"
-#include "../NetworkDependencies/OysterByte.h"
-
-namespace Oyster
-{
- namespace Network
- {
- namespace Client
- {
- class Client
- {
- public:
- Client();
- ~Client();
-
- int Connect(unsigned int port, char filename[]);
-
- void Send(OysterByte& bytes);
- void Recv(OysterByte& bytes);
-
- private:
- ::Oyster::Network::Connection* connection;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp
index b8f1057f..72c011a2 100644
--- a/Code/Network/OysterNetworkClient/ClientMain.cpp
+++ b/Code/Network/OysterNetworkClient/ClientMain.cpp
@@ -6,15 +6,20 @@
#include "..\NetworkDependencies\Protocols.h"
#include "../NetworkDependencies/OysterByte.h"
#include "../../Misc/ThreadSafeQueue.h"
-#include "Client.h"
+#include "../NetworkDependencies/ThreadedClient.h"
+#include "../../Misc/WinTimer.h"
+#include "../../Misc/Utilities.h"
#pragma comment(lib, "ws2_32.lib")
using namespace std;
using namespace Oyster::Network::Protocols;
-using namespace Oyster::Network::Client;
+using namespace Oyster::Network;
+using namespace Utility;
+using namespace Utility::DynamicMemory;
-void chat(Client &client);
+void chat(ThreadedClient &client);
+void PrintOutMessage(ProtocolSet* set);
int main()
{
@@ -27,10 +32,10 @@ int main()
cout << "Client" << endl;
//Create Client
- Client client;
+ ThreadedClient* client = new ThreadedClient;
//Connect to server
- errorCode = client.Connect(9876, "localhost");
+ errorCode = client->Connect(9876, "localhost");
if(errorCode != 0)
{
@@ -38,7 +43,8 @@ int main()
wcout << "errorMessage: " << errorTest << endl;
}
- chat(client);
+ chat(*client);
+ delete client;
ShutdownWinSock();
@@ -46,76 +52,79 @@ int main()
return 0;
}
-void chat(Client &client)
+void chat(ThreadedClient &client)
{
Oyster::Network::Translator *t = new Oyster::Network::Translator();
+ IPostBox< SmartPointer> *postBox = new PostBox< SmartPointer>;
- Oyster::Network::OysterByte msgRecv;
- string msgSend = "";
+ client.setRecvPostBox(postBox);
+
+ SmartPointer msgRecv = new OysterByte();
+ SmartPointer msgSend = new OysterByte();
ProtocolSet* set = new ProtocolSet;
- ProtocolTest test;
- test.numOfFloats = 5;
- test.f = new float[test.numOfFloats];
- float temp = 12345.5654f;
- for(int i = 0; i < 5; i++)
+ ProtocolPlayerPos test;
+ test.ID = 5;
+ test.nrOfFloats = 5;
+ test.matrix = new float[test.nrOfFloats];
+ float temp = 10;
+ for(int i = 0; i < (int)test.nrOfFloats; i++)
{
- test.f[i] = temp;
+ test.matrix[i] = temp;
temp++;
}
+ t->Pack(test, msgSend);
- bool chatDone = false;
+ WinTimer timer;
- while(!chatDone)
+ while(1)
{
- client.Recv(msgRecv);
-
- t->Unpack(set, msgRecv);
-
- switch(set->type)
+ //Fetch new messages from the postbox
+ if(postBox->FetchMessage(msgRecv))
{
- case PackageType_header:
- break;
- case PackageType_test:
- cout <<"Client 2: " << set->Protocol.pTest->textMessage <Protocol.pTest->numOfFloats; i++)
- {
- cout << set->Protocol.pTest->f[i] << ' ' ;
- }
- cout << endl;
- break;
- }
-
- set->Release();
- msgRecv.Clear(1000);
+ t->Unpack(set, msgRecv);
- /*std::getline(std::cin, msgSend);
-
-
-
- if( msgSend != "exit")
- {
- if(msgSend.length() < 1)
- {
- msgSend = "ERROR!";
- }
-
- test.textMessage = msgSend;
-
- t->Pack(test, msgRecv);
-
- client.Send(msgRecv);
+ //PrintOutMessage(set);
+ set->Release();
}
- else
+ //Send message to server each second
+ if(timer.getElapsedSeconds() > 1)
{
- chatDone = true;
+ cout << "Sending to server." << endl;
+ timer.reset();
+ client.Send(msgSend);
}
-
- cin.clear();*/
-
+ Sleep(1);
}
+ delete postBox;
delete t;
delete set;
+}
+
+void PrintOutMessage(ProtocolSet* set)
+{
+ switch(set->type)
+ {
+ case PackageType_header:
+ break;
+ case PackageType_test:
+ cout <<"Client 2: " << set->Protocol.pTest->textMessage <Protocol.pTest->numOfFloats; i++)
+ {
+ cout << set->Protocol.pTest->f[i] << ' ' ;
+ }
+ cout << endl;
+ break;
+
+ case PackageType_player_pos:
+ cout << "ID " << set->Protocol.pPlayerPos->ID << endl;
+ for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++)
+ {
+ cout << set->Protocol.pPlayerPos->matrix[i] << ' ';
+ }
+ cout << endl;
+ break;
+ }
}
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj
index f4e13099..bb63d4cf 100644
--- a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj
+++ b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj
@@ -154,12 +154,8 @@
-
-
-
-
diff --git a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj.filters b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj.filters
index 2e5e9ef6..cd4a498b 100644
--- a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj.filters
+++ b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj.filters
@@ -18,13 +18,5 @@
Source Files
-
- Source Files
-
-
-
-
- Header Files
-
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/Client.cpp b/Code/Network/OysterNetworkServer/Client.cpp
deleted file mode 100644
index 5cc15eec..00000000
--- a/Code/Network/OysterNetworkServer/Client.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "Client.h"
-
-using namespace Oyster::Network;
-using namespace Oyster::Network::Server;
-
-Client::Client(unsigned int socket)
-{
- connection = new Connection(socket);
-}
-
-Client::~Client()
-{
- delete connection;
-}
-
-void Client::Send(OysterByte& bytes)
-{
- connection->Send(bytes);
-}
-
-void Client::Recv(OysterByte& bytes)
-{
- connection->Recieve(bytes);
-}
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/Client.h b/Code/Network/OysterNetworkServer/Client.h
deleted file mode 100644
index 2c5ba35f..00000000
--- a/Code/Network/OysterNetworkServer/Client.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef NETWORK_SERVER_CLIENT_H
-#define NETWORK_SERVER_CLIENT_H
-
-/////////////////////////////////////
-// Created by Pontus Fransson 2013 //
-/////////////////////////////////////
-
-#include "../NetworkDependencies/Connection.h"
-#include "../NetworkDependencies/OysterByte.h"
-
-namespace Oyster
-{
- namespace Network
- {
- namespace Server
- {
- class Client
- {
- public:
- Client(unsigned int socket);
- ~Client();
-
- void Send(OysterByte& bytes);
- void Recv(OysterByte& bytes);
-
- private:
- ::Oyster::Network::Connection* connection;
-
- };
- }
- }
-};
-
-#endif
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj
index 65136729..4452ee37 100644
--- a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj
+++ b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj
@@ -149,16 +149,20 @@
{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}
+
+ {460d625f-2ac9-4559-b809-0ba89ceaedf4}
+
{c5aa09d0-6594-4cd3-bd92-1d380c7b3b50}
-
+
-
+
+
diff --git a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj.filters b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj.filters
index 3cb5827c..6073a0c5 100644
--- a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj.filters
+++ b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj.filters
@@ -18,12 +18,15 @@
Source Files
-
+
Source Files
-
+
+ Header Files
+
+
Header Files
diff --git a/Code/Network/OysterNetworkServer/RecieverObject.h b/Code/Network/OysterNetworkServer/RecieverObject.h
new file mode 100644
index 00000000..681c7204
--- /dev/null
+++ b/Code/Network/OysterNetworkServer/RecieverObject.h
@@ -0,0 +1,19 @@
+#ifndef OYSTER_NETWORK_SERVER_RECIEVER_OBJECT_H
+#define OYSTER_NETWORK_SERVER_RECIEVER_OBJECT_H
+
+/////////////////////////////////////
+// Created by Pontus Fransson 2013 //
+/////////////////////////////////////
+
+#include "../NetworkDependencies/Protocols.h"
+#include "../NetworkDependencies/OysterByte.h"
+#include "../../Misc/Utilities.h"
+
+class RecieverObject
+{
+public:
+ virtual void ProcFunc(Utility::DynamicMemory::SmartPointer msg) = 0;
+
+};
+
+#endif
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/ServerMain.cpp b/Code/Network/OysterNetworkServer/ServerMain.cpp
index 9dd0a0c1..f97aeb98 100644
--- a/Code/Network/OysterNetworkServer/ServerMain.cpp
+++ b/Code/Network/OysterNetworkServer/ServerMain.cpp
@@ -3,126 +3,53 @@
#include
#include
#include "../NetworkDependencies/WinsockFunctions.h"
-#include "../NetworkDependencies/Listener.h"
-#include "../NetworkDependencies/Translator.h"
-#include "Client.h"
-#include "../NetworkDependencies/OysterByte.h"
-#include "../NetworkDependencies/PostBox.h"
-#include "../../Misc/WinTimer.h"
-
-#pragma comment(lib, "ws2_32.lib")
+#include "TestClass.h"
using namespace std;
-using namespace Oyster::Network::Server;
-using namespace Oyster::Network;
-using namespace ::Protocols;
-using namespace Utility;
+
+void clientProc(Oyster::Network::NetworkClient* client);
int main()
{
- OysterByte recvBuffer;
- IPostBox* postBox = new PostBox();
-
- cout << "Server" << endl;
- Translator t;
- int errorCode;
-
if(!InitWinSock())
{
cout << "errorMessage: unable to start winsock" << endl;
}
- //Create socket
- Listener listener;
- listener.Init(9876);
- listener.SetPostBox(postBox);
- Sleep(1000);
+ Test test;
- //Start listening
- //Accept a client
- ProtocolTest test;
- test.clientID = 0;
- test.size = 2;
- test.textMessage = "hej";
- test.numOfFloats = 0;
- test.f = new float[test.numOfFloats];
- float temp = 395.456f;
- for(int i = 0; i < (int)test.numOfFloats; i++)
- {
- test.f[i] = temp;
- temp--;
- }
+ cout << "Server" << endl;
- t.Pack(test, recvBuffer);
-
- WinTimer timer;
+ test.mainLoop();
- vector clients;
- int client = -1;
while(1)
{
- client = -1;
- postBox->FetchMessage(client);
- if(client != -1)
- {
- cout << "Client connected: " << client << endl;
- clients.push_back(new Client(client));
-
- clients.at(clients.size()-1)->Send(recvBuffer);
- }
-
- //Send a message every 1 secounds to all clients.
+ //Fetch new clients from the postbox
+ /*
+ //Send a message every 1 seconds to all clients.
if(timer.getElapsedSeconds() > 1)
{
cout << "Sending to " << clients.size() << " clients." << endl;
timer.reset();
for(int i = 0; i < (int)clients.size(); i++)
{
- clients.at(i)->Send(recvBuffer);
+ clients.at(i)->Send(sendBuffer);
}
- }
- Sleep(100);
- }
- listener.Shutdown();
+ }*/
- /*
- ProtocolSet* set = new ProtocolSet;
-
- client1.Send(recvBuffer);
-
- while(1)
- {
- client1.Recv(recvBuffer);
-
- t.Unpack(set, recvBuffer);
- cout << set->Protocol.pTest->clientID << ' ' << set->Protocol.pTest->packageType << ' ' << set->Protocol.pTest->size << endl;
- cout << "Client1: " << set->Protocol.pTest->textMessage << endl;
- for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++)
+ /*//Fetch messages
+ if(recvPostBox->FetchMessage(recvBuffer))
{
- cout << set->Protocol.pTest->f[i] << ' ';
- }
- cout << endl;
- set->Release();
- client2.Send(recvBuffer);
+ t.Unpack(set, recvBuffer);
- client2.Recv(recvBuffer);
-
- t.Unpack(set, recvBuffer);
- cout << set->Protocol.pTest->clientID << ' ' << set->Protocol.pTest->packageType << ' ' << set->Protocol.pTest->size << endl;
- cout << "Client2: " << set->Protocol.pTest->textMessage << endl;
- for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++)
- {
- cout << set->Protocol.pTest->f[i] << ' ';
- }
- cout << endl;
- set->Release();
- client1.Send(recvBuffer);
+ //PrintOutMessage(set);
+ set->Release();
+ }*/
}
+ Sleep(1000);
- ShutdownWinSock();
- delete set;
- */
system("pause");
+
return 0;
-}
+}
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/TestClass.cpp b/Code/Network/OysterNetworkServer/TestClass.cpp
new file mode 100644
index 00000000..1580b644
--- /dev/null
+++ b/Code/Network/OysterNetworkServer/TestClass.cpp
@@ -0,0 +1,86 @@
+#include "TestClass.h"
+#include "../../Misc/WinTimer.h"
+#include
+
+using namespace Oyster::Network;
+using namespace ::Server;
+using namespace ::Protocols;
+using namespace Utility;
+using namespace ::DynamicMemory;
+using namespace std;
+
+Test::Test()
+{
+ recvPostBox = new PostBox>;
+
+ sendBuffer = new OysterByte;
+ recvBuffer = new OysterByte;
+
+ NetworkServer::INIT_DESC initDesc;
+ initDesc.port = 9876;
+ initDesc.proc = NULL;
+ server.Init(initDesc);
+ server.Start();
+
+ test.clientID = 0;
+ test.ID = 5;
+ test.nrOfFloats = 10;
+ test.matrix = new float[test.nrOfFloats];
+
+ for(int i = 0; i < (int)test.nrOfFloats; i++)
+ {
+ test.matrix[i] = (float)i;
+ }
+
+ t.Pack(test, sendBuffer);
+}
+
+Test::~Test()
+{
+ for(int i = 0; i < (int)clients.size(); i++)
+ delete clients.at(i);
+
+ server.Stop();
+}
+
+void Test::ProcFunc(Utility::DynamicMemory::SmartPointer msg)
+{
+
+ return;
+}
+
+void Test::mainLoop()
+{
+ WinTimer timer;
+
+ while(1)
+ {
+
+ }
+}
+
+void Test::PrintOutMessage(ProtocolSet* set)
+{
+ switch(set->type)
+ {
+ case PackageType_header:
+ break;
+ case PackageType_test:
+ cout <<"Client 2: " << set->Protocol.pTest->textMessage <Protocol.pTest->numOfFloats; i++)
+ {
+ cout << set->Protocol.pTest->f[i] << ' ' ;
+ }
+ cout << endl;
+ break;
+
+ case PackageType_player_pos:
+ //cout << "ID " << set->Protocol.pPlayerPos->ID << endl;
+ for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++)
+ {
+ cout << set->Protocol.pPlayerPos->matrix[i] << ' ';
+ }
+ cout << endl;
+ break;
+ }
+}
\ No newline at end of file
diff --git a/Code/Network/OysterNetworkServer/TestClass.h b/Code/Network/OysterNetworkServer/TestClass.h
new file mode 100644
index 00000000..439e5b1f
--- /dev/null
+++ b/Code/Network/OysterNetworkServer/TestClass.h
@@ -0,0 +1,37 @@
+#ifndef TEST_CLASS_H
+#define TEST_CLASS_H
+
+#include "RecieverObject.h"
+#include "../../Misc/Utilities.h"
+#include "../NetworkDependencies/OysterByte.h"
+#include "../NetworkDependencies/PostBox.h"
+#include "../NetworkAPI/NetworkClient.h"
+#include "../NetworkAPI/NetworkServer.h"
+#include "../NetworkDependencies/Translator.h"
+#include
+
+class Test : public RecieverObject
+{
+public:
+ Test();
+ ~Test();
+
+ void mainLoop();
+
+ virtual void ProcFunc(Utility::DynamicMemory::SmartPointer msg);
+ void PrintOutMessage(Oyster::Network::Protocols::ProtocolSet* set);
+
+private:
+ std::vector clients;
+ Oyster::Network::IPostBox> *recvPostBox;
+
+ Oyster::Network::Translator t;
+ Oyster::Network::Protocols::ProtocolPlayerPos test;
+ Utility::DynamicMemory::SmartPointer sendBuffer;
+ Utility::DynamicMemory::SmartPointer recvBuffer;
+
+ Oyster::Network::Server::NetworkServer server;
+
+};
+
+#endif
\ No newline at end of file
diff --git a/Code/OysterGraphics/Core/Init.cpp b/Code/OysterGraphics/Core/Init.cpp
index c69b80b4..548615d2 100644
--- a/Code/OysterGraphics/Core/Init.cpp
+++ b/Code/OysterGraphics/Core/Init.cpp
@@ -32,7 +32,8 @@ namespace Oyster
log << "DirectX running in debug mode.\n";
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
-
+
+ createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
D3D_FEATURE_LEVEL featureLevelsToTry[] =
{
diff --git a/Code/OysterGraphics/Core/ShaderManager.cpp b/Code/OysterGraphics/Core/ShaderManager.cpp
index 94f7fd57..c4f1b38e 100644
--- a/Code/OysterGraphics/Core/ShaderManager.cpp
+++ b/Code/OysterGraphics/Core/ShaderManager.cpp
@@ -279,7 +279,7 @@ namespace Oyster
void Core::ShaderManager::Clean()
{
- for(int i = 0; i < VData.size(); ++i)
+ for(int i = 0; i < (int)VData.size(); ++i)
{
delete[] VData[i].data;
}
diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp
index b5de4fda..fcb3481c 100644
--- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp
+++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp
@@ -4,11 +4,18 @@
#include "../Render/Rendering/Render.h"
#include "../FileLoader/ObjReader.h"
#include "../../Misc/Resource/OysterResource.h"
+#include "../FileLoader/GeneralLoader.h"
namespace Oyster
{
namespace Graphics
{
+ namespace
+ {
+ Math::Float4x4 View;
+ Math::Float4x4 Projection;
+ }
+
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
{
Core::resolution = resulotion;
@@ -26,16 +33,31 @@ namespace Oyster
return API::Sucsess;
}
- void API::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
+ void API::SetProjection(Math::Float4x4& projection)
+ {
+ Projection = projection;
+ }
+
+ void API::SetView(Math::Float4x4& view)
+ {
+ View = view;
+ }
+
+ void API::NewFrame()
{
Render::Rendering::Basic::NewFrame(View, Projection);
}
- void API::RenderScene(Model::Model* models, int count)
+ void API::RenderScene(Model::Model models[], int count)
{
Render::Rendering::Basic::RenderScene(models,count);
}
+ void API::RenderModel(Model::Model& m)
+ {
+ Render::Rendering::Basic::RenderScene(&m,1);
+ }
+
void API::EndFrame()
{
Render::Rendering::Basic::EndFrame();
@@ -52,9 +74,7 @@ namespace Oyster
m->WorldMatrix = Oyster::Math::Float4x4::identity;
m->Visible = true;
- OBJReader or;
- or.readOBJFile(filename);
- m->info = or.toModel();
+ m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadOBJ);
return m;
}
@@ -63,7 +83,7 @@ namespace Oyster
{
Model::ModelInfo* info = (Model::ModelInfo*)model->info;
delete model;
- info->Vertices->~Buffer();
+ Oyster::Resource::OysterResource::ReleaseResource((Oyster::Resource::OHRESOURCE)info);
}
void API::Clean()
@@ -72,6 +92,14 @@ namespace Oyster
Oyster::Resource::OysterResource::Clean();
Oyster::Graphics::Core::ShaderManager::Clean();
Oyster::Graphics::Render::Resources::Clean();
+
+ SAFE_RELEASE(Core::depthStencil);
+ SAFE_RELEASE(Core::backBufferRTV);
+ SAFE_RELEASE(Core::backBufferUAV);
+
+ SAFE_RELEASE(Core::swapChain);
+ SAFE_RELEASE(Core::deviceContext);
+ SAFE_RELEASE(Core::device);
}
}
}
\ No newline at end of file
diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h
index bd07c391..f4c38076 100644
--- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h
+++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h
@@ -4,10 +4,10 @@
#include "OysterMath.h"
#include
-#if defined GFX_DLL_EXPORT
+#ifdef GFX_DLL_EXPORT
#define GFX_DLL_USAGE __declspec(dllexport)
#else
- #define GFX_DLL_USAGE __declspec(dllimport)
+ #define GFX_DLL_USAGE
#endif
namespace Oyster
@@ -28,9 +28,14 @@ namespace Oyster
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
static void Clean();
- //! @brief from Oyster::Math Float4x4, expects corect methods
- static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
- static void RenderScene(Oyster::Graphics::Model::Model* models, int count);
+
+ static void SetView(Oyster::Math::Float4x4& View);
+ static void SetProjection(Oyster::Math::Float4x4& Projection);
+
+ //! @brief will internally use last values from SetView and SetProjection
+ static void NewFrame();
+ static void RenderScene(Oyster::Graphics::Model::Model models[], int count);
+ static void RenderModel(Oyster::Graphics::Model::Model& model);
static void EndFrame();
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
diff --git a/Code/OysterGraphics/FileLoader/GeneralLoader.h b/Code/OysterGraphics/FileLoader/GeneralLoader.h
index fcce1e02..4eab570b 100644
--- a/Code/OysterGraphics/FileLoader/GeneralLoader.h
+++ b/Code/OysterGraphics/FileLoader/GeneralLoader.h
@@ -27,7 +27,8 @@ namespace Oyster
void UnloadShaderD(void* loadedData);
void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out);
- void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type);
+ void UnloadOBJ(void* loadedData);
+ void LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out);
}
}
}
\ No newline at end of file
diff --git a/Code/OysterGraphics/FileLoader/TextureLoader.cpp b/Code/OysterGraphics/FileLoader/ModelLoader.cpp
similarity index 97%
rename from Code/OysterGraphics/FileLoader/TextureLoader.cpp
rename to Code/OysterGraphics/FileLoader/ModelLoader.cpp
index 1c6ba263..0fe623a9 100644
--- a/Code/OysterGraphics/FileLoader/TextureLoader.cpp
+++ b/Code/OysterGraphics/FileLoader/ModelLoader.cpp
@@ -1,6 +1,7 @@
#include "GeneralLoader.h"
#include "..\Core\Dx11Includes.h"
#include "..\Core\Core.h"
+#include "ObjReader.h"
HRESULT CreateWICTextureFromFileEx( ID3D11Device* d3dDevice,
ID3D11DeviceContext* d3dContext,
@@ -35,6 +36,30 @@ void Oyster::Graphics::Loading::UnloadTexture(void* data)
SAFE_RELEASE(srv);
}
+void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out)
+{
+ OBJReader obj;
+ obj.readOBJFile(filename);
+ Model::ModelInfo* info;
+ info = obj.toModel();
+ out.loadedData = info;
+ out.resourceUnloadFnc = Oyster::Graphics::Loading::UnloadOBJ;
+}
+
+void Oyster::Graphics::Loading::UnloadOBJ(void* data)
+{
+ Model::ModelInfo* info = (Model::ModelInfo*) data;
+ SAFE_DELETE(info->Vertices);
+ if(info->Indexed)
+ {
+ SAFE_DELETE(info->Indecies);
+ }
+ for(int i =0;iMaterial.size();++i)
+ {
+ Oyster::Resource::OysterResource::ReleaseResource(info->Material[i]);
+ }
+ delete info;
+}
#include
#include
diff --git a/Code/OysterGraphics/FileLoader/ObjReader.cpp b/Code/OysterGraphics/FileLoader/ObjReader.cpp
index 7eb1e268..923f0747 100644
--- a/Code/OysterGraphics/FileLoader/ObjReader.cpp
+++ b/Code/OysterGraphics/FileLoader/ObjReader.cpp
@@ -95,7 +95,7 @@ void OBJReader::readOBJFile( std::wstring fileName )
inStream.close();
- Mat = Oyster::Resource::OysterResource::LoadResource((fileName + L".jpg").c_str(),Oyster::Graphics::Loading::LoadTexture);
+ Mat = Oyster::Resource::OysterResource::LoadResource((fileName + L".png").c_str(),Oyster::Graphics::Loading::LoadTexture);
}
Oyster::Graphics::Model::ModelInfo* OBJReader::toModel()
diff --git a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp
index 5a7ba9e3..b3c8a0b7 100644
--- a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp
+++ b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp
@@ -10,6 +10,8 @@ namespace Oyster
{
namespace Loading
{
+ void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type);
+
void UnloadShaderP(void* loadedData)
{
ID3D11PixelShader* ps = ((ID3D11PixelShader*)loadedData);
@@ -165,14 +167,16 @@ namespace Oyster
data.data = new char[data.size];
memcpy(data.data,Shader->GetBufferPointer(),data.size);
#else
+ std::ifstream stream;
+
stream.open(filename, std::ifstream::in | std::ifstream::binary);
if(stream.good())
{
stream.seekg(0, std::ios::end);
- sd.size = size_t(stream.tellg());
- sd.data = new char[sd.size];
+ data.size = size_t(stream.tellg());
+ data.data = new char[data.size];
stream.seekg(0, std::ios::beg);
- stream.read(&sd.data[0], sd.size);
+ stream.read(&data.data[0], data.size);
stream.close();
}
else
@@ -180,7 +184,6 @@ namespace Oyster
memset(&out,0,sizeof(out));
return;
}
-
#endif
out.loadedData = Core::ShaderManager::CreateShader(data, Core::ShaderManager::ShaderType(type));
}
diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj
index 0df3d45b..cd1a5670 100644
--- a/Code/OysterGraphics/OysterGraphics.vcxproj
+++ b/Code/OysterGraphics/OysterGraphics.vcxproj
@@ -109,6 +109,7 @@
$(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso
+ 5.0
@@ -124,12 +125,13 @@
$(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso
+ 5.0
Level3
- MaxSpeed
+ Disabled
true
true
true
@@ -143,12 +145,14 @@
$(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso
+ true
+ 5.0
Level3
- MaxSpeed
+ Disabled
true
true
true
@@ -162,6 +166,8 @@
$(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso
+ true
+ 5.0
@@ -172,7 +178,7 @@
-
+
@@ -264,6 +270,8 @@
+
+
diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
index 50e7f9f1..2edb318b 100644
--- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
+++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
@@ -2,6 +2,8 @@
#include "../Resources/Resources.h"
#include "../../Definitions/GraphicalDefinition.h"
#include "../../Model/ModelInfo.h"
+#include