diff --git a/SQCSim-common/define.h b/SQCSim-common/define.h index 48a4f4c..2ebf25d 100644 --- a/SQCSim-common/define.h +++ b/SQCSim-common/define.h @@ -35,6 +35,8 @@ typedef uint8_t BlockType; enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST }; +enum ANIM_TYPE { STILL = 0, SHOOTING = 8, JUMPING = 16, JUMPINGSHOOTING = 24, DEAD = 32, TYPE_LAST = 40}; +enum ANIM_POS {FRONT, QUARTER_FRONT_LEFT, QUATER_FRONT_RIGHT, PROFIL_LEFT, PROFIL_RIGHT, QUARTER_BACK_LEFT, QUARTER_BACK_RIGHT, BACK , POS_LAST}; typedef uint64_t Timestamp; #ifdef _WIN32 diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h index 7f4c4af..e88b797 100644 --- a/SQCSim2021/define.h +++ b/SQCSim2021/define.h @@ -28,7 +28,8 @@ #define BASE_WIDTH 640 #define BASE_HEIGHT 480 - +#define ANIME_PATH_JUMP "./media/textures/AssetOtherPlayer/FinalPNGJumping/" +#define ANIME_PATH_STILL "./media/textures/AssetOtherPlayer/FinalPNGStanding/" #define TEXTURE_PATH "./media/textures/" #define SHADER_PATH "./media/shaders/" #define AUDIO_PATH "./media/audio/" diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 86447a3..deff0af 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1,5 +1,7 @@ #include "engine.h" - +#include +#include +#include #include #include #include @@ -449,6 +451,37 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); + + //AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM + + //JUMP + //TextureAtlas::TextureIndex JumpBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackJumpRight.png"); + //TextureAtlas::TextureIndex JumpFront = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueFrontJumpRight.png"); + //TextureAtlas::TextureIndex JumpQuarterBackLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftBackJumpLeft.png"); + //TextureAtlas::TextureIndex JumpQuarterBackRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightBackJumpRight.png"); + //TextureAtlas::TextureIndex JumpProfiltLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueProfilJumpLeft.png"); + //TextureAtlas::TextureIndex JumpProfiltRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueProfilJumpRight.png"); + //TextureAtlas::TextureIndex JumpQuarterFrontLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftFrontJumpLeft.png"); + //TextureAtlas::TextureIndex JumpQuarterFrontRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightFrontJumpRight.png"); + + //STILL + //TextureAtlas::TextureIndex StillBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackRight.png"); + TextureAtlas::TextureIndex StillFront = m_animeAtlas.AddTexture(ANIME_PATH_STILL "BlueFrontRight.png"); + //TextureAtlas::TextureIndex StillQuarterBackLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftBack.png"); + //TextureAtlas::TextureIndex StillQuarterBackRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightBack.png"); + //TextureAtlas::TextureIndex StillProfiltLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueProfilLeft.png"); + //TextureAtlas::TextureIndex StillProfiltRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueProfilRight.png"); + //TextureAtlas::TextureIndex StillQuarterFrontLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeft.png"); + //TextureAtlas::TextureIndex StillQuarterFrontRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRight.png"); + + //SHOOTINGSTILL + //SHOOTINGJUMP + + if (!m_animeAtlas.Generate(TEXTURE_SIZE, false)) { + std::cout << " Unable to generate texture atlas ..." << std::endl; + abort(); + } + if (!m_textureAtlas.Generate(TEXTURE_SIZE, false)) { std::cout << " Unable to generate texture atlas ..." << std::endl; abort(); @@ -464,6 +497,9 @@ void Engine::LoadResource() { m_textureAtlas.TextureIndexToCoord(texIceIndex, u, v, s, s); m_blockinfo[BTYPE_ICE] = new BlockInfo(BTYPE_ICE, "Ice", u, v, s, 1); + + m_animeAtlas.TextureIndexToCoord(0, u, v, s, s); + std::cout << " Loading and compiling shaders ..." << std::endl; if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) { std::cout << " Failed to load shader " << std::endl; @@ -1146,7 +1182,7 @@ void Engine::Render(float elapsedTime) { m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo); m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime); + m_remotePlayer.Render(m_animeAtlas, m_shader01, all, elapsedTime); if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 92d22ac..142b8c7 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -69,6 +69,7 @@ private: Shader m_shader01; BlockInfo* m_blockinfo[BTYPE_LAST]; TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST); + TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST); World m_world = World(); Renderer m_renderer = Renderer(); diff --git a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueBackJumpLeft.png b/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueBackJumpLeft.png deleted file mode 100644 index d0dd74f..0000000 Binary files a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueBackJumpLeft.png and /dev/null differ diff --git a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueFrontJumpLeft.png b/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueFrontJumpLeft.png deleted file mode 100644 index 08420cf..0000000 Binary files a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGJumping/BlueFrontJumpLeft.png and /dev/null differ diff --git a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueBackLeft.png b/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueBackLeft.png deleted file mode 100644 index c743dec..0000000 Binary files a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueBackLeft.png and /dev/null differ diff --git a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueFrontLeft.png b/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueFrontLeft.png deleted file mode 100644 index a3f15f1..0000000 Binary files a/SQCSim2021/media/textures/AssetOtherPlayer/FinalPNGStanding/BlueFrontLeft.png and /dev/null differ diff --git a/SQCSim2021/remoteplayer.cpp b/SQCSim2021/remoteplayer.cpp index d8cbdec..8a4ed7d 100644 --- a/SQCSim2021/remoteplayer.cpp +++ b/SQCSim2021/remoteplayer.cpp @@ -79,19 +79,13 @@ void RemotePlayer::Feed(const netprot::Output out) { void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime) { - // - //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()); + float x = GetPosition().x; float y = GetPosition().y; float z = GetPosition().z; - float width = 1.7f; - float height = 2.5f; - //Pt override les collisions.. a ce point la je sais pas quoi faire + float width = 1.f; + float height = 1.7f; + //Matrix4 mat4 = tran.GetMatrix(); //mat4 VP = pMatrix * vMatrix; diff --git a/SQCSim2021/remoteplayer.h b/SQCSim2021/remoteplayer.h index 6050356..68376a7 100644 --- a/SQCSim2021/remoteplayer.h +++ b/SQCSim2021/remoteplayer.h @@ -13,7 +13,7 @@ class RemotePlayer : public Player { public: - enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 }; + enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 }; // A REVOIR VOIR DEFINE.H POUR LES ANIMES RemotePlayer(netprot::PlayerInfo pinfo); RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos); diff --git a/SQCSim2021/textureatlas.cpp b/SQCSim2021/textureatlas.cpp index d293c84..1adc9f8 100644 --- a/SQCSim2021/textureatlas.cpp +++ b/SQCSim2021/textureatlas.cpp @@ -66,6 +66,7 @@ bool TextureAtlas::Generate(int textureSize, bool mipmap) { ilOriginFunc(IL_ORIGIN_LOWER_LEFT); ilEnable(IL_ORIGIN_SET); + ilEnable(IL_ALPHA); if (!ilLoadImage((const ILstring)it->first.c_str())) return false;