formatting
This commit is contained in:
parent
03aa785a38
commit
225f3aa9b2
7 changed files with 355 additions and 313 deletions
|
@ -2,6 +2,7 @@
|
||||||
refreshable braille display for rendering and input with handtracking
|
refreshable braille display for rendering and input with handtracking
|
||||||
|
|
||||||
**[ disclaimer ]**
|
**[ disclaimer ]**
|
||||||
|
|
||||||
this early repo may require special help/information depending on your setup and prior knowledge - so do not hesitate to reach out to [@spatialfree](https://x.com/spatialfree) with any questions!
|
this early repo may require special help/information depending on your setup and prior knowledge - so do not hesitate to reach out to [@spatialfree](https://x.com/spatialfree) with any questions!
|
||||||
|
|
||||||
## init
|
## init
|
||||||
|
@ -33,8 +34,11 @@ sudo chmod 666 /dev/ttyUSB0
|
||||||
|
|
||||||
## <3
|
## <3
|
||||||
[Bryan Chris Brown](https://twitter.com/BryanChrisBrown)
|
[Bryan Chris Brown](https://twitter.com/BryanChrisBrown)
|
||||||
|
|
||||||
[StereoNick](https://twitter.com/koujaku)
|
[StereoNick](https://twitter.com/koujaku)
|
||||||
|
|
||||||
[Peter Sassaman](https://twitter.com/PeterSassaman)
|
[Peter Sassaman](https://twitter.com/PeterSassaman)
|
||||||
|
|
||||||
[Lucas De Bonet (LucidVR)](https://twitter.com/VrLucid)
|
[Lucas De Bonet (LucidVR)](https://twitter.com/VrLucid)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,26 @@ namespace Main;
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct oriel_data {
|
struct oriel_data
|
||||||
|
{
|
||||||
public Matrix m4;
|
public Matrix m4;
|
||||||
public Matrix m4_inv;
|
public Matrix m4_inv;
|
||||||
public Vec3 size;
|
public Vec3 size;
|
||||||
public float pad; // padding (16 byte alignment)
|
public float pad; // padding (16 byte alignment)
|
||||||
}
|
}
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
unsafe struct oriel_buffer {
|
unsafe struct oriel_buffer
|
||||||
|
{
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 455)] // 455 *see dofdev.hlsli
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 455)] // 455 *see dofdev.hlsli
|
||||||
public oriel_data[] oriels;
|
public oriel_data[] oriels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Mat {
|
public class Mat
|
||||||
MaterialBuffer<oriel_buffer> buffer = new (3);
|
{
|
||||||
oriel_buffer data = new ();
|
MaterialBuffer<oriel_buffer> buffer = new(3);
|
||||||
public void SetOriel(int id, Matrix m4, Vec3 size) {
|
oriel_buffer data = new();
|
||||||
|
public void SetOriel(int id, Matrix m4, Vec3 size)
|
||||||
|
{
|
||||||
data.oriels[id].m4 = (Matrix)System.Numerics.Matrix4x4.Transpose(
|
data.oriels[id].m4 = (Matrix)System.Numerics.Matrix4x4.Transpose(
|
||||||
m4.Inverse
|
m4.Inverse
|
||||||
);
|
);
|
||||||
|
@ -28,19 +32,21 @@ public class Mat {
|
||||||
buffer.Set(data);
|
buffer.Set(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material mono = new (Shader.FromFile("shaders/mono.hlsl"));
|
public Material mono = new(Shader.FromFile("shaders/mono.hlsl"));
|
||||||
public void SetAtlas(string name, Material mat) {
|
public void SetAtlas(string name, Material mat)
|
||||||
|
{
|
||||||
Tex tex = Tex.FromFile($"{name}/{name}.png");
|
Tex tex = Tex.FromFile($"{name}/{name}.png");
|
||||||
tex.SampleMode = TexSample.Point;
|
tex.SampleMode = TexSample.Point;
|
||||||
mat.SetTexture("diffuse", tex);
|
mat.SetTexture("diffuse", tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material sky = new (Shader.FromFile("shaders/sky.hlsl"));
|
public Material sky = new(Shader.FromFile("shaders/sky.hlsl"));
|
||||||
|
|
||||||
public Material unlit = new (Shader.FromFile("shaders/unlit.hlsl"));
|
public Material unlit = new(Shader.FromFile("shaders/unlit.hlsl"));
|
||||||
public Material unlit_clear = new (Shader.FromFile("shaders/unlit.hlsl"));
|
public Material unlit_clear = new(Shader.FromFile("shaders/unlit.hlsl"));
|
||||||
|
|
||||||
public void Init() {
|
public void Init()
|
||||||
|
{
|
||||||
data.oriels = new oriel_data[455]; // 455 *see dofdev.hlsli
|
data.oriels = new oriel_data[455]; // 455 *see dofdev.hlsli
|
||||||
|
|
||||||
mono.FaceCull = Cull.None;
|
mono.FaceCull = Cull.None;
|
||||||
|
@ -50,7 +56,8 @@ public class Mat {
|
||||||
unlit_clear.DepthWrite = false;
|
unlit_clear.DepthWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run() {
|
public void Run()
|
||||||
|
{
|
||||||
Rig rig = Main.Mono.inst.rig;
|
Rig rig = Main.Mono.inst.rig;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
|
|
||||||
namespace Main;
|
namespace Main;
|
||||||
public class Mono {
|
public class Mono
|
||||||
|
{
|
||||||
private static readonly Lazy<Mono> lazy = new(() => new Mono());
|
private static readonly Lazy<Mono> lazy = new(() => new Mono());
|
||||||
public static Mono inst { get { return lazy.Value; } }
|
public static Mono inst { get { return lazy.Value; } }
|
||||||
|
|
||||||
public static readonly bool dev = Environment.CommandLine.Contains("--dev");
|
public static readonly bool dev = Environment.CommandLine.Contains("--dev");
|
||||||
|
|
||||||
|
|
||||||
public MonoNet monoNet = new();
|
public MonoNet monoNet = new();
|
||||||
|
|
||||||
public Rig rig = new();
|
public Rig rig = new();
|
||||||
|
@ -15,7 +17,7 @@ public class Mono {
|
||||||
public Mat mat = new();
|
public Mat mat = new();
|
||||||
Mesh mesh_floor = Mesh.Quad;
|
Mesh mesh_floor = Mesh.Quad;
|
||||||
|
|
||||||
Material mat_room = new (Shader.FromFile("shaders/room.hlsl"));
|
Material mat_room = new(Shader.FromFile("shaders/room.hlsl"));
|
||||||
Model model_room = Model.FromFile("room.glb");
|
Model model_room = Model.FromFile("room.glb");
|
||||||
Mesh mesh_room = Mesh.Quad;
|
Mesh mesh_room = Mesh.Quad;
|
||||||
|
|
||||||
|
@ -184,7 +186,8 @@ public class Mono {
|
||||||
};
|
};
|
||||||
|
|
||||||
// enum of layouts
|
// enum of layouts
|
||||||
public enum Layout {
|
public enum Layout
|
||||||
|
{
|
||||||
Qwerty,
|
Qwerty,
|
||||||
Colemak
|
Colemak
|
||||||
}
|
}
|
||||||
|
@ -202,7 +205,8 @@ public class Mono {
|
||||||
} },
|
} },
|
||||||
};
|
};
|
||||||
|
|
||||||
public char KeyToChar(int index) {
|
public char KeyToChar(int index)
|
||||||
|
{
|
||||||
return layouts[Layout.Colemak][index];
|
return layouts[Layout.Colemak][index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +218,8 @@ public class Mono {
|
||||||
|
|
||||||
string txt = "hello ";
|
string txt = "hello ";
|
||||||
|
|
||||||
public void Init() {
|
public void Init()
|
||||||
|
{
|
||||||
rig.Init();
|
rig.Init();
|
||||||
|
|
||||||
mat.Init();
|
mat.Init();
|
||||||
|
@ -226,7 +231,8 @@ public class Mono {
|
||||||
keyboard_btn.held = true;
|
keyboard_btn.held = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run() {
|
public void Run()
|
||||||
|
{
|
||||||
rig.Run();
|
rig.Run();
|
||||||
|
|
||||||
keyboard_m4 = Matrix.TRS(
|
keyboard_m4 = Matrix.TRS(
|
||||||
|
@ -243,8 +249,10 @@ public class Mono {
|
||||||
// // Log.Info("thumb is out");
|
// // Log.Info("thumb is out");
|
||||||
// xi = 0;
|
// xi = 0;
|
||||||
// }
|
// }
|
||||||
for (int i = 0; i < keb_keys.Length-1; i++) {
|
for (int i = 0; i < keb_keys.Length - 1; i++)
|
||||||
if (Input.Key(keb_keys[i].key).IsJustActive()) {
|
{
|
||||||
|
if (Input.Key(keb_keys[i].key).IsJustActive())
|
||||||
|
{
|
||||||
txt += keb_keys[i].char_;
|
txt += keb_keys[i].char_;
|
||||||
monoNet.value = keb_keys[i].char_;
|
monoNet.value = keb_keys[i].char_;
|
||||||
monoNet.send = true;
|
monoNet.send = true;
|
||||||
|
@ -256,14 +264,16 @@ public class Mono {
|
||||||
index_pos.z = Math.Clamp(index_tip.z, -0.3f, 0.1f);
|
index_pos.z = Math.Clamp(index_tip.z, -0.3f, 0.1f);
|
||||||
keyboard_btn.Frame(index_pos.z > 0.0f, index_pos.z < -0.2f);
|
keyboard_btn.Frame(index_pos.z > 0.0f, index_pos.z < -0.2f);
|
||||||
|
|
||||||
if (!keyboard_btn.held) {
|
if (!keyboard_btn.held)
|
||||||
|
{
|
||||||
// snap to grid
|
// snap to grid
|
||||||
index_pos.x = (float)Math.Clamp(Math.Round(index_tip.x), 0, 10-1);
|
index_pos.x = (float)Math.Clamp(Math.Round(index_tip.x), 0, 10 - 1);
|
||||||
index_pos.y = (float)Math.Clamp(Math.Round(index_tip.y), 0, 3-1);
|
index_pos.y = (float)Math.Clamp(Math.Round(index_tip.y), 0, 3 - 1);
|
||||||
|
|
||||||
index_i = (int)(index_pos.y * 10 + index_pos.x);
|
index_i = (int)(index_pos.y * 10 + index_pos.x);
|
||||||
|
|
||||||
if (index_i != last_index_i) {
|
if (index_i != last_index_i)
|
||||||
|
{
|
||||||
last_index_i = index_i;
|
last_index_i = index_i;
|
||||||
// Log.Info($"index_i: {index_i}");
|
// Log.Info($"index_i: {index_i}");
|
||||||
monoNet.value = KeyToChar(index_i);
|
monoNet.value = KeyToChar(index_i);
|
||||||
|
@ -271,7 +281,8 @@ public class Mono {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyboard_btn.frameDown) {
|
if (keyboard_btn.frameDown)
|
||||||
|
{
|
||||||
// send haptic input for input confirmation
|
// send haptic input for input confirmation
|
||||||
txt += KeyToChar(index_i);
|
txt += KeyToChar(index_i);
|
||||||
}
|
}
|
||||||
|
@ -282,8 +293,10 @@ public class Mono {
|
||||||
// keyboard
|
// keyboard
|
||||||
Hierarchy.Push(keyboard_m4);
|
Hierarchy.Push(keyboard_m4);
|
||||||
// 3 rows of 10 keys
|
// 3 rows of 10 keys
|
||||||
for (int y = 0; y < 3; y++) {
|
for (int y = 0; y < 3; y++)
|
||||||
for (int x = 0; x < 10; x++) {
|
{
|
||||||
|
for (int x = 0; x < 10; x++)
|
||||||
|
{
|
||||||
Vec3 pos = V.XYZ(x, y, 0);
|
Vec3 pos = V.XYZ(x, y, 0);
|
||||||
// background quad
|
// background quad
|
||||||
Mesh.Quad.Draw(
|
Mesh.Quad.Draw(
|
||||||
|
@ -306,11 +319,13 @@ public class Mono {
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
);
|
);
|
||||||
// show the braille dots(spheres) above the text
|
// show the braille dots(spheres) above the text
|
||||||
for (int k = 0; k < 6; k++) {
|
for (int k = 0; k < 6; k++)
|
||||||
|
{
|
||||||
float spacing = 0.2f;
|
float spacing = 0.2f;
|
||||||
float x_offset = (k % 2) * spacing;
|
float x_offset = (k % 2) * spacing;
|
||||||
float y_offset = (k / 2) * -spacing;
|
float y_offset = (k / 2) * -spacing;
|
||||||
if (char_cell[keychar][k] == 1) {
|
if (char_cell[keychar][k] == 1)
|
||||||
|
{
|
||||||
Mesh.Sphere.Draw(
|
Mesh.Sphere.Draw(
|
||||||
mat.unlit_clear,
|
mat.unlit_clear,
|
||||||
Matrix.TS(
|
Matrix.TS(
|
||||||
|
@ -359,7 +374,7 @@ public class Mono {
|
||||||
mat.unlit,
|
mat.unlit,
|
||||||
Matrix.TS(
|
Matrix.TS(
|
||||||
V.XYZ(0, 0, 0),
|
V.XYZ(0, 0, 0),
|
||||||
1*U.cm
|
1 * U.cm
|
||||||
),
|
),
|
||||||
Color.Hex(0x666666FF)
|
Color.Hex(0x666666FF)
|
||||||
);
|
);
|
||||||
|
@ -403,7 +418,8 @@ public class Mono {
|
||||||
new() { key = Key.Y, char_ = 'y' },
|
new() { key = Key.Y, char_ = 'y' },
|
||||||
new() { key = Key.Z, char_ = 'z' },
|
new() { key = Key.Z, char_ = 'z' },
|
||||||
};
|
};
|
||||||
public struct KebKey {
|
public struct KebKey
|
||||||
|
{
|
||||||
public Key key;
|
public Key key;
|
||||||
public char char_;
|
public char char_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ using System.Net.Http;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
public class MonoNet {
|
public class MonoNet
|
||||||
|
{
|
||||||
public Socket socket;
|
public Socket socket;
|
||||||
int bufferSize = 180; // ?
|
int bufferSize = 180; // ?
|
||||||
byte[] wData; int wHead;
|
byte[] wData; int wHead;
|
||||||
|
@ -12,10 +13,11 @@ public class MonoNet {
|
||||||
public char value = ' ';
|
public char value = ' ';
|
||||||
|
|
||||||
|
|
||||||
public MonoNet() {
|
public MonoNet()
|
||||||
|
{
|
||||||
|
|
||||||
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
string ip = "192.168.0.23";
|
string ip = "192.168.1.117";
|
||||||
|
|
||||||
EndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 1234);
|
EndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 1234);
|
||||||
socket.Connect(serverEndPoint);
|
socket.Connect(serverEndPoint);
|
||||||
|
@ -29,11 +31,14 @@ public class MonoNet {
|
||||||
writeThread.Start();
|
writeThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write() {
|
void Write()
|
||||||
|
{
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running) {
|
while (running)
|
||||||
|
{
|
||||||
Thread.Sleep(60);
|
Thread.Sleep(60);
|
||||||
if (send) {
|
if (send)
|
||||||
|
{
|
||||||
wHead = 0;
|
wHead = 0;
|
||||||
BitConverter.GetBytes(value).CopyTo(wData, wHead);
|
BitConverter.GetBytes(value).CopyTo(wData, wHead);
|
||||||
socket.Send(wData);
|
socket.Send(wData);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
public class Rig {
|
public class Rig
|
||||||
|
{
|
||||||
public Vec3 head_pos = Vec3.Zero;
|
public Vec3 head_pos = Vec3.Zero;
|
||||||
public Quat head_ori = Quat.Identity;
|
public Quat head_ori = Quat.Identity;
|
||||||
public Vec3 view_pos = Vec3.Zero;
|
public Vec3 view_pos = Vec3.Zero;
|
||||||
|
@ -10,16 +11,19 @@ public class Rig {
|
||||||
|
|
||||||
public Vec3 perch_pos = Vec3.Zero;
|
public Vec3 perch_pos = Vec3.Zero;
|
||||||
|
|
||||||
public void Init() {
|
public void Init()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run() {
|
public void Run()
|
||||||
|
{
|
||||||
hand_0 = Input.Hand(Handed.Left);
|
hand_0 = Input.Hand(Handed.Left);
|
||||||
hand_1 = Input.Hand(Handed.Right);
|
hand_1 = Input.Hand(Handed.Right);
|
||||||
|
|
||||||
head_pos = Main.Mono.dev && Time.Totalf > 0.5f ? head_pos : Input.Head.position;
|
head_pos = Main.Mono.dev && Time.Totalf > 0.5f ? head_pos : Input.Head.position;
|
||||||
head_ori = Main.Mono.dev && Time.Totalf > 0.5f ? head_ori : Input.Head.orientation;
|
head_ori = Main.Mono.dev && Time.Totalf > 0.5f ? head_ori : Input.Head.orientation;
|
||||||
view_pos = head_pos + V.XYZ(0, -6*U.cm, 0);
|
view_pos = head_pos + V.XYZ(0, -6 * U.cm, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,11 +35,14 @@ public class Rig {
|
||||||
perch_pos = palm_pos + Vec3.Up * 8 * U.cm;
|
perch_pos = palm_pos + Vec3.Up * 8 * U.cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Btn {
|
public struct Btn
|
||||||
|
{
|
||||||
public bool frameDown, held, frameUp;
|
public bool frameDown, held, frameUp;
|
||||||
|
|
||||||
public void Frame(bool down, bool? up = null) {
|
public void Frame(bool down, bool? up = null)
|
||||||
if (up != null && held) {
|
{
|
||||||
|
if (up != null && held)
|
||||||
|
{
|
||||||
down = !(bool)up;
|
down = !(bool)up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,16 @@ global using StereoKit;
|
||||||
Log.Filter = LogLevel.Info;
|
Log.Filter = LogLevel.Info;
|
||||||
Log.Info("hello log!");
|
Log.Info("hello log!");
|
||||||
|
|
||||||
SKSettings settings = new() {
|
SKSettings settings = new()
|
||||||
|
{
|
||||||
appName = "dofbox",
|
appName = "dofbox",
|
||||||
|
|
||||||
assetsFolder = "res",
|
assetsFolder = "res",
|
||||||
depthMode = DepthMode.D32,
|
depthMode = DepthMode.D32,
|
||||||
disableUnfocusedSleep = true,
|
disableUnfocusedSleep = true,
|
||||||
flatscreenWidth = 1280,
|
flatscreenWidth = 1280,
|
||||||
flatscreenHeight = 720,
|
flatscreenHeight = 720,
|
||||||
// displayPreference = DisplayMode.Flatscreen,
|
displayPreference = DisplayMode.Flatscreen,
|
||||||
// disableFlatscreenMRSim = true,
|
// disableFlatscreenMRSim = true,
|
||||||
origin = OriginMode.Floor,
|
origin = OriginMode.Floor,
|
||||||
overlayApp = true,
|
overlayApp = true,
|
||||||
|
@ -34,6 +36,7 @@ Renderer.SetFOV(60f);
|
||||||
|
|
||||||
Main.Mono mono = Main.Mono.inst;
|
Main.Mono mono = Main.Mono.inst;
|
||||||
mono.Init();
|
mono.Init();
|
||||||
SK.Run(() => {
|
SK.Run(() =>
|
||||||
|
{
|
||||||
mono.Run();
|
mono.Run();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue