Merge with Gamle Logic

This commit is contained in:
lindaandersson 2014-01-20 11:59:43 +01:00
commit a1128986d5
110 changed files with 2919 additions and 1131 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.1">
<diagram program="umlet" version="12.2">
<zoom_level>11</zoom_level>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>726</x>
<x>847</x>
<y>363</y>
<w>132</w>
<h>33</h>
@ -15,7 +15,7 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>440</x>
<x>561</x>
<y>363</y>
<w>132</w>
<h>33</h>
@ -26,19 +26,19 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>550</x>
<y>286</y>
<x>671</x>
<y>209</y>
<w>132</w>
<h>33</h>
</coordinates>
<panel_attributes>Physics / Math</panel_attributes>
<panel_attributes>Physics</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>737</x>
<y>176</y>
<x>858</x>
<y>132</y>
<w>121</w>
<h>33</h>
</coordinates>
@ -48,8 +48,8 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>363</x>
<y>286</y>
<x>484</x>
<y>209</y>
<w>154</w>
<h>33</h>
</coordinates>
@ -59,8 +59,8 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>385</x>
<y>176</y>
<x>506</x>
<y>132</y>
<w>121</w>
<h>33</h>
</coordinates>
@ -70,8 +70,8 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>550</x>
<y>154</y>
<x>671</x>
<y>132</y>
<w>132</w>
<h>33</h>
</coordinates>
@ -81,7 +81,7 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>583</x>
<x>704</x>
<y>363</y>
<w>132</w>
<h>33</h>
@ -92,86 +92,64 @@
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>550</x>
<y>198</y>
<w>132</w>
<h>33</h>
</coordinates>
<panel_attributes>Threading</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>550</x>
<x>495</x>
<y>55</y>
<w>132</w>
<w>176</w>
<h>44</h>
</coordinates>
<panel_attributes>DanBias
<panel_attributes>DanBiasClientLauncher
bg=green</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>759</x>
<y>176</y>
<x>880</x>
<y>132</y>
<w>54</w>
<h>208</h>
<h>252</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;187;33;165;33;33</additional_attributes>
<additional_attributes>33;231;33;209;33;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>462</x>
<y>176</y>
<x>583</x>
<y>132</y>
<w>351</w>
<h>208</h>
<h>252</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;187;33;165;330;165;330;33</additional_attributes>
<additional_attributes>33;231;33;209;330;209;330;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>407</x>
<y>176</y>
<x>528</x>
<y>132</y>
<w>54</w>
<h>131</h>
<h>98</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;110;33;33</additional_attributes>
<additional_attributes>33;77;33;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>649</x>
<y>176</y>
<w>153</w>
<h>142</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;121;132;121;132;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>473</x>
<y>143</y>
<x>594</x>
<y>110</y>
<w>98</w>
<h>65</h>
<h>54</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>77;33;44;33;44;44;33;44</additional_attributes>
<additional_attributes>77;33;33;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>484</x>
<y>264</y>
<x>605</x>
<y>187</y>
<w>87</w>
<h>54</h>
</coordinates>
@ -181,76 +159,54 @@ bg=green</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>616</x>
<y>176</y>
<x>737</x>
<y>132</y>
<w>197</w>
<h>208</h>
<h>252</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;187;33;165;176;165;176;33</additional_attributes>
<additional_attributes>33;231;33;209;176;209;176;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>473</x>
<y>165</y>
<w>98</w>
<h>65</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>77;44;44;44;44;33;33;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>649</x>
<y>165</y>
<x>770</x>
<y>110</y>
<w>109</w>
<h>65</h>
<h>54</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;44;66;44;66;33;88;33</additional_attributes>
<additional_attributes>33;33;88;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>649</x>
<y>143</y>
<w>109</w>
<h>65</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;33;66;33;66;44;88;44</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>649</x>
<y>33</y>
<w>164</w>
<h>164</h>
<x>880</x>
<y>66</y>
<w>54</w>
<h>87</h>
</coordinates>
<panel_attributes>lt=&gt;-</panel_attributes>
<additional_attributes>33;33;143;33;143;143</additional_attributes>
<additional_attributes>33;33;33;66</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>407</x>
<y>33</y>
<w>164</w>
<h>164</h>
<x>528</x>
<y>66</y>
<w>54</w>
<h>87</h>
</coordinates>
<panel_attributes>lt=&gt;-</panel_attributes>
<additional_attributes>143;33;33;33;33;143</additional_attributes>
<additional_attributes>33;33;33;66</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>319</x>
<x>440</x>
<y>22</y>
<w>550</w>
<h>385</h>
<h>396</h>
</coordinates>
<panel_attributes>GameEngine</panel_attributes>
<additional_attributes/>
@ -258,7 +214,7 @@ bg=green</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>759</x>
<x>880</x>
<y>363</y>
<w>54</w>
<h>164</h>
@ -269,7 +225,7 @@ bg=green</panel_attributes>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>770</x>
<x>891</x>
<y>506</y>
<w>319</w>
<h>220</h>
@ -280,7 +236,7 @@ bg=green</panel_attributes>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>781</x>
<x>902</x>
<y>539</y>
<w>297</w>
<h>176</h>
@ -300,7 +256,7 @@ Release(resource :Model*) :void</panel_attributes>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>440</x>
<x>561</x>
<y>506</y>
<w>308</w>
<h>242</h>
@ -311,7 +267,7 @@ Release(resource :Model*) :void</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>528</x>
<x>649</x>
<y>363</y>
<w>142</w>
<h>175</h>
@ -322,7 +278,7 @@ Release(resource :Model*) :void</panel_attributes>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>451</x>
<x>572</x>
<y>539</y>
<w>286</w>
<h>198</h>
@ -343,7 +299,7 @@ Enable(Enable :bool) :void</panel_attributes>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>330</x>
<x>451</x>
<y>363</y>
<w>99</w>
<h>33</h>
@ -354,18 +310,18 @@ Enable(Enable :bool) :void</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>341</x>
<y>176</y>
<x>462</x>
<y>132</y>
<w>472</w>
<h>208</h>
<h>252</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;187;33;165;451;165;451;33</additional_attributes>
<additional_attributes>33;231;33;209;451;209;451;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>55</x>
<x>176</x>
<y>506</y>
<w>374</w>
<h>242</h>
@ -376,7 +332,7 @@ Enable(Enable :bool) :void</panel_attributes>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>66</x>
<x>187</x>
<y>539</y>
<w>352</w>
<h>121</h>
@ -393,7 +349,7 @@ Release(Resource :ResourceHandle*) :void</panel_attributes>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>66</x>
<x>187</x>
<y>693</y>
<w>352</w>
<h>44</h>
@ -406,7 +362,7 @@ FMOD</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>209</x>
<x>330</x>
<y>627</y>
<w>54</w>
<h>87</h>
@ -417,7 +373,7 @@ FMOD</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>165</x>
<x>286</x>
<y>363</y>
<w>362</w>
<h>175</h>
@ -425,4 +381,60 @@ FMOD</panel_attributes>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>341;33;341;88;253;88;253;154;33;154</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>781</x>
<y>55</y>
<w>198</w>
<h>44</h>
</coordinates>
<panel_attributes>DanBiasServerLauncher
bg=green</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>671</x>
<y>253</y>
<w>132</w>
<h>33</h>
</coordinates>
<panel_attributes>Math</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>770</x>
<y>132</y>
<w>153</w>
<h>164</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>33;143;132;143;132;33</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>682</x>
<y>297</y>
<w>99</w>
<h>33</h>
</coordinates>
<panel_attributes>Misc</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>605</x>
<y>198</y>
<w>87</w>
<h>98</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>66;77;44;77;44;33;33;33</additional_attributes>
</element>
</diagram>

View File

@ -0,0 +1,334 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.1">
<zoom_level>10</zoom_level>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>390</x>
<y>120</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>/C_Object/
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>320</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_Player</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>440</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_StaticObj</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>200</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_DynamicObj</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>240</x>
<y>0</y>
<w>200</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120;180;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>370</x>
<y>0</y>
<w>50</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>450</x>
<y>0</y>
<w>50</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>210</x>
<y>220</y>
<w>100</w>
<h>100</h>
</coordinates>
<panel_attributes>GameState
--
C_Object*
GameState
Camera
Client*</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>360</x>
<y>330</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>/GameClientState/
Is eighter game or lobby </panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>570</x>
<y>220</y>
<w>100</w>
<h>100</h>
</coordinates>
<panel_attributes>LobbyState
--
C_Object*
Camera
Client*</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>380</x>
<y>440</y>
<w>120</w>
<h>120</h>
</coordinates>
<panel_attributes>DanBiasGame
--
Client
Input
GameClientState
Window</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>400</x>
<y>350</y>
<w>50</w>
<h>110</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>30;90;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>230</x>
<y>290</y>
<w>150</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;60;130;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>490</x>
<y>290</y>
<w>150</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>130;30;130;60;30;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>560</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_UiObject</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>410</x>
<y>0</y>
<w>210</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>190;30;190;120;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>410</x>
<y>120</y>
<w>180</w>
<h>120</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>160;100;30;100;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>280</x>
<y>120</y>
<w>170</w>
<h>120</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>30;100;150;100;150;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>620</x>
<y>120</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>Light</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>340</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>NetworkAPI
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>230</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>GraphicsAPI
--
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>230</x>
<y>530</y>
<w>170</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30;150;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>360</x>
<y>530</y>
<w>50</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>460</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>Input
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>460</x>
<y>530</y>
<w>50</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>120</x>
<y>520</y>
<w>110</w>
<h>40</h>
</coordinates>
<panel_attributes>DanBiasLancher
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>580</x>
<y>640</y>
<w>110</w>
<h>40</h>
</coordinates>
<panel_attributes>WindowManager
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>470</x>
<y>530</y>
<w>190</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>170;110;170;30;30;30</additional_attributes>
</element>
</diagram>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.2">
<zoom_level>10</zoom_level>
</diagram>

View File

@ -423,14 +423,14 @@ INetworkSession</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>170</x>
<y>400</y>
<w>130</w>
<h>90</h>
<x>150</x>
<y>420</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>MapManager
--
Manages and makes sure maps are avalible to all clinents.
Manages all map stuff.
elementstyle=wordwrap
</panel_attributes>

View File

@ -0,0 +1,402 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.2">
<zoom_level>8</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>680</x>
<y>592</y>
<w>136</w>
<h>40</h>
</coordinates>
<panel_attributes>CustomNetworkProtocol
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>560</x>
<y>688</y>
<w>152</w>
<h>40</h>
</coordinates>
<panel_attributes>NetworkServer
--
elementstyle=wordwrap</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>776</x>
<y>688</y>
<w>152</w>
<h>40</h>
</coordinates>
<panel_attributes>NetworkClient
--
elementstyle=wordwrap</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>720</x>
<y>448</y>
<w>40</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=red</panel_attributes>
<additional_attributes>24;24;24;144</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>664</x>
<y>432</y>
<w>152</w>
<h>40</h>
</coordinates>
<panel_attributes>GameProtocols
--
elementstyle=wordwrap
bg=green</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>592</x>
<y>424</y>
<w>88</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>24;32;72;24</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>464</x>
<y>440</y>
<w>152</w>
<h>40</h>
</coordinates>
<panel_attributes>DanBiasServer
--
elementstyle=wordwrap
bg=green</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>880</x>
<y>440</y>
<w>152</w>
<h>40</h>
</coordinates>
<panel_attributes>DanBiasGame
--
elementstyle=wordwrap
bg=green</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>792</x>
<y>424</y>
<w>104</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>88;32;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>608</x>
<y>608</y>
<w>152</w>
<h>96</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=blue</panel_attributes>
<additional_attributes>24;80;24;56;136;56;136;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>736</x>
<y>608</y>
<w>136</w>
<h>96</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=blue</panel_attributes>
<additional_attributes>120;80;120;56;24;56;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>688</x>
<y>680</y>
<w>104</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;
fg=blue</panel_attributes>
<additional_attributes>88;24;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>512</x>
<y>456</y>
<w>64</w>
<h>264</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=red</panel_attributes>
<additional_attributes>24;24;24;248;48;248</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>904</x>
<y>456</y>
<w>64</w>
<h>272</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=red</panel_attributes>
<additional_attributes>48;24;48;256;24;256</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>504</x>
<y>456</y>
<w>288</w>
<h>304</h>
</coordinates>
<panel_attributes>lt=&gt;
fg=red</panel_attributes>
<additional_attributes>24;24;24;288;248;288;248;256;272;256</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>544</x>
<y>568</y>
<w>400</w>
<h>168</h>
</coordinates>
<panel_attributes>bg=orange
NetworkAPI</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>720</x>
<y>240</y>
<w>40</w>
<h>208</h>
</coordinates>
<panel_attributes>lt=.
fg=red</panel_attributes>
<additional_attributes>24;24;24;192</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>520</x>
<y>168</y>
<w>120</w>
<h>56</h>
</coordinates>
<panel_attributes>ProtocolIdentificationID
--
/Collection of uniuqe/
/protocol identifications/
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>824</x>
<y>176</y>
<w>120</w>
<h>48</h>
</coordinates>
<panel_attributes>GameProtocols
--
/Collects protocols/
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>696</x>
<y>136</y>
<w>88</w>
<h>24</h>
</coordinates>
<panel_attributes>ControlProtocols
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>696</x>
<y>168</y>
<w>88</w>
<h>24</h>
</coordinates>
<panel_attributes>LobbyProtocols
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>696</x>
<y>200</y>
<w>88</w>
<h>24</h>
</coordinates>
<panel_attributes>ObjectProtocols</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>696</x>
<y>232</y>
<w>88</w>
<h>24</h>
</coordinates>
<panel_attributes>PlayerProtocols
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>760</x>
<y>184</y>
<w>80</w>
<h>72</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>64;24;48;24;48;56;24;56</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>760</x>
<y>176</y>
<w>80</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>64;24;40;24;40;32;24;32</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>760</x>
<y>160</y>
<w>80</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>64;32;40;32;40;24;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>760</x>
<y>128</y>
<w>80</w>
<h>72</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>64;56;48;56;48;24;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>616</x>
<y>184</y>
<w>96</w>
<h>72</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>80;56;56;56;56;24;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>616</x>
<y>176</y>
<w>96</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>80;32;64;32;64;24;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>616</x>
<y>160</y>
<w>96</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>80;24;64;24;64;32;24;32</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>616</x>
<y>128</y>
<w>96</w>
<h>72</h>
</coordinates>
<panel_attributes>lt=&gt;</panel_attributes>
<additional_attributes>80;24;56;24;56;56;24;56</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>512</x>
<y>112</y>
<w>440</w>
<h>152</h>
</coordinates>
<panel_attributes>bg=orange
GameProtocols</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>744</x>
<y>312</y>
<w>184</w>
<h>72</h>
</coordinates>
<panel_attributes>Protocols is created in a seperate module because both server and client needs to share the same protocols and the same protocol identifications.
elementstyle=wordwrap</panel_attributes>
<additional_attributes/>
</element>
</diagram>

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.1">
<diagram program="umlet" version="12.2">
<zoom_level>12</zoom_level>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>540</x>
<y>456</y>
<w>132</w>
<y>468</y>
<w>336</w>
<h>36</h>
</coordinates>
<panel_attributes>OysterThread</panel_attributes>
@ -16,9 +16,9 @@
<type>com.umlet.element.Class</type>
<coordinates>
<x>372</x>
<y>408</y>
<y>396</y>
<w>120</w>
<h>36</h>
<h>48</h>
</coordinates>
<panel_attributes>/Some class/</panel_attributes>
<additional_attributes/>
@ -29,11 +29,11 @@
<x>336</x>
<y>300</y>
<w>228</w>
<h>132</h>
<h>120</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;&gt;&gt;&gt;-
&lt;&lt;implements&gt;&gt;</panel_attributes>
<additional_attributes>96;108;96;60;204;60</additional_attributes>
<additional_attributes>96;96;96;60;204;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
@ -41,52 +41,30 @@
<x>396</x>
<y>408</y>
<w>168</w>
<h>96</h>
<h>108</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-
Creates&gt;&gt;</panel_attributes>
<additional_attributes>36;36;36;72;132;72;144;72</additional_attributes>
<additional_attributes>36;36;36;84;132;84;144;84</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>564</x>
<y>372</y>
<x>660</x>
<y>384</y>
<w>60</w>
<h>108</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>36;84;36;36</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>540</x>
<y>540</y>
<w>132</w>
<h>36</h>
</coordinates>
<panel_attributes>OysterMutex</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>564</x>
<y>456</y>
<w>60</w>
<h>108</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>36;36;36;84</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>540</x>
<y>312</y>
<w>336</w>
<h>96</h>
<h>108</h>
</coordinates>
<panel_attributes>/&lt;&lt;interface&gt;&gt;/
IThreadObject
@ -123,16 +101,4 @@ bg=red</panel_attributes>
<panel_attributes>lt=-</panel_attributes>
<additional_attributes>36;36;36;108</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>336</x>
<y>408</y>
<w>228</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&gt;&gt;.
uses</panel_attributes>
<additional_attributes>60;36;60;144;204;144</additional_attributes>
</element>
</diagram>

View File

@ -3,6 +3,5 @@
BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved )
{
//MessageBox(0, L"DanBiasGame Loaded", 0, 0);
return TRUE;
}

View File

@ -204,6 +204,7 @@
<ClCompile Include="GameClientState\C_Object.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientRecieverFunc.h" />
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />

View File

@ -5,118 +5,20 @@
#include "GameClientState/GameClientState.h"
#include "GameClientState\GameState.h"
#include "GameClientState\LobbyState.h"
#include <GameProtocols.h>
#include <Protocols.h>
#include "NetworkClient.h"
#include "../WindowManager/WindowShell.h"
#include "L_inputClass.h"
#include "WinTimer.h"
#include "vld.h"
#include "GameClientRecieverFunc.h"
namespace DanBias
{
#pragma region Game Data
struct MyRecieverObject :public Oyster::Network::ProtocolRecieverObject
{
Oyster::Network::NetworkClient* nwClient;
Client::GameClientState* gameClientState;
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
{
int pType = p[0].value.netInt;
switch (pType)
{
case protocol_General_Status:
{
GameLogic::Protocol_General_Status::States state;
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
}
break;
case protocol_Gameplay_PlayerNavigation:
{
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++)
{
protocolData->key[i] = p[i+1].value.netBool;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_PlayerPosition:
{
Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++)
{
protocolData->playerPos[i] = p[i].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_CreateObject:
{
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
protocolData->object_ID = p[1].value.netInt;
protocolData->path = p[2].value.netCharPtr;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+3].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_RemoveObject:
{
Client::GameClientState::RemoveObj* protocolData = new Client::GameClientState::RemoveObj;
protocolData->object_ID = p[1].value.netInt;
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_ObjectPosition:
{
Client::GameClientState::ObjPos* protocolData = new Client::GameClientState::ObjPos;
protocolData->object_ID = p[1].value.netInt;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+2].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
default:
break;
}
}
};
class DanBiasGamePrivateData
{
@ -134,13 +36,14 @@ namespace DanBias
WindowShell* window;
InputClass* inputObj;
Utility::WinTimer* timer;
MyRecieverObject* recieverObj;
GameRecieverObject* recieverObj;
} data;
#pragma endregion
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
float DanBiasGame::capFrame = 0;
//--------------------------------------------------------------------------------------
// Interface API functions
@ -157,9 +60,9 @@ namespace DanBias
if( FAILED( InitInput() ) )
return DanBiasClientReturn_Error;
m_data->recieverObj = new MyRecieverObject;
m_data->recieverObj = new GameRecieverObject;
// m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
if (!m_data->recieverObj->nwClient->IsConnected())
@ -185,10 +88,16 @@ namespace DanBias
float dt = (float)m_data->timer->getElapsedSeconds();
m_data->timer->reset();
capFrame += dt;
if(capFrame > 0.03)
{
if(Update(dt) != S_OK)
return DanBiasClientReturn_Error;
if(Render(dt) != S_OK)
return DanBiasClientReturn_Error;
capFrame = 0;
}
}
return DanBiasClientReturn_Sucess;
}

View File

@ -0,0 +1,113 @@
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
#define DANBIAS_CLIENTRECIEVEROBJECT_H
namespace DanBias
{
struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
{
Oyster::Network::NetworkClient* nwClient;
Client::GameClientState* gameClientState;
// receiver function for server messages
// parsing protocols and sending it to the gameState
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
{
int pType = p[0].value.netInt;
switch (pType)
{
case protocol_General_Status:
{
GameLogic::Protocol_General_Status::States state;
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
if( state == GameLogic::Protocol_General_Status::States_disconected)
{
// server disconnected
DanBiasGame::Release();
}
}
break;
case protocol_Gameplay_PlayerNavigation:
{
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++)
{
protocolData->key[i] = p[i+1].value.netBool;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_PlayerPosition:
{
Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++)
{
protocolData->playerPos[i] = p[i].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_CreateObject:
{
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
protocolData->object_ID = p[1].value.netInt;
protocolData->path = p[2].value.netCharPtr;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+3].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete p[2].value.netCharPtr; //delete char array
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_RemoveObject:
{
Client::GameClientState::RemoveObj* protocolData = new Client::GameClientState::RemoveObj;
protocolData->object_ID = p[1].value.netInt;
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gameplay_ObjectPosition:
{
Client::GameClientState::ObjPos* protocolData = new Client::GameClientState::ObjPos;
protocolData->object_ID = p[1].value.netInt;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+2].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
default:
break;
}
}
};
}
#endif

View File

@ -26,6 +26,7 @@ void C_DynamicObj::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
privData->ID = modelInit.id;
}
void C_DynamicObj::setPos(Oyster::Math::Float4x4 world)
{

View File

@ -28,7 +28,7 @@ void C_Player::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
privData->ID = modelInit.id;
}
void C_Player::setPos(Oyster::Math::Float4x4 world)

View File

@ -28,6 +28,7 @@ void C_StaticObj::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
privData->ID = modelInit.id;
}
void C_StaticObj::setPos(Oyster::Math::Float4x4 world)

View File

@ -24,6 +24,7 @@ void C_UIobject::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
privData->ID = modelInit.id;
}
void C_UIobject::setPos(Oyster::Math::Float4x4 world)

View File

@ -2,7 +2,7 @@
#include "DllInterfaces/GFXAPI.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h"
#include <GameProtocols.h>
#include <Protocols.h>
#include "NetworkClient.h"
@ -18,10 +18,16 @@ struct GameState::myData
Oyster::Network::NetworkClient* nwClient;
gameStateState state;
}privData;
GameState::GameState(void)
{
key_forward = false;
key_backward = false;
key_strafeRight = false;
key_strafeLeft = false;
}
@ -40,6 +46,12 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
}
GameState::gameStateState GameState::LoadGame()
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(0,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 5;
plight.Bright = 2;
Oyster::Graphics::API::AddLight(plight);
LoadModels(L"map");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return gameStateState_playing;
@ -54,20 +66,35 @@ bool GameState::LoadModels(std::wstring mapFile)
ModelInitData modelData;
modelData.world = Oyster::Math3D::Float4x4::identity;
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\worldDummy";
modelData.id = 0;
// load models
C_Object* obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\worldDummy";
modelData.id ++;
obj = new C_DynamicObj();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\worldDummy";
modelData.id ++;
obj = new C_DynamicObj();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
return true;
}
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
@ -110,25 +137,54 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
movePlayer.bTurnRight = false;
if(KeyInput->IsKeyPressed(DIK_W))
{
if(!key_forward)
{
movePlayer.bForward = true;
send = true;
key_forward = true;
}
}
else
key_forward = false;
if(KeyInput->IsKeyPressed(DIK_S))
{
if(!key_backward)
{
movePlayer.bBackward = true;
send = true;
key_backward = true;
}
}
else
key_backward = false;
if(KeyInput->IsKeyPressed(DIK_A))
{
if(!key_strafeLeft)
{
movePlayer.bStrafeLeft = true;
send = true;
key_strafeLeft = true;
}
}
else
key_strafeLeft = false;
if(KeyInput->IsKeyPressed(DIK_D))
{
if(!key_strafeRight)
{
movePlayer.bStrafeRight = true;
send = true;
key_strafeRight = true;
}
}
else
key_strafeRight = false;
if (privData->nwClient->IsConnected() && send)
{
@ -209,28 +265,35 @@ void GameState::Protocol( ObjPos* pos )
{
world[i] = pos->worldPos[i];
}
for (int i = 0; i < privData->object.size(); i++)
{
if(privData->object[i]->GetId() == pos->object_ID)
{
privData->object[i]->setPos(world);
//privData->view = world;
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
}
}
}
void GameState::Protocol( NewObj* pos )
void GameState::Protocol( NewObj* newObj )
{
Oyster::Math::Float4x4 world;
for(int i = 0; i<16; i++)
{
world[i] = pos->worldPos[i];
world[i] = newObj->worldPos[i];
}
ModelInitData modelData;
modelData.world = world;
modelData.visible = true;
modelData.id = pos->object_ID;
modelData.id = newObj->object_ID;
//not sure if this is good parsing rom char* to wstring
const char* path = pos->path;
const char* path = newObj->path;
modelData.modelPath = std::wstring(path, path + strlen(path));
// load models
C_Object* player = new C_Player();

View File

@ -17,6 +17,11 @@ class GameState : public GameClientState
};
private:
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
struct myData;
myData* privData;
public:

View File

@ -39,6 +39,12 @@ bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient)
}
bool LobbyState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 3;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
// init models

View File

@ -1,3 +1,6 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASGAME_DANBIASGAME_H
#define DANBIASGAME_DANBIASGAME_H
@ -54,6 +57,8 @@ namespace DanBias
static HRESULT Render(float deltaTime);
static HRESULT CleanUp();
static float capFrame;
private:
static DanBiasGamePrivateData* m_data;

View File

@ -1,3 +1,6 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_ADMIN_INTERFACE_H
#define DANBIASSERVER_ADMIN_INTERFACE_H

View File

@ -179,10 +179,13 @@
<ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameServer.cpp" />
<ClCompile Include="GameSession\GameClient.cpp" />
<ClCompile Include="GameSession\GameSession_Events.cpp" />
<ClCompile Include="GameSession\GameSession_General.cpp" />
<ClCompile Include="GameSession\GameSession_Network.cpp" />
<ClCompile Include="LobbySessions\INetworkSession.cpp" />
<ClCompile Include="LobbySessions\LobbyClient.cpp" />
<ClCompile Include="LobbySessions\GameLobby.cpp" />
<ClCompile Include="GameSession\GameSession.cpp" />
<ClCompile Include="GameSession\GameSession_Logic.cpp" />
<ClCompile Include="LobbySessions\MainLobby.cpp" />
<ClCompile Include="LobbySessions\NetworkSession.cpp" />
</ItemGroup>

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H
#define DANBIAS_SERVER_DANBIAS_SERVER_H

View File

@ -22,10 +22,12 @@ namespace DanBias
{
using namespace Oyster::Network;
GameServer* GameServer::instance = 0;
void GameServer::NetworkCallback(NetworkClient* client)
{
static GameSession *myTest = 0;
static bool myTest = false;
static int sessionId = -1;
printf("Client with ID [%i] connected.\n", client->GetID());
if(!myTest)
@ -36,10 +38,9 @@ namespace DanBias
desc.mapName = L"test";
desc.clients.Push(c);
desc.exitDestionation = this->mainLobby;
int sessionId = 0;
if((sessionId = GameSessionManager::AddSession(desc, true)) == 0)
printf("Failed to create a game session");
printf("Failed to create a game session\n");
myTest = true;
//myTest = new GameSession();
//
//DanBias::GameSession::GameSessionDescription desc;
@ -52,7 +53,7 @@ namespace DanBias
else
{
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
myTest->Join(c);
GameSessionManager::JoinSession(sessionId, c);
}
@ -68,7 +69,7 @@ namespace DanBias
, maxClients(0)
, mainLobby(0)
, server(0)
{ }
{ this->instance = this; }
GameServer::~GameServer()
{
@ -89,7 +90,6 @@ namespace DanBias
if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error;
if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error;
//if(!WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasServerReturn_Error;
this->initiated = true;
return DanBiasServerReturn_Sucess;
@ -108,10 +108,9 @@ namespace DanBias
{
if(!WindowShell::Frame()) break;
this->mainLobby->Frame();
if(GetAsyncKeyState(0x51))
if(GetAsyncKeyState(0x51)) //Q for exit
break;
}
@ -119,6 +118,8 @@ namespace DanBias
}
DanBiasServerReturn GameServer::Release()
{
GameSessionManager::CloseSession();
this->mainLobby->Release();
delete this->mainLobby;
this->server->Shutdown();
delete this->server;
@ -126,6 +127,11 @@ namespace DanBias
return DanBiasServerReturn_Sucess;
}
NetworkSession* GameServer::MainLobbyInstance()
{
return GameServer::instance->mainLobby;
}
bool GameServer::LoadIniFile(InitData& ini)
{
std::ifstream in;

View File

@ -21,6 +21,8 @@ namespace DanBias
DanBiasServerReturn Run();
DanBiasServerReturn Release();
static NetworkSession* MainLobbyInstance();
private:
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
void NetworkCallback(Oyster::Network::NetworkClient* client) override;
@ -31,6 +33,7 @@ namespace DanBias
int maxClients;
MainLobby *mainLobby;
Oyster::Network::NetworkServer *server;
static GameServer* instance;
private:
struct InitData

View File

@ -4,16 +4,21 @@
#include "GameClient.h"
#include "..\LobbySessions\NetworkSession.h"
#include <GameProtocols.h>
#include <Game.h>
#include <Protocols.h>
using namespace Utility::DynamicMemory;
using namespace DanBias;
using namespace GameLogic;
GameClient::GameClient(SmartPointer<LobbyClient> client, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
static int gameClientIDCount = 1;
GameClient::GameClient(SmartPointer<LobbyClient> client, Game::PlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
{
this->callbackValue = value;
this->client = client;
this->player = new GameLogic::Player();
this->id = gameClientIDCount++;
this->player = player;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
c.callbackType = Oyster::Callback::CallbackType_Object;
c.value = this;
@ -22,8 +27,9 @@ GameClient::GameClient(SmartPointer<LobbyClient> client, Oyster::Callback::Oyste
}
GameClient::~GameClient()
{
this->client->Disconnect();
this->player.Release();
if(this->client) this->client->Disconnect();
this->player = 0;
this->id = -1;
}
void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
@ -31,15 +37,30 @@ void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSessi
this->callbackValue = value;
}
GameLogic::Player* GameClient::GetPlayer()
GameLogic::Game::PlayerData* GameClient::GetPlayer()
{
return this->player.Get();
return this->player;
}
LobbyClient* GameClient::GetClient()
GameLogic::Game::PlayerData* GameClient::ReleasePlayer()
{
GameLogic::Game::PlayerData *temp = this->player;
this->player = 0;
return temp;
}
LobbyClient* GameClient::GetClient() const
{
return this->client;
}
Utility::DynamicMemory::SmartPointer<LobbyClient> GameClient::ReleaseClient()
{
SmartPointer<LobbyClient> temp = this->client;
this->client = 0;
return temp;
}
int GameClient::GetID() const
{
return this->id;
}
void GameClient::ObjectCallback(NetworkSession::NetEvent e)
{
e.gameClient = this;

View File

@ -6,26 +6,33 @@
#include "..\LobbySessions\LobbyClient.h"
#include <PostBox\PostBox.h>
#include <Player.h>
#include <Game.h>
namespace DanBias
{
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
{
public:
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::Game::PlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
virtual~GameClient();
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
GameLogic::Player* GetPlayer();
LobbyClient* GetClient();
/* */
GameLogic::Game::PlayerData* GetPlayer();
GameLogic::Game::PlayerData* ReleasePlayer();
LobbyClient* GetClient() const;
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
int GetID() const;
private:
Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
GameLogic::Game::PlayerData* player;
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
int id;
void ObjectCallback(NetworkSession::NetEvent) override;
private:

View File

@ -1,319 +0,0 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <GameProtocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
void InsertObject(DynamicArray<SmartPointer<GameClient>>& clients, SmartPointer<GameClient> obj)
{
for (unsigned int i = 0; i < clients.Size(); i++)
{
if(!clients[i])
{
clients[i] = obj;
return;
}
}
}
void RemoveObject(DynamicArray<SmartPointer<GameClient>>& clients, DanBias::GameClient* obj)
{
for (unsigned int i = 0; i < clients.Size(); i++)
{
if(clients[i] && clients[i]->GetClient()->GetID() == obj->GetClient()->GetID())
{
clients[i] = 0;
return;
}
}
}
GameSession::GameSession()
{
this->owner = 0;
this->box = 0;
this->isCreated = false;
this->isRunning = false;
}
GameSession::~GameSession()
{
delete this->box;
this->box = 0;
this->owner = 0;
}
bool GameSession::Create(GameDescription& desc)
{
if(desc.clients.Size() == 0) return false;
if(!desc.owner) return false;
if(!desc.mapName.size()) return false;
if(this->isCreated) return false;
this->clients.Resize(desc.clients.Size());
this->box = new PostBox<NetworkSession::NetEvent>();
this->owner = desc.owner;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
c.value.callbackPostBox = this->box;
c.callbackType = Oyster::Callback::CallbackType_PostBox;
for (unsigned int i = 0; i < desc.clients.Size(); i++)
{
this->clients[i] = new GameClient(desc.clients[i], c);
}
this->isCreated = true;
return true;
}
void GameSession::Run()
{
if(this->isRunning) return;
if(this->clients.Size() > 0)
{
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS) return;
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_2);
this->isRunning = true;
}
}
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
{
if(!this->isCreated) return false;
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
c.value.callbackPostBox = this->box;
c.callbackType = Oyster::Callback::CallbackType_PostBox;
SmartPointer<GameClient> obj = new GameClient(client, c);
InsertObject(this->clients, obj);
return true;
}
void GameSession::CloseSession(bool dissconnectClients)
{
this->worker.Stop(false);
//NetworkSession::CloseSession(dissconnectClients);
this->isCreated = false;
this->isRunning = false;
}
////private: //overriden Threading functions
bool GameSession::DoWork ( )
{
this->Frame();
return true;
}
#ifndef ERIK
////private:
void GameSession::Frame()
{
this->ParseEvents();
if(GetAsyncKeyState(VK_UP))
{
Protocol_General_Status p(Protocol_General_Status::States_ready);
Send(p.GetProtocol());
Sleep(100);
}
}
void GameSession::ParseEvents()
{
if( !this->box->IsEmpty() )
{
NetworkSession::NetEvent &e = this->box->Fetch();
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
ParseGameplayEvent(e.protocol, e.gameClient);
if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
ParseGeneralEvent(e.protocol, e.gameClient);
}
}
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
{
switch (p[protocol_INDEX_ID].value.netShort)
{
case protocol_Gameplay_PlayerNavigation:
{
if(p[1].value.netBool) //bool bForward;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
if(p[2].value.netBool) //bool bBackward;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p[5].value.netBool) //bool bStrafeRight;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
//Oyster::Math::Float4x4 p;
Protocol_ObjectPosition op;//(c.GetPlayer()->GetRigidBody(), c.GetPlayer()->GetID());
//op.object_ID = c.GetPlayer()->GetID();
Send(op.GetProtocol());
}
break;
case protocol_Gameplay_PlayerMouseMovement:
break;
case protocol_Gameplay_PlayerPosition:
break;
case protocol_Gameplay_CreateObject:
break;
case protocol_Gameplay_ObjectPosition:
break;
}
}
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
{
switch (p[protocol_INDEX_ID].value.netShort)
{
case protocol_General_Status:
switch (p[1].value.netInt)
{
case GameLogic::Protocol_General_Status::States_bussy:
break;
case GameLogic::Protocol_General_Status::States_disconected:
printf("Client with ID [%i] dissconnected", c->GetClient()->GetID());
RemoveObject(this->clients, c);
break;
case GameLogic::Protocol_General_Status::States_idle:
break;
case GameLogic::Protocol_General_Status::States_ready:
break;
}
break;
case protocol_General_Text:
break;
}
}
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i] && this->clients[i]->GetClient())
this->clients[i]->GetClient()->Send(p);
}
}
#else
#include "DynamicObject.h"
//#include "CollisionManager.h"
//#include "GameLogicStates.h"
//#include <GameProtocols.h>
/*
using namespace GameLogic;
//VARIABLES GOES HERE
DynamicObject* objectBox;
bool GameSession::Init(GameSessionDescription& desc)
{
if(desc.clients.Size() == 0) return false;
this->box = new PostBox<NetEvent>();
this->owner = desc.owner;
for (unsigned int i = 0; i < desc.clients.Size(); i++)
{
desc.clients[i]->SetPostbox(this->box);
this->clients.Push(desc.clients[i]);
}
CollisionManager::BoxCollision(0,0);
objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX);
Protocol_CreateObject objectCreation;
objectCreation.object_ID = objectBox->GetID();
objectCreation.path = "crate";
Oyster::Math::Float4x4 worldMat = objectBox->GetRigidBody()->GetOrientation();
for (int i = 0; i < 16; i++)
{
objectCreation.worldMatrix[i] = worldMat[i];
}
for (int i = 0; i < clients.Size(); i++)
{
clients[i]->NetClient_Object()->Send(objectCreation);
}
return true;
}
void GameSession::Frame()
{
}
void GameSession::ParseEvents()
{
if(this->box && !this->box->IsEmpty())
{
NetEvent &e = this->box->Fetch();
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
ParseProtocol(e.protocol, *e.reciever);
}
}
void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::ClientObject& c)
{
switch (p[0].value.netShort)
{
case protocol_Gamplay_PlayerNavigation:
{
if(p[1].value.netBool) //bool bForward;
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
if(p[2].value.netBool) //bool bBackward;
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p[5].value.netBool) //bool bStrafeRight;
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
}
break;
case protocol_Gamplay_PlayerMouseMovement:
break;
case protocol_Gamplay_PlayerPosition:
break;
case protocol_Gamplay_CreateObject:
break;
case protocol_Gamplay_ObjectPosition:
break;
}
}
*/
#endif
}//End namespace DanBias

View File

@ -4,12 +4,15 @@
#ifndef DANBIASSERVER_GAME_SESSION_H
#define DANBIASSERVER_GAME_SESSION_H
//warning C4150: deletion of pointer to incomplete type, no destructor called
//warning C4150: deletion of pointer to incomplete type, no destructor called, because of forward decleration and the use of smartpointer.
#pragma warning(disable: 4150)
#include "..\LobbySessions\NetworkSession.h"
#include <WinTimer.h>
#include <PostBox\IPostBox.h>
#include <Thread\OysterThread.h>
#include <Game.h>
#include <Queue.h>
namespace DanBias
{
@ -18,6 +21,9 @@ namespace DanBias
class GameSession : public Oyster::Thread::IThreadObject, public INetworkSession
{
public:
/**
* A container to use when initiating a new session
*/
struct GameDescription
{
std::wstring mapName;
@ -25,6 +31,19 @@ namespace DanBias
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
};
struct GameSessionEvent
{
union EventData
{
GameLogic::Game::PlayerData* player;
} data;
enum EventType
{
EventType_Player,
EventType_DynamicObject,
} value;
};
public:
GameSession();
virtual~GameSession();
@ -41,33 +60,48 @@ namespace DanBias
bool Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client);
/**
*
* Closes the game session
* @param disconnectClients If set to true clients is dissconnected from the server, if false the clients is sent to the given owner of the session.
*/
void CloseSession(bool dissconnectClients = false);
void CloseSession(bool disconnectClients = false);
inline bool IsCreated() const { return this->isCreated; }
inline bool IsRunning() const { return this->isRunning; }
//Private member functions
private:
void Frame();
//Handles all events recieved
void ParseEvents();
//Handles all gameplay events
void ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
//Handles all general events
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
//Adds a client to the client list
void AddClient(Utility::DynamicMemory::SmartPointer<GameClient> obj);
//Removes a client from the client list
void RemoveClient(DanBias::GameClient* obj);
//Sends a protocol ta all clients in session
void Send(Oyster::Network::CustomNetProtocol* p);
private: //overriden Threading functions
//Frame function, derived from IThreadObject
bool DoWork ( ) override;
//Sends a client to the owner, if obj is NULL then all clients is sent
void SendToOwner(DanBias::GameClient* obj);
//Do a cleanup on all the private data
void Clean();
//Update game objects if needed
void UpdateGameObjects();
//Private member variables
private:
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
NetworkSession* owner;
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
Oyster::Thread::OysterThread worker;
GameLogic::Game gameInstance;
NetworkSession* owner;
bool isCreated;
bool isRunning;
Utility::Container::Queue<GameSessionEvent> modifiedClient;
private:
friend class AdminInterface;

View File

@ -78,7 +78,7 @@ bool GameSessionManager::StartSession(int session)
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client)
{
int i = -1;
if((i = gameSessionData.Existst(session)) != -1) return false;
if((i = gameSessionData.Existst(session)) == -1) return false;
gameSessionData.sessions[i]->Join(client);
@ -97,6 +97,13 @@ void GameSessionManager::GetSessionInfo(int session, GameSessionInfo& data)
//data.numberOfPlayers = gameSessionData.sessions[i]->
}
void GameSessionManager::CloseSession()
{
for (unsigned int i = 0; i < gameSessionData.sessions.Size(); i++)
{
gameSessionData.sessions[i]->CloseSession();
}
}
void GameSessionManager::CloseSession(int session)
{
int i = -1;

View File

@ -64,6 +64,11 @@ namespace DanBias
*/
static void CloseSession(int session);
/**
* Close all sessions.
*/
static void CloseSession();
/**
* Get total sessions running
* @return Returns the total sessions curently running.

View File

@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <OysterMath.h>
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
void GameSession::ParseEvents()
{
if( !this->box->IsEmpty() )
{
NetworkSession::NetEvent &e = this->box->Fetch();
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
ParseGameplayEvent(e.protocol, e.gameClient);
if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
ParseGeneralEvent(e.protocol, e.gameClient);
}
}
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
{
GameSessionEvent e;
e.data.player = c->GetPlayer();
e.value = GameSessionEvent::EventType_Player;
switch (p[protocol_INDEX_ID].value.netShort)
{
case protocol_Gameplay_PlayerNavigation:
{
//Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
if(p[1].value.netBool) //bool bForward;
//world.v[3].x = 2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
if(p[2].value.netBool) //bool bBackward;
//world.v[3].x = -2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p[5].value.netBool) //bool bStrafeRight;
//world.v[3].y = 2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
//world.v[3].y = -2;
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
}
break;
case protocol_Gameplay_PlayerMouseMovement:
break;
case protocol_Gameplay_PlayerPosition:
break;
case protocol_Gameplay_CreateObject:
break;
case protocol_Gameplay_ObjectPosition:
break;
}
this->modifiedClient.Push(e);
}
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
{
switch (p[protocol_INDEX_ID].value.netShort)
{
case protocol_General_Status:
switch (p[1].value.netInt)
{
case GameLogic::Protocol_General_Status::States_bussy:
break;
case GameLogic::Protocol_General_Status::States_disconected:
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
this->RemoveClient(c);
break;
case GameLogic::Protocol_General_Status::States_idle:
break;
case GameLogic::Protocol_General_Status::States_ready:
break;
}
break;
case protocol_General_Text:
break;
}
}
}//End namespace DanBias

View File

@ -0,0 +1,170 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include "..\GameServer.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
GameSession::GameSession()
{
this->owner = 0;
this->box = 0;
this->isCreated = false;
this->isRunning = false;
}
GameSession::~GameSession()
{
delete this->box;
this->box = 0;
this->owner = 0;
}
bool GameSession::Create(GameDescription& desc)
{
if(desc.clients.Size() == 0) return false;
if(!desc.owner) return false;
if(!desc.mapName.size()) return false;
if(this->isCreated) return false;
this->clients.Resize(desc.clients.Size());
this->box = new PostBox<NetworkSession::NetEvent>();
this->owner = desc.owner;
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
c.value.callbackPostBox = this->box;
c.callbackType = Oyster::Callback::CallbackType_PostBox;
for (unsigned int i = 0; i < desc.clients.Size(); i++)
{
this->clients[i] = new GameClient(desc.clients[i], gameInstance.CreatePlayer(), c);
}
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS) return false;
this->isCreated = true;
return true;
}
void GameSession::Run()
{
if(this->isRunning) return;
if(this->clients.Size() > 0)
{
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_2);
this->isRunning = true;
}
}
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
{
if(!this->isCreated) return false;
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
c.value.callbackPostBox = this->box;
c.callbackType = Oyster::Callback::CallbackType_PostBox;
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
AddClient(obj);
return true;
}
void GameSession::CloseSession(bool dissconnectClients)
{
if(dissconnectClients)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
this->clients[i]->GetClient()->Disconnect();
}
}
else
{
this->SendToOwner(0); //Send all clients to the current owner
}
this->Clean();
}
void GameSession::AddClient(SmartPointer<GameClient> obj)
{
for (unsigned int i = 0; i < clients.Size(); i++)
{
if(!clients[i])
{
clients[i] = obj;
return;
}
}
clients.Push(obj);
}
void GameSession::RemoveClient(DanBias::GameClient* obj)
{
for (unsigned int i = 0; i < clients.Size(); i++)
{
if(clients[i] && clients[i]->GetID() == obj->GetID())
{
clients[i] = 0;
return;
}
}
}
void GameSession::SendToOwner(DanBias::GameClient* obj)
{
DanBias::NetworkSession *s = GameServer::MainLobbyInstance();
if(this->owner) s = this->owner;
if(obj)
{
s->Attach(obj->ReleaseClient());
RemoveClient(obj);
}
else
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i])
{
s->Attach(this->clients[i]->ReleaseClient());
RemoveClient(this->clients[i]);
}
}
}
}
void GameSession::Clean()
{
this->worker.Terminate();
this->clients.Clear();
delete this->box;
this->box = 0;
this->gameInstance;
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
}
}//End namespace DanBias

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
#include <OysterMath.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
bool GameSession::DoWork( )
{
if(GetAsyncKeyState(VK_UP))
{
Protocol_General_Status p(Protocol_General_Status::States_ready);
Send(p.GetProtocol());
Sleep(100);
}
if(GetAsyncKeyState(VK_DOWN))
{
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
Protocol_CreateObject p(world, 2, "../Content/crate");
Send(p.GetProtocol());
Sleep(100);
}
this->ParseEvents();
this->gameInstance.NewFrame();
this->UpdateGameObjects();
return this->isRunning;
}
void GameSession::UpdateGameObjects()
{
while(!this->modifiedClient.IsEmpty())
{
//There is something that needs update
GameSessionEvent e = this->modifiedClient.Pop();
switch (e.value)
{
case GameSessionEvent::EventType_Player:
//e.data.player->GetOrientation();
break;
}
}
if(clients.Size() == 1)
{
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
Protocol_ObjectPosition p(world, 1);
Send(p.GetProtocol());
Sleep(100);
}
}
}//End namespace DanBias

View File

@ -0,0 +1,29 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i] && this->clients[i]->GetClient())
this->clients[i]->GetClient()->Send(p);
}
}
}//End namespace DanBias

View File

@ -1,3 +1,6 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_LEVELMANAGER_H
#define DANBIASSERVER_LEVELMANAGER_H

View File

@ -1,3 +1,6 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_INETWORKSESSION_H
#define DANBIASSERVER_INETWORKSESSION_H

View File

@ -1,5 +1,5 @@
#include "LobbyClient.h"
#include <GameProtocols.h>
#include <Protocols.h>
using namespace Utility::DynamicMemory;
using namespace Oyster::Network;

View File

@ -1,3 +1,6 @@
/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
#ifndef DANBIASSERVER_LOBBYCLIENT_H
#define DANBIASSERVER_LOBBYCLIENT_H

View File

@ -19,11 +19,12 @@ namespace DanBias
}
MainLobby::~MainLobby()
{
delete this->box;
this->box = 0;
}
void MainLobby::Release()
{
delete this->box;
this->box = 0;
this->CloseSession(true);
}

View File

@ -6,7 +6,7 @@
#include "NetworkSession.h"
#include "GameLobby.h"
#include <GameProtocols.h>
#include <Protocols.h>
#include <PostBox\IPostBox.h>
namespace DanBias

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////
// Launcher to launch Danbias server or client //
// Launcher to launch Danbias server //
// Created by [Dennis Andersen] [2013] //
//////////////////////////////////////////////////
#define NOMINMAX //Blame it on windows

View File

@ -39,16 +39,16 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void)
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput)
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage)
{
//switch case to determin what functionallity to use in the attatchment
switch (fireInput)
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(fireInput);
ForcePush(usage);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(fireInput);
ForcePull(usage);
break;
}
@ -57,7 +57,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInp
/********************************************************
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage)
{
//create coneRigidBody that will then collide with object and push them in the aimed direction
}
@ -65,7 +65,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput)
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage)
{
//Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
}

View File

@ -15,26 +15,26 @@ namespace GameLogic
~AttatchmentMassDriver(void);
void UseAttatchment(const WEAPON_FIRE &fireInput);
void UseAttatchment(const WEAPON_FIRE &usage);
private:
/********************************************************
* Pushes objects and players in a cone in front of the player
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForcePush(const WEAPON_FIRE &fireInput);
void ForcePush(const WEAPON_FIRE &usage);
/********************************************************
* Pulls the player forward, this is a movement tool
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForcePull(const WEAPON_FIRE &fireInput);
void ForcePull(const WEAPON_FIRE &usage);
/********************************************************
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
* @param fireInput: allows switching on different functionality in this specific function
********************************************************/
void ForceSuck(const WEAPON_FIRE &fireInput);
void ForceSuck(const WEAPON_FIRE &usage);
private:
struct PrivateData;

View File

@ -1,6 +1,9 @@
#include "AttatchmentSocket.h"
#include "IAttatchment.h"
#include "DynamicArray.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct AttatchmentSocket::PrivateData
{
@ -14,7 +17,7 @@ struct AttatchmentSocket::PrivateData
}
IAttatchment *attatchment;
SmartPointer<IAttatchment> attatchment;
}myData;
@ -26,10 +29,7 @@ AttatchmentSocket::AttatchmentSocket(void)
AttatchmentSocket::~AttatchmentSocket(void)
{
if (myData->attatchment)
{
delete myData->attatchment;
}
}
IAttatchment* AttatchmentSocket::GetAttatchment()
@ -39,18 +39,12 @@ IAttatchment* AttatchmentSocket::GetAttatchment()
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
{
if (myData->attatchment)
{
delete myData->attatchment;
}
myData->attatchment = attatchment;
}
void AttatchmentSocket::RemoveAttatchment()
{
if (myData->attatchment)
{
delete myData->attatchment;
}
myData->attatchment = 0;
}

View File

@ -55,3 +55,8 @@ using namespace GameLogic;
return Physics::ICustomBody::SubscriptMessage_none;
}
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}

View File

@ -14,7 +14,7 @@ namespace GameLogic
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj);
//these are the specific collision case functions
//void PlayerVBox(Player &player, DynamicObject &box);
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);

View File

@ -9,9 +9,7 @@
namespace GameLogic
{
class DANBIAS_GAMELOGIC_DLL DynamicObject : public Object
class DynamicObject : public Object
{
public:

View File

@ -0,0 +1,129 @@
#include "Game.h"
#include "Player.h"
#include "Level.h"
#include <DynamicArray.h>
#include <GID.h>
#include <PhysicsAPI.h>
#include <WinTimer.h>
using namespace GameLogic;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
#define DELTA_TIME 0.01666666666666666666666666666667f
template<typename T>
int InsertObject(DynamicArray<T*>& list, T* obj)
{
for (unsigned int i = 0; i < list.Size(); i++)
{
if(!list[i])
{
list[i] = obj;
return i;
}
}
list.Push(obj);
return list.Size() - 1;
}
template<typename T>
int RemoveObject(DynamicArray<T*>& list, T* obj)
{
for (unsigned int i = 0; i < list.Size(); i++)
{
if(!list[i])
{
list[i] = obj;
return i;
}
}
list.Push(obj);
return list.Size() - 1;
}
struct Game::PrivateData
{
PrivateData()
{ }
~PrivateData()
{
for (unsigned int i = 0; i < players.Size(); i++)
{
this->players[i]->player = 0;
}
}
DynamicArray<PlayerData*> players;
LevelData* level;
Utility::WinTimer timer;
}myData;
Game::Game(void)
{
myData = new PrivateData();
}
Game::~Game(void)
{
if(myData)
{
delete myData;
}
}
void Game::GetAllPlayerPositions() const
{
}
Game::PlayerData* Game::CreatePlayer()
{
Player *newPlayer = new Player();
PlayerData *newPdata = new PlayerData();
newPdata->player = newPlayer;
int id = InsertObject(this->myData->players, newPdata);
return this->myData->players[id];
}
Game::LevelData* Game::CreateLevel()
{
Level *newLevel = new Level();
newLevel->InitiateLevel(1000);
LevelData *newLdata = new LevelData();
newLdata->level = newLevel;
myData->level = newLdata;
return myData->level;
}
void Game::CreateTeam()
{
}
void Game::NewFrame()
{
double dt = this->myData->timer.getElapsedSeconds();
//60 fps sec is currently staticly
if(dt >= DELTA_TIME)
{
for (int i = 0; i < this->myData->players.Size(); i++)
{
if(this->myData->players[i]->player)
this->myData->players[i]->player->BeginFrame();
}
API::Instance().Update();
for (int i = 0; i < this->myData->players.Size(); i++)
{
if(this->myData->players[i]->player)
this->myData->players[i]->player->EndFrame();
}
this->myData->timer.reset();
}
}

119
Code/Game/GameLogic/Game.h Normal file
View File

@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////
// Created by [Erik Persson] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef GAME_H
#define GAME_H
#include "GameLogicDef.h"
#include "GameLogicStates.h"
#include <OysterMath.h>
namespace GameLogic
{
class Player;
class Level;
class DANBIAS_GAMELOGIC_DLL Game
{
public:
struct DANBIAS_GAMELOGIC_DLL PlayerData
{
private:
friend class Game;
Player *player;
PlayerData();
PlayerData(int playerID,int teamID);
~PlayerData();
public:
/********************************************************
* Moves the chosen player based on input
* @param playerID: ID of the player you want to recieve the message
* @param movement: enum value on what kind of action is to be taken
********************************************************/
void Move(const PLAYER_MOVEMENT &movement);
/********************************************************
* Uses the chosen players weapon based on input
* @param playerID: ID of the player you want to recieve the message
* @param Usage: enum value on what kind of action is to be taken
********************************************************/
void UseWeapon(int playerID, const WEAPON_FIRE &usage);
/********************************************************
* Gets players position
* @param playerID: ID of the player whos position you want
********************************************************/
Oyster::Math::Float3 GetPosition();
/********************************************************
* Gets players current orientation
* @param playerID: ID of the player whos position you want
********************************************************/
Oyster::Math::Float4x4 GetOrientation();
/********************************************************
* Check player state
* @return The current player state
********************************************************/
PLAYER_STATE GetState() const;
/***/
int GetID() const;
/***/
int GetTeamID() const;
};
struct DANBIAS_GAMELOGIC_DLL LevelData
{
private:
friend class Game;
Level *level;
LevelData();
~LevelData();
public:
};
public:
Game(void);
~Game(void);
/********************************************************
* Gets the position of all players currently in the game
********************************************************/
void GetAllPlayerPositions() const;
/********************************************************
* Creates a player and returns PlayerData
********************************************************/
PlayerData* CreatePlayer();
/********************************************************
* Creates a level and returns LevelData
********************************************************/
LevelData* CreateLevel();
/********************************************************
* Creates a team
********************************************************/
void CreateTeam();
/********************************************************
* Runs a update of the gamelogic and physics
********************************************************/
void NewFrame();
private:
struct PrivateData;
PrivateData *myData;
};
}
#endif

View File

@ -173,6 +173,7 @@
<ClInclude Include="AttatchmentSocket.h" />
<ClInclude Include="CollisionManager.h" />
<ClInclude Include="DynamicObject.h" />
<ClInclude Include="Game.h" />
<ClInclude Include="GameLogicDef.h" />
<ClInclude Include="GameLogicStates.h" />
<ClInclude Include="GameMode.h" />
@ -190,7 +191,10 @@
<ClCompile Include="AttatchmentSocket.cpp" />
<ClCompile Include="CollisionManager.cpp" />
<ClCompile Include="DynamicObject.cpp" />
<ClCompile Include="Game.cpp" />
<ClCompile Include="GameMode.cpp" />
<ClCompile Include="Game_LevelData.cpp" />
<ClCompile Include="Game_PlayerData.cpp" />
<ClCompile Include="IAttatchment.cpp" />
<ClCompile Include="Level.cpp" />
<ClCompile Include="Object.cpp" />

View File

@ -16,6 +16,8 @@ namespace GameLogic
PLAYER_STATE_JUMPING = 0,
PLAYER_STATE_WALKING = 1,
PLAYER_STATE_IDLE = 2,
PLAYER_STATE_DEAD = 4,
PLAYER_STATE_INVALID = 8,
};
enum OBJECT_TYPE
@ -37,7 +39,7 @@ namespace GameLogic
enum WEAPON_STATE
{
WEAPON_STATE_FIREING = 0,
WEAPON_STATE_FIRING = 0,
WEAPON_STATE_IDLE = 1,
WEAPON_STATE_RELOADING = 2,
};

View File

@ -0,0 +1,14 @@
#include "Game.h"
#include "Level.h"
using namespace GameLogic;
Game::LevelData::LevelData()
{
}
Game::LevelData::~LevelData()
{
}

View File

@ -0,0 +1,46 @@
#include "Game.h"
#include "Player.h"
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
}
Game::PlayerData::~PlayerData()
{
}
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
{
this->player->Move(movement);
}
void Game::PlayerData::UseWeapon(int playerID, const WEAPON_FIRE &usage)
{
}
Oyster::Math::Float3 Game::PlayerData::GetPosition()
{
return this->player->GetPosition();
}
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
{
return this->player->GetOrientation();
}
PLAYER_STATE Game::PlayerData::GetState() const
{
return this->player->GetState();
}
int Game::PlayerData::GetID() const
{
return this->player->GetID();
}
int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
}

View File

@ -19,7 +19,7 @@ namespace GameLogic
IAttatchment(void);
~IAttatchment(void);
virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0;
virtual void UseAttatchment(const WEAPON_FIRE &usage) = 0;
private:

View File

@ -5,8 +5,11 @@
#include "Player.h"
#include "PhysicsAPI.h"
#include "TeamManager.h"
#include "DynamicArray.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
struct Level::PrivateData
{
@ -18,17 +21,15 @@ struct Level::PrivateData
{
}
TeamManager *teamManager;
//SmartPointer<TeamManager> teamManager;
StaticObject** staticObjects;
int nrOfStaticObjects;
//DynamicArray<SmartPointer<StaticObject>> staticObjects;
DynamicObject** dynamicObjects;
int nrOfDynamicObjects;
//DynamicArray<SmartPointer<DynamicObject>> dynamicObjects;
GameMode* gameMode;
//SmartPointer<GameMode> gameMode;
Oyster::Physics::ICustomBody *rigidBodyLevel;
SmartPointer<ICustomBody> rigidBodyLevel;
}myData;
@ -46,21 +47,42 @@ Level::~Level(void)
void Level::InitiateLevel(std::string levelPath)
{
}
void Level::InitiateLevel(float radius)
{
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true;
sbDesc.radius = radius;
sbDesc.mass = 1e16; //10^16
sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
API::Instance().AddObject(rigidBody);
API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = (float)1e16;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell);
}
void Level::AddPlayerToTeam(Player *player, int teamID)
{
myData->teamManager->AddPlayerToTeam(player,teamID);
//myData->teamManager->AddPlayerToTeam(player,teamID);
}
void Level::CreateTeam(int teamSize)
{
myData->teamManager->CreateTeam(teamSize);
//myData->teamManager->CreateTeam(teamSize);
}
void Level::RespawnPlayer(Player *player)
{
myData->teamManager->RespawnPlayerRandom(player);
//myData->teamManager->RespawnPlayerRandom(player);
}

View File

@ -21,6 +21,7 @@ namespace GameLogic
* @param levelPath: Path to a file that contains all information on the level
********************************************************/
void InitiateLevel(std::string levelPath);
void Level::InitiateLevel(float radius);
/********************************************************
* Creates a team in the level

View File

@ -16,7 +16,10 @@ Object::Object()
//sbDesc.centerPosition =
//poi
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
Oyster::Physics::API::Instance().AddObject(rigidBody);
//rigidBody->gameObjectRef = this;
@ -33,6 +36,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
//poi
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
Oyster::Physics::API::Instance().AddObject(rigidBody);
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
//rigidBody->gameObjectRef = this;
@ -46,14 +51,13 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
Object::~Object(void)
{
}
OBJECT_TYPE Object::GetType()
OBJECT_TYPE Object::GetType() const
{
return this->type;
}
int Object::GetID()
int Object::GetID() const
{
return this->objectID;
}

View File

@ -8,26 +8,19 @@
#include "GameLogicStates.h"
#include "GameLogicDef.h"
#include <PhysicsAPI.h>
namespace Oyster
{
namespace Physics
{
class ICustomBody;
}
}
namespace GameLogic
{
class DANBIAS_GAMELOGIC_DLL Object
class Object
{
public:
Object();
Object(void* collisionFunc, OBJECT_TYPE type);
~Object(void);
OBJECT_TYPE GetType();
int GetID();
OBJECT_TYPE GetType() const;
int GetID() const;
Oyster::Physics::ICustomBody* GetRigidBody();
@ -36,6 +29,9 @@ namespace GameLogic
int objectID;
protected:
Oyster::Physics::ICustomBody *rigidBody;
Oyster::Physics::ICustomBody::State setState;
Oyster::Physics::ICustomBody::State getState;
};
}

View File

@ -1,56 +1,36 @@
#include "Player.h"
#include "OysterMath.h"
#include "CollisionManager.h"
#include "Weapon.h"
using namespace GameLogic;
using namespace Oyster::Physics;
struct Player::PrivateData
{
PrivateData()
Player::Player()
:DynamicObject(CollisionManager::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
{
weapon = new Weapon();
life = 100;
teamID = -1;
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
lookDir = Oyster::Math::Float4(0,0,-1,0);
Oyster::Physics::ICustomBody::State state;
this->rigidBody->GetState( this->setState );
setState.SetLinearMomentum( Oyster::Math::Float4(20, 0, 0, 0) );
this->rigidBody->SetState( setState );
lookDir = Oyster::Math::Float3(1,0,0);
}
~PrivateData()
{
if (weapon)
{
delete weapon;
}
}
int life;
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
Oyster::Math::Float3 lookDir;
}myData;
Player::Player()
:Object(CollisionManager::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
{
myData = new PrivateData();
}
Player::~Player(void)
{
delete myData;
delete weapon;
weapon = NULL;
}
void Player::Move(const PLAYER_MOVEMENT &movement)
{
//Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
switch(movement)
{
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
@ -77,73 +57,91 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward()
{
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
setState.ApplyLinearImpulse(this->lookDir * 100);
}
void Player::MoveBackwards()
{
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
setState.ApplyLinearImpulse(-this->lookDir * 100);
}
void Player::MoveRight()
{
//Do cross product with forward vector and negative gravity vector
//Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
setState.ApplyLinearImpulse(r * 100);
}
void Player::MoveLeft()
{
//Do cross product with forward vector and negative gravity vector
//Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
//Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
setState.ApplyLinearImpulse(-r * 100);
}
void Player::UseWeapon(const WEAPON_FIRE &fireInput)
void Player::UseWeapon(const WEAPON_FIRE &usage)
{
myData->weapon->Use(fireInput);
this->weapon->Use(usage);
}
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
{
//API::Instance().SetCenter(rigidBody,spawnPoint);
myData->life = 100;
myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
myData->lookDir = Oyster::Math::Float3(1,0,0);
this->life = 100;
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float4(1,0,0);
}
void Player::Jump()
{
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100);
}
bool Player::IsWalking()
{
return (myData->playerState == PLAYER_STATE::PLAYER_STATE_WALKING);
return (this->playerState == PLAYER_STATE::PLAYER_STATE_WALKING);
}
bool Player::IsJumping()
{
return (myData->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING);
return (this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING);
}
bool Player::IsIdle()
{
return (myData->playerState == PLAYER_STATE::PLAYER_STATE_IDLE);
return (this->playerState == PLAYER_STATE::PLAYER_STATE_IDLE);
}
Oyster::Math::Float3 Player::GetPos()
Oyster::Math::Float3 Player::GetPosition() const
{
//return rigidBody->GetCenter();
return Oyster::Math::Float3(0,0,0);
return (Oyster::Math::Float3)getState.GetCenterPosition();
}
Oyster::Math::Float3 Player::GetLookDir()
Oyster::Math::Float4x4 Player::GetOrientation() const
{
return myData->lookDir;
return this->getState.GetOrientation();
}
int Player::GetTeamID()
Oyster::Math::Float3 Player::GetLookDir() const
{
return myData->teamID;
return this->lookDir.xyz;
}
int Player::GetTeamID() const
{
return this->teamID;
}
PLAYER_STATE Player::GetState() const
{
return this->playerState;
}
void Player::DamageLife(int damage)
{
myData->life -= damage;
this->life -= damage;
}
void Player::BeginFrame()
{
this->rigidBody->SetState(this->setState);
}
void Player::EndFrame()
{
this->rigidBody->GetState(this->getState);
this->setState = this->getState;
}

View File

@ -3,17 +3,20 @@
//////////////////////////////////////////////////
#ifndef PLAYER_H
#define PLAYER_H
#include "GameLogicStates.h"
#include "GameLogicDef.h"
#include "OysterMath.h"
#include "Object.h"
#include "DynamicObject.h"
#include "OysterMath.h"
#include "CollisionManager.h"
namespace GameLogic
{
class DANBIAS_GAMELOGIC_DLL Player : public Object
class Weapon;
class Player : public DynamicObject
{
public:
Player(void);
~Player(void);
@ -33,7 +36,7 @@ namespace GameLogic
* Uses the weapon based on input
* @param fireInput: enum value on what kind of action is to be taken
********************************************************/
void UseWeapon(const WEAPON_FIRE &fireInput);
void UseWeapon(const WEAPON_FIRE &usage);
/********************************************************
* Respawns the player, this resets several stats and settings on the player
@ -46,18 +49,28 @@ namespace GameLogic
bool IsJumping();
bool IsIdle();
Oyster::Math::Float3 GetPos();
Oyster::Math::Float3 GetLookDir();
int GetTeamID();
Oyster::Math::Float3 GetPosition() const;
Oyster::Math::Float3 GetLookDir() const;
Oyster::Math::Float4x4 GetOrientation() const;
int GetTeamID() const;
PLAYER_STATE GetState() const;
void DamageLife(int damage);
private:
//Do frame calculations
void BeginFrame();
void EndFrame();
void Jump();
private:
struct PrivateData;
PrivateData *myData;
void Jump();
private:
int life;
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
Oyster::Math::Float4 lookDir;
};
}
#endif

View File

@ -54,7 +54,7 @@ void TeamManager::RespawnPlayerRandom(Player *player)
Player *respawnOnThis = myData->teams[teamID]->GetPlayer(0);
player->Respawn(respawnOnThis->GetPos());
player->Respawn(respawnOnThis->GetPosition());
}
void TeamManager::CreateTeam(int teamSize)

View File

@ -1,8 +1,10 @@
#include "Weapon.h"
#include "AttatchmentSocket.h"
#include "AttatchmentMassDriver.h"
#include "DynamicArray.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct Weapon::PrivateData
{
@ -12,7 +14,6 @@ struct Weapon::PrivateData
selectedAttatchment = 0;
currentNrOfAttatchments = 0;
selectedSocketID = 0;
maxNrOfSockets = 0;
attatchmentSockets = 0;
}
@ -22,11 +23,9 @@ struct Weapon::PrivateData
WEAPON_STATE weaponState;
AttatchmentSocket **attatchmentSockets;
int maxNrOfSockets;
DynamicArray<SmartPointer<AttatchmentSocket>> attatchmentSockets;
int currentNrOfAttatchments;
IAttatchment *selectedAttatchment;
SmartPointer<IAttatchment> selectedAttatchment;
int selectedSocketID;
}myData;
@ -39,34 +38,23 @@ Weapon::Weapon()
Weapon::Weapon(int MaxNrOfSockets)
{
myData = new PrivateData();
myData->maxNrOfSockets = MaxNrOfSockets;
myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets];
for (int i = 0; i < MaxNrOfSockets; i++)
{
myData->attatchmentSockets[i] = new AttatchmentSocket();
}
myData->attatchmentSockets.Resize(MaxNrOfSockets);
}
Weapon::~Weapon(void)
{
for (int i = 0; i < myData->currentNrOfAttatchments; i++)
{
delete myData->attatchmentSockets[i];
}
delete[] myData->attatchmentSockets;
delete myData;
}
/********************************************************
* Uses the weapon based on the input given and the current chosen attatchment
********************************************************/
void Weapon::Use(const WEAPON_FIRE &fireInput)
void Weapon::Use(const WEAPON_FIRE &usage)
{
if (myData->selectedAttatchment)
{
myData->selectedAttatchment->UseAttatchment(fireInput);
myData->selectedAttatchment->UseAttatchment(usage);
}
}
@ -80,7 +68,7 @@ void Weapon::Use(const WEAPON_FIRE &fireInput)
********************************************************/
bool Weapon::IsFireing()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIREING);
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIRING);
}
bool Weapon::IsIdle()
@ -95,7 +83,7 @@ bool Weapon::IsReloading()
bool Weapon::IsValidSocket(int socketID)
{
if(socketID < myData->maxNrOfSockets && socketID >= 0)
if(socketID < myData->attatchmentSockets.Size() && socketID >= 0)
{
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
{
@ -114,7 +102,7 @@ int Weapon::GetCurrentSocketID()
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
{
if(myData->currentNrOfAttatchments < myData->maxNrOfSockets)
if(myData->currentNrOfAttatchments < myData->attatchmentSockets.Size())
{
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
myData->currentNrOfAttatchments++;

View File

@ -35,8 +35,6 @@ namespace GameLogic
int GetCurrentSocketID();
private:
struct PrivateData;
PrivateData *myData;

View File

@ -13,6 +13,7 @@ namespace GameLogic
States_ready,
States_idle,
States_bussy,
State_waiting,
States_disconected,
};
States status;

View File

@ -155,7 +155,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ControlProtocols.h" />
<ClInclude Include="GameProtocols.h" />
<ClInclude Include="GameplayProtocols.h" />
<ClInclude Include="Protocols.h" />
<ClInclude Include="LobbyProtocols.h" />
<ClInclude Include="ObjectProtocols.h" />
<ClInclude Include="PlayerProtocols.h" />

View File

@ -0,0 +1,63 @@
#ifndef GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
#define GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
#include <vector>
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
struct Protocol_GameplayInitiateSession :public Oyster::Network::CustomProtocolObject
{
struct SessionInitData
{
int id;
int type;
//std::string text;
};
std::vector<SessionInitData> element;
Protocol_GameplayInitiateSession()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_Initiate;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_GameplayInitiateSession(Oyster::Network::CustomNetProtocol& p)
{
int size = p[1].value.netInt;
for (int i = 0; i < size; i++)
{
SessionInitData d = { p[i+2].value.netInt, p[i+3].value.netInt /*, p[i+4].value.netCharPtr */ };
element.push_back(d);
}
}
void Add(int id, int type, std::string text)
{
SessionInitData d = { id, type /*, text*/ };
element.push_back(d);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
//Store the elements count
this->protocol[1].value = element.size();
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (unsigned int i = 0; i < element.size(); i+=3)
{
this->protocol[i+2].value = element[i].id;
this->protocol[i+3].value = element[i].type;
//element[i].text.copy(this->protocol[i+4].value.netCharPtr, element[i].text.size());
this->protocol[i+2].type = Oyster::Network::NetAttributeType_Int;
this->protocol[i+3].type = Oyster::Network::NetAttributeType_Int;
//this->protocol[i+4].type = Oyster::Network::NetAttributeType_CharArray;
}
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
}
#endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H

View File

@ -28,27 +28,47 @@ namespace GameLogic
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
}
Protocol_CreateObject(float m[16], int id, char *path)
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_CreateObject;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
for (int i = 3; i <= 18; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = id;
this->path = path;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = path;
this->protocol[3].value = worldMatrix[1];
this->protocol[4].value = worldMatrix[2];
this->protocol[5].value = worldMatrix[3];
this->protocol[6].value = worldMatrix[4];
this->protocol[7].value = worldMatrix[5];
this->protocol[8].value = worldMatrix[6];
this->protocol[9].value = worldMatrix[7];
this->protocol[10].value = worldMatrix[8];
this->protocol[11].value = worldMatrix[9];
this->protocol[12].value = worldMatrix[10];
this->protocol[13].value = worldMatrix[11];
this->protocol[14].value = worldMatrix[12];
this->protocol[15].value = worldMatrix[13];
this->protocol[16].value = worldMatrix[14];
this->protocol[17].value = worldMatrix[15];
this->protocol[18].value = worldMatrix[16];
this->protocol[3].value = worldMatrix[0];
this->protocol[4].value = worldMatrix[1];
this->protocol[5].value = worldMatrix[2];
this->protocol[6].value = worldMatrix[3];
this->protocol[7].value = worldMatrix[4];
this->protocol[8].value = worldMatrix[5];
this->protocol[9].value = worldMatrix[6];
this->protocol[10].value = worldMatrix[7];
this->protocol[11].value = worldMatrix[8];
this->protocol[12].value = worldMatrix[9];
this->protocol[13].value = worldMatrix[10];
this->protocol[14].value = worldMatrix[11];
this->protocol[15].value = worldMatrix[12];
this->protocol[16].value = worldMatrix[13];
this->protocol[17].value = worldMatrix[14];
this->protocol[18].value = worldMatrix[15];
return &protocol;
}

View File

@ -42,7 +42,7 @@ namespace GameLogic
bTurnLeft = val[3].value.netBool;
bTurnRight = val[4].value.netBool;
bStrafeRight = val[5].value.netBool;
bStrafeRight = val[6].value.netBool;
bStrafeLeft = val[6].value.netBool;
return *this;
}
@ -53,7 +53,7 @@ namespace GameLogic
this->protocol[3].value = bTurnLeft;
this->protocol[4].value = bTurnRight;
this->protocol[5].value = bStrafeRight;
this->protocol[6].value = bStrafeRight;
this->protocol[6].value = bStrafeLeft;
return &protocol;
}

View File

@ -22,7 +22,7 @@
/***********************************/
/********* GENERAL PROTOCOLS ***************************************************************************************************/
/***********[ 100 - 200 ]***********/
#define protocol_GeneralMIN 100 /* This defines lower bounds of general protocols (okay to have same value on first element). */
#define protocol_GeneralMIN 100
#define protocol_General_Status 100
#define protocol_General_Text 101
#define protocol_GeneralMAX 199
@ -51,6 +51,7 @@
#define protocol_Gameplay_CreateObject 303
#define protocol_Gameplay_RemoveObject 304
#define protocol_Gameplay_ObjectPosition 305
#define protocol_Gameplay_Initiate 306
#define protocol_GameplayMAX 399
@ -61,11 +62,4 @@ inline bool ProtocolIsLobby(short ID) { return (ID >= protocol_LobbyMIN && ID <=
inline bool ProtocolIsGeneral(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); }
inline bool ProtocolIsGameplay(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); }
/***********************************/
/*********** TEST PROTOCOLS *******************************************************************************************************/
/***********[ x - x ]************/
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H

View File

@ -5,5 +5,6 @@
#include "PlayerProtocols.h"
#include "LobbyProtocols.h"
#include "ControlProtocols.h"
#include "GameplayProtocols.h"
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H

View File

@ -1,13 +1,13 @@
#ifndef I_QUEUE_H
#define I_QUEUE_H
#ifndef MISC_I_QUEUE_H
#define MISC_I_QUEUE_H
/////////////////////////////////
// Created by Sam Svensson 2013//
/////////////////////////////////
namespace Oyster
namespace Utility
{
namespace Queue
namespace Container
{
template <typename Type>
class IQueue
@ -20,13 +20,10 @@ namespace Oyster
virtual ~IQueue() {};
virtual void Push( Type item ) = 0;
virtual Type Pop() = 0;
virtual Type Front() = 0;
virtual Type Back() = 0;
virtual int Size() = 0;
virtual bool IsEmpty() = 0;
virtual void Swap( IQueue<Type> &queue ) = 0;
};
}

View File

@ -162,6 +162,7 @@
<ClInclude Include="OysterCallback.h" />
<ClInclude Include="PostBox\IPostBox.h" />
<ClInclude Include="PostBox\PostBox.h" />
<ClInclude Include="Queue.h" />
<ClInclude Include="Resource\OysterResource.h" />
<ClInclude Include="Resource\OResource.h" />
<ClInclude Include="ThreadSafeQueue.h" />

View File

@ -101,5 +101,8 @@
<ClInclude Include="OysterCallback.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Queue.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -24,7 +24,8 @@ namespace Oyster
virtual bool IsEmpty();
private:
Oyster::Queue::ThreadSafeQueue<T> messages;
Utility::Container::ThreadSafeQueue<T> messages;
//Utility::Container::ThreadSafeQueue<T> messages;
};

181
Code/Misc/Queue.h Normal file
View File

@ -0,0 +1,181 @@
#ifndef MISC_QUEUE_H
#define MISC_QUEUE_H
////////////////////////////////////////////
// Created by Sam Svensson 2013
/////////////////////////////////////////////
#include "IQueue.h"
namespace Utility
{
namespace Container
{
template <typename Type>
class Queue : public IQueue<Type>
{
public:
Queue<Type>();
virtual ~Queue<Type>();
virtual void Push( Type item );
virtual Type Pop();
virtual Type Front();
virtual Type Back();
virtual int Size();
virtual bool IsEmpty();
virtual void Swap( IQueue<Type> &queue );
private:
class Node
{
public:
Type item;
Node *next;
Node(Type item){ this->item = item; this->next = NULL; };
~Node() {};
};
Node *front;
Node *back;
int nrOfNodes;
};
//----------------------------------------------
//implemented template functions
//----------------------------------------------
template < typename Type >
Queue<Type>::Queue()
{
this->front = NULL;
this->back = NULL;
this->nrOfNodes = 0;
}
template < typename Type >
Queue<Type>::~Queue()
{
if(!nrOfNodes) return;
if(this->front != NULL)
{
Node *destroyer;
Node *walker = this->front;
for(int i = 0; i < this->nrOfNodes; i++)
{
destroyer = walker;
walker = walker->next;
delete destroyer;
}
this->front = NULL;
this->back = NULL;
}
}
template < typename Type >
void Queue<Type>::Push(Type item)
{
Node *e = new Node(item);
if(this->front != NULL)
{
this->back->next = e;
this->back = e;
}
else
{
this->front = e;
this->back = e;
}
this->nrOfNodes++;
}
template < typename Type >
Type Queue<Type>::Pop()
{
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;
}
template < typename Type >
Type Queue<Type>::Front()
{
Type temp = this->front->item;
return temp;
}
template < typename Type >
Type Queue<Type>::Back()
{
Type temp = this->back->item;
return temp;
}
template < typename Type >
int Queue<Type>::Size()
{
int size = this->nrOfNodes;
return size;
}
template < typename Type >
bool Queue<Type>::IsEmpty()
{
if(nrOfNodes == 0 || this->front == NULL)
{
return true;
}
return false;
}
template < typename Type >
void Queue<Type>::Swap(IQueue<Type> &queue )
{
int prevNrOfNodes = this->nrOfNodes;
int size = queue.Size();
for(int i = 0; i < size; i++)
{
this->Push(queue.Pop());
}
for(int i = 0; i < prevNrOfNodes; i++)
{
queue.Push(this->Pop());
}
}
}
}
#endif

View File

@ -71,13 +71,13 @@ namespace Oyster
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackObject<bool, void>* worker, bool start, bool detach = false);
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach = false);
OYSTER_THREAD_ERROR Start();
OYSTER_THREAD_ERROR Stop(bool wait = false);
OYSTER_THREAD_ERROR Stop();
OYSTER_THREAD_ERROR Pause();
OYSTER_THREAD_ERROR Pause(int mSec);
OYSTER_THREAD_ERROR Resume();
OYSTER_THREAD_ERROR SetWorker(IThreadObject* worker = 0);
OYSTER_THREAD_ERROR SetWorker(ThreadFnc worker = 0);
OYSTER_THREAD_ERROR Terminate(bool wait = true);
OYSTER_THREAD_ERROR Terminate();
OYSTER_THREAD_ERROR Wait();
OYSTER_THREAD_ERROR Wait(int mSec);
OYSTER_THREAD_ERROR Swap(const OysterThread* other);

View File

@ -15,8 +15,6 @@ using namespace Oyster::Thread;
using namespace Utility::DynamicMemory;
#pragma region Declerations
enum OYSTER_THREAD_STATE
@ -51,8 +49,8 @@ using namespace Utility::DynamicMemory;
OwnerContainer ownerObj; //
std::atomic<int> msec; //<! A timer in miliseconds.
std::timed_mutex threadFunctionLock;
//std::mutex threadWaitFunctionLock;
//std::timed_mutex threadFunctionLock;
std::mutex threadStopMutex;
};
/** A typical Oyster thread function */
@ -60,8 +58,9 @@ using namespace Utility::DynamicMemory;
struct RefData
{
//std::mutex threadWaitFunctionLock;
std::mutex threadWaitFunctionLock;
bool isCreated;
bool isAlive;
ThreadData *threadData;
std::thread workerThread;
@ -73,74 +72,25 @@ using namespace Utility::DynamicMemory;
~RefData()
{
//threadWaitFunctionLock.lock();
Terminate(true);
Terminate();
//threadWaitFunctionLock.unlock();
}
OYSTER_THREAD_ERROR Terminate(bool wait)
OYSTER_THREAD_ERROR Terminate()
{
if(!threadData) return OYSTER_THREAD_ERROR_SUCCESS;
this->threadData->state = OYSTER_THREAD_STATE_DEAD;
if(wait)
{
if(std::this_thread::get_id() != this->workerThread.get_id())
if(this->workerThread.joinable())
{
this->workerThread.join();
this->isCreated = false;
delete this->threadData;
this->threadData = 0;
}
}
else
{
if(this->workerThread.joinable())
this->workerThread.detach();
}
return OYSTER_THREAD_ERROR_SUCCESS;
}
//OYSTER_THREAD_ERROR Create(ThreadFunction fnc, IThreadObject* worker, bool start, bool detach)
//{
// if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
//
// threadData = new ThreadData();
// if(start)
// this->threadData->state = OYSTER_THREAD_STATE_NORMAL;
// else
// this->threadData->state = OYSTER_THREAD_STATE_IDLE;
// threadData->owner = worker;
// threadData->prio = OYSTER_THREAD_PRIORITY_3;
//
// workerThread = std::thread(fnc, this->threadData);
//
// if(detach)
// this->workerThread.detach();
//
// isCreated = true;
//
// return OYSTER_THREAD_ERROR_SUCCESS;
//}
//OYSTER_THREAD_ERROR Create(ThreadFunction fnc, Oyster::Callback::OysterCallback<bool, void> worker, bool start, bool detach)
//{
// if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
//
// threadData = new ThreadData();
// if(start)
// this->threadData->state = OYSTER_THREAD_STATE_NORMAL;
// else
// this->threadData->state = OYSTER_THREAD_STATE_IDLE;
// threadData->ownerObj = worker;
// threadData->prio = OYSTER_THREAD_PRIORITY_3;
//
// workerThread = std::thread(fnc, this->threadData);
//
// if(detach)
// this->workerThread.detach();
//
// isCreated = true;
//
// return OYSTER_THREAD_ERROR_SUCCESS;
//}
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
{
if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
@ -155,8 +105,8 @@ using namespace Utility::DynamicMemory;
workerThread = std::thread(fnc, this->threadData);
if(detach)
this->workerThread.detach();
//if(detach)
// this->workerThread.detach();
isCreated = true;
@ -171,9 +121,7 @@ using namespace Utility::DynamicMemory;
PrivateData(){}
~PrivateData()
{
if(data)
if(data->threadData)
memset(&data->threadData->ownerObj, 0, sizeof(OwnerContainer));
data.Release();
}
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
{
@ -181,12 +129,12 @@ using namespace Utility::DynamicMemory;
data = new RefData();
return data->Create(fnc, worker, start, detach);
}
OYSTER_THREAD_ERROR Terminate(bool wait)
OYSTER_THREAD_ERROR Terminate()
{
if(!data)
return OYSTER_THREAD_ERROR_FAILED;
return data->Terminate(wait);
return data->Terminate();
}
};
@ -248,7 +196,8 @@ using namespace Utility::DynamicMemory;
if(w->ownerObj.value.obj) w->ownerObj.value.obj->ThreadExit();
w->state = OYSTER_THREAD_STATE_DEAD;
delete w;
//delete w;
}
};
@ -295,31 +244,6 @@ OYSTER_THREAD_ERROR OysterThread::Create(ThreadFnc worker, bool start, bool deta
return this->privateData->Create(ThreadHelp::ThreadingFunction, c, start, detach);
}
/*
OYSTER_THREAD_ERROR OysterThread::Create(Oyster::Callback::CallbackObject<bool, void>* worker, bool start, bool detach)
{
if(!this->privateData)
this->privateData = new PrivateData();
Oyster::Callback::OysterCallback<> temp;
temp.callbackType = Oyster::Callback::CallbackType_Object;
temp.value = worker;
return this->privateData->Create(ThreadHelp::ThreadingFunction, temp, start, detach);
}
OYSTER_THREAD_ERROR OysterThread::Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach)
{
if(!this->privateData)
this->privateData = new PrivateData();
Oyster::Callback::OysterCallback<> temp;
temp.callbackType = Oyster::Callback::CallbackType_Function;
temp.value = worker;
return this->privateData->Create(ThreadHelp::ThreadingFunction, temp, start, detach);
}
*/
OYSTER_THREAD_ERROR OysterThread::Start()
{
if(!this->privateData->data->threadData->ownerObj)
@ -332,9 +256,9 @@ OYSTER_THREAD_ERROR OysterThread::Start()
return OYSTER_THREAD_ERROR_SUCCESS;
}
OYSTER_THREAD_ERROR OysterThread::Stop(bool wait)
OYSTER_THREAD_ERROR OysterThread::Stop()
{
return this->Terminate(wait);
return this->Terminate();
}
OYSTER_THREAD_ERROR OysterThread::Pause()
{
@ -373,9 +297,9 @@ OYSTER_THREAD_ERROR OysterThread::SetWorker(ThreadFnc worker)
return OYSTER_THREAD_ERROR_SUCCESS;;
}
OYSTER_THREAD_ERROR OysterThread::Terminate(bool wait)
OYSTER_THREAD_ERROR OysterThread::Terminate()
{
return this->privateData->Terminate(wait);
return this->privateData->Terminate();
}
OYSTER_THREAD_ERROR OysterThread::Wait()
{
@ -385,9 +309,6 @@ OYSTER_THREAD_ERROR OysterThread::Wait()
if( this->privateData->data->workerThread.get_id() == std::this_thread::get_id())
return OYSTER_THREAD_ERROR_ThreadCannotWaintOnItselfe;
//this->privateData->data->threadData->threadFunctionLock.lock();
//this->privateData->data->threadData->threadFunctionLock.unlock();
return OYSTER_THREAD_ERROR_SUCCESS;
}
OYSTER_THREAD_ERROR OysterThread::Wait(int msec)
@ -395,9 +316,6 @@ OYSTER_THREAD_ERROR OysterThread::Wait(int msec)
if(this->privateData->data->workerThread.get_id() == std::this_thread::get_id())
return OYSTER_THREAD_ERROR_ThreadCannotWaintOnItselfe;
//if(this->privateData->data->threadData->threadFunctionLock.try_lock_for(std::chrono::milliseconds(msec)))
// this->privateData->data->threadData->threadFunctionLock.unlock();
return OYSTER_THREAD_ERROR_SUCCESS;
}
OYSTER_THREAD_ERROR OysterThread::Swap(const OysterThread* other)

View File

@ -10,11 +10,10 @@
/////////////////////////////////////////////
#include "IQueue.h"
#include "Thread/OysterMutex.h"
namespace Oyster
namespace Utility
{
namespace Queue
namespace Container
{
template <typename Type>
class ThreadSafeQueue : public IQueue<Type>

View File

@ -293,6 +293,7 @@ namespace Utility
this->_ptr = p;
if(p) this->_rc->Incref();
else this->_rc = 0;
}
return *this;
}

View File

@ -22,10 +22,10 @@ struct CustomNetProtocol::PrivateData
size_t size = strlen(i->second.value.netCharPtr);
if(size == 0) continue;
attributes[i->first];
attributes[i->first].value.netCharPtr = new char[size + 1];
//strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr);
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
attributes[i->first].type = NetAttributeType_CharArray;
}
else
{

View File

@ -63,9 +63,8 @@ struct ClientDataContainer
}
~ClientDataContainer()
{
thread.Stop();
thread.Wait();
connection.Disconnect();
thread.Stop();
callbackType = NetworkProtocolCallbackType_Unknown;
ShutdownWinSock();
@ -244,6 +243,7 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[])
void NetworkClient::Disconnect()
{
privateData->data->connection.Disconnect();
privateData->data->thread.Terminate();
}
bool NetworkClient::IsConnected()

View File

@ -115,7 +115,7 @@ void NetworkServer::PrivateData::Stop()
started = false;
thread.Stop(true);
thread.Stop();
}
void NetworkServer::PrivateData::Shutdown()

View File

@ -108,6 +108,7 @@ int Connection::InitiateClient()
int Connection::Disconnect()
{
if(this->closed) return -1;
int val = CloseSocket(this->socket);
this->socket = -1;
this->closed = true;
@ -117,6 +118,8 @@ int Connection::Disconnect()
int Connection::Send(OysterByte &bytes)
{
if(this->closed) return -1;
int nBytes;
nBytes = send(this->socket, bytes, bytes.GetSize(), 0);
@ -130,6 +133,7 @@ int Connection::Send(OysterByte &bytes)
int Connection::Recieve(OysterByte &bytes)
{
if(this->closed) return -1;
int nBytes;
bytes.Resize(1000);
@ -150,6 +154,8 @@ int Connection::Recieve(OysterByte &bytes)
//Listen will only return the correct socket or -1 for failure.
int Connection::Listen()
{
if(this->closed) return -1;
int clientSocket;
if((clientSocket = (int)accept(this->socket, NULL, NULL)) == INVALID_SOCKET)
{
@ -205,5 +211,14 @@ int Connection::InitiateSocket()
return WSAGetLastError();
}
int flag = 1;
int result = setsockopt(this->socket, /* socket affected */
IPPROTO_TCP, /* set option at TCP level */
TCP_NODELAY, /* name of option */
(char *) &flag, /* the cast is historical cruft */
sizeof(int)); /* length of option value */
if (result < 0)
return -1;
return 0;
}

View File

@ -6,11 +6,14 @@ using namespace Oyster::Thread;
Listener::Listener()
{
this->port = -1;
this->isListening = false;
connection = NULL;
}
Listener::Listener(Oyster::Network::IPostBox<int>* postBox)
{
this->isListening = false;
connection = NULL;
this->postBox = postBox;
}
@ -19,9 +22,11 @@ Listener::~Listener()
{
if(connection)
{
this->thread.Terminate(false);
this->isListening = false;
this->thread.Terminate();
delete connection;
connection = 0;
this->port = -1;
}
}
@ -36,6 +41,8 @@ bool Listener::Init(unsigned int port)
return false;
}
this->port = port;
this->isListening = true;
return true;
}
@ -52,6 +59,11 @@ bool Listener::Init(unsigned int port, bool start)
return false;
}
if(start)
{
this->isListening = true;
}
this->port = port;
return true;
}
@ -62,17 +74,18 @@ bool Listener::Start()
return false;
}
this->isListening = true;
return true;
}
void Listener::Stop()
{
thread.Stop();
StopListen();
}
void Listener::Shutdown()
{
thread.Stop(false);
StopListen();
}
void Listener::SetPostBox(Oyster::Network::IPostBox<int>* postBox)
@ -87,6 +100,10 @@ int Listener::Accept()
int clientSocket = -1;
clientSocket = connection->Listen();
if(!this->isListening.load())
{
return -1;
}
if(clientSocket != -1)
{
stdMutex.lock();
@ -96,13 +113,26 @@ int Listener::Accept()
return clientSocket;
}
void Listener::StopListen()
{
if(this->connection && this->connection->IsConnected())
{
this->isListening = false;
Connection c;
c.InitiateClient();
c.Connect(this->port, "127.0.0.1");
}
}
bool Listener::DoWork()
{
if(!this->connection) return false;
int result = Accept();
if(result == -1)
if(!this->isListening.load())
{
return false;
}
else if(result == -1)
{
//Do something?
}

View File

@ -11,6 +11,7 @@
#include "../../Misc/Thread/OysterThread.h"
#include "../../Misc/Thread/OysterMutex.h"
#include "../../Misc/Utilities.h"
#include <atomic>
namespace Oyster
{
@ -41,6 +42,7 @@ namespace Oyster
//Function that runs in the thread.
int Accept();
void StopListen();
private:
::Oyster::Network::Connection* connection;
@ -50,7 +52,8 @@ namespace Oyster
std::mutex stdMutex;
IPostBox<int>* postBox;
std::atomic<bool> isListening;
int port;
};
}
}

View File

@ -27,7 +27,7 @@ namespace Oyster
virtual bool IsFull();
private:
Oyster::Queue::ThreadSafeQueue<T> messages;
Utility::Container::ThreadSafeQueue<T> messages;
};

View File

@ -4,6 +4,7 @@
#include <iostream>
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace Utility::Container;
using namespace Utility::DynamicMemory;
ThreadedClient::ThreadedClient()

View File

@ -7,6 +7,7 @@
#include "Dx11Includes.h"
#include <sstream>
#include "OysterMath.h"
#include <vld.h>
namespace Oyster
{

View File

@ -51,21 +51,36 @@ namespace Oyster
{
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload);
if(data)
{
if(ForceReload && VSMap.count(name))
{
VS[VSMap[name]] = (ID3D11VertexShader*)data;
}
else
{
VSMap[name] = VS.size();
VS.push_back((ID3D11VertexShader*)data);
}
}
}
break;
case Oyster::Graphics::Core::PipelineManager::Hull:
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderH, -1, ForceReload);
if(!HSMap.count(name) || ForceReload)
{
if(data!=0)
{
if(ForceReload && HSMap.count(name))
{
HS[HSMap[name]] = (ID3D11HullShader*)data;
}
else
{
HSMap[name] = HS.size();
HS.push_back((ID3D11HullShader*)data);
}
}
}
break;
case Oyster::Graphics::Core::PipelineManager::Domain:
@ -73,43 +88,72 @@ namespace Oyster
if(!DSMap.count(name) || ForceReload)
{
if(data!=0)
{
if(ForceReload && DSMap.count(name))
{
DS[DSMap[name]] = (ID3D11DomainShader*)data;
}
else
{
DSMap[name] = DS.size();
DS.push_back((ID3D11DomainShader*)data);
}
}
}
break;
case Oyster::Graphics::Core::PipelineManager::Geometry:
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderG, -1, ForceReload);
if(!GSMap.count(name) || ForceReload)
{
if(data!=0)
{
if(ForceReload && GSMap.count(name))
{
GS[GSMap[name]] = (ID3D11GeometryShader*)data;
}
else
{
GSMap[name] = GS.size();
GS.push_back((ID3D11GeometryShader*)data);
}
}
}
break;
case Oyster::Graphics::Core::PipelineManager::Pixel:
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderP, -1, ForceReload);
if(!PSMap.count(name) || ForceReload)
{
if(data!=0)
{
if(ForceReload && PSMap.count(name))
{
PS[PSMap[name]] = (ID3D11PixelShader*)data;
}
else
{
PSMap[name] = PS.size();
PS.push_back((ID3D11PixelShader*)data);
}
}
}
break;
case Oyster::Graphics::Core::PipelineManager::Compute:
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderC, -1, ForceReload);
if(!CSMap.count(name) || ForceReload)
{
if(data!=0)
{
if(ForceReload && CSMap.count(name))
{
CS[CSMap[name]] = (ID3D11ComputeShader*)data;
}
else
{
CSMap[name] = CS.size();
CS.push_back((ID3D11ComputeShader*)data);
}
}
}
break;
default:
@ -375,9 +419,9 @@ namespace Oyster
void Core::PipelineManager::CleanPipeline()
{
deviceContext->VSSetShaderResources(0,16,Core::srvNULL);
deviceContext->GSSetShaderResources(0,16,Core::srvNULL);
deviceContext->PSSetShaderResources(0,16,Core::srvNULL);
//deviceContext->VSSetShaderResources(0,16,Core::srvNULL);
//deviceContext->GSSetShaderResources(0,16,Core::srvNULL);
//deviceContext->PSSetShaderResources(0,16,Core::srvNULL);
deviceContext->CSSetShaderResources(0,16,Core::srvNULL);
deviceContext->CSSetUnorderedAccessViews(0,8,Core::uavNULL,NULL);
deviceContext->OMSetRenderTargets(8,Core::rtvNULL, NULL);

View File

@ -20,6 +20,12 @@ namespace Oyster
Oyster::Math::Matrix P;
};
struct PerModel
{
Math::Matrix WV;
Math::Matrix WVP;
};
struct FinalVertex
{
Oyster::Math::Float3 pos;
@ -34,9 +40,10 @@ namespace Oyster
struct LightConstants
{
Math::Float4x4 InvProj;
Math::Float4x4 Proj;
Math::Float2 Pixels;
int Lights;
float Pad;
float SSAORadius;
Oyster::Math::Float4x4 View;
};

View File

@ -6,6 +6,7 @@
#include "../FileLoader/ObjReader.h"
#include "../../Misc/Resource/OysterResource.h"
#include "../FileLoader/GeneralLoader.h"
#include <vld.h>
namespace Oyster
{
@ -26,12 +27,6 @@ namespace Oyster
{
return API::Fail;
}
#ifdef _DEBUG
if(Render::Resources::Debug::Init() == Core::Init::Fail)
{
return API::Fail;
}
#endif
Render::Resources::Deffered::Init();
Render::Preparations::Basic::SetViewPort();
@ -62,12 +57,12 @@ namespace Oyster
void API::RenderScene(Model::Model models[], int count)
{
Render::Rendering::Basic::RenderScene(models,count);
Render::Rendering::Basic::RenderScene(models,count, View, Projection);
}
void API::RenderModel(Model::Model& m)
{
Render::Rendering::Basic::RenderScene(&m,1);
Render::Rendering::Basic::RenderScene(&m,1, View, Projection);
}
void API::EndFrame()
@ -103,10 +98,6 @@ namespace Oyster
SAFE_DELETE(Core::viewPort);
Oyster::Resource::OysterResource::Clean();
Oyster::Graphics::Core::PipelineManager::Clean();
#ifdef _DEBUG
Oyster::Graphics::Render::Resources::Debug::Clean();
#endif
Oyster::Graphics::Render::Resources::Deffered::Clean();
SAFE_RELEASE(Core::depthStencil);
@ -128,5 +119,13 @@ namespace Oyster
{
Lights.clear();
}
#ifdef _DEBUG
API::State API::ReloadShaders()
{
Render::Resources::Deffered::InitShaders();
return State::Sucsess;
}
#endif
}
}

View File

@ -4,7 +4,7 @@
#include "..\Model\Model.h"
#include "OysterMath.h"
#include <Windows.h>
//#include <vld.h>
#include <vld.h>
#ifdef GFX_DLL_EXPORT
#define GFX_DLL_USAGE __declspec(dllexport)
@ -29,23 +29,40 @@ namespace Oyster
};
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
#ifdef _DEBUG
static State ReloadShaders();
#endif
//! @todo Memory Leaks
//! @brief Clean Resources and release all memory
static void Clean();
//! @brief Sets the view matrix to use next frame
static void SetView(Oyster::Math::Float4x4& View);
//! @brief Sets the projection matrix to use next frame
static void SetProjection(Oyster::Math::Float4x4& Projection);
//! @brief will internally use last values from SetView and SetProjection
static void NewFrame();
//! @brief Renders a list of models
static void RenderScene(Oyster::Graphics::Model::Model models[], int count);
//! @brief Renders a single model
static void RenderModel(Oyster::Graphics::Model::Model& model);
//! @brief Performs light calculations, post effects and presents the scene
static void EndFrame();
//! @brief Creates a model from the supplied file, note: do not include .obj
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
//! @brief deletes a model and relases the models resources
static void DeleteModel(Oyster::Graphics::Model::Model* model);
//! @brief adds a light to the scene
static void AddLight(Definitions::Pointlight light);
//! @brief removes all lights from the scene
static void ClearLights();
//! @brief Sets Options to the graphics, note: currently unused
static State SetOptions(Option);
};
}

View File

@ -39,11 +39,12 @@ void Oyster::Graphics::Loading::UnloadTexture(void* data)
void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out)
{
FileLoaders::ObjReader* obj = FileLoaders::ObjReader::LoadFile(filename);
FileLoaders::ObjReader obj;
obj.LoadFile(filename);
Model::ModelInfo* info = new Model::ModelInfo();
Oyster::FileLoaders::ObjReader::Vertex* vdata;
int count;
obj->GetVertexData(&vdata, count);
obj.GetVertexData(&vdata, count);
info->Vertices = new Core::Buffer();
Core::Buffer::BUFFER_INIT_DESC desc;
desc.ElementSize = sizeof(FileLoaders::ObjReader::Vertex);

View File

@ -3,31 +3,16 @@
#include "..\Core\Core.h"
#include <fstream>
#include <map>
#include <vld.h>
using namespace std;
using namespace Oyster::FileLoaders;
using namespace Oyster;
using namespace Oyster::Math;
ObjReader *ObjReader::LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform)
void ObjReader::LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform)
{
static std::map<std::wstring, ObjReader *> cache;
ObjReader *reader = NULL;
if (cache.count(fileName))
{
reader = cache[fileName];
}
else
{
reader = new ObjReader();
reader->ParseFile(fileName + L".obj", transform);
cache[fileName] = reader;
}
return reader;
this->ParseFile(fileName + L".obj", transform);
}
ObjReader::ObjReader(void)
@ -37,6 +22,7 @@ ObjReader::ObjReader(void)
ObjReader::~ObjReader(void)
{
SAFE_DELETE_ARRAY(this->vertices);
}
void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
@ -50,7 +36,6 @@ void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
}
wstring path;
//Utility::String::ExtractDirPath(path,fileName,'\\');
std::vector<Vertex> VertexList;
std::vector<Float3> vList;
@ -74,6 +59,7 @@ void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
if(c==L"v")
{
position = readVertex(offset,s);
//position *= 0.001f;
vList.push_back(position);
}
else if(c==L"vt")

View File

@ -16,7 +16,7 @@ namespace Oyster
Oyster::Math::Float3 Normal;
};
static ObjReader *LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
void LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
ObjReader(void);
~ObjReader(void);

View File

@ -9,9 +9,11 @@ namespace Oyster
{
namespace Model
{
//struct ModelInfo;
struct Model
{
//! do not Edit, linked to render data
//ModelInfo* info;
void* info;
Oyster::Math::Float4x4 WorldMatrix;
bool Visible;

View File

@ -182,7 +182,6 @@
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Render\Resources\Deffered.cpp" />
<ClCompile Include="Render\Resources\Debug.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Core\Core.h" />
@ -196,7 +195,6 @@
<ClInclude Include="Render\Rendering\Render.h" />
<ClInclude Include="Definitions\GraphicalDefinition.h" />
<ClInclude Include="Render\Resources\Deffered.h" />
<ClInclude Include="Render\Resources\Debug.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Misc\Misc.vcxproj">
@ -219,6 +217,16 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="Shader\HLSL\Deffered Shaders\PostPass.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">5.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\HLSL\Deffered Shaders\VertexGatherData.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
@ -268,6 +276,7 @@
<None Include="Shader\HLSL\Deffered Shaders\GBufferHeader.hlsli" />
<None Include="Shader\HLSL\Deffered Shaders\LightCalc.hlsli" />
<None Include="Shader\HLSL\Deffered Shaders\PosManipulation.hlsli" />
<None Include="Shader\HLSL\Deffered Shaders\SSAO.hlsli" />
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -34,6 +34,8 @@ namespace Oyster
lc.Pixels = Core::resolution;
lc.Lights = numLights;
lc.View = View;
lc.Proj = Projection;
lc.SSAORadius = 3;
data = Resources::Deffered::LightConstantsData.Map();
memcpy(data, &lc, sizeof(Definitions::LightConstants));
@ -44,14 +46,18 @@ namespace Oyster
Resources::Deffered::PointLightsData.Unmap();
}
void Basic::RenderScene(Model::Model* models, int count)
void Basic::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection)
{
for(int i = 0; i < count; ++i)
{
if(models[i].Visible)
{
Definitions::PerModel pm;
pm.WV = View * models[i].WorldMatrix;
pm.WVP = Projection * pm.WV;
void* data = Resources::Deffered::ModelData.Map();
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
memcpy(data,&(pm),sizeof(pm));
Resources::Deffered::ModelData.Unmap();
@ -82,6 +88,10 @@ namespace Oyster
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
Core::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
Core::swapChain->Present(0,0);
}
}

View File

@ -17,7 +17,7 @@ namespace Oyster
public:
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
static void RenderScene(Model::Model* models, int count);
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection);
static void EndFrame();
};
}

View File

@ -11,6 +11,9 @@ typedef Oyster::Graphics::Core::Buffer Buffer;
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\Deffered Shaders\\";
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
const int KernelSize = 10;
const int SampleSpread = 8;
namespace Oyster
{
namespace Graphics
@ -20,12 +23,15 @@ namespace Oyster
namespace Resources
{
ID3D11RenderTargetView* Deffered::GBufferRTV[2] = {0};
ID3D11ShaderResourceView* Deffered::GBufferSRV[2] = {0};
ID3D11RenderTargetView* Deffered::GBufferRTV[Deffered::GBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::GBufferSRV[Deffered::GBufferSize] = {0};
ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0};
Shader::RenderPass Deffered::GeometryPass;
Shader::RenderPass Deffered::LightPass;
Shader::RenderPass Deffered::PostPass;
Buffer Deffered::ModelData = Buffer();
Buffer Deffered::VPData = Buffer();
@ -34,7 +40,10 @@ namespace Oyster
Buffer Deffered::PointLightsData = Buffer();
ID3D11ShaderResourceView* Deffered::PointLightView = NULL;
Core::Init::State Deffered::Init()
ID3D11ShaderResourceView* Deffered::SSAOKernel = NULL;
ID3D11ShaderResourceView* Deffered::SSAORandom = NULL;
Core::Init::State Deffered::InitShaders()
{
#ifdef _DEBUG
std::wstring path = PathToHLSL;
@ -47,10 +56,17 @@ namespace Oyster
Core::PipelineManager::Init(path + L"PixelGatherData" + end, ShaderType::Pixel, L"Geometry");
Core::PipelineManager::Init(path + L"VertexGatherData" + end, ShaderType::Vertex, L"Geometry");
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
return Core::Init::State::Success;
}
Core::Init::State Deffered::Init()
{
InitShaders();
//Create Buffers
Buffer::BUFFER_INIT_DESC desc;
desc.ElementSize = sizeof(Oyster::Math::Matrix);
desc.ElementSize = sizeof(Definitions::PerModel);
desc.NumElements = 1;
desc.InitData = NULL;
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
@ -72,7 +88,7 @@ namespace Oyster
desc.Type = Buffer::STRUCTURED_BUFFER;
PointLightsData.Init(desc);
//Create States
////Create States
D3D11_RASTERIZER_DESC rdesc;
rdesc.CullMode = D3D11_CULL_BACK;
rdesc.FillMode = D3D11_FILL_SOLID;
@ -131,11 +147,82 @@ namespace Oyster
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
}
for(int i = 0; i < Resources::Deffered::LBufferSize; ++i)
{
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
}
Buffer* b = &PointLightsData;
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
srand(time(0));
//SSAO
Math::Vector3 kernel[KernelSize];
Math::Vector3 random[SampleSpread];
for(int i = 0;i < KernelSize; ++i)
{
kernel[i] = Oyster::Math::Vector3::null;
while( kernel[i] == Oyster::Math::Vector3::null )
{
kernel[i] = Oyster::Math::Vector3(
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
}
kernel[i].Normalize();
//Create ShaderEffects
float scale = float(i) / float(KernelSize);
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
kernel[i] *= scale;
}
for( int i = 0; i < SampleSpread; ++i)
{
random[i] = Oyster::Math::Vector3::null;
while( random[i] == Oyster::Math::Vector3::null )
{
random[i] = Oyster::Math::Vector3(
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
0.0f);
}
random[i].Normalize();
}
//kernel[0] = Math::Vector3(0,1,1);
//kernel[0].Normalize();
D3D11_TEXTURE1D_DESC T1desc;
T1desc.Width = KernelSize;
T1desc.MipLevels = T1desc.ArraySize = 1;
T1desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
T1desc.Usage = D3D11_USAGE_DEFAULT;
T1desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
T1desc.CPUAccessFlags = 0;
T1desc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA sphere;
sphere.pSysMem = kernel;
D3D11_SUBRESOURCE_DATA rnd;
rnd.pSysMem = random;
ID3D11Texture1D *pTexture1[2];
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1[0] );
Core::device->CreateShaderResourceView( pTexture1[0], 0, &SSAOKernel );
pTexture1[0]->Release();
T1desc.Width = SampleSpread;
Core::device->CreateTexture1D( &T1desc, &rnd, &pTexture1[1] );
Core::device->CreateShaderResourceView( (pTexture1[1]), 0, &SSAORandom );
pTexture1[1]->Release();
////Create ShaderEffects
////---------------- Geometry Pass Setup ----------------------------
GeometryPass.Shaders.Pixel = GetShader::Pixel(L"Geometry");
GeometryPass.Shaders.Vertex = GetShader::Vertex(L"Geometry");
@ -161,8 +248,12 @@ namespace Oyster
}
GeometryPass.depth = Core::depthStencil;
////---------------- Light Pass Setup ----------------------------
LightPass.Shaders.Compute = GetShader::Compute(L"LightPass");
LightPass.UAV.Compute.push_back(Core::backBufferUAV);
for(int i = 0; i<Deffered::LBufferSize;++i)
{
LightPass.UAV.Compute.push_back(LBufferUAV[i]);
}
for(int i = 0; i<Deffered::GBufferSize;++i)
{
LightPass.SRV.Compute.push_back(GBufferSRV[i]);
@ -170,7 +261,16 @@ namespace Oyster
LightPass.SRV.Compute.push_back(Core::depthStencilUAV);
LightPass.CBuffers.Compute.push_back(LightConstantsData);
LightPass.SRV.Compute.push_back(PointLightView);
LightPass.SRV.Compute.push_back(SSAOKernel);
LightPass.SRV.Compute.push_back(SSAORandom);
////---------------- Post Pass Setup ----------------------------
PostPass.Shaders.Compute = GetShader::Compute(L"PostPass");
for(int i = 0; i<Deffered::LBufferSize;++i)
{
PostPass.SRV.Compute.push_back(LBufferSRV[i]);
}
PostPass.UAV.Compute.push_back(Core::backBufferUAV);
return Core::Init::State::Success;
}
@ -181,6 +281,9 @@ namespace Oyster
Resources::Deffered::VPData.~Buffer();
Resources::Deffered::LightConstantsData.~Buffer();
Resources::Deffered::PointLightsData.~Buffer();
SAFE_RELEASE(Resources::Deffered::PointLightView);
SAFE_RELEASE(Deffered::SSAOKernel);
SAFE_RELEASE(Deffered::SSAORandom);
for(int i = 0; i< GBufferSize; ++i)
{
@ -188,22 +291,10 @@ namespace Oyster
SAFE_RELEASE(GBufferSRV[i]);
}
for(int i = 0; i < (int)GeometryPass.CBuffers.Vertex.size(); ++i)
for(int i = 0; i< LBufferSize; ++i)
{
SAFE_RELEASE(GeometryPass.CBuffers.Vertex[i]);
}
for(int i = 0; i < (int)GeometryPass.CBuffers.Pixel.size(); ++i)
{
SAFE_RELEASE(GeometryPass.CBuffers.Pixel[i]);
}
for(int i = 0; i < (int)GeometryPass.CBuffers.Geometry.size(); ++i)
{
SAFE_RELEASE(GeometryPass.CBuffers.Geometry[i]);
}
for(int i = 0; i < (int)GeometryPass.CBuffers.Compute.size(); ++i)
{
SAFE_RELEASE(GeometryPass.CBuffers.Compute[i]);
SAFE_RELEASE(LBufferUAV[i]);
SAFE_RELEASE(LBufferSRV[i]);
}
SAFE_RELEASE(GeometryPass.IAStage.Layout);

View File

@ -15,6 +15,7 @@ namespace Oyster
public:
static const int GBufferSize = 2;
static const int LBufferSize = 3;
static const int MaxLightSize = 100;
//! GBuffers
//! 0 = Diffuse + SpecKoeff
@ -22,8 +23,14 @@ namespace Oyster
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
static Core::PipelineManager::RenderPass GeometryPass;
static Core::PipelineManager::RenderPass LightPass;
static Core::PipelineManager::RenderPass PostPass;
static Core::Buffer ModelData;
static Core::Buffer VPData;
@ -33,7 +40,12 @@ namespace Oyster
static Core::Buffer PointLightsData;
static ID3D11ShaderResourceView* PointLightView;
static ID3D11ShaderResourceView* SSAOKernel;
static ID3D11ShaderResourceView* SSAORandom;
static Core::Init::State Init();
static Core::Init::State InitShaders();
static void Clean();
};
}

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