Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities #90

Merged
merged 38 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3c375f8
[Scene] Added. [external/entt] Added.
Unarelith Apr 4, 2020
c725adc
[Scene] Test item drop entity almost working.
Unarelith Apr 4, 2020
86ace0d
[InventoryCube] Texture rendering fixed.
Unarelith Apr 4, 2020
de98013
[Scene] Splitted into Controllers. [Config] New 'useItemDrop' option.
Unarelith Apr 4, 2020
4e09432
[Scene] Now using AbstractController instead of static classes.
Unarelith Apr 4, 2020
0f610ea
[AnimationComponent] Added new animation type: translation. [ItemDrop…
Unarelith Apr 5, 2020
4710c72
Working on entity serialization.
Unarelith Apr 5, 2020
9bf0969
Entity serialization is almost complete, only rendering data left.
Unarelith Apr 5, 2020
69b08c5
Got rendering working.
Unarelith Apr 5, 2020
9738bbe
[PlayerList] Added to store players in server.
Unarelith Apr 5, 2020
dd81f09
[CollisionController] Now server-side.
Unarelith Apr 5, 2020
fd0702c
Entities completely serialized.
Unarelith Apr 5, 2020
673e20e
[ServerWorld] Sending Scene state more often.
Unarelith Apr 5, 2020
b4a0ea6
[entt] Small tweaks for compatibility with C++17 version.
Unarelith Apr 8, 2020
fd7f880
Now using C++17 entt version.
Unarelith Apr 12, 2020
096a9d3
SFML and GameKit are now used as git submodules.
Unarelith Apr 13, 2020
51c3bf9
[README.md] Updated with new compilation instructions.
Unarelith Apr 13, 2020
cec6001
[SceneSerializer] Adapted to latest EnTT version.
Unarelith Apr 13, 2020
61a7012
[SceneSerializer] Now using entt::continuous_loader.
Unarelith Apr 13, 2020
5ea8047
[AnimationController] Moved client-side.
Unarelith Apr 25, 2020
5f76f3c
[SceneSerializer] Removed. [CMake] Small fix for 3.17.
Unarelith Apr 28, 2020
aa80cd4
[README.md] Updated compiler support line for C++17.
Unarelith Apr 28, 2020
26d65db
[NetworkComponent|NetworkController] Added.
Unarelith Apr 28, 2020
f9012fc
[Network] 'EntityDespawn' packet added.
Unarelith Apr 28, 2020
6ad4695
[README.md] Updated.
Unarelith Apr 28, 2020
1420e13
[RotationComponent] Added.
Unarelith Apr 28, 2020
0630440
[AnimationComponent] Now serialized.
Unarelith Apr 28, 2020
c8a289e
[CollisionController] Now sends inventory update.
Unarelith Apr 28, 2020
7d5b00e
[ServerConfig] Added for option 'useItemDrops'.
Unarelith Apr 28, 2020
c1097d4
[README.md] Updated.
Unarelith Apr 29, 2020
dd04ed9
[.travis.yml] Small fix. [entt] Updated.
Unarelith Apr 29, 2020
88041e5
[NetworkComponent] Now using server-side entity ID instead of an arbi…
Unarelith Apr 29, 2020
2cb2017
[cmake/FindGameKit.cmake] Removed.
Unarelith Apr 29, 2020
6d76a9f
[scene] Components, controllers and factories now have their own subf…
Unarelith Apr 29, 2020
96a0cf6
[CollisionController] Now checks the dimension too.
Unarelith Apr 29, 2020
4e9e039
[InventoryCube] Small fix.
Unarelith Apr 29, 2020
c151847
Windows-related fixes.
Unarelith Apr 29, 2020
9048b53
[ServerConfig] 'useItemDrops' is now 'false' by default.
Unarelith Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ doc/html
doc/latex

# Binaries
build
openminer
openminer_server
*.exe
Expand All @@ -63,5 +64,6 @@ openminer_server
*.zip
test_atlas.png
config.lua
server_config.lua
TODO

11 changes: 11 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[submodule "external/entt"]
path = external/entt
url = git://github.com/skypjack/entt.git
ignore = dirty
[submodule "external/SFML"]
path = external/SFML
url = git://github.com/SFML/SFML.git
ignore = dirty
[submodule "external/gamekit"]
path = external/gamekit
url = git://github.com/Unarelith/GameKit.git
18 changes: 4 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: linux
dist: trusty
dist: xenial
language: cpp

compiler:
Expand Down Expand Up @@ -32,21 +32,11 @@ addons:

before_install:
- sudo cp /usr/include/lua5.2/* /usr/include/
- git clone git://github.com/SFML/SFML.git
- cd SFML
- cmake .
- make -j8
- sudo make install
- cd ..
- git clone git://github.com/Quent42340/GameKit.git
- cd GameKit
- cmake .
- make -j8
- sudo make install
- cd ..

script:
- cmake .
- mkdir build
- cd build
- cmake ..
- make -j8

notifications:
Expand Down
83 changes: 49 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

include_directories(external)

#------------------------------------------------------------------------------
# Compiler flags
#------------------------------------------------------------------------------
set(DEBUG_GCC_FLAGS -g -Og -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
set(RELEASE_GCC_FLAGS -O3)
set(RELWITHDEB_GCC_FLAGS -g -O3 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

#------------------------------------------------------------------------------
# Setting default build type
Expand Down Expand Up @@ -55,21 +57,6 @@ endif()
include_directories(${LUA_INCLUDE_DIR})
link_directories(${LUA_LIBRARY_DIRS})

#------------------------------------------------------------------------------
# - gamekit
#------------------------------------------------------------------------------
if (WIN32)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/gamekit)
endif ()

find_package(GameKit REQUIRED)

if(NOT GAMEKIT_FOUND)
message(FATAL_ERROR "gamekit is needed to build the project. Please install it correctly.")
endif()

include_directories(${GAMEKIT_INCLUDE_DIR})

#------------------------------------------------------------------------------
# - tinyxml2
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -149,38 +136,66 @@ include_directories(${SDL2_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS})

#------------------------------------------------------------------------------
# - SFML network
# - GLEW
#------------------------------------------------------------------------------
if (WIN32)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/SFML)
endif ()
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glew)

find_package(GLEW REQUIRED)

if(NOT GLEW_FOUND)
message(FATAL_ERROR "GLEW not found!")
endif(NOT GLEW_FOUND)

if (MINGW)
set(SFML_STATIC_LIBRARIES TRUE)
include_directories(${GLEW_INCLUDE_DIRS})
endif ()

find_package(SFML COMPONENTS system network)
#------------------------------------------------------------------------------
# Submodules
# from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
#------------------------------------------------------------------------------
find_package(Git QUIET)

if(NOT SFML_FOUND)
message(FATAL_ERROR "SFML is needed to build the project. Please install it correctly.")
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

include_directories(${SFML_INCLUDE_DIRS})
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/gamekit/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

#------------------------------------------------------------------------------
# - GLEW
# - EnTT
#------------------------------------------------------------------------------
if (WIN32)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glew)
add_subdirectory(external/entt)
include_directories(external/entt/single_include)

find_package(GLEW REQUIRED)
#------------------------------------------------------------------------------
# - gamekit
#------------------------------------------------------------------------------
add_subdirectory(external/gamekit)
include_directories(external/gamekit/include)

if(NOT GLEW_FOUND)
message(FATAL_ERROR "GLEW not found!")
endif(NOT GLEW_FOUND)
#------------------------------------------------------------------------------
# - SFML network
#------------------------------------------------------------------------------
set(SFML_BUILD_AUDIO FALSE)
set(SFML_BUILD_GRAPHICS FALSE)
set(SFML_BUILD_WINDOW FALSE)
set(SFML_STATIC TRUE)

include_directories(${GLEW_INCLUDE_DIRS})
endif ()
set(BUILD_SHARED_LIBS OFF)

add_subdirectory(external/SFML)

#------------------------------------------------------------------------------
# Subdirectories
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- [Wiki](#wiki)
- [Keys](#keys)
- [How to compile](#how-to-compile)
- [Using Linux](#using-linux)
- [Using Windows](#using-windows)
- [Using OSX](#using-osx)
- [Discussion](#discussion)
- [Project status](#project-status)
- [Screenshots](#screenshots)
Expand Down Expand Up @@ -63,22 +66,25 @@ The long-term goal of this project is to provide a viable alternative to Minecra
### Using Linux

- Dependencies:
- A compiler with C++14 support (GCC >= 5.0 or clang >= 3.4)
- [CMake](http://www.cmake.org/download/)
- [GameKit](https://github.com/Unarelith/GameKit) (requires `SDL2` + `tinyxml2`, will switch to `SFML` starting from 2.6)
- [SFML](https://www.sfml-dev.org/) (only used for network)
- A compiler with C++17 support (GCC >= 7.0 or clang >= 5.0)
- [CMake](http://www.cmake.org/download/) (>= 3.12.4)
- [Lua](http://www.lua.org)
- [GameKit dependencies](https://github.com/Unarelith/GameKit#how-to-compile)
- _Linux users: Check your distribution repositories for packages._
- Run `cmake .`
- Run `make -j8`
- Run the client with `./openminer`
- If you want a multiplayer game, run the server with `./openminer_server`
- Run `cmake -B build . && cmake --build build -j8`
- Or `mkdir build && cd build && cmake .. && make -j8 && cmake ..` (for old CMake versions)
- Run the client with `./build/openminer`
- If you want a multiplayer game, run the server with `./build/openminer_server`

### Using Windows

- [Wiki: Compiling on Windows using CMake and MinGW-w64](https://github.com/Unarelith/OpenMiner/wiki/Compiling-on-Windows-with-MinGW-w64)
- [Wiki: Compiling on Windows using CMake and Visual Studio 2017](https://github.com/Unarelith/OpenMiner/wiki/Compiling-on-Windows-with-Visual-Studio-2017)

### Using OSX

I don't have an OSX system at the moment. But you can help me create a guide for this OS if you have one!

## Discussion

- Discord: [join server](https://discord.gg/eN8k8wt)
Expand All @@ -104,16 +110,16 @@ This list is non exhaustive.
- Player model display (currently without rotation nor animation)
- Dimensions (like the Nether or the Ender in Minecraft) ([#80](https://github.com/Unarelith/OpenMiner/pull/80))
- World loading/saving (using `/save <name>` and `/load <name>` commands, see [#26](https://github.com/Unarelith/OpenMiner/issues/26))
- Texture pack system (partially implemented, see [#34](https://github.com/Unarelith/OpenMiner/issues/34))
- Entities (block drops, mobs, etc...) ([#90](https://github.com/Unarelith/OpenMiner/pull/90))

### Missing features

- Texture pack system ([#34](https://github.com/Unarelith/OpenMiner/issues/34))
- Fluid propagation ([#62](https://github.com/Unarelith/OpenMiner/issues/62))
- Day/night cycle with sun/moon display ([#73](https://github.com/Unarelith/OpenMiner/issues/73))
- Real worldgen (seed-based, cave tunnels) ([#79](https://github.com/Unarelith/OpenMiner/issues/79))
- Clouds ([#52](https://github.com/Unarelith/OpenMiner/pull/52))
- Particle system
- Entities (block drops, mobs, etc...)

## Screenshots

Expand Down
16 changes: 0 additions & 16 deletions cmake/FindGameKit.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/FindTinyXml2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_path(TINYXML2_INCLUDE_DIRS NAMES tinyxml2.h)
find_library(TINYXML2_LIBRARIES NAMES tinyxml2)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(tinyxml2 DEFAULT_MSG TINYXML2_LIBRARIES TINYXML2_INCLUDE_DIRS)
find_package_handle_standard_args(TinyXml2 DEFAULT_MSG TINYXML2_LIBRARIES TINYXML2_INCLUDE_DIRS)

mark_as_advanced(TINYXML2_INCLUDE_DIRS TINYXML2_LIBRARIES)

2 changes: 2 additions & 0 deletions cmake/sdl2/FindSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
VERSION_VAR SDL2_VERSION_STRING)

if(SDL2MAIN_LIBRARY)
SET(FPHSA_NAME_MISMATCHED ON)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main
REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION_STRING)
SET(FPHSA_NAME_MISMATCHED OFF)
endif()


Expand Down
2 changes: 1 addition & 1 deletion config.example.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- You can copy this file as 'config.lua' to load automatically those settings at client startup
-- Here the default values are set, you can remove options or change them accordingly
-- See client/source/Config.cpp for more details
-- See source/client/core/Config.cpp for more details

-- Gameplay
isFlyModeEnabled = false
Expand Down
1 change: 1 addition & 0 deletions external/SFML
Submodule SFML added at 50e173
1 change: 1 addition & 0 deletions external/entt
Submodule entt added at 89dc7f
1 change: 1 addition & 0 deletions external/gamekit
Submodule gamekit added at d39510
14 changes: 0 additions & 14 deletions resources/shaders/color.f.glsl

This file was deleted.

13 changes: 8 additions & 5 deletions resources/shaders/game.f.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

varying vec4 v_coord3d;
varying vec4 v_color;
varying vec2 v_texCoord;
varying vec2 v_lightValue;
varying float v_ambientOcclusion;

Expand All @@ -10,8 +11,7 @@ varying float v_dist;

uniform int u_renderDistance;

// Get current pixel color
vec4 getColor();
uniform sampler2D u_tex;

// Get light color
vec4 light(vec4 color, vec3 lightColor, vec4 lightPosition, float ambientIntensity, float diffuseIntensity);
Expand All @@ -29,9 +29,12 @@ void main() {
if(blockFace > -1. && v_dist > u_renderDistance) discard;

// Get current pixel color and apply multiplier on grayscale textures
vec4 color = getColor();
if (blockFace > -1 && color != v_color && color.r == color.g && color.g == color.b) {
color *= v_color;
vec4 color = v_color;
if (v_texCoord.x > -0.99 && v_texCoord.y > -0.99) {
color = texture2D(u_tex, v_texCoord);
if (blockFace > -1 && color.r == color.g && color.g == color.b) {
color *= v_color;
}
}

// Block breaking animation
Expand Down
7 changes: 7 additions & 0 deletions server_config.example.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- You can copy this file as 'server_config.lua' to load automatically those settings at server startup
-- Here the default values are set, you can remove options or change them accordingly
-- See source/server/core/ServerConfig.cpp for more details

-- Gameplay
useItemDrops = false

8 changes: 4 additions & 4 deletions source/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(PROJECT_NAME ${CMAKE_PROJECT_NAME})
# Get source files
#------------------------------------------------------------------------------
file(GLOB_RECURSE SOURCE_FILES *.cpp)
file(GLOB_RECURSE HEADER_FILES *.hpp ../server/*.hpp ../common/*.hpp ../../external/*.hpp)
file(GLOB_RECURSE HEADER_FILES *.hpp ../server/*.hpp ../common/*.hpp)

foreach(HEADER_FILE ${HEADER_FILES})
get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
Expand Down Expand Up @@ -49,7 +49,8 @@ endif ()

target_link_libraries(${PROJECT_NAME}
${CMAKE_PROJECT_NAME}_server_lib
${GAMEKIT_LIBRARIES}
${CMAKE_PROJECT_NAME}_common
gamekit
${OPENGL_LIBRARIES}
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
Expand All @@ -60,6 +61,5 @@ target_link_libraries(${PROJECT_NAME}
${LUA_LIBRARIES}
sfml-system
sfml-network
${UNIX_LIBS}
${CMAKE_PROJECT_NAME}_common)
${UNIX_LIBS})

2 changes: 1 addition & 1 deletion source/client/core/ClientApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void ClientApplication::init() {
gk::CoreApplication::init();

m_window.addVertexAttribute(VertexAttribute::Coord3d, "coord3d", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, coord3d)));
m_window.addVertexAttribute(VertexAttribute::Color, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
m_window.addVertexAttribute(VertexAttribute::TexCoord, "texCoord", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, texCoord)));
m_window.addVertexAttribute(VertexAttribute::Color, "color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, color)));
m_window.addVertexAttribute(VertexAttribute::Normal, "normal", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, normal)));
m_window.addVertexAttribute(VertexAttribute::LightValue, "lightValue", 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, lightValue)));
m_window.addVertexAttribute(VertexAttribute::AmbientOcclusion, "ambientOcclusion", 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid *>(offsetof(Vertex, ambientOcclusion)));
Expand Down
Loading