organizational ripples
This commit is contained in:
parent
a4e3285d77
commit
8308529340
4 changed files with 106 additions and 40 deletions
BIN
add/ripple.glb
Normal file
BIN
add/ripple.glb
Normal file
Binary file not shown.
Binary file not shown.
66
src/Mono.cs
66
src/Mono.cs
|
@ -7,10 +7,12 @@ public class Mono {
|
||||||
public PR.Noise noise = new PR.Noise(939949595);
|
public PR.Noise noise = new PR.Noise(939949595);
|
||||||
|
|
||||||
public Material matDev;
|
public Material matDev;
|
||||||
public Material matHoloframe = new Material(Shader.FromFile("above.hlsl"));
|
public Material matHoloframe = new Material(Shader.FromFile("shaders/above.hlsl"));
|
||||||
Material matHoloframeUnder = new Material(Shader.FromFile("below.hlsl"));
|
Material matHoloframeUnder = new Material(Shader.FromFile("shaders/below.hlsl"));
|
||||||
public Material matHolo = new Material(Shader.FromFile("above.hlsl"));
|
public Material matHoloclear = new Material(Shader.FromFile("shaders/above.hlsl"));
|
||||||
Material matHoloUnder = new Material(Shader.FromFile("below.hlsl"));
|
Material matHoloclearUnder = new Material(Shader.FromFile("shaders/below.hlsl"));
|
||||||
|
public Material matHolo = new Material(Shader.FromFile("shaders/above.hlsl"));
|
||||||
|
Material matHoloUnder = new Material(Shader.FromFile("shaders/below.hlsl"));
|
||||||
|
|
||||||
public Rig rig = new Rig();
|
public Rig rig = new Rig();
|
||||||
public Space space = new Space();
|
public Space space = new Space();
|
||||||
|
@ -61,6 +63,15 @@ public class Mono {
|
||||||
matHoloUnder.FaceCull = Cull.None;
|
matHoloUnder.FaceCull = Cull.None;
|
||||||
matHolo.Chain = matHoloUnder;
|
matHolo.Chain = matHoloUnder;
|
||||||
|
|
||||||
|
matHoloclear.SetColor("clearcolor", Color.Black);
|
||||||
|
matHoloclear.Transparency = Transparency.Add;
|
||||||
|
matHoloclear.DepthWrite = false;
|
||||||
|
matHoloclear.FaceCull = Cull.None;
|
||||||
|
matHoloclearUnder.SetColor("clearcolor", Color.Black);
|
||||||
|
matHoloclearUnder.Transparency = Transparency.Add;
|
||||||
|
matHoloclearUnder.DepthWrite = false;
|
||||||
|
matHoloclearUnder.FaceCull = Cull.None;
|
||||||
|
matHoloclear.Chain = matHoloclearUnder;
|
||||||
|
|
||||||
matHoloframe.SetColor("clearcolor", Color.Black);
|
matHoloframe.SetColor("clearcolor", Color.Black);
|
||||||
matHoloframe.Transparency = Transparency.Add;
|
matHoloframe.Transparency = Transparency.Add;
|
||||||
|
@ -81,11 +92,11 @@ public class Mono {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Spatial spatial = new Spatial();
|
Spatial spatial = new Spatial(new Vec3(-1, 0.76f, 0.666f));
|
||||||
Cursor cursor = new Cursor();
|
Cursor cursor = new Cursor();
|
||||||
Drawer drawerA = new Drawer(new Pose(new Vec3(-0.5f, 0.6f, -0.8f), Quat.Identity));
|
Drawer drawerA = new Drawer(new Pose(new Vec3(-0.8f, 0.6f, 1.4f), Quat.FromAngles(0, 90f, 0)));
|
||||||
Drawer drawerB = new Drawer(new Pose(new Vec3(0, 0.6f, -0.8f), Quat.Identity));
|
Drawer drawerB = new Drawer(new Pose(new Vec3(-0.8f, 0.6f, 0.95f), Quat.FromAngles(0, 90f, 0)));
|
||||||
Drawer drawerC = new Drawer(new Pose(new Vec3(0.5f, 0.6f, -0.8f), Quat.Identity));
|
Drawer drawerC = new Drawer(new Pose(new Vec3(-0.8f, 0.6f, 0.5f), Quat.FromAngles(0, 90f, 0)));
|
||||||
|
|
||||||
public void Frame() {
|
public void Frame() {
|
||||||
|
|
||||||
|
@ -93,6 +104,10 @@ public class Mono {
|
||||||
// Input.HandClearOverride(Handed.Right);
|
// Input.HandClearOverride(Handed.Right);
|
||||||
// store hand pre override in rig
|
// store hand pre override in rig
|
||||||
rig.Step();
|
rig.Step();
|
||||||
|
Hand h = Input.Hand(Handed.Right);
|
||||||
|
if (h.pinch.IsActive()) {
|
||||||
|
Console.WriteLine($"{h.pinchPt}, {Input.Head.orientation * -Vec3.Forward}");
|
||||||
|
}
|
||||||
|
|
||||||
// Hand hand = Input.Hand(Handed.Right);
|
// Hand hand = Input.Hand(Handed.Right);
|
||||||
// Controller con = Input.Controller(Handed.Right);
|
// Controller con = Input.Controller(Handed.Right);
|
||||||
|
@ -201,8 +216,8 @@ public class Mono {
|
||||||
}
|
}
|
||||||
|
|
||||||
int dofIndex = 0;
|
int dofIndex = 0;
|
||||||
Pose windowPose = new Pose(0, 1.2f, -0.6f, Quat.FromAngles(0, 180, 0));
|
Pose windowPose = new Pose(-0.333f, 1.2f, -0.5f, Quat.FromAngles(0, 180, 0));
|
||||||
Material windowMat = new Material(Shader.FromFile("window.hlsl"));
|
Material windowMat = new Material(Shader.FromFile("shaders/window.hlsl"));
|
||||||
TextStyle style = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, Color.Black);
|
TextStyle style = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, Color.Black);
|
||||||
TextStyle style2 = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, new Color(0.5f, 0.5f, 0.5f));
|
TextStyle style2 = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, new Color(0.5f, 0.5f, 0.5f));
|
||||||
Vec2 fieldSize = new Vec2(6f * U.cm, 3f * U.cm);
|
Vec2 fieldSize = new Vec2(6f * U.cm, 3f * U.cm);
|
||||||
|
@ -486,15 +501,16 @@ public class Cursor {
|
||||||
|
|
||||||
|
|
||||||
public class Spatial {
|
public class Spatial {
|
||||||
// example, to build out from
|
// example, to build out from!
|
||||||
|
// rn it's just adding two vectors
|
||||||
|
// building towards great interactivity and visual feedback
|
||||||
|
public Spatial(Vec3 origin) {
|
||||||
|
this.origin = origin;
|
||||||
|
}
|
||||||
|
public Vec3 origin;
|
||||||
|
float scale = 0.2f;
|
||||||
|
float thickness => 0.02f * scale;
|
||||||
|
|
||||||
// just adding two vectors
|
|
||||||
// with great interactivity and visual feedback
|
|
||||||
|
|
||||||
float scale = 0.1f;
|
|
||||||
float thickness => 0.01f * scale;
|
|
||||||
|
|
||||||
Vec3 origin = new Vec3(0, 1, -1);
|
|
||||||
|
|
||||||
float t = 1.0f;
|
float t = 1.0f;
|
||||||
Vec3 aFrom, aTo;
|
Vec3 aFrom, aTo;
|
||||||
|
@ -505,9 +521,9 @@ public class Spatial {
|
||||||
|
|
||||||
public void Frame() {
|
public void Frame() {
|
||||||
// origin axis
|
// origin axis
|
||||||
Lines.Add(origin, World(new Vec3(1, 0, 0)), new Color(1, 0, 0), thickness);
|
Lines.Add(origin, World(new Vec3(1, 0, 0)), new Color(1, 0, 0), thickness * 0.333f);
|
||||||
Lines.Add(origin, World(new Vec3(0, 1, 0)), new Color(0, 1, 0), thickness);
|
Lines.Add(origin, World(new Vec3(0, 1, 0)), new Color(0, 1, 0), thickness * 0.333f);
|
||||||
Lines.Add(origin, World(new Vec3(0, 0, 1)), new Color(0, 0, 1), thickness);
|
Lines.Add(origin, World(new Vec3(0, 0, 1)), new Color(0, 0, 1), thickness * 0.333f);
|
||||||
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(origin, thickness), new Color(0.5f, 0.5f, 0.5f));
|
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(origin, thickness), new Color(0.5f, 0.5f, 0.5f));
|
||||||
|
|
||||||
Random rand = Random.Shared;
|
Random rand = Random.Shared;
|
||||||
|
@ -525,9 +541,10 @@ public class Spatial {
|
||||||
}
|
}
|
||||||
t += Time.Stepf / 2f;
|
t += Time.Stepf / 2f;
|
||||||
|
|
||||||
|
// Lines.Add(origin, World(a), new Color(1, 1, 1, 0.5f), thickness * 2); // they clip with no material way to fix it?
|
||||||
Lines.Add(origin, World(a), new Color(1, 1, 0), thickness);
|
Lines.Add(origin, World(a), new Color(1, 1, 0), thickness);
|
||||||
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(World(a), thickness), new Color(1, 1, 0));
|
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(World(a), thickness), new Color(1, 1, 0));
|
||||||
|
// Lines.Add(origin, World(b), new Color(1, 1, 1, 0.5f), thickness * 2);
|
||||||
Lines.Add(origin, World(b), new Color(0, 1, 1), thickness);
|
Lines.Add(origin, World(b), new Color(0, 1, 1), thickness);
|
||||||
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(World(b), thickness), new Color(0, 1, 1));
|
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(World(b), thickness), new Color(0, 1, 1));
|
||||||
|
|
||||||
|
@ -543,3 +560,8 @@ public class Spatial {
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Volumetric Lines
|
||||||
|
public class Vine {
|
||||||
|
|
||||||
|
}
|
78
src/Space.cs
78
src/Space.cs
|
@ -13,7 +13,7 @@ public class Space {
|
||||||
BufferData data = new BufferData();
|
BufferData data = new BufferData();
|
||||||
|
|
||||||
Material matFloor = new Material(Shader.Default);
|
Material matFloor = new Material(Shader.Default);
|
||||||
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("room.hlsl"));
|
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("shaders/room.hlsl"));
|
||||||
Mesh cube = Mesh.Cube;
|
Mesh cube = Mesh.Cube;
|
||||||
|
|
||||||
Solid floor;
|
Solid floor;
|
||||||
|
@ -117,7 +117,7 @@ public class Space {
|
||||||
for (float x = -radius; x < radius; x++) {
|
for (float x = -radius; x < radius; x++) {
|
||||||
for (float z = -radius; z < radius; z++) {
|
for (float z = -radius; z < radius; z++) {
|
||||||
|
|
||||||
float noise = Mono.inst.noise.D2((int)x, (int)z);
|
float d2 = Mono.inst.noise.D2((int)x, (int)z);
|
||||||
float xpos = pillarsOffset.x + x;
|
float xpos = pillarsOffset.x + x;
|
||||||
float zpos = pillarsOffset.z - z;
|
float zpos = pillarsOffset.z - z;
|
||||||
|
|
||||||
|
@ -129,17 +129,17 @@ public class Space {
|
||||||
xpos + x,
|
xpos + x,
|
||||||
radius / 2,
|
radius / 2,
|
||||||
zpos + z / 2
|
zpos + z / 2
|
||||||
) + Quat.FromAngles(noise * 90, noise * 360, 0) * Vec3.Forward * 2f,
|
) + Quat.FromAngles(d2 * 90, d2 * 360, 0) * Vec3.Forward * 2f,
|
||||||
new Vec3(2, 1, 2) * (0.5f + noise)
|
new Vec3(2, 1, 2) * (0.5f + d2)
|
||||||
),
|
),
|
||||||
Color.White
|
Color.White
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float height = 1 + noise;
|
float height = 1 + d2;
|
||||||
float angle = noise * 360f;
|
float angle = d2 * 360f;
|
||||||
Vec3 offset = Quat.FromAngles(0, angle, 0) * Vec3.Forward * noise * 0.5f;
|
Vec3 offset = Quat.FromAngles(0, angle, 0) * Vec3.Forward * d2 * 0.5f;
|
||||||
xpos += offset.x;
|
xpos += offset.x;
|
||||||
zpos += offset.z;
|
zpos += offset.z;
|
||||||
Mesh.Cube.Draw(
|
Mesh.Cube.Draw(
|
||||||
|
@ -159,22 +159,66 @@ public class Space {
|
||||||
Quat.FromAngles(0, angle, 0),
|
Quat.FromAngles(0, angle, 0),
|
||||||
new Vec3(0.95f, height, 0.95f)
|
new Vec3(0.95f, height, 0.95f)
|
||||||
),
|
),
|
||||||
new Color(0.3f, 0.7f + (noise * 0.3f), 0.2f, 1f)
|
new Color(0.3f, 0.7f + (d2 * 0.3f), 0.2f, 1f)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// meshBeam.Draw(
|
for (int i = 0; i < drops.Length; i++) {
|
||||||
// Mono.inst.matHolo,
|
if (drops[i] == null) drops[i] = new Drop();
|
||||||
// Matrix.TRS(
|
|
||||||
// new Vec3(0, 1, -3),
|
|
||||||
// Quat.FromAngles(90f, 0, 0),
|
|
||||||
// 1
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
// tree.Frame();
|
drops[i].Frame(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Drop[] drops = new Drop[128];
|
||||||
|
class Drop {
|
||||||
|
public Vec3 pos;
|
||||||
|
float rippleT = 1f;
|
||||||
|
bool falling = false;
|
||||||
|
Mesh mesh_ripple = Model.FromFile("ripple.glb").FindNode("ripple").Mesh;
|
||||||
|
|
||||||
|
public void Frame(int id) {
|
||||||
|
if (!falling) {
|
||||||
|
PR.Noise noise = Mono.inst.noise;
|
||||||
|
rippleT += Time.Stepf / 0.5f;
|
||||||
|
if (rippleT >= 1.0f + (1.0f + noise.D1(id))) {
|
||||||
|
pos = new Vec3(
|
||||||
|
noise.value * 10f,
|
||||||
|
10,
|
||||||
|
-0.5f + noise.uvalue * -10f
|
||||||
|
);
|
||||||
|
falling = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
float t = 1 - MathF.Min(rippleT, 1f);
|
||||||
|
t *= t;
|
||||||
|
t = 1 - t;
|
||||||
|
mesh_ripple.Draw(
|
||||||
|
Mono.inst.matHoloclear,
|
||||||
|
Matrix.TRS(pos, Quat.Identity, new Vec3(0.333f * t, 0.0133f, 0.333f * t)),
|
||||||
|
new Color(1f, 1f, 1f, 1f) * (1f - t)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (falling) {
|
||||||
|
// rain's terminal velocity is 9.8 m/s
|
||||||
|
pos.y -= 9.8f * Time.Stepf;
|
||||||
|
if (pos.y <= 0.0f) {
|
||||||
|
pos.y = 0.0f;
|
||||||
|
rippleT = 0f;
|
||||||
|
falling = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh.Cube.Draw(
|
||||||
|
Mono.inst.matHoloclear,
|
||||||
|
Matrix.TRS(pos, Quat.Identity, new Vec3(0.002f, 0.98f, 0.002f)),
|
||||||
|
new Color(0.8f, 0.8f, 1f) * 0.1333f
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Tree tree = new Tree();
|
// Tree tree = new Tree();
|
||||||
// Tree[] trees = new Tree[128];
|
// Tree[] trees = new Tree[128];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue