diff --git a/SQCSim2021.sln b/SQCSim2021.sln
index 0965676..7f8c39d 100644
--- a/SQCSim2021.sln
+++ b/SQCSim2021.sln
@@ -7,12 +7,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQCSim2021", "SQCSim2021\SQ
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
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.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.Build.0 = Release|Win32
EndGlobalSection
diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj
index ed5fe7b..58470be 100644
--- a/SQCSim2021/SQCSim2021.vcxproj
+++ b/SQCSim2021/SQCSim2021.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
@@ -18,6 +26,7 @@
+
@@ -29,6 +38,7 @@
+
@@ -49,6 +59,12 @@
Unicode
v142
+
+ Application
+ true
+ Unicode
+ v142
+
Application
false
@@ -56,26 +72,49 @@
Unicode
v142
+
+ Application
+ false
+ true
+ Unicode
+ v142
+
+
+
+
+
+
+
true
external\devil178\include;external\sfml23\include;$(IncludePath)
external\devil178\lib;external\sfml23\lib;$(LibraryPath)
+
+ true
+ external\devil178\include;external\sfml23\include;$(IncludePath)
+ external\devil178\lib;external\sfml23\lib;$(LibraryPath)
+
false
external\sfml23\include;external\devil178\include;external\glew170\include;$(IncludePath)
external\sfml23\lib;external\devil178\lib;external\glew170\lib;$(LibraryPath)
+
+ false
+ external\sfml23\include;external\devil178\include;external\glew170\include;$(IncludePath)
+ external\sfml23\lib;external\devil178\lib;external\glew170\lib;$(LibraryPath)
+
@@ -90,6 +129,20 @@
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)
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ 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)
+
+
Level3
@@ -108,6 +161,24 @@
sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+ sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;%(AdditionalDependencies)
+
+
diff --git a/SQCSim2021/SQCSim2021.vcxproj.filters b/SQCSim2021/SQCSim2021.vcxproj.filters
index 5ae06f2..e45304c 100644
--- a/SQCSim2021/SQCSim2021.vcxproj.filters
+++ b/SQCSim2021/SQCSim2021.vcxproj.filters
@@ -41,6 +41,9 @@
Fichiers d%27en-tête
+
+ Fichiers d%27en-tête
+
@@ -67,6 +70,9 @@
Fichiers sources
+
+ Fichiers sources
+
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index fd3e10f..86ba515 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -3,6 +3,7 @@
#include
#include
#include "transformation.h"
+#include "player.h"
Engine::Engine() { }
@@ -56,7 +57,7 @@ void Engine::Render(float elapsedTime)
gameTime += elapsedTime;
- Transformation cube;
+ Transformation all;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -65,49 +66,53 @@ void Engine::Render(float elapsedTime)
glLoadIdentity();
+ m_player.Move(m_keyW, m_keyS, m_keyA, m_keyD, elapsedTime);
+ m_player.ApplyTransformation(all);
+
// Skybox
m_textureSkybox.Bind();
glDisable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
glTexCoord2f(1, 0);
- glVertex3f(10.f, 10.f, 10.f);
+ glVertex3f(100.f, 100.f, 100.f);
glTexCoord2f(0, 0);
- glVertex3f(-10.f, 10.f, 10.f);
+ glVertex3f(-100.f, 100.f, 100.f);
glTexCoord2f(0, 1);
- glVertex3f(-10.f, -10.f, 10.f);
+ glVertex3f(-100.f, -3.f, 100.f);
glTexCoord2f(1, 1);
- glVertex3f(10.f, -10.f, 10.f);
+ glVertex3f(100.f, -3.f, 100.f);
glTexCoord2f(1, 0);
- glVertex3f(10.f, -10.f, -10.f);
+ glVertex3f(100.f, -3.f, -100.f);
glTexCoord2f(0, 0);
- glVertex3f(-10.f, -10.f, -10.f);
+ glVertex3f(-100.f, -3.f, -100.f);
glTexCoord2f(0, 1);
- glVertex3f(-10.f, 10.f, -10.f);
+ glVertex3f(-100.f, 100.f, -100.f);
glTexCoord2f(1, 1);
- glVertex3f(10.f, 10.f, -10.f);
+ glVertex3f(100.f, 100.f, -100.f);
glTexCoord2f(1, 0);
- glVertex3f(-10.f, 10.f, 10.f);
+ glVertex3f(-100.f, 100.f, 100.f);
glTexCoord2f(0, 0);
- glVertex3f(-10.f, 10.f, -10.f);
+ glVertex3f(-100.f, 100.f, -100.f);
glTexCoord2f(0, 1);
- glVertex3f(-10.f, -10.f, -10.f);
+ glVertex3f(-100.f, -3.f, -100.f);
glTexCoord2f(1, 1);
- glVertex3f(-10.f, -10.f, 10.f);
+ glVertex3f(-100.f, -3.f, 100.f);
glTexCoord2f(1, 0);
- glVertex3f(10.f, 10.f, -10.f);
+ glVertex3f(100.f, 100.f, -100.f);
glTexCoord2f(0, 0);
- glVertex3f(10.f, 10.f, 10.f);
+ glVertex3f(100.f, 100.f, 100.f);
glTexCoord2f(0, 1);
- glVertex3f(10.f, -10.f, 10.f);
+ glVertex3f(100.f, -3.f, 100.f);
glTexCoord2f(1, 1);
- glVertex3f(10.f, -10.f, -10.f);
+ glVertex3f(100.f, -3.f, -100.f);
glEnd();
glEnable(GL_DEPTH_TEST);
+ all.Use();
// Plancher
// Les vertex doivent etre affiches dans le sens anti-horaire (CCW)
m_textureFloor.Bind();
@@ -124,12 +129,13 @@ void Engine::Render(float elapsedTime)
glVertex3f(-100.f, -2.f, -100.f);
glEnd();
+
// Cube
- cube.ApplyTranslation(0.f, 0.f, -10.f);
- cube.ApplyRotation(gameTime * 100.f, 0.f, 1.f, 0.f);
- cube.ApplyRotation(gameTime * 100.f, 0.f, 0.f, 1.f);
- cube.ApplyRotation(gameTime * 100.f, 1.f, 0.f, 0.f);
- cube.Use();
+ all.ApplyTranslation(0.f, 0.f, -10.f);
+ all.ApplyRotation(gameTime * 100.f, 0.f, 1.f, 0.f);
+ all.ApplyRotation(gameTime * 100.f, 0.f, 0.f, 1.f);
+ all.ApplyRotation(gameTime * 100.f, 1.f, 0.f, 0.f);
+ all.Use();
m_textureCube.Bind();
glBegin(GL_QUADS);
@@ -153,7 +159,7 @@ void Engine::Render(float elapsedTime)
glTexCoord2f(0, 1);
glVertex3f(-0.5f, 0.5f, 0.5f);
- glNormal3f(0, -1, 0);
+ glNormal3f(0, 1, 0);
glTexCoord2f(0, 0);
glVertex3f(-0.5f, -0.5f, -0.5f);
glTexCoord2f(1, 0);
@@ -163,7 +169,7 @@ void Engine::Render(float elapsedTime)
glTexCoord2f(0, 1);
glVertex3f(-0.5f, -0.5f, 0.5f);
- glNormal3f(0, 1, 0);
+ glNormal3f(0, -1, 0);
glTexCoord2f(0, 0);
glVertex3f(0.5f, -0.5f, -0.5f);
glTexCoord2f(1, 0);
@@ -270,6 +276,9 @@ void Engine::KeyReleaseEvent(unsigned char key)
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
// 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
diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h
index 09861f2..62f1802 100644
--- a/SQCSim2021/engine.h
+++ b/SQCSim2021/engine.h
@@ -4,6 +4,7 @@
#include "openglcontext.h"
#include "texture.h"
#include "transformation.h"
+#include "player.h"
class Engine : public OpenglContext
{
@@ -31,6 +32,8 @@ private:
Texture m_textureSkybox;
Texture m_textureCube;
+ Player m_player = Player(Vector3f(0, 0, 0));
+
bool m_keyW = false;
bool m_keyA = false;
bool m_keyS = false;
diff --git a/SQCSim2021/player.cpp b/SQCSim2021/player.cpp
new file mode 100644
index 0000000..fc8efd9
--- /dev/null
+++ b/SQCSim2021/player.cpp
@@ -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);
+}
diff --git a/SQCSim2021/player.h b/SQCSim2021/player.h
new file mode 100644
index 0000000..ea37472
--- /dev/null
+++ b/SQCSim2021/player.h
@@ -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__
+