pleurer en rotation

This commit is contained in:
Claudel-D-Roy 2023-11-18 14:16:24 -05:00
parent dc0d2d8148
commit 82cfc2d1b1
5 changed files with 47 additions and 16 deletions

View File

@ -16,8 +16,8 @@
#define SEED 0 #define SEED 0
#define COUNTDOWN 300 #define COUNTDOWN 300
#define WORLD_SIZE_X 64 #define WORLD_SIZE_X 8
#define WORLD_SIZE_Y 64 #define WORLD_SIZE_Y 8
#define FRAMES_RENDER_CHUNKS 1 #define FRAMES_RENDER_CHUNKS 1
#define FRAMES_UPDATE_CHUNKS 1 #define FRAMES_UPDATE_CHUNKS 1

View File

@ -1046,6 +1046,8 @@ void Engine::Render(float elapsedTime) {
Transformation all; Transformation all;
Transformation skybox; Transformation skybox;
Transformation remotePlayer;
Vector3f vstep; Vector3f vstep;
// Transformations initiales // 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); 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_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
m_renderer.UpdateMesh(&m_world, 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) m_skybox.Render(skybox);
if (m_isSkybox) DrawHud(elapsedTime, bloc); if (m_isSkybox) DrawHud(elapsedTime, bloc);
if (m_isSkybox) DisplayPovGun(); if (m_isSkybox) DisplayPovGun();
ProcessNotificationQueue(); ProcessNotificationQueue();

View File

@ -62,7 +62,7 @@ private:
void DrawHud(float elapsedTime, BlockType bloc); void DrawHud(float elapsedTime, BlockType bloc);
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f); void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
void RenderRemotePlayers(RemotePlayer& remoteplayer, float elapsedTime);
Connector m_conn; Connector m_conn;

View File

@ -1,13 +1,14 @@
#include "remoteplayer.h" #include "remoteplayer.h"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include "texture.h"
#include <thread> #include <thread>
#include <queue> #include <queue>
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); LoadTexture(m_texture_front, TEXTURE_PATH "AssetOtherPlayer/FinalPNGStanding/BlueFrontRight.png", false, false);
@ -69,22 +70,36 @@ void RemotePlayer::Feed(const netprot::Output out) {
previous.id = current.id; 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; float u, v, w, h;
atlas.Bind(); atlas.Bind();
atlas.TextureIndexToCoord(0, u, v, w, h);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(0, 50., 0); atlas.TextureIndexToCoord(0, u, v, w, h);
glTexCoord2f(u+w, v); glVertex3f(50., 50., 0); glTexCoord2f(u, v); glVertex3f(x, y + size, z);
glTexCoord2f(u+w, v+h); glVertex3f(50., 0, 0); glTexCoord2f(u + w, v); glVertex3f(x + size, y + size, z);
glTexCoord2f(u, v+h); glVertex3f(0, 0, 0); glTexCoord2f(u + w, v + h); glVertex3f(x + size, y, z);
glTexCoord2f(u, v + h); glVertex3f(x, y, z);
glEnd(); glEnd();
shader.Disable(); shader.Disable();
} }
bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError) bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError)

View File

@ -7,6 +7,9 @@
#include "shader.h" #include "shader.h"
#include "texture.h" #include "texture.h"
#include "openglcontext.h" #include "openglcontext.h"
#include "vertexbuffer.h"
#include "texture.h"
#include "../SQCSim-common/matrix4.h"
class RemotePlayer : public Player { class RemotePlayer : public Player {
public: public:
@ -18,7 +21,7 @@ public:
void Init(); void Init();
void Feed(const netprot::Output out); 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); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError);
private: private:
@ -31,5 +34,7 @@ private:
Texture m_texture_front; Texture m_texture_front;
}; };
#endif #endif