Compare commits
26 commits
4992a39ba0
...
4ae3e435bd
Author | SHA1 | Date | |
---|---|---|---|
4ae3e435bd | |||
b5cae879a6 | |||
b7d508b7a0 | |||
c434d7f866 | |||
724bc153be | |||
04c35d6107 | |||
25faa58e35 | |||
adcf0960b6 | |||
232edb1b41 | |||
3a81917a24 | |||
064f5c3254 | |||
b0414df2d1 | |||
d15cb8e093 | |||
ebef28435b | |||
21f619b607 | |||
25829de17b | |||
784364e23d | |||
22d7a22fd1 | |||
c87a7ab183 | |||
12ae8adca6 | |||
705614909b | |||
82eefebb7c | |||
c9889b50d2 | |||
c46be74112 | |||
cf12207557 | |||
6e82ae9955 |
7 changed files with 205 additions and 45 deletions
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
Binary file not shown.
|
@ -20,6 +20,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="StereoKit" Version="0.3.9" />
|
<PackageReference Include="StereoKit" Version="0.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
125
src/Arts.cs
125
src/Arts.cs
|
@ -9,6 +9,7 @@ static class Arts
|
||||||
static Dictionary<string, Mesh> meshes = new();
|
static Dictionary<string, Mesh> meshes = new();
|
||||||
static Material mat_mono = new Material("mono.hlsl");
|
static Material mat_mono = new Material("mono.hlsl");
|
||||||
static Material mat_unlit = new Material("unlit.hlsl");
|
static Material mat_unlit = new Material("unlit.hlsl");
|
||||||
|
static Material mat_add = new Material("unlit.hlsl");
|
||||||
static Material mat_both = new Material("unlit.hlsl");
|
static Material mat_both = new Material("unlit.hlsl");
|
||||||
static Material mat_backface = new Material("backface.hlsl");
|
static Material mat_backface = new Material("backface.hlsl");
|
||||||
static Material mat_justcolor = new Material("justcolor.hlsl");
|
static Material mat_justcolor = new Material("justcolor.hlsl");
|
||||||
|
@ -52,11 +53,15 @@ static class Arts
|
||||||
}
|
}
|
||||||
|
|
||||||
text_style = TextStyle.FromFont(
|
text_style = TextStyle.FromFont(
|
||||||
Font.FromFile("Staatliches.ttf"),
|
Font.FromFile("Assets/Staatliches.ttf"),
|
||||||
1.0f * U.cm,
|
1.0f * U.cm,
|
||||||
Color.White
|
Color.White
|
||||||
);
|
);
|
||||||
|
|
||||||
|
mat_add.Transparency = Transparency.Add;
|
||||||
|
mat_add.DepthTest = DepthTest.LessOrEq;
|
||||||
|
mat_add.DepthWrite = false;
|
||||||
|
|
||||||
mat_backface.FaceCull = Cull.Front;
|
mat_backface.FaceCull = Cull.Front;
|
||||||
mat_backface.Transparency = Transparency.Add;
|
mat_backface.Transparency = Transparency.Add;
|
||||||
mat_backface.DepthTest = DepthTest.LessOrEq;
|
mat_backface.DepthTest = DepthTest.LessOrEq;
|
||||||
|
@ -67,6 +72,10 @@ static class Arts
|
||||||
mat_slash.FaceCull = Cull.None;
|
mat_slash.FaceCull = Cull.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [!] hacky offset stepper for noise
|
||||||
|
public static int offset = 0;
|
||||||
|
static int offstep() => offset += 100;
|
||||||
|
|
||||||
public static void Frame()
|
public static void Frame()
|
||||||
{
|
{
|
||||||
// Input.HandVisible(Handed.Max, false);
|
// Input.HandVisible(Handed.Max, false);
|
||||||
|
@ -75,30 +84,46 @@ static class Arts
|
||||||
Matrix m4_world = Mono.world_pose.ToMatrix();
|
Matrix m4_world = Mono.world_pose.ToMatrix();
|
||||||
Hierarchy.Push(m4_world);
|
Hierarchy.Push(m4_world);
|
||||||
|
|
||||||
// mesh test
|
// ground
|
||||||
meshes["_dmg"].Draw(
|
meshes["circle"].Draw(
|
||||||
mat_mono,
|
mat_unlit,
|
||||||
Matrix.TRS(
|
Matrix.TRS(
|
||||||
V.XYZ(0, 0, -1),
|
V.XYZ(0, 0, 0),
|
||||||
Quat.Identity,
|
Quat.Identity,
|
||||||
0.1f
|
12.0f
|
||||||
)
|
),
|
||||||
|
Color.Hex(0x808080FF).ToLinear()
|
||||||
);
|
);
|
||||||
|
|
||||||
// bamboo
|
// bamboo
|
||||||
for (int i = -12; i <= 12; i++)
|
offset = 0;
|
||||||
|
int s_len = 24;
|
||||||
|
for (int i = -s_len; i <= s_len; i++)
|
||||||
{
|
{
|
||||||
float z_offset = Noise.s_scalar_x(i) * 2.0f;
|
Quat q = Quat.FromAngles(0, i * 3, 0);
|
||||||
float x_offset = Noise.s_scalar_x(i + 32) * 0.2f;
|
Vec3 pos = q * V.XYZ(0, 0, -10 + (Maths.smooth_stop(Noise.u_scalar_x(i + s_len * 2)) * 5));
|
||||||
float x_wind = Maths.smooth_stop(Maths.u_scalar(SKMath.Sin((i * 0.16f) - Time.Totalf)));
|
// float z_offset = Noise.s_scalar_x(i + 32) * 2.0f;
|
||||||
|
float x_offset = Noise.s_scalar_x(i + s_len * 4) * 0.2f;
|
||||||
|
float x_wind = Maths.smooth_stop(Maths.u_scalar(SKMath.Sin((pos.x * 0.5f) - Time.Totalf)));
|
||||||
Vec3[] p = new Vec3[] {
|
Vec3[] p = new Vec3[] {
|
||||||
V.XYZ(i * 0.3f, 0, -10 + z_offset),
|
pos + V.XYZ(0, 0, 0),
|
||||||
V.XYZ(i * 0.3f, 1, -10 + z_offset),
|
pos + V.XYZ(0, 1, 0),
|
||||||
|
|
||||||
V.XYZ(i * 0.3f, 4, -10 + z_offset),
|
pos + V.XYZ(0, 4, 0),
|
||||||
V.XYZ(i * 0.3f + x_offset + x_wind, 5, -10 + z_offset),
|
pos + V.XYZ(x_offset + x_wind, 5, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (Noise.u_scalar < 0.1f * Time.Stepf)
|
||||||
|
{
|
||||||
|
VFX.Leaf(p[3]);
|
||||||
|
// static float fall_timer = 0.0f;
|
||||||
|
// fall_timer -= Time.Stepf;
|
||||||
|
// if (fall_timer <= 0.0f)
|
||||||
|
// {
|
||||||
|
// fall_timer = 1.0f;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// debug bezier points
|
// debug bezier points
|
||||||
// for (int i = 0; i < p.Length; i++)
|
// for (int i = 0; i < p.Length; i++)
|
||||||
// {
|
// {
|
||||||
|
@ -123,7 +148,7 @@ static class Arts
|
||||||
// );
|
// );
|
||||||
|
|
||||||
int steps = 92;
|
int steps = 92;
|
||||||
Vec3 pastPos = p[0];
|
Vec3 pastPoint = p[0];
|
||||||
float pastThc = 0.0f;
|
float pastThc = 0.0f;
|
||||||
for (int j = 0; j < steps; j++)
|
for (int j = 0; j < steps; j++)
|
||||||
{
|
{
|
||||||
|
@ -131,17 +156,39 @@ static class Arts
|
||||||
Vec3 a = Vec3.Lerp(p[0], p[1], t);
|
Vec3 a = Vec3.Lerp(p[0], p[1], t);
|
||||||
Vec3 b = Vec3.Lerp(p[1], p[2], t);
|
Vec3 b = Vec3.Lerp(p[1], p[2], t);
|
||||||
Vec3 c = Vec3.Lerp(p[2], p[3], t);
|
Vec3 c = Vec3.Lerp(p[2], p[3], t);
|
||||||
Vec3 pos = Vec3.Lerp(Vec3.Lerp(a, b, t), Vec3.Lerp(b, c, t), t);
|
Vec3 point = Vec3.Lerp(Vec3.Lerp(a, b, t), Vec3.Lerp(b, c, t), t);
|
||||||
float thc = (1.0f + Maths.precision((1.0f - t), Maths.lerp(0.1f, 0.2f, Noise.u_scalar_x(i))) * 2.0f) * U.cm * 6.0f;
|
float thc = (1.0f + Maths.precision((1.0f - t), Maths.lerp(0.1f, 0.2f, Noise.u_scalar_x(i))) * 2.0f) * U.cm * 6.0f;
|
||||||
Lines.Add(
|
Lines.Add(
|
||||||
pastPos,
|
pastPoint,
|
||||||
pos,
|
point,
|
||||||
thc != pastThc ? Color.Hex(0x959493FF).ToLinear() : Color.Hex(0xB9E7AFFF).ToLinear(),
|
thc != pastThc ? Color.Hex(0x959493FF).ToLinear() : Color.Hex(0xB9E7AFFF).ToLinear(),
|
||||||
thc
|
thc
|
||||||
);
|
);
|
||||||
pastPos = pos;
|
pastPoint = point;
|
||||||
pastThc = thc;
|
pastThc = thc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// leaves
|
||||||
|
for (int j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
meshes["leaf"].Draw(
|
||||||
|
mat_unlit,
|
||||||
|
Matrix.TRS(
|
||||||
|
p[3] + Quat.LookAt(p[3], p[2], Vec3.Right) * V.XYZ(
|
||||||
|
Noise.s_scalar_x(j + offstep()),
|
||||||
|
Noise.s_scalar_x(j + offstep()),
|
||||||
|
Noise.s_scalar_x(j + offstep()) * 3
|
||||||
|
) * 0.2f,
|
||||||
|
(
|
||||||
|
Quat.FromAngles(Noise.s_scalar_x(j + offstep()) * 180f, 0, 0) *
|
||||||
|
Quat.FromAngles(0, Noise.s_scalar_x(j + offstep()) * 180f, 0) *
|
||||||
|
Quat.FromAngles(0, 0, Noise.s_scalar_x(j + offstep()) * 180f)
|
||||||
|
),
|
||||||
|
0.1f
|
||||||
|
),
|
||||||
|
Color.Hex(0xBAE8B0FF).ToLinear()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unit cube
|
// unit cube
|
||||||
|
@ -234,10 +281,8 @@ static class Arts
|
||||||
),
|
),
|
||||||
Color.White
|
Color.White
|
||||||
);
|
);
|
||||||
if (Rig.btn_select.state)
|
|
||||||
{
|
|
||||||
VFX.Play(min_hit_pos);
|
VFX.Play(min_hit_pos);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,10 +343,9 @@ static class Arts
|
||||||
}
|
}
|
||||||
|
|
||||||
// particles
|
// particles
|
||||||
Particle[] particles = VFX.particles;
|
for (int i = 0; i < VFX.ps.count; i++)
|
||||||
for (int i = 0; i < particles.Length; i++)
|
|
||||||
{
|
{
|
||||||
Particle particle = particles[i];
|
Particle particle = VFX.ps.particles[i];
|
||||||
Mesh.Sphere.Draw(
|
Mesh.Sphere.Draw(
|
||||||
mat_unlit,
|
mat_unlit,
|
||||||
Matrix.TRS(
|
Matrix.TRS(
|
||||||
|
@ -312,6 +356,35 @@ static class Arts
|
||||||
Color.Hex(0xC75A09FF).ToLinear()
|
Color.Hex(0xC75A09FF).ToLinear()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < VFX.leafs.count; i++)
|
||||||
|
{
|
||||||
|
Particle particle = VFX.leafs.particles[i];
|
||||||
|
meshes["leaf"].Draw(
|
||||||
|
mat_unlit,
|
||||||
|
Matrix.TRS(
|
||||||
|
particle.pos,
|
||||||
|
particle.ori,
|
||||||
|
particle.scl
|
||||||
|
),
|
||||||
|
Color.Hex(0xBAE8B0FF).ToLinear()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < VFX.ripples.count; i++)
|
||||||
|
{
|
||||||
|
Particle particle = VFX.ripples.particles[i];
|
||||||
|
if (particle.state.state)
|
||||||
|
{
|
||||||
|
meshes["ripple"].Draw(
|
||||||
|
mat_add,
|
||||||
|
Matrix.TRS(
|
||||||
|
particle.pos,
|
||||||
|
particle.ori,
|
||||||
|
particle.scl
|
||||||
|
),
|
||||||
|
particle.col.ToLinear()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Hierarchy.Pop();
|
Hierarchy.Pop();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ static class Mono
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
game_time = 0.0;
|
game_time = 0.0;
|
||||||
world_pose = new(0, -1, -2);
|
world_pose = new(0, 0, 0);
|
||||||
menu = new(false);
|
menu = new(false);
|
||||||
menu_pose = new(0, 0, 0);
|
menu_pose = new(0, 0, 0);
|
||||||
menu_scale = 1 * U.cm;
|
menu_scale = 1 * U.cm;
|
||||||
|
@ -60,8 +60,10 @@ static class Mono
|
||||||
}
|
}
|
||||||
|
|
||||||
// flatscreen dev controls
|
// flatscreen dev controls
|
||||||
if (Device.Name == "Simulator")
|
if (Device.DisplayType == DisplayType.Flatscreen)// Device.Name == "Simulator")
|
||||||
{
|
{
|
||||||
|
world_pose = new(0, -1, -2);
|
||||||
|
|
||||||
if (Input.Key(Key.MouseCenter).IsActive())
|
if (Input.Key(Key.MouseCenter).IsActive())
|
||||||
{
|
{
|
||||||
float sx = Input.Mouse.posChange.x;
|
float sx = Input.Mouse.posChange.x;
|
||||||
|
|
|
@ -22,7 +22,8 @@ class Program
|
||||||
disableFlatscreenMRSim = true,
|
disableFlatscreenMRSim = true,
|
||||||
renderScaling = 2,
|
renderScaling = 2,
|
||||||
renderMultisample = 0,
|
renderMultisample = 0,
|
||||||
// mode = AppMode.Simulator,
|
|
||||||
|
// displayPreference = DisplayMode.Flatscreen
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!SK.Initialize(settings))
|
if (!SK.Initialize(settings))
|
||||||
|
|
|
@ -27,7 +27,7 @@ static class Rig
|
||||||
head = Input.Head;
|
head = Input.Head;
|
||||||
|
|
||||||
// flatscreen dev controls
|
// flatscreen dev controls
|
||||||
if (Device.Name == "Simulator")
|
if (Device.DisplayType == DisplayType.Flatscreen)// Device.Name == "Simulator")
|
||||||
{
|
{
|
||||||
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
||||||
btn_back.Step(Input.Key(Key.MouseRight).IsActive());
|
btn_back.Step(Input.Key(Key.MouseRight).IsActive());
|
||||||
|
|
104
src/VFX.cs
104
src/VFX.cs
|
@ -5,23 +5,23 @@ namespace slash;
|
||||||
|
|
||||||
static class VFX
|
static class VFX
|
||||||
{
|
{
|
||||||
public static Particle[] particles = new Particle[64];
|
public static ParticleSystem ps = new(64);
|
||||||
static int index = 0;
|
public static ParticleSystem leafs = new(64);
|
||||||
|
public static ParticleSystem ripples = new(64);
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < particles.Length; i++)
|
ps.Init();
|
||||||
{
|
leafs.Init();
|
||||||
particles[i] = new();
|
ripples.Init();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Play(Vec3 pos)
|
public static void Play(Vec3 pos)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
index = (index + 1) % particles.Length;
|
ps.index = (ps.index + 1) % ps.count;
|
||||||
Particle particle = particles[index];
|
Particle particle = ps.particles[ps.index];
|
||||||
particle.pos = pos;
|
particle.pos = pos;
|
||||||
particle.vel = Quat.FromAngles(Noise.u_scalar * 360, 0, 0) * Quat.FromAngles(0, Noise.u_scalar * 360, 0) * Vec3.Forward * 3.0f;
|
particle.vel = Quat.FromAngles(Noise.u_scalar * 360, 0, 0) * Quat.FromAngles(0, Noise.u_scalar * 360, 0) * Vec3.Forward * 3.0f;
|
||||||
particle.ori = Quat.Identity;
|
particle.ori = Quat.Identity;
|
||||||
|
@ -29,11 +29,33 @@ static class VFX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Leaf(Vec3 pos)
|
||||||
|
{
|
||||||
|
leafs.index = (leafs.index + 1) % leafs.count;
|
||||||
|
Particle particle = leafs.particles[leafs.index];
|
||||||
|
particle.state.Step(true);
|
||||||
|
particle.pos = pos;
|
||||||
|
particle.vel = V.XYZ(0, 0, 0); // Quat.FromAngles(Noise.u_scalar * 360, 0, 0) * Quat.FromAngles(0, Noise.u_scalar * 360, 0) * Vec3.Forward * 3.0f;
|
||||||
|
particle.ori = Quat.FromAngles(Noise.s_scalar * 180, 0, 0) * Quat.FromAngles(0, Noise.s_scalar * 180, 0);
|
||||||
|
particle.scl = 0.1f; // (1.0f / 3) * Maths.smooth_start(Noise.u_scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Ripple(Vec3 pos)
|
||||||
|
{
|
||||||
|
ripples.index = (ripples.index + 1) % ripples.count;
|
||||||
|
Particle particle = ripples.particles[ripples.index];
|
||||||
|
particle.state.Step(true);
|
||||||
|
particle.pos = pos;
|
||||||
|
particle.vel = V.XYZ(0, 0, 0); // Quat.FromAngles(Noise.u_scalar * 360, 0, 0) * Quat.FromAngles(0, Noise.u_scalar * 360, 0) * Vec3.Forward * 3.0f;
|
||||||
|
particle.ori = Quat.Identity;
|
||||||
|
particle.scl = 0.1f; // (1.0f / 3) * Maths.smooth_start(Noise.u_scalar);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Frame()
|
public static void Frame()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < particles.Length; i++)
|
for (int i = 0; i < ps.count; i++)
|
||||||
{
|
{
|
||||||
Particle particle = particles[i];
|
Particle particle = ps.particles[i];
|
||||||
if (particle.vel.MagnitudeSq > float.Epsilon)
|
if (particle.vel.MagnitudeSq > float.Epsilon)
|
||||||
{
|
{
|
||||||
particle.pos += particle.vel * Time.Stepf;
|
particle.pos += particle.vel * Time.Stepf;
|
||||||
|
@ -52,20 +74,82 @@ static class VFX
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < leafs.count; i++)
|
||||||
|
{
|
||||||
|
Particle particle = leafs.particles[i];
|
||||||
|
particle.state.Step(particle.pos.y > 0);
|
||||||
|
if (particle.state.state)
|
||||||
|
{
|
||||||
|
particle.pos += particle.vel * Time.Stepf;
|
||||||
|
float x_wind = Maths.smooth_stop(Maths.u_scalar(SKMath.Sin((particle.pos.x * 0.5f) - Time.Totalf)));
|
||||||
|
particle.vel.x += x_wind * Time.Stepf;
|
||||||
|
particle.vel += Vec3.Up * -9.81f * 0.1f * Time.Stepf;
|
||||||
|
particle.ori = Quat.LookDir(particle.vel) * Quat.FromAngles(0, 0, 90);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
particle.pos.y = 0;
|
||||||
|
particle.vel = Vec3.Zero;
|
||||||
|
|
||||||
|
if (particle.state.delta == -1)
|
||||||
|
{
|
||||||
|
Ripple(particle.pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ripples.count; i++)
|
||||||
|
{
|
||||||
|
Particle particle = ripples.particles[i];
|
||||||
|
particle.state.Step(particle.scl < 1.0);
|
||||||
|
if (particle.state.state)
|
||||||
|
{
|
||||||
|
particle.scl += Time.Stepf;
|
||||||
|
float val = 1.0f - particle.scl;
|
||||||
|
particle.col = new Color(val, val, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Particle
|
public class Particle
|
||||||
{
|
{
|
||||||
|
public DeltaBool state;
|
||||||
public Vec3 pos, vel;
|
public Vec3 pos, vel;
|
||||||
public Quat ori;
|
public Quat ori;
|
||||||
public float scl;
|
public float scl;
|
||||||
|
public Color col;
|
||||||
|
|
||||||
public Particle()
|
public Particle()
|
||||||
{
|
{
|
||||||
|
this.state = new(false);
|
||||||
this.pos = Vec3.Zero;
|
this.pos = Vec3.Zero;
|
||||||
this.vel = Vec3.Zero;
|
this.vel = Vec3.Zero;
|
||||||
this.ori = Quat.Identity;
|
this.ori = Quat.Identity;
|
||||||
this.scl = 0.0f;
|
this.scl = 0.0f;
|
||||||
|
this.col = Color.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ParticleSystem
|
||||||
|
{
|
||||||
|
public Particle[] particles;
|
||||||
|
public int count;
|
||||||
|
public int index;
|
||||||
|
|
||||||
|
public ParticleSystem(int count)
|
||||||
|
{
|
||||||
|
this.particles = new Particle[count];
|
||||||
|
this.count = count;
|
||||||
|
this.index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < particles.Length; i++)
|
||||||
|
{
|
||||||
|
particles[i] = new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue