This commit is contained in:
Claudel-D-Roy 2023-12-02 15:19:46 -05:00
parent 5a491c5446
commit df0a142b12
3 changed files with 32 additions and 25 deletions

View File

@ -394,7 +394,7 @@ void Engine::Init() {
m_world.SetSeed(seed);
m_startTime = std::chrono::high_resolution_clock::now();
m_remotePlayer.SetPosition(Vector3f(.5, CHUNK_SIZE_Y + 10., .5));
// Gestion de souris.
CenterMouse();
HideCursor();
@ -1249,6 +1249,8 @@ void Engine::Render(float elapsedTime) {
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
//m_booster.RenderBillboard({ 195,16,195 }, m_textureAtlas, m_shader01, all);
m_remotePlayer.ApplyPhysics(Vector3f(0, 0, 0), &m_world, elapsedTime);
m_remotePlayer.Render(m_animeAtlas, m_shader01, all ,elapsedTime , m_player);
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
@ -1377,7 +1379,7 @@ void Engine::Render(float elapsedTime) {
for (auto& [key, player] : m_players) {
RemotePlayer* rt = static_cast<RemotePlayer*>(player);
glClear(GL_STENCIL_BUFFER_BIT);
rt->Render(m_animeAtlas, m_shader01, all, elapsedTime);
rt->Render(m_animeAtlas, m_shader01, all, elapsedTime, m_player);
m_otherplayerpos = player->GetPosition(); // Aller chercher GetPosition des deux façon, voir si ça chie.
}
glEnable(GL_CULL_FACE);

View File

@ -81,31 +81,37 @@ void RemotePlayer::Feed(const netprot::Output out) {
//m_position = current.position;
}
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime)
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime, Player& camera)
{
float x = GetPosition().x;
float y = GetPosition().y;
float z = GetPosition().z;
float width = 1.f;
float height = 1.7f;
Matrix4 mat4 = tran.GetMatrix();
Vector3f CameraRight = Vector3f(mat4.Get11(), mat4.Get21(), mat4.Get31());
Vector3f CameraUp = Vector3f(mat4.Get12(), mat4.Get22(), mat4.Get32());
Vector3f playerPosition = GetPosition() + Vector3f(0.f, 0.f, 0.f);
//Vector3f postionCamera = camera.GetPosition();
Vector3f v3 = (playerPosition + CameraRight * -0.5 * width + CameraUp * -0.5 * height);
Vector3f v1 = (playerPosition + CameraRight * 0.5 * width + CameraUp * -0.5 * height);
Vector3f v2 = (playerPosition + CameraRight * 0.5 * width + CameraUp * 0.5 * height);
Vector3f v4 = (playerPosition + CameraRight * -0.5 * width + CameraUp * 0.5 * height);
//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();
atlas.TextureIndexToCoord(0, u, v, w, h);
//glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -113,20 +119,19 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
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();
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);
glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z);
glTexCoord2f(u + w, v + h); glVertex3f(v3.x, v3.y, v3.z);
glTexCoord2f(u, v + h); glVertex3f(v4.x, v4.y, v4.z);
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);
}
bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError)

View File

@ -21,7 +21,7 @@ public:
void Init();
void Feed(const netprot::Output out);
void Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime);
void Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime, Player& camera);
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError);
void SetPosition(Vector3f pos) { m_position = pos; }