summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-09-29 15:09:29 -0700
committeryum <yumfood@airmail.cc>2022-09-29 15:09:29 -0700
commit963f8aecb44a6cff83a75a60deec102562d79ff1 (patch)
tree86d1ad21a12ac732c7043d03416eab2b111daf33
parent6aecadd5f73fc92992435b2d210a55a01280de95 (diff)
delete SetLetters.cs
Doesn't work in game. Also change # of characters per slot to 80, down from 128. Also realize that VRChat supports 256 BITS of parameter, not 256 BYTES. Next design idea: * 3 8-bit parameters: letter, row, col * 1 boolean parameter: active * one animation for each slot/letter combo, as usual * one fx layer like this: if !active: do nothing if row == 0: if col == 0: if letter == 0: play row00_col00_letter00 animation * because write defaults are off, we should be able to "save" letters by simply setting active = false * thus we don't need to simultaneously address the entire board, saving memory
-rw-r--r--SetLetters.cs191
-rw-r--r--generate_animations.sh2
-rw-r--r--generate_fx.py10
-rw-r--r--osc_ctrl.py4
4 files changed, 9 insertions, 198 deletions
diff --git a/SetLetters.cs b/SetLetters.cs
deleted file mode 100644
index 558e3c2..0000000
--- a/SetLetters.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-// Expands a list of 4-byte parameters into a longer list of (effectively)
-// 1-byte parameters. The 1-byte parameters are easier to use in an animation
-// layer, since we can write conditions for them.
-[SharedBetweenAnimators]
-public class SetLetters : StateMachineBehaviour
-{
- Dictionary<string, int> letters_;
- List<string> cell_parameters_;
- List<string> group_parameters_;
-
- int GetLetterFromGroup(int g, int which)
- {
- return (((g & (0x000000FF << (which * 8))) >> (which * 8)) & 0x000000FF);
- }
-
- // This function is called in 2 contexts:
- // 1. animator.parameters contains everything we need. Updating params is not
- // reflected in emulator.
- // 2. animator.parameters contains nothing we need. Updating params is
- // reflected in emulator.
- override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
- {
- if (letters_ == null) {
- letters_ = new Dictionary<string, int>();
- }
-
- // I don't know why or how but Unity fucking refuses to save this variable,
- // so reinitialize it every time, YOLO.
- cell_parameters_ = new List<string> {
- "_Letter_Row00_Col00",
- "_Letter_Row00_Col01",
- "_Letter_Row00_Col02",
- "_Letter_Row00_Col03",
- "_Letter_Row00_Col04",
- "_Letter_Row00_Col05",
- "_Letter_Row00_Col06",
- "_Letter_Row00_Col07",
- "_Letter_Row00_Col08",
- "_Letter_Row00_Col09",
- "_Letter_Row00_Col10",
- "_Letter_Row00_Col11",
- "_Letter_Row00_Col12",
- "_Letter_Row00_Col13",
- "_Letter_Row01_Col00",
- "_Letter_Row01_Col01",
- "_Letter_Row01_Col02",
- "_Letter_Row01_Col03",
- "_Letter_Row01_Col04",
- "_Letter_Row01_Col05",
- "_Letter_Row01_Col06",
- "_Letter_Row01_Col07",
- "_Letter_Row01_Col08",
- "_Letter_Row01_Col09",
- "_Letter_Row01_Col10",
- "_Letter_Row01_Col11",
- "_Letter_Row01_Col12",
- "_Letter_Row01_Col13",
- "_Letter_Row02_Col00",
- "_Letter_Row02_Col01",
- "_Letter_Row02_Col02",
- "_Letter_Row02_Col03",
- "_Letter_Row02_Col04",
- "_Letter_Row02_Col05",
- "_Letter_Row02_Col06",
- "_Letter_Row02_Col07",
- "_Letter_Row02_Col08",
- "_Letter_Row02_Col09",
- "_Letter_Row02_Col10",
- "_Letter_Row02_Col11",
- "_Letter_Row02_Col12",
- "_Letter_Row02_Col13",
- "_Letter_Row03_Col00",
- "_Letter_Row03_Col01",
- "_Letter_Row03_Col02",
- "_Letter_Row03_Col03",
- "_Letter_Row03_Col04",
- "_Letter_Row03_Col05",
- "_Letter_Row03_Col06",
- "_Letter_Row03_Col07",
- "_Letter_Row03_Col08",
- "_Letter_Row03_Col09",
- "_Letter_Row03_Col10",
- "_Letter_Row03_Col11",
- "_Letter_Row03_Col12",
- "_Letter_Row03_Col13",
- "_Letter_Row04_Col00",
- "_Letter_Row04_Col01",
- "_Letter_Row04_Col02",
- "_Letter_Row04_Col03",
- "_Letter_Row04_Col04",
- "_Letter_Row04_Col05",
- "_Letter_Row04_Col06",
- "_Letter_Row04_Col07",
- "_Letter_Row04_Col08",
- "_Letter_Row04_Col09",
- "_Letter_Row04_Col10",
- "_Letter_Row04_Col11",
- "_Letter_Row04_Col12",
- "_Letter_Row04_Col13",
- "_Letter_Row05_Col00",
- "_Letter_Row05_Col01",
- "_Letter_Row05_Col02",
- "_Letter_Row05_Col03",
- "_Letter_Row05_Col04",
- "_Letter_Row05_Col05",
- "_Letter_Row05_Col06",
- "_Letter_Row05_Col07",
- "_Letter_Row05_Col08",
- "_Letter_Row05_Col09",
- "_Letter_Row05_Col10",
- "_Letter_Row05_Col11",
- "_Letter_Row05_Col12",
- "_Letter_Row05_Col13",
- };
- group_parameters_ = new List<string> {
- "_Letter_Row00_Col00_03",
- "_Letter_Row00_Col04_07",
- "_Letter_Row00_Col08_11",
- "_Letter_Row00_Col12_13",
- "_Letter_Row01_Col00_03",
- "_Letter_Row01_Col04_07",
- "_Letter_Row01_Col08_11",
- "_Letter_Row01_Col12_13",
- "_Letter_Row02_Col00_03",
- "_Letter_Row02_Col04_07",
- "_Letter_Row02_Col08_11",
- "_Letter_Row02_Col12_13",
- "_Letter_Row03_Col00_03",
- "_Letter_Row03_Col04_07",
- "_Letter_Row03_Col08_11",
- "_Letter_Row03_Col12_13",
- "_Letter_Row04_Col00_03",
- "_Letter_Row04_Col04_07",
- "_Letter_Row04_Col08_11",
- "_Letter_Row04_Col12_13",
- "_Letter_Row05_Col00_03",
- "_Letter_Row05_Col04_07",
- "_Letter_Row05_Col08_11",
- "_Letter_Row05_Col12_13",
- };
-
- bool got_match = false;
- foreach (var param in animator.parameters) {
- if (param.name == "_Letter_Row00_Col00_03") {
- got_match = true;
- break;
- }
- }
- if (!got_match) {
- if (!letters_.ContainsKey(cell_parameters_[0])) {
- return;
- }
- foreach (var param in cell_parameters_) {
- animator.SetInteger(param, letters_[param]);
- }
-
- return;
- }
-
- int cell_idx = 0;
- for (int i = 0; i < group_parameters_.Count; i++) {
- string group_param = group_parameters_[i];
- int g = animator.GetInteger(group_param);
-
- string cell_param = cell_parameters_[cell_idx];
- letters_[cell_param] = GetLetterFromGroup(g, 0);
- cell_idx += 1;
-
- cell_param = cell_parameters_[cell_idx];
- letters_[cell_param] = GetLetterFromGroup(g, 1);
- cell_idx += 1;
-
- // If we're on the last group of 4 in a row, we do not look at the cells,
- // since there are only 14 cells in each row.
- if (i % 4 != 3) {
- cell_param = cell_parameters_[cell_idx];
- letters_[cell_param] = GetLetterFromGroup(g, 2);
- cell_idx += 1;
-
- cell_param = cell_parameters_[cell_idx];
- letters_[cell_param] = GetLetterFromGroup(g, 3);
- cell_idx += 1;
- }
- }
- }
-}
diff --git a/generate_animations.sh b/generate_animations.sh
index 12e49f3..4ff4c3a 100644
--- a/generate_animations.sh
+++ b/generate_animations.sh
@@ -16,7 +16,7 @@ for row in `seq 0 5`; do
for col in `seq 0 13`; do
COL_PADDED=$(printf '%02d' $col)
LETTER_SHADER_PARAM=_Letter_Row${ROW_PADDED}_Col${COL_PADDED}
- for letter in `seq 0 128`; do
+ for letter in `seq 0 79`; do
LETTER_PADDED=$(printf '%02d' $letter)
ANIM_NAME=${LETTER_SHADER_PARAM}_Letter${LETTER_PADDED}
FILENAME=generated/animations/${ANIM_NAME}.anim
diff --git a/generate_fx.py b/generate_fx.py
index 2deadba..da64def 100644
--- a/generate_fx.py
+++ b/generate_fx.py
@@ -308,7 +308,7 @@ AnimatorState:
- {fileID: %SET_LETTERS_SCRIPT_U2%}
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
- m_WriteDefaultValues: 1
+ m_WriteDefaultValues: 0
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
@@ -455,7 +455,7 @@ def genCellAnimationLayers(state):
print(replaceMacros(CELL_LAYER_HEADER, params))
# Add a state for each animation, i.e. for each character writeable in this slot.
- for i in range(0,128):
+ for i in range(0,80):
params["CELL_LAYER_STATE_U2"] = get_u2(params["ANIMATOR_STATE_U"], state)
params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)] = params["CELL_LAYER_STATE_U2"]
params["STATE_Y"] = str(-190 - i * 40)
@@ -463,7 +463,7 @@ def genCellAnimationLayers(state):
print(CELL_LAYER_MIDDLE)
- for i in range(0,128):
+ for i in range(0,80):
params["CELL_LAYER_TRANSITION_U2"] = get_u2(params["ANIMATOR_STATE_TRANSITION_U"], state)
params["CELL_LAYER_TRANSITION_U2" + layer + ("_Letter%02d" % i)] = params["CELL_LAYER_TRANSITION_U2"]
print(replaceMacros(CELL_LAYER_TRANSITION_HEADER, params))
@@ -473,7 +473,7 @@ def genCellAnimationLayers(state):
print(replaceMacros(CELL_LAYER_SUFFIX, params))
# Done creating the layer header! Phew. Let's make the states next.
- for i in range(0,128):
+ for i in range(0,80):
params["ANIMATION_NAME"] = layer + ("_Letter%02d" % i)
params["CELL_LAYER_STATE_U2"] = params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)]
# Get the GUID of the animation we will play at this state.
@@ -482,7 +482,7 @@ def genCellAnimationLayers(state):
print(replaceMacros(CELL_LAYER_STATE, params))
# OK, finally, let's wire up the states.
- for i in range(0,128):
+ for i in range(0,80):
params["CELL_LAYER_TRANSITION_U2"] = params["CELL_LAYER_TRANSITION_U2" + layer + ("_Letter%02d" % i)]
params["TRANSITION_THRESHOLD"] = str(i)
params["CELL_LAYER_DST_STATE_U2"] = params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)]
diff --git a/osc_ctrl.py b/osc_ctrl.py
index 9a986a1..9cb33cf 100644
--- a/osc_ctrl.py
+++ b/osc_ctrl.py
@@ -19,7 +19,9 @@ client = udp_client.SimpleUDPClient(args.i, args.p)
for i in range(1,100):
addr="/avatar/parameters/_Letter_Row00_Col00_03"
- msg = ((15 << 24) | (16 << 16) | (17 << 8) | 18)
+ #addr="/avatar/parameters/_Letter_Row00_Col00"
+ #msg = ((15 << 24) | (16 << 16) | (17 << 8) | 18)
+ msg = i % 2
print("send {} to {}".format(msg, addr))
client.send_message(addr, msg)
time.sleep(1)