diff --git a/SQCSim-common/define.h b/SQCSim-common/define.h index 48a4f4c..55e5fe5 100644 --- a/SQCSim-common/define.h +++ b/SQCSim-common/define.h @@ -16,8 +16,8 @@ #define SEED 0 #define COUNTDOWN 300 -#define WORLD_SIZE_X 64 -#define WORLD_SIZE_Y 64 +#define WORLD_SIZE_X 8 +#define WORLD_SIZE_Y 8 #define FRAMES_RENDER_CHUNKS 1 #define FRAMES_UPDATE_CHUNKS 1 diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 81afefa..3805138 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1046,6 +1046,8 @@ void Engine::Render(float elapsedTime) { Transformation all; Transformation skybox; + Transformation remotePlayer; + Vector3f vstep; // Transformations initiales @@ -1141,12 +1143,21 @@ void Engine::Render(float elapsedTime) { } if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas); + //m_remotePlayer.ApplyTransformation(remotePlayer, false); m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo); m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo); + m_remotePlayer.Render(m_textureAtlas, m_shader01, elapsedTime, m_player); + + + + + - m_remotePlayer.Render(m_textureAtlas, m_shader01, elapsedTime); if (m_isSkybox) m_skybox.Render(skybox); + + + if (m_isSkybox) DrawHud(elapsedTime, bloc); if (m_isSkybox) DisplayPovGun(); ProcessNotificationQueue(); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 88697e6..8f38082 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -62,7 +62,7 @@ private: void DrawHud(float elapsedTime, BlockType bloc); void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f); - void RenderRemotePlayers(RemotePlayer& remoteplayer, float elapsedTime); + Connector m_conn; diff --git a/SQCSim2021/remoteplayer.cpp b/SQCSim2021/remoteplayer.cpp index 1ef4cd1..93ce9ef 100644 --- a/SQCSim2021/remoteplayer.cpp +++ b/SQCSim2021/remoteplayer.cpp @@ -1,13 +1,14 @@ #include "remoteplayer.h" #include #include -#include "texture.h" + #include #include -RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0), 0, 0) { + +RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)){ LoadTexture(m_texture_front, TEXTURE_PATH "AssetOtherPlayer/FinalPNGStanding/BlueFrontRight.png", false, false); @@ -18,7 +19,7 @@ RemotePlayer::~RemotePlayer() } -void RemotePlayer::Init() +void RemotePlayer::Init() { } @@ -69,22 +70,36 @@ void RemotePlayer::Feed(const netprot::Output out) { previous.id = current.id; } -void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, float elapsedTime) +void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, float elapsedTime, Player m_player) { - shader.Use(); - //m_texture_front.Bind(); + // + //Vector3f playerToQuad = m_player.GetPosition() - m_position; + //playerToQuad.Normalize(); + //Vector3f targetPosition = m_player.GetPosition() + playerToQuad * 10.0f; + //Matrix4f rotationMatrix; + //rotationMatrix.SetLookAt(m_position, targetPosition, Vector3f(0, 1, 0)); + //glMultMatrixf(rotationMatrix.GetInternalValues()); + //Pt override les collisions.. a ce point la je sais pas quoi faire + + shader.Use(); + float x = 0; + float y = m_player.GetPosition().y; + float z = 0; + float size = 5.0f; + float u, v, w, h; atlas.Bind(); - atlas.TextureIndexToCoord(0, u, v, w, h); glBegin(GL_QUADS); - glTexCoord2f(u, v); glVertex3f(0, 50., 0); - glTexCoord2f(u+w, v); glVertex3f(50., 50., 0); - glTexCoord2f(u+w, v+h); glVertex3f(50., 0, 0); - glTexCoord2f(u, v+h); glVertex3f(0, 0, 0); + atlas.TextureIndexToCoord(0, u, v, w, h); + glTexCoord2f(u, v); glVertex3f(x, y + size, z); + glTexCoord2f(u + w, v); glVertex3f(x + size, y + size, z); + glTexCoord2f(u + w, v + h); glVertex3f(x + size, y, z); + glTexCoord2f(u, v + h); glVertex3f(x, y, z); glEnd(); shader.Disable(); + } bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError) diff --git a/SQCSim2021/remoteplayer.h b/SQCSim2021/remoteplayer.h index ea28c1c..64079b8 100644 --- a/SQCSim2021/remoteplayer.h +++ b/SQCSim2021/remoteplayer.h @@ -7,6 +7,9 @@ #include "shader.h" #include "texture.h" #include "openglcontext.h" +#include "vertexbuffer.h" +#include "texture.h" +#include "../SQCSim-common/matrix4.h" class RemotePlayer : public Player { public: @@ -18,7 +21,7 @@ public: void Init(); void Feed(const netprot::Output out); - void Render(TextureAtlas& atlas, Shader& shader, float elapsedTime); + void Render(TextureAtlas& atlas, Shader& shader, float elapsedTime, Player m_player); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError); private: @@ -29,6 +32,8 @@ private: Anim m_animstate; uint64_t m_team_id; Texture m_texture_front; + + };