booster quasi fonctionnel

affichage seulement visible a travers un autre booster.
ne se ramasse pas encore.
This commit is contained in:
Frederic Leger 2023-12-15 23:02:20 -05:00
parent 570bef266c
commit 2364fb9c1f
15 changed files with 285 additions and 192 deletions

View File

@ -131,6 +131,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="booster.h" />
<ClInclude Include="array2d.h" />
<ClInclude Include="array3d.h" />
<ClInclude Include="blockinfo.h" />
@ -147,6 +148,7 @@
<ClInclude Include="world.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="booster.cpp" />
<ClCompile Include="blockinfo.cpp" />
<ClCompile Include="boostinfo.cpp" />
<ClCompile Include="bullet.cpp" />

View File

@ -54,6 +54,9 @@
<ClInclude Include="transformation.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="booster.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="boostinfo.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
@ -83,6 +86,9 @@
<ClCompile Include="transformation.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="booster.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="boostinfo.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>

38
SQCSim-common/booster.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "booster.h"
Booster::Booster()
{
}
Booster::Booster(Vector3f tpos, BOOST_TYPE ttype)
{
pos = tpos;
type = ttype;
available = true;
}
Booster::~Booster()
{
}
Vector3f Booster::GetPosition()
{
return pos;
}
BOOST_TYPE Booster::GetType()
{
return type;
}
bool Booster::GetAvailability()
{
return available;
}
void Booster::SetAvailability(bool value)
{
available = value;
}

View File

@ -1,18 +1,13 @@
#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"
#include "../SQCSim-common/player.h"
#include "vector3.h"
class Booster {
public:
Booster();
Booster(Vector3f tpos, BOOST_TYPE ttype);
~Booster();
void RenderBillboard(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player);
Vector3f GetPosition();
BOOST_TYPE GetType();
bool GetAvailability();

View File

@ -31,7 +31,7 @@
#define TEXTURE_SIZE 512
#define MAX_BULLETS 512
#define NB_BOOST 1
#define NB_BOOST 2
#define TIME_SPEED_BOOST 10 //secondes
#define TIME_DAMAGE_BOOST 10 //secondes
#define TIME_INVINCIBLE_BOOST 4 //secondes

View File

@ -216,7 +216,8 @@ void Player::TakeBooster(Booster booster_table[])
{
for (int i = 0; i < sizeof(booster_table); i++)
{
if (abs((m_position.x + m_position.y + m_position.z) - (booster_table[i].GetPosition().x + booster_table[i].GetPosition().y + booster_table[i].GetPosition().z)) <= 0.5f && booster_table[i].GetAvailability() == true)
Vector3f pos = booster_table[i].GetPosition();
if (abs((m_position.x + m_position.y + m_position.z) - (pos.x + pos.y +pos.z)) <= 0.5f && booster_table[i].GetAvailability() == true)
{
GetBooster(booster_table[i].GetType());
booster_table[i].SetAvailability(false);

View File

@ -4,7 +4,7 @@
#include <cmath>
#include "transformation.h"
#include "vector3.h"
#include "../SQCSim2021/booster.h"
#include "booster.h"
#include "define.h"

View File

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="audio.h" />
<ClInclude Include="booster.h" />
<ClInclude Include="connector.h" />
<ClInclude Include="define.h" />
<ClInclude Include="engine.h" />
@ -38,7 +37,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="audio.cpp" />
<ClCompile Include="booster.cpp" />
<ClCompile Include="connector.cpp" />
<ClCompile Include="engine.cpp" />
<ClCompile Include="main.cpp" />

View File

@ -53,9 +53,6 @@
<ClInclude Include="remoteplayer.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="booster.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="settings.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
@ -103,9 +100,6 @@
<ClCompile Include="remoteplayer.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="booster.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="settings.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>

View File

@ -1,81 +0,0 @@
#include "booster.h"
Booster::Booster(Vector3f tpos, BOOST_TYPE ttype)
{
pos = tpos;
type = ttype;
}
Booster::~Booster()
{
}
Vector3f Booster::GetPosition()
{
return pos;
}
BOOST_TYPE Booster::GetType()
{
return type;
}
bool Booster::GetAvailability()
{
return available;
}
void Booster::SetAvailability(bool value)
{
available = value;
}
void Booster::RenderBillboard(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player)
{
float width = 1.0f;
float height = 1.7f;
Matrix4 mat4 = tran.GetMatrix();
Vector3f DiffCam = GetPosition() - player.GetPosition();
Vector3f UpCam = Vector3f(mat4.Get12(), mat4.Get22(), mat4.Get32());
Vector3f CrossA = DiffCam.Cross(UpCam);
Vector3f CrossB = DiffCam.Cross(CrossA);
CrossA.Normalize();
CrossB.Normalize();
Vector3f playerPosition = GetPosition() + Vector3f(0.f, 0.f, 0.f);
Vector3f v1 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v2 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v3 = (playerPosition + CrossA * 0.5 * width - CrossB * 0.5 * height);
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
float u, v, w, h;
shader.Use();
textureAtlas.Bind();
textureAtlas.TextureIndexToCoord(0, u, v, w, h);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
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();
}

View File

@ -3,13 +3,13 @@
//#define SFML_STATIC true
#include "../SQCSim-common/define.h"
#include <iostream>
#include <chrono>
#include <iomanip>
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "../SQCSim-common/define.h"
#ifdef _WIN32
#include <gl/GL.h>

View File

@ -78,7 +78,6 @@ void Engine::LoadResource() {
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
abort();
}
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
@ -124,15 +123,15 @@ void Engine::LoadResource() {
LoadTexture(m_textureMenuQuit, TEXTURE_PATH "menus/buttons/main/mainQuit.png", false);
LoadTexture(m_textureMenuSingle, TEXTURE_PATH "menus/buttons/main/mainSingle.png", false);
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.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");
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); //0
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); //1
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); //2
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); //3
TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.png"); //4
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png"); //5
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png"); //6
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png"); //7
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png"); //8
//AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM
@ -1326,6 +1325,8 @@ void Engine::Render(float elapsedTime) {
static float pollTime = 0;
static float bulletTime = 0;
static BlockType bloc = 1;
booster_table[0] = Booster({ 215, 15, 195 }, BTYPE_SPEED);
booster_table[1] = Booster({ 213, 15, 195 }, BTYPE_HEAL);
if (elapsedTime > 0.1f) return;
@ -1424,17 +1425,14 @@ void Engine::Render(float elapsedTime) {
}
}
}
gameTime += elapsedTime * 10;
Vector3f dance = Vector3f(sin(gameTime), 0, cos(-gameTime));
dance.Normalize();
booster_table[0] = Booster({ 195, 16, 195 }, BTYPE_SPEED);
m_remotePlayer.ApplyPhysics(dance, &m_world, elapsedTime, booster_table);
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
m_remotePlayer.Render(m_animeAtlas, m_shader01, all, elapsedTime);
booster_table[0].RenderBillboard(m_textureAtlas, m_shader01, all, m_player);
glDisable(GL_CULL_FACE);
for (Booster booster : booster_table) {
glClear(GL_STENCIL_BUFFER_BIT);
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
}
glEnable(GL_CULL_FACE);
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);

View File

@ -5,6 +5,7 @@
#include <chrono>
#include <cmath>
#include <unordered_map>
#include <set>
#include "../SQCSim-common/array2d.h"
#include "../SQCSim-common/blockinfo.h"
#include "../SQCSim-common/boostinfo.h"
@ -13,6 +14,7 @@
#include "../SQCSim-common/world.h"
#include "../SQCSim-common/transformation.h"
#include "../SQCSim-common/player.h"
#include "../SQCSim-common/booster.h"
#include "define.h"
#include "openglcontext.h"
#include "texture.h"
@ -23,16 +25,15 @@
#include "connector.h"
#include "renderer.h"
#include "remoteplayer.h"
#include "booster.h"
#include "settings.h"
class Engine : public OpenglContext {
public:
Engine();
virtual ~Engine();
virtual void DrawMenu();
virtual void DrawPause();
virtual void DrawSplachScreen();
virtual void Init();
virtual void DeInit();
virtual void LoadResource();
@ -47,90 +48,153 @@ public:
private:
int GetFps(float elapsedTime) const;
int GetCountdown(float elapsedTime);
int GetOptionsChoice();
bool StartMultiplayerGame();
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
void ChangeResolution(Resolution resolution);
void InstantDamage();
void SystemNotification(std::string systemLog);
void KillNotification(Player killer, Player killed);
void DisplayNotification(std::string message);
void ProcessNotificationQueue();
void DisplayCrosshair();
void DisplayPovGun();
void DisplayCurrentItem();
void DisplayHud(int timer);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySingleOrMultiplayerMenu();
void DrawHud(float elapsedTime, BlockType bloc);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySplashScreen();
void DisplayMainMenu();
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
void DrawMainMenuButtons(float centerX, float centerY);
void DrawSingleMultiButtons(float centerX, float centerY);
void DisplayLobbyMenu(float elapsedTime);
void SetPlayerUsername(float elapsedTime);
void SetServerAddress(float elapsedTime);
void DisplayPauseMenu(float elapsedTime);
void DisplayOptionsMenu();
void DisplayAudioMenu(float centerX, float centerY);
void DisplayGraphicsMenu(float centerX, float centerY);
void DisplayGameplayMenu(float centerX, float centerY);
void DrawSliderBackground(float centerX, float centerY, float minVal, float maxVal, float bottomSideValue, float topSideValue);
void DisplayBarPercentValue(float centerX, float centerY, float posX, float posY, float minVal, float maxVal, float value);
void DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue);
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
void ProcessNotificationQueue();
char SimulateKeyboard(unsigned char key);
void HandlePlayerInput(float elapsedTime);
Audio m_audio = Audio(AUDIO_PATH "music01.wav", AUDIO_PATH "menumusic01.wav");
irrklang::ISound* m_powpow, * m_scream;
irrklang::ISound* m_whoosh[MAX_BULLETS];
Bullet* m_bullets[MAX_BULLETS];
//Menu
Vector3f m_otherplayerpos = Vector3f(999, 999, 999);
World m_world = World();
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Connector m_conn;
Shader m_shader01;
Renderer m_renderer = Renderer();
Booster booster_table[NB_BOOST];
BlockInfo* m_blockinfo[BTYPE_LAST];
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
GameState m_gamestate = GameState::SPLASH;
Shader m_shader01;
Skybox m_skybox;
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
World m_world = World();
Renderer m_renderer = Renderer();
Booster* booster_table;
TextureAtlas::TextureIndex texBoostHeal;
Texture m_textureCrosshair;
Texture m_textureFont;
Texture m_textureGun;
Texture m_texturePovGun;
Texture m_textureSkybox;
Texture m_textureSoloMultiMenu;
Texture m_textureSoloText;
Texture m_textureMultiText;
Texture m_textureTitle;
TextureAtlas::TextureIndex texBoostHeal;
Texture m_textureLobbyMenu;
Texture m_textureMainMenu;
Texture m_textureOptionsMenu;
Texture m_texturePauseMenu;
Texture m_textureSplashScreen;
Skybox m_skybox;
Audio m_audio = Audio(AUDIO_PATH "start.wav");
Texture m_textureHd;
Texture m_textureFhd;
Texture m_textureQhd;
Texture m_textureUhd;
irrklang::ISound* m_powpow,
* m_scream;
irrklang::ISound *m_whoosh[MAX_BULLETS];
Texture m_textureLobbyServer;
Texture m_textureLobbyIdentify;
Texture m_textureCheck;
Texture m_textureChecked;
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Texture m_texturePauseResume;
Texture m_texturePauseMainMenu;
Bullet* m_bullets[MAX_BULLETS];
Texture m_textureOptAudio;
Texture m_textureOptBack;
Texture m_textureOptGameplay;
Texture m_textureOptGraphics;
Texture m_textureOptMain;
Texture m_textureOptMusic;
Texture m_textureOptOptions;
Texture m_textureOptResolution;
Texture m_textureOptSensitivity;
Texture m_textureOptSfx;
std::unordered_map<uint64_t, Player*> m_players;
netprot::Buffer m_buf, m_bufout;
std::chrono::high_resolution_clock::time_point m_startTime;
Texture m_textureMenuBack;
Texture m_textureMenuMulti;
Texture m_textureMenuOptions;
Texture m_textureMenuPlay;
Texture m_textureMenuQuit;
Texture m_textureMenuSingle;
Texture m_textureMenuTitle;
//Menu
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
GameState m_gamestate = GameState::MAIN_MENU;
Texture MenuTitleTexture;
Texture MenuBGTexture;
Texture MenuStartTexture;
Texture MenuQuitTexture;
Texture MenuOptionsTexture;
Texture PauseBGTexture;
Texture SplachScreenTexture;
Settings m_options = Settings(m_audio);
Resolution m_resolution = HD;
float m_splashTime = 2.0f;
float m_scale;
float m_time = 0;
float m_time_SplashScreen = 0;
float m_titleX = 0;
float m_titleY = 0;
float m_Width = 0;
float m_Height = 0;
int m_renderCount = 0;
int m_countdown = COUNTDOWN;
int m_nbReductionChunk = 4;
int m_timerReductionChunk = 30;
float m_mainvolume;
float m_musicvolume;
float m_sfxvolume;
float m_sensitivity;
int m_selectedOption = 0;
bool m_selectedOptAudioMainBar = false;
bool m_selectedOptAudioMusicBar = false;
bool m_selectedOptAudioSfxBar = false;
bool m_selectedGameplaySensitivityBar = false;
bool m_damage = false;
bool m_wireframe = false;
@ -144,6 +208,25 @@ private:
bool m_soloMultiChoiceMade = false;
bool m_stopcountdown = false;
bool m_selectedPlayOptions = false;
bool m_selectedOptions = false;
bool m_selectedQuit = false;
std::string m_currentInputString;
std::string m_username;
std::string m_serverAddr;
char m_inputChar = 0;
bool m_invalidChar = false;
bool m_charChanged = false;
bool m_settingUsername = false;
bool m_settingServer = false;
bool m_selectedSinglePlayer = false;
bool m_selectedMultiPlayer = false;
bool m_singleReady = false;
bool m_multiReady = false;
bool m_key1 = false;
bool m_key2 = false;
@ -153,19 +236,30 @@ private:
bool m_keyA = false;
bool m_keyS = false;
bool m_keyD = false;
bool m_keyEnter = false;
bool m_keySpace = false;
bool m_keyShift = false;
bool m_keyBackspace = false;
bool m_mouseL = false;
bool m_mouseR = false;
bool m_mouseC = false;
bool m_mouseWU = false;
bool m_mouseWD = false;
//Pour trouver ou est la souris
float m_mousemx = 0;
float m_mousemy = 0;
bool m_networkgame = false;
netprot::PlayerInfo m_pinfo;
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));
Connector m_conn;
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
std::chrono::high_resolution_clock::time_point m_startTime;
std::unordered_map<uint64_t, Player*> m_players;
netprot::Buffer m_buf, m_bufout;
netprot::ChunkMod* m_chunkmod = nullptr;
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
std::string m_messageNotification = "";
};

View File

@ -244,27 +244,75 @@ 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)
void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster)
{
//float x = pos.x;
//float y = pos.y;
//float z = pos.z;
//float width = 1.0f;
//float height = 1.0f;
if (booster.GetAvailability() == true)
{
float width = 1.f;
float height = 1.f;
//float u, v, w, h;
//shader.Use();
//textureAtlas.Bind();
//textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
Vector3f DiffCam = booster.GetPosition() - player.GetPosition();
Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
//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();
Vector3f CrossA = DiffCam.Cross(UpCam);
Vector3f CrossB = DiffCam.Cross(CrossA);
CrossA.Normalize();
CrossB.Normalize();
Vector3f playerPosition = booster.GetPosition() + Vector3f(0.f, -.75f, 0.f);
Vector3f v2 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v1 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v3 = (playerPosition + CrossA * 0.5 * width - CrossB * 0.5 * height);
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
int index;
BOOST_TYPE type = booster.GetType();
switch (type)
{
case BTYPE_HEAL:
index = 5;
break;
case BTYPE_DAMAGE:
index = 6;
break;
case BTYPE_SPEED:
index = 7;
break;
case BTYPE_INVINCIBLE:
index = 8;
break;
default:
index = 1;
break;
}
float u, v, w, h;
shader.Use();
textureAtlas.Bind();
textureAtlas.TextureIndexToCoord(index, u, v, w, h);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
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();
}
}

View File

@ -29,7 +29,7 @@ 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 RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster);
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;