a minimalistic engine for:
- Physical simulations
- Numerical math
- Game development
- Computer graphics
- Educational purposes
- Computational core is written in C/C++11. It should have no dependencies on external libraries. Even C++STL is avoided where possible. Attempt is made to optimize simultanously run-time speed, code length, compilation time, and interal interdependece of modules. In that respect especially tradeoffs for using templates and class hierarchies are considered.
- C/C++ part is compiled using CMake 2.8 and tested with gcc 5.4.0 on Ubunt 16.04. Code::Blocks project is generated by
cmake .. -G "CodeBlocks - Unix Makefiles"
. There are several CMake projects for different parts which differ in dependencies - Standalone apps, games and demos use SDL2 and OpenGL 1.2 and 4.0 for Graphical user interface. Some other dependencies (e.g. SDL2-net, SDL2-image, SDL2-ttf) may be added to particular build target but are not required globaly.
- There is stand allone set GPU accelerated simulations using OpenCL
- Some apps use embeded Lua3.2 for scripting, but it is not globally required.
- Python 2.7 + numpy + matplotlib is used to make convenient science/engineering packeges partialy wrappaing the C/C++ core libraries.
- In addition there are some documents using iPython (Jupyter) and javascript+WebGL for rendering interactive 3D graphics and editors of glsl shaders on web. These are independent on the rest.
- tested on Ubunu 16.04 64bit)
- make sure you have installed
gcc >=5.4.0
,CMake >2.8
,libglew-dev
,SDL2-dev
- got to
cpp/Builds/sketches_SDL/
create subdirectoryBuild
- from
cpp/Builds/sketches_SDL/Build
generate makefiles bycmake .. -G "CodeBlocks - Unix Makefiles"
- in the same directory compile the project
make
. The compiled binaris are stored incpp/Build
- you may also load Code::Blocks project
cpp/Builds/sketches_SDL/SimpleSimulationEngine.cbp
and compile particular build target from Code::Blocks - If
cmake
ormake
fails due to some dependencies, you may try compile just part of the project (e.g.cpp/Build/libs
) which has less dependencies - you may also remove problematic build targets by commenting out particular parts of
CMakeFile.txt
- If you were able to compile
sketches_SDL
you may try compile applications and games incpp/Builds/apps/
or the whole project in the same way just incpp/Builds/all/
(you will needliblua5.2-dev
andlibtolua5.2-dev
) - You may try compile OpenCL demos in
cpp/Build/sketches_OCL
in the same way. This will require properly installed GPU drivers and opencl libraris. These are platform dependent. Personally I tested withnvidia-opencl-dev
.- Note: be very carefull when installing GPU drivers on linux, ou can easily brak the system (I did 3 times). In my case
nvidia-opencl-dev
installed dependecieslibcuda-378 nvidia-378 nvidia-opencl-icd-378 nvidia-prime nvidia-settings opencl-headers
. I also addednvidia-modprobe
. When you break your system this make help:there are many guides for installing GPU drivers on linux. I found particularily helpfull and working this onesudo apt-get autoremove --purge nvidia-* sudo stop lightdm sudo apt-get install xserver-xorg-video-nouveau
- Note: be very carefull when installing GPU drivers on linux, ou can easily brak the system (I did 3 times). In my case
This is work in progress. Often particular modules of the engine are functional, but they are not put together to build an unified system and work together.
-
- 2d vector, 3d vector, 3x3 matrix, 4x4 matrix, Quaternions
- Fast math rutines with approximations of some functions ( e.g. goniometry, Error function ... )
- Functions with derivatives ( like tresholds and sigmoides, and Lorenzieans etc. )
- Composing of complicated 1D,2D,3D functions from simple primitives with analytic gradients
- Splines in 1D, 2D 3D, e.g. cubic hermite spline (other splines needs to be systematized)
- [Simplex noise] (cpp/common/math/Noise.h)
- Basic linear algebra ( matrix multiplication, transpose, GaussJordan solver, Biconjugate gradinet iterative solver, Fitting, Jacobi matrix diagonalization), and N-dimensional vectors
- Minimalistic Fourier transform, with FFT for
$2^N$ elemetns
-
Math solvers
- Brent line search
- Stochastic optimization
- iterative non-linear gradient based optimization using FIRE (faster and more robust CG, comparable and sometimes better than BFGS)
- Variable step ODE integrator by Runge–Kutta–Fehlberg
-
Computational Geometry
- Basic 2d and 3d shapes computational geometry, ray tracing, Covex polygons, polygon Mesh and regular polyhedra
-
Spatial datastructures - This needs cleanup, there is too many duplicite methods/versions. Especially, Rulers should be splited from data.
- Various methos for acceleration of local interactions and nearest neighbor search e.g. HashMap, nD BoundigSphere hierarchy, and grids.
- Various grids (trinagular, rectangular, cubic, and triclinc )
- Some maps suport raymarching/rasterization e.g. trinagular and cubic
-
Physical simulations
- Rigid-Body dynamics in 2D and 3D - with application in RigidBody molecular dynamics, Flight dynamics and vehicle on tarrain, and Sailing
- SoftBody dynamics with Truss simulation (e.g. for something like BridgeBuilder)
- Molecular mechanics used there
- simulation of hydraulic errosion for terrain generation
-
GUI and interfaces
-
Graphics
- OpenGL 1.2/2
- OpenGL 3+
- Examples of Rendering meshes, rendering to texture, instances, bilboards
- ScreenSpace ambient occlusion
- Ray-Traced analytic primitives e.g. Spherical atoms
- Ray-Marching of analytical functions e.g. molecular orbitals.
- TODO: (in-shader Constructive solid geometry CGS)
- Terrain rendering from heightmap texture with logaritmic depth buffer for large scenes
- Angularly sensitive bilboards (impostors) for rendering Vegetation and clouds
-
Apps and Games
- Molecular editors with Rigid Body Molecular dynamics (coarse grained=>faster, no need for intramoleculer forcefiel) with python interface, and normal Soft Body Molecular mechanics
- 3D subsonic aircraft combat simulator
- 2D Sail-ships simulator with multiplayer and battleship simulator
- Land-Combat tactical simulator simulator for WWII and modern era
- 3D Tank simulator
- 2D historical battle simulator (TotalWar like) with large army (~30000 soldiers)
- Realistic Spaceship desing and simulation game
- multipole expansion
- fast multipole method or FFT for long range interactions
- Global optimization algorithms for molecular simulation
- easy to use generic rendering and physical engine for games (with scene graph) which goes together seamlessly
- pyMolecular - Rigid Body Molecular dynamics (test)
- pyRay - real-time Constructive Solid Geometry by ray-marching on GPU using pyOpenCL
- pySimE - Physics and chemistry suite with many useful functions
- Pure python
- enumeration of chemical reactions and calculation of entalpy bilance
- Comparison of performance for various spacecraft propulsion
- Using C++ libraries
- Trajectory of electron in electromagnetic field generated by arbitrary shape of coil
- phenomenological calculation of nuclar bomb yield by time propagation of rate equations in 0D.
- N-body simulations of planet orbits using RKF45
- Simulation of Rocket launch from plant surface (considering also aerodynamic drag)
- Pure python
- pyShock time propagation shockwaves in 1D (planar, cylinrical or spherical symmetry) - e.g. for implosion of nuclear bombs (WIP)
projects using HTML + Javascritp + WebGL + THREE.js and/or Python Jupyter.nb
-
SpaceCombat - ideas about combat in solar system supported by physical calculations in python (Jupyter.nb) (see example and 3D graphics (WebGL+Three.js) - it is strongly inspired by Project Rho: Atomic rockets
-
Web interfaces for building fragment shaders inspired by ShaderToy
- RayTraced analytical primitives for other shaders
- PlanetDesigner - web interface for building glsl fragment shaders for procedural generation and rendering of planets seen from space
- ShaderDebug - debuging domain wraping functions used for procudural generation of other shaders
Main motivation is to assemble various common algorithma from physics, numerical mathematics, computer graphics and computer science and build minimalistic tools for rapid development of physical simulation programs and games.
It should be:
- Didactic - user is expected to be able to understand how things works inside ( i.e. it should not be a blackbox ). The code sould document intself (without much comment strings or external doc).
- Focused on development of small programs ( like sketches/demos )
- Each particular part of the engine should be illustrated by simplistic example / demo
- Minimal dependencies on 3rd party libraries.
- Minimalized inter-dependencies between different modules within the engine. Many modules are designed to work independently, and be easily plugged into other projects
- often just as header files (
.h
)
- often just as header files (
- No compicated instalation procedures required
- It is rather a set of tools and pre-programed code samples rather than enclosed package
- It does not follow rigorous Object Oriented Programing paradigma and other good practices of software enginering common in large projects. Especially encapsulation resp. information hiding is avoided (everything is
public
), since otherwise it would lead to huge boiler-plate code (.get()
and.set()
) and limited or tedious user extensions. - User is expected and ecouraged to modify the code (including core parts) to match requirements of his particular project. It should be more a starting point of further development rather than final product.
- C++11 is used in pragmatic way, not ideologically.
- E.g. pass by reference,
templates
andlambda
expressions are used for programming convenience and computational performance. - At the same time old-schoop C is often prefered:
printf
is used instead ofstd:iostrem
char*
instead ofstring
- raw pointers
double*
for arrays instead ofstd:vector
or smart pointers
- E.g. pass by reference,