organizational ripples

This commit is contained in:
ethan merchant 2023-07-18 16:49:33 -04:00
parent a4e3285d77
commit 8308529340
4 changed files with 106 additions and 40 deletions

BIN
add/ripple.glb Normal file

Binary file not shown.

Binary file not shown.

View file

@ -7,10 +7,12 @@ public class Mono {
public PR.Noise noise = new PR.Noise(939949595);
public Material matDev;
public Material matHoloframe = new Material(Shader.FromFile("above.hlsl"));
Material matHoloframeUnder = new Material(Shader.FromFile("below.hlsl"));
public Material matHolo = new Material(Shader.FromFile("above.hlsl"));
Material matHoloUnder = new Material(Shader.FromFile("below.hlsl"));
public Material matHoloframe = new Material(Shader.FromFile("shaders/above.hlsl"));
Material matHoloframeUnder = new Material(Shader.FromFile("shaders/below.hlsl"));
public Material matHoloclear = new Material(Shader.FromFile("shaders/above.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 Space space = new Space();
@ -61,6 +63,15 @@ public class Mono {
matHoloUnder.FaceCull = Cull.None;
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.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();
Drawer drawerA = new Drawer(new Pose(new Vec3(-0.5f, 0.6f, -0.8f), Quat.Identity));
Drawer drawerB = new Drawer(new Pose(new Vec3(0, 0.6f, -0.8f), Quat.Identity));
Drawer drawerC = 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.8f, 0.6f, 0.95f), Quat.FromAngles(0, 90f, 0)));
Drawer drawerC = new Drawer(new Pose(new Vec3(-0.8f, 0.6f, 0.5f), Quat.FromAngles(0, 90f, 0)));
public void Frame() {
@ -93,6 +104,10 @@ public class Mono {
// Input.HandClearOverride(Handed.Right);
// store hand pre override in rig
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);
// Controller con = Input.Controller(Handed.Right);
@ -201,8 +216,8 @@ public class Mono {
}
int dofIndex = 0;
Pose windowPose = new Pose(0, 1.2f, -0.6f, Quat.FromAngles(0, 180, 0));
Material windowMat = new Material(Shader.FromFile("window.hlsl"));
Pose windowPose = new Pose(-0.333f, 1.2f, -0.5f, Quat.FromAngles(0, 180, 0));
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 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);
@ -486,15 +501,16 @@ public class Cursor {
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;
Vec3 aFrom, aTo;
@ -505,9 +521,9 @@ public class Spatial {
public void Frame() {
// origin axis
Lines.Add(origin, World(new Vec3(1, 0, 0)), new Color(1, 0, 0), thickness);
Lines.Add(origin, World(new Vec3(0, 1, 0)), new Color(0, 1, 0), thickness);
Lines.Add(origin, World(new Vec3(0, 0, 1)), new Color(0, 0, 1), 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 * 0.333f);
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));
Random rand = Random.Shared;
@ -525,9 +541,10 @@ public class Spatial {
}
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);
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);
Mesh.Sphere.Draw(Material.Unlit, Matrix.TS(World(b), thickness), new Color(0, 1, 1));
@ -542,4 +559,9 @@ public class Spatial {
}
//
}
// Volumetric Lines
public class Vine {
}

View file

@ -13,7 +13,7 @@ public class Space {
BufferData data = new BufferData();
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;
Solid floor;
@ -117,7 +117,7 @@ public class Space {
for (float x = -radius; x < radius; x++) {
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 zpos = pillarsOffset.z - z;
@ -129,17 +129,17 @@ public class Space {
xpos + x,
radius / 2,
zpos + z / 2
) + Quat.FromAngles(noise * 90, noise * 360, 0) * Vec3.Forward * 2f,
new Vec3(2, 1, 2) * (0.5f + noise)
) + Quat.FromAngles(d2 * 90, d2 * 360, 0) * Vec3.Forward * 2f,
new Vec3(2, 1, 2) * (0.5f + d2)
),
Color.White
);
continue;
}
float height = 1 + noise;
float angle = noise * 360f;
Vec3 offset = Quat.FromAngles(0, angle, 0) * Vec3.Forward * noise * 0.5f;
float height = 1 + d2;
float angle = d2 * 360f;
Vec3 offset = Quat.FromAngles(0, angle, 0) * Vec3.Forward * d2 * 0.5f;
xpos += offset.x;
zpos += offset.z;
Mesh.Cube.Draw(
@ -159,22 +159,66 @@ public class Space {
Quat.FromAngles(0, angle, 0),
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(
// Mono.inst.matHolo,
// Matrix.TRS(
// new Vec3(0, 1, -3),
// Quat.FromAngles(90f, 0, 0),
// 1
// )
// );
// tree.Frame();
for (int i = 0; i < drops.Length; i++) {
if (drops[i] == null) drops[i] = new Drop();
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[] trees = new Tree[128];