Merge branch 'master' into SQC-22
@@ -25,13 +25,14 @@
|
||||
<ClInclude Include="engine.h" />
|
||||
<ClInclude Include="mesh.h" />
|
||||
<ClInclude Include="openglcontext.h" />
|
||||
<ClInclude Include="remoteplayer.h" />
|
||||
<ClInclude Include="shader.h" />
|
||||
<ClInclude Include="skybox.h" />
|
||||
<ClInclude Include="texture.h" />
|
||||
<ClInclude Include="textureatlas.h" />
|
||||
<ClInclude Include="tool.h" />
|
||||
<ClInclude Include="vertexbuffer.h" />
|
||||
<ClInclude Include="worldrenderer.h" />
|
||||
<ClInclude Include="renderer.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="audio.cpp" />
|
||||
@@ -40,13 +41,14 @@
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="mesh.cpp" />
|
||||
<ClCompile Include="openglcontext.cpp" />
|
||||
<ClCompile Include="remoteplayer.cpp" />
|
||||
<ClCompile Include="shader.cpp" />
|
||||
<ClCompile Include="skybox.cpp" />
|
||||
<ClCompile Include="texture.cpp" />
|
||||
<ClCompile Include="textureatlas.cpp" />
|
||||
<ClCompile Include="tool.cpp" />
|
||||
<ClCompile Include="vertexbuffer.cpp" />
|
||||
<ClCompile Include="worldrenderer.cpp" />
|
||||
<ClCompile Include="renderer.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
||||
@@ -130,7 +132,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -145,7 +147,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -162,7 +164,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
@@ -184,7 +186,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
|
@@ -47,7 +47,10 @@
|
||||
<ClInclude Include="mesh.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="worldrenderer.h">
|
||||
<ClInclude Include="renderer.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="remoteplayer.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@@ -88,7 +91,10 @@
|
||||
<ClCompile Include="mesh.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="worldrenderer.cpp">
|
||||
<ClCompile Include="renderer.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="remoteplayer.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.18.4)
|
||||
|
||||
project(SQCSim-Client VERSION 0.8)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_STANDARD_REQUIRED True)
|
||||
|
||||
set(CMAKE_BUILD_DIRECTORY "./build")
|
||||
@@ -50,7 +50,8 @@ add_executable(SQCSim-client
|
||||
"../textureatlas.cpp"
|
||||
"../tool.cpp"
|
||||
"../vertexbuffer.cpp"
|
||||
"../worldrenderer.cpp"
|
||||
"../renderer.cpp"
|
||||
"../remoteplayer.cpp"
|
||||
"../main.cpp"
|
||||
)
|
||||
|
||||
|
@@ -42,7 +42,7 @@ int Connector::Init() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Connector::Connect(char* srv_addr, std::string name) {
|
||||
int Connector::Connect(const char* srv_addr, std::string name) {
|
||||
sockaddr_in add;
|
||||
m_srvsockaddr.sin_family = AF_INET;
|
||||
m_srvsockaddr.sin_port = htons(SRV_PORT);
|
||||
@@ -54,44 +54,60 @@ int Connector::Connect(char* srv_addr, std::string name) {
|
||||
|
||||
if (connect(m_sock_tcp, (sockaddr*)&m_srvsockaddr, sizeof(m_srvsockaddr)) < 0) {
|
||||
std::cout << "<EFBFBD>chec de la connexion." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
char* buf = new char[150];
|
||||
uint32_t buflen = 150;
|
||||
flag_t flag = 1;
|
||||
if (ioctl(m_sock_tcp, SOCK_NONBLOCK, &flag) < 0) {
|
||||
std::cout << "Impossible de mettre le socket en mode non-bloquant." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
netprot::Buffer bf;
|
||||
netprot::LoginInfo log;
|
||||
memcpy(&log.name, name.c_str(), name.size() + 1);
|
||||
strcpy(log.name, name.c_str());
|
||||
|
||||
netprot::Serialize(&log, &buf, &buflen);
|
||||
netprot::sendPack(m_sock_tcp, &log, &bf);
|
||||
|
||||
int se = send(m_sock_tcp, buf, buflen, 0);
|
||||
bool ready = false;
|
||||
int errors = 0;
|
||||
std::vector<netprot::Packet> lsPck;
|
||||
while (!ready) {
|
||||
lsPck = netprot::recvPacks(m_sock_tcp, &bf);
|
||||
|
||||
delete[] buf;
|
||||
buf = new char[150] {0};
|
||||
buflen = 150;
|
||||
int rpack = 0;
|
||||
|
||||
while (rpack < 2) {
|
||||
recv(m_sock_tcp, buf, buflen, 0);
|
||||
|
||||
switch (netprot::getType(buf, buflen)) {
|
||||
case netprot::PACKET_TYPE::LOGINF:
|
||||
if (!netprot::Deserialize(&m_loginfo, buf, buflen)) {
|
||||
std::cout << "Packet LoginInfo invalide." << std::endl;
|
||||
return 2;
|
||||
for (auto& pck : lsPck) {
|
||||
bool bypass_delete = false;
|
||||
netprot::PlayerInfo* pl = nullptr;
|
||||
switch (pck.type) {
|
||||
using enum netprot::PACKET_TYPE;
|
||||
case LOGINF:
|
||||
m_loginfo = netprot::LoginInfo((netprot::LoginInfo*)pck.ptr);
|
||||
break;
|
||||
case GAMEINFO:
|
||||
m_gameinfo = netprot::GameInfo((netprot::GameInfo*)pck.ptr);
|
||||
break;
|
||||
case PLAYINF:
|
||||
pl = (netprot::PlayerInfo*)pck.ptr;
|
||||
m_players[pl->id] = pl;
|
||||
bypass_delete = true;
|
||||
break;
|
||||
case TEAMINF:
|
||||
// TODO: Faire dequoi avec TeamInfo si on fini par avoir des teams.
|
||||
break;
|
||||
case SYNC:
|
||||
m_origin = netprot::Sync((netprot::Sync*)pck.ptr);
|
||||
ready = true;
|
||||
break;
|
||||
default:
|
||||
errors++;
|
||||
break;
|
||||
}
|
||||
++rpack;
|
||||
break;
|
||||
case netprot::PACKET_TYPE::GAMEINFO:
|
||||
if (!netprot::Deserialize(&m_gameinfo, buf, buflen)) {
|
||||
std::cout << "Packet GameInfo invalide." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
++rpack;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Packet invalide." << std::endl;
|
||||
break;
|
||||
if (!bypass_delete)
|
||||
netprot::emptyPack(pck);
|
||||
}
|
||||
lsPck.clear();
|
||||
if (errors > 100)
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -99,3 +115,5 @@ int Connector::Connect(char* srv_addr, std::string name) {
|
||||
uint64_t Connector::getId() const { return m_loginfo.sid; }
|
||||
|
||||
unsigned int Connector::getSeed() const { return m_gameinfo.seed; }
|
||||
|
||||
netprot::Sync Connector::getOrigin() const { return m_origin; }
|
||||
|
@@ -11,26 +11,32 @@ public:
|
||||
~Connector();
|
||||
|
||||
int Init();
|
||||
int Connect(char* srv_addr, std::string name);
|
||||
int Connect(const char* srv_addr, std::string name);
|
||||
uint64_t getId() const;
|
||||
unsigned int getSeed() const;
|
||||
netprot::Sync getOrigin() const;
|
||||
|
||||
|
||||
//void SendInput();
|
||||
//int Sync();
|
||||
|
||||
SOCKET m_sock_udp = 0,
|
||||
m_sock_tcp = 0;
|
||||
sockaddr_in m_srvsockaddr;
|
||||
|
||||
// void updateRemotePlayers(std::map<RemotePlayers> rplayers);
|
||||
|
||||
std::map<uint64_t, netprot::PlayerInfo> m_players;
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
WSADATA m_wsaData;
|
||||
#endif
|
||||
std::map<Timestamp, netprot::Input> m_inputmanifest;
|
||||
std::map<uint64_t, netprot::PlayerInfo> m_players;
|
||||
std::map<uint64_t, netprot::TeamInfo> m_teams;
|
||||
|
||||
netprot::LoginInfo m_loginfo;
|
||||
netprot::GameInfo m_gameinfo;
|
||||
|
||||
sockaddr_in m_srvsockaddr;
|
||||
SOCKET m_sock_udp = 0,
|
||||
m_sock_tcp = 0;
|
||||
netprot::Sync m_origin;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <climits>
|
||||
#endif
|
||||
|
||||
#define NETWORK_TEST false
|
||||
#define SRV_ADDR "127.0.0.1"
|
||||
#define COUNTDOWN 300
|
||||
|
||||
|
@@ -18,7 +18,8 @@
|
||||
#include "audio.h"
|
||||
#include "textureatlas.h"
|
||||
#include "connector.h"
|
||||
#include "worldrenderer.h"
|
||||
#include "renderer.h"
|
||||
#include "remoteplayer.h"
|
||||
|
||||
class Engine : public OpenglContext {
|
||||
public:
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
virtual ~Engine();
|
||||
virtual void DrawMenu();
|
||||
virtual void DrawPause();
|
||||
virtual void DrawSplachScreen();
|
||||
virtual void Init();
|
||||
virtual void DeInit();
|
||||
virtual void LoadResource();
|
||||
@@ -38,23 +40,24 @@ public:
|
||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
||||
|
||||
private:
|
||||
float GetScale() const;
|
||||
|
||||
int GetFps(float elapsedTime) const;
|
||||
int GetCountdown(float elapsedTime);
|
||||
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||
|
||||
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 PrintText(float x, float y, float scale, const std::string& t);
|
||||
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||
|
||||
Connector m_conn;
|
||||
Shader m_shader01;
|
||||
@@ -62,12 +65,17 @@ private:
|
||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||
|
||||
World m_world = World();
|
||||
WorldRenderer m_wrenderer = WorldRenderer();
|
||||
Renderer m_renderer = Renderer();
|
||||
|
||||
Texture m_textureSkybox;
|
||||
Texture m_textureFont;
|
||||
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;
|
||||
|
||||
Skybox m_skybox;
|
||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||
@@ -80,8 +88,10 @@ private:
|
||||
|
||||
Bullet* m_bullets[MAX_BULLETS];
|
||||
|
||||
std::map<uint64_t, Player*> m_players;
|
||||
|
||||
//Menu
|
||||
enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
||||
GameState m_gamestate = GameState::MAIN_MENU;
|
||||
Texture MenuTitleTexture;
|
||||
Texture MenuBGTexture;
|
||||
@@ -89,13 +99,21 @@ private:
|
||||
Texture MenuQuitTexture;
|
||||
Texture MenuOptionsTexture;
|
||||
Texture PauseBGTexture;
|
||||
Texture SplachScreenTexture;
|
||||
|
||||
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;
|
||||
|
||||
bool m_damage = false;
|
||||
|
||||
bool m_wireframe = false;
|
||||
bool m_isSkybox = true;
|
||||
bool m_block = false;
|
||||
@@ -104,6 +122,7 @@ private:
|
||||
bool m_displayHud = true;
|
||||
bool m_displayInfo = false;
|
||||
bool m_resetcountdown = false;
|
||||
bool m_soloMultiChoiceMade = false;
|
||||
bool m_stopcountdown = false;
|
||||
|
||||
bool m_keyK = false;
|
||||
@@ -122,6 +141,8 @@ private:
|
||||
float m_mousemx = 0;
|
||||
float m_mousemy = 0;
|
||||
|
||||
bool m_networkgame = false;
|
||||
|
||||
std::string m_messageNotification = "";
|
||||
};
|
||||
|
||||
|
BIN
SQCSim2021/media/audio/whitenoise.ogg
Normal file
BIN
SQCSim2021/media/textures/BrouillonbackgroundMenu.png
Normal file
After Width: | Height: | Size: 6.5 MiB |
BIN
SQCSim2021/media/textures/multi_player.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
SQCSim2021/media/textures/sc2.png
Normal file
After Width: | Height: | Size: 195 KiB |
BIN
SQCSim2021/media/textures/single_multi.png
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
SQCSim2021/media/textures/single_player.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
SQCSim2021/media/textures/skybox2.png
Normal file
After Width: | Height: | Size: 4.3 MiB |
BIN
SQCSim2021/media/textures/title.png
Normal file
After Width: | Height: | Size: 30 KiB |
@@ -9,7 +9,7 @@ Mesh::~Mesh() {
|
||||
void Mesh::FlushMeshToVBO() {
|
||||
m_vertexBuffer.SetMeshData(m_vd, m_vcount);
|
||||
m_vcount = 0;
|
||||
delete[] m_vd;
|
||||
//delete[] m_vd;
|
||||
}
|
||||
|
||||
void Mesh::FlushVBO() {
|
||||
|
@@ -9,6 +9,7 @@ OpenglContext::~OpenglContext()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool OpenglContext::Start(const std::string& title, int width, int height, bool fullscreen)
|
||||
{
|
||||
m_title = title;
|
||||
@@ -22,13 +23,14 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
||||
|
||||
while (m_app.isOpen())
|
||||
{
|
||||
clock.restart();
|
||||
|
||||
sf::Event Event;
|
||||
while (m_app.pollEvent(Event))
|
||||
{
|
||||
switch(Event.type)
|
||||
clock.restart();
|
||||
|
||||
sf::Event Event;
|
||||
while (m_app.pollEvent(Event))
|
||||
{
|
||||
switch (Event.type)
|
||||
{
|
||||
case sf::Event::Closed:
|
||||
m_app.close();
|
||||
break;
|
||||
@@ -51,29 +53,29 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
||||
MouseReleaseEvent(ConvertMouseButton(Event.mouseButton.button), Event.mouseButton.x, Event.mouseButton.y);
|
||||
break;
|
||||
case sf::Event::MouseWheelMoved:
|
||||
if(Event.mouseWheel.delta > 0)
|
||||
if (Event.mouseWheel.delta > 0)
|
||||
MousePressEvent(MOUSE_BUTTON_WHEEL_UP, Event.mouseButton.x, Event.mouseButton.y);
|
||||
else
|
||||
MousePressEvent(MOUSE_BUTTON_WHEEL_DOWN, Event.mouseButton.x, Event.mouseButton.y);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_app.setActive();
|
||||
Render(m_lastFrameTime);
|
||||
m_app.display();
|
||||
|
||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||
|
||||
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
||||
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
||||
if(waitTime > 0)
|
||||
{
|
||||
sf::sleep(sf::seconds(waitTime));
|
||||
m_app.setActive();
|
||||
Render(m_lastFrameTime);
|
||||
m_app.display();
|
||||
|
||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||
}
|
||||
|
||||
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
||||
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
||||
if (waitTime > 0)
|
||||
{
|
||||
sf::sleep(sf::seconds(waitTime));
|
||||
|
||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||
}
|
||||
}
|
||||
|
||||
UnloadResource();
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <SFML/Window.hpp>
|
||||
#include "define.h"
|
||||
#include "texture.h"
|
||||
|
||||
// Documentation de SFML: http://www.sfml-dev.org/documentation/index-fr.php
|
||||
class OpenglContext
|
||||
@@ -31,7 +32,6 @@ public:
|
||||
virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
||||
|
||||
|
||||
bool Start(const std::string& title, int width, int height, bool fullscreen);
|
||||
bool Stop();
|
||||
|
||||
|
70
SQCSim2021/remoteplayer.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "remoteplayer.h"
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : Player(Vector3f(0, 0, 0), 0, 0), m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
|
||||
|
||||
}
|
||||
|
||||
void RemotePlayer::Init() {
|
||||
|
||||
}
|
||||
|
||||
void RemotePlayer::Feed(const netprot::Output out) {
|
||||
|
||||
current.position = out.position;
|
||||
current.direction = out.direction;
|
||||
current.states = out.states;
|
||||
current.id = out.id;
|
||||
|
||||
//a revoir pour le jump et le shoot en meme temps lorsque les test seront possible
|
||||
|
||||
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) {
|
||||
//true;
|
||||
m_animstate = Anim::SHOOTING;
|
||||
}
|
||||
else if (current.states.jumping) {
|
||||
//true;
|
||||
m_animstate = Anim::JUMPING;
|
||||
}
|
||||
else if (current.states.dead) {
|
||||
//true;
|
||||
m_animstate = Anim::DEAD;
|
||||
}
|
||||
else if(current.states.powerup){
|
||||
//true;
|
||||
m_animstate = Anim::POWERUP;
|
||||
}
|
||||
else if (current.states.still) {
|
||||
//true;
|
||||
m_animstate = Anim::STILL;
|
||||
}
|
||||
else if (current.states.running) {
|
||||
//true;
|
||||
m_animstate = Anim::RUNNING;
|
||||
}
|
||||
|
||||
|
||||
previous.direction = current.direction;
|
||||
previous.position = current.position;
|
||||
previous.states = current.states;
|
||||
previous.id = current.id;
|
||||
|
||||
|
||||
|
||||
}
|
26
SQCSim2021/remoteplayer.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef REMOTEPLAYER_H__
|
||||
#define REMOTEPLAYER_H__
|
||||
#include "../SQCSim-common/player.h"
|
||||
#include "../SQCSim-common/netprotocol.h"
|
||||
#include "define.h"
|
||||
#include "textureatlas.h"
|
||||
#include "shader.h"
|
||||
|
||||
class RemotePlayer : public Player {
|
||||
public:
|
||||
enum Anim { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
||||
|
||||
RemotePlayer(netprot::PlayerInfo pinfo);
|
||||
|
||||
void Init();
|
||||
void Feed(const netprot::Output out);
|
||||
|
||||
private:
|
||||
netprot::Output current, previous;
|
||||
netprot::PlayerInfo m_pinfo;
|
||||
float m_aminacc;
|
||||
Anim m_animstate;
|
||||
uint64_t m_team_id;
|
||||
|
||||
};
|
||||
#endif
|
@@ -1,13 +1,13 @@
|
||||
#include "worldrenderer.h"
|
||||
#include "renderer.h"
|
||||
|
||||
WorldRenderer::WorldRenderer() {
|
||||
Renderer::Renderer() {
|
||||
m_meshes.Reset(nullptr);
|
||||
}
|
||||
|
||||
WorldRenderer::~WorldRenderer() {
|
||||
Renderer::~Renderer() {
|
||||
}
|
||||
|
||||
void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) {
|
||||
void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
|
||||
rendercount = 0;
|
||||
Vector3f angle;
|
||||
Vector3f cursor;
|
||||
@@ -18,7 +18,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
||||
direct.Normalize();
|
||||
pos.y = 1;
|
||||
|
||||
static Vector3<unsigned int> renderManifest[VIEW_DISTANCE * 8]; // Nombre de Chunks maximal à être rendus.
|
||||
static Vector3<unsigned int> renderManifest[VIEW_DISTANCE * 8]; // Nombre de Chunks maximal <EFBFBD> <20>tre rendus.
|
||||
|
||||
//for (int dist = VIEW_DISTANCE; dist >= 0; dist -= CHUNK_SIZE_X) {
|
||||
for (int dist = 0; dist <= VIEW_DISTANCE; dist += CHUNK_SIZE_X) {
|
||||
@@ -27,18 +27,18 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
||||
int echantillons;
|
||||
|
||||
if (dist > VIEW_DISTANCE * .1f) {
|
||||
sinus = .00872653549f; // sin(1/2 degré)
|
||||
cosinus = .99996192306; // cos(1/2 degré)
|
||||
sinus = .00872653549f; // sin(1/2 degr<EFBFBD>)
|
||||
cosinus = .99996192306; // cos(1/2 degr<EFBFBD>)
|
||||
echantillons = 180;
|
||||
}
|
||||
//else {//if (dist > VIEW_DISTANCE * .3f) {
|
||||
// sinus = .01151891831f; // sin(2/3 degré)
|
||||
// cosinus = .99993365506; // cos(2/3 degré)
|
||||
// sinus = .01151891831f; // sin(2/3 degr<EFBFBD>)
|
||||
// cosinus = .99993365506; // cos(2/3 degr<EFBFBD>)
|
||||
// echantillons = 120;
|
||||
//}
|
||||
//else if (dist > VIEW_DISTANCE * .2f) {
|
||||
// sinus = .01745240643; // sin(1 degré)
|
||||
// cosinus = .99984769515; // cos(1 degré)
|
||||
// sinus = .01745240643; // sin(1 degr<EFBFBD>)
|
||||
// cosinus = .99984769515; // cos(1 degr<EFBFBD>)
|
||||
// echantillons = 90;
|
||||
//}
|
||||
//else if (dist > VIEW_DISTANCE * .1f) {
|
||||
@@ -72,7 +72,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
||||
bool valide = true;
|
||||
unsigned int chx, chy;
|
||||
origin->ChunkAt(cursor)->GetPosition(chx, chy);
|
||||
for (int index = 0; index < rendercount; ++index) // Permet de vérifier seulement contre celles ajoutées dans la frame, et ne pas avoir à refaire l'array à chaque frame.
|
||||
for (int index = 0; index < rendercount; ++index) // Permet de v<EFBFBD>rifier seulement contre celles ajout<EFBFBD>es dans la frame, et ne pas avoir <EFBFBD> refaire l'array <EFBFBD> chaque frame.
|
||||
if (renderManifest[index].x == chx && renderManifest[index].z == chy)
|
||||
valide = false;
|
||||
|
||||
@@ -107,7 +107,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||
};
|
||||
|
||||
void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||
void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||
int cx = player.x;
|
||||
int cy = player.z;
|
||||
static int frameUpdate = 2;
|
||||
@@ -212,3 +212,10 @@ void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
||||
}
|
||||
|
||||
void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const {
|
||||
}
|
||||
|
30
SQCSim2021/renderer.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef RENDERER_H__
|
||||
#define RENDERER_H__
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include "../SQCSim-common/world.h"
|
||||
#include "../SQCSim-common/transformation.h"
|
||||
#include "define.h"
|
||||
#include "mesh.h"
|
||||
#include "textureatlas.h"
|
||||
#include "shader.h"
|
||||
#include "remoteplayer.h"
|
||||
|
||||
class Renderer {
|
||||
private:
|
||||
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
||||
|
||||
TextureAtlas* m_playertext = nullptr;
|
||||
Shader* m_playershader = nullptr;
|
||||
|
||||
public:
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||
|
||||
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;
|
||||
};
|
||||
#endif
|
@@ -8,30 +8,30 @@ void Skybox::Init(float size){
|
||||
int count = 0;
|
||||
VertexBuffer::VertexData* vd = new VertexBuffer::VertexData[24];
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 0.f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 0.f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 0.f, .5f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 1.f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 1.f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, .25f, 1.f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 0.f, .75f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 1.f, .5f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 1.f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .25f, 1.f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, .5f, 1.f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .5f, 1.f);
|
||||
|
||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .5f, .25f);
|
||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, .75f, .25f);
|
||||
|
@@ -1,23 +0,0 @@
|
||||
#ifndef WORLDRENDERER_H__
|
||||
#define WORLDRENDERER_H__
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include "../SQCSim-common/world.h"
|
||||
#include "../SQCSim-common/transformation.h"
|
||||
#include "define.h"
|
||||
#include "mesh.h"
|
||||
#include "textureatlas.h"
|
||||
#include "shader.h"
|
||||
|
||||
class WorldRenderer {
|
||||
private:
|
||||
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
||||
|
||||
public:
|
||||
WorldRenderer();
|
||||
~WorldRenderer();
|
||||
|
||||
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas);
|
||||
void UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||
};
|
||||
#endif
|