Merge branch 'master' into SQC19_Booster

This commit is contained in:
Frederic Leger 2023-11-20 15:43:01 -05:00
commit 3a38753d8e
12 changed files with 69 additions and 19 deletions

View File

@ -27,7 +27,7 @@
#define THREADS_UPDATE_CHUNKS 6
#define THREADS_DELETE_CHUNKS 3
#define VIEW_DISTANCE 512 // Si les chunks arrêtent de s'afficher pendant une game et qu'il y a un access violation quand tu quitte, il faut augmenter ce chiffre.
#define VIEW_DISTANCE 512 // Si les chunks arr<EFBFBD>tent de s'afficher pendant une game et qu'il y a un access violation quand tu quitte, il faut augmenter ce chiffre.
#define TEXTURE_SIZE 512
#define MAX_BULLETS 512
@ -41,6 +41,8 @@ typedef uint8_t BlockType;
typedef uint8_t BoostType;
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST };
enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE, BTYPE_BOOST_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

View File

@ -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/"

View File

@ -1,5 +1,7 @@
#include "engine.h"
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <chrono>
#include <thread>
@ -453,6 +455,37 @@ void Engine::LoadResource() {
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png");
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.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();
@ -477,6 +510,9 @@ void Engine::LoadResource() {
m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", 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;
@ -1158,7 +1194,6 @@ void Engine::Render(float elapsedTime) {
//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);
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
m_booster.RenderBillboard({ 120,20,120 }, m_textureAtlas, texBoostHeal, m_shader01, all);
@ -1168,12 +1203,12 @@ void Engine::Render(float elapsedTime) {
//m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
//if (m_isSkybox) m_skybox.Render(skybox);
if (m_isSkybox) m_skybox.Render(skybox);
if (m_isSkybox) DrawHud(elapsedTime, bloc);
if (m_isSkybox) DisplayPovGun();
DrawHud(elapsedTime, bloc);
DisplayPovGun();
ProcessNotificationQueue();
if (m_damage)
{

View File

@ -72,6 +72,7 @@ private:
BlockInfo* m_blockinfo[BTYPE_LAST];
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
World m_world = World();
Renderer m_renderer = Renderer();

View File

@ -7,7 +7,7 @@ void main()
texel = texture2D(tex,gl_TexCoord[0].st);
texel *= light;
texel.a = 255.;
gl_FragColor = texel;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 KiB

View File

@ -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;
@ -111,6 +105,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
atlas.TextureIndexToCoord(0, u, v, w, h);
//glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(x - width/2., y - height, z); //glVertex3f(v4.x, v4.y, v4.z);//glVertex3f(0, 50, 0);
@ -118,6 +116,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
glTexCoord2f(u + w, v + h); glVertex3f(x+width/2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0);
glTexCoord2f(u, v + h); glVertex3f(x-width/2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
glEnd();
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendEquation(GL_FUNC_SUBTRACT);
glDisable(GL_BLEND);
shader.Disable();
//tran.ApplyTranslation(-m_position);
//glEnable(GL_DEPTH_TEST);

View File

@ -12,7 +12,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);

View File

@ -40,6 +40,9 @@ TextureAtlas::TextureIndex TextureAtlas::AddTexture(const std::string& fname) {
}
bool TextureAtlas::Generate(int textureSize, bool mipmap) {
// TODO mipmap pas encore 100% parfait...
assert(!mipmap);
@ -66,6 +69,8 @@ bool TextureAtlas::Generate(int textureSize, bool mipmap) {
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
ilEnable(IL_ORIGIN_SET);
ilEnable(IL_ALPHA);
ilEnable(IL_BLIT_BLEND);
if (!ilLoadImage((const ILstring)it->first.c_str()))
return false;
@ -170,8 +175,10 @@ bool TextureAtlas::Generate(int textureSize, bool mipmap) {
mipmapSize /= 2;
}
m_isValid = true;
return true;
}