diff --git a/.gitignore b/.gitignore
index f15149d..8ffde58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -378,3 +378,5 @@ FodyWeavers.xsd
/SQCSim2021/cmake/*
!/SQCSim2021/cmake/CMakeLists.txt
/SQCSim2021/SQCSim-client
+SQCSim2021/SQCSim2021.vcxproj.filters
+SQCSim2021/SQCSim2021.vcxproj
diff --git a/SQCSim-common/netprotocol.h b/SQCSim-common/netprotocol.h
index 33f233e..693f03f 100644
--- a/SQCSim-common/netprotocol.h
+++ b/SQCSim-common/netprotocol.h
@@ -45,7 +45,11 @@ namespace netprot {
bool jumping,
shooting,
hit,
- powerup;
+ powerup,
+ dead,
+ still,
+ jumpshot,
+ running;
};
struct Input { // cli -> srv UDP ~frame
diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp
index 9fe810c..57c2259 100644
--- a/SQCSim-common/player.cpp
+++ b/SQCSim-common/player.cpp
@@ -8,6 +8,8 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
m_username = "Zelda Bee-Bop56";
}
+Player::~Player() {}
+
void Player::TurnLeftRight(float value) {
m_rotY += value;
if (m_rotY > 360) m_rotY = 0;
@@ -206,3 +208,9 @@ void Player::Teleport(int& x, int& z) {
m_position.x -= x * CHUNK_SIZE_X;
m_position.z -= z * CHUNK_SIZE_Z;
}
+
+uint64_t Player::getId() const { return id; }
+
+Vector3f Player::InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now) {
+ return Vector3f();
+}
diff --git a/SQCSim-common/player.h b/SQCSim-common/player.h
index e439fa2..d592613 100644
--- a/SQCSim-common/player.h
+++ b/SQCSim-common/player.h
@@ -12,6 +12,8 @@ public:
enum Sound { NOSOUND, STEP, FALL };
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
+ ~Player();
+
void TurnLeftRight(float value);
void TurnTopBottom(float value);
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
@@ -26,12 +28,13 @@ public:
float GetHP() const;
void Teleport(int& x, int& z);
-private:
+protected:
Vector3f m_position;
Vector3f m_velocity;
Vector3f m_direction;
std::string m_username;
+ uint64_t id = 0;
float m_rotX = 0;
float m_rotY = 0;
@@ -40,6 +43,9 @@ private:
float m_hp;
bool m_airborne;
+
+ Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
+
};
#endif //_PLAYER_H__
diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj
index 9fd58a9..fc67c42 100644
--- a/SQCSim2021/SQCSim2021.vcxproj
+++ b/SQCSim2021/SQCSim2021.vcxproj
@@ -25,13 +25,14 @@
+
-
+
@@ -40,13 +41,14 @@
+
-
+
diff --git a/SQCSim2021/SQCSim2021.vcxproj.filters b/SQCSim2021/SQCSim2021.vcxproj.filters
index 3bf0928..5c8a864 100644
--- a/SQCSim2021/SQCSim2021.vcxproj.filters
+++ b/SQCSim2021/SQCSim2021.vcxproj.filters
@@ -47,7 +47,10 @@
Fichiers d%27en-tête
-
+
+ Fichiers d%27en-tête
+
+
Fichiers d%27en-tête
@@ -88,7 +91,10 @@
Fichiers sources
-
+
+ Fichiers sources
+
+
Fichiers sources
diff --git a/SQCSim2021/connector.h b/SQCSim2021/connector.h
index 5a9773e..5dd6db4 100644
--- a/SQCSim2021/connector.h
+++ b/SQCSim2021/connector.h
@@ -21,6 +21,9 @@ public:
SOCKET m_sock_udp = 0,
m_sock_tcp = 0;
sockaddr_in m_srvsockaddr;
+
+ // void updateRemotePlayers(std::map rplayers);
+
private:
#ifdef _WIN32
WSADATA m_wsaData;
diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h
index f28c86b..6e41b9f 100644
--- a/SQCSim2021/engine.h
+++ b/SQCSim2021/engine.h
@@ -18,7 +18,7 @@
#include "audio.h"
#include "textureatlas.h"
#include "connector.h"
-#include "worldrenderer.h"
+#include "renderer.h"
class Engine : public OpenglContext {
public:
@@ -61,7 +61,7 @@ private:
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
World m_world = World();
- WorldRenderer m_wrenderer = WorldRenderer();
+ Renderer m_renderer = Renderer();
Texture m_textureSkybox;
Texture m_textureFont;
diff --git a/SQCSim2021/remoteplayer.cpp b/SQCSim2021/remoteplayer.cpp
new file mode 100644
index 0000000..1d2de20
--- /dev/null
+++ b/SQCSim2021/remoteplayer.cpp
@@ -0,0 +1,70 @@
+#include "remoteplayer.h"
+#include
+#include
+
+
+RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
+
+}
+
+void RemotePlayer::Init() {
+
+}
+
+void RemotePlayer::Feed(const netprot::Output out) {
+
+ current.position = out.position;
+ current.direction = out.direction;
+ current.states = out.states;
+ current.id = out.id;
+
+ //a revoir pour le jump et le shoot en meme temps lorsque les test seront possible
+
+ if (current.position != previous.position)
+ {
+ Vector3f positionDelta = current.position - previous.position;
+ m_position = current.position + positionDelta;
+ m_direction = current.direction;
+
+ }
+
+ if(current.direction != previous.direction)
+ {
+ m_direction = current.direction;
+ current.direction = current.direction;
+ }
+
+ if (current.states.shooting) {
+ //true;
+ m_animstate = Anim::SHOOTING;
+ }
+ else if (current.states.jumping) {
+ //true;
+ m_animstate = Anim::JUMPING;
+ }
+ else if (current.states.dead) {
+ //true;
+ m_animstate = Anim::DEAD;
+ }
+ else if(current.states.powerup){
+ //true;
+ m_animstate = Anim::POWERUP;
+ }
+ else if (current.states.still) {
+ //true;
+ m_animstate = Anim::STILL;
+ }
+ else if (current.states.running) {
+ //true;
+ m_animstate = Anim::RUNNING;
+ }
+
+
+ previous.direction = current.direction;
+ previous.position = current.position;
+ previous.states = current.states;
+ previous.id = current.id;
+
+
+
+}
\ No newline at end of file
diff --git a/SQCSim2021/remoteplayer.h b/SQCSim2021/remoteplayer.h
new file mode 100644
index 0000000..70b585b
--- /dev/null
+++ b/SQCSim2021/remoteplayer.h
@@ -0,0 +1,25 @@
+#ifndef REMOTEPLAYER_H__
+#define REMOTEPLAYER_H__
+#include "../SQCSim-common/player.h"
+#include "../SQCSim-common/netprotocol.h"
+#include "define.h"
+#include "textureatlas.h"
+#include "shader.h"
+
+class RemotePlayer : public Player {
+public:
+ enum Anim { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
+
+ RemotePlayer();
+
+ void Init();
+ void Feed(const netprot::Output out);
+
+private:
+ netprot::Output current, previous;
+ float m_aminacc;
+ Anim m_animstate;
+ uint64_t m_team_id;
+
+};
+#endif
\ No newline at end of file
diff --git a/SQCSim2021/worldrenderer.cpp b/SQCSim2021/renderer.cpp
similarity index 87%
rename from SQCSim2021/worldrenderer.cpp
rename to SQCSim2021/renderer.cpp
index e4e0333..b4c8f91 100644
--- a/SQCSim2021/worldrenderer.cpp
+++ b/SQCSim2021/renderer.cpp
@@ -1,13 +1,13 @@
-#include "worldrenderer.h"
+#include "renderer.h"
-WorldRenderer::WorldRenderer() {
+Renderer::Renderer() {
m_meshes.Reset(nullptr);
}
-WorldRenderer::~WorldRenderer() {
+Renderer::~Renderer() {
}
-void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) {
+void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
rendercount = 0;
Vector3f angle;
Vector3f cursor;
@@ -18,7 +18,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
direct.Normalize();
pos.y = 1;
- static Vector3 renderManifest[VIEW_DISTANCE * 8]; // Nombre de Chunks maximal à être rendus.
+ static Vector3 renderManifest[VIEW_DISTANCE * 8]; // Nombre de Chunks maximal � �tre rendus.
//for (int dist = VIEW_DISTANCE; dist >= 0; dist -= CHUNK_SIZE_X) {
for (int dist = 0; dist <= VIEW_DISTANCE; dist += CHUNK_SIZE_X) {
@@ -27,18 +27,18 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
int echantillons;
if (dist > VIEW_DISTANCE * .1f) {
- sinus = .00872653549f; // sin(1/2 degré)
- cosinus = .99996192306; // cos(1/2 degré)
+ sinus = .00872653549f; // sin(1/2 degr�)
+ cosinus = .99996192306; // cos(1/2 degr�)
echantillons = 180;
}
//else {//if (dist > VIEW_DISTANCE * .3f) {
- // sinus = .01151891831f; // sin(2/3 degré)
- // cosinus = .99993365506; // cos(2/3 degré)
+ // sinus = .01151891831f; // sin(2/3 degr�)
+ // cosinus = .99993365506; // cos(2/3 degr�)
// echantillons = 120;
//}
//else if (dist > VIEW_DISTANCE * .2f) {
- // sinus = .01745240643; // sin(1 degré)
- // cosinus = .99984769515; // cos(1 degré)
+ // sinus = .01745240643; // sin(1 degr�)
+ // cosinus = .99984769515; // cos(1 degr�)
// echantillons = 90;
//}
//else if (dist > VIEW_DISTANCE * .1f) {
@@ -72,7 +72,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
bool valide = true;
unsigned int chx, chy;
origin->ChunkAt(cursor)->GetPosition(chx, chy);
- for (int index = 0; index < rendercount; ++index) // Permet de vérifier seulement contre celles ajoutées dans la frame, et ne pas avoir à refaire l'array à chaque frame.
+ for (int index = 0; index < rendercount; ++index) // Permet de v�rifier seulement contre celles ajout�es dans la frame, et ne pas avoir � refaire l'array � chaque frame.
if (renderManifest[index].x == chx && renderManifest[index].z == chy)
valide = false;
@@ -107,7 +107,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
glStencilFunc(GL_GREATER, 1, 0xFF);
};
-void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
+void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
int cx = player.x;
int cy = player.z;
static int frameUpdate = 2;
@@ -212,3 +212,10 @@ void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo
}
}
+
+void Renderer::RenderPlayer(Player* player, Transformation tran) const {
+}
+
+void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const {
+}
+
diff --git a/SQCSim2021/renderer.h b/SQCSim2021/renderer.h
new file mode 100644
index 0000000..8afdc3b
--- /dev/null
+++ b/SQCSim2021/renderer.h
@@ -0,0 +1,30 @@
+#ifndef RENDERER_H__
+#define RENDERER_H__
+#include
+#include
+#include "../SQCSim-common/world.h"
+#include "../SQCSim-common/transformation.h"
+#include "define.h"
+#include "mesh.h"
+#include "textureatlas.h"
+#include "shader.h"
+#include "remoteplayer.h"
+
+class Renderer {
+private:
+ Array2d m_meshes = Array2d(WORLD_SIZE_X, WORLD_SIZE_Y);
+
+ TextureAtlas* m_playertext = nullptr;
+ Shader* m_playershader = nullptr;
+
+public:
+ Renderer();
+ ~Renderer();
+
+ void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
+
+ void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const;
+ void RenderPlayer(Player* player, Transformation tran) const;
+ void RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const;
+};
+#endif
\ No newline at end of file
diff --git a/SQCSim2021/worldrenderer.h b/SQCSim2021/worldrenderer.h
deleted file mode 100644
index 46e6624..0000000
--- a/SQCSim2021/worldrenderer.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef WORLDRENDERER_H__
-#define WORLDRENDERER_H__
-#include
-#include
-#include "../SQCSim-common/world.h"
-#include "../SQCSim-common/transformation.h"
-#include "define.h"
-#include "mesh.h"
-#include "textureatlas.h"
-#include "shader.h"
-
-class WorldRenderer {
-private:
- Array2d m_meshes = Array2d(WORLD_SIZE_X, WORLD_SIZE_Y);
-
-public:
- WorldRenderer();
- ~WorldRenderer();
-
- void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas);
- void UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
-};
-#endif
\ No newline at end of file