Ajout de caméra
This commit is contained in:
parent
9d8378784d
commit
7b81f6be61
@ -7,12 +7,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQCSim2021", "SQCSim2021\SQ
|
|||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x64.Build.0 = Debug|x64
|
||||||
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x86.ActiveCfg = Debug|Win32
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x86.Build.0 = Debug|Win32
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x64.Build.0 = Release|x64
|
||||||
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x86.ActiveCfg = Release|Win32
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x86.Build.0 = Release|Win32
|
{A21FD938-1FEA-4687-AB86-0EABAC30877B}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@ -5,10 +5,18 @@
|
|||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="blockarray3d.h" />
|
<ClInclude Include="blockarray3d.h" />
|
||||||
@ -18,6 +26,7 @@
|
|||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
<ClInclude Include="matrix4.h" />
|
<ClInclude Include="matrix4.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
|
<ClInclude Include="player.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
<ClInclude Include="transformation.h" />
|
<ClInclude Include="transformation.h" />
|
||||||
<ClInclude Include="vector3.h" />
|
<ClInclude Include="vector3.h" />
|
||||||
@ -29,6 +38,7 @@
|
|||||||
<ClCompile Include="engine.cpp" />
|
<ClCompile Include="engine.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
|
<ClCompile Include="player.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
<ClCompile Include="transformation.cpp" />
|
<ClCompile Include="transformation.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -49,6 +59,12 @@
|
|||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
@ -56,26 +72,49 @@
|
|||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<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'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>external\devil178\include;external\sfml23\include;$(IncludePath)</IncludePath>
|
<IncludePath>external\devil178\include;external\sfml23\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>external\devil178\lib;external\sfml23\lib;$(LibraryPath)</LibraryPath>
|
<LibraryPath>external\devil178\lib;external\sfml23\lib;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>external\devil178\include;external\sfml23\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>external\devil178\lib;external\sfml23\lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>external\sfml23\include;external\devil178\include;external\glew170\include;$(IncludePath)</IncludePath>
|
<IncludePath>external\sfml23\include;external\devil178\include;external\glew170\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>external\sfml23\lib;external\devil178\lib;external\glew170\lib;$(LibraryPath)</LibraryPath>
|
<LibraryPath>external\sfml23\lib;external\devil178\lib;external\glew170\lib;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>external\sfml23\include;external\devil178\include;external\glew170\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>external\sfml23\lib;external\devil178\lib;external\glew170\lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
@ -90,6 +129,20 @@
|
|||||||
<AdditionalDependencies>sfml-main-d.lib;sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>sfml-main-d.lib;sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>sfml-main-d.lib;sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
@ -108,6 +161,24 @@
|
|||||||
<AdditionalDependencies>sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
@ -41,6 +41,9 @@
|
|||||||
<ClInclude Include="vector3.h">
|
<ClInclude Include="vector3.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="player.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="blockarray3d.cpp">
|
<ClCompile Include="blockarray3d.cpp">
|
||||||
@ -67,6 +70,9 @@
|
|||||||
<ClCompile Include="transformation.cpp">
|
<ClCompile Include="transformation.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="player.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="notes.txt" />
|
<Text Include="notes.txt" />
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
Engine::Engine() { }
|
Engine::Engine() { }
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ void Engine::Render(float elapsedTime)
|
|||||||
|
|
||||||
gameTime += elapsedTime;
|
gameTime += elapsedTime;
|
||||||
|
|
||||||
Transformation cube;
|
Transformation all;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
@ -65,49 +66,53 @@ void Engine::Render(float elapsedTime)
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
|
||||||
|
m_player.Move(m_keyW, m_keyS, m_keyA, m_keyD, elapsedTime);
|
||||||
|
m_player.ApplyTransformation(all);
|
||||||
|
|
||||||
// Skybox
|
// Skybox
|
||||||
m_textureSkybox.Bind();
|
m_textureSkybox.Bind();
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex3f(10.f, 10.f, 10.f);
|
glVertex3f(100.f, 100.f, 100.f);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(-10.f, 10.f, 10.f);
|
glVertex3f(-100.f, 100.f, 100.f);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(-10.f, -10.f, 10.f);
|
glVertex3f(-100.f, -3.f, 100.f);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex3f(10.f, -10.f, 10.f);
|
glVertex3f(100.f, -3.f, 100.f);
|
||||||
|
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex3f(10.f, -10.f, -10.f);
|
glVertex3f(100.f, -3.f, -100.f);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(-10.f, -10.f, -10.f);
|
glVertex3f(-100.f, -3.f, -100.f);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(-10.f, 10.f, -10.f);
|
glVertex3f(-100.f, 100.f, -100.f);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex3f(10.f, 10.f, -10.f);
|
glVertex3f(100.f, 100.f, -100.f);
|
||||||
|
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex3f(-10.f, 10.f, 10.f);
|
glVertex3f(-100.f, 100.f, 100.f);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(-10.f, 10.f, -10.f);
|
glVertex3f(-100.f, 100.f, -100.f);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(-10.f, -10.f, -10.f);
|
glVertex3f(-100.f, -3.f, -100.f);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex3f(-10.f, -10.f, 10.f);
|
glVertex3f(-100.f, -3.f, 100.f);
|
||||||
|
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex3f(10.f, 10.f, -10.f);
|
glVertex3f(100.f, 100.f, -100.f);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(10.f, 10.f, 10.f);
|
glVertex3f(100.f, 100.f, 100.f);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(10.f, -10.f, 10.f);
|
glVertex3f(100.f, -3.f, 100.f);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex3f(10.f, -10.f, -10.f);
|
glVertex3f(100.f, -3.f, -100.f);
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
all.Use();
|
||||||
// Plancher
|
// Plancher
|
||||||
// Les vertex doivent etre affiches dans le sens anti-horaire (CCW)
|
// Les vertex doivent etre affiches dans le sens anti-horaire (CCW)
|
||||||
m_textureFloor.Bind();
|
m_textureFloor.Bind();
|
||||||
@ -124,12 +129,13 @@ void Engine::Render(float elapsedTime)
|
|||||||
glVertex3f(-100.f, -2.f, -100.f);
|
glVertex3f(-100.f, -2.f, -100.f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
// Cube
|
// Cube
|
||||||
cube.ApplyTranslation(0.f, 0.f, -10.f);
|
all.ApplyTranslation(0.f, 0.f, -10.f);
|
||||||
cube.ApplyRotation(gameTime * 100.f, 0.f, 1.f, 0.f);
|
all.ApplyRotation(gameTime * 100.f, 0.f, 1.f, 0.f);
|
||||||
cube.ApplyRotation(gameTime * 100.f, 0.f, 0.f, 1.f);
|
all.ApplyRotation(gameTime * 100.f, 0.f, 0.f, 1.f);
|
||||||
cube.ApplyRotation(gameTime * 100.f, 1.f, 0.f, 0.f);
|
all.ApplyRotation(gameTime * 100.f, 1.f, 0.f, 0.f);
|
||||||
cube.Use();
|
all.Use();
|
||||||
m_textureCube.Bind();
|
m_textureCube.Bind();
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
@ -153,7 +159,7 @@ void Engine::Render(float elapsedTime)
|
|||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(-0.5f, 0.5f, 0.5f);
|
glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
glNormal3f(0, -1, 0);
|
glNormal3f(0, 1, 0);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(-0.5f, -0.5f, -0.5f);
|
glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
@ -163,7 +169,7 @@ void Engine::Render(float elapsedTime)
|
|||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex3f(-0.5f, -0.5f, 0.5f);
|
glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||||
|
|
||||||
glNormal3f(0, 1, 0);
|
glNormal3f(0, -1, 0);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
@ -270,6 +276,9 @@ void Engine::KeyReleaseEvent(unsigned char key)
|
|||||||
|
|
||||||
void Engine::MouseMoveEvent(int x, int y)
|
void Engine::MouseMoveEvent(int x, int y)
|
||||||
{
|
{
|
||||||
|
m_player.TurnLeftRight(y - (Height() / 2));
|
||||||
|
m_player.TurnTopBottom(x - (Width() / 2));
|
||||||
|
|
||||||
// Centrer la souris seulement si elle n'est pas déjà centrée
|
// Centrer la souris seulement si elle n'est pas déjà centrée
|
||||||
// Il est nécessaire de faire la vérification pour éviter de tomber
|
// Il est nécessaire de faire la vérification pour éviter de tomber
|
||||||
// dans une boucle infinie où l'appel à CenterMouse génère un
|
// dans une boucle infinie où l'appel à CenterMouse génère un
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "openglcontext.h"
|
#include "openglcontext.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext
|
class Engine : public OpenglContext
|
||||||
{
|
{
|
||||||
@ -31,6 +32,8 @@ private:
|
|||||||
Texture m_textureSkybox;
|
Texture m_textureSkybox;
|
||||||
Texture m_textureCube;
|
Texture m_textureCube;
|
||||||
|
|
||||||
|
Player m_player = Player(Vector3f(0, 0, 0));
|
||||||
|
|
||||||
bool m_keyW = false;
|
bool m_keyW = false;
|
||||||
bool m_keyA = false;
|
bool m_keyA = false;
|
||||||
bool m_keyS = false;
|
bool m_keyS = false;
|
||||||
|
47
SQCSim2021/player.cpp
Normal file
47
SQCSim2021/player.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) { }
|
||||||
|
|
||||||
|
void Player::TurnLeftRight(float value) {
|
||||||
|
m_rotX += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::TurnTopBottom(float value) {
|
||||||
|
m_rotY += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::Move(bool front, bool back, bool left, bool right, float elapsedTime) {
|
||||||
|
float xrotrad, yrotrad;
|
||||||
|
|
||||||
|
if (front) {
|
||||||
|
yrotrad = (m_rotY / 180 * 3.141592654f);
|
||||||
|
xrotrad = (m_rotX / 180 * 3.141592654f);
|
||||||
|
m_position.x += float(sin(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.z += float(-cos(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.y += float(-sin(xrotrad)) * elapsedTime * 10;
|
||||||
|
}
|
||||||
|
else if (back) {
|
||||||
|
yrotrad = (m_rotY / 180 * 3.141592654f);
|
||||||
|
xrotrad = (m_rotX / 180 * 3.141592654f);
|
||||||
|
m_position.x += float(-sin(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.z += float(cos(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.y += float(sin(xrotrad)) * elapsedTime * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (left) {
|
||||||
|
yrotrad = (m_rotY / 180 * 3.141592654f);
|
||||||
|
m_position.x += float(-cos(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.z += float(-sin(yrotrad)) * elapsedTime * 10;
|
||||||
|
}
|
||||||
|
else if (right) {
|
||||||
|
yrotrad = (m_rotY / 180 * 3.141592654f);
|
||||||
|
m_position.x += float(cos(yrotrad)) * elapsedTime * 10;
|
||||||
|
m_position.z += float(sin(yrotrad)) * elapsedTime * 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::ApplyTransformation(Transformation& transformation) const {
|
||||||
|
transformation.ApplyRotation(-m_rotX, 1.f, 0, 0);
|
||||||
|
transformation.ApplyRotation(-m_rotY, 0, 1.f, 0);
|
||||||
|
transformation.ApplyTranslation(-m_position);
|
||||||
|
}
|
20
SQCSim2021/player.h
Normal file
20
SQCSim2021/player.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef _PLAYER_H__
|
||||||
|
#define _PLAYER_H__
|
||||||
|
#include "vector3.h"
|
||||||
|
#include "transformation.h"
|
||||||
|
|
||||||
|
class Player {
|
||||||
|
public:
|
||||||
|
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
||||||
|
void TurnLeftRight(float value);
|
||||||
|
void TurnTopBottom(float value);
|
||||||
|
void Move(bool front, bool back, bool left, bool right, float elapsedTime);
|
||||||
|
void ApplyTransformation(Transformation& transformation) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector3f m_position;
|
||||||
|
float m_rotX = 0;
|
||||||
|
float m_rotY = 0;
|
||||||
|
};
|
||||||
|
#endif //_PLAYER_H__
|
||||||
|
|
Loading…
Reference in New Issue
Block a user