Compare commits
	
		
			28 Commits
		
	
	
		
			sqc-14_cla
			...
			SQC_21_Men
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 9dd2e1b821 | ||
|  | eed8f5f04a | ||
|  | e2fa4fea7c | ||
|  | fc4a22e844 | ||
|  | 102153a093 | ||
|  | c7271f6217 | ||
|  | 8ebe7b95fc | ||
|  | 5e29c9be54 | ||
|  | f8680a318a | ||
|  | df5b7960b2 | ||
|  | f4d4f1eca0 | ||
|  | 793da52871 | ||
|  | 18a5d98c57 | ||
|  | 81240c6f70 | ||
|  | f1ddd67655 | ||
|  | a054a7bff1 | ||
|  | b712c950c6 | ||
|  | 9cbf20ba21 | ||
|  | 3f774d7c2e | ||
|  | db0a39f64a | ||
|  | f2095f6e5b | ||
|  | 93062e49e2 | ||
|  | c85f7df15e | ||
|  | 6668127f15 | ||
|  | cddc59d6cf | ||
|  | 965e78309e | ||
|  | 0452920697 | ||
|  | 8be8852596 | 
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -373,5 +373,8 @@ FodyWeavers.xsd | ||||
| /x64/Release/SQCSim2023.exe | ||||
| /x64/Debug/SQCSim2023.exe | ||||
| /x64/Debug/SQCSim2021.pdb | ||||
| SQCSim2021/SQCSim2021.vcxproj.filters | ||||
| SQCSim2021/SQCSim2021.vcxproj | ||||
| /SQCSim-srv/cmake/* | ||||
| !/SQCSim-srv/cmake/CMakeLists.txt | ||||
| /SQCSim2021/cmake/* | ||||
| !/SQCSim2021/cmake/CMakeLists.txt | ||||
| /SQCSim2021/SQCSim-client | ||||
|   | ||||
| @@ -7,8 +7,9 @@ Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_cur | ||||
|  | ||||
| Bullet::~Bullet() {} | ||||
|  | ||||
| bool Bullet::Update(World* world, float elapsedtime) { | ||||
| 	for (int x = 0; x < 1000; ++x) { | ||||
| bool Bullet::Update(World* world, float elapsedtime, int perframe) { | ||||
| 	int max = 100 / perframe; | ||||
| 	for (int x = 0; x < max; ++x) { | ||||
| 		m_currentpos += m_velocity * elapsedtime; | ||||
|  | ||||
| 		if (!world->ChunkAt(m_currentpos)) | ||||
| @@ -30,10 +31,14 @@ void Bullet::Transpose(int& x, int& z) { | ||||
| 	m_startpos.z -= z * CHUNK_SIZE_Z; | ||||
| } | ||||
|  | ||||
| Vector3f Bullet::getPos() { | ||||
| Vector3f Bullet::getPos() const { | ||||
| 	return m_currentpos; | ||||
| } | ||||
|  | ||||
| Vector3f Bullet::getVel() const { | ||||
| 	return m_velocity; | ||||
| } | ||||
|  | ||||
| uint64_t Bullet::getTeamID(){ | ||||
| 	return m_tid; | ||||
| } | ||||
|   | ||||
| @@ -12,9 +12,10 @@ public: | ||||
| 	Bullet(Vector3f pos, Vector3f dir, uint64_t tid); | ||||
| 	~Bullet(); | ||||
|  | ||||
| 	bool Update(World* world, float elapsedtime); | ||||
| 	bool Update(World* world, float elapsedtime, int perframe); | ||||
| 	void Transpose(int& x, int& z); | ||||
| 	Vector3f getPos(); | ||||
| 	Vector3f getPos() const; | ||||
| 	Vector3f getVel() const; | ||||
| 	uint64_t getTeamID(); | ||||
|  | ||||
| private: | ||||
|   | ||||
| @@ -53,6 +53,7 @@ typedef uint64_t Timestamp; | ||||
| #include <sys/socket.h> | ||||
| #include <arpa/inet.h> | ||||
| #include <netinet/in.h> | ||||
| #include <cstring> | ||||
|  | ||||
| #define SOCKET int | ||||
| #define INVALID_SOCKET -1 | ||||
|   | ||||
| @@ -33,11 +33,7 @@ namespace netprot { | ||||
| 		bool jumping,  | ||||
| 			 shooting,  | ||||
| 			 hit,  | ||||
| 			 powerup, | ||||
| 			 dead, | ||||
| 			 still, | ||||
| 		     jumpshot, | ||||
| 			 running; | ||||
| 			 powerup; | ||||
| 	}; | ||||
|  | ||||
| 	struct Input {										// cli -> srv			UDP			~frame | ||||
|   | ||||
| @@ -8,8 +8,6 @@ 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; | ||||
| @@ -208,9 +206,3 @@ void Player::Teleport(int& x, int& z) { | ||||
| 	m_position.x -= x * CHUNK_SIZE_X; | ||||
| 	m_position.z -= z * CHUNK_SIZE_Z; | ||||
| } | ||||
|  | ||||
| uint64_t Player::getId() const { return id; } | ||||
|  | ||||
| Vector3f Player::InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now) { | ||||
| 	return Vector3f(); | ||||
| } | ||||
|   | ||||
| @@ -12,8 +12,6 @@ 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); | ||||
| @@ -28,13 +26,12 @@ public: | ||||
| 	float GetHP() const; | ||||
| 	void Teleport(int& x, int& z); | ||||
|  | ||||
| protected: | ||||
| private: | ||||
| 	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; | ||||
| @@ -43,9 +40,6 @@ protected: | ||||
| 	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__ | ||||
|  | ||||
|   | ||||
| @@ -130,7 +130,7 @@ void World::GetScope(unsigned int& x, unsigned int& y) { | ||||
| 	y = m_center[1]; | ||||
| } | ||||
|  | ||||
| void World::Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) { | ||||
| void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) { | ||||
| 	UpdateWorld(player_pos, blockinfo); | ||||
| 	//TransposeWorld(player_pos, bullets); | ||||
| } | ||||
| @@ -407,4 +407,4 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST] | ||||
| 	}*/ | ||||
| } | ||||
|  | ||||
| int World::GettbDeleted() const { return m_tbDeleted.size(); } | ||||
| int World::GettbDeleted() const { return m_tbDeleted.size(); } | ||||
|   | ||||
| @@ -30,7 +30,7 @@ public: | ||||
| 	BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const; | ||||
| 	BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const; | ||||
|  | ||||
| 	void Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]); | ||||
| 	void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]); | ||||
|  | ||||
| 	void GetScope(unsigned int& x, unsigned int& y); | ||||
|  | ||||
|   | ||||
							
								
								
									
										30
									
								
								SQCSim-srv/cmake/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,30 @@ | ||||
| cmake_minimum_required(VERSION 3.18.4) | ||||
|  | ||||
| project(SQCSim-Server VERSION 0.1) | ||||
|  | ||||
| add_compile_options("-Wno-narrowing") | ||||
| set(CMAKE_CXX_STANDARD 17) | ||||
| set(CMAKE_STANDARD_REQUIRED True) | ||||
|  | ||||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../out") | ||||
|  | ||||
| set(SQCSIM_COMMON_DIR "../../SQCSim-common/") | ||||
|  | ||||
| add_library(SQCSim-common | ||||
| 			"${SQCSIM_COMMON_DIR}blockinfo.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}bullet.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}chunk.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}netprotocol.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}opensimplex.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}player.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}transformation.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}world.cpp" | ||||
| ) | ||||
|  | ||||
| add_executable(SQCSim-server | ||||
| 			"../connection.cpp" | ||||
| 			"../server.cpp" | ||||
| 			"../main.cpp" | ||||
| 			) | ||||
|  | ||||
| target_link_libraries(SQCSim-server PUBLIC SQCSim-common) | ||||
| @@ -14,4 +14,4 @@ | ||||
| typedef unsigned char LogDest; | ||||
| enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST }; | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
|   | ||||
| @@ -85,7 +85,7 @@ int Server::Ready() { | ||||
|  | ||||
| 	while (!readystart) { | ||||
| 		sockaddr_in sockad; | ||||
| 		int addrlen = sizeof(sockad); | ||||
| 		unsigned int addrlen = sizeof(sockad); | ||||
| 		SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen); | ||||
|  | ||||
| 		if (sock < 0) | ||||
| @@ -140,7 +140,7 @@ void Server::Run() { | ||||
| 	Log("Partie en cours...", false, false); | ||||
| } | ||||
|  | ||||
| inline std::string Server::Timestamp() { | ||||
| inline std::string Server::LogTimestamp() { | ||||
| 	time_t rawtime; | ||||
| 	struct tm timeinfo; | ||||
| 	char buffer[80]; | ||||
| @@ -162,11 +162,11 @@ inline std::string Server::Timestamp() { | ||||
| void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) { | ||||
| 	switch (m_log) { | ||||
| 	case LOG_DEST::LOGFILE: | ||||
| 		m_logfile << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl; | ||||
| 		m_logfile << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl; | ||||
| 		break; | ||||
| 	case LOG_DEST::CONSOLE: | ||||
| 	default: | ||||
| 		std::cout << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl; | ||||
| 		std::cout << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl; | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,7 @@ private: | ||||
|  | ||||
| 	World* m_world = nullptr; | ||||
|  | ||||
| 	std::string Timestamp(); | ||||
| 	std::string LogTimestamp(); | ||||
| 	void Log(std::string str, bool is_error, bool is_fatal); | ||||
| 	void buildIdList(size_t size); | ||||
|  | ||||
|   | ||||
| @@ -25,14 +25,13 @@ | ||||
|     <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="renderer.h" /> | ||||
|     <ClInclude Include="worldrenderer.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="audio.cpp" /> | ||||
| @@ -41,14 +40,13 @@ | ||||
|     <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="renderer.cpp" /> | ||||
|     <ClCompile Include="worldrenderer.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj"> | ||||
|   | ||||
| @@ -47,10 +47,7 @@ | ||||
|     <ClInclude Include="mesh.h"> | ||||
|       <Filter>Fichiers d%27en-tête</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="renderer.h"> | ||||
|       <Filter>Fichiers d%27en-tête</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="remoteplayer.h"> | ||||
|     <ClInclude Include="worldrenderer.h"> | ||||
|       <Filter>Fichiers d%27en-tête</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
| @@ -91,10 +88,7 @@ | ||||
|     <ClCompile Include="mesh.cpp"> | ||||
|       <Filter>Fichiers sources</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="renderer.cpp"> | ||||
|       <Filter>Fichiers sources</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="remoteplayer.cpp"> | ||||
|     <ClCompile Include="worldrenderer.cpp"> | ||||
|       <Filter>Fichiers sources</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   | ||||
| @@ -2,17 +2,17 @@ | ||||
|  | ||||
| Audio::Audio() { | ||||
| 	m_engine = irrklang::createIrrKlangDevice(); | ||||
| 	m_engine->setDopplerEffectParameters(1); | ||||
| 	m_engine->setRolloffFactor(1); | ||||
| 	m_engine->setDefault3DSoundMinDistance(1); | ||||
| 	m_engine->setDopplerEffectParameters(10); | ||||
| 	m_engine->setRolloffFactor(2); | ||||
| 	m_engine->setDefault3DSoundMinDistance(.1); | ||||
| 	m_engine->setDefault3DSoundMaxDistance(1000); | ||||
| } | ||||
|  | ||||
| Audio::Audio(const char * music) { | ||||
| 	m_engine = irrklang::createIrrKlangDevice(); | ||||
| 	m_engine->setDopplerEffectParameters(1); | ||||
| 	m_engine->setRolloffFactor(1); | ||||
| 	m_engine->setDefault3DSoundMinDistance(1); | ||||
| 	m_engine->setRolloffFactor(2); | ||||
| 	m_engine->setDefault3DSoundMinDistance(.1); | ||||
| 	m_engine->setDefault3DSoundMaxDistance(1000); | ||||
| 	m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING); | ||||
| } | ||||
| @@ -28,10 +28,11 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { | ||||
| 								  irrklang::vec3df(vel.x, vel.y, vel.z)); | ||||
| } | ||||
|  | ||||
| void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume = 1) { | ||||
| 	sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), false, false, true, irrklang::ESM_NO_STREAMING, true); | ||||
| irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) { | ||||
| 	sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true); | ||||
| 	sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z)); | ||||
| 	sound->setVolume(volume); | ||||
| 	return sound; | ||||
| } | ||||
|  | ||||
| void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume = 1) { | ||||
|   | ||||
| @@ -1,24 +1,30 @@ | ||||
| #ifndef AUDIO_H__ | ||||
| #define AUDIO_H__ | ||||
|  | ||||
| #ifdef _WIN32 | ||||
| #include <irrKlang.h> | ||||
| #include <ik_ISoundSource.h> | ||||
| #else | ||||
| #include "./external/irrKlang-64bit-1.6.0/include/irrKlang.h" | ||||
| #include "./external/irrKlang-64bit-1.6.0/include/ik_ISoundSource.h" | ||||
| #endif | ||||
|  | ||||
| #include "../SQCSim-common/vector3.h" | ||||
| #include "define.h" | ||||
|  | ||||
| class Audio { | ||||
| private: | ||||
| 	irrklang::ISoundEngine* m_engine; | ||||
| 	irrklang::ISound* m_music; | ||||
|  | ||||
| public: | ||||
| 	Audio(); | ||||
| 	Audio(const char* music); | ||||
| 	~Audio(); | ||||
| 	irrklang::ISoundEngine* m_engine; | ||||
|  | ||||
| 	void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed); | ||||
|  | ||||
| 	void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume); | ||||
| 	irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume); | ||||
|  | ||||
| 	void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume); | ||||
|  | ||||
| @@ -29,4 +35,4 @@ public: | ||||
| 	void PauseEngine(); | ||||
| }; | ||||
|  | ||||
| #endif // AUDIO_H__ | ||||
| #endif // AUDIO_H__ | ||||
|   | ||||
							
								
								
									
										68
									
								
								SQCSim2021/cmake/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,68 @@ | ||||
| cmake_minimum_required(VERSION 3.18.4) | ||||
|  | ||||
| project(SQCSim-Client VERSION 0.8) | ||||
|  | ||||
| set(CMAKE_CXX_STANDARD 17) | ||||
| set(CMAKE_STANDARD_REQUIRED True) | ||||
|  | ||||
| set(CMAKE_BUILD_DIRECTORY "./build") | ||||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../") | ||||
|  | ||||
| set(SQCSIM_COMMON_DIR "../../SQCSim-common/") | ||||
| set(SQCSIM_EXTERN_DIR "../external/") | ||||
|  | ||||
| find_package(SFML COMPONENTS system window graphics REQUIRED) | ||||
| find_package(DevIL REQUIRED) | ||||
| find_package(OpenGL REQUIRED) | ||||
| find_package(GLEW REQUIRED) | ||||
|  | ||||
| find_library(IRRKLANG_LIBRARY | ||||
| 	NAMES libIrrKlang.so | ||||
| 	PATHS "${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/lib/linux-gcc-64/") | ||||
|  | ||||
| include_directories( | ||||
| 	${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/include/ | ||||
| 			${SFML_INCLUDE_DIRS} | ||||
| 			${IL_INCLUDE_DIR} | ||||
| 			) | ||||
|  | ||||
|  | ||||
| add_library(SQCSim-common | ||||
| 			"${SQCSIM_COMMON_DIR}blockinfo.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}bullet.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}chunk.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}netprotocol.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}opensimplex.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}player.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}transformation.cpp" | ||||
| 			"${SQCSIM_COMMON_DIR}world.cpp" | ||||
| ) | ||||
|  | ||||
| add_executable(SQCSim-client | ||||
| 			"../audio.cpp" | ||||
| 			"../connector.cpp" | ||||
| 			"../engine.cpp" | ||||
| 			"../mesh.cpp" | ||||
| 			"../openglcontext.cpp" | ||||
| 			"../shader.cpp" | ||||
| 			"../skybox.cpp" | ||||
| 			"../texture.cpp" | ||||
| 			"../textureatlas.cpp" | ||||
| 			"../tool.cpp" | ||||
| 			"../vertexbuffer.cpp" | ||||
| 			"../worldrenderer.cpp" | ||||
| 			"../main.cpp" | ||||
| 			) | ||||
|  | ||||
| target_link_libraries(SQCSim-client PUBLIC SQCSim-common | ||||
| 			${IRRKLANG_LIBRARY} | ||||
| 			sfml-system | ||||
| 			sfml-window | ||||
| 			sfml-graphics | ||||
| 			GL | ||||
| 			GLU | ||||
| 			GLEW | ||||
| 			${IL_LIBRARIES} | ||||
| 			${ILU_LIBRARIES} | ||||
| 			) | ||||
|  | ||||
| @@ -17,8 +17,6 @@ public: | ||||
|  | ||||
| 	//void SendInput(); | ||||
| 	//int Sync(); | ||||
|  | ||||
| 	// void updateRemotePlayers(std::map<RemotePlayers> rplayers); | ||||
| private: | ||||
| #ifdef _WIN32 | ||||
| 	WSADATA m_wsaData; | ||||
|   | ||||
| @@ -6,26 +6,34 @@ | ||||
| #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/glew.h> | ||||
| #include <gl/GL.h> | ||||
| #include <gl/GLU.h> | ||||
| #else | ||||
| #include <GL/gl.h> | ||||
| #include <GL/glu.h> | ||||
| #include <climits> | ||||
| #endif | ||||
|  | ||||
| #define NETWORK_TEST false | ||||
| #define SRV_ADDR "127.0.0.1" | ||||
| #define COUNTDOWN 300 | ||||
|  | ||||
| #define BASE_WIDTH 1920 | ||||
| #define BASE_HEIGHT 1080 | ||||
| #define BULLET_UPDATES_PER_FRAME 20 | ||||
|  | ||||
| #define BASE_WIDTH 640 | ||||
| #define BASE_HEIGHT 480 | ||||
|  | ||||
|  | ||||
| #define TEXTURE_PATH        "./media/textures/" | ||||
| #define SHADER_PATH		    "./media/shaders/" | ||||
| #define AUDIO_PATH			"./media/audio/" | ||||
| #define CHUNK_PATH			"./media/chunks/" | ||||
| #define MENU_ITEM_PATH		"./media/menu_items/" | ||||
|  | ||||
| #endif // DEFINE_H__ | ||||
|   | ||||
							
								
								
									
										0
									
								
								SQCSim2021/docs/analyse_preliminaire.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1
									
								
								SQCSim2021/docs/analyse_serveur.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1 @@ | ||||
|  | ||||
| @@ -18,12 +18,14 @@ | ||||
| #include "audio.h" | ||||
| #include "textureatlas.h" | ||||
| #include "connector.h" | ||||
| #include "renderer.h" | ||||
| #include "worldrenderer.h" | ||||
|  | ||||
| class Engine : public OpenglContext { | ||||
| public: | ||||
|     Engine(); | ||||
|     virtual ~Engine(); | ||||
|     virtual void DrawMenu(); | ||||
|     virtual void DrawSplachScreen(); | ||||
|     virtual void Init(); | ||||
|     virtual void DeInit(); | ||||
|     virtual void LoadResource(); | ||||
| @@ -36,8 +38,6 @@ 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); | ||||
|  | ||||
| @@ -48,11 +48,13 @@ private: | ||||
|     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; | ||||
| @@ -60,25 +62,46 @@ private: | ||||
|     TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST); | ||||
|  | ||||
|     World m_world = World(); | ||||
|     Renderer m_renderer = Renderer(); | ||||
|     WorldRenderer m_wrenderer = WorldRenderer(); | ||||
|  | ||||
|     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"); | ||||
|  | ||||
|     irrklang::ISound* m_powpow; | ||||
|     irrklang::ISound* m_scream; | ||||
|     irrklang::ISound* m_powpow, | ||||
|         * m_scream; | ||||
|     irrklang::ISound *m_whoosh[MAX_BULLETS]; | ||||
|  | ||||
|     Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); | ||||
|      | ||||
|     Bullet* m_bullets[MAX_BULLETS]; | ||||
|  | ||||
|     //Menu | ||||
|     enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY }; | ||||
|     GameState m_gamestate = GameState::MAIN_MENU; | ||||
|     Texture MenuTitleTexture; | ||||
|     Texture MenuBGTexture; | ||||
|     Texture MenuStartTexture; | ||||
|     Texture MenuQuitTexture; | ||||
|     Texture MenuOptionsTexture; | ||||
|     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; | ||||
| @@ -91,6 +114,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; | ||||
| @@ -105,6 +129,9 @@ private: | ||||
|     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; | ||||
|  | ||||
|     std::string m_messageNotification = ""; | ||||
| }; | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/audio/noise.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/menu_items/BasicPlay.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 7.9 KiB | 
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/menu_items/BasicQuit.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 8.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/menu_items/test.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 289 KiB | 
| @@ -7,7 +7,7 @@ void main() | ||||
|     texel = texture2D(tex,gl_TexCoord[0].st); | ||||
|  | ||||
|     texel *= light; | ||||
|    texel.a = 255; | ||||
|    texel.a = 255.; | ||||
|     gl_FragColor = texel; | ||||
|     | ||||
| } | ||||
|   | ||||
							
								
								
									
										
											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(); | ||||
|  | ||||
|   | ||||
| @@ -1,70 +0,0 @@ | ||||
| #include "remoteplayer.h" | ||||
| #include <iostream> | ||||
| #include <cstring> | ||||
|  | ||||
|  | ||||
| RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), 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; | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -1,25 +0,0 @@ | ||||
| #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(); | ||||
|  | ||||
| 	void Init(); | ||||
| 	void Feed(const netprot::Output out); | ||||
|  | ||||
| private: | ||||
| 	netprot::Output current, previous; | ||||
| 	float m_aminacc; | ||||
| 	Anim m_animstate; | ||||
| 	uint64_t m_team_id; | ||||
|  | ||||
| }; | ||||
| #endif | ||||
| @@ -1,30 +0,0 @@ | ||||
| #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,13 +1,13 @@ | ||||
| #include "renderer.h" | ||||
| #include "worldrenderer.h" | ||||
| 
 | ||||
| Renderer::Renderer() { | ||||
| WorldRenderer::WorldRenderer() { | ||||
| 	m_meshes.Reset(nullptr); | ||||
| } | ||||
| 
 | ||||
| Renderer::~Renderer() { | ||||
| WorldRenderer::~WorldRenderer() { | ||||
| } | ||||
| 
 | ||||
| void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const { | ||||
| void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) { | ||||
| 	rendercount = 0; | ||||
| 	Vector3f angle; | ||||
| 	Vector3f cursor; | ||||
| @@ -107,7 +107,7 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play | ||||
| 	glStencilFunc(GL_GREATER, 1, 0xFF); | ||||
| }; | ||||
| 
 | ||||
| void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) { | ||||
| void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) { | ||||
| 	int cx = player.x; | ||||
| 	int cy = player.z; | ||||
| 	static int frameUpdate = 2; | ||||
| @@ -212,8 +212,3 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void Renderer::RenderPlayer(Player* player, Transformation tran) const { | ||||
| } | ||||
| 
 | ||||
| void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const { | ||||
| } | ||||
							
								
								
									
										23
									
								
								SQCSim2021/worldrenderer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,23 @@ | ||||
| #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 | ||||