multi oriel draft

This commit is contained in:
spatialfree 2022-10-19 02:42:07 -04:00
parent fa5f92ead1
commit 90b058786d
12 changed files with 488 additions and 207 deletions

View file

@ -51,7 +51,11 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
}
float3 cross(float3 a, float3 b) {
return float3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
return float3(
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x
);
}
float dot(float3 a, float3 b) {
@ -81,6 +85,20 @@ float raymarch(float3 origin, float3 direction) {
return dist;
}
float raymarchy(float3 origin, float3 direction) {
origin = mul(float4(origin, 1), _matrix).xyz;
direction = mul(float4(direction, 0), _matrix).xyz;
float dist = 0.0;
for (int i = 0; i < 256; i++) {
float3 pos = origin + dist * direction;
float step = sdBox(pos, _dimensions / 4.0);
if (step < 0.0001 || dist > 100) break; // 100 == distmax
dist += step;
}
return dist;
}
psOut ps(psIn input) {
psOut o;
o.color = input.color * diffuse.Sample(diffuse_s, input.uv);
@ -93,6 +111,18 @@ psOut ps(psIn input) {
origin += ol * direction;
float oll = raymarchy(origin, direction);
if (oll < 99) {
o.color = float4(1, 1, 1, 1);
float3 origin2 = origin + oll * direction;
float4 og = mul(float4(origin2, 1), sk_viewproj[input.view_id]);
// o.depth = og.z;
o.depth = (og * rcp(og.w)).z;
return o;
}
clip(distance(input.campos, input.world) - distance(input.campos, origin));
float t = 1 - (1 + dot(input.normal, _light)) / 2;

View file

@ -61,9 +61,9 @@ float sdSphere(float3 p, float r) {
return length(p) - r;
}
float raymarch(float3 ro, float3 rd) {
ro = mul(float4(ro, 1), oriel_matrix).xyz;
rd = mul(float4(rd, 0), oriel_matrix).xyz;
float raymarch(float4x4 m, float3 ro, float3 rd) {
ro = mul(float4(ro, 1), m).xyz;
rd = mul(float4(rd, 0), m).xyz;
float dist = 0.0;
for (int i = 0; i < 256; i++) {
float3 pos = ro + dist * rd;
@ -101,7 +101,7 @@ float4 ps(psIn input) : SV_TARGET {
float3 ro = input.campos;
float3 rd = normalize(input.world - ro);
float ol = raymarch(ro, rd);
float ol = raymarch(oriel_matrix, ro, rd);
clip(-(100 - (ol + 1)));
// if ((100 - (ol + 1)) > 0) {
@ -122,5 +122,5 @@ float4 ps(psIn input) : SV_TARGET {
// float value = (col.r + col.r + col.g + col.g + col.g + col.b) / 6;
// return float4(value, value, value, 1);
return col;
return col * 0.333;
}

126
app/Backrooms/Mono.cs Normal file
View file

@ -0,0 +1,126 @@
using Oriels;
namespace Backrooms;
public class Mono {
public Oriel oriel = new Oriel(
new Vec3(-1.0f,-0.5f, 0.5f),
Quat.FromAngles(0, 90, 0),
new Vec3( 0.8f, 0.5f, 0.5f)
) { color = new Color(0, 0, 0) };
Matrix matrix = Matrix.Identity;
Vec3 offset = new Vec3(2, 1, -2);
public float height = 1f;
Vec3 angle = new Vec3(0, 0, 0);
Thing[] thing;
Model model = Model.FromFile("/backrooms/backrooms.glb");
public void Init() {
thing = new Thing[] {
new Thing(
model.GetMesh("Carpet"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Carpet.png"
),
new Thing(
model.GetMesh("Walls"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Walls.png"
),
new Thing(
model.GetMesh("Ceiling"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Ceiling.png"
),
new Thing(
model.GetMesh("Vents"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Vents.png"
),
new Thing(
model.GetMesh("Lights"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Lights.png"
),
};
}
public void Frame() {
Oriels.Rig rig = Oriels.Mono.inst.rig;
// angle.x -= rig.rCon.device.stick.y * 90f * Time.Elapsedf;
// angle.x = PullRequest.Clamp(angle.x, -89, 89);
angle.y -= rig.rCon.device.stick.x * 90f * Time.Elapsedf;
Vec3 input = new Vec3(
rig.lCon.device.stick.x,
0,
rig.lCon.device.stick.y
);
if (input.MagnitudeSq > 0.01f) {
input = (
// Quat.FromAngles(angle.x, 0, 0).Inverse *
Quat.FromAngles(0, angle.y, 0).Inverse *
rig.lCon.ori *
oriel.ori.Inverse
).Normalized * input;
input.y = 0;
offset += input * Time.Elapsedf;
}
offset.y = -height;
// Oriel
float scale = 1f; // oriel.scale * oriel.multiplier;
// scale w/height?
// scale *= oriel.bounds.dimensions.y;
matrix = Matrix.TRS(
Vec3.Zero, // -oriel.bounds.dimensions.y / 2.01f
Quat.FromAngles(angle.x, 0, 0) *
Quat.FromAngles(0, angle.y, 0),
Vec3.One * scale
);
}
public void Render() {
for (int i = 0; i < thing.Length; i++) {
Thing t = thing[i];
t.mat.SetVector("_center", oriel.bounds.center);
t.mat.SetVector("_dimensions", oriel.bounds.dimensions);
t.mat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
t.mat.SetFloat("_lit", 0);
t.mat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
t.mesh.Draw(t.mat,
Matrix.TRS(
offset,
Quat.Identity,
new Vec3(1f, 1f, 1f)
) * matrix * oriel.matrix,
Color.White
);
}
}
}
// temp placement
[Serializable]
public class Thing {
public Mesh mesh;
public Material mat;
public Thing(Mesh mesh, Material mat, string tex) {
this.mesh = mesh;
this.mat = mat;
mat.SetMat(101, Cull.None, true);
// mat.Transparency = Transparency.Add;
// mat.DepthTest = DepthTest.Always;
mat.SetTexture("diffuse", Tex.FromFile(tex));
}
}

99
app/Compositor.cs Normal file
View file

@ -0,0 +1,99 @@
namespace Oriels;
public class Compositor {
// these are in a weird place,
// as a process would not be hosted by a compositor...
Backrooms.Mono backrooms = new Backrooms.Mono();
Greenyard.Mono greenyard = new Greenyard.Mono();
bool other = false;
public void Init() {
backrooms.Init();
greenyard.Init();
}
public void Frame() {
Mono mono = Mono.inst;
// backrooms.oriel.Frame();
// greenyard.oriel.Frame();
// // mono.space.Frame();
// Glove rGlove = Mono.inst.rGlove;
// Vec3 cursor = rGlove.virtualGlove.position;
// if (other) {
// greenyard.Frame();
// Vec3 localCursor = backrooms.oriel.matrixInv.Transform(cursor);
// if (backrooms.oriel.bounds.Contains(localCursor + backrooms.oriel.bounds.center)) {
// Console.WriteLine("in backrooms");
// other = false;
// }
// } else {
// backrooms.Frame();
// Vec3 localCursor = greenyard.oriel.matrixInv.Transform(cursor);
// if (greenyard.oriel.bounds.Contains(localCursor + greenyard.oriel.bounds.center)) {
// Console.WriteLine("in greenyard");
// other = true;
// }
// }
// render buffers ? or just use the depth buffer?
mono.space.Frame();
// backrooms.oriel.Render(); // -> Frame() by moving Input specific parts to the compositor?
// backrooms.Render();
// greenyard.oriel.Render();
// greenyard.Render();
// active oriel
// how to show this?
// well popping up a wireframe would get in the way and look bad
// and a glow would be hard to keep consistent across backgrounds
// am I bringing the crown back?
// matFrame.Wireframe = true;
// matFrame.DepthTest = DepthTest.Always;
// matFrame.SetVector("_cursor", cursor);
// matFrame.SetFloat("_time", Time.Totalf);
// Mesh.Cube.Draw(matFrame,
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
// new Color(0.1f, 0.1f, 0.1f)
// );
// Model model = Model.FromFile("oriel.glb");
// ~ Mesh mesh = model.GetMesh("oriel");
}
void Place() {
}
}
/*
COMMENTS
mono (kernel)
compositor
oriel (client)
app
Frame and Render is not a useful distinction
cycle or loop or step instead of frame?
draw instead of render?
we keep combining the two, and it's not a good idea
as input can be polled at a higher frequency than rendering can be output?
Hertz & Frame
does a process ever not have a GUI? *can be hidden &| locked
we are trying to skip the tty!
would be nice to have a dedicated thread(s)
for essential GUI
*/

View file

@ -125,6 +125,14 @@ public class Glove {
Vec3 thumb = hand.Get(FingerId.Thumb, JointId.Tip).position - con.pos;
virtualGlove.position += Vec3.Lerp(index, thumb, 0.5f);
Vec3 delta = virtualGlove.position - con.pos;
HandJoint[] joints = hand.fingers;
for (int i = 0; i < joints.Length; i++) {
joints[i].position += delta - Vec3.Lerp(index, thumb, 0.5f);
}
Input.HandOverride(chirality ? Handed.Right : Handed.Left, joints);
Render(con.pose, virtualGlove, wrist, stretch, twist, chirality);
}
@ -168,3 +176,11 @@ public class Glove {
// model.Draw(glove.ToMatrix(Vec3.One / 10));
}
}
/*
COMMENTS
con -> hand
*/

View file

@ -2,61 +2,34 @@ using Oriels;
namespace Greenyard;
public class Mono {
// Model greenyardModel = Model.FromFile("greenyard.glb");
// Mesh[] greenyard;
// Material greenyardMat = new Material(Shader.FromFile("/shaders/oriel.hlsl"));
public Oriel oriel = new Oriel(
new Vec3(0.0f, -0.5f, 0.5f),
Quat.FromAngles(0, 90, 0),
new Vec3(0.8f, 0.5f, 0.5f)
) { color = new Color(78 / 256f, 142 / 256f, 191 / 256f) * 0.333f };
Vec3 offset = new Vec3(2, 1, -2);
public float height = 1f;
Vec3 angle = new Vec3(0, 0, 0);
Model greenyardModel = Model.FromFile("greenyard.glb");
Mesh[] greenyard;
Material greenyardMat = new Material(Shader.FromFile("/shaders/oriel.hlsl"));
Thing[] thing;
Model model = Model.FromFile("/backrooms/backrooms.glb");
public Mono() {
}
Matrix matrix = Matrix.Identity;
Vec3 offset = new Vec3(2, 1, -12);
public float height = 6f;
Vec3 angle = new Vec3(0, 180, 0);
public void Init() {
// greenyard = new Mesh[12];
// for (int i = 0; i < greenyard.Length; i++) {
// greenyard[i] = greenyardModel.GetMesh("Object_" + (i + 2));
// }
// greenyardMat.SetMat(101, Cull.None, true);
// greenyardMat.SetTexture("diffuse", Tex.FromFile("greenyard.jpeg"));
thing = new Thing[] {
new Thing(
model.GetMesh("Carpet"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Carpet.png"
),
new Thing(
model.GetMesh("Walls"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Walls.png"
),
new Thing(
model.GetMesh("Ceiling"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Ceiling.png"
),
new Thing(
model.GetMesh("Vents"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Vents.png"
),
new Thing(
model.GetMesh("Lights"),
new Material(Shader.FromFile("/shaders/oriel.hlsl")),
"backrooms/Lights.png"
),
};
greenyard = new Mesh[12];
for (int i = 0; i < greenyard.Length; i++) {
greenyard[i] = greenyardModel.GetMesh("Object_" + (i + 2));
}
greenyardMat.SetMat(101, Cull.None, true);
// greenyardMat.Transparency = Transparency.Add;
// greenyardMat.DepthTest = DepthTest.Always;
greenyardMat.SetTexture("diffuse", Tex.FromFile("greenyard.jpeg"));
}
public void Frame() {
Oriels.Rig rig = Oriels.Mono.inst.rig;
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
// angle.x -= rig.rCon.device.stick.y * 90f * Time.Elapsedf;
// angle.x = PullRequest.Clamp(angle.x, -89, 89);
@ -83,64 +56,33 @@ public class Mono {
// Oriel
float scale = oriel.scale * oriel.multiplier;
if (oriel.scaleWithHeight) {
scale *= oriel.bounds.dimensions.y;
}
float scale = 0.1f; // oriel.scale * oriel.multiplier;
// scale w/height?
// scale *= oriel.bounds.dimensions.y;
Matrix simMatrix = Matrix.TRS(
matrix = Matrix.TRS(
Vec3.Zero, // -oriel.bounds.dimensions.y / 2.01f
Quat.FromAngles(angle.x, 0, 0) *
Quat.FromAngles(0, angle.y, 0),
Vec3.One * scale
);
}
// Render
// greenyardMat.SetVector("_center", oriel.bounds.center);
// greenyardMat.SetVector("_dimensions", oriel.bounds.dimensions);
// greenyardMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
// greenyardMat.SetFloat("_lit", 0);
// greenyardMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
// for (int i = 0; i < greenyard.Length; i++) {
// greenyard[i].Draw(greenyardMat,
// Matrix.TRS(
// offset,
// Quat.Identity,
// new Vec3(1f, 1f, 1f)
// ) * simMatrix * oriel.matrix,
// Color.White
// );
// }
for (int i = 0; i < thing.Length; i++) {
Thing t = thing[i];
t.mat.SetVector("_center", oriel.bounds.center);
t.mat.SetVector("_dimensions", oriel.bounds.dimensions);
t.mat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
t.mat.SetFloat("_lit", 0);
t.mat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
t.mesh.Draw(t.mat,
public void Render() {
greenyardMat.SetVector("_center", oriel.bounds.center);
greenyardMat.SetVector("_dimensions", oriel.bounds.dimensions);
greenyardMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
greenyardMat.SetFloat("_lit", 0);
greenyardMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
for (int i = 0; i < greenyard.Length; i++) {
greenyard[i].Draw(greenyardMat,
Matrix.TRS(
offset,
Quat.Identity,
new Vec3(1f, 1f, 1f)
) * simMatrix * oriel.matrix,
) * matrix * oriel.matrix,
Color.White
);
}
}
}
[Serializable]
public class Thing {
public Mesh mesh;
public Material mat;
public Thing(Mesh mesh, Material mat, string tex) {
this.mesh = mesh;
this.mat = mat;
mat.SetMat(101, Cull.None, true);
mat.SetTexture("diffuse", Tex.FromFile(tex));
}
}

View file

@ -219,7 +219,6 @@ public static class PullRequest {
// return Vec3.Lerp(a * (float)Math.Sin(theta - theta * t) / sinTheta, b * (float)Math.Sin(theta * t) / sinTheta, t);
// }
[Serializable]
public class Noise {
const uint CAP = 4294967295;
const uint BIT_NOISE1 = 0xB5297A4D;
@ -285,7 +284,6 @@ public static class PullRequest {
return MathF.Max(min, MathF.Min(max, v));
}
[Serializable]
public class PID {
public float p, i;
float integral = 0f;
@ -305,7 +303,6 @@ public static class PullRequest {
}
}
[Serializable]
public class Lerper {
public float t = 0;
public float spring = 1;
@ -335,4 +332,77 @@ public static class PullRequest {
t = vel = 0;
}
}
public class OneEuroFilter {
public OneEuroFilter(double minCutoff, double beta) {
firstTime = true;
this.minCutoff = minCutoff;
this.beta = beta;
xFilt = new LowpassFilter();
dxFilt = new LowpassFilter();
dcutoff = 1;
}
protected bool firstTime;
protected double minCutoff;
protected double beta;
protected LowpassFilter xFilt;
protected LowpassFilter dxFilt;
protected double dcutoff;
public double MinCutoff {
get { return minCutoff; }
set { minCutoff = value; }
}
public double Beta {
get { return beta; }
set { beta = value; }
}
public double Filter(double x, double rate) {
double dx = firstTime ? 0 : (x - xFilt.Last()) * rate;
if (firstTime) {
firstTime = false;
}
var edx = dxFilt.Filter(dx, Alpha(rate, dcutoff));
var cutoff = minCutoff + beta * Math.Abs(edx);
return xFilt.Filter(x, Alpha(rate, cutoff));
}
protected double Alpha(double rate, double cutoff) {
var tau = 1.0 / (2 * Math.PI * cutoff);
var te = 1.0 / rate;
return 1.0 / (1.0 + tau / te);
}
}
public class LowpassFilter {
public LowpassFilter() {
firstTime = true;
}
protected bool firstTime;
protected double hatXPrev;
public double Last() {
return hatXPrev;
}
public double Filter(double x, double alpha) {
double hatX = 0;
if (firstTime) {
firstTime = false;
hatX = x;
} else
hatX = alpha * x + (1 - alpha) * hatXPrev;
hatXPrev = hatX;
return hatX;
}
}
}

View file

@ -82,7 +82,7 @@ public class Rig {
public class Con {
public Controller device;
public Vec3 pos;
public Quat ori;
public Quat ori = Quat.Identity;
public Pose pose;
public Vec3 backhandDir;
public Btn gripBtn;
@ -91,7 +91,7 @@ public class Con {
public void Step(bool chirality) {
device = Input.Controller(chirality ? Handed.Right : Handed.Left);
pose.position = pos = device.pose.position;
pose.orientation = ori = device.aim.orientation;
pose.orientation = ori = Quat.Identity; // device.pose.orientation;
backhandDir = ori * (chirality ? Vec3.Right : -Vec3.Right);
gripBtn.Step(device.grip > 0.5f);
triggerBtn.Step(device.trigger > 0.5f);

View file

@ -8,7 +8,7 @@ struct BufferData {
public float time;
}
public class Scene {
public class Space {
MaterialBuffer<BufferData> buffer;
BufferData data = new BufferData();
@ -18,7 +18,7 @@ public class Scene {
Solid floor;
public Scene() {
public Space() {
buffer = new MaterialBuffer<BufferData>(3); // index
@ -41,23 +41,19 @@ public class Scene {
public Vec3 floorScale;
public void Step() {
Oriel oriel = Mono.inst.oriel;
data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
data.dimensions = oriel.bounds.dimensions;
// data.dimensions = Vec3.Zero;
public void Frame() {
// Oriel oriel = Mono.inst.oriel;
// data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
// data.dimensions = oriel.bounds.dimensions;
data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(Matrix.T(Vec3.Up));
data.dimensions = new Vec3(0.1f, 0.1f, 0.1f);
buffer.Set(data);
// PullRequest.BlockOut(floor.GetPose().ToMatrix(floorScale), Color.White * 0.333f, matFloor);
// foreach (ModelNode node in shed.Visuals) {

View file

@ -11,6 +11,11 @@ using Oriels;
namespace Space;
public class Mono {
public Oriel oriel = new Oriel(
new Vec3(1.0f, -0.5f, 0.5f),
Quat.Identity,
new Vec3(0.8f, 0.5f, 0.5f)
);
Node[] nodes = new Node[18];
Vec3 playerPos;
List<Vec3> enemies = new List<Vec3>();
@ -53,7 +58,6 @@ public class Mono {
public void Frame() {
Oriels.Rig rig = Oriels.Mono.inst.rig;
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
Matrix simMatrix = Matrix.TRS(
-playerPos * 0.5f * oriel.bounds.dimensions.y, //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),

View file

@ -15,6 +15,8 @@ if (!SK.Initialize(settings))
Input.HandSolid(Handed.Max, false);
Input.HandVisible(Handed.Max, true);
Renderer.EnableSky = false;
Renderer.ClearColor = new Color(0f, 0f, 0f);
Oriels.Mono mono = Oriels.Mono.inst;
mono.Init();

View file

@ -1,9 +1,6 @@
namespace Oriels;
public class Oriel {
Model model = Model.FromFile("oriel.glb");
Mesh meshCube, meshSphere;
Material matClear = new Material(Shader.Default);
public Material matOriel = new Material(Shader.FromFile("shaders/oriel.hlsl"));
@ -13,31 +10,26 @@ public class Oriel {
public Matrix matrix, matrixInv;
public Bounds bounds;
public Quat ori = Quat.Identity;
public Color color = new Color(0.5f, 0.5f, 0.5f);
// inner matrix
public bool scaleWithHeight = false;
public float scale = 0.5f;
public float multiplier = 1f;
public Oriel() {
// meshCube = model.GetMesh("oriel");
meshCube = Mesh.Cube;
meshSphere = Mesh.Sphere;
public Oriel(Vec3 pos, Quat ori, Vec3 dimensions) {
matClear.Transparency = Transparency.Add;
matFrame.SetMat(102, Cull.Back, true);
matFrame.Transparency = Transparency.Blend;
// matFrame.Transparency = Transparency.Add;
matFrame.SetTexture("dither", Tex.FromFile("dither.png"));
matPanes.SetMat(100, Cull.Front, false);
matOriel.SetMat(101, Cull.None, true);
bounds = new Bounds(
new Vec3(-1.0f, -0.5f, 0.5f),
// Vec3.Zero,
new Vec3(0.8f, 0.5f, 0.5f)
);
ori = Quat.FromAngles(0, 90, 0);
matrix = Matrix.TR(bounds.center, ori);
matPanes.SetMat(100, Cull.Front, false); // true?
// matPanes.Transparency = Transparency.Add;
// matPanes.DepthTest = DepthTest.Always;
matOriel.SetMat(101, Cull.None, true);
// matOriel.Transparency = Transparency.Add;
// matOriel.DepthTest = DepthTest.Always;
bounds = new Bounds(pos, dimensions);
this.ori = ori;
matrix = Matrix.TR(bounds.center, this.ori);
matrixInv = matrix.Inverse;
@ -95,22 +87,26 @@ public class Oriel {
Glove rGlove = Mono.inst.rGlove;
// Vec3 lGlovePos = rig.lGlove.virtualGlove.position;
// glove
// bool frameDown = rig.rCon.triggerBtn.frameDown;
// bool held = rig.rCon.triggerBtn.held;
// bool frameUp = rig.rCon.triggerBtn.frameUp;
// cursor = rGlove.virtualGlove.position;
// cursorOri = rGlove.virtualGlove.orientation;
Hand rHand = Input.Hand(Handed.Right);
// why do I have to do this?
// rHand.IsJustPinched ||
bool frameDown = Input.Key(Key.MouseLeft).IsJustActive() || rig.rCon.triggerBtn.frameDown;
bool held = Input.Key(Key.MouseLeft).IsActive() || rig.rCon.triggerBtn.held;
bool frameUp = Input.Key(Key.MouseLeft).IsJustInactive() || rig.rCon.triggerBtn.frameUp;
cursor = rGlove.virtualGlove.position;
cursorOri = rGlove.virtualGlove.orientation;
// hand
Trackballer tb = (Trackballer)Mono.inst.dofs[3];
bool frameDown = tb.btnOut.frameDown;
bool held = tb.btnOut.held;
bool frameUp = tb.btnOut.frameUp;
// Trackballer tb = (Trackballer)Mono.inst.dofs[3];
// bool frameDown = tb.btnOut.frameDown;
// bool held = tb.btnOut.held;
// bool frameUp = tb.btnOut.frameUp;
WaveCursor wc = (WaveCursor)Mono.inst.dofs[1];
cursor = wc.cursor.position;
cursorOri = Quat.Identity; // wc.cursor.orientation;
// WaveCursor wc = (WaveCursor)Mono.inst.dofs[1];
// cursor = wc.cursor.position;
// cursorOri = Quat.Identity; // wc.cursor.orientation;
// debug
@ -159,7 +155,7 @@ public class Oriel {
qOffset = (ori.Inverse * cursorOri).Normalized;
mOffset = matrix;
interacting = frameDown;
interacting = frameDown && minDist < cursorRadius;
scaling = false;
cornerDetect = Vec3.Zero;
}
@ -232,17 +228,16 @@ public class Oriel {
// matFrame.DepthTest = DepthTest.Always;
// matFrame.SetVector("_cursor", cursor);
// matFrame.SetFloat("_time", Time.Totalf);
// meshCube.Draw(matFrame,
// Mesh.Cube.Draw(matFrame,
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
// new Color(0.1f, 0.1f, 0.1f)
// );
// matPanes.DepthTest = DepthTest.Greater;
matPanes["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrixInv);
meshCube.Draw(matPanes,
Mesh.Cube.Draw(matPanes,
Matrix.TRS(bounds.center, ori, bounds.dimensions),
new Color(0f, 0f, 0f)
// new Color(78 / 256f, 142 / 256f, 191 / 256f)
color
);
matOriel.SetVector("_center", bounds.center);
@ -261,7 +256,7 @@ public class Oriel {
) / cursorRadius;
if (detectCount == 1 || detectCount == 2) {
Vec3 edge = Vec3.One - detect.Abs();
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(
LocalAnchor,
(Vec3.One * thk) + (edge * bounds.dimensions / 3f * prx)
@ -269,19 +264,19 @@ public class Oriel {
);
}
if (detectCount == 3) {
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(
Vec3.Lerp(XAnchor, LocalAnchor, 0.5f),
new Vec3(MathF.Abs(XAnchor.x - LocalAnchor.x), thk, thk)
) * matrix, col
);
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(
Vec3.Lerp(YAnchor, LocalAnchor, 0.5f),
new Vec3(thk, MathF.Abs(YAnchor.y - LocalAnchor.y), thk)
) * matrix, col
);
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(
Vec3.Lerp(ZAnchor, LocalAnchor, 0.5f),
new Vec3(thk, thk, MathF.Abs(ZAnchor.z - LocalAnchor.z))
@ -290,31 +285,31 @@ public class Oriel {
// draw cube(s) on intersecting corner ends
if (cornerDetect.x > 0) {
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(XAnchor, Vec3.One * thk * 2) * matrix,
new Color(1, 0, 0)
);
}
if (cornerDetect.y > 0) {
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(YAnchor, Vec3.One * thk * 2) * matrix,
new Color(0, 1, 0)
);
}
if (cornerDetect.z > 0) {
meshCube.Draw(matClear,
Mesh.Cube.Draw(matClear,
Matrix.TS(ZAnchor, Vec3.One * thk * 2) * matrix,
new Color(0, 0, 1)
);
}
}
meshCube.Draw(Mono.inst.matHolo,
Matrix.TRS(cursor, cursorOri, new Vec3(0.02f, 0.005f, 0.02f)),
Mesh.Sphere.Draw(Mono.inst.matHolo,
Matrix.TRS(cursor, cursorOri, new Vec3(0.02f, 0.02f, 0.02f)),
cursorColor
);
meshSphere.Draw(Mono.inst.matHolo,
Mesh.Sphere.Draw(Mono.inst.matHolo,
Matrix.TS(cursor, new Vec3(1f, 1f, 1f) * cursorRadius * 2),
new Color(0.1f, 0.1f, 0.1f)
);
@ -350,4 +345,5 @@ public class Oriel {
compositor
multi-oriel requires a compositor approach
even if you just start with input management
*/