Architecture générale

This commit is contained in:
MarcEricMartel 2023-10-03 12:43:54 -04:00
parent 54c25e6f78
commit 183c5f186a
11 changed files with 93 additions and 37 deletions

View File

@ -8,6 +8,8 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
m_username = "Zelda Bee-Bop56";
}
Player::~Player() {}
void Player::TurnLeftRight(float value) {
m_rotY += value;
if (m_rotY > 360) m_rotY = 0;
@ -206,3 +208,7 @@ void Player::Teleport(int& x, int& z) {
m_position.x -= x * CHUNK_SIZE_X;
m_position.z -= z * CHUNK_SIZE_Z;
}
Vector3f Player::InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now) {
return Vector3f();
}

View File

@ -12,6 +12,8 @@ public:
enum Sound { NOSOUND, STEP, FALL };
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
~Player();
void TurnLeftRight(float value);
void TurnTopBottom(float value);
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
@ -26,12 +28,13 @@ public:
float GetHP() const;
void Teleport(int& x, int& z);
private:
protected:
Vector3f m_position;
Vector3f m_velocity;
Vector3f m_direction;
std::string m_username;
uint64_t id = 0;
float m_rotX = 0;
float m_rotY = 0;
@ -40,6 +43,9 @@ private:
float m_hp;
bool m_airborne;
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
};
#endif //_PLAYER_H__

View File

@ -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" />
@ -46,7 +47,7 @@
<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">

View File

@ -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,7 @@
<ClCompile Include="mesh.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="worldrenderer.cpp">
<ClCompile Include="renderer.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>

View File

@ -17,6 +17,8 @@ public:
//void SendInput();
//int Sync();
// void updateRemotePlayers(std::map<RemotePlayers> rplayers);
private:
#ifdef _WIN32
WSADATA m_wsaData;

View File

@ -531,9 +531,9 @@ void Engine::Render(float elapsedTime) {
m_bullets[x] = nullptr;
}
m_wrenderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
m_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo);
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
if (m_isSkybox) m_skybox.Render(skybox);

View File

@ -18,7 +18,7 @@
#include "audio.h"
#include "textureatlas.h"
#include "connector.h"
#include "worldrenderer.h"
#include "renderer.h"
class Engine : public OpenglContext {
public:
@ -60,7 +60,7 @@ 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;

25
SQCSim2021/remoteplayer.h Normal file
View File

@ -0,0 +1,25 @@
#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, RUNNING, JUMPING, SHOOTING, JUMPSHOOT, DEAD };
RemotePlayer();
void Init();
void Feed(const netprot::Output out);
private:
netprot::Output current, next;
float m_aminacc;
Anim m_animstate;
uint64_t m_team_id;
};
#endif

View File

@ -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;
@ -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;
@ -211,3 +211,9 @@ 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
View 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

View File

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