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
|
||||
|
||||
**[ 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!
|
||||
|
||||
## init
|
||||
|
@ -33,8 +34,11 @@ sudo chmod 666 /dev/ttyUSB0
|
|||
|
||||
## <3
|
||||
[Bryan Chris Brown](https://twitter.com/BryanChrisBrown)
|
||||
|
||||
[StereoNick](https://twitter.com/koujaku)
|
||||
|
||||
[Peter Sassaman](https://twitter.com/PeterSassaman)
|
||||
|
||||
[Lucas De Bonet (LucidVR)](https://twitter.com/VrLucid)
|
||||
|
||||
|
||||
|
|
|
@ -2,22 +2,26 @@ namespace Main;
|
|||
|
||||
using System.Runtime.InteropServices;
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct oriel_data {
|
||||
struct oriel_data
|
||||
{
|
||||
public Matrix m4;
|
||||
public Matrix m4_inv;
|
||||
public Vec3 size;
|
||||
public float pad; // padding (16 byte alignment)
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
unsafe struct oriel_buffer {
|
||||
unsafe struct oriel_buffer
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 455)] // 455 *see dofdev.hlsli
|
||||
public oriel_data[] oriels;
|
||||
}
|
||||
|
||||
public class Mat {
|
||||
public class Mat
|
||||
{
|
||||
MaterialBuffer<oriel_buffer> buffer = new(3);
|
||||
oriel_buffer data = new();
|
||||
public void SetOriel(int id, Matrix m4, Vec3 size) {
|
||||
public void SetOriel(int id, Matrix m4, Vec3 size)
|
||||
{
|
||||
data.oriels[id].m4 = (Matrix)System.Numerics.Matrix4x4.Transpose(
|
||||
m4.Inverse
|
||||
);
|
||||
|
@ -29,7 +33,8 @@ public class Mat {
|
|||
}
|
||||
|
||||
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.SampleMode = TexSample.Point;
|
||||
mat.SetTexture("diffuse", tex);
|
||||
|
@ -40,7 +45,8 @@ public class Mat {
|
|||
public Material unlit = 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
|
||||
|
||||
mono.FaceCull = Cull.None;
|
||||
|
@ -50,7 +56,8 @@ public class Mat {
|
|||
unlit_clear.DepthWrite = false;
|
||||
}
|
||||
|
||||
public void Run() {
|
||||
public void Run()
|
||||
{
|
||||
Rig rig = Main.Mono.inst.rig;
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
using System.Security.AccessControl;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
namespace Main;
|
||||
public class Mono {
|
||||
public class Mono
|
||||
{
|
||||
private static readonly Lazy<Mono> lazy = new(() => new Mono());
|
||||
public static Mono inst { get { return lazy.Value; } }
|
||||
|
||||
public static readonly bool dev = Environment.CommandLine.Contains("--dev");
|
||||
|
||||
|
||||
public MonoNet monoNet = new();
|
||||
|
||||
public Rig rig = new();
|
||||
|
@ -184,7 +186,8 @@ public class Mono {
|
|||
};
|
||||
|
||||
// enum of layouts
|
||||
public enum Layout {
|
||||
public enum Layout
|
||||
{
|
||||
Qwerty,
|
||||
Colemak
|
||||
}
|
||||
|
@ -202,7 +205,8 @@ public class Mono {
|
|||
} },
|
||||
};
|
||||
|
||||
public char KeyToChar(int index) {
|
||||
public char KeyToChar(int index)
|
||||
{
|
||||
return layouts[Layout.Colemak][index];
|
||||
}
|
||||
|
||||
|
@ -214,7 +218,8 @@ public class Mono {
|
|||
|
||||
string txt = "hello ";
|
||||
|
||||
public void Init() {
|
||||
public void Init()
|
||||
{
|
||||
rig.Init();
|
||||
|
||||
mat.Init();
|
||||
|
@ -226,7 +231,8 @@ public class Mono {
|
|||
keyboard_btn.held = true;
|
||||
}
|
||||
|
||||
public void Run() {
|
||||
public void Run()
|
||||
{
|
||||
rig.Run();
|
||||
|
||||
keyboard_m4 = Matrix.TRS(
|
||||
|
@ -243,8 +249,10 @@ public class Mono {
|
|||
// // Log.Info("thumb is out");
|
||||
// xi = 0;
|
||||
// }
|
||||
for (int i = 0; i < keb_keys.Length-1; i++) {
|
||||
if (Input.Key(keb_keys[i].key).IsJustActive()) {
|
||||
for (int i = 0; i < keb_keys.Length - 1; i++)
|
||||
{
|
||||
if (Input.Key(keb_keys[i].key).IsJustActive())
|
||||
{
|
||||
txt += keb_keys[i].char_;
|
||||
monoNet.value = keb_keys[i].char_;
|
||||
monoNet.send = true;
|
||||
|
@ -256,14 +264,16 @@ public class Mono {
|
|||
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);
|
||||
|
||||
if (!keyboard_btn.held) {
|
||||
if (!keyboard_btn.held)
|
||||
{
|
||||
// snap to grid
|
||||
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_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;
|
||||
// Log.Info($"index_i: {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
|
||||
txt += KeyToChar(index_i);
|
||||
}
|
||||
|
@ -282,8 +293,10 @@ public class Mono {
|
|||
// keyboard
|
||||
Hierarchy.Push(keyboard_m4);
|
||||
// 3 rows of 10 keys
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 10; x++) {
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 10; x++)
|
||||
{
|
||||
Vec3 pos = V.XYZ(x, y, 0);
|
||||
// background quad
|
||||
Mesh.Quad.Draw(
|
||||
|
@ -306,11 +319,13 @@ public class Mono {
|
|||
0, 0, 0
|
||||
);
|
||||
// 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 x_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(
|
||||
mat.unlit_clear,
|
||||
Matrix.TS(
|
||||
|
@ -403,7 +418,8 @@ public class Mono {
|
|||
new() { key = Key.Y, char_ = 'y' },
|
||||
new() { key = Key.Z, char_ = 'z' },
|
||||
};
|
||||
public struct KebKey {
|
||||
public struct KebKey
|
||||
{
|
||||
public Key key;
|
||||
public char char_;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ using System.Net.Http;
|
|||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
public class MonoNet {
|
||||
public class MonoNet
|
||||
{
|
||||
public Socket socket;
|
||||
int bufferSize = 180; // ?
|
||||
byte[] wData; int wHead;
|
||||
|
@ -12,10 +13,11 @@ public class MonoNet {
|
|||
public char value = ' ';
|
||||
|
||||
|
||||
public MonoNet() {
|
||||
public MonoNet()
|
||||
{
|
||||
|
||||
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);
|
||||
socket.Connect(serverEndPoint);
|
||||
|
@ -29,11 +31,14 @@ public class MonoNet {
|
|||
writeThread.Start();
|
||||
}
|
||||
|
||||
void Write() {
|
||||
void Write()
|
||||
{
|
||||
bool running = true;
|
||||
while (running) {
|
||||
while (running)
|
||||
{
|
||||
Thread.Sleep(60);
|
||||
if (send) {
|
||||
if (send)
|
||||
{
|
||||
wHead = 0;
|
||||
BitConverter.GetBytes(value).CopyTo(wData, wHead);
|
||||
socket.Send(wData);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
public class Rig {
|
||||
public class Rig
|
||||
{
|
||||
public Vec3 head_pos = Vec3.Zero;
|
||||
public Quat head_ori = Quat.Identity;
|
||||
public Vec3 view_pos = Vec3.Zero;
|
||||
|
@ -10,10 +11,13 @@ public class Rig {
|
|||
|
||||
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_1 = Input.Hand(Handed.Right);
|
||||
|
||||
|
@ -31,11 +35,14 @@ public class Rig {
|
|||
perch_pos = palm_pos + Vec3.Up * 8 * U.cm;
|
||||
}
|
||||
|
||||
public struct Btn {
|
||||
public struct Btn
|
||||
{
|
||||
public bool frameDown, held, frameUp;
|
||||
|
||||
public void Frame(bool down, bool? up = null) {
|
||||
if (up != null && held) {
|
||||
public void Frame(bool down, bool? up = null)
|
||||
{
|
||||
if (up != null && held)
|
||||
{
|
||||
down = !(bool)up;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,16 @@ global using StereoKit;
|
|||
Log.Filter = LogLevel.Info;
|
||||
Log.Info("hello log!");
|
||||
|
||||
SKSettings settings = new() {
|
||||
SKSettings settings = new()
|
||||
{
|
||||
appName = "dofbox",
|
||||
|
||||
assetsFolder = "res",
|
||||
depthMode = DepthMode.D32,
|
||||
disableUnfocusedSleep = true,
|
||||
flatscreenWidth = 1280,
|
||||
flatscreenHeight = 720,
|
||||
// displayPreference = DisplayMode.Flatscreen,
|
||||
displayPreference = DisplayMode.Flatscreen,
|
||||
// disableFlatscreenMRSim = true,
|
||||
origin = OriginMode.Floor,
|
||||
overlayApp = true,
|
||||
|
@ -34,6 +36,7 @@ Renderer.SetFOV(60f);
|
|||
|
||||
Main.Mono mono = Main.Mono.inst;
|
||||
mono.Init();
|
||||
SK.Run(() => {
|
||||
SK.Run(() =>
|
||||
{
|
||||
mono.Run();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue