booster affiche
affiche simplement un carre rouge pour l'instant et ne se ramasse pas encore
This commit is contained in:
parent
225c815da4
commit
8769aa9e38
@ -20,6 +20,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="audio.h" />
|
||||
<ClInclude Include="booster.h" />
|
||||
<ClInclude Include="connector.h" />
|
||||
<ClInclude Include="define.h" />
|
||||
<ClInclude Include="engine.h" />
|
||||
@ -36,6 +37,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="audio.cpp" />
|
||||
<ClCompile Include="booster.cpp" />
|
||||
<ClCompile Include="connector.cpp" />
|
||||
<ClCompile Include="engine.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
|
@ -53,6 +53,9 @@
|
||||
<ClInclude Include="remoteplayer.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="booster.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="engine.cpp">
|
||||
@ -97,5 +100,8 @@
|
||||
<ClCompile Include="remoteplayer.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="booster.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
46
SQCSim2021/booster.cpp
Normal file
46
SQCSim2021/booster.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "booster.h";
|
||||
|
||||
void Booster::RenderBillboard(const Vector3f pos, TextureAtlas& textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran)
|
||||
{
|
||||
//
|
||||
//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());
|
||||
float x = pos.x;
|
||||
float y = pos.y;
|
||||
float z = pos.z;
|
||||
float width = 1.0f;
|
||||
float height = 1.0f;
|
||||
//Pt override les collisions.. a ce point la je sais pas quoi faire
|
||||
|
||||
//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();
|
||||
textureAtlas.Bind();
|
||||
textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
|
||||
//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);
|
||||
}
|
14
SQCSim2021/booster.h
Normal file
14
SQCSim2021/booster.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef BOOSTER_H__
|
||||
#define BOOSTER_H__
|
||||
#include "define.h"
|
||||
#include "textureatlas.h"
|
||||
#include "shader.h"
|
||||
#include "../SQCSim-common/vector3.h"
|
||||
#include "../SQCSim-common/transformation.h"
|
||||
|
||||
|
||||
class Booster {
|
||||
public:
|
||||
void RenderBillboard(const Vector3f pos, TextureAtlas& textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran);
|
||||
};
|
||||
#endif
|
@ -34,6 +34,6 @@
|
||||
#define AUDIO_PATH "./media/audio/"
|
||||
#define CHUNK_PATH "./media/chunks/"
|
||||
#define MENU_ITEM_PATH "./media/menu_items/"
|
||||
#define BOOSTER_TEXTURE_PATH "./media/textures/Booster"
|
||||
#define BOOSTER_TEXTURE_PATH "./media/textures/Booster/"
|
||||
|
||||
#endif // DEFINE_H__
|
||||
|
@ -448,7 +448,7 @@ void Engine::LoadResource() {
|
||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
||||
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
||||
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
|
||||
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterMauve.png");
|
||||
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png");
|
||||
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png");
|
||||
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png");
|
||||
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png");
|
||||
@ -1160,6 +1160,7 @@ void Engine::Render(float elapsedTime) {
|
||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
|
||||
m_booster.RenderBillboard({ 120,20,120 }, m_textureAtlas, texBoostHeal, m_shader01, all);
|
||||
|
||||
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "connector.h"
|
||||
#include "renderer.h"
|
||||
#include "remoteplayer.h"
|
||||
#include "booster.h"
|
||||
|
||||
|
||||
class Engine : public OpenglContext {
|
||||
@ -74,6 +75,7 @@ private:
|
||||
|
||||
World m_world = World();
|
||||
Renderer m_renderer = Renderer();
|
||||
Booster m_booster = Booster();
|
||||
|
||||
Texture m_textureCrosshair;
|
||||
Texture m_textureFont;
|
||||
@ -85,6 +87,8 @@ private:
|
||||
Texture m_textureMultiText;
|
||||
Texture m_textureTitle;
|
||||
|
||||
TextureAtlas::TextureIndex texBoostHeal;
|
||||
|
||||
Skybox m_skybox;
|
||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "texture.h"
|
||||
#include "openglcontext.h"
|
||||
#include "vertexbuffer.h"
|
||||
#include "texture.h"
|
||||
#include "../SQCSim-common/matrix4.h"
|
||||
|
||||
class RemotePlayer : public Player {
|
||||
|
@ -1,4 +1,9 @@
|
||||
#include "renderer.h"
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
|
||||
Renderer::Renderer() {
|
||||
m_meshes.Reset(nullptr);
|
||||
@ -131,7 +136,8 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
|
||||
}
|
||||
shader.Disable();
|
||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||
int cx = player.x;
|
||||
@ -238,6 +244,30 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran)
|
||||
{
|
||||
//float x = pos.x;
|
||||
//float y = pos.y;
|
||||
//float z = pos.z;
|
||||
//float width = 1.0f;
|
||||
//float height = 1.0f;
|
||||
|
||||
//float u, v, w, h;
|
||||
//shader.Use();
|
||||
//textureAtlas.Bind();
|
||||
//textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "textureatlas.h"
|
||||
#include "shader.h"
|
||||
#include "remoteplayer.h"
|
||||
#include "openglcontext.h"
|
||||
#include "vertexbuffer.h"
|
||||
#include "../SQCSim-common/matrix4.h"
|
||||
|
||||
class Renderer {
|
||||
private:
|
||||
@ -16,6 +19,7 @@ private:
|
||||
|
||||
TextureAtlas* m_playertext = nullptr;
|
||||
Shader* m_playershader = nullptr;
|
||||
bool test = true;
|
||||
|
||||
public:
|
||||
Renderer();
|
||||
@ -25,6 +29,8 @@ public:
|
||||
|
||||
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||
|
||||
void RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran);
|
||||
|
||||
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…
x
Reference in New Issue
Block a user