Sanjay Madhav 8 лет назад
Родитель
Сommit
2271613298
41 измененных файлов с 247 добавлено и 263 удалено
  1. 1 0
      Chapter14/Assets/CatWarrior.gpmesh
  2. 1 0
      Chapter14/Assets/Cube.gpmesh
  3. 8 8
      Chapter14/Assets/English.gptext
  4. 37 1
      Chapter14/Assets/Level3.gplevel
  5. 1 0
      Chapter14/Assets/Plane.gpmesh
  6. 2 1
      Chapter14/Assets/PointLight.gpmesh
  7. 1 0
      Chapter14/Assets/Rifle.gpmesh
  8. 8 8
      Chapter14/Assets/Russian.gptext
  9. 1 0
      Chapter14/Assets/Sphere.gpmesh
  10. 1 0
      Chapter14/Assets/Target.gpmesh
  11. 6 5
      Chapter14/AudioSystem.cpp
  12. 1 1
      Chapter14/AudioSystem.h
  13. 0 0
      Chapter14/Chapter14-windows.sln
  14. 2 2
      Chapter14/Component.cpp
  15. 1 1
      Chapter14/Component.h
  16. 9 13
      Chapter14/Game.cpp
  17. 16 11
      Chapter14/Game.vcxproj
  18. 40 40
      Chapter14/Game.vcxproj.filters
  19. 29 26
      Chapter14/HUD.cpp
  20. 5 5
      Chapter14/HUD.h
  21. 2 2
      Chapter14/LevelLoader.cpp
  22. 0 72
      Chapter14/PlayerMove.cpp
  23. 3 5
      Chapter14/Renderer.cpp
  24. 1 3
      Chapter14/Renderer.h
  25. 3 3
      Chapter14/Shaders/BasicMesh.frag
  26. 2 2
      Chapter14/Shaders/BasicMesh.vert
  27. 2 4
      Chapter14/Shaders/GBufferGlobal.frag
  28. 2 2
      Chapter14/Shaders/GBufferGlobal.vert
  29. 2 2
      Chapter14/Shaders/GBufferPointLight.frag
  30. 2 2
      Chapter14/Shaders/GBufferWrite.frag
  31. 8 9
      Chapter14/Shaders/Phong.frag
  32. 2 2
      Chapter14/Shaders/Phong.vert
  33. 2 2
      Chapter14/Shaders/Skinned.vert
  34. 3 3
      Chapter14/Shaders/Sprite.frag
  35. 2 2
      Chapter14/Shaders/Sprite.vert
  36. 2 2
      Chapter14/SoundEvent.cpp
  37. 1 1
      Chapter14/SoundEvent.h
  38. 3 11
      Chapter14/TargetActor.cpp
  39. 1 2
      Chapter14/TargetActor.h
  40. 27 0
      Chapter14/TargetComponent.cpp
  41. 7 10
      Chapter14/TargetComponent.h

+ 1 - 0
Chapter14/Assets/CatWarrior.gpmesh

@@ -5,6 +5,7 @@
 	"textures":[
 		"Assets/CatWarrior.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[1.017971,17.904892,187.382324,-0.058823,0.921569,-0.380392,48,48,48,48,255,0,0,0,0.222700,0.301400],
 		[0.323929,17.401428,187.014023,-0.380392,0.647059,-0.662745,48,48,48,48,255,0,0,0,0.216700,0.307200],

+ 1 - 0
Chapter14/Assets/Cube.gpmesh

@@ -5,6 +5,7 @@
 	"textures":[
 		"Assets/Cube.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[-0.5,-0.5,-0.5,0,0,-1,0,0],
 		[0.5,-0.5,-0.5,0,0,-1,1,0],

+ 8 - 8
Chapter14/Assets/English.gptext

@@ -1,10 +1,10 @@
 {
-	"TextMap":[
-		{ "key": "PauseTitle", "text": "PAUSED" },
-		{ "key": "ResumeButton", "text": "Resume" },
-		{ "key": "QuitButton", "text": "Quit" },
-		{ "key": "QuitText", "text": "Do you want to quit?" },
-		{ "key": "OKButton", "text": "OK" },
-		{ "key": "CancelButton", "text": "Cancel" }
-	]
+	"TextMap":{
+		"PauseTitle": "PAUSED",
+		"ResumeButton": "Resume",
+		"QuitButton": "Quit",
+		"QuitText": "Do you want to quit?",
+		"OKButton": "OK",
+		"CancelButton": "Cancel"
+	}
 }

+ 37 - 1
Chapter14/Assets/Level3.gplevel

@@ -11113,6 +11113,12 @@
                             200.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11169,6 +11175,12 @@
                             500.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11225,6 +11237,12 @@
                             300.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11281,6 +11299,12 @@
                             300.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11337,6 +11361,12 @@
                             300.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11393,6 +11423,12 @@
                             300.0
                         ]
                     }
+                },
+                {
+                    "type": "TargetComponent",
+                    "properties": {
+                        "updateOrder": 100
+                    }
                 }
             ]
         },
@@ -11435,7 +11471,7 @@
                         "skelFile": "Assets/CatWarrior.gpskel",
                         "animFile": "Assets/CatActionIdle.gpanim",
                         "animPlayRate": 1.0,
-                        "animTime": 0.6669997572898865
+                        "animTime": 0.0
                     }
                 },
                 {

+ 1 - 0
Chapter14/Assets/Plane.gpmesh

@@ -5,6 +5,7 @@
 	"textures":[
 		"Assets/Plane.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[50.000000,50.000000,-0.000000,-0.003922,-0.003922,1.000000,1.000000,1.000000],
 		[50.000000,25.000000,-0.000000,-0.003922,-0.003922,1.000000,1.000000,0.750000],

+ 2 - 1
Chapter14/Assets/PointLight.gpmesh

@@ -4,8 +4,9 @@
 	"shader":"BasicMesh",
 	"textures":[
 		"Assets/Sphere.png",
-      "Assets/Default.png"
+		"Assets/Default.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[0.000000,0.000001,12.500000,-0.003922,-0.003922,0.992157,0.968750,0.000000],
 		[0.475748,-2.391772,12.259815,0.027451,-0.215686,0.968628,0.968750,0.062500],

+ 1 - 0
Chapter14/Assets/Rifle.gpmesh

@@ -5,6 +5,7 @@
 	"textures":[
 		"Assets/Rifle.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[60.004414,-0.751908,0.341529,0.992157,0.003922,-0.003922,0.611816,0.761719],
 		[60.003975,-0.533524,0.153569,0.992157,-0.011765,0.003922,0.614746,0.767578],

+ 8 - 8
Chapter14/Assets/Russian.gptext

@@ -1,10 +1,10 @@
 {
-	"TextMap":[
-		{ "key": "PauseTitle", "text": "ПАУЗА" },
-		{ "key": "ResumeButton", "text": "Продолжить" },
-		{ "key": "QuitButton", "text": "Уволиться" },
-		{ "key": "QuitText", "text": "Вы хотите бросить курить?" },
-		{ "key": "OKButton", "text": "ОК" },
-		{ "key": "CancelButton", "text": "Отмена" }
-	]
+	"TextMap":{
+		"PauseTitle": "ПАУЗА",
+		"ResumeButton": "Продолжить",
+		"QuitButton": "Уволиться",
+		"QuitText": "Вы хотите бросить курить?",
+		"OKButton": "ОК",
+		"CancelButton": "Отмена"
+	}
 }

+ 1 - 0
Chapter14/Assets/Sphere.gpmesh

@@ -6,6 +6,7 @@
 		"Assets/Sphere.png",
       "Assets/Default.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[0.000000,0.000001,12.500000,-0.003922,-0.003922,0.992157,0.968750,0.000000],
 		[0.475748,-2.391772,12.259815,0.027451,-0.215686,0.968628,0.968750,0.062500],

+ 1 - 0
Chapter14/Assets/Target.gpmesh

@@ -5,6 +5,7 @@
 	"textures":[
 		"Assets/Target.png"
 	],
+	"specularPower":100.0,
 	"vertices":[
 		[-0.000004,-25.881905,96.592583,-0.003922,-0.262745,0.960784,0.908691,0.084106],
 		[-25.000004,0.000000,100.000000,-0.003922,-0.003922,1.000000,0.941406,0.115601],

+ 6 - 5
Chapter14/AudioSystem.cpp

@@ -3,13 +3,13 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #include "AudioSystem.h"
 #include <SDL/SDL_log.h>
-#include <FMOD/fmod_studio.hpp>
-#include <FMOD/fmod_errors.h>
+#include <fmod_studio.hpp>
+#include <fmod_errors.h>
 #include <vector>
 
 unsigned int AudioSystem::sNextID = 0;
@@ -92,6 +92,7 @@ void AudioSystem::LoadBank(const std::string& name)
 		&bank // Save pointer to bank
 	);
 
+	const int maxPathLength = 512;
 	if (result == FMOD_OK)
 	{
 		// Add bank to map
@@ -106,12 +107,12 @@ void AudioSystem::LoadBank(const std::string& name)
 			// Get list of event descriptions in this bank
 			std::vector<FMOD::Studio::EventDescription*> events(numEvents);
 			bank->getEventList(events.data(), numEvents, &numEvents);
-			char eventName[512];
+			char eventName[maxPathLength];
 			for (int i = 0; i < numEvents; i++)
 			{
 				FMOD::Studio::EventDescription* e = events[i];
 				// Get the path of this event (like event:/Explosion2D)
-				e->getPath(eventName, 512, nullptr);
+				e->getPath(eventName, maxPathLength, nullptr);
 				// Add to event map
 				mEvents.emplace(eventName, e);
 			}

+ 1 - 1
Chapter14/AudioSystem.h

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #pragma once

+ 0 - 0
Chapter14/Chapter15-windows.sln → Chapter14/Chapter14-windows.sln


+ 2 - 2
Chapter14/Component.cpp

@@ -19,11 +19,11 @@ const char* Component::TypeNames[NUM_COMPONENT_TYPES] = {
 	"FollowCamera",
 	"MeshComponent",
 	"MoveComponent",
-	"PlayerMove",
 	"SkeletalMeshComponent",
 	"SpriteComponent",
 	"MirrorCamera",
-	"PointLightComponent"
+	"PointLightComponent",
+	"TargetComponent"
 };
 
 Component::Component(Actor* owner, int updateOrder)

+ 1 - 1
Chapter14/Component.h

@@ -23,11 +23,11 @@ public:
 		TFollowCamera,
 		TMeshComponent,
 		TMoveComponent,
-		TPlayerMove,
 		TSkeletalMeshComponent,
 		TSpriteComponent,
 		TMirrorCamera,
 		TPointLightComponent,
+		TTargetComponent,
 
 		NUM_COMPONENT_TYPES
 	};

+ 9 - 13
Chapter14/Game.cpp

@@ -48,7 +48,7 @@ bool Game::Initialize()
 
 	// Create the renderer
 	mRenderer = new Renderer(this);
-	if (!mRenderer->Initialize())
+	if (!mRenderer->Initialize(1024.0f, 768.0f))
 	{
 		SDL_Log("Failed to initialize renderer");
 		delete mRenderer;
@@ -112,7 +112,7 @@ void Game::ProcessInput()
 					{
 						HandleKeyPress(event.key.keysym.sym);
 					}
-					else
+					else if (!mUIStack.empty())
 					{
 						mUIStack.back()->
 							HandleKeyPress(event.key.keysym.sym);
@@ -124,7 +124,7 @@ void Game::ProcessInput()
 				{
 					HandleKeyPress(event.button.button);
 				}
-				else
+				else if (!mUIStack.empty())
 				{
 					mUIStack.back()->
 						HandleKeyPress(event.button.button);
@@ -146,7 +146,7 @@ void Game::ProcessInput()
 			}
 		}
 	}
-	else
+	else if (!mUIStack.empty())
 	{
 		mUIStack.back()->ProcessInput(state);
 	}
@@ -414,17 +414,13 @@ void Game::LoadText(const std::string& fileName)
 
 	// Parse the text map
 	const rapidjson::Value& actions = doc["TextMap"];
-	if (actions.IsArray())
+	for (rapidjson::Value::ConstMemberIterator itr = actions.MemberBegin();
+		itr != actions.MemberEnd(); ++itr)
 	{
-		for (rapidjson::SizeType i = 0; i < actions.Size(); i++)
+		if (itr->name.IsString() && itr->value.IsString())
 		{
-			const rapidjson::Value& key = actions[i]["key"];
-			const rapidjson::Value& text = actions[i]["text"];
-
-			if (key.IsString() && text.IsString())
-			{
-				mText.emplace(key.GetString(), text.GetString());
-			}
+			mText.emplace(itr->name.GetString(),
+				itr->value.GetString());
 		}
 	}
 }

+ 16 - 11
Chapter14/Game.vcxproj

@@ -21,11 +21,11 @@
     <ClCompile Include="BoxComponent.cpp" />
     <ClCompile Include="CameraComponent.cpp" />
     <ClCompile Include="Collision.cpp" />
+    <ClCompile Include="Component.cpp" />
     <ClCompile Include="DialogBox.cpp" />
     <ClCompile Include="FollowActor.cpp" />
     <ClCompile Include="FollowCamera.cpp" />
     <ClCompile Include="Font.cpp" />
-    <ClCompile Include="Component.cpp" />
     <ClCompile Include="Game.cpp" />
     <ClCompile Include="GBuffer.cpp" />
     <ClCompile Include="HUD.cpp" />
@@ -39,7 +39,6 @@
     <ClCompile Include="PauseMenu.cpp" />
     <ClCompile Include="PhysWorld.cpp" />
     <ClCompile Include="PlaneActor.cpp" />
-    <ClCompile Include="PlayerMove.cpp" />
     <ClCompile Include="PointLightComponent.cpp" />
     <ClCompile Include="Renderer.cpp" />
     <ClCompile Include="Shader.cpp" />
@@ -48,6 +47,7 @@
     <ClCompile Include="SoundEvent.cpp" />
     <ClCompile Include="SpriteComponent.cpp" />
     <ClCompile Include="TargetActor.cpp" />
+    <ClCompile Include="TargetComponent.cpp" />
     <ClCompile Include="Texture.cpp" />
     <ClCompile Include="UIScreen.cpp" />
     <ClCompile Include="VertexArray.cpp" />
@@ -63,11 +63,11 @@
     <ClInclude Include="BoxComponent.h" />
     <ClInclude Include="CameraComponent.h" />
     <ClInclude Include="Collision.h" />
+    <ClInclude Include="Component.h" />
     <ClInclude Include="DialogBox.h" />
     <ClInclude Include="FollowActor.h" />
     <ClInclude Include="FollowCamera.h" />
     <ClInclude Include="Font.h" />
-    <ClInclude Include="Component.h" />
     <ClInclude Include="Game.h" />
     <ClInclude Include="GBuffer.h" />
     <ClInclude Include="HUD.h" />
@@ -81,7 +81,6 @@
     <ClInclude Include="PauseMenu.h" />
     <ClInclude Include="PhysWorld.h" />
     <ClInclude Include="PlaneActor.h" />
-    <ClInclude Include="PlayerMove.h" />
     <ClInclude Include="PointLightComponent.h" />
     <ClInclude Include="Renderer.h" />
     <ClInclude Include="Shader.h" />
@@ -90,6 +89,7 @@
     <ClInclude Include="SoundEvent.h" />
     <ClInclude Include="SpriteComponent.h" />
     <ClInclude Include="TargetActor.h" />
+    <ClInclude Include="TargetComponent.h" />
     <ClInclude Include="Texture.h" />
     <ClInclude Include="UIScreen.h" />
     <ClInclude Include="VertexArray.h" />
@@ -111,6 +111,7 @@
     <ProjectGuid>{BC508D87-495F-4554-932D-DD68388B63CC}</ProjectGuid>
     <Keyword>Win32Proj</Keyword>
     <RootNamespace>Game</RootNamespace>
+    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -150,21 +151,23 @@
       <Optimization>Disabled</Optimization>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\external\SDL\include;..\external\GLEW\include;..\external\SOIL\include;..\external\rapidjson\include;..\external\FMOD\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <ExceptionHandling>Sync</ExceptionHandling>
+      <AdditionalIncludeDirectories>..\external\SDL\include;..\external\GLEW\include;..\external\SOIL\include;..\external\rapidjson\include;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\inc;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <ExceptionHandling>Sync</ExceptionHandling>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalLibraryDirectories>..\external\SDL\lib\win\x86;..\external\GLEW\lib\win\x86;..\external\SOIL\lib\win\x86;..\external\FMOD\lib\win\x86\Logging;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\external\SDL\lib\win\x86;..\external\GLEW\lib\win\x86;..\external\SOIL\lib\win\x86;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalDependencies>opengl32.lib;SDL2.lib;SDL2main.lib;SDL2_ttf.lib;SDL2_mixer.lib;SDL2_image.lib;glew32.lib;SOIL.lib;fmodL_vc.lib;fmodstudioL_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalOptions>/NODEFAULTLIB:msvcrt.lib %(AdditionalOptions)</AdditionalOptions>
     </Link>
     <PostBuildEvent>
       <Command>xcopy "$(ProjectDir)\..\external\SDL\lib\win\x86\*.dll" "$(OutDir)" /i /s /y
 xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y
-xcopy "$(ProjectDir)\..\external\FMOD\lib\win\x86\Logging\*.dll" "$(OutDir)" /i /s /y</Command>
+xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\lib\*.dll" "$(OutDir)" /i /s /y
+xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib\*.dll" "$(OutDir)" /i /s /y
+</Command>
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -177,7 +180,7 @@ xcopy "$(ProjectDir)\..\external\FMOD\lib\win\x86\Logging\*.dll" "$(OutDir)" /i
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\external\SDL\include;..\external\GLEW\include;..\external\SOIL\include;..\external\rapidjson\include;..\external\FMOD\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\external\SDL\include;..\external\GLEW\include;..\external\SOIL\include;..\external\rapidjson\include;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\inc;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
       <ExceptionHandling>Sync</ExceptionHandling>
     </ClCompile>
@@ -186,13 +189,15 @@ xcopy "$(ProjectDir)\..\external\FMOD\lib\win\x86\Logging\*.dll" "$(OutDir)" /i
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>..\external\SDL\lib\win\x86;..\external\GLEW\lib\win\x86;..\external\SOIL\lib\win\x86;..\external\FMOD\lib\win\x86\Logging;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\external\SDL\lib\win\x86;..\external\GLEW\lib\win\x86;..\external\SOIL\lib\win\x86;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib;C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalDependencies>opengl32.lib;SDL2.lib;SDL2main.lib;SDL2_ttf.lib;SDL2_mixer.lib;SDL2_image.lib;glew32.lib;SOIL.lib;fmodL_vc.lib;fmodstudioL_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PostBuildEvent>
       <Command>xcopy "$(ProjectDir)\..\external\SDL\lib\win\x86\*.dll" "$(OutDir)" /i /s /y
 xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y
-xcopy "$(ProjectDir)\..\external\FMOD\lib\win\x86\Logging\*.dll" "$(OutDir)" /i /s /y</Command>
+xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\lowlevel\lib\*.dll" "$(OutDir)" /i /s /y
+xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib\*.dll" "$(OutDir)" /i /s /y
+</Command>
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 40 - 40
Chapter14/Game.vcxproj.filters

@@ -64,25 +64,25 @@
     <ClCompile Include="CameraComponent.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Collision.cpp">
+    <ClCompile Include="BallActor.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="BoxComponent.cpp">
+    <ClCompile Include="BallMove.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="PhysWorld.cpp">
+    <ClCompile Include="BoxComponent.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="PlayerMove.cpp">
+    <ClCompile Include="Collision.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="TargetActor.cpp">
+    <ClCompile Include="PhysWorld.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="BallActor.cpp">
+    <ClCompile Include="TargetActor.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="BallMove.cpp">
+    <ClCompile Include="DialogBox.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="Font.cpp">
@@ -94,10 +94,16 @@
     <ClCompile Include="PauseMenu.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="TargetComponent.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="UIScreen.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="DialogBox.cpp">
+    <ClCompile Include="Animation.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="BoneTransform.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="FollowActor.cpp">
@@ -106,30 +112,24 @@
     <ClCompile Include="FollowCamera.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="BoneTransform.cpp">
+    <ClCompile Include="SkeletalMeshComponent.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="Skeleton.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Animation.cpp">
+    <ClCompile Include="GBuffer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="MirrorCamera.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="GBuffer.cpp">
+    <ClCompile Include="PointLightComponent.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="LevelLoader.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="SkeletalMeshComponent.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="PointLightComponent.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Actor.h">
@@ -183,25 +183,25 @@
     <ClInclude Include="CameraComponent.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="Collision.h">
+    <ClInclude Include="BallActor.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="BoxComponent.h">
+    <ClInclude Include="BallMove.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="PhysWorld.h">
+    <ClInclude Include="BoxComponent.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="PlayerMove.h">
+    <ClInclude Include="Collision.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="TargetActor.h">
+    <ClInclude Include="PhysWorld.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="BallActor.h">
+    <ClInclude Include="TargetActor.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="BallMove.h">
+    <ClInclude Include="DialogBox.h">
       <Filter>Source Files</Filter>
     </ClInclude>
     <ClInclude Include="Font.h">
@@ -213,45 +213,45 @@
     <ClInclude Include="PauseMenu.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="UIScreen.h">
+    <ClInclude Include="TargetComponent.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="DialogBox.h">
-      <Filter>Source Files</Filter>
-    </ClInclude>
-    <ClInclude Include="FollowActor.h">
+    <ClInclude Include="UIScreen.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="FollowCamera.h">
+    <ClInclude Include="Animation.h">
       <Filter>Source Files</Filter>
     </ClInclude>
     <ClInclude Include="BoneTransform.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="Skeleton.h">
+    <ClInclude Include="FollowActor.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="Animation.h">
+    <ClInclude Include="FollowCamera.h">
       <Filter>Source Files</Filter>
     </ClInclude>
     <ClInclude Include="MatrixPalette.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="MirrorCamera.h">
+    <ClInclude Include="SkeletalMeshComponent.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="GBuffer.h">
+    <ClInclude Include="Skeleton.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="LevelLoader.h">
+    <ClInclude Include="GBuffer.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="SkeletalMeshComponent.h">
+    <ClInclude Include="MirrorCamera.h">
       <Filter>Source Files</Filter>
     </ClInclude>
     <ClInclude Include="PointLightComponent.h">
       <Filter>Source Files</Filter>
     </ClInclude>
+    <ClInclude Include="LevelLoader.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="Shaders\Sprite.frag">
@@ -272,19 +272,19 @@
     <None Include="Shaders\Phong.vert">
       <Filter>Shaders</Filter>
     </None>
-    <None Include="Shaders\Skinned.vert">
-      <Filter>Shaders</Filter>
-    </None>
     <None Include="Shaders\GBufferGlobal.frag">
       <Filter>Shaders</Filter>
     </None>
     <None Include="Shaders\GBufferGlobal.vert">
       <Filter>Shaders</Filter>
     </None>
+    <None Include="Shaders\GBufferPointLight.frag">
+      <Filter>Shaders</Filter>
+    </None>
     <None Include="Shaders\GBufferWrite.frag">
       <Filter>Shaders</Filter>
     </None>
-    <None Include="Shaders\GBufferPointLight.frag">
+    <None Include="Shaders\Skinned.vert">
       <Filter>Shaders</Filter>
     </None>
   </ItemGroup>

+ 29 - 26
Chapter14/HUD.cpp

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #include "HUD.h"
@@ -12,10 +12,10 @@
 #include "Game.h"
 #include "Renderer.h"
 #include "PhysWorld.h"
-#include "TargetActor.h"
 #include "FollowActor.h"
 #include <algorithm>
 #include "GBuffer.h"
+#include "TargetComponent.h"
 
 HUD::HUD(Game* game)
 	:UIScreen(game)
@@ -65,26 +65,21 @@ void HUD::Draw(Shader* shader)
 	//DrawTexture(shader, mHealthBar, Vector2(-350.0f, -350.0f));
 	// Draw the mirror (bottom left)
 	//Texture* mirror = mGame->GetRenderer()->GetMirrorTexture();
-	//DrawTexture(shader, mirror, Vector2(-350.0f, -250.0f), 0.25f, true);
+	//DrawTexture(shader, mirror, Vector2(-350.0f, -250.0f), 1.0f, true);
 	//Texture* tex = mGame->GetRenderer()->GetGBuffer()->GetTexture(GBuffer::EDiffuse);
 	//DrawTexture(shader, tex, Vector2::Zero, 1.0f, true);
 }
 
-void HUD::AddBlipActor(Actor* actor)
+void HUD::AddTargetComponent(TargetComponent* tc)
 {
-	mBlipActors.emplace_back(actor);
+	mTargetComps.emplace_back(tc);
 }
 
-void HUD::RemoveBlipActor(Actor* actor)
+void HUD::RemoveTargetComponent(TargetComponent* tc)
 {
-	auto iter = std::find(mBlipActors.begin(), mBlipActors.end(),
-						  actor);
-	if (iter != mBlipActors.end())
-	{
-		// Swap to end of vector and pop off (avoid erase copies)
-		std::iter_swap(iter, mBlipActors.end() - 1);
-		mBlipActors.pop_back();
-	}
+	auto iter = std::find(mTargetComps.begin(), mTargetComps.end(),
+		tc);
+	mTargetComps.erase(iter);
 }
 
 void HUD::UpdateCrosshair(float deltaTime)
@@ -101,9 +96,13 @@ void HUD::UpdateCrosshair(float deltaTime)
 	if (mGame->GetPhysWorld()->SegmentCast(l, info))
 	{
 		// Is this a target?
-		if (dynamic_cast<TargetActor*>(info.mActor) != nullptr)
+		for (auto tc : mTargetComps)
 		{
-			mTargetEnemy = true;
+			if (tc->GetOwner() == info.mActor)
+			{
+				mTargetEnemy = true;
+				break;
+			}
 		}
 	}
 }
@@ -112,32 +111,36 @@ void HUD::UpdateRadar(float deltaTime)
 {
 	// Clear blip positions from last frame
 	mBlips.clear();
+	
 	// Convert player position to radar coordinates (x forward, z up)
 	Vector3 playerPos = mGame->GetPlayer()->GetPosition();
 	Vector2 playerPos2D(playerPos.y, playerPos.x);
 	// Ditto for player forward
 	Vector3 playerForward = mGame->GetPlayer()->GetForward();
 	Vector2 playerForward2D(playerForward.x, playerForward.y);
+	
 	// Use atan2 to get rotation of radar
 	float angle = Math::Atan2(playerForward2D.y, playerForward2D.x);
 	// Make a 2D rotation matrix
 	Matrix3 rotMat = Matrix3::CreateRotation(angle);
 	
 	// Get positions of blips
-	for (auto actor : mBlipActors)
+	for (auto tc : mTargetComps)
 	{
-		Vector3 actorPos = actor->GetPosition();
-		Vector2 actorPos2D(actorPos.y, actorPos.x);
-		// Calculate vector between player and actor
-		Vector2 playerToActor = actorPos2D - playerPos2D;
+		Vector3 targetPos = tc->GetOwner()->GetPosition();
+		Vector2 actorPos2D(targetPos.y, targetPos.x);
+		
+		// Calculate vector between player and target
+		Vector2 playerToTarget = actorPos2D - playerPos2D;
+		
 		// See if within range
-		if (playerToActor.LengthSq() <= (mRadarRange * mRadarRange))
+		if (playerToTarget.LengthSq() <= (mRadarRange * mRadarRange))
 		{
-			// Convert playerToActor into an offset from
+			// Convert playerToTarget into an offset from
 			// the center of the on-screen radar
-			Vector2 blipPos = playerToActor;
-			blipPos *= 1.0f/mRadarRange;
-			blipPos *= mRadarRadius;
+			Vector2 blipPos = playerToTarget;
+			blipPos *= mRadarRadius/mRadarRange;
+			
 			// Rotate blipPos
 			blipPos = Vector2::Transform(blipPos, rotMat);
 			mBlips.emplace_back(blipPos);

+ 5 - 5
Chapter14/HUD.h

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #pragma once
@@ -20,8 +20,8 @@ public:
 	void Update(float deltaTime) override;
 	void Draw(class Shader* shader) override;
 	
-	void AddBlipActor(class Actor* actor);
-	void RemoveBlipActor(class Actor* actor);
+	void AddTargetComponent(class TargetComponent* tc);
+	void RemoveTargetComponent(class TargetComponent* tc);
 protected:
 	void UpdateCrosshair(float deltaTime);
 	void UpdateRadar(float deltaTime);
@@ -33,8 +33,8 @@ protected:
 	class Texture* mBlipTex;
 	class Texture* mRadarArrow;
 	
-	// Actors that should appear on radar
-	std::vector<class Actor*> mBlipActors;
+	// All the target components in the game
+	std::vector<class TargetComponent*> mTargetComps;
 	// 2D offsets of blips relative to radar
 	std::vector<Vector2> mBlips;
 	// Adjust range of radar and radius

+ 2 - 2
Chapter14/LevelLoader.cpp

@@ -25,11 +25,11 @@
 #include "FollowCamera.h"
 #include "MeshComponent.h"
 #include "MoveComponent.h"
-#include "PlayerMove.h"
 #include "SkeletalMeshComponent.h"
 #include "SpriteComponent.h"
 #include "MirrorCamera.h"
 #include "PointLightComponent.h"
+#include "TargetComponent.h"
 #include <rapidjson/stringbuffer.h>
 #include <rapidjson/prettywriter.h>
 
@@ -54,11 +54,11 @@ std::unordered_map<std::string, std::pair<int, ComponentFunc>> LevelLoader::sCom
 	{ "FollowCamera", { Component::TFollowCamera, &Component::Create<FollowCamera> } },
 	{ "MeshComponent", { Component::TMeshComponent, &Component::Create<MeshComponent> } },
 	{ "MoveComponent", { Component::TMoveComponent, &Component::Create<MoveComponent> } },
-	{ "PlayerMove", { Component::TPlayerMove, &Component::Create<PlayerMove> } },
 	{ "SkeletalMeshComponent", { Component::TSkeletalMeshComponent, &Component::Create<SkeletalMeshComponent> } },
 	{ "SpriteComponent", { Component::TSpriteComponent, &Component::Create<SpriteComponent> } },
 	{ "MirrorCamera", { Component::TMirrorCamera, &Component::Create<MirrorCamera> } },
 	{ "PointLightComponent", { Component::TPointLightComponent, &Component::Create<PointLightComponent> }},
+	{ "TargetComponent",{ Component::TTargetComponent, &Component::Create<TargetComponent> } },
 };
 
 bool LevelLoader::LoadLevel(Game* game, const std::string& fileName)

+ 0 - 72
Chapter14/PlayerMove.cpp

@@ -1,72 +0,0 @@
-// ----------------------------------------------------------------
-// From Game Programming in C++ by Sanjay Madhav
-// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-// 
-// Released under the BSD License
-// See LICENSE.txt for full details.
-// ----------------------------------------------------------------
-
-#include "PlayerMove.h"
-#include "Actor.h"
-#include "Game.h"
-#include "PhysWorld.h"
-
-PlayerMove::PlayerMove(Actor* owner)
-	:MoveComponent(owner)
-{
-}
-
-void PlayerMove::Update(float deltaTime)
-{
-	const float zOffset = 50.0f;
-	const float segmentLength = 100.0f;
-	PhysWorld* phys = mOwner->GetGame()->GetPhysWorld();
-
-	// Test whether forward/strafe movement are valid
-	// Start point is player position +z offset
-	Vector3 start = mOwner->GetPosition();
-	start.z += zOffset;
-	// For forward/back
-	if (!Math::NearZero(mForwardSpeed))
-	{
-		// End point is in direction of forward/backward vector
-		Vector3 dir = mOwner->GetForward();
-		if (mForwardSpeed < 0.0f)
-		{
-			dir *= -1.0f;
-		}
-		Vector3 end = start + dir * segmentLength;
-		// Create line segment
-		LineSegment l(start, end);
-		// Test segment vs world
-		PhysWorld::CollisionInfo info;
-		if (phys->SegmentCast(l, info))
-		{
-			// If we collided, don't allow movement
-			mForwardSpeed = 0.0f;
-		}
-	}
-	// For strafing
-	if (!Math::NearZero(mStrafeSpeed))
-	{
-		// End point is in direction of right/left vector
-		Vector3 dir = mOwner->GetRight();
-		if (mStrafeSpeed < 0.0f)
-		{
-			dir *= -1.0f;
-		}
-		Vector3 end = start + dir * segmentLength;
-		// Create line segment
-		LineSegment l(start, end);
-		// Test segment vs world
-		PhysWorld::CollisionInfo info;
-		if (phys->SegmentCast(l, info))
-		{
-			// If we collided, don't allow movement
-			mStrafeSpeed = 0.0f;
-		}
-	}
-
-	// Now update move component based on modified speeds
-	MoveComponent::Update(deltaTime);
-}

+ 3 - 5
Chapter14/Renderer.cpp

@@ -38,10 +38,10 @@ Renderer::~Renderer()
 {
 }
 
-bool Renderer::Initialize()
+bool Renderer::Initialize(float screenWidth, float screenHeight)
 {
-	mScreenWidth = 1024.0f;
-	mScreenHeight = 768.0f;
+	mScreenWidth = screenWidth;
+	mScreenHeight = screenHeight;
 
 	// Set OpenGL attributes
 	// Use the core OpenGL profile
@@ -550,8 +550,6 @@ void Renderer::SetLightUniforms(Shader* shader, const Matrix4& view)
 		mDirLight.mDiffuseColor);
 	shader->SetVectorUniform("uDirLight.mSpecColor",
 		mDirLight.mSpecColor);
-	shader->SetFloatUniform("uDirLight.mSpecPower",
-		mDirLight.mSpecPower);
 }
 
 Vector3 Renderer::Unproject(const Vector3& screenPoint) const

+ 1 - 3
Chapter14/Renderer.h

@@ -21,8 +21,6 @@ struct DirectionalLight
 	Vector3 mDiffuseColor;
 	// Specular color
 	Vector3 mSpecColor;
-	// Specular power
-	float mSpecPower = 0.0f;
 };
 
 class Renderer
@@ -31,7 +29,7 @@ public:
 	Renderer(class Game* game);
 	~Renderer();
 
-	bool Initialize();
+	bool Initialize(float screenWidth, float screenHeight);
 	void Shutdown();
 	void UnloadData();
 

+ 3 - 3
Chapter14/Shaders/BasicMesh.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3
@@ -13,7 +13,7 @@
 in vec2 fragTexCoord;
 
 // This corresponds to the output color to the color buffer
-layout(location = 0) out vec4 outColor;
+out vec4 outColor;
 
 // This is used for the texture sampling
 uniform sampler2D uTexture;

+ 2 - 2
Chapter14/Shaders/BasicMesh.vert

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 2 - 4
Chapter14/Shaders/GBufferGlobal.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3
@@ -30,8 +30,6 @@ struct DirectionalLight
 	vec3 mDiffuseColor;
 	// Specular color
 	vec3 mSpecColor;
-	// Specular power
-	float mSpecPower;
 };
 
 // Uniforms for lighting

+ 2 - 2
Chapter14/Shaders/GBufferGlobal.vert

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 2 - 2
Chapter14/Shaders/GBufferPointLight.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 2 - 2
Chapter14/Shaders/GBufferWrite.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 8 - 9
Chapter14/Shaders/Phong.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3
@@ -18,7 +18,7 @@ in vec3 fragNormal;
 in vec3 fragWorldPos;
 
 // This corresponds to the output color to the color buffer
-layout(location = 0) out vec4 outColor;
+out vec4 outColor;
 
 // This is used for the texture sampling
 uniform sampler2D uTexture;
@@ -32,15 +32,16 @@ struct DirectionalLight
 	vec3 mDiffuseColor;
 	// Specular color
 	vec3 mSpecColor;
-	// Specular power
-	float mSpecPower;
 };
 
 // Uniforms for lighting
 // Camera position (in world space)
 uniform vec3 uCameraPos;
+// Specular power for this surface
+uniform float uSpecPower;
 // Ambient light level
 uniform vec3 uAmbientLight;
+
 // Directional Light
 uniform DirectionalLight uDirLight;
 
@@ -60,12 +61,10 @@ void main()
 	float NdotL = dot(N, L);
 	if (NdotL > 0)
 	{
-		vec3 Diffuse = uDirLight.mDiffuseColor * dot(N, L);
-		vec3 Specular = uDirLight.mSpecColor * pow(max(0.0, dot(R, V)), uDirLight.mSpecPower);
+		vec3 Diffuse = uDirLight.mDiffuseColor * NdotL;
+		vec3 Specular = uDirLight.mSpecColor * pow(max(0.0, dot(R, V)), uSpecPower);
 		Phong += Diffuse + Specular;
 	}
-	// Clamp light between 0-1 RGB values
-	Phong = clamp(Phong, 0.0, 1.0);
 
 	// Final color is texture color times phong light (alpha = 1)
     outColor = texture(uTexture, fragTexCoord) * vec4(Phong, 1.0f);

+ 2 - 2
Chapter14/Shaders/Phong.vert

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 2 - 2
Chapter14/Shaders/Skinned.vert

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 3 - 3
Chapter14/Shaders/Sprite.frag

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3
@@ -13,7 +13,7 @@
 in vec2 fragTexCoord;
 
 // This corresponds to the output color to the color buffer
-layout(location = 0) out vec4 outColor;
+out vec4 outColor;
 
 // This is used for the texture sampling
 uniform sampler2D uTexture;

+ 2 - 2
Chapter14/Shaders/Sprite.vert

@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------
 // From Game Programming in C++ by Sanjay Madhav
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-//
+// 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 // Request GLSL 3.3

+ 2 - 2
Chapter14/SoundEvent.cpp

@@ -3,12 +3,12 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #include "SoundEvent.h"
 #include "AudioSystem.h"
-#include <FMOD/fmod_studio.hpp>
+#include <fmod_studio.hpp>
 
 SoundEvent::SoundEvent(class AudioSystem* system, unsigned int id)
 	:mSystem(system)

+ 1 - 1
Chapter14/SoundEvent.h

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #pragma once

+ 3 - 11
Chapter14/TargetActor.cpp

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #include "TargetActor.h"
@@ -12,7 +12,7 @@
 #include "MeshComponent.h"
 #include "BoxComponent.h"
 #include "Mesh.h"
-#include "HUD.h"
+#include "TargetComponent.h"
 
 TargetActor::TargetActor(Game* game)
 	:Actor(game)
@@ -25,13 +25,5 @@ TargetActor::TargetActor(Game* game)
 	// Add collision box
 	BoxComponent* bc = new BoxComponent(this);
 	bc->SetObjectBox(mesh->GetBox());
-	
-	// Add to radar
-	GetGame()->GetHUD()->AddBlipActor(this);
-}
-
-TargetActor::~TargetActor()
-{
-	// Remove from radar
-	GetGame()->GetHUD()->RemoveBlipActor(this);
+	new TargetComponent(this);
 }

+ 1 - 2
Chapter14/TargetActor.h

@@ -3,7 +3,7 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #pragma once
@@ -13,6 +13,5 @@ class TargetActor : public Actor
 {
 public:
 	TargetActor(class Game* game);
-	~TargetActor();
 	TypeID GetType() const override { return TTargetActor; }
 };

+ 27 - 0
Chapter14/TargetComponent.cpp

@@ -0,0 +1,27 @@
+// ----------------------------------------------------------------
+// From Game Programming in C++ by Sanjay Madhav
+// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
+// 
+// Released under the BSD License
+// See LICENSE in root directory for full details.
+// ----------------------------------------------------------------
+
+#include "BoxComponent.h"
+#include "Actor.h"
+#include "Game.h"
+#include "PhysWorld.h"
+#include "TargetComponent.h"
+#include "Math.h"
+#include "Game.h"
+#include "HUD.h"
+
+TargetComponent::TargetComponent(Actor * owner)
+	:Component(owner)
+{
+	mOwner->GetGame()->GetHUD()->AddTargetComponent(this);
+}
+
+TargetComponent::~TargetComponent()
+{
+	mOwner->GetGame()->GetHUD()->RemoveTargetComponent(this);
+}

+ 7 - 10
Chapter14/PlayerMove.h → Chapter14/TargetComponent.h

@@ -3,19 +3,16 @@
 // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
 // 
 // Released under the BSD License
-// See LICENSE.txt for full details.
+// See LICENSE in root directory for full details.
 // ----------------------------------------------------------------
 
 #pragma once
-#include "MoveComponent.h"
+#include "Component.h"
 
-class PlayerMove : public MoveComponent
+class TargetComponent : public Component
 {
 public:
-	PlayerMove(class Actor* owner);
-
-	void Update(float deltaTime) override;
-
-	TypeID GetType() const override { return TPlayerMove; }
-protected:
-};
+	TargetComponent(class Actor* owner);
+	~TargetComponent();
+	TypeID GetType() const override { return TTargetComponent; }
+};