Skip to content

Commit

Permalink
hand tracking progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzo committed Aug 13, 2024
1 parent 04c1744 commit de38a17
Show file tree
Hide file tree
Showing 21 changed files with 1,144 additions and 753 deletions.
50 changes: 0 additions & 50 deletions CONTRIBUTING.md

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Speedrun utilities for Stress Level Zero games.
Collection of my Boneworks/Bonelab mods and tools.

## Structure

The speedrun mods are under `projects/GAMENAME`. Common code is included in `common`.
The mods/tools are under `projects/CATEGORY`. Common code is included in `common`.
24 changes: 6 additions & 18 deletions common/Utilities/Colliders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ public static ColliderVisualization Visualize(
switch (castedCollider) {
case BoxCollider boxCollider: {
visualization = GameObject.Instantiate(DebugColliderPrefabs.BOX, parent);
SetMaterial(visualization, color, shader);
Geometry.SetMaterial(visualization, color, shader);
visualization.active = true;
break;
}

case SphereCollider sphereCollider: {
visualization =
GameObject.Instantiate(DebugColliderPrefabs.SPHERE, parent);
SetMaterial(visualization, color, shader);
Geometry.SetMaterial(visualization, color, shader);
visualization.active = true;
break;
}
Expand All @@ -198,18 +198,18 @@ public static ColliderVisualization Visualize(
var cylinder = GameObject.Instantiate(
DebugColliderPrefabs.CYLINDER, visualization.transform
);
SetMaterial(cylinder, color, shader);
Geometry.SetMaterial(cylinder, color, shader);
cylinder.active = true;
var endA = GameObject.Instantiate(
DebugColliderPrefabs.SPHERE, visualization.transform
);
SetMaterial(endA, color, shader);
Geometry.SetMaterial(endA, color, shader);
endA.active = true;
endA.transform.localPosition = new Vector3(0, -0.5f, 0);
var endB = GameObject.Instantiate(
DebugColliderPrefabs.SPHERE, visualization.transform
);
SetMaterial(endB, color, shader);
Geometry.SetMaterial(endB, color, shader);
endB.active = true;
endB.transform.localPosition = new Vector3(0, 0.5f, 0);
visualization.transform.SetParent(parent, false);
Expand All @@ -221,7 +221,7 @@ public static ColliderVisualization Visualize(
var meshFilter = visualization.AddComponent<MeshFilter>();
meshFilter.mesh = meshCollider.sharedMesh;
var meshRenderer = visualization.AddComponent<MeshRenderer>();
SetMaterial(meshRenderer.gameObject, color, shader);
Geometry.SetMaterial(meshRenderer.gameObject, color, shader);
visualization.transform.SetParent(parent, false);
visualization.active = true;
break;
Expand Down Expand Up @@ -340,17 +340,5 @@ private bool NeedsUpdate(Vector3 center, Vector3 other) {
return true;
}
}

private static void
SetMaterial(GameObject gameObject, Color color, Shader shader = null) {
var meshRenderer = gameObject.GetComponent<MeshRenderer>();
meshRenderer.shadowCastingMode =
UnityEngine.Rendering.ShadowCastingMode.Off;
meshRenderer.receiveShadows = false;
var material = meshRenderer.material;
if (shader != null)
material.shader = shader;
material.color = color;
}
}
}
12 changes: 12 additions & 0 deletions common/Utilities/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,17 @@ public static (Vector3[], int[], Vector3[])
return (vertices.ToArray(), triangles, normals);
}
}

public static void
SetMaterial(GameObject gameObject, Color color, Shader shader = null) {
var meshRenderer = gameObject.GetComponent<MeshRenderer>();
meshRenderer.shadowCastingMode =
UnityEngine.Rendering.ShadowCastingMode.Off;
meshRenderer.receiveShadows = false;
var material = meshRenderer.material;
if (shader != null)
material.shader = shader;
material.color = color;
}
}
}
20 changes: 11 additions & 9 deletions common/Utilities/Shaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
using UnityEngine;

namespace Sst.Utilities {
public class Shaders {
public static class Shaders {
private static Shader _defaultShader;
public static Shader DefaultShader {
get => _defaultShader ??
(_defaultShader = Resources.FindObjectsOfTypeAll<Shader>().First(
shader => shader.name == "Sprites/Default"
));
get => _defaultShader != null
? _defaultShader
: (_defaultShader = Resources.FindObjectsOfTypeAll<Shader>().First(
shader => shader.name == "Sprites/Default"
));
}

private static Shader _highlightShader;
public static Shader HighlightShader {
get => _highlightShader ??
(_highlightShader = Resources.FindObjectsOfTypeAll<Shader>().First(
shader => shader.name == "SLZ/Highlighter"
));
get => _highlightShader != null
? _highlightShader
: (_highlightShader = Resources.FindObjectsOfTypeAll<Shader>().First(
shader => shader.name == "SLZ/Highlighter"
));
}
}
}
3 changes: 2 additions & 1 deletion projects/Bonelab/HandTracking/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
<Compile Include="../../../common/Utilities/Dbg.cs" />
<Compile Include="../../../common/Utilities/Geometry.cs" />
<Compile Include="../../../common/Utilities/FpsCounter.cs" />
<Compile Include="../../../common/Utilities/Shaders.cs" />
<Compile Include="../../../common/Bonelab/LevelHooks.cs" />
<Compile Include="../../../common/Bonelab/Levels.cs" />
<Compile Include="../../../common/Bonelab/Bonelab.cs" />
</ItemGroup>

</Project>
</Project>
6 changes: 5 additions & 1 deletion projects/Bonelab/HandTracking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Adds support for hand tracking.

- This mod is for the **patch 4 Quest standalone** version of the game
- Install **Melon Loader 0.5.7** via Lemon Loader
- Add the hand tracking permission to the game APK using Quest Patcher
- Add the hand tracking permission to the game APK using [Quest Patcher](https://github.com/Lauriethefish/QuestPatcher)
- **IMPORTANT: This will RESET YOUR GAME and you will LOSE YOUR SAVE AND MODS so back them up first**
- Until [my PR to add the "mod loader: none" option](https://github.com/Lauriethefish/QuestPatcher/pull/188) is merged, you will need to download [my fork of Quest Patcher](https://github.com/jakzo/QuestPatcher/releases) instead of the official one
- Go to the "Tools & Options" tab -> click the "Change App" button -> select `com.StressLevelZero.BONELAB`
- Go to the "Patching" tab -> **select `None` for the mod loader** (you should have already installed Melon Loader)
- Click "Patching Options" -> **scroll to "Hand Tracking Type" -> select `V2`**
Expand All @@ -14,6 +15,9 @@ Adds support for hand tracking.
- Make sure hand tracking is enabled in your Quest settings
- You should know by putting your controllers down while in the Quest menu and it switches to hands within a few seconds
- Start the game
- For best results make sure your settings match these defaults:
- Locomotion controlled by left controller (right handed mode)
- Movement direction is direction of head

## Usage

Expand Down
2 changes: 1 addition & 1 deletion projects/Bonelab/HandTracking/build-and-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd "$(dirname $0)"
dotnet build ./Project.csproj

# TIP: Enable wireless mode from SideQuest
adb connect 192.168.0.69
# adb connect 192.168.0.69

FILE=HandTracking.P4.ML5.dll
adb shell am force-stop com.StressLevelZero.BONELAB
Expand Down
Loading

0 comments on commit de38a17

Please sign in to comment.