mirror of
https://github.com/eliasstepanik/FluidSimulation.git
synced 2026-01-10 04:58:30 +00:00
Added Config.json
This commit is contained in:
parent
f50dd3be04
commit
0e87a7e15d
7
PixelEngine/Config.cs
Normal file
7
PixelEngine/Config.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace PixelEngine;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public List<Density> Densities { get; set; }
|
||||
public List<Velocity> Velocities { get; set; }
|
||||
}
|
||||
62
PixelEngine/Config.json
Normal file
62
PixelEngine/Config.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"Densities":[
|
||||
{
|
||||
"x":64,
|
||||
"y":64,
|
||||
"amount":200
|
||||
}
|
||||
],
|
||||
"Velocities":[
|
||||
{
|
||||
"x":32,
|
||||
"y":64,
|
||||
"amountX":0.1,
|
||||
"amountY":-0.1
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":64,
|
||||
"amountX":-0.1,
|
||||
"amountY":0.1
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":32,
|
||||
"amountX":0.1,
|
||||
"amountY":0.1
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":96,
|
||||
"amountX":-0.1,
|
||||
"amountY":-0.1
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
"x":64,
|
||||
"y":64,
|
||||
"amountX":0.1,
|
||||
"amountY":-0.1
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":64,
|
||||
"amountX":-0.1,
|
||||
"amountY":0.1
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":64,
|
||||
"amountX":0.1,
|
||||
"amountY":0.1
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":64,
|
||||
"amountX":-0.1,
|
||||
"amountY":-0.1
|
||||
}
|
||||
]
|
||||
}
|
||||
8
PixelEngine/Density.cs
Normal file
8
PixelEngine/Density.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace PixelEngine;
|
||||
|
||||
public class Density
|
||||
{
|
||||
public int x { get; set; }
|
||||
public int y{ get; set; }
|
||||
public float amount { get; set; }
|
||||
}
|
||||
@ -77,7 +77,8 @@ public class Fluid
|
||||
}
|
||||
}
|
||||
|
||||
public void renderD() {
|
||||
public void renderD()
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
int x = i * scale;
|
||||
@ -211,11 +212,11 @@ public class Fluid
|
||||
|
||||
if (x < 0.5f) x = 0.5f;
|
||||
if (x > Nfloat + 0.5f) x = Nfloat + 0.5f;
|
||||
i0 = RayMath.floorf(x);
|
||||
i0 = floorf(x);
|
||||
i1 = i0 + 1.0f;
|
||||
if (y < 0.5f) y = 0.5f;
|
||||
if (y > Nfloat + 0.5f) y = Nfloat + 0.5f;
|
||||
j0 = RayMath.floorf(y);
|
||||
j0 = floorf(y);
|
||||
j1 = j0 + 1.0f;
|
||||
|
||||
s1 = x - i0;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using static Raylib_CsLo.Raylib;
|
||||
using static Raylib_CsLo.RayGui;
|
||||
using Raylib_CsLo;
|
||||
@ -7,8 +8,8 @@ namespace PixelEngine;
|
||||
|
||||
public class Game
|
||||
{
|
||||
private const int Size = 256;
|
||||
private const int Scale = 2;
|
||||
private const int Size = 128;
|
||||
private const int Scale = 7;
|
||||
private const int Iter = 10;
|
||||
private const float Dt = 0.2f;
|
||||
private const float Diffusion = 0f;
|
||||
@ -27,12 +28,26 @@ public class Game
|
||||
|
||||
InitWindow(Size * Scale, Size * Scale, WindowTitle);
|
||||
SetTargetFPS(TargetFps);
|
||||
|
||||
}
|
||||
|
||||
public void HandleInput()
|
||||
{
|
||||
|
||||
var config = JsonConvert.DeserializeObject<Config>(File.ReadAllText("Config.json"));
|
||||
|
||||
foreach (var configVelocity in config.Velocities)
|
||||
{
|
||||
DrawCircle(configVelocity.x * Scale, configVelocity.y *Scale, 5, RED);
|
||||
DrawLine(configVelocity.x * Scale,configVelocity.y *Scale, (int) ((configVelocity.x * Scale) + (configVelocity.amountX)),(int) ((configVelocity.y * Scale) + (configVelocity.amountY)), RED);
|
||||
_fluid.addVelocity(configVelocity.x, configVelocity.y, configVelocity.amountX, configVelocity.amountY);
|
||||
}
|
||||
|
||||
foreach (var configDensity in config.Densities)
|
||||
{
|
||||
_fluid.addDensity(configDensity.x, configDensity.y, configDensity.amount);
|
||||
}
|
||||
|
||||
// Add Density
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
@ -61,7 +76,7 @@ public class Game
|
||||
PMouse = GetMousePosition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -9,7 +9,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Raylib-CsLo" Version="4.2.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Config.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
10
PixelEngine/Velocity.cs
Normal file
10
PixelEngine/Velocity.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace PixelEngine;
|
||||
|
||||
public class Velocity
|
||||
{
|
||||
public int x { get; set; }
|
||||
public int y { get; set; }
|
||||
public float amountX { get; set; }
|
||||
public float amountY { get; set; }
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user