Skip to content

zer0nim/mod1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mod1 [42 project]

demo

🌊 Project

A simple water flow simulation over a terrain.

The project is fully written in C++ with the OpenGL framework.

💻 Installation

You need CMake 3.13 or above

git clone --recursive https://github.com/zer0nim/mod1
cd mod1
mkdir build && cd build
cmake ..
make

🚀 Usage

The program uses at least one map file as input. The file contains some points height to define were the Terrain should pass. You can view some example maps format in the asset/map folder.

usage: ./mod1 <map1.mod1> <map2.mod1> ...
./mod1 asset/map/example1.mod1 asset/map/example2.mod1 asset/map/example3.mod1 asset/map/example4.mod1

If you want, you can edit some settings (resolution, keys, ...). After starting the program at least once, modify the configs/settings.json and/or configs/controls.json files.

Wave demo

demo wave 1 demo wave 2

Sandbox demo, add water were you want

demo sandbox

Drain demo, water is drained from the ground below a certain height

demo drain

📔 References

Water flow simulation

For the water simulation, I used the Pipe Method. Only the water surface is represented with a height field, modeling the flow between adjacent columns of fluid by using a system of virtual pipe connection.

Large-Scale Water Simulation in Games. Kellomäki, Timo (2015)

Real-Time Fluid Simulation Using Height Fields, Bálint Miklós, Advisor Dr. Matthias Müller, Prof Dr, Markus Gross, Eth Zürich

Dynamic Simulation of Splashing Fluids, James F. O’Brien and Jessica K. Hodgins

Terrain interpolation

The Terrain is represented by a height field, the terrain should cross some points defined by a map file (example in the asset/map folder). Then I interpolate the other points by using an Inverse Distance Weighting Interpolation algorithm.

Terrain/water rendering

I render the terrain and water height field using a single OpenGL triangle strip. triangle strip to render surface, Kevin

The water use the skybox environment mapping to simulate reflection.

learnopengl.com cubemaps, Joey de Vries

Mouse Picking with Ray Casting

For the sandbox simulation, I used raycast to detect were to put water in the ground. OpenGL 3D Mouse Picking Tutorial, ThinMatrix Mouse Picking with Ray Casting, Anton Gerdelan

About

A simple water flow simulation over a terrain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages