👍️[Update] Model/View : rename "depth" -> " z_pos"
This commit is contained in:
@@ -770,7 +770,7 @@ class Config:
|
||||
if isinstance(value, dict) and set(value.keys()) == set(self.OVERLAY_SMALL_LOG_SETTINGS.keys()):
|
||||
for key, value in value.items():
|
||||
match (key):
|
||||
case "x_pos" | "y_pos" | "depth" | "x_rotation" | "y_rotation" | "z_rotation":
|
||||
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation":
|
||||
if isinstance(value, float):
|
||||
self._OVERLAY_SMALL_LOG_SETTINGS[key] = value
|
||||
case "display_duration" | "fadeout_duration":
|
||||
@@ -1073,7 +1073,7 @@ class Config:
|
||||
self._OVERLAY_SMALL_LOG_SETTINGS = {
|
||||
"x_pos": 0.0,
|
||||
"y_pos": 0.0,
|
||||
"depth": 0.0,
|
||||
"z_pos": 0.0,
|
||||
"x_rotation": 0.0,
|
||||
"y_rotation": 0.0,
|
||||
"z_rotation": 0.0,
|
||||
|
||||
@@ -897,7 +897,7 @@ def callbackSetOverlaySmallLogSettings(value, set_type:str):
|
||||
pre_settings[set_type] = value
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||
match (set_type):
|
||||
case "x_pos" | "y_pos" | "depth" | "x_rotation" | "y_rotation" | "z_rotation":
|
||||
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation":
|
||||
model.updateOverlayPosition()
|
||||
case "display_duration" | "fadeout_duration":
|
||||
model.updateOverlayTimes()
|
||||
|
||||
@@ -74,7 +74,7 @@ overlay_settings:
|
||||
ui_scaling: UI Scaling
|
||||
x_position: X-axis (left-right)
|
||||
y_position: Y-axis (up-down)
|
||||
depth: Z-axis (front-back)
|
||||
z_position: Z-axis (front-back)
|
||||
x_rotation: X-axis rotation
|
||||
y_rotation: Y-axis rotation
|
||||
z_rotation: Z-axis rotation
|
||||
|
||||
@@ -73,7 +73,7 @@ overlay_settings:
|
||||
ui_scaling: サイズ
|
||||
x_position: X軸(左右)
|
||||
y_position: Y軸(上下)
|
||||
depth: Z軸(前後)
|
||||
z_position: Z軸(前後)
|
||||
x_rotation: X軸の回転
|
||||
y_rotation: Y軸の回転
|
||||
z_rotation: Z軸の回転
|
||||
|
||||
22
model.py
22
model.py
@@ -84,10 +84,10 @@ class Model:
|
||||
self.overlay = Overlay(
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["depth"],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"],
|
||||
config.OVERLAY_SETTINGS["opacity"],
|
||||
@@ -685,12 +685,14 @@ class Model:
|
||||
self.overlay.startOverlay()
|
||||
|
||||
def updateOverlayPosition(self):
|
||||
pos = (config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"], config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
|
||||
depth = config.OVERLAY_SMALL_LOG_SETTINGS["depth"]
|
||||
x_rotation = config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"]
|
||||
y_rotation = config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"]
|
||||
z_rotation = config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"]
|
||||
self.overlay.updatePosition(pos, depth, x_rotation, y_rotation, z_rotation)
|
||||
self.overlay.updatePosition(
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
|
||||
config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"],
|
||||
)
|
||||
|
||||
def updateOverlayTimes(self):
|
||||
display_duration = config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]
|
||||
|
||||
@@ -18,7 +18,7 @@ def mat34Id(array):
|
||||
arr[i][j] = array[i][j]
|
||||
return arr
|
||||
|
||||
def getBaseMatrix(x_pos, y_pos, depth, x_rotation, y_rotation, z_rotation):
|
||||
def getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation):
|
||||
arr = np.zeros((3, 4))
|
||||
rot = utils.euler_to_rotation_matrix((x_rotation, y_rotation, z_rotation))
|
||||
|
||||
@@ -26,50 +26,50 @@ def getBaseMatrix(x_pos, y_pos, depth, x_rotation, y_rotation, z_rotation):
|
||||
for j in range(3):
|
||||
arr[i][j] = rot[i][j]
|
||||
|
||||
arr[0][3] = x_pos * depth
|
||||
arr[1][3] = y_pos * depth
|
||||
arr[2][3] = - depth
|
||||
arr[0][3] = x_pos * z_pos
|
||||
arr[1][3] = y_pos * z_pos
|
||||
arr[2][3] = - z_pos
|
||||
return arr
|
||||
|
||||
def getHMDBaseMatrix():
|
||||
x_pos = 0.0
|
||||
y_pos = -0.4
|
||||
depth = 1.0
|
||||
z_pos = 1.0
|
||||
x_rotation = 0.0
|
||||
y_rotation = 0.0
|
||||
z_rotation = 0.0
|
||||
arr = getBaseMatrix(x_pos, y_pos, depth, x_rotation, y_rotation, z_rotation)
|
||||
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
|
||||
return arr
|
||||
|
||||
def getLeftHandBaseMatrix():
|
||||
x_pos = 0.0
|
||||
y_pos = -0.06
|
||||
depth = -0.14
|
||||
z_pos = -0.14
|
||||
x_rotation = -62.0
|
||||
y_rotation = 154.0
|
||||
z_rotation = 71.0
|
||||
arr = getBaseMatrix(x_pos, y_pos, depth, x_rotation, y_rotation, z_rotation)
|
||||
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
|
||||
return arr
|
||||
|
||||
def getRightHandBaseMatrix():
|
||||
x_pos = 0.0
|
||||
y_pos = -0.06
|
||||
depth = -0.14
|
||||
z_pos = -0.14
|
||||
x_rotation = -62.0
|
||||
y_rotation = -154.0
|
||||
z_rotation = -71.0
|
||||
arr = getBaseMatrix(x_pos, y_pos, depth, x_rotation, y_rotation, z_rotation)
|
||||
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
|
||||
return arr
|
||||
|
||||
class Overlay:
|
||||
def __init__(self, x, y , depth, x_rotation, y_rotation, z_rotation, display_duration, fadeout_duration, opacity, ui_scaling):
|
||||
def __init__(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, display_duration, fadeout_duration, opacity, ui_scaling):
|
||||
self.initialized = False
|
||||
settings = {
|
||||
"color": [1, 1, 1],
|
||||
"opacity": opacity,
|
||||
"x_pos": x,
|
||||
"y_pos": y,
|
||||
"depth": depth,
|
||||
"x_pos": x_pos,
|
||||
"y_pos": y_pos,
|
||||
"z_pos": z_pos,
|
||||
"x_rotation": x_rotation,
|
||||
"y_rotation": y_rotation,
|
||||
"z_rotation": z_rotation,
|
||||
@@ -100,8 +100,9 @@ class Overlay:
|
||||
self.updateOpacity(self.settings["opacity"])
|
||||
self.updateUiScaling(self.settings["ui_scaling"])
|
||||
self.updatePosition(
|
||||
(self.settings["x_pos"], self.settings["y_pos"]),
|
||||
self.settings["depth"],
|
||||
self.settings["x_pos"],
|
||||
self.settings["y_pos"],
|
||||
self.settings["z_pos"],
|
||||
self.settings["x_rotation"],
|
||||
self.settings["y_rotation"],
|
||||
self.settings["z_rotation"],
|
||||
@@ -143,20 +144,20 @@ class Overlay:
|
||||
self.overlay.setOverlayAlpha(self.handle, self.settings["opacity"])
|
||||
|
||||
def updateUiScaling(self, ui_scaling):
|
||||
self.settings['ui_scaling'] = ui_scaling
|
||||
self.settings["ui_scaling"] = ui_scaling
|
||||
if self.initialized is True:
|
||||
self.overlay.setOverlayWidthInMeters(self.handle, self.settings['ui_scaling'])
|
||||
self.overlay.setOverlayWidthInMeters(self.handle, self.settings["ui_scaling"])
|
||||
|
||||
def updatePosition(self, pos, depth, x_rotation, y_rotation, z_rotation, tracker="HMD"):
|
||||
def updatePosition(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, tracker="HMD"):
|
||||
"""
|
||||
pos is a 2-tuple representing normalized (x, y)
|
||||
depth is a float representing the depth of the icon plane
|
||||
x_rotation, y_rotation, z_rotation are floats representing the rotation of the icon plane
|
||||
x_pos, y_pos, z_pos are floats representing the position of overlay
|
||||
x_rotation, y_rotation, z_rotation are floats representing the rotation of overlay
|
||||
tracker is a string representing the tracker to use ("HMD", "LeftHand", "RightHand")
|
||||
"""
|
||||
|
||||
self.settings["x_pos"] = pos[0]
|
||||
self.settings["y_pos"] = pos[1]
|
||||
self.settings["depth"] = depth
|
||||
self.settings["x_pos"] = x_pos
|
||||
self.settings["y_pos"] = y_pos
|
||||
self.settings["z_pos"] = z_pos
|
||||
self.settings["x_rotation"] = x_rotation
|
||||
self.settings["y_rotation"] = y_rotation
|
||||
self.settings["z_rotation"] = z_rotation
|
||||
@@ -175,7 +176,7 @@ class Overlay:
|
||||
base_matrix = getHMDBaseMatrix()
|
||||
trackerIndex = openvr.k_unTrackedDeviceIndex_Hmd
|
||||
|
||||
translation = (self.settings["x_pos"], self.settings["y_pos"], - self.settings['depth'])
|
||||
translation = (self.settings["x_pos"], self.settings["y_pos"], - self.settings["z_pos"])
|
||||
rotation = (self.settings["x_rotation"], self.settings["y_rotation"], self.settings["z_rotation"])
|
||||
transform = utils.transform_matrix(base_matrix, translation, rotation)
|
||||
self.transform = mat34Id(transform)
|
||||
@@ -188,10 +189,10 @@ class Overlay:
|
||||
)
|
||||
|
||||
def updateDisplayDuration(self, display_duration):
|
||||
self.settings['display_duration'] = display_duration
|
||||
self.settings["display_duration"] = display_duration
|
||||
|
||||
def updateFadeoutDuration(self, fadeout_duration):
|
||||
self.settings['fadeout_duration'] = fadeout_duration
|
||||
self.settings["fadeout_duration"] = fadeout_duration
|
||||
|
||||
def checkActive(self):
|
||||
try:
|
||||
@@ -207,16 +208,16 @@ class Overlay:
|
||||
return False
|
||||
|
||||
def evaluateOpacityFade(self, lastUpdate, currentTime):
|
||||
if (currentTime - lastUpdate) > self.settings['display_duration']:
|
||||
timeThroughInterval = currentTime - lastUpdate - self.settings['display_duration']
|
||||
self.fadeRatio = 1 - timeThroughInterval / self.settings['fadeout_duration']
|
||||
if (currentTime - lastUpdate) > self.settings["display_duration"]:
|
||||
timeThroughInterval = currentTime - lastUpdate - self.settings["display_duration"]
|
||||
self.fadeRatio = 1 - timeThroughInterval / self.settings["fadeout_duration"]
|
||||
if self.fadeRatio < 0:
|
||||
self.fadeRatio = 0
|
||||
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings['opacity'])
|
||||
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings["opacity"])
|
||||
|
||||
def update(self):
|
||||
currTime = time.monotonic()
|
||||
if self.settings['fadeout_duration'] != 0:
|
||||
if self.settings["fadeout_duration"] != 0:
|
||||
self.evaluateOpacityFade(self.lastUpdate, currTime)
|
||||
else:
|
||||
self.updateOpacity(self.settings["opacity"])
|
||||
@@ -255,10 +256,10 @@ class Overlay:
|
||||
|
||||
@staticmethod
|
||||
def checkSteamvrRunning() -> bool:
|
||||
_proc_name = "vrmonitor.exe" if os.name == 'nt' else "vrmonitor"
|
||||
_proc_name = "vrmonitor.exe" if os.name == "nt" else "vrmonitor"
|
||||
return _proc_name in (p.name() for p in process_iter())
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
# from overlay_image import OverlayImage
|
||||
# overlay_image = OverlayImage()
|
||||
|
||||
@@ -290,13 +291,13 @@ if __name__ == '__main__':
|
||||
|
||||
x_pos = 0
|
||||
y_pos = 0
|
||||
depth = 0
|
||||
z_pos = 0
|
||||
x_rotation = 0
|
||||
y_rotation = 0
|
||||
z_rotation = 0
|
||||
|
||||
base_matrix = getLeftHandBaseMatrix()
|
||||
translation = (x_pos * depth, y_pos * depth, depth)
|
||||
translation = (x_pos * z_pos, y_pos * z_pos, z_pos)
|
||||
rotation = (x_rotation, y_rotation, z_rotation)
|
||||
transform = utils.transform_matrix(base_matrix, translation, rotation)
|
||||
transform = mat34Id(transform)
|
||||
|
||||
@@ -23,7 +23,7 @@ class OverlayImage:
|
||||
|
||||
@staticmethod
|
||||
def concatenateImagesVertically(img1: Image, img2: Image) -> Image:
|
||||
dst = Image.new('RGBA', (img1.width, img1.height + img2.height))
|
||||
dst = Image.new("RGBA", (img1.width, img1.height + img2.height))
|
||||
dst.paste(img1, (0, 0))
|
||||
dst.paste(img2, (0, img1.height))
|
||||
return dst
|
||||
|
||||
20
view.py
20
view.py
@@ -180,11 +180,11 @@ class View():
|
||||
VAR_OVERLAY_SMALL_LOG_Y_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
|
||||
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
|
||||
|
||||
VAR_LABEL_OVERLAY_SMALL_LOG_DEPTH=StringVar(value=i18n.t("overlay_settings.depth")),
|
||||
SLIDER_RANGE_OVERLAY_SMALL_LOG_DEPTH=(-5, 5),
|
||||
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DEPTH=10000,
|
||||
VAR_OVERLAY_SMALL_LOG_DEPTH=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["depth"]),
|
||||
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["depth"]),
|
||||
VAR_LABEL_OVERLAY_SMALL_LOG_Z_POS=StringVar(value=i18n.t("overlay_settings.z_position")),
|
||||
SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_POS=(-5, 5),
|
||||
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_POS=10000,
|
||||
VAR_OVERLAY_SMALL_LOG_Z_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]),
|
||||
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]),
|
||||
|
||||
VAR_LABEL_OVERLAY_SMALL_LOG_X_ROTATION=StringVar(value=i18n.t("overlay_settings.x_rotation")),
|
||||
SLIDER_RANGE_OVERLAY_SMALL_LOG_X_ROTATION=(-180, 180),
|
||||
@@ -1166,7 +1166,7 @@ class View():
|
||||
INIT_OVERLAY_SMALL_LOG_SETTINGS = {
|
||||
"x_pos": 0.0,
|
||||
"y_pos": 0.0,
|
||||
"depth": 0.0,
|
||||
"z_pos": 0.0,
|
||||
"x_rotation": 0.0,
|
||||
"y_rotation": 0.0,
|
||||
"z_rotation": 0.0,
|
||||
@@ -1184,7 +1184,7 @@ class View():
|
||||
|
||||
self.setLatestConfigVariable("OverlaySmallLogXPos")
|
||||
self.setLatestConfigVariable("OverlaySmallLogYPos")
|
||||
self.setLatestConfigVariable("OverlaySmallLogDepth")
|
||||
self.setLatestConfigVariable("OverlaySmallLogZPos")
|
||||
self.setLatestConfigVariable("OverlaySmallLogXRotation")
|
||||
self.setLatestConfigVariable("OverlaySmallLogYRotation")
|
||||
self.setLatestConfigVariable("OverlaySmallLogZRotation")
|
||||
@@ -1950,9 +1950,9 @@ class View():
|
||||
self.view_variable.VAR_OVERLAY_SMALL_LOG_Y_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
|
||||
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
|
||||
|
||||
case "OverlaySmallLogDepth":
|
||||
self.view_variable.VAR_OVERLAY_SMALL_LOG_DEPTH.set(config.OVERLAY_SMALL_LOG_SETTINGS["depth"])
|
||||
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH.set(config.OVERLAY_SMALL_LOG_SETTINGS["depth"])
|
||||
case "OverlaySmallLogZPos":
|
||||
self.view_variable.VAR_OVERLAY_SMALL_LOG_Z_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"])
|
||||
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"])
|
||||
|
||||
case "OverlaySmallLogXRotation":
|
||||
self.view_variable.VAR_OVERLAY_SMALL_LOG_X_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"])
|
||||
|
||||
@@ -147,21 +147,21 @@ class QuickSettingsWindow(CTkToplevel):
|
||||
|
||||
|
||||
row+=1
|
||||
def overlaySmallLogSettingsDepthSliderCallback(e):
|
||||
def overlaySmallLogSettingsZPosSliderCallback(e):
|
||||
value = round(e,2)
|
||||
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "depth")
|
||||
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH.set(str(value))
|
||||
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "z_pos")
|
||||
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS.set(str(value))
|
||||
|
||||
self.qsb__overlay_small_log_settings_depth = createSettingBoxSlider(
|
||||
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_DEPTH,
|
||||
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH,
|
||||
slider_attr_name="qsb__overlay_small_log_settings_depth_slider",
|
||||
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_DEPTH,
|
||||
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DEPTH,
|
||||
command=overlaySmallLogSettingsDepthSliderCallback,
|
||||
variable=view_variable.VAR_OVERLAY_SMALL_LOG_DEPTH,
|
||||
self.qsb__overlay_small_log_settings_z_pos = createSettingBoxSlider(
|
||||
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_Z_POS,
|
||||
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS,
|
||||
slider_attr_name="qsb__overlay_small_log_settings_z_pos_slider",
|
||||
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_POS,
|
||||
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_POS,
|
||||
command=overlaySmallLogSettingsZPosSliderCallback,
|
||||
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Z_POS,
|
||||
)
|
||||
self.qsb__overlay_small_log_settings_depth.grid(row=row)
|
||||
self.qsb__overlay_small_log_settings_z_pos.grid(row=row)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user