^SK preview 5

This commit is contained in:
spatialfree 2022-10-19 02:43:43 -04:00
parent 90b058786d
commit 845d0d03ea
2 changed files with 118 additions and 125 deletions

View file

@ -1,189 +1,182 @@
namespace Oriels; namespace Oriels;
public class Mono { public class Mono {
private static readonly Lazy<Oriels.Mono> lazy = new Lazy<Oriels.Mono>(() => new Oriels.Mono()); private static readonly Lazy<Oriels.Mono> lazy = new Lazy<Oriels.Mono>(() => new Oriels.Mono());
public static Oriels.Mono inst { get { return lazy.Value; } } public static Oriels.Mono inst { get { return lazy.Value; } }
public PullRequest.Noise noise = new PullRequest.Noise(939949595); public PullRequest.Noise noise = new PullRequest.Noise(939949595);
public Material matDev; public Material matDev;
public Material matHolo; public Material matHolo;
public Rig rig = new Rig(); public Rig rig = new Rig();
public Scene scene = new Scene(); public Space space = new Space();
public Compositor compositor = new Compositor();
// ------------------------------------------------- // -------------------------------------------------
public dof[] dofs; public dof[] dofs;
int dofIndex = 0; int dofIndex = 0;
dof dof => dofs[dofIndex]; dof dof => dofs[dofIndex];
public Oriel oriel = new Oriel(); // -> array ? public ColorCube colorCube = new ColorCube();
public ColorCube colorCube = new ColorCube(); public Glove rGlove = new Glove(true), lGlove = new Glove(false);
public Glove Glove(bool chirality) { return chirality ? rGlove : lGlove; }
public Glove rGlove = new Glove(true), lGlove = new Glove(false); public BlockCon rBlock = new BlockCon(true), lBlock = new BlockCon(false);
public Glove Glove(bool chirality) { return chirality ? rGlove : lGlove; } public BlockCon BlockCon(bool chirality) { return chirality ? rBlock : lBlock; }
public Block[] blocks = new Block[] {
new Block(), new Block(), new Block(), new Block(), new Block(), new Block()
};
public BlockCon rBlock = new BlockCon(true), lBlock = new BlockCon(false); public CubicCon cubicCon = new CubicCon();
public BlockCon BlockCon(bool chirality) { return chirality ? rBlock : lBlock; } public Cubic[] cubics = new Cubic[] {
public Block[] blocks = new Block[] { new Cubic(), new Cubic(), new Cubic(), new Cubic(), new Cubic(), new Cubic()
new Block(), new Block(), new Block(), new Block(), new Block(), new Block() };
};
public CubicCon cubicCon = new CubicCon(); // -------------------------------------------------
public Cubic[] cubics = new Cubic[] {
new Cubic(), new Cubic(), new Cubic(), new Cubic(), new Cubic(), new Cubic()
};
// ------------------------------------------------- public MonoNet net = new MonoNet();
public MonoNet net = new MonoNet(); public Mono() {
Renderer.SetClip(0.02f, 1000f);
public Mono() { dofs = new dof[] {
Renderer.SetClip(0.02f, 1000f); // new StretchFinger(),
new WaveCursor() { handed = Handed.Left },
new WaveCursor() { handed = Handed.Right },
new Trackballer() { handed = Handed.Left },
new Trackballer() { handed = Handed.Right },
// new StretchCursor() { },
// new StretchCursor() { },
};
}
dofs = new dof[] { public void Init() {
// new StretchFinger(), compositor.Init();
new WaveCursor() { handed = Handed.Left },
new WaveCursor() { handed = Handed.Right },
new Trackballer() { handed = Handed.Left },
new Trackballer() { handed = Handed.Right },
// new StretchCursor() { },
// new StretchCursor() { },
};
}
public void Init() { dofs[0].Init();
dofs[1].Init();
dofs[2].Init();
dofs[3].Init();
// dofs[0].Init(); matDev = Material.Default.Copy();
// dofs[1].Init(); matDev.SetTexture("diffuse", Tex.DevTex);
// spaceMono.Init();
greenyard.Init();
matDev = Material.Default.Copy();
matDev.SetTexture("diffuse", Tex.DevTex);
matHolo = Material.Default.Copy(); matHolo = Material.Default.Copy();
matHolo.Transparency = Transparency.Add; matHolo.Transparency = Transparency.Add;
matHolo.DepthWrite = false; matHolo.DepthWrite = false;
matHolo.DepthTest = DepthTest.Less; matHolo.DepthTest = DepthTest.Always;
matHolo.SetTexture("diffuse", Tex.DevTex); matHolo.SetTexture("diffuse", Tex.DevTex);
} }
// ------------------------------------------------- public void Frame() {
// Space.Mono spaceMono = new Space.Mono(); // Input.HandClearOverride(Handed.Left);
Greenyard.Mono greenyard = new Greenyard.Mono(); Input.HandClearOverride(Handed.Right);
// store hand pre override in rig
rig.Step();
// ------------------------------------------------- // Hand hand = Input.Hand(Handed.Right);
// Controller con = Input.Controller(Handed.Right);
// Mesh.Cube.Draw(
// Material.Default,
// hand.IsJustPinched
// )
public void Frame() { // Con -> Hand
// lGlove.Step();
// rGlove.Step();
rig.Step(); compositor.Frame();
// ------------------------------------------------- // -------------------------------------------------
// dof.Frame();
dofs[0].Frame();
dofs[1].Frame();
dofs[2].Frame();
dofs[3].Frame();
WaveCursor lwc = (WaveCursor)dofs[0]; // // dof.Frame();
WaveCursor rwc = (WaveCursor)dofs[1]; dofs[0].Frame();
dofs[1].Frame();
dofs[2].Frame();
dofs[3].Frame();
WaveCursor lwc = (WaveCursor)dofs[0];
WaveCursor rwc = (WaveCursor)dofs[1];
Trackballer ltb = (Trackballer)dofs[2]; Trackballer ltb = (Trackballer)dofs[2];
Trackballer rtb = (Trackballer)dofs[3]; Trackballer rtb = (Trackballer)dofs[3];
lwc.Demo(ltb.ori); lwc.Demo(ltb.ori);
rwc.Demo(rtb.ori); rwc.Demo(rtb.ori);
Mesh.Cube.Draw(Mono.inst.matHolo, Mesh.Cube.Draw(Mono.inst.matHolo,
Matrix.TRS( Matrix.TRS(
lwc.cursor.position, lwc.cursor.position,
ltb.ori, Quat.Identity, // ltb.ori,
0.04f 0.015f
), ),
new Color(1, 0, 0) new Color(0, 1, 1)
); );
Mesh.Cube.Draw(Mono.inst.matHolo, Mesh.Cube.Draw(Mono.inst.matHolo,
Matrix.TRS( Matrix.TRS(
rwc.cursor.position, rwc.cursor.position,
rtb.ori, Quat.Identity, // rtb.ori,
0.04f 0.015f
), ),
new Color(1, 0, 0) new Color(0, 1, 1)
); );
// rBlock.Step(); lBlock.Step();
// rGlove.Step(); lGlove.Step(); // cubicCon.Step();
// rBlock.Step(); lBlock.Step(); // colorCube.Palm(lCon.device);
// cubicCon.Step(); // -------------------------------------------------
// colorCube.Palm(lCon.device); net.me.Step();
net.send = true;
oriel.Frame(); ShowWindowButton();
}
scene.Step(); // after! (render scene after oriel) Pose windowPoseButton = new Pose(0, 0, 0.75f, Quat.Identity);
void ShowWindowButton() {
UI.WindowBegin("Window Button", ref windowPoseButton);
// ------------------------------------------------- // if (UI.Button("Draw Oriel Axis")) { oriel.drawAxis = !oriel.drawAxis; }
// spaceMono.Frame(); // if (UI.Button("Reset Oriel Quat")) { oriel.ori = Quat.Identity; }
greenyard.Frame(); // if (UI.Button("Scale w/Height")) { oriel.scaleWithHeight = !oriel.scaleWithHeight; }
// UI.HSlider("Scale", ref oriel.scale, 0.1f, 1f, 0.1f);
// UI.HSlider("Multiplier", ref oriel.multiplier, 0.1f, 1f, 0.1f);
// // UI.Label("Player.y");
// UI.HSlider("Player.y", ref greenyard.height, 1f, 6f, 0.2f);
// ------------------------------------------------- // UI.Label("pos.y");
// UI.HSlider("pos.y", ref playerY, -1f, 1f, 0.1f);
oriel.Render(); // UI.Label("trail.length");
// UI.HSlider("trail.length", ref trailLen, 0.1f, 1f, 0.1f);
net.me.Step(); // UI.Label("trail.scale");
net.send = true; // UI.HSlider("trail.str", ref trailScl, 0.1f, 2f, 0.1f);
ShowWindowButton(); // UI.Label("str");
} // UI.HSlider("str", ref stretchStr, 0.1f, 1f, 0.1f);
Pose windowPoseButton = new Pose(0, 0, 0.75f, Quat.Identity);
void ShowWindowButton() {
UI.WindowBegin("Window Button", ref windowPoseButton);
// if (UI.Button("Draw Oriel Axis")) { oriel.drawAxis = !oriel.drawAxis; }
// if (UI.Button("Reset Oriel Quat")) { oriel.ori = Quat.Identity; }
// if (UI.Button("Scale w/Height")) { oriel.scaleWithHeight = !oriel.scaleWithHeight; }
// UI.HSlider("Scale", ref oriel.scale, 0.1f, 1f, 0.1f);
// UI.HSlider("Multiplier", ref oriel.multiplier, 0.1f, 1f, 0.1f);
// UI.Label("Player.y");
// UI.HSlider("Player.y", ref greenyard.height, 0.1f, 1.5f, 0.1f);
UI.Label("pos.y");
UI.HSlider("pos.y", ref playerY, -1f, 1f, 0.1f);
UI.Label("trail.length");
UI.HSlider("trail.length", ref trailLen, 0.1f, 1f, 0.1f);
UI.Label("trail.scale");
UI.HSlider("trail.str", ref trailScl, 0.1f, 2f, 0.1f);
UI.Label("str");
UI.HSlider("str", ref stretchStr, 0.1f, 1f, 0.1f);
// flipIndex // flipIndex
// flipGrip // flipGrip
UI.WindowEnd(); UI.WindowEnd();
} }
public float trailLen = 0.5f; public float trailLen = 0.666f;
public float trailScl = 0.2f; public float trailScl = 0.2f;
public float stretchStr = 0.333f; public float stretchStr = 0.5f;
public float playerY = 0; public float playerY = 0;
} }

View file

@ -15,7 +15,7 @@ class StretchCursor : dof {
float mag = (vTo - vFrom).Magnitude; float mag = (vTo - vFrom).Magnitude;
stretch = MathF.Max(mag - deadzone, 0); stretch = MathF.Max(mag - deadzone, 0);
Vec3 dir = PullRequest.Direction(vTo, vFrom); Vec3 dir = Vec3.Direction(vTo, vFrom);
cursor = vTo + dir * stretch * strength; cursor = vTo + dir * stretch * strength;
// draw // draw