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

@@ -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)