Merge remote-tracking branch 'origin/master'
Conflicts: Escape-the-Dawn/GameWorld.h
This commit is contained in:
@@ -3,13 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio 2012
|
# Visual Studio 2012
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Escape-the-Dawn", "Escape-the-Dawn\Escape-the-Dawn.vcxproj", "{FE405CFA-8FCE-4867-92CF-797E73B36482}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Escape-the-Dawn", "Escape-the-Dawn\Escape-the-Dawn.vcxproj", "{FE405CFA-8FCE-4867-92CF-797E73B36482}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests\Tests.vcxproj", "{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{A9755CAA-62DC-442D-B82C-F548546CFD38} = {A9755CAA-62DC-442D-B82C-F548546CFD38}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Executable", "Executable\Executable.vcxproj", "{A9755CAA-62DC-442D-B82C-F548546CFD38}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
@@ -20,14 +13,6 @@ Global
|
|||||||
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Debug|Win32.Build.0 = Debug|Win32
|
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.ActiveCfg = Release|Win32
|
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.Build.0 = Release|Win32
|
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.Build.0 = Release|Win32
|
||||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ struct PointLight : Component
|
|||||||
{
|
{
|
||||||
float Intensity;
|
float Intensity;
|
||||||
float MaxRange;
|
float MaxRange;
|
||||||
float SpecularIntensity;
|
glm::vec3 Specular;
|
||||||
Color Color;
|
glm::vec3 Diffuse;
|
||||||
|
float constantAttenuation, linearAttenuation, quadraticAttenuation;
|
||||||
|
float spotExponent;
|
||||||
|
Color color;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include "Renderer.h"
|
||||||
#define GLFW_INCLUDE_GLU
|
#include "GameWorld.h"
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <glext.h>
|
|
||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "glerror.h"
|
#include "glerror.h"
|
||||||
|
|
||||||
#include "Renderer.h"
|
|
||||||
#include "GameWorld.h"
|
|
||||||
|
|
||||||
class Engine
|
class Engine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LibraryPath>$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LibraryPath>$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32sd.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32sd.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent />
|
<PostBuildEvent />
|
||||||
<PostBuildEvent />
|
<PostBuildEvent />
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;</AdditionalDependencies>
|
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;</AdditionalDependencies>
|
||||||
@@ -101,9 +101,12 @@
|
|||||||
<ClCompile Include="Engine.h" />
|
<ClCompile Include="Engine.h" />
|
||||||
<ClCompile Include="Frame.cpp" />
|
<ClCompile Include="Frame.cpp" />
|
||||||
<ClCompile Include="GameFrame.cpp" />
|
<ClCompile Include="GameFrame.cpp" />
|
||||||
|
<ClCompile Include="GameWorld.cpp" />
|
||||||
<ClCompile Include="GUIManager.cpp" />
|
<ClCompile Include="GUIManager.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="MenuFrame.cpp" />
|
<ClCompile Include="MenuFrame.cpp" />
|
||||||
<ClCompile Include="Model.cpp" />
|
<ClCompile Include="Model.cpp" />
|
||||||
|
<ClCompile Include="OBJ.cpp" />
|
||||||
<ClCompile Include="Renderer.cpp" />
|
<ClCompile Include="Renderer.cpp" />
|
||||||
<ClCompile Include="ShaderProgram.cpp" />
|
<ClCompile Include="ShaderProgram.cpp" />
|
||||||
<ClCompile Include="Systems\CollisionSystem.cpp" />
|
<ClCompile Include="Systems\CollisionSystem.cpp" />
|
||||||
@@ -145,6 +148,8 @@
|
|||||||
<ClInclude Include="glerror.h" />
|
<ClInclude Include="glerror.h" />
|
||||||
<ClInclude Include="MenuFrame.h" />
|
<ClInclude Include="MenuFrame.h" />
|
||||||
<ClInclude Include="Model.h" />
|
<ClInclude Include="Model.h" />
|
||||||
|
<ClInclude Include="OBJ.h" />
|
||||||
|
<ClInclude Include="OpenGL.h" />
|
||||||
<ClInclude Include="Renderer.h" />
|
<ClInclude Include="Renderer.h" />
|
||||||
<ClInclude Include="ShaderProgram.h" />
|
<ClInclude Include="ShaderProgram.h" />
|
||||||
<ClInclude Include="Systems\InputSystem.h" />
|
<ClInclude Include="Systems\InputSystem.h" />
|
||||||
@@ -160,7 +165,14 @@
|
|||||||
<ClInclude Include="World.h" />
|
<ClInclude Include="World.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="Fragment2.glsl" />
|
||||||
<None Include="Shaders\Fragment.glsl" />
|
<None Include="Shaders\Fragment.glsl" />
|
||||||
|
<None Include="Shaders\Normals.frag.glsl" />
|
||||||
|
<None Include="Shaders\Normals.geo.glsl" />
|
||||||
|
<None Include="Shaders\VisualizeDepth.frag.glsl" />
|
||||||
|
<None Include="Shaders\VisualizeDepth.vert.glsl" />
|
||||||
|
<None Include="Shaders\ShadowMap.frag.glsl" />
|
||||||
|
<None Include="Shaders\ShadowMap.vert.glsl" />
|
||||||
<None Include="Shaders\Vertex.glsl" />
|
<None Include="Shaders\Vertex.glsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Camera.cpp" />
|
<ClCompile Include="Camera.cpp" />
|
||||||
|
<ClCompile Include="OBJ.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="GameWorld.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Component.h" />
|
<ClInclude Include="Component.h" />
|
||||||
@@ -142,6 +145,8 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="GameWorld.h" />
|
<ClInclude Include="GameWorld.h" />
|
||||||
<ClInclude Include="Camera.h" />
|
<ClInclude Include="Camera.h" />
|
||||||
|
<ClInclude Include="OBJ.h" />
|
||||||
|
<ClInclude Include="OpenGL.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Shaders\Fragment.glsl">
|
<None Include="Shaders\Fragment.glsl">
|
||||||
@@ -150,6 +155,27 @@
|
|||||||
<None Include="Shaders\Vertex.glsl">
|
<None Include="Shaders\Vertex.glsl">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Shaders\Normals.geo.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Shaders\Normals.frag.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Fragment2.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Shaders\ShadowMap.frag.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Shaders\ShadowMap.vert.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Shaders\VisualizeDepth.frag.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="Shaders\VisualizeDepth.vert.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Systems">
|
<Filter Include="Systems">
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
|
||||||
|
layout(binding=0) uniform sampler2D texture;
|
||||||
|
|
||||||
|
const int numberOfLights = 2;
|
||||||
|
lightSource lights[numberOfLights];
|
||||||
|
|
||||||
|
uniform vec4 position[numberOfLights];
|
||||||
|
uniform vec4 specular[numberOfLights];
|
||||||
|
uniform vec4 diffuse[numberOfLights];
|
||||||
|
uniform float constantAttenuation[numberOfLights];
|
||||||
|
uniform float linearAttenuation[numberOfLights];
|
||||||
|
uniform float quadraticAttenuation[numberOfLights];
|
||||||
|
uniform float spotExponent[numberOfLights];
|
||||||
|
|
||||||
|
in VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Input;
|
||||||
|
|
||||||
|
vec4 scene_ambient = vec4(0.2, 0.2, 0.2, 1.0);
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
vec4 texel = texture2D(texture, Input.TextureCoord);
|
||||||
|
|
||||||
|
vec3 normalDirection = normalize(Normal);
|
||||||
|
vec3 viewDirection = normalize(vec3(v_inv * vec4(0.0, 0.0, 0.0, 1.0) - Position));
|
||||||
|
vec3 lightDirection;
|
||||||
|
float attenuation;
|
||||||
|
|
||||||
|
// initialize total lighting with ambient lighting
|
||||||
|
vec3 totalLighting = vec3(scene_ambient) * vec3(frontMaterial.ambient);
|
||||||
|
|
||||||
|
for (int index = 0; index < numberOfLights; index++) // for all light sources
|
||||||
|
{
|
||||||
|
vec3 positionToLightSource = vec3(position[index] - Position);
|
||||||
|
float distance = length(positionToLightSource);
|
||||||
|
lightDirection = normalize(positionToLightSource);
|
||||||
|
|
||||||
|
attenuation = 1.0 / (constantAttenuation[index]
|
||||||
|
+ linearAttenuation[index] * distance
|
||||||
|
+ quadraticAttenuation[index] * distance * distance);
|
||||||
|
|
||||||
|
attenuation = attenuation * pow(clampedCosine, spotExponent[index]);
|
||||||
|
|
||||||
|
vec3 diffuseReflection = attenuation
|
||||||
|
* vec3(diffuse[index]) * vec3(frontMaterial.diffuse)
|
||||||
|
* max(0.0, dot(normalDirection, lightDirection));
|
||||||
|
|
||||||
|
vec3 specularReflection;
|
||||||
|
if (dot(normalDirection, lightDirection) < 0.0) // light source on the wrong side?
|
||||||
|
{
|
||||||
|
specularReflection = vec3(0.0, 0.0, 0.0); // no specular reflection
|
||||||
|
}
|
||||||
|
else // light source on the right side
|
||||||
|
{
|
||||||
|
specularReflection = attenuation * vec3(specular[index]) * vec3(frontMaterial.specular)
|
||||||
|
* pow(max(0.0, dot(reflect(-lightDirection, normalDirection), viewDirection)), frontMaterial.shininess);
|
||||||
|
}
|
||||||
|
|
||||||
|
totalLighting = totalLighting + diffuseReflection + specularReflection;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragmentColor = vec4(totalLighting, 1.0) * texel;
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
#include "GameWorld.h"
|
||||||
|
|
||||||
|
|
||||||
|
void GameWorld::Initialize()
|
||||||
|
{
|
||||||
|
World::Initialize();
|
||||||
|
|
||||||
|
//AddSystem("LevelGenerationSystem");
|
||||||
|
AddSystem("InputSystem");
|
||||||
|
//AddSystem("CollisionSystem");
|
||||||
|
//AddSystem("ParticleSystem");
|
||||||
|
AddSystem("PlayerSystem");
|
||||||
|
AddSystem("SoundSystem");
|
||||||
|
AddSystem("RenderSystem");
|
||||||
|
|
||||||
|
std::shared_ptr<Components::Transform> transform;
|
||||||
|
std::shared_ptr<Components::Model> model;
|
||||||
|
std::shared_ptr<Components::PointLight> pointLight;
|
||||||
|
std::shared_ptr<Components::Camera> camera;
|
||||||
|
EntityID ent;
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
ent = CreateEntity();
|
||||||
|
SetProperty(ent, "Name", std::string("Camera"));
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
AddComponent<Components::Input>(ent, "Input");
|
||||||
|
transform->Position = glm::vec3(0.f, 2.f, 10.f);
|
||||||
|
camera = AddComponent<Components::Camera>(ent, "Camera");
|
||||||
|
camera->FOV = 45.f;
|
||||||
|
camera->FarClip = 1000.f;
|
||||||
|
camera->NearClip = 0.01f;
|
||||||
|
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
|
||||||
|
|
||||||
|
// Fucking lights
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, 4.f, 0.f);
|
||||||
|
transform->Position = glm::vec3(10.f, 2.f, 5.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 5.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "sphere.obj";
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
||||||
|
transform->Position = glm::vec3(0.f, 2.f, 5.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Specular = glm::vec3(3.0, 3.0, 3.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(3.0, 0.0, 0.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "sphere.obj";
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, -4.f, 0.f);
|
||||||
|
transform->Position = glm::vec3(-10.f, 2.f, 5.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(0.0, 3.0, 0.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "sphere.obj";
|
||||||
|
|
||||||
|
//ground
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, -4.f, 0.f);
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "plane.obj";
|
||||||
|
|
||||||
|
// Player
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "ship.obj";
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(10.f, 0.f, 0.f);
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "ship.obj";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::Update(double dt)
|
||||||
|
{
|
||||||
|
World::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::RegisterComponents()
|
||||||
|
{
|
||||||
|
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
|
||||||
|
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
|
||||||
|
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
|
||||||
|
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
|
||||||
|
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
|
||||||
|
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
|
||||||
|
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
|
||||||
|
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
|
||||||
|
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
|
||||||
|
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
|
||||||
|
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
|
||||||
|
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
|
||||||
|
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
|
||||||
|
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::RegisterSystems()
|
||||||
|
{
|
||||||
|
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
||||||
|
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
||||||
|
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
||||||
|
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
||||||
|
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
|
||||||
|
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
|
||||||
|
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
|
||||||
|
}
|
||||||
@@ -30,103 +30,18 @@
|
|||||||
class GameWorld : public World
|
class GameWorld : public World
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameWorld(std::shared_ptr<Renderer> renderer);
|
GameWorld(std::shared_ptr<Renderer> renderer)
|
||||||
void Initialize() override;
|
: m_Renderer(renderer), World() { }
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
void RegisterSystems() override;
|
void RegisterSystems() override;
|
||||||
void RegisterComponents() override;
|
void RegisterComponents() override;
|
||||||
|
|
||||||
void Update(double dt) override;
|
void Update(double dt) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Renderer> m_Renderer;
|
std::shared_ptr<Renderer> m_Renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameWorld::GameWorld(std::shared_ptr<Renderer> renderer)
|
|
||||||
: m_Renderer(renderer), World()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::Initialize()
|
|
||||||
{
|
|
||||||
World::Initialize();
|
|
||||||
|
|
||||||
//AddSystem("LevelGenerationSystem");
|
|
||||||
AddSystem("InputSystem");
|
|
||||||
AddSystem("CollisionSystem");
|
|
||||||
//AddSystem("ParticleSystem");
|
|
||||||
AddSystem("PlayerSystem");
|
|
||||||
AddSystem("SoundSystem");
|
|
||||||
AddSystem("RenderSystem");
|
|
||||||
|
|
||||||
std::shared_ptr<Components::Transform> transform;
|
|
||||||
std::shared_ptr<Components::Model> model;
|
|
||||||
std::shared_ptr<Components::Camera> camera;
|
|
||||||
EntityID ent;
|
|
||||||
|
|
||||||
ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "ship.obj";
|
|
||||||
auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
|
|
||||||
soundEmitter->Gain = 1;
|
|
||||||
soundEmitter->MaxDistance = FLT_MAX;
|
|
||||||
soundEmitter->ReferenceDistance = 10;
|
|
||||||
soundEmitter->Loop = true;
|
|
||||||
soundEmitter->Pitch = 1;
|
|
||||||
GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
|
|
||||||
auto aabb = AddComponent<Components::Bounds>(ent, "Bounds");
|
|
||||||
aabb->Origin = transform->Position;
|
|
||||||
aabb->VolumeVector = glm::vec3(30.f, 20.f, 50.f);
|
|
||||||
GetSystem<Systems::CollisionSystem>("CollisionSystem")->Intersects(ent, ent);
|
|
||||||
|
|
||||||
|
|
||||||
ent = CreateEntity();
|
|
||||||
SetProperty(ent, "Name", std::string("Camera"));
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
AddComponent<Components::Input>(ent, "Input");
|
|
||||||
transform->Position = glm::vec3(0.f, 2.f, 10.f);
|
|
||||||
camera = AddComponent<Components::Camera>(ent, "Camera");
|
|
||||||
camera->FOV = 45.f;
|
|
||||||
camera->FarClip = 1000.f;
|
|
||||||
camera->NearClip = 0.01f;
|
|
||||||
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::RegisterSystems()
|
|
||||||
{
|
|
||||||
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
|
||||||
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
|
||||||
m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
|
||||||
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
|
||||||
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
|
|
||||||
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
|
|
||||||
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::RegisterComponents()
|
|
||||||
{
|
|
||||||
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
|
|
||||||
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
|
|
||||||
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
|
|
||||||
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
|
|
||||||
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
|
|
||||||
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
|
|
||||||
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
|
|
||||||
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
|
|
||||||
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
|
|
||||||
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
|
|
||||||
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
|
|
||||||
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
|
|
||||||
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
|
|
||||||
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::Update(double dt)
|
|
||||||
{
|
|
||||||
World::Update(dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GameWorld_h__
|
#endif // GameWorld_h__
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
#ifndef GameWorld_h__
|
||||||
|
#define GameWorld_h__
|
||||||
|
|
||||||
|
#include "World.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
#include "Systems/CollisionSystem.h"
|
||||||
|
#include "Systems/InputSystem.h"
|
||||||
|
#include "Systems/LevelGenerationSystem.h"
|
||||||
|
#include "Systems/ParticleSystem.h"
|
||||||
|
#include "Systems/PlayerSystem.h"
|
||||||
|
#include "Systems/RenderSystem.h"
|
||||||
|
#include "Systems/SoundSystem.h"
|
||||||
|
|
||||||
|
#include "Components/Bounds.h"
|
||||||
|
#include "Components/Camera.h"
|
||||||
|
#include "Components/Collision.h"
|
||||||
|
#include "Components/DirectionalLight.h"
|
||||||
|
#include "Components/Input.h"
|
||||||
|
#include "Components/Model.h"
|
||||||
|
#include "Components/ParticleEmitter.h"
|
||||||
|
#include "Components/PointLight.h"
|
||||||
|
#include "Components/PowerUp.h"
|
||||||
|
#include "Components/SoundEmitter.h"
|
||||||
|
#include "Components/Sprite.h"
|
||||||
|
#include "Components/Stat.h"
|
||||||
|
#include "Components/Template.h"
|
||||||
|
#include "Components/Transform.h"
|
||||||
|
|
||||||
|
class GameWorld : public World
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameWorld(std::shared_ptr<Renderer> renderer);
|
||||||
|
void Initialize() override;
|
||||||
|
|
||||||
|
void RegisterSystems() override;
|
||||||
|
void RegisterComponents() override;
|
||||||
|
|
||||||
|
void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<Renderer> m_Renderer;
|
||||||
|
};
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
GameWorld::GameWorld(std::shared_ptr<Renderer> renderer)
|
||||||
|
: m_Renderer(renderer), World()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::Initialize()
|
||||||
|
{
|
||||||
|
World::Initialize();
|
||||||
|
|
||||||
|
//AddSystem("LevelGenerationSystem");
|
||||||
|
AddSystem("InputSystem");
|
||||||
|
//AddSystem("CollisionSystem");
|
||||||
|
//AddSystem("ParticleSystem");
|
||||||
|
AddSystem("PlayerSystem");
|
||||||
|
AddSystem("SoundSystem");
|
||||||
|
AddSystem("RenderSystem");
|
||||||
|
|
||||||
|
std::shared_ptr<Components::Transform> transform;
|
||||||
|
std::shared_ptr<Components::Model> model;
|
||||||
|
std::shared_ptr<Components::PointLight> pointLight;
|
||||||
|
std::shared_ptr<Components::Camera> camera;
|
||||||
|
EntityID ent;
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, 4.f, 0.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, -4.f, 0.f);
|
||||||
|
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
||||||
|
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
|
||||||
|
pointLight->constantAttenuation = 0.f;
|
||||||
|
pointLight->linearAttenuation = 1.f;
|
||||||
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
|
pointLight->spotExponent = 0.0f;
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(10.f, 0.f, 0.f);
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "ship.obj";
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
|
model->ModelFile = "ship.obj";
|
||||||
|
// auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
|
||||||
|
// soundEmitter->Gain = 1;
|
||||||
|
// soundEmitter->MaxDistance = FLT_MAX;
|
||||||
|
// soundEmitter->ReferenceDistance = 10;
|
||||||
|
// soundEmitter->Loop = true;
|
||||||
|
// soundEmitter->ReferenceDistance = 0.1;
|
||||||
|
// soundEmitter->Pitch = 1;
|
||||||
|
// GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
SetProperty(ent, "Name", std::string("Camera"));
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
AddComponent<Components::Input>(ent, "Input");
|
||||||
|
transform->Position = glm::vec3(0.f, 2.f, 10.f);
|
||||||
|
camera = AddComponent<Components::Camera>(ent, "Camera");
|
||||||
|
camera->FOV = 45.f;
|
||||||
|
camera->FarClip = 1000.f;
|
||||||
|
camera->NearClip = 0.01f;
|
||||||
|
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::RegisterSystems()
|
||||||
|
{
|
||||||
|
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
||||||
|
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
||||||
|
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
||||||
|
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
||||||
|
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
|
||||||
|
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
|
||||||
|
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::RegisterComponents()
|
||||||
|
{
|
||||||
|
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
|
||||||
|
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
|
||||||
|
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
|
||||||
|
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
|
||||||
|
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
|
||||||
|
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
|
||||||
|
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
|
||||||
|
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
|
||||||
|
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
|
||||||
|
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
|
||||||
|
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
|
||||||
|
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
|
||||||
|
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
|
||||||
|
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::Update(double dt)
|
||||||
|
{
|
||||||
|
World::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> origin/master
|
||||||
|
#endif // GameWorld_h__
|
||||||
@@ -3,12 +3,61 @@
|
|||||||
|
|
||||||
Model::Model(const char* path)
|
Model::Model(const char* path)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Loadobj(path, Vertices, Normals, TextureCoords);
|
Loadobj(path, Vertices, Normals, TextureCoords);
|
||||||
CreateBuffers(Vertices, Normals, TextureCoords);
|
CreateBuffers(Vertices, Normals, TextureCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Model::Model(OBJ &obj)
|
||||||
|
{
|
||||||
|
OBJ::MaterialInfo* currentMaterial = nullptr;
|
||||||
|
TextureGroup* currentTexGroup = nullptr;
|
||||||
|
int index = 0;
|
||||||
|
for (auto face : obj.Faces) {
|
||||||
|
if (face.Material == nullptr) {
|
||||||
|
LOG_ERROR("Missing material for .obj file \"%s\"", obj.Path().string().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// New material
|
||||||
|
if (face.Material != currentMaterial) {
|
||||||
|
currentMaterial = face.Material;
|
||||||
|
// Load texture
|
||||||
|
std::shared_ptr<Texture> texture = std::make_shared<Texture>(currentMaterial->TextureFile);
|
||||||
|
// TODO: Load material parameters
|
||||||
|
// Create new texture group (start index of new group is upcoming index)
|
||||||
|
TextureGroup texGroup = { texture, index, index };
|
||||||
|
TextureGroups.push_back(texGroup);
|
||||||
|
currentTexGroup = &TextureGroups.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Face definitions
|
||||||
|
for (auto faceDef : face.Definitions) {
|
||||||
|
glm::vec3 vertex;
|
||||||
|
std::tie(vertex.x, vertex.y, vertex.z) = obj.Vertices.at(faceDef.VertexIndex - 1);
|
||||||
|
Vertices.push_back(vertex);
|
||||||
|
|
||||||
|
if (faceDef.NormalIndex != 0) {
|
||||||
|
glm::vec3 normal;
|
||||||
|
std::tie(normal.x, normal.y, normal.z) = obj.Normals.at(faceDef.NormalIndex - 1);
|
||||||
|
Normals.push_back(normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (faceDef.TextureCoordIndex != 0) {
|
||||||
|
glm::vec2 texCoord;
|
||||||
|
// TODO: W-coord?
|
||||||
|
std::tie(texCoord.x, texCoord.y, std::ignore) = obj.TextureCoords.at(faceDef.TextureCoordIndex - 1);
|
||||||
|
TextureCoords.push_back(texCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentTexGroup->EndIndex = index;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Vertices.size() > 0) {
|
||||||
|
CreateBuffers(Vertices, Normals, TextureCoords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::Loadobj(const char* path, std::vector <glm::vec3> & out_vertices, std::vector <glm::vec3> &out_normals, std::vector <glm::vec2> & out_TextureCoords)
|
bool Model::Loadobj(const char* path, std::vector <glm::vec3> & out_vertices, std::vector <glm::vec3> &out_normals, std::vector <glm::vec2> & out_TextureCoords)
|
||||||
{
|
{
|
||||||
std::vector< unsigned int > vertexIndices, TextureCoordIndices, normalIndices;
|
std::vector< unsigned int > vertexIndices, TextureCoordIndices, normalIndices;
|
||||||
@@ -143,27 +192,39 @@ bool Model::Loadobj(const char* path, std::vector <glm::vec3> & out_vertices, st
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Model::CreateBuffers( std::vector<glm::vec3> _Vertices, std::vector<glm::vec3> _Normals, std::vector<glm::vec2>_TextureCoords)
|
void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec3> normals, std::vector<glm::vec2>textureCoords)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG_INFO("Generating VertexBuffer");
|
LOG_INFO("Generating VertexBuffer");
|
||||||
glGenBuffers(1, &VertexBuffer);
|
glGenBuffers(1, &VertexBuffer);
|
||||||
|
if (vertices.size() > 0) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, _Vertices.size() * sizeof(glm::vec3), &_Vertices[0], GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec3), &vertices[0], GL_STATIC_DRAW);
|
||||||
GLERROR("GLEW: BufferFail, VertexBuffer");
|
GLERROR("GLEW: BufferFail, VertexBuffer");
|
||||||
|
} else {
|
||||||
|
LOG_WARNING("Created empty vertex buffer!");
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Generating NormalBuffer");
|
LOG_INFO("Generating NormalBuffer");
|
||||||
glGenBuffers(1, &NormalBuffer);
|
glGenBuffers(1, &NormalBuffer);
|
||||||
|
if (normals.size() > 0) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, NormalBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, NormalBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, _Normals.size() * sizeof(glm::vec3), &_Normals[0], GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(glm::vec3), &normals[0], GL_STATIC_DRAW);
|
||||||
GLERROR("GLEW: BufferFail, NormalBuffer");
|
GLERROR("GLEW: BufferFail, NormalBuffer");
|
||||||
|
} else {
|
||||||
|
LOG_WARNING("Created empty normal buffer!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG_INFO("Generating textureCoordBuffer");
|
LOG_INFO("Generating textureCoordBuffer");
|
||||||
glGenBuffers(1, &TextureCoordBuffer);
|
glGenBuffers(1, &TextureCoordBuffer);
|
||||||
|
if (textureCoords.size() > 0) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, TextureCoordBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, TextureCoordBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, _TextureCoords.size() * sizeof(glm::vec2), &_TextureCoords[0], GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, textureCoords.size() * sizeof(glm::vec2), &textureCoords[0], GL_STATIC_DRAW);
|
||||||
GLERROR("GLEW: BufferFail, TextureCoordBuffer");
|
GLERROR("GLEW: BufferFail, TextureCoordBuffer");
|
||||||
|
} else {
|
||||||
|
LOG_WARNING("Created empty texture coordinate buffer!");
|
||||||
|
}
|
||||||
|
|
||||||
glGenVertexArrays(1, &VAO);
|
glGenVertexArrays(1, &VAO);
|
||||||
glBindVertexArray(VAO);
|
glBindVertexArray(VAO);
|
||||||
|
|||||||
+23
-14
@@ -8,37 +8,48 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#include "OpenGL.h"
|
||||||
#include <GL/glew.h>
|
|
||||||
#define GLFW_INCLUDE_GLU
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <glext.h>
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/constants.hpp>
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
#include "glerror.h"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
|
#include "glerror.h"
|
||||||
|
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include "OBJ.h"
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Model(OBJ &obj);
|
||||||
|
Model(const char* path);
|
||||||
|
|
||||||
|
struct TextureGroup
|
||||||
|
{
|
||||||
|
std::shared_ptr<Texture> Texture;
|
||||||
|
unsigned int StartIndex;
|
||||||
|
unsigned int EndIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
GLuint VAO;
|
||||||
|
std::vector<TextureGroup> TextureGroups;
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Texture>> texture;
|
||||||
|
glm::mat4 GetMatrix();
|
||||||
std::vector<glm::vec3> Vertices;
|
std::vector<glm::vec3> Vertices;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
std::vector<glm::vec3> Normals;
|
std::vector<glm::vec3> Normals;
|
||||||
std::vector<glm::vec2> TextureCoords;
|
std::vector<glm::vec2> TextureCoords;
|
||||||
|
|
||||||
GLuint VertexBuffer;
|
GLuint VertexBuffer;
|
||||||
GLuint NormalBuffer;
|
GLuint NormalBuffer;
|
||||||
GLuint TextureCoordBuffer;
|
GLuint TextureCoordBuffer;
|
||||||
GLuint VAO;
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Texture>> texture;
|
|
||||||
|
|
||||||
Model(const char* path);
|
|
||||||
|
|
||||||
bool Loadobj(
|
bool Loadobj(
|
||||||
const char* path,
|
const char* path,
|
||||||
@@ -47,8 +58,6 @@ public:
|
|||||||
std::vector <glm::vec2> & out_TextureCoords
|
std::vector <glm::vec2> & out_TextureCoords
|
||||||
);
|
);
|
||||||
|
|
||||||
glm::mat4 GetMatrix();
|
|
||||||
|
|
||||||
void CreateBuffers(
|
void CreateBuffers(
|
||||||
std::vector<glm::vec3> _Vertices,
|
std::vector<glm::vec3> _Vertices,
|
||||||
std::vector<glm::vec3> _Normals,
|
std::vector<glm::vec3> _Normals,
|
||||||
|
|||||||
@@ -0,0 +1,225 @@
|
|||||||
|
#include "OBJ.h"
|
||||||
|
|
||||||
|
bool OBJ::LoadFromFile(std::string filename)
|
||||||
|
{
|
||||||
|
m_Path = boost::filesystem::path(filename);
|
||||||
|
|
||||||
|
// http://paulbourke.net/dataformats/obj/
|
||||||
|
std::ifstream file(m_Path.string());
|
||||||
|
if (!file.is_open()) {
|
||||||
|
LOG_ERROR("Failed to open .obj \"%s\"", m_Path.string().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (line.length() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::stringstream ss(line);
|
||||||
|
|
||||||
|
std::string prefix;
|
||||||
|
ss >> prefix;
|
||||||
|
|
||||||
|
// Ignore comments
|
||||||
|
if (prefix == "#")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Material files
|
||||||
|
if (prefix == "mtllib") {
|
||||||
|
std::string materialFilename;
|
||||||
|
ss >> materialFilename;
|
||||||
|
m_MaterialPath = m_Path.branch_path() / materialFilename;
|
||||||
|
ParseMaterial();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Material statement
|
||||||
|
if (prefix == "usemtl") {
|
||||||
|
std::string material;
|
||||||
|
ss >> material;
|
||||||
|
m_CurrentMaterial = &Materials[material];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vertices
|
||||||
|
if (prefix == "v") {
|
||||||
|
float x, y, z;
|
||||||
|
ss >> x >> y >> z;
|
||||||
|
Vertices.push_back(std::make_tuple(x, y, z));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normals
|
||||||
|
if (prefix == "vn") {
|
||||||
|
float x, y, z;
|
||||||
|
ss >> x >> y >> z;
|
||||||
|
Normals.push_back(std::make_tuple(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Texture coordinates
|
||||||
|
if (prefix == "vt") {
|
||||||
|
float u, v, w;
|
||||||
|
ss >> u >> v >> w;
|
||||||
|
TextureCoords.push_back(std::make_tuple(u, v, w));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Face definitions
|
||||||
|
if (prefix == "f") {
|
||||||
|
Face face;
|
||||||
|
face.Material = m_CurrentMaterial;
|
||||||
|
|
||||||
|
std::string faceDefString;
|
||||||
|
while (ss >> faceDefString) {
|
||||||
|
std::stringstream ss2(faceDefString);
|
||||||
|
FaceDefinition faceDef = { 0, 0, 0 };
|
||||||
|
|
||||||
|
ss2 >> faceDef.VertexIndex;
|
||||||
|
ss2.ignore(); // Ignore first delimiter
|
||||||
|
if (!ss2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ss2.peek() == '/') {
|
||||||
|
ss2.ignore();
|
||||||
|
ss2 >> faceDef.NormalIndex;
|
||||||
|
} else {
|
||||||
|
ss2 >> faceDef.TextureCoordIndex;
|
||||||
|
ss2.ignore();
|
||||||
|
ss2 >> faceDef.NormalIndex;
|
||||||
|
}
|
||||||
|
face.Definitions.push_back(faceDef);
|
||||||
|
}
|
||||||
|
Faces.push_back(face);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OBJ::ParseMaterial()
|
||||||
|
{
|
||||||
|
// http://paulbourke.net/dataformats/mtl/
|
||||||
|
std::ifstream file(m_MaterialPath.string());
|
||||||
|
if (!file.is_open()) {
|
||||||
|
LOG_ERROR("Failed to open .mtl \"%s\"", m_MaterialPath.string().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
|
||||||
|
|
||||||
|
std::string currentMaterialName;
|
||||||
|
MaterialInfo* currentMaterial = nullptr;
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (line.length() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::stringstream ss(line);
|
||||||
|
|
||||||
|
std::string prefix;
|
||||||
|
ss >> prefix;
|
||||||
|
|
||||||
|
// Create a new material definition
|
||||||
|
if (prefix == "newmtl") {
|
||||||
|
MaterialInfo mat =
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
std::make_tuple(0.2f, 0.2f, 0.2f),
|
||||||
|
std::make_tuple(0.8f, 0.8f, 0.8f),
|
||||||
|
std::make_tuple(1.0f, 1.0f, 1.0f),
|
||||||
|
std::make_tuple(1.0f, 1.0f, 1.0f),
|
||||||
|
1.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
ss >> currentMaterialName;
|
||||||
|
LOG_INFO("Parsing material %s", currentMaterialName.c_str());
|
||||||
|
Materials[currentMaterialName] = mat;
|
||||||
|
currentMaterial = &Materials[currentMaterialName];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentMaterial)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Ambient color
|
||||||
|
if (prefix == "Ka") {
|
||||||
|
float r, g, b;
|
||||||
|
ss >> r >> g >> b;
|
||||||
|
currentMaterial->AmbientColor = std::make_tuple(r, g, b);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Diffuse color
|
||||||
|
if (prefix == "Kd") {
|
||||||
|
float r, g, b;
|
||||||
|
ss >> r >> g >> b;
|
||||||
|
currentMaterial->DiffuseColor = std::make_tuple(r, g, b);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Specular color
|
||||||
|
if (prefix == "Ks") {
|
||||||
|
float r, g, b;
|
||||||
|
ss >> r >> g >> b;
|
||||||
|
currentMaterial->SpecularColor = std::make_tuple(r, g, b);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Transmission filter
|
||||||
|
if (prefix == "Tf") {
|
||||||
|
std::stringstream ss2;
|
||||||
|
ss2 << ss.str();
|
||||||
|
|
||||||
|
std::string command;
|
||||||
|
ss2 >> command;
|
||||||
|
if (command == "xyz") {
|
||||||
|
// TODO: "The "Ks xyz" statement specifies the specular reflectivity using CIEXYZ values."
|
||||||
|
}
|
||||||
|
else if (command == "spectral") {
|
||||||
|
// TODO: "The "Tf spectral" statement specifies the transmission filter using a spectral curve."
|
||||||
|
} else {
|
||||||
|
float r, g, b;
|
||||||
|
ss >> r;
|
||||||
|
// G and B are optional
|
||||||
|
if (!(ss >> g >> b))
|
||||||
|
{
|
||||||
|
g = r;
|
||||||
|
b = r;
|
||||||
|
}
|
||||||
|
currentMaterial->TransmissionFilter = std::make_tuple(r, g, b);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Optical density
|
||||||
|
if (prefix == "Ni") {
|
||||||
|
ss >> currentMaterial->OpticalDensity;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Alpha
|
||||||
|
if (prefix == "d" || prefix == "Tr") {
|
||||||
|
ss >> currentMaterial->Alpha;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Shininess
|
||||||
|
if (prefix == "Ns") {
|
||||||
|
ss >> currentMaterial->Shininess;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Illumination model
|
||||||
|
if (prefix == "illum") {
|
||||||
|
int illum = 0;
|
||||||
|
ss >> illum;
|
||||||
|
currentMaterial->IlluminationModel = illum;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Texture file
|
||||||
|
// TODO:
|
||||||
|
if (prefix == "map_Ka" || prefix == "map_Kd") {
|
||||||
|
ss >> currentMaterial->TextureFile;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#ifndef OBJ_h__
|
||||||
|
#define OBJ_h__
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <tuple>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
|
class OBJ
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct MaterialInfo
|
||||||
|
{
|
||||||
|
std::string TextureFile;
|
||||||
|
std::tuple<float, float, float> AmbientColor;
|
||||||
|
std::tuple<float, float, float> DiffuseColor;
|
||||||
|
std::tuple<float, float, float> SpecularColor;
|
||||||
|
std::tuple<float, float, float> TransmissionFilter;
|
||||||
|
float OpticalDensity;
|
||||||
|
float Alpha;
|
||||||
|
float Shininess;
|
||||||
|
int IlluminationModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FaceDefinition
|
||||||
|
{
|
||||||
|
int VertexIndex;
|
||||||
|
int TextureCoordIndex;
|
||||||
|
int NormalIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Face
|
||||||
|
{
|
||||||
|
Face() : Material(nullptr) { }
|
||||||
|
std::vector<FaceDefinition> Definitions;
|
||||||
|
MaterialInfo* Material;
|
||||||
|
};
|
||||||
|
|
||||||
|
OBJ() : m_CurrentMaterial(nullptr) { }
|
||||||
|
OBJ(std::string filename) : m_CurrentMaterial(nullptr) { LoadFromFile(filename); }
|
||||||
|
|
||||||
|
std::vector<std::tuple<float, float, float>> Vertices;
|
||||||
|
std::vector<std::tuple<float, float, float>> Normals;
|
||||||
|
std::vector<std::tuple<float, float, float>> TextureCoords;
|
||||||
|
std::vector<Face> Faces;
|
||||||
|
std::map<std::string, MaterialInfo> Materials;
|
||||||
|
|
||||||
|
bool LoadFromFile(std::string filename);
|
||||||
|
boost::filesystem::path Path() const { return m_Path; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::filesystem::path m_Path;
|
||||||
|
boost::filesystem::path m_MaterialPath;
|
||||||
|
MaterialInfo* m_CurrentMaterial;
|
||||||
|
|
||||||
|
void ParseMaterial();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OBJ_h__
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,5 @@
|
|||||||
|
#include <GL/glew.h>
|
||||||
|
#define GLFW_INCLUDE_GLU
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <glext.h>
|
||||||
|
#define GLM_FORCE_RADIANS
|
||||||
+257
-27
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
Renderer::Renderer()
|
Renderer::Renderer()
|
||||||
{
|
{
|
||||||
|
m_VSync = false;
|
||||||
|
m_DrawNormals = false;
|
||||||
|
m_DrawWireframe = false;
|
||||||
|
|
||||||
|
m_SunPosition = glm::vec3(0, 10, 10);
|
||||||
|
m_SunTarget = glm::vec3(0);
|
||||||
|
m_SunProjection = glm::ortho<float>(-20, 20, -20, 20, -10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Initialize()
|
void Renderer::Initialize()
|
||||||
@@ -39,45 +46,211 @@ void Renderer::Initialize()
|
|||||||
LOG_ERROR("GLEW: Initialization failed");
|
LOG_ERROR("GLEW: Initialization failed");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
// Create Camera
|
// Create Camera
|
||||||
|
|
||||||
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
|
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
|
||||||
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
|
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
|
||||||
|
|
||||||
|
glfwSwapInterval(m_VSync);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
LoadContent();
|
LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Draw(double _dt)
|
void Renderer::LoadContent()
|
||||||
{
|
{
|
||||||
|
auto standardVS = std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl"));
|
||||||
|
auto standardFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl"));
|
||||||
|
|
||||||
|
m_ShaderProgram.AddShader(standardVS);
|
||||||
|
m_ShaderProgram.AddShader(standardFS);
|
||||||
|
m_ShaderProgram.Compile();
|
||||||
|
m_ShaderProgram.Link();
|
||||||
|
|
||||||
|
m_ShaderProgramNormals.AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/Normals.geo.glsl")));
|
||||||
|
m_ShaderProgramNormals.AddShader(standardVS);
|
||||||
|
m_ShaderProgramNormals.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Normals.frag.glsl")));
|
||||||
|
m_ShaderProgramNormals.Compile();
|
||||||
|
m_ShaderProgramNormals.Link();
|
||||||
|
|
||||||
|
m_ShaderProgramShadows.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowMap.vert.glsl")));
|
||||||
|
m_ShaderProgramShadows.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShadowMap.frag.glsl")));
|
||||||
|
m_ShaderProgramShadows.Compile();
|
||||||
|
m_ShaderProgramShadows.Link();
|
||||||
|
|
||||||
|
m_ShaderProgramShadowsDrawDepth.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/VisualizeDepth.vert.glsl")));
|
||||||
|
m_ShaderProgramShadowsDrawDepth.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/VisualizeDepth.frag.glsl")));
|
||||||
|
m_ShaderProgramShadowsDrawDepth.Compile();
|
||||||
|
m_ShaderProgramShadowsDrawDepth.Link();
|
||||||
|
|
||||||
|
m_ScreenQuad = CreateQuad();
|
||||||
|
CreateShadowMap(2048*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::CreateShadowMap(int resolution)
|
||||||
|
{
|
||||||
|
glGenFramebuffers(1, &m_ShadowFrameBuffer);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
|
||||||
|
|
||||||
|
// Depth texture
|
||||||
|
glGenTextures(1, &m_ShadowDepthTexture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, resolution, resolution, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
|
|
||||||
|
//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE );
|
||||||
|
//glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY );
|
||||||
|
|
||||||
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_ShadowDepthTexture, 0);
|
||||||
|
glDrawBuffer(GL_NONE);
|
||||||
|
|
||||||
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
|
LOG_ERROR("Framebuffer incomplete!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Renderer::Draw(double dt)
|
||||||
|
{
|
||||||
|
DrawShadowMap();
|
||||||
|
DrawScene();
|
||||||
|
|
||||||
|
DrawDebugShadowMap();
|
||||||
|
|
||||||
|
ModelsToRender.clear();
|
||||||
|
glfwSwapBuffers(m_Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawScene()
|
||||||
|
{
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glViewport(0, 0, WIDTH, HEIGHT);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
|
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
m_ShaderProgram.Bind();
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
#ifdef DEBUG
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
glPolygonMode(GL_BACK, GL_LINE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Draw models
|
||||||
|
glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0));
|
||||||
|
glm::mat4 depthCamera = m_SunProjection * depthViewMatrix;
|
||||||
|
glm::mat4 depthMVP = depthCamera;
|
||||||
|
glm::mat4 biasMatrix(
|
||||||
|
0.5, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.5, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 0.5, 0.0,
|
||||||
|
0.5, 0.5, 0.5, 1.0
|
||||||
|
);
|
||||||
|
glm::mat4 depthBiasMVP = biasMatrix * depthMVP;
|
||||||
|
|
||||||
|
m_ShaderProgram.Bind();
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthBiasMVP));
|
||||||
|
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "position"), 3, Light_position.data());
|
||||||
|
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "specular"), 3, Light_specular.data());
|
||||||
|
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "diffuse"), 3, Light_diffuse.data());
|
||||||
|
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 3, Light_constantAttenuation.data());
|
||||||
|
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 3, Light_linearAttenuation.data());
|
||||||
|
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 3, Light_quadraticAttenuation.data());
|
||||||
|
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "spotExponent"), 3, Light_spotExponent.data());
|
||||||
|
if (m_DrawWireframe) {
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
}
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
||||||
|
DrawModels(m_ShaderProgram);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Debug draw model normals
|
||||||
|
if (m_DrawNormals) {
|
||||||
|
m_ShaderProgramNormals.Bind();
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
DrawModels(m_ShaderProgramNormals);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawShadowMap()
|
||||||
|
{
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
|
||||||
|
glViewport(0, 0, 2048*2, 2048*2);
|
||||||
|
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0));
|
||||||
|
glm::mat4 depthCamera = m_SunProjection * depthViewMatrix;
|
||||||
|
|
||||||
|
//glm::mat4 cameraMatrix = depthProjectionMatrix * m_Camera->ViewMatrix();
|
||||||
|
|
||||||
|
glm::mat4 MVP;
|
||||||
|
|
||||||
|
m_ShaderProgramShadows.Bind();
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
for (int i = 0; i < ModelsToRender.size(); i++)
|
||||||
|
{
|
||||||
|
ModelData* modelData = ModelsToRender.at(i);
|
||||||
|
auto model = modelData->model;
|
||||||
|
|
||||||
|
MVP = depthCamera * modelData->ModelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramShadows.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
|
|
||||||
|
glBindVertexArray(model->VAO);
|
||||||
|
for (auto texGroup : model->TextureGroups) {
|
||||||
|
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawDebugShadowMap()
|
||||||
|
{
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glViewport(0, 0, 200*(16.f/9.f), 200);
|
||||||
|
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
m_ShaderProgramShadowsDrawDepth.Bind();
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
||||||
|
glBindVertexArray(m_ScreenQuad);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawModels(ShaderProgram &shader)
|
||||||
|
{
|
||||||
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
|
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
|
||||||
|
|
||||||
glm::mat4 MVP;
|
glm::mat4 MVP;
|
||||||
for (int i = 0; i < ModelsToRender.size(); i++)
|
for (int i = 0; i < ModelsToRender.size(); i++)
|
||||||
{
|
{
|
||||||
|
ModelData* modelData = ModelsToRender.at(i);
|
||||||
|
auto model = modelData->model;
|
||||||
|
|
||||||
|
MVP = cameraMatrix * modelData->ModelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shader.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shader.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(modelData->ModelMatrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shader.GetHandle(), "view"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||||
|
glBindVertexArray(model->VAO);
|
||||||
|
for (auto texGroup : model->TextureGroups) {
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, ModelsToRender[i]->model->texture[0]->texture);
|
glBindTexture(GL_TEXTURE_2D, texGroup.Texture->texture);
|
||||||
MVP = cameraMatrix * ModelsToRender[i]->ModelMatrix;
|
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(ModelsToRender[i]->ModelMatrix));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "view"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
|
||||||
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "lightPosition"), 1, glm::value_ptr(glm::vec3(2.0f, 4.0f, 1.0f)));
|
|
||||||
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 1.5f);
|
|
||||||
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 0.0f);
|
|
||||||
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 0.0f);
|
|
||||||
glBindVertexArray(ModelsToRender[i]->model->VAO);
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
ModelsToRender.clear();
|
|
||||||
|
|
||||||
glfwSwapBuffers(m_Window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawText()
|
void Renderer::DrawText()
|
||||||
@@ -90,7 +263,7 @@ void Renderer::AddTextToDraw()
|
|||||||
//Add to draw shit vector
|
//Add to draw shit vector
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::AddModelToDraw(Model* _model, glm::vec3 _position, glm::quat _orientation)
|
void Renderer::AddModelToDraw(std::shared_ptr<Model> _model, glm::vec3 _position, glm::quat _orientation)
|
||||||
{
|
{
|
||||||
glm::mat4 RotationMatrix = glm::toMat4(_orientation);
|
glm::mat4 RotationMatrix = glm::toMat4(_orientation);
|
||||||
glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
|
glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
|
||||||
@@ -98,12 +271,69 @@ void Renderer::AddModelToDraw(Model* _model, glm::vec3 _position, glm::quat _ori
|
|||||||
ModelsToRender.push_back(new ModelData(_model, ModelMatrix));
|
ModelsToRender.push_back(new ModelData(_model, ModelMatrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fixa med shaders, lägga in alla verts osv.
|
void Renderer::AddPointLightToDraw(
|
||||||
|
glm::vec3 _position,
|
||||||
void Renderer::LoadContent()
|
glm::vec3 _specular,
|
||||||
|
glm::vec3 _diffuse,
|
||||||
|
float _constantAttenuation,
|
||||||
|
float _linearAttenuation,
|
||||||
|
float _quadraticAttenuation,
|
||||||
|
float _spotExponent
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_ShaderProgram.AddShader(std::unique_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
Light_position.push_back(_position.x);
|
||||||
m_ShaderProgram.AddShader(std::unique_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
Light_position.push_back(_position.y);
|
||||||
m_ShaderProgram.Compile();
|
Light_position.push_back(_position.z);
|
||||||
m_ShaderProgram.Link();
|
Light_specular.push_back(_specular.x);
|
||||||
|
Light_specular.push_back(_specular.y);
|
||||||
|
Light_specular.push_back(_specular.z);
|
||||||
|
Light_diffuse.push_back(_diffuse.x);
|
||||||
|
Light_diffuse.push_back(_diffuse.y);
|
||||||
|
Light_diffuse.push_back(_diffuse.z);
|
||||||
|
Light_constantAttenuation.push_back(_constantAttenuation);
|
||||||
|
Light_linearAttenuation.push_back(_linearAttenuation);
|
||||||
|
Light_quadraticAttenuation.push_back(_quadraticAttenuation);
|
||||||
|
Light_spotExponent.push_back(_spotExponent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint Renderer::CreateQuad()
|
||||||
|
{
|
||||||
|
float quadVertices[] = {
|
||||||
|
-1.0f, -1.0f, 0.0f,
|
||||||
|
1.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f,
|
||||||
|
|
||||||
|
-1.0f, -1.0f, 0.0f,
|
||||||
|
1.0f, -1.0f, 0.0f,
|
||||||
|
1.0f, 1.0f, 0.0f,
|
||||||
|
};
|
||||||
|
float quadTexCoords[] = {
|
||||||
|
0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f,
|
||||||
|
0.0f, 1.0f,
|
||||||
|
|
||||||
|
0.0f, 0.0f,
|
||||||
|
1.0f, 0.0f,
|
||||||
|
1.0f, 1.0f,
|
||||||
|
};
|
||||||
|
GLuint vbo[2], vao;
|
||||||
|
glGenBuffers(2, vbo);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, 3 * 6 * sizeof(float), quadVertices, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, 2 * 6 * sizeof(float), quadTexCoords, GL_STATIC_DRAW);
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
||||||
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
|
||||||
|
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
glEnableVertexAttribArray(0);
|
||||||
|
glEnableVertexAttribArray(2);
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
return vao;
|
||||||
}
|
}
|
||||||
+51
-12
@@ -7,12 +7,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#include "OpenGL.h"
|
||||||
#include <GL/glew.h>
|
|
||||||
#define GLFW_INCLUDE_GLU
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <glext.h>
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/constants.hpp>
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
@@ -24,11 +19,12 @@
|
|||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
#include "Components/PointLight.h"
|
||||||
|
|
||||||
class Renderer
|
class Renderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderProgram m_ShaderProgram;
|
|
||||||
glm::mat4 viewMatrix;
|
glm::mat4 viewMatrix;
|
||||||
glm::mat4 projectionMatrix;
|
glm::mat4 projectionMatrix;
|
||||||
|
|
||||||
@@ -36,13 +32,20 @@ public:
|
|||||||
|
|
||||||
struct ModelData
|
struct ModelData
|
||||||
{
|
{
|
||||||
Model* model;
|
std::shared_ptr<Model> model;
|
||||||
glm::mat4 ModelMatrix;
|
glm::mat4 ModelMatrix;
|
||||||
ModelData(Model* _model, glm::mat4 _modelMatrix) : model(_model), ModelMatrix(_modelMatrix)
|
ModelData(std::shared_ptr<Model> _model, glm::mat4 _modelMatrix)
|
||||||
{}
|
: model(_model), ModelMatrix(_modelMatrix) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<ModelData*> ModelsToRender;
|
std::vector<ModelData*> ModelsToRender;
|
||||||
|
std::vector<float> Light_position;
|
||||||
|
std::vector<float> Light_specular;
|
||||||
|
std::vector<float> Light_diffuse;
|
||||||
|
std::vector<float> Light_constantAttenuation;
|
||||||
|
std::vector<float> Light_linearAttenuation;
|
||||||
|
std::vector<float> Light_quadraticAttenuation;
|
||||||
|
std::vector<float> Light_spotExponent;
|
||||||
|
|
||||||
Renderer();
|
Renderer();
|
||||||
|
|
||||||
@@ -50,22 +53,58 @@ public:
|
|||||||
void Draw(double dt);
|
void Draw(double dt);
|
||||||
void DrawText();
|
void DrawText();
|
||||||
|
|
||||||
void AddModelToDraw(Model*, glm::vec3, glm::quat);
|
void AddModelToDraw(std::shared_ptr<Model> model, glm::vec3 position, glm::quat orientation);
|
||||||
void AddTextToDraw();
|
void AddTextToDraw();
|
||||||
|
void AddPointLightToDraw(
|
||||||
|
glm::vec3 _position,
|
||||||
|
glm::vec3 _specular,
|
||||||
|
glm::vec3 _diffuse,
|
||||||
|
float _constantAttenuation,
|
||||||
|
float _linearAttenuation,
|
||||||
|
float _quadraticAttenuation,
|
||||||
|
float _spotExponent
|
||||||
|
);
|
||||||
|
|
||||||
void LoadContent();
|
void LoadContent();
|
||||||
|
|
||||||
GLFWwindow* GetWindow() const { return m_Window; }
|
GLFWwindow* GetWindow() const { return m_Window; }
|
||||||
std::shared_ptr<Camera> GetCamera() const { return m_Camera; }
|
std::shared_ptr<Camera> GetCamera() const { return m_Camera; }
|
||||||
|
|
||||||
|
bool DrawNormals() const { return m_DrawNormals; }
|
||||||
|
void DrawNormals(bool val) { m_DrawNormals = val; }
|
||||||
|
bool DrawWireframe() const { return m_DrawWireframe; }
|
||||||
|
void DrawWireframe(bool val) { m_DrawWireframe = val; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow* m_Window;
|
GLFWwindow* m_Window;
|
||||||
GLint m_glVersion[2];
|
GLint m_glVersion[2];
|
||||||
GLchar* m_glVendor;
|
GLchar* m_glVendor;
|
||||||
|
bool m_VSync;
|
||||||
|
bool m_DrawNormals;
|
||||||
|
bool m_DrawWireframe;
|
||||||
|
|
||||||
|
glm::vec3 m_SunPosition;
|
||||||
|
glm::vec3 m_SunTarget;
|
||||||
|
glm::mat4 m_SunProjection;
|
||||||
|
|
||||||
|
GLuint m_ScreenQuad;
|
||||||
|
GLuint m_ShadowFrameBuffer;
|
||||||
|
GLuint m_ShadowDepthTexture;
|
||||||
|
|
||||||
std::shared_ptr<Camera> m_Camera;
|
std::shared_ptr<Camera> m_Camera;
|
||||||
|
|
||||||
GLuint vertexArrayObject;
|
ShaderProgram m_ShaderProgram;
|
||||||
|
ShaderProgram m_ShaderProgramNormals;
|
||||||
|
ShaderProgram m_ShaderProgramShadows;
|
||||||
|
ShaderProgram m_ShaderProgramShadowsDrawDepth;
|
||||||
|
|
||||||
|
void DrawScene();
|
||||||
|
void DrawModels(ShaderProgram &shader);
|
||||||
|
void DrawShadowMap();
|
||||||
|
void CreateShadowMap(int resolution);
|
||||||
|
GLuint CreateQuad();
|
||||||
|
void DrawDebugShadowMap();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Renderer_h__
|
#endif // Renderer_h__
|
||||||
@@ -84,20 +84,16 @@ bool Shader::IsCompiled() const
|
|||||||
return m_ShaderHandle != 0;
|
return m_ShaderHandle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderProgram::ShaderProgram()
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderProgram::~ShaderProgram()
|
ShaderProgram::~ShaderProgram()
|
||||||
{
|
{
|
||||||
Unbind();
|
if (m_ShaderProgramHandle != 0) {
|
||||||
glDeleteProgram(m_ShaderProgramHandle);
|
glDeleteProgram(m_ShaderProgramHandle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderProgram::AddShader(std::unique_ptr<Shader> shader)
|
void ShaderProgram::AddShader(std::shared_ptr<Shader> shader)
|
||||||
{
|
{
|
||||||
m_Shaders.push_back(std::move(shader));
|
m_Shaders.push_back(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderProgram::Compile()
|
void ShaderProgram::Compile()
|
||||||
@@ -111,6 +107,11 @@ void ShaderProgram::Compile()
|
|||||||
|
|
||||||
GLuint ShaderProgram::Link()
|
GLuint ShaderProgram::Link()
|
||||||
{
|
{
|
||||||
|
if (m_Shaders.size() == 0) {
|
||||||
|
LOG_ERROR("Failed to link shader program: No shaders bound");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Linking shader program");
|
LOG_INFO("Linking shader program");
|
||||||
m_ShaderProgramHandle = glCreateProgram();
|
m_ShaderProgramHandle = glCreateProgram();
|
||||||
for (auto &shader : m_Shaders) {
|
for (auto &shader : m_Shaders) {
|
||||||
@@ -119,10 +120,6 @@ GLuint ShaderProgram::Link()
|
|||||||
glLinkProgram(m_ShaderProgramHandle);
|
glLinkProgram(m_ShaderProgramHandle);
|
||||||
if (GLERROR("glLinkProgram"))
|
if (GLERROR("glLinkProgram"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (auto &shader : m_Shaders) {
|
|
||||||
shader.release();
|
|
||||||
}
|
|
||||||
m_Shaders.clear();
|
m_Shaders.clear();
|
||||||
|
|
||||||
return m_ShaderProgramHandle;
|
return m_ShaderProgramHandle;
|
||||||
@@ -145,8 +142,3 @@ void ShaderProgram::Unbind()
|
|||||||
{
|
{
|
||||||
glActiveShaderProgram(0, 0);
|
glActiveShaderProgram(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderProgram::Initialize()
|
|
||||||
{
|
|
||||||
m_ShaderProgramHandle = 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,11 +6,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#include "OpenGL.h"
|
||||||
#include <GL/glew.h>
|
|
||||||
#define GLFW_INCLUDE_GLU
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <glext.h>
|
|
||||||
|
|
||||||
#include "glerror.h"
|
#include "glerror.h"
|
||||||
|
|
||||||
@@ -68,25 +64,20 @@ public:
|
|||||||
class ShaderProgram
|
class ShaderProgram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderProgram();
|
ShaderProgram()
|
||||||
|
: m_ShaderProgramHandle(0) { }
|
||||||
~ShaderProgram();
|
~ShaderProgram();
|
||||||
|
|
||||||
void AddShader(std::unique_ptr<Shader> shader);
|
void AddShader(std::shared_ptr<Shader> shader);
|
||||||
|
|
||||||
void Compile();
|
void Compile();
|
||||||
GLuint Link();
|
GLuint Link();
|
||||||
|
|
||||||
GLuint GetHandle();
|
GLuint GetHandle();
|
||||||
|
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
void Unbind();
|
void Unbind();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint m_ShaderProgramHandle;
|
GLuint m_ShaderProgramHandle;
|
||||||
std::vector<std::unique_ptr<Shader>> m_Shaders;
|
std::vector<std::shared_ptr<Shader>> m_Shaders;
|
||||||
|
|
||||||
void Initialize();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ShaderProgram_h__
|
#endif // ShaderProgram_h__
|
||||||
@@ -3,73 +3,103 @@
|
|||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
|
|
||||||
layout(binding=0) uniform sampler2D texture;
|
layout(binding=0) uniform sampler2D texture0;
|
||||||
|
layout(binding=1) uniform sampler2D shadowMap;
|
||||||
|
|
||||||
uniform vec3 lightPosition;
|
const int numberOfLights = 3;
|
||||||
uniform float constantAttenuation;
|
|
||||||
uniform float linearAttenuation;
|
uniform vec3 position[numberOfLights];
|
||||||
uniform float quadraticAttenuation;
|
uniform vec3 specular[numberOfLights];
|
||||||
|
uniform vec3 diffuse[numberOfLights];
|
||||||
|
uniform float constantAttenuation[numberOfLights];
|
||||||
|
uniform float linearAttenuation[numberOfLights];
|
||||||
|
uniform float quadraticAttenuation[numberOfLights];
|
||||||
|
uniform float spotExponent[numberOfLights];
|
||||||
|
|
||||||
in VertexData {
|
in VertexData {
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
|
vec3 ShadowCoord;
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
|
vec3 scene_ambient = vec3(0.2);
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Texture
|
|
||||||
vec4 texel = texture2D(texture, Input.TextureCoord);
|
|
||||||
//vec4 texel1 = texture2D(texture1, Input.TextureCoord * 32.0);
|
|
||||||
//vec4 texel2 = texture2D(texture2, Input.TextureCoord * 100.0);
|
|
||||||
//vec4 blend = texture2D(blendmap, Input.TextureCoord);
|
|
||||||
|
|
||||||
|
// Texture
|
||||||
|
vec4 texel = texture2D(texture0, Input.TextureCoord);
|
||||||
//vec4 texel = (blend.x * texel0) + (blend.y * texel1) + (blend.z * texel2);
|
//vec4 texel = (blend.x * texel0) + (blend.y * texel1) + (blend.z * texel2);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Phong shading
|
// Phong shading
|
||||||
//
|
//
|
||||||
|
|
||||||
// Light
|
// Ambient light
|
||||||
//vec3 lightPosition = vec3(0, 0, 2);
|
vec3 La = scene_ambient; // Ambient light
|
||||||
vec3 Ls = vec3(1.0, 1.0, 0.9); // Specular light
|
|
||||||
vec3 Ld = vec3(1.0, 1.0, 0.9); // Diffuse light
|
|
||||||
vec3 La = vec3(0.6, 0.6, 0.6); // Ambient light
|
|
||||||
|
|
||||||
// Object
|
|
||||||
vec3 Ks = vec3(0.3, 0.3, 0.3); // Specular reflectance
|
vec3 Ks = vec3(0.3, 0.3, 0.3); // Specular reflectance
|
||||||
vec3 Kd = vec3(1.0, 1.0, 1.0); // Diffuse reflectance
|
vec3 Kd = vec3(1.0, 1.0, 1.0); // Diffuse reflectance
|
||||||
vec3 Ka = vec3(1.0, 1.0, 1.0); // Ambient reflectance
|
vec3 Ka = vec3(1.0, 1.0, 1.0); // Ambient reflectance
|
||||||
|
vec3 Is;
|
||||||
|
vec3 Id;
|
||||||
|
|
||||||
vec3 lightPosView = vec3(view * vec4(lightPosition, 1.0));
|
// Shadows
|
||||||
|
//float cosTheta = clamp(dot(Input.Normal, vec3(0, 1, 0)), 0.0, 1.0);
|
||||||
|
//float bias = 0.001 * tan(acos(cosTheta)); // cosTheta is dot( n,l ), clamped between 0 and 1
|
||||||
|
//bias = clamp(bias, 0.0, 0.01);
|
||||||
|
float bias = 0.003;
|
||||||
|
float visibility = 1.0;
|
||||||
|
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
|
||||||
|
if (shadowMapValue.z < Input.ShadowCoord.z - bias) {
|
||||||
|
visibility = 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 totalLighting = La * Ka * visibility;
|
||||||
|
|
||||||
|
float attenuation;
|
||||||
|
|
||||||
|
for(int i = 0; i < numberOfLights; i++)
|
||||||
|
{
|
||||||
|
// Light
|
||||||
|
//vec3 lightPosition = vec3(0, 0, 2);
|
||||||
|
vec3 Ls = specular[i]; // Specular light
|
||||||
|
vec3 Ld = diffuse[i]; // Diffuse light
|
||||||
|
|
||||||
|
vec3 lightPosView = vec3(view * vec4(position[i], 1.0));
|
||||||
vec3 surfacePosition = vec3(model * vec4(Input.Position, 1.0));
|
vec3 surfacePosition = vec3(model * vec4(Input.Position, 1.0));
|
||||||
vec3 surfacePosView = vec3(view * vec4(surfacePosition, 1.0));
|
vec3 surfacePosView = vec3(view * vec4(surfacePosition, 1.0));
|
||||||
vec3 surfaceToLight = normalize(lightPosView - surfacePosView);
|
vec3 surfaceToLight = normalize(lightPosView - surfacePosView);
|
||||||
mat3 normalMatrix = transpose(inverse(mat3(view * model)));
|
mat3 normalMatrix = transpose(inverse(mat3(view * model)));
|
||||||
vec3 surfaceNormal = normalize(normalMatrix * Input.Normal);
|
vec3 surfaceNormal = normalize(normalMatrix * Input.Normal);
|
||||||
|
|
||||||
|
float dist = length(position[i] - surfacePosition);
|
||||||
|
|
||||||
|
attenuation = 1.0 / (constantAttenuation[i]
|
||||||
|
+ linearAttenuation[i] * dist
|
||||||
|
+ quadraticAttenuation[i] * pow(dist, 2.0));
|
||||||
|
//attenuation = attenuation * pow(clampedCosine, spotExponent[i]);
|
||||||
|
|
||||||
|
// Diffuse light
|
||||||
|
float dotProd = dot(surfaceToLight, surfaceNormal);
|
||||||
|
dotProd = max(dotProd, 0.0);
|
||||||
|
|
||||||
|
Id = Ld * Kd * abs(dotProd) * attenuation;
|
||||||
|
|
||||||
// Specular light
|
// Specular light
|
||||||
vec3 reflection = reflect(-surfaceToLight, surfaceNormal);
|
vec3 reflection = reflect(-surfaceToLight, surfaceNormal);
|
||||||
float dotSpecular = dot(reflection, normalize(-surfacePosView));
|
float dotSpecular = dot(reflection, normalize(-surfacePosView));
|
||||||
dotSpecular = max(dotSpecular, 0.0);
|
dotSpecular = max(dotSpecular, 0.0);
|
||||||
float specularFactor = pow(dotSpecular, 30.0); // Specular factor
|
float specularFactor = pow(dotSpecular, 30.0); // Specular factor
|
||||||
vec3 Is = Ls * Ks * specularFactor;
|
|
||||||
|
|
||||||
// Diffuse light
|
Is = attenuation * Ls * Ks * specularFactor;
|
||||||
float dotProd = dot(surfaceToLight, surfaceNormal);
|
|
||||||
dotProd = max(dotProd, 0.0);
|
|
||||||
vec3 Id = Ld * Kd * abs(dotProd);
|
|
||||||
|
|
||||||
// Ambient light
|
totalLighting = totalLighting + Id + Is;
|
||||||
vec3 Ia = La * Ka;
|
}
|
||||||
|
|
||||||
float dist = length(lightPosition - surfacePosition);
|
fragmentColor = vec4(totalLighting, 1.0) * texel;
|
||||||
float attenuation = 1.0 / (constantAttenuation
|
|
||||||
+ linearAttenuation * dist
|
|
||||||
+ quadraticAttenuation * pow(dist, 2.0));
|
|
||||||
|
|
||||||
fragmentColor = vec4((Is + Id) * attenuation + Ia, 1.0) * texel;
|
|
||||||
|
|
||||||
//fragmentColor = vec4(Id, 1.0) * texel;
|
//fragmentColor = vec4(Id, 1.0) * texel;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
|
|
||||||
|
out vec4 FragmentColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
FragmentColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
|
|
||||||
|
layout(triangles) in;
|
||||||
|
layout(line_strip, max_vertices = 6) out;
|
||||||
|
|
||||||
|
in VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Input[3];
|
||||||
|
|
||||||
|
out VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < gl_in.length(); i++)
|
||||||
|
{
|
||||||
|
gl_Position = MVP * vec4(Input[i].Position, 1.0);
|
||||||
|
EmitVertex();
|
||||||
|
gl_Position = MVP * vec4(Input[i].Position + Input[i].Normal, 1.0);
|
||||||
|
EmitVertex();
|
||||||
|
EndPrimitive();
|
||||||
|
|
||||||
|
Output.Position = Input[i].Position;
|
||||||
|
Output.Normal = Input[i].Normal;
|
||||||
|
Output.TextureCoord = Input[i].TextureCoord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
|
|
||||||
|
layout(location = 0) out float FragmentDepth;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
FragmentDepth = gl_FragCoord.z;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
layout(location = 1) in vec3 Normal;
|
||||||
|
layout(location = 2) in vec2 TextureCoord;
|
||||||
|
|
||||||
|
out VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = MVP * vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
Output.Normal = Normal;
|
||||||
|
Output.TextureCoord = TextureCoord;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 MVP;
|
uniform mat4 MVP;
|
||||||
|
uniform mat4 DepthMVP;
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
layout(location = 1) in vec3 Normal;
|
layout(location = 1) in vec3 Normal;
|
||||||
@@ -10,6 +11,7 @@ out VertexData {
|
|||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
|
vec3 ShadowCoord;
|
||||||
} Output;
|
} Output;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@@ -19,4 +21,5 @@ void main()
|
|||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.Normal = Normal;
|
Output.Normal = Normal;
|
||||||
Output.TextureCoord = TextureCoord;
|
Output.TextureCoord = TextureCoord;
|
||||||
|
Output.ShadowCoord = vec3(DepthMVP * vec4(Position, 1.0));
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout(binding = 0) uniform sampler2D DepthTexture;
|
||||||
|
|
||||||
|
in VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Input;
|
||||||
|
|
||||||
|
out vec4 FragmentColor;
|
||||||
|
|
||||||
|
float LinearizeDepth(float z)
|
||||||
|
{
|
||||||
|
float n = 0.1; // camera z near
|
||||||
|
float f = 10.0; // camera z far
|
||||||
|
return (2.0 * n) / (f + n - z * (f - n));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
float z = texture(DepthTexture, Input.TextureCoord).x;
|
||||||
|
vec4 color = vec4(z, z, z, 0);
|
||||||
|
|
||||||
|
FragmentColor = color;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
layout(location = 2) in vec2 TextureCoord;
|
||||||
|
|
||||||
|
out VertexData {
|
||||||
|
vec3 Position;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
Output.TextureCoord = TextureCoord;
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -21,10 +21,34 @@ void Systems::InputSystem::Update(double dt)
|
|||||||
glfwGetCursorPos(m_Renderer->GetWindow(), &xpos, &ypos);
|
glfwGetCursorPos(m_Renderer->GetWindow(), &xpos, &ypos);
|
||||||
m_CurrentMouseDeltaX = xpos - m_LastMouseX;
|
m_CurrentMouseDeltaX = xpos - m_LastMouseX;
|
||||||
m_CurrentMouseDeltaY = ypos - m_LastMouseY;
|
m_CurrentMouseDeltaY = ypos - m_LastMouseY;
|
||||||
|
m_LastMouseX = xpos;
|
||||||
|
m_LastMouseY = ypos;
|
||||||
|
|
||||||
|
// Lock mouse while holding LMB
|
||||||
|
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||||
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
|
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
|
||||||
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
|
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
|
||||||
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
|
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
|
||||||
}
|
}
|
||||||
|
// Hide/show cursor with LMB
|
||||||
|
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && !m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||||
|
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
|
}
|
||||||
|
if (!m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||||
|
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Wireframe
|
||||||
|
if (m_CurrentKeyState[GLFW_KEY_F1] && !m_LastKeyState[GLFW_KEY_F1]) {
|
||||||
|
m_Renderer->DrawWireframe(!m_Renderer->DrawWireframe());
|
||||||
|
}
|
||||||
|
// Normals
|
||||||
|
if (m_CurrentKeyState[GLFW_KEY_F2] && !m_LastKeyState[GLFW_KEY_F2]) {
|
||||||
|
m_Renderer->DrawNormals(!m_Renderer->DrawNormals());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
@@ -39,3 +63,6 @@ void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
input->dX = m_CurrentMouseDeltaX;
|
input->dX = m_CurrentMouseDeltaX;
|
||||||
input->dY = m_CurrentMouseDeltaY;
|
input->dY = m_CurrentMouseDeltaY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::array<int, GLFW_KEY_LAST+1> Systems::InputSystem::m_CurrentKeyState;
|
||||||
|
std::array<int, GLFW_KEY_LAST+1> Systems::InputSystem::m_LastKeyState;
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Renderer> m_Renderer;
|
std::shared_ptr<Renderer> m_Renderer;
|
||||||
|
static std::array<int, GLFW_KEY_LAST+1> m_CurrentKeyState;
|
||||||
std::array<int, GLFW_KEY_LAST+1> m_CurrentKeyState;
|
static std::array<int, GLFW_KEY_LAST+1> m_LastKeyState;
|
||||||
std::array<int, GLFW_KEY_LAST+1> m_LastKeyState;
|
|
||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
|
||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
|
||||||
float m_CurrentMouseDeltaX, m_CurrentMouseDeltaY;
|
float m_CurrentMouseDeltaX, m_CurrentMouseDeltaY;
|
||||||
float m_LastMouseX, m_LastMouseY;
|
float m_LastMouseX, m_LastMouseY;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,31 +19,34 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
|
|
||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if (name == "Camera") {
|
if (name == "Camera") {
|
||||||
|
if (input->MouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||||
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
||||||
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
||||||
|
|
||||||
|
float speed = 8.0f;
|
||||||
float speed = 4.0f;
|
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
||||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
|
speed *= 2.0f;
|
||||||
{
|
|
||||||
speed = 1.0f;
|
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_A] == GLFW_PRESS)
|
if(input->KeyState[GLFW_KEY_LEFT_ALT]) {
|
||||||
{
|
speed /= 2.0f;
|
||||||
transform->Position -= Camera_Right * (float)dt*2.f * speed;
|
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_D] == GLFW_PRESS)
|
if(input->KeyState[GLFW_KEY_A]) {
|
||||||
{
|
transform->Position -= Camera_Right * (float)dt * speed;
|
||||||
transform->Position += Camera_Right * (float)dt*2.f * speed;
|
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_W] == GLFW_PRESS)
|
if(input->KeyState[GLFW_KEY_D]) {
|
||||||
{
|
transform->Position += Camera_Right * (float)dt * speed;
|
||||||
transform->Position -= Camera_Forward * (float)dt*2.f * speed;
|
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_S] == GLFW_PRESS)
|
if(input->KeyState[GLFW_KEY_W]) {
|
||||||
{
|
transform->Position -= Camera_Forward * (float)dt * speed;
|
||||||
transform->Position += Camera_Forward * (float)dt*2.f * speed;
|
}
|
||||||
|
if(input->KeyState[GLFW_KEY_S]) {
|
||||||
|
transform->Position += Camera_Forward * (float)dt * speed;
|
||||||
|
}
|
||||||
|
if(input->KeyState[GLFW_KEY_SPACE]) {
|
||||||
|
transform->Position += glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||||
|
}
|
||||||
|
if(input->KeyState[GLFW_KEY_LEFT_CONTROL]) {
|
||||||
|
transform->Position -= glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||||
@@ -53,7 +56,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>(input->dX/300.f,glm::vec3(0,1,0));
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>(input->dX/300.f,glm::vec3(0,1,0));
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Renderer.h"
|
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
#include "Components/Input.h"
|
#include "Components/Input.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|||||||
@@ -15,16 +15,31 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
||||||
if (transformComponent == nullptr)
|
if (transformComponent == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Draw models
|
||||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
|
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
|
||||||
if (modelComponent != nullptr)
|
if (modelComponent != nullptr)
|
||||||
{
|
{
|
||||||
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
|
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
|
||||||
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
|
m_CachedModels[modelComponent->ModelFile] = std::make_shared<Model>(OBJ(modelComponent->ModelFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* model = m_CachedModels[modelComponent->ModelFile];
|
auto model = m_CachedModels[modelComponent->ModelFile];
|
||||||
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
|
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
|
||||||
}
|
}
|
||||||
|
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity, "PointLight");
|
||||||
|
if (pointLightComponent != nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_Renderer->AddPointLightToDraw(
|
||||||
|
transformComponent->Position,
|
||||||
|
pointLightComponent->Specular,
|
||||||
|
pointLightComponent->Diffuse,
|
||||||
|
pointLightComponent->constantAttenuation,
|
||||||
|
pointLightComponent->linearAttenuation,
|
||||||
|
pointLightComponent->quadraticAttenuation,
|
||||||
|
pointLightComponent->spotExponent);
|
||||||
|
}
|
||||||
auto cameraComponent = m_World->GetComponent<Components::Camera>(entity, "Camera");
|
auto cameraComponent = m_World->GetComponent<Components::Camera>(entity, "Camera");
|
||||||
if (cameraComponent != nullptr)
|
if (cameraComponent != nullptr)
|
||||||
{
|
{
|
||||||
@@ -35,8 +50,6 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
|
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
|
||||||
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
|
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#include "RenderSystem.h"
|
|
||||||
#include "World.h"
|
|
||||||
|
|
||||||
void Systems::RenderSystem::OnComponentCreated( std::string type, std:: shared_ptr<Component> component )
|
|
||||||
{
|
|
||||||
if(type == "Model")
|
|
||||||
{
|
|
||||||
auto modelComponent = std::static_pointer_cast<Components::Model>(component);
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (m_CachedModels.find(modelComponent->ModelFile) != m_CachedModels.end()) {
|
|
||||||
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
>>>>>>> ce6b570520794087eb98447a571578585a705ded
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
|
|
||||||
{
|
|
||||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
|
|
||||||
if (modelComponent == nullptr)
|
|
||||||
return;
|
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
|
||||||
if (transformComponent == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()) {
|
|
||||||
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
|
|
||||||
}
|
|
||||||
Model* model = m_CachedModels[modelComponent->ModelFile];
|
|
||||||
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef RenderSystem_h__
|
#ifndef RenderSystem_h__
|
||||||
#define RenderSystem_h__
|
#define RenderSystem_h__
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
@@ -8,7 +10,6 @@
|
|||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
#include "Components/Camera.h"
|
#include "Components/Camera.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -19,7 +20,7 @@ namespace Systems
|
|||||||
RenderSystem(World* world, std::shared_ptr<Renderer> renderer)
|
RenderSystem(World* world, std::shared_ptr<Renderer> renderer)
|
||||||
: System(world), m_Renderer(renderer) {}
|
: System(world), m_Renderer(renderer) {}
|
||||||
|
|
||||||
std::unordered_map<std::string, Model*> m_CachedModels;
|
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
|
||||||
|
|
||||||
void OnComponentCreated(std::string type, std:: shared_ptr<Component> component) override;
|
void OnComponentCreated(std::string type, std:: shared_ptr<Component> component) override;
|
||||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
Texture::Texture( const char* path )
|
Texture::Texture(std::string path)
|
||||||
{
|
{
|
||||||
Load(path);
|
Load(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Texture::Load( const char* path )
|
void Texture::Load(std::string path)
|
||||||
{
|
{
|
||||||
texture = SOIL_load_OGL_texture(path, 0, 0, SOIL_FLAG_INVERT_Y);
|
texture = SOIL_load_OGL_texture(path.c_str(), 0, 0, SOIL_FLAG_INVERT_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::Bind()
|
void Texture::Bind()
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
#ifndef Texture_h__
|
#ifndef Texture_h__
|
||||||
#define Texture_h__
|
#define Texture_h__
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <string>
|
||||||
#define GLFW_INCLUDE_GLU
|
|
||||||
#include <GLFW/glfw3.h>
|
#include "OpenGL.h"
|
||||||
#include <glext.h>
|
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
|
||||||
class Texture
|
class Texture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture(const char* path);
|
Texture(std::string path);
|
||||||
|
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
|
|
||||||
void Load(const char* path);
|
void Load(std::string path);
|
||||||
void Bind();
|
void Bind();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#ifndef _GLERROR_H
|
#ifndef _GLERROR_H
|
||||||
#define _GLERROR_H
|
#define _GLERROR_H
|
||||||
|
|
||||||
#define GLFW_INCLUDE_GLU
|
|
||||||
#include <GLFW\glfw3.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define DEBUG_H
|
#define DEBUG_H
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
// http://stackoverflow.com/a/2282433
|
// http://stackoverflow.com/a/2282433
|
||||||
#define __func__ __FUNCTION__
|
#define __func__ __FUNCTION__
|
||||||
// http://stackoverflow.com/a/8488201
|
// http://stackoverflow.com/a/8488201
|
||||||
@@ -46,10 +47,13 @@ static void _LOG(_LOG_LEVEL logLevel, char* file, char* func, unsigned int line,
|
|||||||
if (logLevel > LOG_LEVEL)
|
if (logLevel > LOG_LEVEL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char message[512];
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf_s(message, 512, format, args);
|
char* message = nullptr;
|
||||||
|
size_t size = vsnprintf(message, 0, format, args);
|
||||||
|
message = new char[size+1];
|
||||||
|
message[size] = '\0';
|
||||||
|
vsnprintf(message, size, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (logLevel == LOG_LEVEL_ERROR)
|
if (logLevel == LOG_LEVEL_ERROR)
|
||||||
@@ -61,6 +65,8 @@ static void _LOG(_LOG_LEVEL logLevel, char* file, char* func, unsigned int line,
|
|||||||
{
|
{
|
||||||
std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;
|
std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] message;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG(logLevel, format, ...) \
|
#define LOG(logLevel, format, ...) \
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material.001
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd ObstacleTexture.png
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Blender v2.69 (sub 0) OBJ File: 'obstaclesandstuff.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib plane.mtl
|
||||||
|
o Plane_Plane.001
|
||||||
|
v 102.461288 0.778257 97.553291
|
||||||
|
v -97.538712 0.778257 97.553291
|
||||||
|
v 102.461288 0.778257 -102.446709
|
||||||
|
v -97.538712 0.778257 -102.446709
|
||||||
|
vt 0.000100 0.000100
|
||||||
|
vt 0.999900 0.000100
|
||||||
|
vt 0.000100 0.999900
|
||||||
|
vt 0.999900 0.999900
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
usemtl Material.004
|
||||||
|
s off
|
||||||
|
f 2/1/1 1/2/1 4/3/1
|
||||||
|
f 1/2/1 3/4/1 4/3/1
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender MTL File: 'obstaclesandstuff.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material.001
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd ObstacleTexture.png
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
# Blender v2.69 (sub 0) OBJ File: 'obstaclesandstuff.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib sphere.mtl
|
||||||
|
o Icosphere
|
||||||
|
v -0.000000 -0.184854 -0.000000
|
||||||
|
v 0.133761 -0.082670 0.097182
|
||||||
|
v -0.051091 -0.082670 0.157246
|
||||||
|
v -0.165338 -0.082669 -0.000000
|
||||||
|
v -0.051091 -0.082670 -0.157246
|
||||||
|
v 0.133761 -0.082670 -0.097182
|
||||||
|
v 0.051091 0.082670 0.157246
|
||||||
|
v -0.133761 0.082670 0.097182
|
||||||
|
v -0.133761 0.082670 -0.097182
|
||||||
|
v 0.051091 0.082670 -0.157246
|
||||||
|
v 0.165338 0.082669 -0.000000
|
||||||
|
v -0.000000 0.184854 -0.000000
|
||||||
|
v -0.030031 -0.157247 0.092426
|
||||||
|
v 0.078622 -0.157247 0.057122
|
||||||
|
v 0.048592 -0.097185 0.149549
|
||||||
|
v 0.157245 -0.097184 -0.000000
|
||||||
|
v 0.078622 -0.157247 -0.057122
|
||||||
|
v -0.097183 -0.157246 -0.000000
|
||||||
|
v -0.127214 -0.097184 0.092426
|
||||||
|
v -0.030031 -0.157247 -0.092426
|
||||||
|
v -0.127214 -0.097184 -0.092426
|
||||||
|
v 0.048592 -0.097185 -0.149549
|
||||||
|
v 0.175807 0.000000 0.057122
|
||||||
|
v 0.175807 0.000000 -0.057122
|
||||||
|
v -0.000000 0.000000 0.184854
|
||||||
|
v 0.108654 0.000000 0.149550
|
||||||
|
v -0.175807 0.000000 0.057122
|
||||||
|
v -0.108654 0.000000 0.149550
|
||||||
|
v -0.108654 0.000000 -0.149550
|
||||||
|
v -0.175807 0.000000 -0.057122
|
||||||
|
v 0.108654 0.000000 -0.149550
|
||||||
|
v -0.000000 0.000000 -0.184854
|
||||||
|
v 0.127214 0.097184 0.092426
|
||||||
|
v -0.048592 0.097185 0.149549
|
||||||
|
v -0.157245 0.097184 -0.000000
|
||||||
|
v -0.048592 0.097185 -0.149549
|
||||||
|
v 0.127214 0.097184 -0.092426
|
||||||
|
v 0.030031 0.157247 0.092426
|
||||||
|
v 0.097183 0.157246 -0.000000
|
||||||
|
v -0.078622 0.157247 0.057122
|
||||||
|
v -0.078622 0.157247 -0.057122
|
||||||
|
v 0.030031 0.157247 -0.092426
|
||||||
|
vt 0.000000 0.000000
|
||||||
|
vt 1.000000 0.000000
|
||||||
|
vt 1.000000 1.000000
|
||||||
|
vn 0.102381 -0.943523 0.315090
|
||||||
|
vn 0.700224 -0.661699 0.268032
|
||||||
|
vn -0.268034 -0.943523 0.194737
|
||||||
|
vn -0.268034 -0.943523 -0.194737
|
||||||
|
vn 0.102381 -0.943523 -0.315090
|
||||||
|
vn 0.904989 -0.330385 0.268031
|
||||||
|
vn 0.024747 -0.330386 0.943521
|
||||||
|
vn -0.889697 -0.330385 0.315095
|
||||||
|
vn -0.574602 -0.330387 -0.748784
|
||||||
|
vn 0.534576 -0.330386 -0.777865
|
||||||
|
vn 0.802609 -0.125627 0.583127
|
||||||
|
vn -0.306569 -0.125628 0.943522
|
||||||
|
vn -0.992077 -0.125629 0.000000
|
||||||
|
vn -0.306569 -0.125628 -0.943522
|
||||||
|
vn 0.802609 -0.125627 -0.583127
|
||||||
|
vn 0.408946 0.661699 0.628425
|
||||||
|
vn -0.471300 0.661699 0.583122
|
||||||
|
vn -0.700224 0.661699 -0.268032
|
||||||
|
vn 0.038530 0.661699 -0.748779
|
||||||
|
vn 0.724042 0.661695 -0.194736
|
||||||
|
vn -0.038530 -0.661699 0.748779
|
||||||
|
vn 0.187594 -0.794658 0.577345
|
||||||
|
vn 0.471300 -0.661699 0.583122
|
||||||
|
vn 0.700224 -0.661699 -0.268032
|
||||||
|
vn 0.607060 -0.794656 0.000000
|
||||||
|
vn 0.331304 -0.943524 0.000000
|
||||||
|
vn -0.724042 -0.661695 0.194736
|
||||||
|
vn -0.491119 -0.794658 0.356821
|
||||||
|
vn -0.408946 -0.661699 0.628425
|
||||||
|
vn -0.408946 -0.661699 -0.628425
|
||||||
|
vn -0.491119 -0.794657 -0.356821
|
||||||
|
vn -0.724042 -0.661695 -0.194736
|
||||||
|
vn 0.471300 -0.661699 -0.583122
|
||||||
|
vn 0.187594 -0.794658 -0.577345
|
||||||
|
vn -0.038530 -0.661699 -0.748779
|
||||||
|
vn 0.992077 0.125629 0.000000
|
||||||
|
vn 0.982246 -0.187599 0.000000
|
||||||
|
vn 0.904989 -0.330385 -0.268031
|
||||||
|
vn 0.306569 0.125628 0.943522
|
||||||
|
vn 0.303531 -0.187597 0.934171
|
||||||
|
vn 0.534576 -0.330386 0.777865
|
||||||
|
vn -0.802609 0.125627 0.583127
|
||||||
|
vn -0.794655 -0.187595 0.577348
|
||||||
|
vn -0.574602 -0.330387 0.748783
|
||||||
|
vn -0.802609 0.125627 -0.583127
|
||||||
|
vn -0.794655 -0.187595 -0.577348
|
||||||
|
vn -0.889697 -0.330385 -0.315095
|
||||||
|
vn 0.306569 0.125628 -0.943522
|
||||||
|
vn 0.303531 -0.187597 -0.934171
|
||||||
|
vn 0.024747 -0.330386 -0.943521
|
||||||
|
vn 0.574602 0.330387 0.748784
|
||||||
|
vn 0.794656 0.187595 0.577348
|
||||||
|
vn 0.889697 0.330385 0.315095
|
||||||
|
vn -0.534576 0.330386 0.777864
|
||||||
|
vn -0.303531 0.187597 0.934171
|
||||||
|
vn -0.024747 0.330386 0.943521
|
||||||
|
vn -0.904989 0.330385 -0.268031
|
||||||
|
vn -0.982246 0.187599 0.000000
|
||||||
|
vn -0.904989 0.330384 0.268031
|
||||||
|
vn -0.024747 0.330386 -0.943521
|
||||||
|
vn -0.303531 0.187597 -0.934171
|
||||||
|
vn -0.534576 0.330386 -0.777865
|
||||||
|
vn 0.889697 0.330385 -0.315095
|
||||||
|
vn 0.794655 0.187595 -0.577348
|
||||||
|
vn 0.574602 0.330387 -0.748784
|
||||||
|
vn 0.268034 0.943523 0.194737
|
||||||
|
vn 0.491120 0.794657 0.356821
|
||||||
|
vn 0.724042 0.661695 0.194736
|
||||||
|
vn -0.102381 0.943523 0.315090
|
||||||
|
vn -0.187594 0.794658 0.577345
|
||||||
|
vn 0.038530 0.661699 0.748779
|
||||||
|
vn -0.331304 0.943524 0.000000
|
||||||
|
vn -0.607060 0.794656 0.000000
|
||||||
|
vn -0.700224 0.661699 0.268032
|
||||||
|
vn -0.102381 0.943524 -0.315090
|
||||||
|
vn -0.187594 0.794658 -0.577345
|
||||||
|
vn -0.471300 0.661699 -0.583122
|
||||||
|
vn 0.268034 0.943523 -0.194736
|
||||||
|
vn 0.491120 0.794657 -0.356821
|
||||||
|
vn 0.408947 0.661699 -0.628425
|
||||||
|
usemtl Material.001
|
||||||
|
s off
|
||||||
|
f 1/1/1 14/2/1 13/3/1
|
||||||
|
f 2/1/2 14/2/2 16/3/2
|
||||||
|
f 1/1/3 13/2/3 18/3/3
|
||||||
|
f 1/1/4 18/2/4 20/3/4
|
||||||
|
f 1/1/5 20/2/5 17/3/5
|
||||||
|
f 2/1/6 16/2/6 23/3/6
|
||||||
|
f 3/1/7 15/2/7 25/3/7
|
||||||
|
f 4/1/8 19/2/8 27/3/8
|
||||||
|
f 5/1/9 21/2/9 29/3/9
|
||||||
|
f 6/1/10 22/2/10 31/3/10
|
||||||
|
f 2/1/11 23/2/11 26/3/11
|
||||||
|
f 3/1/12 25/2/12 28/3/12
|
||||||
|
f 4/1/13 27/2/13 30/3/13
|
||||||
|
f 5/1/14 29/2/14 32/3/14
|
||||||
|
f 6/1/15 31/2/15 24/3/15
|
||||||
|
f 7/1/16 33/2/16 38/3/16
|
||||||
|
f 8/1/17 34/2/17 40/3/17
|
||||||
|
f 9/1/18 35/2/18 41/3/18
|
||||||
|
f 10/1/19 36/2/19 42/3/19
|
||||||
|
f 11/1/20 37/2/20 39/3/20
|
||||||
|
f 13/1/21 15/2/21 3/3/21
|
||||||
|
f 13/1/22 14/2/22 15/3/22
|
||||||
|
f 14/1/23 2/2/23 15/3/23
|
||||||
|
f 16/1/24 17/2/24 6/3/24
|
||||||
|
f 16/1/25 14/2/25 17/3/25
|
||||||
|
f 14/1/26 1/2/26 17/3/26
|
||||||
|
f 18/1/27 19/2/27 4/3/27
|
||||||
|
f 18/1/28 13/2/28 19/3/28
|
||||||
|
f 13/1/29 3/2/29 19/3/29
|
||||||
|
f 20/1/30 21/2/30 5/3/30
|
||||||
|
f 20/1/31 18/2/31 21/3/31
|
||||||
|
f 18/1/32 4/2/32 21/3/32
|
||||||
|
f 17/1/33 22/2/33 6/3/33
|
||||||
|
f 17/1/34 20/2/34 22/3/34
|
||||||
|
f 20/1/35 5/2/35 22/3/35
|
||||||
|
f 23/1/36 24/2/36 11/3/36
|
||||||
|
f 23/1/37 16/2/37 24/3/37
|
||||||
|
f 16/1/38 6/2/38 24/3/38
|
||||||
|
f 25/1/39 26/2/39 7/3/39
|
||||||
|
f 25/1/40 15/2/40 26/3/40
|
||||||
|
f 15/1/41 2/2/41 26/3/41
|
||||||
|
f 27/1/42 28/2/42 8/3/42
|
||||||
|
f 27/1/43 19/2/43 28/3/43
|
||||||
|
f 19/1/44 3/2/44 28/3/44
|
||||||
|
f 29/1/45 30/2/45 9/3/45
|
||||||
|
f 29/1/46 21/2/46 30/3/46
|
||||||
|
f 21/1/47 4/2/47 30/3/47
|
||||||
|
f 31/1/48 32/2/48 10/3/48
|
||||||
|
f 31/1/49 22/2/49 32/3/49
|
||||||
|
f 22/1/50 5/2/50 32/3/50
|
||||||
|
f 26/1/51 33/2/51 7/3/51
|
||||||
|
f 26/1/52 23/2/52 33/3/52
|
||||||
|
f 23/1/53 11/2/53 33/3/53
|
||||||
|
f 28/1/54 34/2/54 8/3/54
|
||||||
|
f 28/1/55 25/2/55 34/3/55
|
||||||
|
f 25/1/56 7/2/56 34/3/56
|
||||||
|
f 30/1/57 35/2/57 9/3/57
|
||||||
|
f 30/1/58 27/2/58 35/3/58
|
||||||
|
f 27/1/59 8/2/59 35/3/59
|
||||||
|
f 32/1/60 36/2/60 10/3/60
|
||||||
|
f 32/1/61 29/2/61 36/3/61
|
||||||
|
f 29/1/62 9/2/62 36/3/62
|
||||||
|
f 24/1/63 37/2/63 11/3/63
|
||||||
|
f 24/1/64 31/2/64 37/3/64
|
||||||
|
f 31/1/65 10/2/65 37/3/65
|
||||||
|
f 38/1/66 39/2/66 12/3/66
|
||||||
|
f 38/1/67 33/2/67 39/3/67
|
||||||
|
f 33/1/68 11/2/68 39/3/68
|
||||||
|
f 40/1/69 38/2/69 12/3/69
|
||||||
|
f 40/1/70 34/2/70 38/3/70
|
||||||
|
f 34/1/71 7/2/71 38/3/71
|
||||||
|
f 41/1/72 40/2/72 12/3/72
|
||||||
|
f 41/1/73 35/2/73 40/3/73
|
||||||
|
f 35/1/74 8/2/74 40/3/74
|
||||||
|
f 42/1/75 41/2/75 12/3/75
|
||||||
|
f 42/1/76 36/2/76 41/3/76
|
||||||
|
f 36/1/77 9/2/77 41/3/77
|
||||||
|
f 39/1/78 42/2/78 12/3/78
|
||||||
|
f 39/1/79 37/2/79 42/3/79
|
||||||
|
f 37/1/80 10/2/80 42/3/80
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,115 @@
|
|||||||
|
# Max2Mtl Version 4.0 Mar 10th, 2001
|
||||||
|
#
|
||||||
|
# Multi/Sub Material__10791 (9) to come
|
||||||
|
#
|
||||||
|
newmtl Material__46
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__47
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__48
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__49
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__50
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__51
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__52
|
||||||
|
Ka 0.1 0.1 0.1
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.5
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__10657
|
||||||
|
Ka 0.6 0.6 0.6
|
||||||
|
Kd 0.6 0.6 0.6
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__10658
|
||||||
|
Ka 0.6 0.6 0.6
|
||||||
|
Kd 0.6 0.6 0.6
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
# Multi/Sub Material__10791 done
|
||||||
|
#
|
||||||
|
# Multi/Sub Material__10737 (3) to come
|
||||||
|
#
|
||||||
|
newmtl Material__10678
|
||||||
|
Ka 1.0 1.0 1.0
|
||||||
|
Kd 1.0 1.0 1.0
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__69
|
||||||
|
Ka 0.6 0.6 0.6
|
||||||
|
Kd 0.6 0.6 0.6
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
newmtl Material__10677
|
||||||
|
Ka 0.6 0.6 0.6
|
||||||
|
Kd 0.6 0.6 0.6
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
# Multi/Sub Material__10737 done
|
||||||
|
#
|
||||||
|
newmtl 03_-_Default
|
||||||
|
Ka 0.5 0.5 0.5
|
||||||
|
Kd 0.5 0.5 0.5
|
||||||
|
Ks 0.9 0.9 0.9
|
||||||
|
d 1.0
|
||||||
|
Ns 0.0
|
||||||
|
illum 2
|
||||||
|
#
|
||||||
|
# EOF
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,91 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{A9755CAA-62DC-442D-B82C-F548546CFD38}</ProjectGuid>
|
|
||||||
<RootNamespace>Executable</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
|
||||||
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
|
||||||
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>GLEW_STATIC;DEBUG;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>GLEW_STATIC;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="main.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
|
|
||||||
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="main.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,107 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}</ProjectGuid>
|
|
||||||
<RootNamespace>Tests</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
|
|
||||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
|
|
||||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>boost_unit_test_framework-vc110-gd-1_55.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent />
|
|
||||||
<PostBuildEvent />
|
|
||||||
<PreBuildEvent />
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>"$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Message>Running tests</Message>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalDependencies>boost_unit_test_framework-vc110-1_55.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<PreBuildEvent />
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>"$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Message>Running tests</Message>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="main.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
|
|
||||||
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="main.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#include "logging.h"
|
|
||||||
|
|
||||||
#include "World.h"
|
|
||||||
#include "GameWorld.h"
|
|
||||||
#include "Components/Transform.h"
|
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE World
|
|
||||||
#define BOOST_TEST_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(Parenting)
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
|
|
||||||
// Parenting
|
|
||||||
EntityID ent1 = world.CreateEntity();
|
|
||||||
BOOST_CHECK(ent1 != 0); // 0 is reserved for world
|
|
||||||
BOOST_CHECK(ent1 == 1);
|
|
||||||
BOOST_CHECK(world.GetEntityParent(ent1) == 0);
|
|
||||||
EntityID ent2 = world.CreateEntity(ent1);
|
|
||||||
BOOST_CHECK(ent2 != 0);
|
|
||||||
BOOST_CHECK(ent2 == ent1 + 1);
|
|
||||||
BOOST_CHECK(world.GetEntityParent(ent2) == ent1);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(SceneGraphTraversal)
|
|
||||||
{
|
|
||||||
std::shared_ptr<Renderer> renderer(new Renderer());
|
|
||||||
renderer->Initialize();
|
|
||||||
GameWorld world(renderer);
|
|
||||||
|
|
||||||
EntityID ent1 = world.CreateEntity();
|
|
||||||
auto t1 = world.AddComponent<Components::Transform>(ent1, "Transform");
|
|
||||||
BOOST_REQUIRE(t1 != nullptr);
|
|
||||||
t1->Position[0] = 1.0f;
|
|
||||||
t1->Position[1] = 1.0f;
|
|
||||||
t1->Position[2] = 1.0f;
|
|
||||||
EntityID ent2 = world.CreateEntity(ent1);
|
|
||||||
auto t2 = world.AddComponent<Components::Transform>(ent2, "Transform");
|
|
||||||
BOOST_REQUIRE(t2 != nullptr);
|
|
||||||
t2->Position[0] = 1.0f;
|
|
||||||
t2->Position[1] = 1.0f;
|
|
||||||
t2->Position[2] = 1.0f;
|
|
||||||
|
|
||||||
world.Update(0.0);
|
|
||||||
|
|
||||||
LOG_INFO("ent1: %f %f %f", t1->Position[0], t1->Position[1], t1->Position[2]);
|
|
||||||
LOG_INFO("ent2: %f %f %f", t2->Position[0], t2->Position[1], t2->Position[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(Recycling)
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
|
|
||||||
// EntityID recycling
|
|
||||||
EntityID ent11 = world.CreateEntity(); // 1
|
|
||||||
world.RemoveEntity(ent11);
|
|
||||||
EntityID ent12 = world.CreateEntity(); // 1
|
|
||||||
BOOST_REQUIRE(ent11 == ent12);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ComponentCreation)
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
|
|
||||||
EntityID ent = world.CreateEntity();
|
|
||||||
BOOST_CHECK(world.AddComponent(ent, "Transform") != nullptr);
|
|
||||||
BOOST_CHECK(world.AddComponent(ent, "Input") != nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(Properties)
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
|
|
||||||
EntityID ent = world.CreateEntity();
|
|
||||||
|
|
||||||
world.SetProperty(ent, "String", std::string("derpfish"));
|
|
||||||
world.SetProperty(ent, "Integer", 123);
|
|
||||||
world.SetProperty(ent, "Float", 0.04f);
|
|
||||||
|
|
||||||
BOOST_CHECK(world.GetProperty<std::string>(ent, "String") == "derpfish");
|
|
||||||
BOOST_CHECK(world.GetProperty<int>(ent, "Integer") == 123);
|
|
||||||
BOOST_CHECK(world.GetProperty<float>(ent, "Float") == 0.04f);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user