clouded clearing
This commit is contained in:
parent
9befafe2d5
commit
097377a89e
5 changed files with 153 additions and 69 deletions
|
@ -58,8 +58,6 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
col.b = col.b * 0.3;
|
||||
|
||||
col.rgb *= 0.1;
|
||||
} else {
|
||||
col.rgb = lerp(col.rgb, float3(0.3, 1, 0.2), (input.world.y / 20));
|
||||
}
|
||||
|
||||
// dist magnitude from center X0Z
|
||||
|
|
|
@ -76,8 +76,6 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
// bluer
|
||||
col.r *= 1 - (t / 10);
|
||||
col.g *= 1 - (t / 10);
|
||||
|
||||
col.rgb = lerp(col.rgb, float3(0.3, 1, 0.2), (-input.world.y / 20));
|
||||
|
||||
return lerp(clearcolor, col, t);
|
||||
|
||||
|
|
44
app/Mono.cs
44
app/Mono.cs
|
@ -88,6 +88,9 @@ public class Mono {
|
|||
matHoloframe.Chain = matHoloframeUnder;
|
||||
}
|
||||
|
||||
Pose shape = new Pose(new Vec3(0, 1f, -3f), Quat.FromAngles(45, 0, 45));
|
||||
bool shapeHeld = false;
|
||||
|
||||
public void Frame() {
|
||||
|
||||
// Input.HandClearOverride(Handed.Left);
|
||||
|
@ -135,6 +138,23 @@ public class Mono {
|
|||
rtb.Demo();
|
||||
}
|
||||
|
||||
if (!shapeHeld) {
|
||||
shapeHeld = rtb.btnPush.frameDown;
|
||||
}
|
||||
if (shapeHeld) {
|
||||
shape.position = rwc.cursor.smooth;
|
||||
shape.orientation = rtb.ori;
|
||||
shapeHeld = !rtb.btnPull.frameDown;
|
||||
}
|
||||
// I'd rather have it be pose.pos & pose.ori
|
||||
// as it's a bit of space hog
|
||||
|
||||
Mesh.Cube.Draw(
|
||||
Mono.inst.matHoloframe,
|
||||
shape.ToMatrix(0.5f),
|
||||
new Color(0.5f, 0.55f, 0.75f) * 0.3f
|
||||
);
|
||||
|
||||
// </Heresy>
|
||||
|
||||
// rBlock.Step(); lBlock.Step();
|
||||
|
@ -314,6 +334,27 @@ public class Design {
|
|||
// public int integer {};
|
||||
}
|
||||
|
||||
public class Cursor {
|
||||
PullRequest.OneEuroFilter xF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
PullRequest.OneEuroFilter yF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
PullRequest.OneEuroFilter zF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
Vec3 _raw;
|
||||
public Vec3 raw {
|
||||
get => _raw;
|
||||
set {
|
||||
_raw = value;
|
||||
pos = new Vec3(
|
||||
(float)xF.Filter(raw.x, (double)Time.Elapsedf),
|
||||
(float)yF.Filter(raw.y, (double)Time.Elapsedf),
|
||||
(float)zF.Filter(raw.z, (double)Time.Elapsedf)
|
||||
);
|
||||
smooth = Vec3.Lerp(smooth, pos, Time.Elapsedf * 6f);
|
||||
}
|
||||
}
|
||||
public Vec3 pos { get; private set; }
|
||||
public Vec3 smooth { get; private set; }
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
COMMENTS
|
||||
|
@ -335,7 +376,8 @@ public class Design {
|
|||
t
|
||||
|
||||
demo
|
||||
virtual shapes -> that can be slotted
|
||||
seperate the demos from the dofs, and make them rebindable (assigning input using reflection?)
|
||||
virtual shapes(scalable) -> that can be slotted
|
||||
physics boxes
|
||||
|
||||
mirror
|
||||
|
|
115
app/Space.cs
115
app/Space.cs
|
@ -61,7 +61,13 @@ public class Space {
|
|||
floor.AddBox(new Vec3(scale, 0.1f, scale), 1, new Vec3(0, scale / 2, 0));
|
||||
matFloor.SetTexture("diffuse", Tex.FromFile("floor.png"));
|
||||
matFloor.SetFloat("tex_scale", 32);
|
||||
}
|
||||
|
||||
meshBeam = Mesh.GeneratePlane(new Vec2(0.1f, 1));
|
||||
Vertex[] verts = meshBeam.GetVerts();
|
||||
verts[0].col = new Color(1f, 0.5f, 0.5f);
|
||||
meshBeam.SetVerts(verts);
|
||||
}
|
||||
Mesh meshBeam;
|
||||
|
||||
public float scale;
|
||||
public Vec3 floorScale;
|
||||
|
@ -106,17 +112,42 @@ public class Space {
|
|||
|
||||
// leek.Draw(Matrix.TRS(new Vec3(2.5f, 0, -2.5f) * 1.2f, Quat.FromAngles(180f, 30f, 0f), 1.2f));
|
||||
|
||||
// draw grid of pillars
|
||||
|
||||
float radius = 9;
|
||||
Vec3 pillarsOffset = new Vec3(0, 0, -10);
|
||||
for (float x = -radius; x < radius; x++) {
|
||||
for (float z = -radius; z < radius; z++) {
|
||||
float height = 3f;
|
||||
|
||||
float noise = Mono.inst.noise.D2((int)x, (int)z);
|
||||
float xpos = pillarsOffset.x + x;
|
||||
float zpos = pillarsOffset.z - z;
|
||||
|
||||
if (Vec3.Distance(new Vec3(xpos, 0, zpos), Vec3.Zero) < radius / 2) {
|
||||
Mesh.Cube.Draw(
|
||||
Mono.inst.matHolo,
|
||||
Matrix.TS(
|
||||
new Vec3(
|
||||
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)
|
||||
),
|
||||
Color.White
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
float height = 1 + noise;
|
||||
float angle = noise * 360f;
|
||||
Vec3 offset = Quat.FromAngles(0, angle, 0) * Vec3.Forward * noise * 0.5f;
|
||||
xpos += offset.x;
|
||||
zpos += offset.z;
|
||||
Mesh.Cube.Draw(
|
||||
Mono.inst.matHolo,
|
||||
Matrix.TRS(
|
||||
new Vec3(pillarsOffset.x + x, (height * 0.5f), pillarsOffset.z - z),
|
||||
Quat.FromAngles(0, 0, 0),
|
||||
new Vec3(xpos, (height * 0.5f), zpos),
|
||||
Quat.FromAngles(0, angle, 0),
|
||||
new Vec3(0.1f, height, 0.1f)
|
||||
),
|
||||
new Color(1f, 1f, 1f, 1f)
|
||||
|
@ -125,13 +156,79 @@ public class Space {
|
|||
Mesh.Cube.Draw(
|
||||
Mono.inst.matHolo,
|
||||
Matrix.TRS(
|
||||
new Vec3(pillarsOffset.x + x, height, pillarsOffset.z - z),
|
||||
Quat.FromAngles(0, 0, 0),
|
||||
new Vec3(0.95f, 1f, 0.95f)
|
||||
new Vec3(xpos, height, zpos),
|
||||
Quat.FromAngles(0, angle, 0),
|
||||
new Vec3(0.95f, height, 0.95f)
|
||||
),
|
||||
new Color(0.3f, 1f, 0.2f, 1f)
|
||||
new Color(0.3f, 0.7f + (noise * 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();
|
||||
}
|
||||
Tree tree = new Tree();
|
||||
// Tree[] trees = new Tree[128];
|
||||
|
||||
class Tree {
|
||||
float r; // damage
|
||||
float g; // resources
|
||||
float b; // peak
|
||||
// color(r, max(g, b), b)
|
||||
// height = b
|
||||
|
||||
public void Frame() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
sapling
|
||||
e
|
||||
|
||||
e = lerp(e, g * lft, lft / x)
|
||||
r += e
|
||||
g -= e
|
||||
b -= min(g, 0)
|
||||
reliant on ideal conditions being there to ease off of the seed dependency
|
||||
(scrappy can outlast the g)
|
||||
|
||||
tree
|
||||
r += min(g, 0) + background radiation * lft
|
||||
g += b * lft
|
||||
b +=
|
||||
r 0->b
|
||||
g = clamp(g, 0, 1)
|
||||
b = clamp(b, 0, 1)
|
||||
|
||||
e = (r / neighbors) * lft
|
||||
g -= e
|
||||
|
||||
if g > 1 - r
|
||||
seed(g)
|
||||
g = 0
|
||||
|
||||
tilt towards best spot
|
||||
* rand.dir * r * smoothstart (r * r * r * r * r) ?
|
||||
|
||||
if r > b
|
||||
b += lft
|
||||
|
||||
if b > 1
|
||||
poof
|
||||
|
||||
seed
|
||||
g = what was passed down
|
||||
pos = parent.pos + Quat.FromAngles(0, noise.value * 360f, 0) * parent.r // lol
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -6,18 +6,8 @@ class WaveCursor : dof {
|
|||
// input
|
||||
public Handed handed = Handed.Left;
|
||||
|
||||
public class Cursor
|
||||
{
|
||||
public Vec3 raw;
|
||||
public Vec3 pos;
|
||||
public Vec3 smooth;
|
||||
}
|
||||
|
||||
// data
|
||||
public Cursor cursor = new Cursor();
|
||||
PullRequest.OneEuroFilter xF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
PullRequest.OneEuroFilter yF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
PullRequest.OneEuroFilter zF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
|
||||
|
||||
public void Init() {}
|
||||
|
||||
|
@ -38,53 +28,17 @@ class WaveCursor : dof {
|
|||
);
|
||||
|
||||
cursor.raw = hand.Get(FingerId.Index, JointId.Tip).position + dir * stretch * reach.value;
|
||||
cursor.pos.x = (float)xF.Filter(cursor.raw.x, (double)Time.Elapsedf);
|
||||
cursor.pos.y = (float)yF.Filter(cursor.raw.y, (double)Time.Elapsedf);
|
||||
cursor.pos.z = (float)zF.Filter(cursor.raw.z, (double)Time.Elapsedf);
|
||||
cursor.smooth = Vec3.Lerp(cursor.smooth, cursor.pos, Time.Elapsedf * 6f);
|
||||
|
||||
Mesh.Sphere.Draw(Mono.inst.matHoloframe, Matrix.TRS(cursor.raw, Quat.Identity, 0.01f), new Color(1, 0, 0));
|
||||
Mesh.Sphere.Draw(Mono.inst.matHoloframe, Matrix.TRS(cursor.pos, Quat.Identity, 0.01f), new Color(0, 1, 0));
|
||||
Mesh.Sphere.Draw(Mono.inst.matHoloframe, Matrix.TRS(cursor.smooth, Quat.Identity, 0.01f), new Color(0, 0, 1));
|
||||
|
||||
|
||||
// pinch is more than just the thumb and index finger
|
||||
|
||||
handBtn.Frame(
|
||||
PinchStep(hand, FingerId.Little, littleBtn) ||
|
||||
PinchStep(hand, FingerId.Ring, ringBtn) ||
|
||||
PinchStep(hand, FingerId.Middle, middleBtn) ||
|
||||
PinchStep(hand, FingerId.Index, indexBtn)
|
||||
);
|
||||
if (handBtn.held) {
|
||||
shapePos = cursor.pos;
|
||||
}
|
||||
|
||||
// Mesh.Cube.Draw(
|
||||
// Mono.inst.matHolo,
|
||||
// Matrix.TS(shapePos, 10 * U.cm),
|
||||
// new Color(0.5f, 0.55f, 0.75f)
|
||||
// );
|
||||
}
|
||||
}
|
||||
Btn littleBtn = new Btn();
|
||||
Btn ringBtn = new Btn();
|
||||
Btn middleBtn = new Btn();
|
||||
Btn indexBtn = new Btn();
|
||||
Btn handBtn = new Btn();
|
||||
Vec3 shapePos = new Vec3(0, 1.3f, -0.5f);
|
||||
|
||||
|
||||
// design
|
||||
public Design deadzone = new Design { str="0.3", term="0+1t", min=0, max=1 };
|
||||
public Design reach = new Design { str="1.0", term="0+m", min=0 };
|
||||
|
||||
// demo
|
||||
public Design snakeLength = new Design { str="0.5", term="0+1t", min=0, max=1 };
|
||||
public Design snakeScale = new Design { str="0.333", term=">0", min=0.01f };
|
||||
public Design snakeRadius = new Design { str="4", term="0+cm", unit=U.cm, min=0 };
|
||||
|
||||
|
||||
float Flexion(Hand hand, FingerId finger) {
|
||||
float flexion = (Vec3.Dot(
|
||||
PullRequest.Direction(
|
||||
|
@ -100,15 +54,10 @@ class WaveCursor : dof {
|
|||
return Math.Max(flexion - deadzone.value, 0f) / (1 - deadzone.value);
|
||||
}
|
||||
|
||||
bool PinchStep(Hand hand, FingerId finger, Btn btn) {
|
||||
HandJoint thumb = hand.Get(FingerId.Thumb, JointId.Tip);
|
||||
HandJoint fingy = hand.Get(finger, JointId.Tip);
|
||||
float dist = Vec3.Distance(thumb.position, fingy.position);
|
||||
btn.Frame(dist < 1 * U.cm, dist < 2 * U.cm);
|
||||
|
||||
return btn.held;
|
||||
}
|
||||
|
||||
// demo
|
||||
public Design snakeLength = new Design { str="0.5", term="0+1t", min=0, max=1 };
|
||||
public Design snakeScale = new Design { str="0.333", term=">0", min=0.01f };
|
||||
public Design snakeRadius = new Design { str="4", term="0+cm", unit=U.cm, min=0 };
|
||||
|
||||
Vec3[] mm = new Vec3[128];
|
||||
public void Demo(Quat ori) {
|
||||
|
|
Loading…
Add table
Reference in a new issue