2023-10-15 16:23:43 -04:00
|
|
|
#include "remoteplayer.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstring>
|
2023-11-18 14:16:24 -05:00
|
|
|
|
2023-11-13 16:02:13 -05:00
|
|
|
#include <thread>
|
|
|
|
#include <queue>
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-18 14:16:24 -05:00
|
|
|
|
|
|
|
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)){
|
2023-11-13 16:02:13 -05:00
|
|
|
|
|
|
|
LoadTexture(m_texture_front, TEXTURE_PATH "AssetOtherPlayer/FinalPNGStanding/BlueFrontRight.png", false, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-11-19 16:46:13 -05:00
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-13 16:02:13 -05:00
|
|
|
RemotePlayer::~RemotePlayer()
|
|
|
|
{
|
2023-11-14 22:17:00 -05:00
|
|
|
|
2023-10-15 16:23:43 -04:00
|
|
|
}
|
|
|
|
|
2023-11-18 14:16:24 -05:00
|
|
|
void RemotePlayer::Init()
|
2023-11-14 22:17:00 -05:00
|
|
|
{
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemotePlayer::Feed(const netprot::Output out) {
|
|
|
|
|
2023-11-19 16:46:13 -05:00
|
|
|
//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.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;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//previous.direction = current.direction;
|
|
|
|
//previous.position = current.position;
|
|
|
|
//previous.states = current.states;
|
|
|
|
//previous.id = current.id;
|
2023-11-13 16:02:13 -05:00
|
|
|
}
|
|
|
|
|
2023-11-19 16:46:13 -05:00
|
|
|
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime)
|
2023-11-13 16:02:13 -05:00
|
|
|
{
|
2023-11-18 14:16:24 -05:00
|
|
|
//
|
|
|
|
//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());
|
2023-11-19 16:46:13 -05:00
|
|
|
float x = GetPosition().x;
|
|
|
|
float y = GetPosition().y;
|
|
|
|
float z = GetPosition().z;
|
|
|
|
float width = 1.7f;
|
|
|
|
float height = 2.5f;
|
2023-11-18 14:16:24 -05:00
|
|
|
//Pt override les collisions.. a ce point la je sais pas quoi faire
|
|
|
|
|
2023-11-19 16:46:13 -05:00
|
|
|
//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);
|
2023-11-18 14:16:24 -05:00
|
|
|
|
2023-11-19 16:46:13 -05:00
|
|
|
//tran.ApplyTranslation(m_position);
|
2023-11-15 08:27:51 -05:00
|
|
|
float u, v, w, h;
|
2023-11-19 16:46:13 -05:00
|
|
|
//glDisable(GL_DEPTH_TEST);
|
|
|
|
shader.Use();
|
2023-11-15 08:27:51 -05:00
|
|
|
atlas.Bind();
|
2023-11-18 14:16:24 -05:00
|
|
|
atlas.TextureIndexToCoord(0, u, v, w, h);
|
2023-11-19 16:46:13 -05:00
|
|
|
//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);
|
2023-11-13 16:02:13 -05:00
|
|
|
glEnd();
|
2023-11-15 08:27:51 -05:00
|
|
|
shader.Disable();
|
2023-11-19 16:46:13 -05:00
|
|
|
//tran.ApplyTranslation(-m_position);
|
|
|
|
//glEnable(GL_DEPTH_TEST);
|
2023-11-13 16:02:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError)
|
|
|
|
{
|
|
|
|
texture.Load(filename, useMipmaps);
|
|
|
|
if (!texture.IsValid()) {
|
|
|
|
std::cerr << "Unable to load texture (" << filename << ")" << std::endl;
|
|
|
|
if (stopOnError)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|