├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── cmake └── Modules │ ├── CMakeParseArguments.cmake │ ├── FindASSIMP.cmake │ ├── FindFreetype.cmake │ ├── FindGLEW.cmake │ ├── FindPackageHandleStandardArgs.cmake │ ├── FindPackageMessage.cmake │ └── FindSFML.cmake ├── deploy_key.enc ├── doxygen.conf.in ├── hooks ├── pre-push └── setup_hooks.py ├── includes ├── AABB2.h ├── BoneMatrices.h ├── BroadPhaseCollider.h ├── Camera.h ├── Collider.h ├── ColliderFactory.h ├── ControlStatus.h ├── Controls.h ├── ControlsManager.h ├── CubeMapTexture.h ├── DestructorUtils.h ├── Dimension.h ├── Effects.h ├── ExactPhaseCollider.h ├── FileLogHandler.h ├── Font.h ├── FontManager.h ├── GLSquare.h ├── GameObject.h ├── Globals.h ├── HUDGraphic.h ├── HudRenderer.h ├── IComponent.h ├── IDrawable.h ├── IHudDrawable.h ├── IJoystickTranslation.h ├── IMesh.h ├── IRenderComponent.h ├── IShader.h ├── ImageTexture.h ├── Input.h ├── JoystickAxis.h ├── JoystickButton.h ├── JoystickTranslation.h ├── JoystickTranslator.h ├── KeyboardButton.h ├── Layout.h ├── Lights.h ├── ListLayout.h ├── LogHandler.h ├── Logger.h ├── Material.h ├── Mesh.h ├── MouseAxis.h ├── MouseButton.h ├── MousePosition.h ├── MouseWarp.h ├── MoveComponent.h ├── Octree.h ├── ParticleConf.h ├── ParticleGenerator.h ├── ParticleRenderer.h ├── PerspectiveCamera.h ├── PositioningLayout.h ├── RelativeIHudDrawable.h ├── Renderer.h ├── ResourceManager.h ├── Scene.h ├── ShaderProgram.h ├── SkyBoxRenderer.h ├── Sphere.h ├── StandardRenderer.h ├── StdOutLogHandler.h ├── TextLayout.h ├── TextObject.h ├── Texture.h ├── Triangle.h ├── Utils.h ├── Wind.h ├── WindAffection.h ├── Window.h ├── constants.h ├── freetype │ ├── config │ │ ├── ftconfig.h │ │ ├── ftheader.h │ │ ├── ftmodule.h │ │ ├── ftoption.h │ │ └── ftstdlib.h │ ├── freetype.h │ ├── ftadvanc.h │ ├── ftautoh.h │ ├── ftbbox.h │ ├── ftbdf.h │ ├── ftbitmap.h │ ├── ftbzip2.h │ ├── ftcache.h │ ├── ftcffdrv.h │ ├── ftchapters.h │ ├── ftcid.h │ ├── fterrdef.h │ ├── fterrors.h │ ├── ftfntfmt.h │ ├── ftgasp.h │ ├── ftglyph.h │ ├── ftgxval.h │ ├── ftgzip.h │ ├── ftimage.h │ ├── ftincrem.h │ ├── ftlcdfil.h │ ├── ftlist.h │ ├── ftlzw.h │ ├── ftmac.h │ ├── ftmm.h │ ├── ftmodapi.h │ ├── ftmoderr.h │ ├── ftotval.h │ ├── ftoutln.h │ ├── ftpfr.h │ ├── ftrender.h │ ├── ftsizes.h │ ├── ftsnames.h │ ├── ftstroke.h │ ├── ftsynth.h │ ├── ftsystem.h │ ├── fttrigon.h │ ├── ftttdrv.h │ ├── fttypes.h │ ├── ftwinfnt.h │ ├── internal │ │ ├── autohint.h │ │ ├── ftcalc.h │ │ ├── ftdebug.h │ │ ├── ftdriver.h │ │ ├── ftgloadr.h │ │ ├── fthash.h │ │ ├── ftmemory.h │ │ ├── ftobjs.h │ │ ├── ftpic.h │ │ ├── ftrfork.h │ │ ├── ftserv.h │ │ ├── ftstream.h │ │ ├── fttrace.h │ │ ├── ftvalid.h │ │ ├── internal.h │ │ ├── psaux.h │ │ ├── pshints.h │ │ ├── services │ │ │ ├── svbdf.h │ │ │ ├── svcid.h │ │ │ ├── svfntfmt.h │ │ │ ├── svgldict.h │ │ │ ├── svgxval.h │ │ │ ├── svkern.h │ │ │ ├── svmm.h │ │ │ ├── svotval.h │ │ │ ├── svpfr.h │ │ │ ├── svpostnm.h │ │ │ ├── svprop.h │ │ │ ├── svpscmap.h │ │ │ ├── svpsinfo.h │ │ │ ├── svsfnt.h │ │ │ ├── svttcmap.h │ │ │ ├── svtteng.h │ │ │ ├── svttglyf.h │ │ │ └── svwinfnt.h │ │ ├── sfnt.h │ │ ├── t1types.h │ │ └── tttypes.h │ ├── t1tables.h │ ├── ttnameid.h │ ├── tttables.h │ ├── tttags.h │ └── ttunpat.h ├── ft2build.h ├── glutil │ └── glutil.h ├── linmath │ ├── Common.h │ ├── Quaternion.h │ ├── SmallVector2.h │ ├── SmallVector2.inl │ ├── SmallVector3.h │ ├── SmallVector3.inl │ ├── SmallVector4.h │ ├── SmallVector4.inl │ ├── float2.h │ ├── float3.h │ ├── float3x3.h │ ├── float4.h │ ├── float4x4.h │ ├── int2.h │ ├── int3.h │ ├── int4.h │ └── inverse.h ├── rapidjson │ ├── allocators.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ │ ├── en.h │ │ └── error.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── internal │ │ ├── biginteger.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ ├── strtod.h │ │ └── swap.h │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ ├── pointer.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── stringbuffer.h │ └── writer.h ├── stb_image.h └── timer.h ├── lib ├── DevIL.lib ├── FreeImage.dll ├── FreeImage.lib ├── GL │ ├── freeglut.h │ ├── freeglut_ext.h │ ├── freeglut_std.h │ ├── glew.h │ ├── glut.h │ ├── glxew.h │ └── wglew.h ├── IL │ ├── DevIL.lib │ ├── ILU.lib │ ├── ILUT.lib │ ├── config.h │ ├── config.h.win │ ├── devil_internal_exports.h │ ├── il.h │ ├── il_wrap.h │ ├── ilu.h │ ├── ilu_region.h │ ├── ilut.h │ └── ilut_config.h ├── ILU.lib ├── ILUT.lib ├── OpenAL32.lib ├── README.md ├── SFML │ ├── Audio.hpp │ ├── Audio │ │ ├── AlResource.hpp │ │ ├── Export.hpp │ │ ├── InputSoundFile.hpp │ │ ├── Listener.hpp │ │ ├── Music.hpp │ │ ├── OutputSoundFile.hpp │ │ ├── Sound.hpp │ │ ├── SoundBuffer.hpp │ │ ├── SoundBufferRecorder.hpp │ │ ├── SoundFileFactory.hpp │ │ ├── SoundFileFactory.inl │ │ ├── SoundFileReader.hpp │ │ ├── SoundFileWriter.hpp │ │ ├── SoundRecorder.hpp │ │ ├── SoundSource.hpp │ │ └── SoundStream.hpp │ ├── Config.hpp │ ├── Graphics.hpp │ ├── Graphics │ │ ├── BlendMode.hpp │ │ ├── CircleShape.hpp │ │ ├── Color.hpp │ │ ├── ConvexShape.hpp │ │ ├── Drawable.hpp │ │ ├── Export.hpp │ │ ├── Font.hpp │ │ ├── Glyph.hpp │ │ ├── Image.hpp │ │ ├── PrimitiveType.hpp │ │ ├── Rect.hpp │ │ ├── Rect.inl │ │ ├── RectangleShape.hpp │ │ ├── RenderStates.hpp │ │ ├── RenderTarget.hpp │ │ ├── RenderTexture.hpp │ │ ├── RenderWindow.hpp │ │ ├── Shader.hpp │ │ ├── Shape.hpp │ │ ├── Sprite.hpp │ │ ├── Text.hpp │ │ ├── Texture.hpp │ │ ├── Transform.hpp │ │ ├── Transformable.hpp │ │ ├── Vertex.hpp │ │ ├── VertexArray.hpp │ │ └── View.hpp │ ├── Main.hpp │ ├── Network.hpp │ ├── Network │ │ ├── Export.hpp │ │ ├── Ftp.hpp │ │ ├── Http.hpp │ │ ├── IpAddress.hpp │ │ ├── Packet.hpp │ │ ├── Socket.hpp │ │ ├── SocketHandle.hpp │ │ ├── SocketSelector.hpp │ │ ├── TcpListener.hpp │ │ ├── TcpSocket.hpp │ │ └── UdpSocket.hpp │ ├── OpenGL.hpp │ ├── System.hpp │ ├── System │ │ ├── Clock.hpp │ │ ├── Err.hpp │ │ ├── Export.hpp │ │ ├── FileInputStream.hpp │ │ ├── InputStream.hpp │ │ ├── Lock.hpp │ │ ├── MemoryInputStream.hpp │ │ ├── Mutex.hpp │ │ ├── NonCopyable.hpp │ │ ├── Sleep.hpp │ │ ├── String.hpp │ │ ├── String.inl │ │ ├── Thread.hpp │ │ ├── Thread.inl │ │ ├── ThreadLocal.hpp │ │ ├── ThreadLocalPtr.hpp │ │ ├── ThreadLocalPtr.inl │ │ ├── Time.hpp │ │ ├── Utf.hpp │ │ ├── Utf.inl │ │ ├── Vector2.hpp │ │ ├── Vector2.inl │ │ ├── Vector3.hpp │ │ └── Vector3.inl │ ├── Window.hpp │ └── Window │ │ ├── Context.hpp │ │ ├── ContextSettings.hpp │ │ ├── Event.hpp │ │ ├── Export.hpp │ │ ├── GlResource.hpp │ │ ├── Joystick.hpp │ │ ├── Keyboard.hpp │ │ ├── Mouse.hpp │ │ ├── Sensor.hpp │ │ ├── Touch.hpp │ │ ├── VideoMode.hpp │ │ ├── Window.hpp │ │ ├── WindowHandle.hpp │ │ └── WindowStyle.hpp ├── assimp.lib ├── assimp │ ├── Compiler │ │ ├── poppack1.h │ │ └── pushpack1.h │ ├── DefaultLogger.hpp │ ├── Exporter.hpp │ ├── IOStream.hpp │ ├── IOSystem.hpp │ ├── Importer.hpp │ ├── LogStream.hpp │ ├── Logger.hpp │ ├── NullLogger.hpp │ ├── ProgressHandler.hpp │ ├── ai_assert.h │ ├── anim.h │ ├── camera.h │ ├── cexport.h │ ├── cfileio.h │ ├── cimport.h │ ├── color4.h │ ├── color4.inl │ ├── config.h │ ├── defs.h │ ├── importerdesc.h │ ├── light.h │ ├── material.h │ ├── material.inl │ ├── matrix3x3.h │ ├── matrix3x3.inl │ ├── matrix4x4.h │ ├── matrix4x4.inl │ ├── mesh.h │ ├── postprocess.h │ ├── quaternion.h │ ├── quaternion.inl │ ├── scene.h │ ├── texture.h │ ├── types.h │ ├── vector2.h │ ├── vector2.inl │ ├── vector3.h │ ├── vector3.inl │ └── version.h ├── catch.hpp ├── freeglutd.lib ├── freeimage │ └── FreeImage.h ├── freetype.lib ├── glew32.lib ├── glew32s.lib ├── lib.rar ├── libsfml-audio.so ├── libsfml-audio.so.2.3 ├── libsfml-audio.so.2.3.2 ├── libsfml-graphics.so ├── libsfml-graphics.so.2.3 ├── libsfml-graphics.so.2.3.2 ├── libsfml-network.so ├── libsfml-network.so.2.3 ├── libsfml-network.so.2.3.2 ├── libsfml-system.so ├── libsfml-system.so.2.3 ├── libsfml-system.so.2.3.2 ├── libsfml-window.so ├── libsfml-window.so.2.3 ├── libsfml-window.so.2.3.2 ├── sfml-audio-d.lib ├── sfml-audio-s-d.lib ├── sfml-audio-s.lib ├── sfml-audio.lib ├── sfml-system-d.lib ├── sfml-system-s-d.lib ├── sfml-system-s.lib ├── sfml-system.lib ├── sfml-window-d-2.lib ├── sfml-window-s-d.lib ├── sfml-window-s.lib └── sfml-window.lib ├── publish_docs.sh ├── shaders ├── cutoff.frag ├── emissive.frag ├── emissive.vert ├── horizontal_blur.frag ├── hud.frag ├── hud.vert ├── particle.frag ├── particle.vert ├── postFx.frag ├── postFx.vert ├── shadowMap.frag ├── shadowMap.vert ├── simple.frag ├── simple.vert ├── skybox.frag ├── skybox.vert └── vertical_blur.frag ├── src ├── CMakeLists.txt ├── Input │ ├── CMakeLists.txt │ ├── ControlStatus.cpp │ ├── ControlsManager.cpp │ ├── Input.cpp │ ├── JoystickAxis.cpp │ ├── JoystickButton.cpp │ ├── JoystickTranslation.cpp │ ├── JoystickTranslator.cpp │ ├── KeyboardButton.cpp │ ├── MouseAxis.cpp │ ├── MouseButton.cpp │ ├── MousePosition.cpp │ └── MouseWarp.cpp ├── Misc │ ├── CMakeLists.txt │ ├── CubeMapTexture.cpp │ ├── FileWatcher.cpp │ ├── FileWatcher.h │ └── ResourceManager.cpp ├── cameras │ ├── CMakeLists.txt │ ├── Camera.cpp │ └── PerspectiveCamera.cpp ├── collision │ ├── BFBroadPhase.cpp │ ├── BFBroadPhase.h │ ├── CMakeLists.txt │ ├── Collider.cpp │ ├── ColliderFactory.cpp │ ├── ExactOctreeCollider.cpp │ ├── ExactOctreeCollider.h │ ├── Octree.cpp │ ├── TwoPhaseCollider.cpp │ └── TwoPhaseCollider.h ├── common │ ├── CMakeLists.txt │ ├── Timer.cpp │ └── Utils.cpp ├── components │ ├── CMakeLists.txt │ ├── MoveComponent.cpp │ └── StandardRenderer.cpp ├── core │ ├── CMakeLists.txt │ ├── Globals.cpp │ ├── Renderer.cpp │ └── Window.cpp ├── glutil │ ├── CMakeLists.txt │ └── glutil.cpp ├── linmath │ ├── CMakeLists.txt │ ├── Quaternion.cpp │ ├── float2.cpp │ ├── float3.cpp │ ├── float3x3.cpp │ ├── float4.cpp │ ├── float4x4.cpp │ ├── int2.cpp │ ├── int3.cpp │ └── int4.cpp ├── logging │ ├── CMakeLists.txt │ └── Logger.cpp ├── objects │ ├── BoneInfluenceOnVertex.cpp │ ├── BoneInfluenceOnVertex.h │ ├── BoneTransformer.cpp │ ├── BoneTransformer.h │ ├── CMakeLists.txt │ ├── Chunk.cpp │ ├── Chunk.h │ ├── GameObject.cpp │ ├── ImageTexture.cpp │ ├── Mesh.cpp │ ├── Scene.cpp │ ├── SkyBoxRenderer.cpp │ ├── Texture.cpp │ ├── Triangle.cpp │ ├── Wind.cpp │ └── WindAffection.cpp ├── particle │ ├── CMakeLists.txt │ ├── Particle.cpp │ ├── Particle.h │ ├── ParticleGenerator.cpp │ └── ParticleRenderer.cpp ├── shader │ ├── CMakeLists.txt │ ├── FragmentShader.cpp │ ├── FragmentShader.h │ ├── ShaderProgram.cpp │ ├── VertexShader.cpp │ └── VertexShader.h └── userInterface │ ├── CMakeLists.txt │ ├── Dimension.cpp │ ├── Font.cpp │ ├── FontManager.cpp │ ├── GLSquare.cpp │ ├── HUDGraphic.cpp │ ├── HudRenderer.cpp │ ├── IHudDrawable.cpp │ ├── InsideChecker.h │ ├── InsideRoundedSquareChecker.cpp │ ├── InsideRoundedSquareChecker.h │ ├── InsideSquareChecker.cpp │ ├── InsideSquareChecker.h │ ├── Layout.cpp │ ├── ListLayout.cpp │ ├── PositioningLayout.cpp │ ├── RelativeIHudDrawable.cpp │ ├── TextLayout.cpp │ └── TextObject.cpp └── test ├── CMakeLists.txt ├── collider_test.cpp ├── is_inside_test.cpp ├── octree_test.cpp └── skeletalAnimationTests.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/* 2 | /build/* 3 | /Release/* 4 | /Testing/* 5 | /docs/* 6 | Thumbs.db 7 | *~ 8 | .idea 9 | *.swo 10 | *.swp 11 | 12 | *.blender 13 | *.blender1 14 | 15 | doxygen.conf 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: 3 | - gcc 4 | 5 | sudo: required 6 | dist: trusty 7 | 8 | install: 9 | - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi 10 | 11 | addons: 12 | apt: 13 | sources: 14 | - ubuntu-toolchain-r-test 15 | - george-edison55-precise-backports 16 | 17 | packages: 18 | - cmake-data 19 | - gcc-4.9 20 | - g++-4.9 21 | - cmake 22 | - freeglut3-dev 23 | - libfreeimage3 24 | - libfreeimage-dev 25 | - libassimp-dev 26 | - libglew-dev 27 | - libxmu-dev 28 | - libxi-dev 29 | - libopenal1 30 | - libopenal-dev 31 | - libalut0 32 | - libalut-dev 33 | - libvorbis-dev 34 | - libjpeg-dev 35 | - libfreetype6-dev 36 | - libxrandr-dev 37 | - libglew-dev 38 | - libsndfile1-dev 39 | - libudev-dev 40 | - libxcb-image0 41 | - libxcb-randr0 42 | - libudev-dev 43 | - build-essential 44 | - libcgmanager-dev 45 | - libudev1 46 | 47 | 48 | 49 | 50 | before_script: 51 | - mkdir -p build 52 | - cd build 53 | - cmake -DCMAKE_BUILD_TYPE:STRING=Debug -Wdev -Werror=dev -D CMAKE_CXX_FLAGS="-Werror" .. 54 | 55 | 56 | script: make -j8 all && make test 57 | 58 | after_success: 59 | - cd ../ 60 | - ./publish_docs.sh 61 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | # Project Name 3 | PROJECT(Bubba-3D) 4 | 5 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/") 6 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/") 7 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") 8 | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") 10 | 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLEW_STATIC") 13 | 14 | if (CMAKE_COMPILER_IS_GNUCXX) 15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLEW_STATIC") 17 | endif() 18 | 19 | 20 | ######################################################### 21 | # Testing 22 | ######################################################### 23 | include_directories(src) 24 | add_subdirectory (src) 25 | include(CTest) 26 | add_subdirectory(test) 27 | 28 | 29 | ######################################################### 30 | # Docs 31 | ######################################################### 32 | find_package(Doxygen) 33 | option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" 34 | ${DOXYGEN_FOUND}) 35 | 36 | if(BUILD_DOCUMENTATION) 37 | if(NOT DOXYGEN_FOUND) 38 | message(FATAL_ERROR "Doxygen is needed to build the documentation.") 39 | endif() 40 | 41 | set(doxyfile_in ${PROJECT_SOURCE_DIR}/doxygen.conf.in) 42 | set(doxyfile ${PROJECT_SOURCE_DIR}/doxygen.conf) 43 | set(GENERATE_HTML YES) 44 | set(GENERATE_LATEX NO) 45 | 46 | configure_file(${doxyfile_in} ${doxyfile}) 47 | 48 | message("Doxygen build started.") 49 | 50 | add_custom_target(doc ALL 51 | COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} 52 | WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} 53 | COMMENT "Generating API documentation with Doxygen" 54 | VERBATIM) 55 | 56 | # install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc) 57 | endif() 58 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | COMPILESTRING = mkdir -p build;cd build;cmake -DCMAKE_BUILD_TYPE:STRING=Debug ..;make -j16; 2 | 3 | all: 4 | $(COMPILESTRING) 5 | 6 | tests: $(all) 7 | $(COMPILESTRING) ctest; 8 | 9 | testsX: $(all) 10 | $(COMPILESTRING) ctest -V; 11 | 12 | 13 | clean: 14 | rm -rf build; 15 | 16 | install: 17 | -sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y 18 | -sudo add-apt-repository ppa:george-edison55/cmake-3.x -y 19 | -sudo apt-get update 20 | -sudo apt-get install gcc-4.9 g++-4.9 -y 21 | -sudo apt-get install freeglut3-dev libjpeg-dev libfreetype6-dev libxrandr-dev libglew-dev libsndfile1-dev libopenal-dev libudev-dev -y 22 | -sudo apt-get install software-properties-common libfreeimage3 libfreeimage-dev libassimp-dev libglw1-mesa-dev libglew-dev libxmu-dev libxi-dev -y 23 | -sudo apt-get install cmake -y 24 | -sudo apt-get install libsfml-dev libcsfml-dev 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bubba-3D [![Build Status](https://travis-ci.org/Bubbers/Bubba-3D.svg?branch=master)](https://travis-ci.org/Bubbers/Bubba-3D) !['LGPL3'](https://www.gnu.org/graphics/lgplv3-88x31.png) 2 | ======= 3 | 4 | About 5 | ----- 6 | This is a small 3D Game-Engine programmed in C++ using openGL. 7 | Originally implemented as a school project, now extended for fun! 8 | 9 | Usage 10 | ----- 11 | Tutorials can be found on the [wiki](https://github.com/Bubbers/Bubba-3D/wiki) 12 | 13 | How the various classes work can be found in the 14 | [API documentation](http://bubbers.github.io/Bubba-3D/) 15 | 16 | Installation 17 | ------------ 18 | ### Requirements: 19 | * [CMake](http://www.cmake.org/) 20 | * [Assimp](https://github.com/assimp/assimp) 21 | * [GLEW](https://github.com/nigels-com/glew) 22 | * [SFML](http://www.sfml-dev.org/index.php) 23 | * [Freetype](http://www.freetype.org/) 24 | 25 | #### Installing dependencies 26 | See [wiki](https://github.com/Bubbers/Bubba-3D/wiki) 27 | 28 | ### Compile using cmake: 29 | ```bash 30 | mkdir build 31 | cd build 32 | cmake .. 33 | make 34 | ``` 35 | -------------------------------------------------------------------------------- /cmake/Modules/CMakeParseArguments.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # CMakeParseArguments 3 | # ------------------- 4 | # 5 | # This module once implemented the :command:`cmake_parse_arguments` command 6 | # that is now implemented natively by CMake. It is now an empty placeholder 7 | # for compatibility with projects that include it to get the command from 8 | # CMake 3.4 and lower. 9 | 10 | #============================================================================= 11 | # Copyright 2010 Alexander Neundorf 12 | # 13 | # Distributed under the OSI-approved BSD License (the "License"); 14 | # see accompanying file Copyright.txt for details. 15 | # 16 | # This software is distributed WITHOUT ANY WARRANTY; without even the 17 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | # See the License for more information. 19 | #============================================================================= 20 | # (To distribute this file outside of CMake, substitute the full 21 | # License text for the above reference.) 22 | -------------------------------------------------------------------------------- /cmake/Modules/FindASSIMP.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Assimp 2 | # Once done, this will define 3 | # 4 | # ASSIMP_FOUND - system has Assimp 5 | # ASSIMP_INCLUDE_DIR - the Assimp include directories 6 | # ASSIMP_LIBRARIES - link these to use Assimp 7 | 8 | #FIND_PATH( ASSIMP_INCLUDE_DIR assimp/mesh.h 9 | # /usr/include 10 | # /usr/local/include 11 | # /opt/local/include 12 | # /sw/include 13 | # ) 14 | 15 | FIND_LIBRARY( ASSIMP_LIBRARY assimp libassimp 16 | /usr/lib64 17 | /usr/lib 18 | /usr/lib/x86_64-linux-gnu 19 | /usr/local/lib 20 | /opt/local/lib 21 | /usr/local/lib64 22 | /usr/local/lib 23 | /sw/lib 24 | ) 25 | 26 | 27 | FIND_PATH(ASSIMP_INCLUDE_DIR assimp/ai_assert.h 28 | $ENV{ASSIMPSDIR}/include 29 | $ENV{ASSIMPSDIR} 30 | $ENV{ASSIMPSDIR}/.. 31 | ~/Library/Frameworks/AssImp.framework/Headers 32 | /Library/Frameworks/AssImp.framework/Headers 33 | /usr/local/include/assimp 34 | /usr/local/include 35 | /usr/include/assimp 36 | /home/travis 37 | /home/travis/build/Bubbers/Bubba-3D/lib 38 | /usr/include 39 | /sw/include/assimp # Fink 40 | /sw/include 41 | /opt/local/include/assimp # DarwinPorts 42 | /opt/local/include 43 | /opt/csw/include/assimp # Blastwave 44 | /opt/csw/include 45 | /opt/include/assimp 46 | /opt/include 47 | ${_assimp_INCLUDE_SEARCH_DIRS_SYSTEM} 48 | ) 49 | 50 | IF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) 51 | SET( ASSIMP_FOUND TRUE ) 52 | SET( ASSIMP_LIBRARIES ${ASSIMP_LIBRARY} ) 53 | ENDIF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) 54 | 55 | IF(ASSIMP_FOUND) 56 | IF(NOT ASSIMP_FIND_QUIETLY) 57 | MESSAGE(STATUS "Found ASSIMP: ${ASSIMP_LIBRARY}") 58 | ENDIF(NOT ASSIMP_FIND_QUIETLY) 59 | ELSE(ASSIMP_FOUND) 60 | IF(ASSIMP_FIND_REQUIRED) 61 | MESSAGE(FATAL_ERROR "Could not find libASSIMP") 62 | ENDIF(ASSIMP_FIND_REQUIRED) 63 | ENDIF(ASSIMP_FOUND) -------------------------------------------------------------------------------- /deploy_key.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/deploy_key.enc -------------------------------------------------------------------------------- /hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Running prepush script" 4 | BRANCH=`git name-rev --name-only HEAD` 5 | if [ "$BRANCH" == "develop" ] || [ "$BRANCH" == "master" ]; then 6 | echo $1 7 | echo $2 8 | 9 | make 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /hooks/setup_hooks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import shutil 5 | import argparse 6 | 7 | HOOKS_PATH = os.path.dirname(os.path.abspath(__file__)) 8 | 9 | def parse(): 10 | parser = argparse.ArgumentParser() 11 | parser.add_argument("--clean", action="store_true", help="Remove hooks") 12 | args = parser.parse_args() 13 | 14 | git_folder = os.path.join("..",".git") 15 | 16 | if not os.path.isdir(git_folder): 17 | with open(git_folder) as f: 18 | line = f.readline() 19 | line = line.split(" ") 20 | git_folder = os.path.join("..", line[1][:-1]) 21 | 22 | git_folder = os.path.join(git_folder, "hooks") 23 | 24 | if args.clean: 25 | clean(git_folder) 26 | else: 27 | setup_hooks(git_folder) 28 | 29 | def setup_hooks(git_folder): 30 | for hook in os.listdir(HOOKS_PATH): 31 | if hook not in __file__: 32 | shutil.copy("{}/{}".format(HOOKS_PATH, hook), os.path.join(git_folder, hook)) 33 | 34 | def clean(git_folder): 35 | for hook in os.listdir(HOOKS_PATH): 36 | if hook not in __file__: 37 | os.remove(os.path.join(git_folder, hook)) 38 | 39 | if __name__ == "__main__": 40 | parse() 41 | -------------------------------------------------------------------------------- /includes/AABB2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #ifndef __AABB_H__ 18 | #define __AABB_H__ 19 | 20 | #include 21 | #include 22 | 23 | struct AABB { 24 | chag::float3 maxV; 25 | chag::float3 minV; 26 | 27 | AABB() { 28 | maxV = chag::make_vector(-FLT_MAX, -FLT_MAX, -FLT_MAX); 29 | minV = chag::make_vector(FLT_MAX, FLT_MAX, FLT_MAX); 30 | } 31 | 32 | float getSize() { 33 | return sqrtf(pow(maxV.x - minV.x,2) + pow(maxV.y - minV.y,2) + pow(maxV.z - minV.z,2)); 34 | } 35 | 36 | chag::float3 getCenterPosition() { 37 | return (maxV - minV) / 2; 38 | } 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /includes/BoneMatrices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "linmath/float4x4.h" 20 | 21 | /** 22 | * Struct for containing different matrices related to a bone. 23 | * Used for transforming vertices connected to a bone. 24 | */ 25 | struct BoneMatrices 26 | { 27 | //BoneOffset transforms a vertex from local space to bone space 28 | chag::float4x4 boneOffset = chag::make_identity(); 29 | //finalTransformation transforms a vertex connected to the bone in bone space to its new position relative the bone. 30 | chag::float4x4 finalTransformation = chag::make_identity(); 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /includes/BroadPhaseCollider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2015-12-05. 19 | // 20 | 21 | #ifndef BUBBA_3D_BROADPHASE_H 22 | #define BUBBA_3D_BROADPHASE_H 23 | 24 | #include 25 | #include "Utils.h" 26 | #include "Scene.h" 27 | 28 | class GameObject; 29 | 30 | /** 31 | * The broad phase collider performs fast and inaccurate (many false positives, no false negatives) 32 | * collision detections. A more exact collision test should be performed after. 33 | */ 34 | class BroadPhaseCollider { 35 | public: 36 | /** 37 | * Returns a list of possibly colliding pairs 38 | */ 39 | virtual CollisionPairList computeCollisionPairs(Scene *scene) = 0; 40 | 41 | 42 | }; 43 | #endif //BUBBA_3D_BROADPHASE_H 44 | -------------------------------------------------------------------------------- /includes/Camera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include "IComponent.h" 22 | 23 | /** 24 | * Interface for manipulating a camera 25 | */ 26 | class Camera : public IComponent{ 27 | public: 28 | Camera(chag::float3 position, chag::float3 lookAt, 29 | chag::float3 up, float fov, float ratio, 30 | float nearPlane, float farPlane): 31 | m_vPosition(position), m_vLookAt(lookAt), m_vUp(up), m_fFov(fov), 32 | m_fRatio(ratio), m_fNearPlane(nearPlane), m_fFarPlane(farPlane) 33 | { 34 | } 35 | 36 | ~Camera() = default; 37 | 38 | virtual void update(float dt) = 0; 39 | virtual chag::float4x4 getViewMatrix() = 0; 40 | virtual chag::float4x4 getProjectionMatrix() = 0; 41 | 42 | virtual void setPosition(chag::float3 position); 43 | virtual void setLookAt(chag::float3 lookAt); 44 | virtual void setUpVector(chag::float3 up); 45 | chag::float3 getPosition() { return m_vPosition; }; 46 | chag::float3 getLookAt() { return m_vLookAt; }; 47 | chag::float3 getUp() { return m_vUp; }; 48 | 49 | protected: 50 | chag::float3 m_vPosition; 51 | chag::float3 m_vLookAt; 52 | chag::float3 m_vUp; 53 | float m_fFov = 60.0f; 54 | float m_fRatio = 1.0f; 55 | float m_fNearPlane = 0.1f; 56 | float m_fFarPlane = 100.0f; 57 | }; 58 | -------------------------------------------------------------------------------- /includes/ColliderFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-04-13. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_COLLIDERFACTORY_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_COLLIDERFACTORY_H 23 | 24 | #include "Collider.h" 25 | 26 | /** 27 | * Class responsible for creating colliders 28 | */ 29 | class ColliderFactory { 30 | public: 31 | /** 32 | * Retuns a two phase collider. The first phase will be a fast, inaccurate test and 33 | * the second phase will be a exact test. 34 | */ 35 | static Collider* getTwoPhaseCollider(); 36 | }; 37 | 38 | #endif //SUPER_BUBBA_AWESOME_SPACE_COLLIDERFACTORY_H 39 | -------------------------------------------------------------------------------- /includes/Controls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #ifndef BUBBA_3D_CONTROLS_ENUM_H 19 | #define BUBBA_3D_CONTROLS_ENUM_H 20 | 21 | /** 22 | * The functions used to bind the controls in main() 23 | */ 24 | enum Controls {ACCELERATE,TURN,ALTITUDE,SHOOT,QUIT, CONTINUE}; 25 | 26 | #endif -------------------------------------------------------------------------------- /includes/CubeMapTexture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | class CubeMapTexture 23 | { 24 | public: 25 | CubeMapTexture(const std::string& posXFilename, const std::string& negXFilename, 26 | const std::string& posYFilename, const std::string& negYFilename, 27 | const std::string& posZFilename, const std::string& negZFilename); 28 | 29 | ~CubeMapTexture(); 30 | 31 | void load(); 32 | void bind(GLenum textureUnit); 33 | 34 | private: 35 | GLuint m_texture; 36 | 37 | void loadCubeMapFace(std::string filename, GLenum face); 38 | }; 39 | -------------------------------------------------------------------------------- /includes/DestructorUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #ifndef BUBBA_3D_DESTRUCTOR_UTILS_H 18 | #define BUBBA_3D_DESTRUCTOR_UTILS_H 19 | 20 | 21 | #include 22 | 23 | template 24 | void deleteLoop(std::vector *v) { 25 | for (size_t n = 0; n < v->size(); ++n) 26 | { 27 | delete &(v[n]); 28 | } 29 | delete v; 30 | } 31 | #endif //BUBBA_3D_DESTRUCTOR_UTILS_H 32 | -------------------------------------------------------------------------------- /includes/Effects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "linmath/float3.h" 20 | 21 | namespace FOG_EQ { 22 | enum fog_equation { 23 | LINEAR = 0, 24 | EXP = 1, 25 | EXP2 = 2, 26 | NONE = 3 27 | }; 28 | }; 29 | 30 | 31 | struct Fog { 32 | float fDensity; 33 | float fStart; 34 | float fEnd; 35 | chag::float3 vColor; 36 | FOG_EQ::fog_equation fEquation; 37 | 38 | Fog() { 39 | fDensity = 0.001f; 40 | fStart = 50.0f; 41 | fEnd = 900.0f; 42 | vColor = chag::make_vector(1.0f, 1.0f, 1.0f); 43 | fEquation = FOG_EQ::NONE; 44 | } 45 | }; 46 | 47 | struct Blur { 48 | float cutOff; 49 | bool active; 50 | 51 | Blur() { 52 | cutOff = 1.0f; 53 | active = true; 54 | } 55 | }; 56 | 57 | struct Bloom { 58 | bool active; 59 | 60 | Bloom(){ 61 | active = true; 62 | } 63 | }; 64 | 65 | 66 | struct Effects { 67 | Fog fog; 68 | Blur blur; 69 | Bloom bloom; 70 | }; 71 | -------------------------------------------------------------------------------- /includes/ExactPhaseCollider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-04-13. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_EXACTPHASE_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_EXACTPHASE_H 23 | 24 | #include "Utils.h" 25 | 26 | /** 27 | * The exact phase collider is responsible for performing 28 | * exact collision tests. 29 | */ 30 | class ExactPhaseCollider { 31 | public: 32 | /** 33 | * Takes a list of possibly colliding pairs and performs exact collision 34 | * tests between them. 35 | * 36 | */ 37 | virtual CollisionPairList computeExactCollision(CollisionPairList possibleCollision) = 0; 38 | 39 | }; 40 | 41 | #endif //SUPER_BUBBA_AWESOME_SPACE_EXACTPHASE_H 42 | -------------------------------------------------------------------------------- /includes/FileLogHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "LogHandler.h" 21 | #include 22 | #include 23 | 24 | class FileLogHandler : public LogHandler { 25 | public: 26 | FileLogHandler(std::string fileName) { 27 | logFile.open(fileName.c_str()); 28 | }; 29 | ~FileLogHandler() { 30 | logFile.close(); 31 | }; 32 | 33 | virtual void log(std::string msg) { 34 | logFile << msg; 35 | }; 36 | 37 | private: 38 | ofstream logFile; 39 | }; 40 | -------------------------------------------------------------------------------- /includes/Font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | #include 19 | #include FT_FREETYPE_H 20 | 21 | 22 | /** 23 | * A class that contains data about the characters of a font. 24 | * Load a font using FontManager. TextObject can render text 25 | * using a Font. 26 | */ 27 | class Font { 28 | public: 29 | 30 | struct GlyphData{ 31 | int advanceX; // advance.x 32 | int advanceY; // advance.y 33 | 34 | int bitmapWidth; // bitmap.width; 35 | int bitmapHeight; // bitmap.rows; 36 | 37 | int bitmapLeft; // bitmap_left; 38 | int bitmapTop; // bitmap_top; 39 | 40 | int offsetX; // x offset of glyph in texture coordinates 41 | GlyphData(int offsetX, FT_GlyphSlot ft_glyphSlot); 42 | GlyphData(){} 43 | }; 44 | 45 | GlyphData getCharacter(unsigned char character); 46 | Font(int pixelSize); 47 | void addGlyph(FT_GlyphSlot glyph, int offsetX, unsigned char character); 48 | 49 | int getPixelSize(); 50 | 51 | private: 52 | void checkInvalidCharacter(unsigned char character); 53 | GlyphData glyphs[128-32]; 54 | int pixelSize = 0; 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /includes/Globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-01-09. 19 | // 20 | 21 | #ifndef BUBBA_3D_GLOBALS_H 22 | #define BUBBA_3D_GLOBALS_H 23 | 24 | class Globals{ 25 | public: 26 | enum Key { WINDOW_HEIGHT=0, WINDOW_WIDTH=1,MOUSE_WINDOW_X=2,MOUSE_WINDOW_Y=3, FONT_TEXTURE_WIDTH=4, FONT_TEXTURE_HEIGHT=5}; 27 | static void set(Key key, int value); 28 | static int get(Key key); 29 | 30 | private: 31 | static int masterFunc(Key key, int value, bool getElseSet); 32 | 33 | }; 34 | 35 | #endif //BUBBA_3D_GLOBALS_H 36 | -------------------------------------------------------------------------------- /includes/IComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #ifndef BUBBA_3D_COMPONENT_H 19 | #define BUBBA_3D_COMPONENT_H 20 | 21 | #include 22 | 23 | class GameObject; 24 | 25 | class IComponent { 26 | public: 27 | virtual void update(float dt) = 0; 28 | void bind(std::weak_ptr owner) { this->owner = owner; }; 29 | 30 | virtual void beforeCollision(std::shared_ptr collider) {}; 31 | virtual void duringCollision(std::shared_ptr collider) {}; 32 | virtual void afterCollision(std::shared_ptr collider) {}; 33 | virtual void onDeath(){ }; 34 | protected: 35 | std::weak_ptr owner; 36 | }; 37 | 38 | #endif //BUBBA_3D_COMPONENT_H 39 | 40 | -------------------------------------------------------------------------------- /includes/IDrawable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | class ShaderProgram; 22 | 23 | class IDrawable { 24 | public: 25 | IDrawable() { shininess = 0.0f; }; 26 | 27 | virtual ~IDrawable(){}; 28 | 29 | virtual void render() = 0; 30 | virtual void renderShadow(std::shared_ptr &shaderProgram) = 0; 31 | virtual void renderEmissive(std::shared_ptr &shaderProgram) = 0; 32 | 33 | float shininess; 34 | }; 35 | -------------------------------------------------------------------------------- /includes/IHudDrawable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class ShaderProgram; 24 | 25 | /** 26 | * An interface for low-level objects used by HudRenderer to render the HUD. 27 | * Mainly produced by different implementations of Layout 28 | */ 29 | class IHudDrawable { 30 | public: 31 | virtual void render(std::shared_ptr shaderProgram, chag::float4x4* projectionMatrix) = 0; 32 | 33 | /** 34 | * Sets a position relative to the original position calculated 35 | * by Layout implementations. 36 | */ 37 | virtual void setRelativePosition(chag::float3 position); 38 | /** 39 | * Sets the rotation center offset. The original center is the actual center 40 | * of the drawn object. 41 | */ 42 | virtual void setCenterOffset(chag::float3 offset); 43 | virtual void setRotation(float rotation); 44 | virtual void setScale(chag::float2 scale); 45 | chag::float3 relativePosition = chag::make_vector(0.0f, 0.0f, 0.0f); 46 | 47 | protected: 48 | chag::float3 center = chag::make_vector(0.0f, 0.0f, 0.0f); 49 | float rotation = 0.0f; 50 | chag::float3 originalPosition = chag::make_vector(0.0f, 0.0f, 0.0f); 51 | chag::float3 scale = chag::make_vector(1.0f,1.0f,1.0f); 52 | }; 53 | -------------------------------------------------------------------------------- /includes/IJoystickTranslation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-01-15. 19 | // 20 | 21 | #ifndef BUBBA_3D_IJOYSTICKTRANSLATION_H 22 | #define BUBBA_3D_IJOYSTICKTRANSLATION_H 23 | 24 | class IJoystickTranslation{ 25 | public: 26 | enum Button : int {A,B,X,Y,LB,RB,START,BACK,GUIDE,LEFT_THUMBSTICK_PUSH,RIGHT_THUMBSTICK_PUSH}; 27 | enum Axis : int {LEFT_THUMBSTICK_X,LEFT_THUMBSTICK_Y,RIGHT_THUMBSTICK_X,RIGHT_THUMBSTICK_Y,DPAD_X,DPAD_Y,LT,RT}; 28 | 29 | virtual float getAxisValue(Axis axis) = 0; 30 | virtual float getButtonValue(Button button) = 0; 31 | virtual bool isDefaultMapping() = 0; 32 | 33 | }; 34 | 35 | #endif //BUBBA_3D_IJOYSTICKTRANSLATION_H 36 | -------------------------------------------------------------------------------- /includes/IMesh.h: -------------------------------------------------------------------------------- 1 | 2 | #include "Triangle.h" 3 | #include 4 | 5 | #ifndef HALLSOFBUBBA_IMESH_H 6 | #define HALLSOFBUBBA_IMESH_H 7 | 8 | #endif //HALLSOFBUBBA_IMESH_H 9 | 10 | class Chunk; 11 | 12 | class IMesh { 13 | public: 14 | /** 15 | * NOTE: The triangles have not been transformed. 16 | * 17 | * @return A list of all the triangles of the mesh. 18 | */ 19 | virtual std::vector getTriangles() = 0; 20 | 21 | /** 22 | * NOTE: The AABB has not been transformed. 23 | * 24 | * @return The AABB of the mesh. 25 | */ 26 | virtual AABB* getAABB() = 0; 27 | 28 | /** 29 | * NOTE: The sphere has not been transformed. 30 | * 31 | * @return The sphere surrounding the object. 32 | */ 33 | virtual Sphere getSphere() = 0; 34 | 35 | virtual std::vector* getChunks() = 0; 36 | virtual std::vector* getMaterials() = 0; 37 | 38 | virtual bool hasAnimations() = 0; 39 | 40 | /** 41 | * Calculates the transform to be applied to each bone at the current time. 42 | * 43 | * @param totalElapsedTimeInSeconds The time since the application was started 44 | * @return A vector containing the transforms of each bone. The index in the vector corresponds to the bones index. The index of a bone can be found in boneNameToIndexMapping. 45 | * 46 | */ 47 | virtual std::vector getBoneTransforms(float totalElapsedTimeInSeconds) = 0; 48 | }; -------------------------------------------------------------------------------- /includes/IRenderComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "IComponent.h" 20 | #include 21 | 22 | class ShaderProgram; 23 | 24 | class IRenderComponent : public IComponent { 25 | public: 26 | virtual void render() = 0; 27 | virtual void renderShadow(std::shared_ptr &shaderProgram) = 0; 28 | 29 | /** 30 | * Renders only the emissive colors of the object. Look at the implementation 31 | * of StandardRender::renderEmissive for implementation example. 32 | * 33 | * @param shaderProgram 34 | */ 35 | virtual void renderEmissive(std::shared_ptr &shaderProgram) = 0; 36 | 37 | protected: 38 | std::shared_ptr shaderProgram; 39 | 40 | }; 41 | -------------------------------------------------------------------------------- /includes/ImageTexture.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HALLSOFBUBBA_IMAGETEXTURE_H 3 | #define HALLSOFBUBBA_IMAGETEXTURE_H 4 | 5 | #endif //HALLSOFBUBBA_IMAGETEXTURE_H 6 | 7 | #include 8 | 9 | class ImageTexture: public Texture { 10 | public: 11 | ImageTexture(std::string fileName); 12 | 13 | void loadTexture() override; 14 | 15 | private: 16 | std::string fileName; 17 | }; -------------------------------------------------------------------------------- /includes/Input.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | /** 22 | * Base class for classes that supply the status 23 | * for bindings to InputManager. Any class that wants 24 | * to work as an input binding must extend this class. 25 | */ 26 | class Input { 27 | public: 28 | virtual ~Input() {}; 29 | virtual ControlStatus getStatus() = 0; 30 | virtual ControlStatus::Activator getActivator() = 0; 31 | bool isDual(); 32 | 33 | protected: 34 | Input(bool dual); 35 | bool dual; 36 | 37 | }; 38 | -------------------------------------------------------------------------------- /includes/JoystickButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-22. 19 | // 20 | 21 | #ifndef BUBBA_3D_JOYSTICKBUTTON_H 22 | #define BUBBA_3D_JOYSTICKBUTTON_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | * An input class for joystick buttons. 30 | */ 31 | class JoystickButton : public Input{ 32 | public: 33 | /** 34 | * Creates a non-dual button activated when button number \p button is pressed. 35 | */ 36 | JoystickButton(IJoystickTranslation::Button button); 37 | /** 38 | * Creates a dual button activated when either button is pressed. When \p neg is 39 | * pressed the ControlStatus value is -100, when \p pos is pressed the value is 100. If 40 | * both or none are pressed the value is 0. 41 | */ 42 | JoystickButton(IJoystickTranslation::Button pos, IJoystickTranslation::Button neg); 43 | ControlStatus getStatus(); 44 | ControlStatus::Activator getActivator(); 45 | 46 | private: 47 | IJoystickTranslation::Button joystickPos,joystickNeg; 48 | 49 | }; 50 | 51 | 52 | #endif //BUBBA_3D_JOYSTICKBUTTON_H 53 | -------------------------------------------------------------------------------- /includes/JoystickTranslator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class ControlStatus; 24 | 25 | class JoystickTranslator { 26 | 27 | public: 28 | IJoystickTranslation* getTranslation(unsigned int joystickID); 29 | 30 | static JoystickTranslator* getInstance(); 31 | 32 | void init(std::string filePath); 33 | void updateMapping(); 34 | 35 | virtual ~JoystickTranslator(); 36 | 37 | private: 38 | JoystickTranslator(); 39 | 40 | std::vector translations; 41 | 42 | 43 | void readDocument(rapidjson::Document *doc); 44 | void check(bool, std::string); 45 | int getJoystick(unsigned int devId, unsigned int vendId, unsigned int startAt); 46 | void readMappings(rapidjson::Value* mappings, unsigned int joystickID, bool defaultMapping); 47 | bool initiated = false; 48 | 49 | JoystickTranslation::valueRetriever decideOnButtonRetriever(rapidjson::Value* mapData); 50 | JoystickTranslation::valueRetriever decideOnAxisRetriever(rapidjson::Value* mapData, std::string axisName); 51 | 52 | rapidjson::Document *jsonConfig; 53 | 54 | static IJoystickTranslation::Button buttonFromString(std::string name); 55 | static IJoystickTranslation::Axis axisFromString(std::string name); 56 | static sf::Joystick::Axis SFMLAxisFromString(std::string name); 57 | }; 58 | -------------------------------------------------------------------------------- /includes/KeyboardButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-22. 19 | // 20 | 21 | #ifndef BUBBA_3D_KEYBOARDBUTTON_H 22 | #define BUBBA_3D_KEYBOARDBUTTON_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | * An Input class activated by keyboard buttons 30 | */ 31 | class KeyboardButton : public Input { 32 | public: 33 | /** 34 | * A non-dual input activated if \p key is pressed. 35 | */ 36 | KeyboardButton(sf::Keyboard::Key key); 37 | 38 | ~KeyboardButton() = default; 39 | /** 40 | * Creates a dual button activated when either key is pressed. When \p keyNeg is 41 | * pressed the ControlStatus value is -100, when ±p keyPos is pressed the value is 100. If 42 | * both or none are pressed the value is 0. 43 | */ 44 | KeyboardButton(sf::Keyboard::Key keyPos, sf::Keyboard::Key keyNeg); 45 | ControlStatus getStatus(); 46 | ControlStatus::Activator getActivator(); 47 | 48 | private: 49 | sf::Keyboard::Key keyPos,keyNeg; 50 | 51 | }; 52 | 53 | 54 | #endif //BUBBA_3D_KEYBOARDBUTTON_H 55 | -------------------------------------------------------------------------------- /includes/Lights.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | struct Light 22 | { 23 | chag::float3 ambientColor; 24 | chag::float3 diffuseColor; 25 | chag::float3 specularColor; 26 | 27 | Light() { 28 | ambientColor = chag::make_vector(0.0f, 0.0f, 0.0f); 29 | diffuseColor = chag::make_vector(0.0f, 0.0f, 0.0f); 30 | specularColor = chag::make_vector(0.0f, 0.0f, 0.0f); 31 | } 32 | }; 33 | 34 | struct Attenuation { 35 | float constant = 1.5f; 36 | float linear = 0.0f; 37 | float exp = 0.0f; 38 | }; 39 | 40 | struct DirectionalLight : public Light { 41 | chag::float3 direction; 42 | }; 43 | 44 | struct PointLight : public Light { 45 | chag::float3 position; 46 | Attenuation attenuation; 47 | }; 48 | 49 | struct SpotLight : public Light { 50 | chag::float3 direction; 51 | chag::float3 position; 52 | Attenuation attenuation; 53 | float cutOff; //cos(rads) of the wanted angle 54 | float outerCutOff; //used for smooth edges 55 | }; 56 | -------------------------------------------------------------------------------- /includes/ListLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | /** 22 | * A layout to create a list of other layouts. 23 | */ 24 | class ListLayout : public Layout { 25 | public: 26 | enum Orientation {HORIZONTAL,VERTICAL}; 27 | 28 | /** 29 | * The child of a wrapping layout can only use 30 | * Dimension::WRAP or Dimension::PIXELS 31 | */ 32 | virtual void addChild(Layout* child); 33 | 34 | virtual Dimension getWidth(); 35 | virtual Dimension getHeight(); 36 | 37 | /** 38 | * Creates a list where the children are placed after 39 | * each other in the specified \p orientation 40 | */ 41 | ListLayout(Orientation orientation, Dimension width, Dimension height); 42 | virtual ~ListLayout() = default; 43 | virtual void getGLSquares(float layoutXPos,float layoutYPos, float layoutWidth, 44 | float layoutHeight, std::map *map); 45 | 46 | protected: 47 | Orientation orientation; 48 | Dimension width,height; 49 | 50 | unsigned int wrapSize(Orientation orientation); 51 | void checkChildCompatibility(Layout* child); 52 | }; 53 | -------------------------------------------------------------------------------- /includes/LogHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | class LogHandler { 22 | public: 23 | LogHandler() = default; 24 | ~LogHandler() = default; 25 | 26 | virtual void log(std::string msg) = 0; 27 | }; 28 | -------------------------------------------------------------------------------- /includes/Logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include "LogHandler.h" 23 | 24 | enum LogLevel {DEBUG, INFO, WARNING, SEVERE}; 25 | 26 | class Logger 27 | { 28 | public: 29 | 30 | static void setDebug(bool debug); 31 | static void setFileSave(bool saveToFile); 32 | 33 | static void logDebug(std::string msg); 34 | static void logError(std::string msg); 35 | static void logWarning(std::string msg); 36 | static void logInfo(std::string msg); 37 | 38 | static void setLogLevel(unsigned int level); 39 | static void addLogHandler(LogHandler* logHandler); 40 | 41 | private: 42 | Logger(); 43 | ~Logger(); 44 | 45 | static unsigned int currentLogLevel; 46 | static std::vector logHandlers; 47 | static std::string levelToString(unsigned int level); 48 | static void log(unsigned int level, std::string msg); 49 | static std::string getTime(); 50 | }; 51 | -------------------------------------------------------------------------------- /includes/MouseAxis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-01-01. 19 | // 20 | 21 | #ifndef BUBBA_3D_MOUSEAXIS_H 22 | #define BUBBA_3D_MOUSEAXIS_H 23 | 24 | #include 25 | 26 | /** 27 | * An input class that is activated when the mouse isn't in the center. 28 | * Use this input type with care. If you want this input to behave as 29 | * in a typical FPS game you have to reset the mouse position to the center 30 | * of the screen between every frame. If you want the raw mouse position 31 | * use MousePosition instead. 32 | * 33 | * \see MousePosition 34 | */ 35 | class MouseAxis : public Input { 36 | public: 37 | 38 | /** 39 | * Represents the mouse x/y offsets from the center of the window 40 | */ 41 | enum Axis {X,Y}; 42 | 43 | /** 44 | * Creates a dual input which is activated when the mouse isn't 45 | * in the center of the window. The control status value will be 46 | * the offsetFromCenter*accelerator. 47 | */ 48 | MouseAxis(Axis,float accelerator); 49 | ControlStatus getStatus(); 50 | ControlStatus::Activator getActivator(); 51 | 52 | private: 53 | Axis axis; 54 | float accelerator; 55 | float clip(float n); 56 | }; 57 | 58 | 59 | #endif //BUBBA_3D_MOUSEAXIS_H 60 | -------------------------------------------------------------------------------- /includes/MouseButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-22. 19 | // 20 | 21 | #ifndef BUBBA_3D_MOUSEBUTTON_H 22 | #define BUBBA_3D_MOUSEBUTTON_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | * An input class activated by mouse clicks. Mouse buttons supported 30 | * are left-, scroll-, right-click and two extra buttons. 31 | */ 32 | class MouseButton : public Input { 33 | public: 34 | /** 35 | * Creates a non-dual button activated when \p button is pressed. 36 | */ 37 | MouseButton(sf::Mouse::Button button); 38 | /** 39 | * Creates a dual button activated when either button is pressed. When \p buttonNeg is 40 | * pressed the ControlStatus value is -100, when \p buttonPos is pressed the value is 100. If 41 | * both or none are pressed the value is 0. 42 | */ 43 | MouseButton(sf::Mouse::Button buttonPos, sf::Mouse::Button buttonNeg); 44 | ControlStatus getStatus(); 45 | ControlStatus::Activator getActivator(); 46 | 47 | private: 48 | sf::Mouse::Button mButtonPos, mButtonNeg; 49 | }; 50 | 51 | 52 | #endif //BUBBA_3D_MOUSEBUTTON_H 53 | -------------------------------------------------------------------------------- /includes/MouseWarp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-20. 19 | // 20 | 21 | #ifndef BUBBA_3D_MOUSEWARP_H 22 | #define BUBBA_3D_MOUSEWARP_H 23 | 24 | 25 | class MouseWarp { 26 | private: 27 | bool warped; 28 | int x = 0,y = 0; 29 | public: 30 | MouseWarp(); 31 | MouseWarp(int x, int y); 32 | static MouseWarp noWarp(); 33 | static MouseWarp warp(int x, int y); 34 | bool isWarped(); 35 | int getX(); 36 | int getY(); 37 | 38 | }; 39 | 40 | 41 | #endif //BUBBA_3D_MOUSEWARP_H 42 | -------------------------------------------------------------------------------- /includes/MoveComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "IComponent.h" 20 | #include "linmath/float3.h" 21 | #include "GameObject.h" 22 | #include "HudRenderer.h" 23 | #include 24 | 25 | class MoveComponent : public IComponent { 26 | public: 27 | MoveComponent(); 28 | MoveComponent(chag::Quaternion rotationSpeed, 29 | chag::float3 velocity, chag::float3 acceleration, chag::float3 scaleSpeed); 30 | 31 | virtual void update(float dt); 32 | 33 | chag::float3 getVelocity(); 34 | chag::float3 getAcceleration(); 35 | chag::Quaternion getRotationSpeed(); 36 | chag::float3 getScaleSpeed(); 37 | 38 | void setVelocity(chag::float3 v); 39 | void setAcceleration(chag::float3 a); 40 | void setRotationSpeed(chag::Quaternion rs); 41 | void setScaleSpeed(chag::float3 ss); 42 | 43 | private: 44 | chag::float3 velocity = chag::make_vector(0.0f, 0.0f, 0.0f); 45 | chag::float3 acceleration = chag::make_vector(0.0f, 0.0f, 0.0f); 46 | chag::Quaternion rotationSpeed; 47 | chag::float3 scaleSpeed = chag::make_vector(0.0f,0.0f,0.0f); 48 | }; 49 | -------------------------------------------------------------------------------- /includes/PerspectiveCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "Camera.h" 20 | 21 | /** 22 | * \brief Implementation of the Camera interface. 23 | * 24 | * Provides a perspective projection. 25 | */ 26 | class PerspectiveCamera : public Camera { 27 | public: 28 | PerspectiveCamera(chag::float3 position, chag::float3 lookAt, chag::float3 up, 29 | float fov, float ratio, float nearPlane, float farPlane); 30 | ~PerspectiveCamera(); 31 | 32 | chag::float4x4 getViewMatrix(); 33 | chag::float4x4 getProjectionMatrix(); 34 | 35 | void update(float dt); 36 | void setPosition(chag::float3 position); 37 | void setLookAt(chag::float3 lookAt); 38 | void setUpVector(chag::float3 up); 39 | private: 40 | chag::float4x4 lookAt(const chag::float3 &eye, const chag::float3 ¢er, const chag::float3 &up); 41 | chag::float4x4 perspectiveMatrix(float fov, float aspectRatio, float n, float f); 42 | }; 43 | -------------------------------------------------------------------------------- /includes/PositioningLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | class PositioningLayout : public Layout { 22 | public: 23 | virtual void addChild(Layout* child); 24 | 25 | virtual void addChild(Layout* child, Dimension x, Dimension y); 26 | 27 | /** 28 | * \warning Never allowed to return a wrapping dimension 29 | */ 30 | virtual Dimension getWidth(); 31 | /** 32 | * \warning Never allowed to return a wrapping dimension 33 | */ 34 | virtual Dimension getHeight(); 35 | 36 | virtual void getGLSquares(float layoutXPos,float layoutYPos, float layoutWidth, 37 | float layoutHeight, std::map *map); 38 | 39 | PositioningLayout(Dimension width, Dimension height); 40 | 41 | void checkChildCompatibility(Layout* child); 42 | 43 | virtual Layout* findById(std::string id); 44 | 45 | virtual void invokeListenersInternal(int x, int y, ListenerType listenerType, bool mayBeHit); 46 | 47 | protected: 48 | struct PositionedLayout { 49 | Layout* child; 50 | Dimension x; 51 | Dimension y; 52 | PositionedLayout(Layout* child, Dimension x, Dimension y) : child(child), x(x), y(y){ 53 | } 54 | }; 55 | 56 | Dimension width,height; 57 | std::vector children; 58 | }; 59 | -------------------------------------------------------------------------------- /includes/RelativeIHudDrawable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "IHudDrawable.h" 20 | #include 21 | 22 | class GameObject; 23 | class Camera; 24 | 25 | class RelativeIHudDrawable : public IHudDrawable { 26 | public: 27 | 28 | RelativeIHudDrawable(Camera* worldCamera, std::shared_ptr relativeTo, IHudDrawable* toDraw); 29 | virtual void render(std::shared_ptr shaderProgram, chag::float4x4* projectionMatrix); 30 | 31 | protected: 32 | std::shared_ptr relativeTo; 33 | IHudDrawable* toDraw; 34 | Camera* worldCamera; 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /includes/SkyBoxRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "IRenderComponent.h" 20 | #include 21 | #include 22 | 23 | class Camera; 24 | class CubeMapTexture; 25 | class IMesh; 26 | class Chunk; 27 | class GameObject; 28 | 29 | class SkyBoxRenderer : public IRenderComponent 30 | { 31 | public: 32 | SkyBoxRenderer(Camera* camera, IMesh* skyMesh, std::shared_ptr gameObject); 33 | ~SkyBoxRenderer(); 34 | 35 | bool init(const std::string& posXFilename, const std::string& negXFilename, 36 | const std::string& posYFilename, const std::string& negYFilename, 37 | const std::string& posZFilename, const std::string& negZFilename); 38 | 39 | void renderShadow(std::shared_ptr &shaderProgram) {}; 40 | void render(); 41 | void update(float dt); 42 | private: 43 | void renderChunk(Chunk& chunk); 44 | 45 | Camera* m_camera; 46 | CubeMapTexture* m_pCubemap; 47 | IMesh *m_skyMesh; 48 | std::shared_ptr gameObject; 49 | }; 50 | -------------------------------------------------------------------------------- /includes/Sphere.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | class Sphere{ 20 | 21 | public: 22 | Sphere() = default; 23 | Sphere(chag::float3 position, float radius): pos(position), radius(radius) { 24 | } 25 | 26 | chag::float3 getPosition() { 27 | return pos; 28 | } 29 | 30 | float getRadius() { 31 | return radius; 32 | } 33 | 34 | void setPosition(chag::float3 position) { 35 | pos = position; 36 | } 37 | 38 | void setRadius(float radius) { 39 | this->radius = radius; 40 | } 41 | 42 | private: 43 | chag::float3 pos; 44 | float radius; 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /includes/StandardRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "IRenderComponent.h" 20 | #include "SFML/Window.hpp" 21 | #include 22 | 23 | class IMesh; 24 | class ShaderProgram; 25 | class GameObject; 26 | class Chunk; 27 | 28 | /** 29 | * \brief Renders meshes with the default shader 30 | * 31 | * Class is responsible for rendering a Mesh/GameObject using 32 | * the default shader simple.vert and simple.frag. 33 | * 34 | */ 35 | class StandardRenderer : public IRenderComponent { 36 | public: 37 | StandardRenderer(); 38 | StandardRenderer(std::shared_ptr mesh, std::shared_ptr shader); 39 | 40 | void update(float dt); 41 | 42 | void render(); 43 | void renderShadow(std::shared_ptr &shaderProgram); 44 | void renderEmissive(std::shared_ptr &shaderProgram); 45 | private: 46 | std::shared_ptr mesh; 47 | sf::Clock clock; 48 | 49 | void setBones(std::shared_ptr &shaderProgram) const; 50 | }; 51 | 52 | 53 | -------------------------------------------------------------------------------- /includes/StdOutLogHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #ifndef SUPER_BUBBA_AWESOME_SPACE_STDOUTLOGHANDLER_H__ 19 | #define SUPER_BUBBA_AWESOME_SPACE_STDOUTLOGHANDLER_H__ 20 | 21 | #include "LogHandler.h" 22 | #include 23 | 24 | class StdOutLogHandler : public LogHandler { 25 | public: 26 | StdOutLogHandler() {}; 27 | ~StdOutLogHandler() {}; 28 | 29 | virtual void log(std::string msg) { 30 | printf("%s", msg.c_str()); 31 | }; 32 | 33 | }; 34 | 35 | 36 | #endif //SUPER_BUBBA_AWESOME_SPACE_STDOUTLOGHANDLER_H 37 | -------------------------------------------------------------------------------- /includes/Texture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | class Texture { 24 | public: 25 | Texture() {}; 26 | Texture(GLuint textureID): textureID(textureID) {}; 27 | void bind(GLenum textureUnit); 28 | virtual void loadTexture() = 0; 29 | GLuint getID(); 30 | 31 | int getHeight(); 32 | int getWidth(); 33 | 34 | protected: 35 | 36 | GLuint textureID; 37 | int width,height; 38 | }; 39 | -------------------------------------------------------------------------------- /includes/Triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | 21 | struct BoundingBox { 22 | chag::float3 points[8]; 23 | }; 24 | 25 | class Triangle { 26 | public: 27 | Triangle(chag::float3 p1, chag::float3 p2, chag::float3 p3); 28 | ~Triangle(); 29 | 30 | BoundingBox *getBoundingBox(); 31 | 32 | chag::float3 p1; 33 | chag::float3 p2; 34 | chag::float3 p3; 35 | private: 36 | BoundingBox box; 37 | 38 | BoundingBox calculateBoundingBox(); 39 | }; 40 | -------------------------------------------------------------------------------- /includes/Wind.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Wind { 6 | public: 7 | Wind(); 8 | Wind(const chag::float3 &force); 9 | 10 | const chag::float3 &getForce() const; 11 | 12 | private: 13 | chag::float3 force; 14 | 15 | }; 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /includes/WindAffection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | class WindAffection { 5 | public: 6 | bool getIsAffectedByWind() const; 7 | void setAffectedByWind(bool isAffectedByWind); 8 | 9 | float getMainBendiness() const; 10 | void setMainBendiness(float mainBendiness); 11 | 12 | float getBranchAmplitude() const; 13 | void setBranchAmplitude(float branchAmplitude); 14 | 15 | float getLeafAmplitude() const; 16 | void setLeafAmplitude(float leafAmplitude); 17 | 18 | private: 19 | bool isAffectedByWind = false; 20 | float mainBendiness = 0.0f; 21 | float branchAmplitude = 0.0f; 22 | float leafAmplitude = 0.0f; 23 | }; 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /includes/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #ifndef BUBBA_3D_CONSTANTS_H 18 | #define BUBBA_3D_CONSTANTS_H 19 | 20 | #define UNIFORM_BUFFER_OBJECT_MATRICES_NAME "Matrices" 21 | #define UNIFORM_BUFFER_OBJECT_MATRICES_INDEX 0 22 | 23 | 24 | #define SIMPLE_SHADER_NAME "simple_shader" 25 | #define EMISSIVE_SHADER_NAME "emissive_shader" 26 | 27 | 28 | 29 | #endif //BUBBA_3D_CONSTANTS_H 30 | -------------------------------------------------------------------------------- /includes/freetype/config/ftmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file registers the FreeType modules compiled into the library. 3 | * 4 | * If you use GNU make, this file IS NOT USED! Instead, it is created in 5 | * the objects directory (normally `/objs/') based on information 6 | * from `/modules.cfg'. 7 | * 8 | * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile 9 | * FreeType without GNU make. 10 | * 11 | */ 12 | 13 | FT_USE_MODULE( FT_Module_Class, autofit_module_class ) 14 | FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) 15 | FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) 16 | FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) 17 | FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) 18 | FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) 19 | FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) 20 | FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) 21 | FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) 22 | FT_USE_MODULE( FT_Module_Class, psaux_module_class ) 23 | FT_USE_MODULE( FT_Module_Class, psnames_module_class ) 24 | FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) 25 | FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) 26 | FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) 27 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) 28 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) 29 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) 30 | FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) 31 | 32 | /* EOF */ 33 | -------------------------------------------------------------------------------- /includes/freetype/internal/services/svkern.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svkern.h */ 4 | /* */ 5 | /* The FreeType Kerning service (specification). */ 6 | /* */ 7 | /* Copyright 2006-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVKERN_H_ 20 | #define SVKERN_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_TRUETYPE_TABLES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | #define FT_SERVICE_ID_KERNING "kerning" 29 | 30 | 31 | typedef FT_Error 32 | (*FT_Kerning_TrackGetFunc)( FT_Face face, 33 | FT_Fixed point_size, 34 | FT_Int degree, 35 | FT_Fixed* akerning ); 36 | 37 | FT_DEFINE_SERVICE( Kerning ) 38 | { 39 | FT_Kerning_TrackGetFunc get_track; 40 | }; 41 | 42 | /* */ 43 | 44 | 45 | FT_END_HEADER 46 | 47 | 48 | #endif /* SVKERN_H_ */ 49 | 50 | 51 | /* END */ 52 | -------------------------------------------------------------------------------- /includes/freetype/internal/services/svtteng.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svtteng.h */ 4 | /* */ 5 | /* The FreeType TrueType engine query service (specification). */ 6 | /* */ 7 | /* Copyright 2006-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVTTENG_H_ 20 | #define SVTTENG_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_MODULE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /* 30 | * SFNT table loading service. 31 | */ 32 | 33 | #define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" 34 | 35 | /* 36 | * Used to implement FT_Get_TrueType_Engine_Type 37 | */ 38 | 39 | FT_DEFINE_SERVICE( TrueTypeEngine ) 40 | { 41 | FT_TrueTypeEngineType engine_type; 42 | }; 43 | 44 | /* */ 45 | 46 | 47 | FT_END_HEADER 48 | 49 | 50 | #endif /* SVTTENG_H_ */ 51 | 52 | 53 | /* END */ 54 | -------------------------------------------------------------------------------- /includes/freetype/internal/services/svwinfnt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svwinfnt.h */ 4 | /* */ 5 | /* The FreeType Windows FNT/FONT service (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVWINFNT_H_ 20 | #define SVWINFNT_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_WINFONTS_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_WINFNT "winfonts" 30 | 31 | typedef FT_Error 32 | (*FT_WinFnt_GetHeaderFunc)( FT_Face face, 33 | FT_WinFNT_HeaderRec *aheader ); 34 | 35 | 36 | FT_DEFINE_SERVICE( WinFnt ) 37 | { 38 | FT_WinFnt_GetHeaderFunc get_header; 39 | }; 40 | 41 | /* */ 42 | 43 | 44 | FT_END_HEADER 45 | 46 | 47 | #endif /* SVWINFNT_H_ */ 48 | 49 | 50 | /* END */ 51 | -------------------------------------------------------------------------------- /includes/linmath/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_linmath_Common_h 2 | #define _chag_linmath_Common_h 3 | 4 | 5 | namespace chag 6 | { 7 | 8 | /** 9 | * Specialized for the matrix types to contruct identity matrix. 10 | */ 11 | template 12 | const T make_identity(); 13 | template 14 | const T make_rotation_x(float angle); 15 | template 16 | const T make_rotation_y(float angle); 17 | template 18 | const T make_rotation_z(float angle); 19 | template 20 | const T make_rotation(const U& axis, float angle); 21 | template 22 | const T make_matrix(const float *e); 23 | template 24 | const T make_scale(const U& scale); 25 | 26 | 27 | class float3x3; 28 | class float4x4; 29 | 30 | template 31 | class SmallVector3; 32 | typedef SmallVector3 float3; 33 | typedef SmallVector3 int3; 34 | 35 | template 36 | class SmallVector2; 37 | typedef SmallVector2 float2; 38 | typedef SmallVector2 int2; 39 | 40 | template 41 | class SmallVector4; 42 | typedef SmallVector4 float4; 43 | typedef SmallVector4 int4; 44 | 45 | 46 | 47 | template 48 | inline const S lerp(const S &a, const S &b, const T &t) 49 | { 50 | return a + (b - a) * t; 51 | } 52 | 53 | 54 | } // namespace chag 55 | 56 | #endif // _chag_linmath_Common_h 57 | -------------------------------------------------------------------------------- /includes/linmath/Quaternion.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_Quaternion_h 2 | #define _chag_Quaternion_h 3 | 4 | #include "float3.h" 5 | #include "float4x4.h" 6 | 7 | 8 | 9 | namespace chag 10 | { 11 | class Quaternion 12 | { 13 | public: 14 | float3 v; 15 | float w; 16 | // The default constructor creates an identity quaternion 17 | Quaternion():v(make_vector(0.0f, 0.0f, 0.0f)), w(1.0) {}; 18 | Quaternion(float3 mv, float mw):v(mv), w(mw) {}; 19 | 20 | const Quaternion operator + (const Quaternion& q) const 21 | { 22 | return Quaternion(v + q.v, w + q.w); 23 | }; 24 | 25 | const Quaternion operator * (const Quaternion& q) const 26 | { 27 | return Quaternion(cross(v, q.v) + q.w * v + w * q.v, 28 | w * q.w - dot(v, q.v)); 29 | } 30 | 31 | const Quaternion operator * (const float& f) const 32 | { 33 | return Quaternion(v * f, w * f); 34 | } 35 | 36 | // Conjugate 37 | const Quaternion conj() const 38 | { 39 | return Quaternion(-v, w); 40 | } 41 | 42 | 43 | }; 44 | 45 | /** 46 | */ 47 | Quaternion make_quaternion_axis_angle(const float3 &axis, float angle); 48 | 49 | /** 50 | */ 51 | Quaternion make_quaternion(const float3x3 &rot); 52 | 53 | /** 54 | */ 55 | Quaternion make_quaternion(const float4x4 &rot); 56 | 57 | 58 | // Norm 59 | const float n(const Quaternion& q); 60 | // Inverse 61 | const Quaternion inv(const Quaternion& q); 62 | 63 | // Creating a matrix from a quaternion 64 | const float3x3 toMatrix3x3(const Quaternion& q); 65 | const float4x4 makematrix(const Quaternion& q); 66 | 67 | const Quaternion slerp(Quaternion q, Quaternion r, float t); 68 | 69 | } // namespace chag 70 | 71 | #endif // _chag_Quaternion_h 72 | -------------------------------------------------------------------------------- /includes/linmath/float2.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_float2_h 2 | #define _chag_float2_h 3 | 4 | #include "linmath/SmallVector2.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector2 float2; 10 | 11 | } // namespace chag 12 | 13 | #endif // _chag_float2_h 14 | -------------------------------------------------------------------------------- /includes/linmath/float3.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_float3_h 2 | #define _chag_float3_h 3 | 4 | #include "linmath/SmallVector3.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector3 float3; 10 | 11 | } // namespace chag 12 | 13 | #endif // _chag_float3_h 14 | -------------------------------------------------------------------------------- /includes/linmath/float3x3.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_float3x3_h 2 | #define _chag_float3x3_h 3 | 4 | #include "linmath/Common.h" 5 | #include "float3.h" 6 | 7 | namespace chag 8 | { 9 | 10 | class float4x4; 11 | 12 | class float3x3 13 | { 14 | public: 15 | // The three columns of the matrix 16 | float3 c1; 17 | float3 c2; 18 | float3 c3; 19 | 20 | float3& operator [] (const size_t i); 21 | const float3& operator [] (const size_t i) const; 22 | 23 | const float &operator()(const size_t row, const size_t column) const { return *(&(&c1 + column - 1)->x + row - 1); } 24 | float &operator()(const size_t row, const size_t column) { return *(&(&c1 + column - 1)->x + row - 1); } 25 | 26 | const bool operator == (const float3x3& m) const; 27 | const bool operator != (const float3x3& m) const; 28 | 29 | // Assignement 30 | const float3x3 operator - (const float3x3 M); 31 | const float3 operator * (const float3& v) const; 32 | const float3x3 operator * (const float f) const; 33 | 34 | const float3 row(size_t i) const; 35 | const float3x3 operator * (const float3x3& M) const; 36 | }; 37 | 38 | 39 | // Find the LU decomposition of the matrix 40 | const void lu(const float3x3 &a, float3x3 &l, float3x3 &u); 41 | const float3 lr(float3x3 &a); 42 | void egenvektor(float3x3 &m, float3 *v1, float3 *v2, float3 *v3); 43 | 44 | 45 | const float3x3 transpose(const float3x3 &m); 46 | 47 | 48 | const float determinant(const float3x3 &m); 49 | 50 | const float3 cramers(const float3x3 &m, const float3& u); 51 | 52 | 53 | /** 54 | */ 55 | template <> 56 | const float3x3 make_identity(); 57 | 58 | template <> 59 | const float3x3 make_matrix(const float *e); 60 | 61 | const float3x3 make_matrix3x3(const float4x4 &m); 62 | 63 | const float3x3 make_matrix(const float3 &c1, const float3 &c2, const float3 &c3); 64 | 65 | /** 66 | * The matrix is indexed on the form Mrow,column. 67 | */ 68 | const float3x3 make_matrix(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33); 69 | 70 | const float3x3 operator * (const float& f, const float3x3& M); 71 | 72 | } // namespace chag 73 | 74 | #endif // _chag_float3x3_h 75 | -------------------------------------------------------------------------------- /includes/linmath/float4.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_float4_h 2 | #define _chag_float4_h 3 | 4 | #include "linmath/SmallVector4.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector4 float4; 10 | 11 | } // namespace chag 12 | 13 | #endif // _chag_float4_h 14 | -------------------------------------------------------------------------------- /includes/linmath/int2.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_int2_h 2 | #define _chag_int2_h 3 | 4 | #include "linmath/SmallVector2.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector2 int2; 10 | typedef SmallVector2 uint2; 11 | 12 | } // namespace chag 13 | 14 | #endif // _chag_int2_h 15 | -------------------------------------------------------------------------------- /includes/linmath/int3.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_int3_h 2 | #define _chag_int3_h 3 | 4 | #include "linmath/SmallVector3.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector3 int3; 10 | 11 | } // namespace chag 12 | 13 | #endif // _chag_int3_h 14 | -------------------------------------------------------------------------------- /includes/linmath/int4.h: -------------------------------------------------------------------------------- 1 | #ifndef _chag_int4_h 2 | #define _chag_int4_h 3 | 4 | #include "linmath/SmallVector4.h" 5 | 6 | namespace chag 7 | { 8 | 9 | typedef SmallVector4 int4; 10 | 11 | } // namespace chag 12 | 13 | #endif // _chag_int4_h 14 | -------------------------------------------------------------------------------- /includes/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Custom strlen() which works on different character types. 24 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 25 | \param s Null-terminated input string. 26 | \return Number of characters in the string. 27 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 28 | */ 29 | template 30 | inline SizeType StrLen(const Ch* s) { 31 | const Ch* p = s; 32 | while (*p) ++p; 33 | return SizeType(p - s); 34 | } 35 | 36 | } // namespace internal 37 | RAPIDJSON_NAMESPACE_END 38 | 39 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 40 | -------------------------------------------------------------------------------- /includes/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Custom swap() to avoid dependency on C++ header 24 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 25 | \note This has the same semantics as std::swap(). 26 | */ 27 | template 28 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 29 | T tmp = a; 30 | a = b; 31 | b = tmp; 32 | } 33 | 34 | } // namespace internal 35 | RAPIDJSON_NAMESPACE_END 36 | 37 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 38 | -------------------------------------------------------------------------------- /includes/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #ifdef _WIN32 20 | #include 21 | 22 | using namespace std::chrono; 23 | #endif 24 | 25 | #ifdef __linux__ 26 | #include 27 | #endif 28 | 29 | namespace utils { 30 | class Timer { 31 | public: 32 | void start(); 33 | void stop(); 34 | double getElapsedTime(); 35 | 36 | private: 37 | 38 | #ifdef __linux__ 39 | struct timeval tStart; 40 | struct timeval tEnd; 41 | #endif 42 | 43 | #ifdef _WIN32 44 | high_resolution_clock::time_point tEnd; 45 | high_resolution_clock::time_point tStart; 46 | #endif 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /lib/DevIL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/DevIL.lib -------------------------------------------------------------------------------- /lib/FreeImage.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/FreeImage.dll -------------------------------------------------------------------------------- /lib/FreeImage.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/FreeImage.lib -------------------------------------------------------------------------------- /lib/GL/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /lib/GL/glut.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLUT_H__ 2 | #define __GLUT_H__ 3 | 4 | /* 5 | * glut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | 19 | /*** END OF FILE ***/ 20 | 21 | #endif /* __GLUT_H__ */ 22 | -------------------------------------------------------------------------------- /lib/IL/DevIL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/IL/DevIL.lib -------------------------------------------------------------------------------- /lib/IL/ILU.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/IL/ILU.lib -------------------------------------------------------------------------------- /lib/IL/ILUT.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/IL/ILUT.lib -------------------------------------------------------------------------------- /lib/IL/config.h.win: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_H__ 2 | #define __CONFIG_H__ 3 | 4 | #define IL_USE_PRAGMA_LIBS // Links to only the libraries that are requested. 5 | #define IL_INLINE_ASM 1 // Define if you can support at least some ASM 6 | 7 | // Supported images formats (IL) 8 | 9 | // #define IL_NO_BLP 10 | // #define IL_NO_BMP 11 | // #define IL_NO_CUT 12 | // #define IL_NO_CHEAD 13 | // #define IL_NO_DCX 14 | // #define IL_NO_DDS 15 | // #define IL_NO_DICOM 16 | // #define IL_NO_DOOM 17 | // #define IL_NO_EXR 18 | // #define IL_NO_FITS 19 | // #define IL_NO_FTX 20 | // #define IL_NO_GIF 21 | // #define IL_NO_HDR 22 | // #define IL_NO_ICO 23 | // #define IL_NO_ICNS 24 | // #define IL_NO_IWI 25 | // #define IL_NO_JP2 26 | // #define IL_NO_JPG 27 | // #define IL_NO_LCMS 28 | // #define IL_NO_LIF 29 | // #define IL_NO_MDL 30 | // #define IL_NO_MNG 31 | // #define IL_NO_PCD 32 | // #define IL_NO_PCX 33 | // #define IL_NO_PIC 34 | // #define IL_NO_PIX 35 | // #define IL_NO_PNG 36 | // #define IL_NO_PNM 37 | // #define IL_NO_PSD 38 | // #define IL_NO_PSP 39 | // #define IL_NO_PXR 40 | // #define IL_NO_RAW 41 | // #define IL_NO_ROT 42 | // #define IL_NO_SGI 43 | // #define IL_NO_SUN 44 | // #define IL_NO_TGA 45 | // #define IL_NO_TIF 46 | // #define IL_NO_TPL 47 | // #define IL_NO_WAL 48 | // #define IL_NO_WDP 49 | // #define IL_NO_XPM 50 | 51 | #define IL_USE_JPEGLIB_UNMODIFIED 1 52 | #define IL_USE_DXTC_NVIDIA 53 | #define IL_USE_DXTC_SQUISH 54 | 55 | //#define IL_NO_GAMES 56 | 57 | /* Supported api (ilut) */ 58 | 59 | 60 | // 61 | // sorry just 62 | // cant get this one to work under windows 63 | // have disabled for the now 64 | // 65 | // will look at it some more later 66 | // 67 | // Kriss 68 | // 69 | #undef ILUT_USE_ALLEGRO 70 | 71 | #undef ILUT_USE_DIRECTX8 72 | #define ILUT_USE_DIRECTX9 73 | #define ILUT_USE_DIRECTX10 74 | #define ILUT_USE_OPENGL 75 | #define ILUT_USE_SDL 76 | #define ILUT_USE_WIN32 77 | 78 | 79 | #endif /* __CONFIG_H__ */ 80 | -------------------------------------------------------------------------------- /lib/IL/ilu_region.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // ImageLib Utility Sources 4 | // Copyright (C) 2000-2002 by Denton Woods 5 | // Last modified: 07/09/2002 <--Y2K Compliant! =] 6 | // 7 | // Filename: src-ILU/src/ilu_region.h 8 | // 9 | // Description: Creates an image region. 10 | // 11 | //----------------------------------------------------------------------------- 12 | 13 | #ifndef ILU_REGION_H 14 | #define ILU_REGION_H 15 | 16 | typedef struct Edge 17 | { 18 | ILint yUpper; 19 | ILfloat xIntersect, dxPerScan; 20 | struct Edge *next; 21 | } Edge; 22 | 23 | 24 | #endif//ILU_REGION_H 25 | 26 | -------------------------------------------------------------------------------- /lib/IL/ilut_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __ILUT_CONFIG_H__ 2 | #define __ILUT_CONFIG_H__ 3 | 4 | #define IL_USE_PRAGMA_LIBS 5 | 6 | // Supported APIs (ILUT) 7 | 8 | // 9 | // sorry just 10 | // cant get this one to work under windows 11 | // have disabled for the now 12 | // 13 | // will look at it some more later 14 | // 15 | // Kriss 16 | // 17 | #undef ILUT_USE_ALLEGRO 18 | 19 | #undef ILUT_USE_DIRECTX8 20 | //#define ILUT_USE_DIRECTX9 21 | //#define ILUT_USE_DIRECTX10 22 | #define ILUT_USE_OPENGL 23 | //#define ILUT_USE_SDL 24 | #define ILUT_USE_WIN32 25 | 26 | #endif//__ILUT_CONFIG_H__ 27 | -------------------------------------------------------------------------------- /lib/ILU.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/ILU.lib -------------------------------------------------------------------------------- /lib/ILUT.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/ILUT.lib -------------------------------------------------------------------------------- /lib/OpenAL32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/OpenAL32.lib -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | #FOR WINDOWS ONLY 2 | 3 | These should be all the libraries you need to compile the project.
4 | 5 | Link the following in cmake: 6 | 7 | #ASSIMP 8 | ASSIMP_INCLUDE_DIR - Bubba-3D/lib
9 | ASSIMP_LIBRARY - Bubba-3D/lib/assimp.lib
10 | ASSIMP_LIBRARY_DEBUG - Bubba-3D/lib/assimp.lib
11 | ASSIMP_LIBRARY_RELEASE - Bubba-3D/lib/assimp.lib
12 | 13 | #GLEW 14 | GLEW_INCLUDE_DIR - Bubba-3D/lib
15 | GLEW_LIBRARY - Bubba-3D/lib/glew32s.lib
16 | 17 | #GLUT 18 | GLUT_INCLUDE_DIR - Bubba-3D/lib
19 | GLUT_glut_LIBRARY - Bubba-3D/lib/freeglutd.lib
20 | 21 | #FREEIMAGE 22 | FREEIMAGE_DIR - Bubba-3D/lib/freeimage
23 | FREEIMAGE_FOUND - Check
24 | FREEIMAGE_INCLUDE_PATH - Bubba-3D/lib/freeimage
25 | FREEIMAGE_LIBRARY - Bubba-3D/lib/freeimage/FreeImage.lib
26 | -------------------------------------------------------------------------------- /lib/SFML/Audio/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_EXPORT_HPP 26 | #define SFML_AUDIO_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_AUDIO_EXPORTS) 38 | 39 | #define SFML_AUDIO_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_AUDIO_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_AUDIO_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML/Graphics/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_EXPORT_HPP 26 | #define SFML_GRAPHICS_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_GRAPHICS_EXPORTS) 38 | 39 | #define SFML_GRAPHICS_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_GRAPHICS_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_GRAPHICS_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML/Main.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_MAIN_HPP 26 | #define SFML_MAIN_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | #if defined(SFML_SYSTEM_IOS) 35 | 36 | // On iOS, we have no choice but to have our own main, 37 | // so we need to rename the user one and call it later 38 | #define main sfmlMain 39 | 40 | #endif 41 | 42 | 43 | #endif // SFML_MAIN_HPP 44 | -------------------------------------------------------------------------------- /lib/SFML/Network/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_EXPORT_HPP 26 | #define SFML_NETWORK_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_NETWORK_EXPORTS) 38 | 39 | #define SFML_NETWORK_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_NETWORK_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_NETWORK_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML/Network/SocketHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SOCKETHANDLE_HPP 26 | #define SFML_SOCKETHANDLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | #if defined(SFML_SYSTEM_WINDOWS) 34 | #include 35 | #endif 36 | 37 | 38 | namespace sf 39 | { 40 | //////////////////////////////////////////////////////////// 41 | // Define the low-level socket handle type, specific to 42 | // each platform 43 | //////////////////////////////////////////////////////////// 44 | #if defined(SFML_SYSTEM_WINDOWS) 45 | 46 | typedef UINT_PTR SocketHandle; 47 | 48 | #else 49 | 50 | typedef int SocketHandle; 51 | 52 | #endif 53 | 54 | } // namespace sf 55 | 56 | 57 | #endif // SFML_SOCKETHANDLE_HPP 58 | -------------------------------------------------------------------------------- /lib/SFML/System/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_EXPORT_HPP 26 | #define SFML_SYSTEM_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_SYSTEM_EXPORTS) 38 | 39 | #define SFML_SYSTEM_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_SYSTEM_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_SYSTEM_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML/System/Sleep.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SLEEP_HPP 26 | #define SFML_SLEEP_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \ingroup system 39 | /// \brief Make the current thread sleep for a given duration 40 | /// 41 | /// sf::sleep is the best way to block a program or one of its 42 | /// threads, as it doesn't consume any CPU power. 43 | /// 44 | /// \param duration Time to sleep 45 | /// 46 | //////////////////////////////////////////////////////////// 47 | void SFML_SYSTEM_API sleep(Time duration); 48 | 49 | } // namespace sf 50 | 51 | 52 | #endif // SFML_SLEEP_HPP 53 | -------------------------------------------------------------------------------- /lib/SFML/System/String.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | String String::fromUtf8(T begin, T end) 29 | { 30 | String string; 31 | Utf8::toUtf32(begin, end, std::back_inserter(string.m_string)); 32 | return string; 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | String String::fromUtf16(T begin, T end) 39 | { 40 | String string; 41 | Utf16::toUtf32(begin, end, std::back_inserter(string.m_string)); 42 | return string; 43 | } 44 | 45 | 46 | //////////////////////////////////////////////////////////// 47 | template 48 | String String::fromUtf32(T begin, T end) 49 | { 50 | String string; 51 | string.m_string.assign(begin, end); 52 | return string; 53 | } 54 | -------------------------------------------------------------------------------- /lib/SFML/Window/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOW_EXPORT_HPP 26 | #define SFML_WINDOW_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_WINDOW_EXPORTS) 38 | 39 | #define SFML_WINDOW_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_WINDOW_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_WINDOW_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/assimp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp.lib -------------------------------------------------------------------------------- /lib/assimp/Compiler/poppack1.h: -------------------------------------------------------------------------------- 1 | 2 | // =============================================================================== 3 | // May be included multiple times - resets structure packing to the defaults 4 | // for all supported compilers. Reverts the changes made by #include 5 | // 6 | // Currently this works on the following compilers: 7 | // MSVC 7,8,9 8 | // GCC 9 | // BORLAND (complains about 'pack state changed but not reverted', but works) 10 | // =============================================================================== 11 | 12 | #ifndef AI_PUSHPACK_IS_DEFINED 13 | # error pushpack1.h must be included after poppack1.h 14 | #endif 15 | 16 | // reset packing to the original value 17 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 18 | # pragma pack( pop ) 19 | #endif 20 | #undef PACK_STRUCT 21 | 22 | #undef AI_PUSHPACK_IS_DEFINED 23 | -------------------------------------------------------------------------------- /lib/assimp/Compiler/pushpack1.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // =============================================================================== 4 | // May be included multiple times - sets structure packing to 1 5 | // for all supported compilers. #include reverts the changes. 6 | // 7 | // Currently this works on the following compilers: 8 | // MSVC 7,8,9 9 | // GCC 10 | // BORLAND (complains about 'pack state changed but not reverted', but works) 11 | // 12 | // 13 | // USAGE: 14 | // 15 | // struct StructToBePacked { 16 | // } PACK_STRUCT; 17 | // 18 | // =============================================================================== 19 | 20 | #ifdef AI_PUSHPACK_IS_DEFINED 21 | # error poppack1.h must be included after pushpack1.h 22 | #endif 23 | 24 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 25 | # pragma pack(push,1) 26 | # define PACK_STRUCT 27 | #elif defined( __GNUC__ ) 28 | # define PACK_STRUCT __attribute__((packed)) 29 | #else 30 | # error Compiler not supported 31 | #endif 32 | 33 | #if defined(_MSC_VER) 34 | 35 | // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop 36 | # pragma warning (disable : 4103) 37 | #endif 38 | 39 | #define AI_PUSHPACK_IS_DEFINED 40 | 41 | 42 | -------------------------------------------------------------------------------- /lib/assimp/ai_assert.h: -------------------------------------------------------------------------------- 1 | /** @file assert.h 2 | */ 3 | #ifndef AI_DEBUG_H_INC 4 | #define AI_DEBUG_H_INC 5 | 6 | #ifdef _DEBUG 7 | # include 8 | # define ai_assert(expression) assert(expression) 9 | #else 10 | # define ai_assert(expression) 11 | #endif 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /lib/assimp/defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp/defs.h -------------------------------------------------------------------------------- /lib/assimp/matrix3x3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp/matrix3x3.h -------------------------------------------------------------------------------- /lib/assimp/matrix3x3.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp/matrix3x3.inl -------------------------------------------------------------------------------- /lib/assimp/matrix4x4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp/matrix4x4.h -------------------------------------------------------------------------------- /lib/assimp/matrix4x4.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/assimp/matrix4x4.inl -------------------------------------------------------------------------------- /lib/freeglutd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/freeglutd.lib -------------------------------------------------------------------------------- /lib/freeimage/FreeImage.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/freeimage/FreeImage.h -------------------------------------------------------------------------------- /lib/freetype.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/freetype.lib -------------------------------------------------------------------------------- /lib/glew32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/glew32.lib -------------------------------------------------------------------------------- /lib/glew32s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/glew32s.lib -------------------------------------------------------------------------------- /lib/lib.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/lib.rar -------------------------------------------------------------------------------- /lib/libsfml-audio.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-audio.so -------------------------------------------------------------------------------- /lib/libsfml-audio.so.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-audio.so.2.3 -------------------------------------------------------------------------------- /lib/libsfml-audio.so.2.3.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-audio.so.2.3.2 -------------------------------------------------------------------------------- /lib/libsfml-graphics.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-graphics.so -------------------------------------------------------------------------------- /lib/libsfml-graphics.so.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-graphics.so.2.3 -------------------------------------------------------------------------------- /lib/libsfml-graphics.so.2.3.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-graphics.so.2.3.2 -------------------------------------------------------------------------------- /lib/libsfml-network.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-network.so -------------------------------------------------------------------------------- /lib/libsfml-network.so.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-network.so.2.3 -------------------------------------------------------------------------------- /lib/libsfml-network.so.2.3.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-network.so.2.3.2 -------------------------------------------------------------------------------- /lib/libsfml-system.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-system.so -------------------------------------------------------------------------------- /lib/libsfml-system.so.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-system.so.2.3 -------------------------------------------------------------------------------- /lib/libsfml-system.so.2.3.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-system.so.2.3.2 -------------------------------------------------------------------------------- /lib/libsfml-window.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-window.so -------------------------------------------------------------------------------- /lib/libsfml-window.so.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-window.so.2.3 -------------------------------------------------------------------------------- /lib/libsfml-window.so.2.3.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/libsfml-window.so.2.3.2 -------------------------------------------------------------------------------- /lib/sfml-audio-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-audio-d.lib -------------------------------------------------------------------------------- /lib/sfml-audio-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-audio-s-d.lib -------------------------------------------------------------------------------- /lib/sfml-audio-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-audio-s.lib -------------------------------------------------------------------------------- /lib/sfml-audio.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-audio.lib -------------------------------------------------------------------------------- /lib/sfml-system-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-system-d.lib -------------------------------------------------------------------------------- /lib/sfml-system-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-system-s-d.lib -------------------------------------------------------------------------------- /lib/sfml-system-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-system-s.lib -------------------------------------------------------------------------------- /lib/sfml-system.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-system.lib -------------------------------------------------------------------------------- /lib/sfml-window-d-2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-window-d-2.lib -------------------------------------------------------------------------------- /lib/sfml-window-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-window-s-d.lib -------------------------------------------------------------------------------- /lib/sfml-window-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-window-s.lib -------------------------------------------------------------------------------- /lib/sfml-window.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubbers/Bubba-3D/c05790583c9f9d7a017e2369dad75fc133991a1a/lib/sfml-window.lib -------------------------------------------------------------------------------- /publish_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ "${TRAVIS_BRANCH}" != "master" ]] 5 | then 6 | echo "Branch ${TRAVIS_BRANCH} is not master" 7 | exit 0 8 | fi 9 | 10 | # Fetch the gh-pages branch and switch to it 11 | git fetch origin gh-pages 12 | git checkout -qf FETCH_HEAD 13 | git checkout -b gh-pages 14 | 15 | # Setting git author 16 | git config user.email "noreply@travis-ci.org" 17 | git config user.name "Travis CI" 18 | 19 | # Moving docs to root directory and committing 20 | cp -r build/docs/html/* . 21 | git add . 22 | 23 | git commit -m "Built new docs on master" 24 | 25 | # Adding deploy key 26 | ENCRYPTION_LABEL="773359cabcfc" 27 | ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" 28 | ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" 29 | ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} 30 | ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} 31 | 32 | openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d 33 | chmod 600 deploy_key 34 | eval `ssh-agent -s` 35 | ssh-add deploy_key 36 | 37 | # Pushing to github 38 | git push "git@github.com:Bubbers/Bubba-3D.git" gh-pages -f 39 | -------------------------------------------------------------------------------- /shaders/cutoff.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | // Note: this is core in OpenGL 3.1 (glsl 1.40) and later, we use OpenGL 3.0 for the tutorials 4 | #extension GL_ARB_texture_rectangle : enable 5 | 6 | // required by GLSL spec Sect 4.5.3 (though nvidia does not, amd does) 7 | precision highp float; 8 | 9 | uniform sampler2DRect frameBufferTexture; 10 | uniform float cutAt; 11 | out vec4 fragmentColor; 12 | 13 | 14 | /** 15 | * Implements cutoff to ensure only bright parts of the screen gets blurred to produce bloom. 16 | */ 17 | void main() 18 | { 19 | vec4 sample = texture(frameBufferTexture, gl_FragCoord.xy); 20 | 21 | //float sunUp = max(0.0f, cos((time / 20.0f) * 2.0f * 3.14f)); 22 | if (sample.r > cutAt || sample.g > cutAt || sample.b > cutAt) 23 | { 24 | fragmentColor = sample; 25 | } 26 | else 27 | { 28 | fragmentColor = vec4(0.0); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /shaders/emissive.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | in vec2 texCoord; 3 | 4 | uniform vec3 material_emissive_color; 5 | uniform int has_emissive_texture; 6 | uniform sampler2D emissive_texture; 7 | 8 | // output to frame buffer. 9 | out vec4 fragmentColor; 10 | 11 | void main() { 12 | 13 | vec3 emissive = material_emissive_color; 14 | if(has_emissive_texture == 1){ 15 | vec3 texEmissive = texture(emissive_texture,texCoord.xy).xyz; 16 | emissive.x *= texEmissive.x; 17 | emissive.y *= texEmissive.y; 18 | emissive.z *= texEmissive.z; 19 | } 20 | if(length(emissive) < 0.0001){ 21 | fragmentColor = vec4(1.0,1.0,1.0,0.0); 22 | }else{ 23 | fragmentColor = vec4(emissive,1.0); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /shaders/emissive.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | #extension GL_ARB_explicit_attrib_location : enable 4 | 5 | layout(location = 0) in vec3 position; 6 | layout(location = 2) in vec2 texCoordIn; // incoming texcoord from the texcoord array 7 | layout(location = 6) in ivec4 boneIds; 8 | layout(location = 7) in vec4 boneWeights; 9 | 10 | uniform mat4 modelMatrix; 11 | 12 | uniform mat4 viewProjectionMatrix; 13 | 14 | uniform int has_animations; 15 | const int MAX_NUM_BONES = 100; 16 | uniform mat4 bones[MAX_NUM_BONES]; 17 | 18 | out vec2 texCoord; // outgoing interpolated texcoord to fragshader 19 | 20 | void main(){ 21 | 22 | vec3 positionInWorldSpace = position; 23 | 24 | if(has_animations == 1) { 25 | mat4 boneTransform = bones[boneIds.x] * boneWeights.x; 26 | boneTransform += bones[boneIds.y] * boneWeights.y; 27 | boneTransform += bones[boneIds.z] * boneWeights.z; 28 | boneTransform += bones[boneIds.w] * boneWeights.w; 29 | 30 | positionInWorldSpace = (boneTransform * vec4(position, 1.0)).xyz; 31 | } 32 | 33 | mat4 modelViewProjectionMatrix = viewProjectionMatrix * modelMatrix; 34 | gl_Position = modelViewProjectionMatrix * vec4(positionInWorldSpace,1.0); 35 | texCoord = texCoordIn; 36 | 37 | } -------------------------------------------------------------------------------- /shaders/horizontal_blur.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | // Note: this is core in OpenGL 3.1 (glsl 1.40) and later, we use OpenGL 3.0 for the tutorials 4 | #extension GL_ARB_texture_rectangle : enable 5 | 6 | // required by GLSL spec Sect 4.5.3 (though nvidia does not, amd does) 7 | precision highp float; 8 | 9 | uniform sampler2DRect frameBufferTexture; 10 | out vec4 fragmentColor; 11 | 12 | 13 | float offsets[9] = float[9](-7.302940716, -5.35180578, -3.403984807, -1.458429517, 0.0, 1.458429517, 3.403984807, 5.35180578, 7.302940716); 14 | //float weights[9] = float[9](0.011110875, 0.045328584, 0.119911134, 0.205817181, 0.117832226, 0.205817181, 0.119911134, 0.045328584, 0.011110875); 15 | float weights[9] = float[9](0.0125949685786212, 0.0513831777608629, 0.1359278107392780, 0.2333084327472980, 0.1335712203478790, 0.2333084327472980, 0.1359278107392780, 0.0513831777608629, 0.0125949685786212); 16 | 17 | 18 | /** 19 | * Implements the horizontal part of a 17 tap separable gaussian blur, using standard deviation of 3.0, calculated 20 | * using the formluas and excel sheet from this blog: http://theinstructionlimit.com/gaussian-blur-revisited-part-two 21 | * The weights have been normalized to make the kernel not brighten or darken the image. 22 | */ 23 | void main() 24 | { 25 | vec4 result = vec4(0.0); 26 | // do a 17 tap blur by sampling a biliniarly filtered texture. 27 | for (int i = 0; i < 9; ++i) 28 | { 29 | result += texture(frameBufferTexture, gl_FragCoord.xy + vec2(offsets[i], 0.0)) * weights[i]; 30 | } 31 | 32 | fragmentColor = result; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /shaders/hud.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | 4 | layout(location=0) in vec3 position; 5 | layout(location=1) in vec2 texCoordIn; 6 | layout(location=2) in vec2 locationIn; 7 | 8 | out vec2 texCoord; 9 | out vec2 location; 10 | 11 | uniform mat4 modelMatrix; 12 | uniform mat4 projectionMatrix; 13 | 14 | void main() { 15 | texCoord = texCoordIn; 16 | location = locationIn; 17 | gl_Position = projectionMatrix*modelMatrix * vec4(position, 1.0); 18 | } -------------------------------------------------------------------------------- /shaders/particle.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | precision highp float; 4 | 5 | in vec2 texCoord; 6 | 7 | out vec4 fragmentColor; 8 | 9 | uniform sampler2D sprite; 10 | uniform vec3 color; 11 | 12 | void main() { 13 | fragmentColor = texture(sprite, texCoord) * vec4(color, 1.0); 14 | } -------------------------------------------------------------------------------- /shaders/particle.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | #define scale 0.1 4 | in vec3 position; 5 | in vec2 texCoordIn; 6 | 7 | uniform mat4 modelMatrix; 8 | 9 | layout(std140) uniform Matrices { 10 | mat4 viewMatrix; 11 | mat4 projectionMatrix; 12 | mat4 viewProjectionMatrix; 13 | }; 14 | 15 | out vec2 texCoord; 16 | 17 | void main() { 18 | texCoord = texCoordIn; 19 | gl_Position = viewProjectionMatrix * modelMatrix * vec4(position, 1.0); 20 | } -------------------------------------------------------------------------------- /shaders/postFx.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | // Note: this is core in OpenGL 3.1 (glsl 1.40) and later, we use OpenGL 3.0 for the tutorials 4 | #extension GL_ARB_texture_rectangle : enable 5 | 6 | // required by GLSL spec Sect 4.5.3 (though nvidia does not, amd does) 7 | precision highp float; 8 | 9 | uniform sampler2DRect frameBufferTexture; 10 | uniform float time; 11 | out vec4 fragmentColor; 12 | 13 | 14 | void main() 15 | { 16 | vec3 color = texture(frameBufferTexture, gl_FragCoord.xy).xyz; 17 | 18 | fragmentColor = vec4(color, 1.0); 19 | } 20 | -------------------------------------------------------------------------------- /shaders/postFx.vert: -------------------------------------------------------------------------------- 1 | #version 130 2 | #extension GL_ARB_explicit_attrib_location : enable 3 | // This vertex shader simply outputs the input coordinates to the rasterizer. It only uses 2D coordinates. 4 | layout(location = 0) in vec2 position; 5 | 6 | void main() 7 | { 8 | gl_Position = vec4(position, 0.0, 1.0); 9 | } -------------------------------------------------------------------------------- /shaders/shadowMap.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | precision highp float; 4 | 5 | out vec4 fragmentColor; 6 | 7 | void main() { 8 | fragmentColor = vec4(1.0); 9 | } -------------------------------------------------------------------------------- /shaders/shadowMap.vert: -------------------------------------------------------------------------------- 1 | #version 130 2 | precision highp float; 3 | 4 | in vec3 position; 5 | uniform mat4 viewProjectionMatrix; 6 | uniform mat4 modelMatrix; 7 | 8 | void main() { 9 | gl_Position = viewProjectionMatrix * modelMatrix* vec4(position, 1.0); 10 | } -------------------------------------------------------------------------------- /shaders/skybox.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | #extension GL_ARB_explicit_attrib_location : enable 3 | 4 | in vec3 texCoord; 5 | 6 | uniform samplerCube cubeMapSampler; 7 | 8 | layout(location = 0) out vec4 fragmentColor; 9 | 10 | void main() { 11 | fragmentColor = texture(cubeMapSampler, texCoord); 12 | } -------------------------------------------------------------------------------- /shaders/skybox.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | #extension GL_ARB_explicit_attrib_location : enable 3 | 4 | layout(location = 0) in vec3 position; 5 | uniform mat4 modelMatrix; 6 | out vec3 texCoord; 7 | 8 | layout(std140) uniform Matrices { 9 | mat4 viewMatrix; 10 | mat4 projectionMatrix; 11 | mat4 viewProjectionMatrix; 12 | }; 13 | 14 | void main() { 15 | vec4 wvp_pos = viewProjectionMatrix * modelMatrix * vec4(position, 1.0); 16 | texCoord = position; 17 | gl_Position = wvp_pos.xyww; 18 | } -------------------------------------------------------------------------------- /shaders/vertical_blur.frag: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | // Note: this is core in OpenGL 3.1 (glsl 1.40) and later, we use OpenGL 3.0 for the tutorials 4 | #extension GL_ARB_texture_rectangle : enable 5 | 6 | // required by GLSL spec Sect 4.5.3 (though nvidia does not, amd does) 7 | precision highp float; 8 | 9 | uniform sampler2DRect frameBufferTexture; 10 | out vec4 fragmentColor; 11 | 12 | 13 | float offsets[9] = float[9](-7.302940716, -5.35180578, -3.403984807, -1.458429517, 0.0, 1.458429517, 3.403984807, 5.35180578, 7.302940716); 14 | //float weights[9] = float[9](0.011110875, 0.045328584, 0.119911134, 0.205817181, 0.117832226, 0.205817181, 0.119911134, 0.045328584, 0.011110875); 15 | float weights[9] = float[9](0.0125949685786212, 0.0513831777608629, 0.1359278107392780, 0.2333084327472980, 0.1335712203478790, 0.2333084327472980, 0.1359278107392780, 0.0513831777608629, 0.0125949685786212); 16 | 17 | 18 | /** 19 | * Implements the vertical part of a 17 tap separable gaussian blur, using standard deviation of 3.0, calculated 20 | * using the formluas and excel sheet from this blog: http://theinstructionlimit.com/gaussian-blur-revisited-part-two 21 | * The weights have been normalized to make the kernel not brighten or darken the image. 22 | */ 23 | void main() 24 | { 25 | vec4 result = vec4(0.0); 26 | // do a 17 tap blur by sampling a biliniarly filtered texture. 27 | for (int i = 0; i < 9; ++i) 28 | { 29 | result += texture(frameBufferTexture, gl_FragCoord.xy + vec2(0.0, offsets[i])) * weights[i]; 30 | } 31 | 32 | fragmentColor = result; 33 | } 34 | -------------------------------------------------------------------------------- /src/Input/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE Input/ControlStatus.cpp 2 | Input/ControlsManager.cpp 3 | Input/Input.cpp 4 | Input/JoystickAxis.cpp 5 | Input/JoystickButton.cpp 6 | Input/JoystickTranslation.cpp 7 | Input/JoystickTranslator.cpp 8 | Input/KeyboardButton.cpp 9 | Input/MouseAxis.cpp 10 | Input/MouseButton.cpp 11 | Input/MousePosition.cpp 12 | Input/MouseWarp.cpp 13 | ${BUBBA3D_FILES_SOURCE} 14 | PARENT_SCOPE) 15 | -------------------------------------------------------------------------------- /src/Input/Input.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-20. 19 | // 20 | 21 | #include "Input.h" 22 | 23 | bool Input::isDual() { 24 | return dual; 25 | } 26 | 27 | Input::Input(bool dual) { 28 | this->dual = dual; 29 | } -------------------------------------------------------------------------------- /src/Input/KeyboardButton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-22. 19 | // 20 | 21 | #include 22 | #include "Input.h" 23 | #include 24 | 25 | KeyboardButton::KeyboardButton(sf::Keyboard::Key key) : Input(false){ 26 | this->keyPos = key; 27 | } 28 | 29 | KeyboardButton::KeyboardButton(sf::Keyboard::Key keyPos, sf::Keyboard::Key keyNeg) : Input(true){ 30 | this->keyNeg = keyNeg; 31 | this->keyPos = keyPos; 32 | } 33 | 34 | ControlStatus::Activator KeyboardButton::getActivator() { 35 | return ControlStatus::KEYBOARD; 36 | } 37 | 38 | ControlStatus KeyboardButton::getStatus() { 39 | float value = sf::Keyboard::isKeyPressed(keyPos) ? 100.0f : 0.0f; 40 | if(dual) 41 | value -= sf::Keyboard::isKeyPressed(keyNeg) ? 100.0f : 0.0f; 42 | return ControlStatus(ControlStatus::KEYBOARD,value); 43 | } -------------------------------------------------------------------------------- /src/Input/MouseAxis.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-01-01. 19 | // 20 | 21 | #include 22 | #include 23 | #include "Input.h" 24 | #include 25 | #include 26 | 27 | MouseAxis::MouseAxis(Axis axis, float accelerator) : Input(true) { 28 | this->axis = axis; 29 | this->accelerator = accelerator; 30 | } 31 | 32 | ControlStatus MouseAxis::getStatus() { 33 | float value = axis == X ? MousePosition().getXMidOffset() : MousePosition().getYMidOffset(); 34 | return ControlStatus(ControlStatus::Activator::MOUSE,clip(value*accelerator)); 35 | } 36 | 37 | ControlStatus::Activator MouseAxis::getActivator() { 38 | return ControlStatus::MOUSE; 39 | } 40 | 41 | float MouseAxis::clip(float n) { 42 | return std::max(-100.0f, std::min(n, 100.0f)); 43 | } -------------------------------------------------------------------------------- /src/Input/MouseButton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-22. 19 | // 20 | 21 | #include 22 | #include "Input.h" 23 | #include 24 | 25 | MouseButton::MouseButton(sf::Mouse::Button button) : Input(false){ 26 | this->mButtonPos = button; 27 | } 28 | 29 | MouseButton::MouseButton(sf::Mouse::Button pos, sf::Mouse::Button neg) : Input(true) { 30 | this->mButtonPos = pos; 31 | this->mButtonNeg = neg; 32 | } 33 | 34 | ControlStatus MouseButton::getStatus() { 35 | float value = sf::Mouse::isButtonPressed(mButtonPos) ? 1.0f : 0.0f; 36 | if(dual) 37 | value -= sf::Mouse::isButtonPressed(mButtonPos) ? 1.0f : 0.0f; 38 | return ControlStatus(ControlStatus::MOUSE, value*100.0f); 39 | } 40 | 41 | ControlStatus::Activator MouseButton::getActivator() { 42 | return ControlStatus::MOUSE; 43 | } -------------------------------------------------------------------------------- /src/Input/MousePosition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-29. 19 | // 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | MousePosition::MousePosition() { 27 | update(); 28 | } 29 | 30 | void MousePosition::update(){ 31 | sf::Vector2i pos = sf::Mouse::getPosition(); 32 | x = pos.x; 33 | y = pos.y; 34 | wx = Globals::get(Globals::Key::MOUSE_WINDOW_X); 35 | wy = Globals::get(Globals::Key::MOUSE_WINDOW_Y); 36 | } 37 | 38 | int MousePosition::getRawX() { 39 | return x; 40 | } 41 | 42 | int MousePosition::getRawY() { 43 | return y; 44 | } 45 | 46 | int MousePosition::getWindowX() { 47 | return wx; 48 | } 49 | 50 | int MousePosition::getWindowY() { 51 | return wy; 52 | } 53 | 54 | int MousePosition::getXMidOffset() { 55 | return getWindowX() - Globals::get(Globals::Key::WINDOW_WIDTH)/2; 56 | } 57 | 58 | int MousePosition::getYMidOffset() { 59 | return getWindowY() - Globals::get(Globals::Key::WINDOW_HEIGHT)/2; 60 | } -------------------------------------------------------------------------------- /src/Input/MouseWarp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2015-12-20. 19 | // 20 | 21 | #include 22 | 23 | MouseWarp::MouseWarp(){ 24 | warped = false; 25 | } 26 | 27 | MouseWarp::MouseWarp(int x, int y) { 28 | this->x = x; 29 | this->y = y; 30 | warped = true; 31 | } 32 | 33 | MouseWarp MouseWarp::noWarp() { return MouseWarp(); } 34 | 35 | MouseWarp MouseWarp::warp(int x, int y) { return MouseWarp(x,y); } 36 | 37 | bool MouseWarp::isWarped() {return warped; } 38 | 39 | int MouseWarp::getX(){ return x;} 40 | int MouseWarp::getY(){ return y;} -------------------------------------------------------------------------------- /src/Misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE Misc/CubeMapTexture.cpp 2 | Misc/ResourceManager.cpp 3 | Misc/FileWatcher.cpp 4 | ${BUBBA3D_FILES_SOURCE} 5 | PARENT_SCOPE) 6 | -------------------------------------------------------------------------------- /src/Misc/FileWatcher.cpp: -------------------------------------------------------------------------------- 1 | #include "FileWatcher.h" 2 | #include 3 | #include 4 | #include 5 | 6 | FileWatcher::FileWatcher() { 7 | fileDescriptor = inotify_init(); 8 | if (fileDescriptor < 0) { 9 | Logger::logError("Couldn't start inotify"); 10 | } else { 11 | Logger::logInfo("FileWatcher started. Ready for adding file watch subscriptions"); 12 | } 13 | } 14 | 15 | void FileWatcher::addWatch(std::string fileName, std::function callback) { 16 | Logger::logInfo("Adding file watch subscription to: " + fileName); 17 | int watchDescriptor = inotify_add_watch(fileDescriptor, fileName.c_str(), IN_CLOSE_WRITE); 18 | if (watchDescriptor < 0) { 19 | Logger::logError("Failed to subscribe file watch to file: " + fileName); 20 | return; 21 | } 22 | 23 | numEvents++; 24 | watchCallbacks.insert(std::pair>(watchDescriptor, callback)); 25 | } 26 | 27 | void FileWatcher::update() { 28 | struct pollfd pfd = {fileDescriptor, POLLIN, POLLIN}; 29 | int timeout = 1; 30 | int eventsAvailable = poll(&pfd, 1, timeout); 31 | 32 | if(eventsAvailable > 0) { 33 | char readBuffer[EVENT_BUF_LEN]; 34 | ssize_t length = read(fileDescriptor, readBuffer, EVENT_BUF_LEN); 35 | 36 | int i = 0; 37 | while (i < length) { 38 | struct inotify_event *event = (struct inotify_event *) &readBuffer[i]; 39 | if (event->mask & IN_CLOSE_WRITE) { 40 | auto value = watchCallbacks.find(event->wd); 41 | if(value != watchCallbacks.end()) { 42 | value->second(); 43 | } 44 | } 45 | i += EVENT_SIZE + event->len; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Misc/FileWatcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define EVENT_SIZE (sizeof(struct inotify_event)) 9 | #define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 )) 10 | typedef int WatchID; 11 | 12 | /** 13 | * @brief Calls callbacks when disks on file change 14 | * 15 | * This class is used for executing callbacks when a file changes on disk. 16 | * This might be useful if you change resources on disk and quickly want to 17 | * reload them in the engine. Should be used for debugging purposes only. 18 | * 19 | * \code 20 | * FileWatcher fileWatcher(); 21 | * fileWatcher.addWatch("local/filename.txt", [](){printf("Callback called");}); 22 | * fileWatcher.update(); 23 | * \endcode 24 | */ 25 | class FileWatcher { 26 | public: 27 | FileWatcher(); 28 | 29 | /** 30 | * @brief Adds a file watch that calls the callback whenever the file is modified 31 | * 32 | * This is only used for debugging purposes to quickly reload resources. 33 | * 34 | * @param fileName The name of the file. 35 | */ 36 | void addWatch(std::string fileName, std::function callback); 37 | 38 | /** 39 | * @brief File watches is poll based and the update method needs to be called regularily. 40 | * 41 | * The file watches fill up a buffer in the kernel that is read and parsed in the update method. 42 | * If a file change matches your subscription the associated callback is called. 43 | * 44 | */ 45 | void update(); 46 | private: 47 | int fileDescriptor; 48 | int numEvents = 0; 49 | std::map> watchCallbacks; 50 | }; -------------------------------------------------------------------------------- /src/cameras/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE cameras/Camera.cpp 2 | cameras/PerspectiveCamera.cpp 3 | ${BUBBA3D_FILES_SOURCE} 4 | PARENT_SCOPE) 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/cameras/Camera.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "Camera.h" 18 | 19 | void Camera::setPosition(chag::float3 position) { 20 | this->m_vPosition = position; 21 | } 22 | 23 | void Camera::setLookAt(chag::float3 lookAt) { 24 | this->m_vLookAt = lookAt; 25 | } 26 | 27 | void Camera::setUpVector(chag::float3 up) { 28 | this->m_vUp = up; 29 | } 30 | -------------------------------------------------------------------------------- /src/collision/BFBroadPhase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2015-12-05. 19 | // 20 | 21 | #ifndef BUBBA_3D_BRUTEFORCEBROADPHASE_H 22 | #define BUBBA_3D_BRUTEFORCEBROADPHASE_H 23 | 24 | #include "BroadPhaseCollider.h" 25 | #include "GameObject.h" 26 | 27 | 28 | class BFBroadPhase : public BroadPhaseCollider 29 | { 30 | public: 31 | BFBroadPhase(); 32 | 33 | virtual CollisionPairList computeCollisionPairs(Scene* scene) override ; 34 | private: 35 | bool isPossiblyColliding(std::shared_ptr gameObject1, std::shared_ptr gameObject2); 36 | 37 | void addIfPossiblyColliding(CollisionPairList &collisionPairs, const std::shared_ptr gameObject1, 38 | const std::shared_ptr gameObject2); 39 | 40 | void findPossiblyCollidesWith(std::vector> &sceneObjects, 41 | CollisionPairList &collisionPairs, 42 | const std::vector>::iterator &i, 43 | const std::shared_ptr gameObject1); 44 | }; 45 | 46 | #endif //BUBBA_3D_BRUTEFORCEBROADPHASE_H 47 | -------------------------------------------------------------------------------- /src/collision/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE collision/BFBroadPhase.cpp 2 | collision/Collider.cpp 3 | collision/Octree.cpp 4 | collision/TwoPhaseCollider.cpp 5 | collision/ExactOctreeCollider.cpp 6 | collision/ColliderFactory.cpp 7 | ${BUBBA3D_FILES_SOURCE} 8 | PARENT_SCOPE) 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/collision/ColliderFactory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-04-13. 19 | // 20 | 21 | #include "BFBroadPhase.h" 22 | #include "../../includes/ColliderFactory.h" 23 | #include "ExactOctreeCollider.h" 24 | #include "TwoPhaseCollider.h" 25 | 26 | Collider* ColliderFactory::getTwoPhaseCollider() { 27 | return new TwoPhaseCollider(new BFBroadPhase(), new ExactOctreeCollider()); 28 | } 29 | -------------------------------------------------------------------------------- /src/collision/ExactOctreeCollider.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include 18 | #include "GameObject.h" 19 | #include "ExactOctreeCollider.h" 20 | 21 | CollisionPairList ExactOctreeCollider::computeExactCollision(CollisionPairList possibleCollision) { 22 | CollisionPairList exactCollisions; 23 | 24 | for(auto i = possibleCollision.begin(); i != possibleCollision.end(); i++ ) { 25 | CollisionPair pair = *i; 26 | 27 | std::shared_ptr object1 = pair.first; 28 | std::shared_ptr object2 = pair.second; 29 | 30 | chag::float4x4 object1ModelMatrix = object1->getModelMatrix(); 31 | chag::float4x4 object2ModelMatrix = object2->getModelMatrix(); 32 | 33 | Octree* object1Oct = object1->getOctree(); 34 | Octree* object2Oct = object2->getOctree(); 35 | 36 | if (octreeOctreeIntersection(object1Oct,&object1ModelMatrix,object2Oct, &object2ModelMatrix)) { 37 | exactCollisions.push_back(CollisionPair(object1, object2)); 38 | } 39 | } 40 | 41 | return exactCollisions; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/collision/ExactOctreeCollider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-04-13. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_EXACTOCTREECOLLIDER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_EXACTOCTREECOLLIDER_H 23 | 24 | #include "../../includes/ExactPhaseCollider.h" 25 | 26 | class ExactOctreeCollider : public ExactPhaseCollider{ 27 | public: 28 | CollisionPairList computeExactCollision(CollisionPairList possibleCollision) override ; 29 | 30 | private: 31 | 32 | }; 33 | 34 | 35 | #endif //SUPER_BUBBA_AWESOME_SPACE_EXACTOCTREECOLLIDER_H 36 | -------------------------------------------------------------------------------- /src/collision/TwoPhaseCollider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include "Collider.h" 22 | 23 | /** 24 | * Class responsible for maintaining a two phase collider, ie 25 | * first a fast inaccurate test and then a more exact test on 26 | * all possibly colliding objects. 27 | */ 28 | class TwoPhaseCollider : public Collider{ 29 | public: 30 | TwoPhaseCollider(BroadPhaseCollider *broadPhaseCollider, ExactPhaseCollider *exactPhaseCollider); 31 | 32 | void updateCollision(Scene *scene) override; 33 | 34 | private: 35 | void triggerObjectEvent(CollisionPair &pair, EventType eventType); 36 | 37 | bool wasCollidingPreviously(CollisionPair sortedPair); 38 | 39 | CollisionPairList collidingList; 40 | 41 | BroadPhaseCollider *broadPhaseCollider; 42 | ExactPhaseCollider *exactPhaseCollider; 43 | 44 | void triggerObjectEvents(CollisionPairList vector); 45 | 46 | void callEventsForObjectsThatNoLongerCollides(CollisionPairList exactCollisions); 47 | 48 | CollisionPair sortPair(CollisionPair pair); 49 | }; 50 | -------------------------------------------------------------------------------- /src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE common/Utils.cpp 2 | common/Timer.cpp 3 | ${BUBBA3D_FILES_SOURCE} 4 | PARENT_SCOPE) 5 | -------------------------------------------------------------------------------- /src/common/Timer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #include "timer.h" 19 | 20 | namespace utils { 21 | 22 | void Timer::start() { 23 | #ifdef __linux__ 24 | gettimeofday(&tStart, nullptr); 25 | #endif 26 | #ifdef _WIN32 27 | tStart = high_resolution_clock::now(); 28 | #endif 29 | } 30 | 31 | void Timer::stop() { 32 | #ifdef __linux__ 33 | gettimeofday(&tEnd, nullptr); 34 | #endif 35 | 36 | #ifdef _WIN32 37 | tEnd = high_resolution_clock::now(); 38 | #endif 39 | } 40 | 41 | double Timer::getElapsedTime() { 42 | double elapsedTime; 43 | 44 | #ifdef __linux__ 45 | elapsedTime = (tEnd.tv_sec - tStart.tv_sec) * 1000.0; 46 | elapsedTime += (tEnd.tv_usec - tStart.tv_usec) / 1000.0; 47 | #endif 48 | 49 | #ifdef _WIN32 50 | duration time_span = duration_cast>(tEnd - tStart); 51 | elapsedTime = time_span.count() * 1000; 52 | #endif 53 | 54 | return elapsedTime; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE components/MoveComponent.cpp 2 | components/StandardRenderer.cpp 3 | ${BUBBA3D_FILES_SOURCE} 4 | PARENT_SCOPE) 5 | -------------------------------------------------------------------------------- /src/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE core/Globals.cpp 2 | core/Renderer.cpp 3 | core/Window.cpp 4 | ${BUBBA3D_FILES_SOURCE} 5 | PARENT_SCOPE) 6 | -------------------------------------------------------------------------------- /src/core/Globals.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-01-10. 19 | // 20 | 21 | #include 22 | 23 | int Globals::get(Key key) { 24 | return masterFunc(key,0,true); 25 | } 26 | 27 | void Globals::set(Key key, int value) { 28 | masterFunc(key,value,false); 29 | } 30 | 31 | int Globals::masterFunc(Key key, int value, bool getElseSet) { 32 | static int vals[] = {0,0,0,0,0,0}; 33 | if(getElseSet){ 34 | return vals[key]; 35 | } else { 36 | vals[key] = value; 37 | return 0; 38 | } 39 | } -------------------------------------------------------------------------------- /src/glutil/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE glutil/glutil.cpp 2 | ${BUBBA3D_FILES_SOURCE} 3 | PARENT_SCOPE) 4 | -------------------------------------------------------------------------------- /src/linmath/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE linmath/float2.cpp 2 | linmath/float3.cpp 3 | linmath/float4.cpp 4 | linmath/float3x3.cpp 5 | linmath/float4x4.cpp 6 | linmath/int2.cpp 7 | linmath/int3.cpp 8 | linmath/int4.cpp 9 | linmath/Quaternion.cpp 10 | ${BUBBA3D_FILES_SOURCE} 11 | PARENT_SCOPE) 12 | -------------------------------------------------------------------------------- /src/linmath/float2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/float2.h" 18 | 19 | template class chag::SmallVector2; 20 | -------------------------------------------------------------------------------- /src/linmath/float3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/float3.h" 18 | 19 | template class chag::SmallVector3; 20 | -------------------------------------------------------------------------------- /src/linmath/float4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/float4.h" 18 | 19 | template class chag::SmallVector4; 20 | -------------------------------------------------------------------------------- /src/linmath/int2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/int2.h" 18 | 19 | template class chag::SmallVector2; 20 | -------------------------------------------------------------------------------- /src/linmath/int3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/int3.h" 18 | 19 | template class chag::SmallVector3; 20 | -------------------------------------------------------------------------------- /src/linmath/int4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "linmath/int4.h" 18 | 19 | template class chag::SmallVector4; 20 | -------------------------------------------------------------------------------- /src/logging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE logging/Logger.cpp 2 | ${BUBBA3D_FILES_SOURCE} 3 | PARENT_SCOPE) 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/objects/BoneInfluenceOnVertex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #include "BoneInfluenceOnVertex.h" 19 | 20 | 21 | 22 | BoneInfluenceOnVertex::BoneInfluenceOnVertex() { 23 | for (int i = 0; i < MAX_NUM_BONES; i++) { 24 | ids[i] = 0; 25 | weights[i] = 0.0; 26 | } 27 | } 28 | 29 | 30 | void BoneInfluenceOnVertex::addBoneData(int boneId, float weight) { 31 | for (int i = 0; i < MAX_NUM_BONES ; i++) { 32 | if(weights[i] == 0.0) { 33 | ids[i] = boneId; 34 | weights[i] = weight; 35 | return; 36 | } 37 | } 38 | 39 | throw std::invalid_argument ("Tried to add more than maxNumBones to a mesh"); 40 | } -------------------------------------------------------------------------------- /src/objects/BoneInfluenceOnVertex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | #include 19 | #include "stdint.h" 20 | #include 21 | 22 | #define MAX_NUM_BONES 4 23 | 24 | /** 25 | * \brief Struct for maintaining information of how a bone affects a vertex 26 | * 27 | * A vertex can be affected by at most {@code MAX_NUM_BONES} and each bone affects 28 | * the vertex by a certain weight. The sum of all weights must equal 1.0. 29 | * 30 | * Usage: 31 | * \code{.cpp} 32 | * BoneInfluenceOnVertex boneInfluence; 33 | * boneInfluence.addBoneData(firstBoneConnectedToVertex, firstBonesWeightOnVertex); 34 | * boneInfluence.addBoneData(secondBoneConnectedToVertex, secondBonesWeightOnVertex); 35 | * \endcode 36 | */ 37 | struct BoneInfluenceOnVertex { 38 | uint ids[MAX_NUM_BONES]; 39 | float weights[MAX_NUM_BONES]; 40 | 41 | BoneInfluenceOnVertex(); 42 | 43 | /** 44 | * Adds bone data to the next free bone slot 45 | */ 46 | void addBoneData(int boneId, float weight) ; 47 | }; 48 | -------------------------------------------------------------------------------- /src/objects/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE objects/Chunk.cpp 2 | objects/GameObject.cpp 3 | objects/Mesh.cpp 4 | objects/Scene.cpp 5 | objects/SkyBoxRenderer.cpp 6 | objects/Texture.cpp 7 | objects/Triangle.cpp 8 | objects/BoneInfluenceOnVertex.cpp 9 | objects/BoneTransformer.cpp 10 | objects/WindAffection.cpp 11 | objects/Wind.cpp 12 | objects/ImageTexture.cpp 13 | ${BUBBA3D_FILES_SOURCE} 14 | PARENT_SCOPE) 15 | -------------------------------------------------------------------------------- /src/objects/Chunk.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "Chunk.h" 18 | 19 | 20 | Chunk::Chunk() { 21 | } -------------------------------------------------------------------------------- /src/objects/Chunk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include "linmath/float2.h" 21 | #include "linmath/float3.h" 22 | #include 23 | #include 24 | #include 25 | #include "BoneInfluenceOnVertex.h" 26 | 27 | class Chunk { 28 | public: 29 | Chunk(); 30 | 31 | ~Chunk() { 32 | } 33 | 34 | // Data on host 35 | std::vector m_positions; 36 | std::vector m_normals; 37 | std::vector m_uvs; 38 | std::vector m_indices; 39 | std::vector m_tangents; 40 | std::vector m_bittangents; 41 | std::vector m_vertexColors; 42 | std::vector bones; 43 | 44 | // Data on GPU 45 | GLuint m_positions_bo; 46 | GLuint m_normals_bo; 47 | GLuint m_uvs_bo; 48 | GLuint m_ind_bo; 49 | GLuint m_tangents_bo; 50 | GLuint m_bittangents_bo; 51 | GLuint m_vertexColors_bo; 52 | GLuint bonesBufferObject; 53 | // Vertex Array Object 54 | GLuint m_vaob; 55 | 56 | unsigned int materialIndex; 57 | }; 58 | -------------------------------------------------------------------------------- /src/objects/ImageTexture.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | ImageTexture::ImageTexture(std::string fileName) { 8 | this->fileName = fileName; 9 | } 10 | 11 | void ImageTexture::loadTexture() { 12 | stbi_set_flip_vertically_on_load(true); 13 | 14 | int comp; 15 | unsigned char* image = stbi_load(fileName.c_str(), &width, &height, &comp, 0); 16 | 17 | if(image == nullptr) { 18 | Logger::logError("Couldnt load image "+ fileName); 19 | } 20 | 21 | GLuint texid; 22 | glGenTextures(1, &texid); 23 | glActiveTexture(GL_TEXTURE0); 24 | CHECK_GL_ERROR(); 25 | glBindTexture(GL_TEXTURE_2D, texid); 26 | CHECK_GL_ERROR(); 27 | 28 | 29 | GLenum format = comp == 3 ? GL_RGB : GL_RGBA; 30 | 31 | glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA_EXT, 32 | width, height, 0, format, GL_UNSIGNED_BYTE, image); 33 | 34 | CHECK_GL_ERROR(); 35 | glGenerateMipmap(GL_TEXTURE_2D); 36 | CHECK_GL_ERROR(); 37 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 38 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 39 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 40 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 41 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); 42 | CHECK_GL_ERROR(); 43 | 44 | glBindTexture(GL_TEXTURE_2D, 0); 45 | CHECK_GL_ERROR(); 46 | textureID = texid; 47 | 48 | stbi_image_free(image); 49 | Logger::logInfo("Loaded image: " + fileName); 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/objects/Texture.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "glutil/glutil.h" 18 | #include 19 | #include 20 | #include "Texture.h" 21 | 22 | #define STB_IMAGE_IMPLEMENTATION 23 | 24 | #include "stb_image.h" 25 | 26 | 27 | void Texture::bind(GLenum textureUnit){ 28 | glActiveTexture(textureUnit); 29 | CHECK_GL_ERROR() 30 | glBindTexture(GL_TEXTURE_2D, textureID); 31 | } 32 | 33 | int Texture::getHeight() { 34 | return height; 35 | } 36 | 37 | int Texture::getWidth() { 38 | return width; 39 | } 40 | 41 | GLuint Texture::getID() { 42 | return textureID; 43 | }; 44 | -------------------------------------------------------------------------------- /src/objects/Triangle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "Triangle.h" 18 | 19 | using namespace chag; 20 | 21 | Triangle::Triangle(float3 p1, float3 p2, float3 p3) 22 | :p1(p1), p2(p2), p3(p3) 23 | { 24 | box = calculateBoundingBox(); 25 | } 26 | 27 | Triangle::~Triangle(void) { 28 | 29 | } 30 | 31 | BoundingBox* Triangle::getBoundingBox(){ 32 | return &box; 33 | } 34 | 35 | BoundingBox Triangle::calculateBoundingBox(){ 36 | float maxX = fmax(fmax(p1.x, p2.x), p3.x); 37 | float maxY = fmax(fmax(p1.y, p2.y), p3.y); 38 | float maxZ = fmax(fmax(p1.z, p2.z), p3.z); 39 | 40 | float minX = fmin(fmin(p1.x, p2.x), p3.x); 41 | float minY = fmin(fmin(p1.y, p2.y), p3.y); 42 | float minZ = fmin(fmin(p1.z, p2.z), p3.z); 43 | 44 | BoundingBox b; 45 | 46 | b.points[0] = make_vector(maxX, maxY, maxZ); 47 | b.points[1] = make_vector(maxX, minY, maxZ); 48 | b.points[2] = make_vector(minX, maxY, maxZ); 49 | b.points[3] = make_vector(minX, minY, maxZ); 50 | 51 | b.points[4] = make_vector(maxX, maxY, minZ); 52 | b.points[5] = make_vector(maxX, minY, minZ); 53 | b.points[6] = make_vector(minX, maxY, minZ); 54 | b.points[7] = make_vector(minX, minY, minZ); 55 | 56 | return b; 57 | } -------------------------------------------------------------------------------- /src/objects/Wind.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "Wind.h" 4 | 5 | Wind::Wind() { 6 | force = chag::make_vector(0.0f, 0.0f, 0.0f); 7 | } 8 | 9 | Wind::Wind(const chag::float3 &force) : force(force) { 10 | 11 | } 12 | 13 | const chag::float3 &Wind::getForce() const { 14 | return force; 15 | } 16 | -------------------------------------------------------------------------------- /src/objects/WindAffection.cpp: -------------------------------------------------------------------------------- 1 | #include "WindAffection.h" 2 | 3 | 4 | bool WindAffection::getIsAffectedByWind() const { 5 | return isAffectedByWind; 6 | } 7 | 8 | void WindAffection::setAffectedByWind(bool isAffectedByWind) { 9 | this->isAffectedByWind = isAffectedByWind; 10 | } 11 | 12 | float WindAffection::getMainBendiness() const { 13 | return mainBendiness; 14 | } 15 | 16 | void WindAffection::setMainBendiness(float mainBendiness) { 17 | this->mainBendiness = mainBendiness; 18 | } 19 | 20 | float WindAffection::getBranchAmplitude() const { 21 | return branchAmplitude; 22 | } 23 | 24 | void WindAffection::setBranchAmplitude(float branchAmplitude) { 25 | WindAffection::branchAmplitude = branchAmplitude; 26 | } 27 | 28 | float WindAffection::getLeafAmplitude() const { 29 | return leafAmplitude; 30 | } 31 | 32 | void WindAffection::setLeafAmplitude(float leafAmplitude) { 33 | WindAffection::leafAmplitude = leafAmplitude; 34 | } 35 | -------------------------------------------------------------------------------- /src/particle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE particle/Particle.cpp 2 | particle/ParticleGenerator.cpp 3 | particle/ParticleRenderer.cpp 4 | ${BUBBA3D_FILES_SOURCE} 5 | PARENT_SCOPE) 6 | -------------------------------------------------------------------------------- /src/particle/Particle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #include "particle/Particle.h" 18 | #include "ParticleConf.h" 19 | 20 | Particle::Particle(ParticleConf &conf, chag::float4x4 modelMatrix) { 21 | reset(conf, modelMatrix); 22 | }; 23 | 24 | void Particle::reset(ParticleConf &conf, chag::float4x4 modelMatrix) { 25 | position = conf.initialPosition(); 26 | chag::float4 vec = chag::make_vector(position.x, position.y, position.z, 1.0f); 27 | chag::float4 mat = modelMatrix * vec; 28 | position.x = mat.x; 29 | position.y = mat.y; 30 | position.z = mat.z; 31 | velocity = conf.initialVelocity(); 32 | life = conf.calcLifetime(); 33 | } 34 | 35 | void Particle::update(float deltaTime, float distanceToCam, ParticleConf &conf) { 36 | velocity = conf.accelerate(velocity); 37 | position += velocity * deltaTime / 10; 38 | life -= deltaTime + (distanceToCam * 2); 39 | } 40 | 41 | bool Particle::isAlive() { 42 | return life > 0.0f; 43 | } 44 | 45 | chag::float3 Particle::getPosition() { 46 | return position; 47 | } 48 | -------------------------------------------------------------------------------- /src/particle/Particle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | #pragma once 18 | 19 | #include "linmath/float3.h" 20 | #include "linmath/Quaternion.h" 21 | 22 | #define PARTICLE_SPEED ((rand() % 6000) - 3000.0f) / 5000.0f 23 | #define PARTICLE_LIFE 1000.0f + (rand() % 1000) 24 | 25 | class ParticleConf; 26 | 27 | /** 28 | * \breif Represents a particle generated by a ParticleGenerator. 29 | * 30 | */ 31 | class Particle { 32 | 33 | public: 34 | Particle(ParticleConf &conf, chag::float4x4 modelMatrix); 35 | 36 | /** 37 | * Resets the particle according to the given ParticleConf. 38 | * This is used in order to reuse particles. 39 | * @param conf The ParticleConf to used by the ParticleGenerator. 40 | */ 41 | void reset( ParticleConf &conf, chag::float4x4 modelMatrix); 42 | 43 | /** 44 | * @return If the Particle is alive, that is visible, or not. 45 | * Dead Particles will can be reused by calling reset(). 46 | */ 47 | bool isAlive(); 48 | 49 | /** 50 | * @param deltaTime Time since last update in seconds. 51 | * @param distanceToCam The distance from camera in units. 52 | * @param conf The ParticleConf used by the ParticleGenerator. 53 | */ 54 | void update(float deltaTime, float distanceToCam, ParticleConf &conf); 55 | chag::float3 getPosition(); 56 | 57 | private: 58 | float life; //in ms 59 | chag::float3 position; 60 | chag::float3 velocity; 61 | }; 62 | -------------------------------------------------------------------------------- /src/shader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE shader/ShaderProgram.cpp 2 | shader/VertexShader.cpp 3 | shader/FragmentShader.cpp 4 | ${BUBBA3D_FILES_SOURCE} 5 | PARENT_SCOPE) 6 | -------------------------------------------------------------------------------- /src/shader/FragmentShader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-03-12. 19 | // 20 | 21 | #include "FragmentShader.h" 22 | 23 | #define FRAGMENT_SHADER_NAME_STRING "Vertex_Shader" 24 | 25 | FragmentShader::FragmentShader(std::string shaderName) { 26 | shaderString = textFileRead(shaderName.c_str(), true); 27 | compile(); 28 | } 29 | 30 | void FragmentShader::compile() { 31 | fragmentShader = compileShader(GL_FRAGMENT_SHADER, shaderString.c_str()); 32 | checkErrors(fragmentShader); 33 | } 34 | 35 | void FragmentShader::checkErrors(GLuint &shader) { 36 | checkCompileErrors(&shader, FRAGMENT_SHADER_NAME_STRING); 37 | } 38 | 39 | GLuint FragmentShader::getGLId() { 40 | return this->fragmentShader; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/shader/FragmentShader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-03-12. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_FRAGMENTSHADER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_FRAGMENTSHADER_H 23 | 24 | #include 25 | 26 | /** 27 | * \brief Compiles Fragment Shaders 28 | * 29 | * Class that takes a fragment shader string and compiles it. 30 | * It also checks for any possible errors that occured during compilation. 31 | * 32 | */ 33 | class FragmentShader : public IShader{ 34 | public: 35 | FragmentShader() {}; 36 | FragmentShader(std::string shaderName); 37 | 38 | virtual void compile(); 39 | virtual void checkErrors(GLuint &shader); 40 | virtual GLuint getGLId(); 41 | 42 | private: 43 | std::string shaderString; 44 | GLuint fragmentShader; 45 | }; 46 | 47 | 48 | #endif //SUPER_BUBBA_AWESOME_SPACE_FRAGMENTSHADER_H 49 | -------------------------------------------------------------------------------- /src/shader/VertexShader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-03-12. 19 | // 20 | 21 | #include "VertexShader.h" 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | VertexShader::VertexShader(std::string shaderName) { 28 | shaderString = textFileRead(shaderName.c_str(), true); 29 | compile(); 30 | } 31 | 32 | void VertexShader::compile() { 33 | vertexShader = compileShader(GL_VERTEX_SHADER, shaderString.c_str()); 34 | checkErrors(vertexShader); 35 | } 36 | 37 | void VertexShader::checkErrors(GLuint &shader) { 38 | checkCompileErrors(&shader, VERTEX_SHADER_NAME_STRING); 39 | } 40 | 41 | GLuint VertexShader::getGLId() { 42 | return this->vertexShader; 43 | } 44 | -------------------------------------------------------------------------------- /src/shader/VertexShader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by johan on 2016-03-12. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_VERTEXSHADER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_VERTEXSHADER_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define VERTEX_SHADER_NAME_STRING "Vertex_Shader" 29 | 30 | /** 31 | * \brief Compiles Vertex Shaders 32 | * 33 | * Class that takes a vertex shader string and compiles it. 34 | * It also checks for any possible errors that occured during compilation. 35 | * 36 | */ 37 | class VertexShader : public IShader { 38 | public: 39 | VertexShader() {}; 40 | VertexShader(std::string shaderName); 41 | 42 | virtual void compile(); 43 | virtual void checkErrors(GLuint &shader); 44 | virtual GLuint getGLId(); 45 | 46 | private: 47 | std::string shaderString; 48 | GLuint vertexShader; 49 | }; 50 | 51 | 52 | #endif //SUPER_BUBBA_AWESOME_SPACE_VERTEXSHADER_H 53 | -------------------------------------------------------------------------------- /src/userInterface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUBBA3D_FILES_SOURCE userInterface/Dimension.cpp 2 | userInterface/Font.cpp 3 | userInterface/FontManager.cpp 4 | userInterface/GLSquare.cpp 5 | userInterface/HUDGraphic.cpp 6 | userInterface/HudRenderer.cpp 7 | userInterface/IHudDrawable.cpp 8 | userInterface/Layout.cpp 9 | userInterface/ListLayout.cpp 10 | userInterface/PositioningLayout.cpp 11 | userInterface/TextLayout.cpp 12 | userInterface/TextObject.cpp 13 | userInterface/InsideChecker.h 14 | userInterface/InsideSquareChecker.h 15 | userInterface/InsideSquareChecker.cpp 16 | userInterface/InsideRoundedSquareChecker.h 17 | userInterface/InsideRoundedSquareChecker.cpp 18 | userInterface/RelativeIHudDrawable.cpp 19 | 20 | ${BUBBA3D_FILES_SOURCE} 21 | PARENT_SCOPE) 22 | -------------------------------------------------------------------------------- /src/userInterface/Font.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-03-11. 19 | // 20 | 21 | #include 22 | #include 23 | #include FT_FREETYPE_H 24 | 25 | #include "Font.h" 26 | 27 | Font::GlyphData::GlyphData(int offsetX, FT_GlyphSlot ft_glyphSlot): 28 | advanceX(ft_glyphSlot->advance.x), 29 | advanceY(ft_glyphSlot->advance.y), 30 | bitmapWidth(ft_glyphSlot->bitmap.width), 31 | bitmapHeight(ft_glyphSlot->bitmap.rows), 32 | bitmapLeft(ft_glyphSlot->bitmap_left), 33 | bitmapTop(ft_glyphSlot->bitmap_top), 34 | offsetX(offsetX) 35 | { 36 | } 37 | 38 | Font::GlyphData Font::getCharacter(unsigned char character) { 39 | checkInvalidCharacter(character); 40 | return glyphs[character-32]; 41 | } 42 | 43 | void Font::checkInvalidCharacter(unsigned char character) { 44 | if(character < 32 || character >= 128) { 45 | throw std::invalid_argument("The font only support characters with" 46 | " ascii value from 32 inclusive to 128 exclusive."); 47 | } 48 | } 49 | 50 | void Font::addGlyph(FT_GlyphSlot glyph, int offsetX, unsigned char character) { 51 | checkInvalidCharacter(character); 52 | glyphs[character-32] = GlyphData(offsetX,glyph); 53 | } 54 | 55 | int Font::getPixelSize() { 56 | return pixelSize; 57 | } 58 | 59 | Font::Font(int pixelSize) : pixelSize(pixelSize) { 60 | } 61 | -------------------------------------------------------------------------------- /src/userInterface/IHudDrawable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-03-12. 19 | // 20 | 21 | #include 22 | #include 23 | #include "IHudDrawable.h" 24 | 25 | void IHudDrawable::setRotation(float rotation) { 26 | this->rotation = rotation; 27 | } 28 | 29 | void IHudDrawable::setRelativePosition(chag::float3 position) { 30 | this->relativePosition = position; 31 | } 32 | 33 | void IHudDrawable::setCenterOffset(chag::float3 offset) { 34 | center = offset; 35 | } 36 | 37 | void IHudDrawable::setScale(chag::float2 scale) { 38 | this->scale = chag::make_vector(scale.x, scale.y, 1.0f); 39 | } 40 | -------------------------------------------------------------------------------- /src/userInterface/InsideChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-06-19. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_INSIDECHECKER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_INSIDECHECKER_H 23 | 24 | 25 | class InsideChecker { 26 | public: 27 | virtual bool isInside(int x, int y) = 0; 28 | }; 29 | 30 | 31 | #endif //SUPER_BUBBA_AWESOME_SPACE_INSIDECHECKER_H 32 | -------------------------------------------------------------------------------- /src/userInterface/InsideRoundedSquareChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-06-19. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_INSIDEGLSQUARECHECKER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_INSIDEGLSQUARECHECKER_H 23 | 24 | #include "InsideSquareChecker.h" 25 | 26 | class GLSquare; 27 | 28 | class InsideRoundedSquareChecker : public InsideSquareChecker { 29 | public: 30 | virtual bool isInside(int x, int y); 31 | InsideRoundedSquareChecker(int x, int y, int width, int height, int rctl, int rctr, int rcbr, int rcbl); 32 | 33 | protected: 34 | int rctl, rctr, rcbr, rcbl; 35 | }; 36 | 37 | 38 | #endif //SUPER_BUBBA_AWESOME_SPACE_INSIDEGLSQUARECHECKER_H 39 | -------------------------------------------------------------------------------- /src/userInterface/InsideSquareChecker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-06-19. 19 | // 20 | 21 | #include "InsideSquareChecker.h" 22 | 23 | InsideSquareChecker::InsideSquareChecker(int x, int y, int width, int height) 24 | : x(x), y(y), width(width), height(height) {} 25 | 26 | bool InsideSquareChecker::isInside(int x, int y) { 27 | return this->x <= x && this->y <= y && (this->x + width) > x && (this->y + height) > y; 28 | } -------------------------------------------------------------------------------- /src/userInterface/InsideSquareChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | // 18 | // Created by simon on 2016-06-19. 19 | // 20 | 21 | #ifndef SUPER_BUBBA_AWESOME_SPACE_INSIDESQUARECHECKER_H 22 | #define SUPER_BUBBA_AWESOME_SPACE_INSIDESQUARECHECKER_H 23 | 24 | #include "InsideChecker.h" 25 | 26 | class InsideSquareChecker : public InsideChecker { 27 | public: 28 | InsideSquareChecker(int x, int y, int width, int height); 29 | virtual bool isInside(int x, int y); 30 | 31 | protected: 32 | int x,y,width,height; 33 | }; 34 | 35 | 36 | #endif //SUPER_BUBBA_AWESOME_SPACE_INSIDESQUARECHECKER_H 37 | -------------------------------------------------------------------------------- /src/userInterface/RelativeIHudDrawable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #include 19 | #include "RelativeIHudDrawable.h" 20 | #include "Camera.h" 21 | #include "GameObject.h" 22 | #include 23 | 24 | RelativeIHudDrawable::RelativeIHudDrawable(Camera* worldCamera, std::shared_ptr relativeTo, IHudDrawable *toDraw) : 25 | relativeTo(relativeTo), toDraw(toDraw), worldCamera(worldCamera) {} 26 | 27 | void RelativeIHudDrawable::render(std::shared_ptr shaderProgram, chag::float4x4 *projectionMatrix) { 28 | 29 | chag::float3 drawableRelativePosition = toDraw->relativePosition; 30 | chag::float4x4 screenPos = worldCamera->getProjectionMatrix() 31 | * worldCamera->getViewMatrix() 32 | * relativeTo->getModelMatrix(); 33 | 34 | int w = Globals::get(Globals::WINDOW_WIDTH); 35 | int h = Globals::get(Globals::WINDOW_HEIGHT); 36 | 37 | float x = (screenPos.c4.x / screenPos.c4.w + 1.0f) * w / 2.0f; 38 | float y = h - (screenPos.c4.y / screenPos.c4.w + 1.0f) * h / 2.0f; 39 | 40 | chag::float3 tempRelativeVector = drawableRelativePosition + chag::make_vector(roundf(x), -roundf(y), 0.0f); 41 | 42 | toDraw->relativePosition = tempRelativeVector; 43 | toDraw->render(shaderProgram, projectionMatrix); 44 | toDraw->relativePosition = drawableRelativePosition; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | set(COLLIDER_TEST_NAME Bubba3DTestCollider) 4 | set(OCTREE_TEST_NAME Bubba3DTestOctree) 5 | set(IS_INSIDE_TEST_NAME Bubba3DTestInside) 6 | set(SKELETAL_ANIMATION_TEST_NAME Bubba3DTestSkeletanAnimation) 7 | 8 | add_executable(${COLLIDER_TEST_NAME} collider_test.cpp) 9 | add_test(NAME TestSuiteCollider COMMAND ${COLLIDER_TEST_NAME}) 10 | target_include_directories (${COLLIDER_TEST_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/lib") 11 | target_link_libraries(${COLLIDER_TEST_NAME} LINK_PUBLIC Bubba3D) 12 | 13 | add_executable(${OCTREE_TEST_NAME} octree_test.cpp) 14 | add_test(NAME TestSuiteOctree COMMAND ${OCTREE_TEST_NAME}) 15 | target_include_directories (${OCTREE_TEST_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/lib") 16 | target_link_libraries(${OCTREE_TEST_NAME} LINK_PUBLIC Bubba3D) 17 | 18 | add_executable(${IS_INSIDE_TEST_NAME} is_inside_test.cpp) 19 | add_test(NAME TestSuiteIsInside COMMAND ${IS_INSIDE_TEST_NAME}) 20 | target_include_directories (${IS_INSIDE_TEST_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/lib") 21 | target_link_libraries(${IS_INSIDE_TEST_NAME} LINK_PUBLIC Bubba3D) 22 | 23 | add_executable(${SKELETAL_ANIMATION_TEST_NAME} skeletalAnimationTests.cpp) 24 | add_test(NAME TestSuiteIsSkeletalAnimation COMMAND ${SKELETAL_ANIMATION_TEST_NAME}) 25 | target_include_directories (${SKELETAL_ANIMATION_TEST_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/lib") 26 | target_link_libraries(${SKELETAL_ANIMATION_TEST_NAME} LINK_PUBLIC Bubba3D) 27 | 28 | # configure unit tests via CTest 29 | enable_testing() 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/skeletalAnimationTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Bubba-3D. 3 | * 4 | * Bubba-3D is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Bubba-3D is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with Bubba-3D. If not, see http://www.gnu.org/licenses/. 16 | */ 17 | 18 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file 19 | 20 | #include 21 | #include "catch.hpp" 22 | 23 | TEST_CASE("SmokeTestAddingBones", "[Skeletal]") { 24 | BoneInfluenceOnVertex boneData; 25 | boneData.addBoneData(1, 3); 26 | } 27 | 28 | TEST_CASE("AddingMoreThanMaxBones", "[Skeletal]") { 29 | BoneInfluenceOnVertex boneData; 30 | try { 31 | for (int i = 0; i < MAX_NUM_BONES + 1; i++) { 32 | boneData.addBoneData(i, i + 1); 33 | } 34 | } catch (const std::exception& exception) { 35 | REQUIRE(true); 36 | return; 37 | } 38 | REQUIRE(false); 39 | } 40 | 41 | TEST_CASE("AddingManyBones", "[Skeletal]") { 42 | BoneInfluenceOnVertex boneData; 43 | for (int i = 0; i < MAX_NUM_BONES; i++) { 44 | boneData.addBoneData(i , i + 1); 45 | REQUIRE(boneData.ids[i] == i ); 46 | REQUIRE(boneData.weights[i] == i + 1); 47 | } 48 | } 49 | 50 | TEST_CASE("CheckZeroInitiatedWeights", "[Skeletal]") { 51 | BoneInfluenceOnVertex boneData; 52 | for (int i = 0; i < MAX_NUM_BONES; i++) { 53 | REQUIRE(boneData.weights[i] == 0); 54 | } 55 | } 56 | 57 | 58 | --------------------------------------------------------------------------------