:godmode: ENFIN SANT-CALISSE DE CRISS
This commit is contained in:
parent
82cfc2d1b1
commit
8860593740
@ -16,8 +16,8 @@
|
||||
#define SEED 0
|
||||
#define COUNTDOWN 300
|
||||
|
||||
#define WORLD_SIZE_X 8
|
||||
#define WORLD_SIZE_Y 8
|
||||
#define WORLD_SIZE_X 64
|
||||
#define WORLD_SIZE_Y 64
|
||||
|
||||
#define FRAMES_RENDER_CHUNKS 1
|
||||
#define FRAMES_UPDATE_CHUNKS 1
|
||||
|
@ -186,10 +186,14 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
|
||||
return snd;
|
||||
}
|
||||
|
||||
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {
|
||||
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
|
||||
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
|
||||
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
|
||||
if (rel) transformation.ApplyTranslation(-GetPOV());
|
||||
if (!rot) {
|
||||
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
|
||||
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetDirection(Vector3f dir) { m_direction = dir; }
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
void TurnTopBottom(float value);
|
||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
|
||||
void ApplyTransformation(Transformation& transformation, bool rel = true) const;
|
||||
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
||||
|
||||
void SetDirection(Vector3f dir);
|
||||
Vector3f GetPosition() const;
|
||||
|
@ -330,7 +330,7 @@ void Engine::Init() {
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
@ -351,7 +351,7 @@ void Engine::Init() {
|
||||
//
|
||||
// Objet de skybox avec sa propre texture et son propre shader!
|
||||
m_skybox.Init(0.2f);
|
||||
|
||||
//m_skybox2.Init(1.f);
|
||||
// Objet de musique!
|
||||
//m_audio.ToggleMusicState();
|
||||
|
||||
@ -415,7 +415,7 @@ void Engine::Init() {
|
||||
|
||||
m_startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
|
||||
m_remotePlayer.SetPosition(Vector3f(.5,CHUNK_SIZE_Y + 10., .5));
|
||||
// Gestion de souris.
|
||||
CenterMouse();
|
||||
HideCursor();
|
||||
@ -425,6 +425,7 @@ void Engine::DeInit() {}
|
||||
|
||||
void Engine::LoadResource() {
|
||||
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
||||
//LoadTexture(m_skybox2.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
||||
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
|
||||
@ -772,17 +773,17 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
fPosY = fPosYJump;
|
||||
fPosY -= charSize;
|
||||
|
||||
ss << " Velocity : " << m_player.GetVelocity();
|
||||
ss << " Velocity : " << m_remotePlayer.GetVelocity();
|
||||
PrintText(fPosX, fPosY, ss.str());
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
|
||||
ss << " Direction : " << m_player.GetDirection();
|
||||
ss << " Player Position : " << m_player.GetPosition();
|
||||
PrintText(fPosX, fPosY, ss.str());
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
|
||||
ss << " Position : " << m_player.GetPosition();
|
||||
ss << " Remote Position : " << m_remotePlayer.GetPosition();//m_player.GetPosition();
|
||||
PrintText(fPosX, fPosY, ss.str());
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
@ -1083,10 +1084,7 @@ void Engine::Render(float elapsedTime) {
|
||||
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
||||
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
||||
|
||||
|
||||
|
||||
|
||||
//m_remotePlayer.ApplyTransformation(all);
|
||||
m_player.ApplyTransformation(remotePlayer, true, false);
|
||||
|
||||
if (m_mouseWU) bloc++;
|
||||
else if (m_mouseWD) bloc--;
|
||||
@ -1142,19 +1140,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.ApplyPhysics(Vector3f(0,0,0), &m_world, 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);
|
||||
m_remotePlayer.Render(m_textureAtlas, m_shader01, elapsedTime, m_player);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
m_remotePlayer.Render(m_textureAtlas, 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);
|
||||
|
||||
//glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
//m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_isSkybox) m_skybox.Render(skybox);
|
||||
|
||||
//if (m_isSkybox) m_skybox.Render(skybox);
|
||||
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ private:
|
||||
bool m_flash = true;
|
||||
bool m_displayCrosshair = true;
|
||||
bool m_displayHud = true;
|
||||
bool m_displayInfo = false;
|
||||
bool m_displayInfo = true;
|
||||
bool m_resetcountdown = false;
|
||||
bool m_soloMultiChoiceMade = false;
|
||||
bool m_stopcountdown = false;
|
||||
@ -154,7 +154,7 @@ private:
|
||||
|
||||
bool m_networkgame = false;
|
||||
netprot::PlayerInfo m_pinfo;
|
||||
RemotePlayer m_remotePlayer;
|
||||
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));
|
||||
std::string m_messageNotification = "";
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,13 @@ RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : m_pinfo(pinfo), m_aminac
|
||||
|
||||
}
|
||||
|
||||
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) {
|
||||
|
||||
LoadTexture(m_texture_front, TEXTURE_PATH "AssetOtherPlayer/FinalPNGStanding/BlueFrontRight.png", false, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
RemotePlayer::~RemotePlayer()
|
||||
{
|
||||
|
||||
@ -26,51 +33,51 @@ 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;
|
||||
//current.position = out.position;
|
||||
//current.direction = out.direction;
|
||||
//current.states = out.states;
|
||||
//current.id = out.id;
|
||||
|
||||
if (current.position != previous.position)
|
||||
{
|
||||
Vector3f positionDelta = current.position - previous.position;
|
||||
m_position = current.position + positionDelta;
|
||||
m_direction = current.direction;
|
||||
//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.direction != previous.direction)
|
||||
//{
|
||||
// m_direction = current.direction;
|
||||
// current.direction = current.direction;
|
||||
//}
|
||||
|
||||
if (current.states.shooting) {
|
||||
m_animstate = Anim::SHOOTING;
|
||||
}
|
||||
else if (current.states.jumping) {
|
||||
m_animstate = Anim::JUMPING;
|
||||
}
|
||||
else if (current.states.dead) {
|
||||
m_animstate = Anim::DEAD;
|
||||
}
|
||||
else if(current.states.powerup){
|
||||
m_animstate = Anim::POWERUP;
|
||||
}
|
||||
else if (current.states.still) {
|
||||
m_animstate = Anim::STILL;
|
||||
}
|
||||
else if (current.states.running) {
|
||||
m_animstate = Anim::RUNNING;
|
||||
}
|
||||
//if (current.states.shooting) {
|
||||
// m_animstate = Anim::SHOOTING;
|
||||
//}
|
||||
//else if (current.states.jumping) {
|
||||
// m_animstate = Anim::JUMPING;
|
||||
//}
|
||||
//else if (current.states.dead) {
|
||||
// m_animstate = Anim::DEAD;
|
||||
//}
|
||||
//else if(current.states.powerup){
|
||||
// m_animstate = Anim::POWERUP;
|
||||
//}
|
||||
//else if (current.states.still) {
|
||||
// m_animstate = Anim::STILL;
|
||||
//}
|
||||
//else if (current.states.running) {
|
||||
// m_animstate = Anim::RUNNING;
|
||||
//}
|
||||
|
||||
previous.direction = current.direction;
|
||||
previous.position = current.position;
|
||||
previous.states = current.states;
|
||||
previous.id = current.id;
|
||||
//previous.direction = current.direction;
|
||||
//previous.position = current.position;
|
||||
//previous.states = current.states;
|
||||
//previous.id = current.id;
|
||||
}
|
||||
|
||||
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, float elapsedTime, Player m_player)
|
||||
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime)
|
||||
{
|
||||
//
|
||||
//Vector3f playerToQuad = m_player.GetPosition() - m_position;
|
||||
@ -79,27 +86,41 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, float elapsedTime
|
||||
//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
|
||||
|
||||
shader.Use();
|
||||
float x = 0;
|
||||
float y = m_player.GetPosition().y;
|
||||
float z = 0;
|
||||
float size = 5.0f;
|
||||
//Matrix4 mat4 = tran.GetMatrix();
|
||||
//mat4 VP = pMatrix * vMatrix;
|
||||
//Vector3f CameraRight = Vector3f(mat4.Get11(), mat4.Get21(), mat4.Get31());
|
||||
//Vector3f CameraUp = Vector3f(mat4.Get12(), mat4.Get22(), mat4.Get32());
|
||||
|
||||
//Vector3f v1 = (m_position + CameraRight * 0.5 * width + CameraUp * -0.5 * width);
|
||||
//Vector3f v2 = (m_position + CameraRight * 0.5 * width + CameraUp * 0.5 * width);
|
||||
//Vector3f v4 = (m_position + CameraRight * -0.5 * width + CameraUp * -0.5 * width);
|
||||
//Vector3f v3 = (m_position + CameraRight * -0.5 * width + CameraUp * 0.5 * width);
|
||||
|
||||
//tran.ApplyTranslation(m_position);
|
||||
float u, v, w, h;
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
shader.Use();
|
||||
atlas.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
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);
|
||||
//glLoadIdentity();
|
||||
|
||||
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);
|
||||
glTexCoord2f(u + w, v); glVertex3f(x+width/2., y - height, z); //glVertex3f(v3.x, v3.y, v3.z); //glVertex3f(50,50, 0);
|
||||
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();
|
||||
shader.Disable();
|
||||
|
||||
//tran.ApplyTranslation(-m_position);
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError)
|
||||
|
@ -16,14 +16,17 @@ public:
|
||||
enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
||||
|
||||
RemotePlayer(netprot::PlayerInfo pinfo);
|
||||
RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos);
|
||||
~RemotePlayer();
|
||||
|
||||
|
||||
void Init();
|
||||
void Feed(const netprot::Output out);
|
||||
void Render(TextureAtlas& atlas, Shader& shader, float elapsedTime, Player m_player);
|
||||
void Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime);
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError);
|
||||
|
||||
void SetPosition(Vector3f pos) { m_position = pos; }
|
||||
|
||||
private:
|
||||
netprot::Output current, previous;
|
||||
std::map<uint64_t, netprot::Output> m_outbuf;
|
||||
|
@ -33,7 +33,7 @@ void Renderer::RemoveChunk(int nbReduit)
|
||||
|
||||
}
|
||||
|
||||
void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
|
||||
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;
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
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 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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user