translate vr physical walking movement into any pc game

Homepage Forums General vorpX Discussion translate vr physical walking movement into any pc game

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #218601
    Farutos
    Participant

    Hello please how to translate vr physical walking movement into any pc game, i am curious about game “Shadows of doubt”
    if its not possible in vorpx eg due to direct vr direct x, would it be able by some steam motion tools like natural locomotion or vrrocker?

    shadows of doubt (voxel)

    Shadows of Doubt in VR with vorpx is very immersive.
    byu/Objectionne inShadows_of_Doubt

    #218603
    Farutos
    Participant

    and basically why catwalk c and virtuix omni can translate movement into arrow keys, but headset/vorpx cannot?

    #218604
    Farutos
    Participant

    and another question, maybe also odd, but since quest headset or at least some or multiple headset can figure out movement, positions that you are close to boundary, and even project to direct vr games, why vorpx cannot make use of this data?

    #218605
    onetoo
    Participant

    I would think some kind of arm swing or vrocker sway could be implemented seeing as VorpX is using positional data for gestures already. I think the biggest benefit would be using it with OpenXR or the Oculus driver since the current third party solutions both rely on the steam OpenVR driver.

    #218609
    Smoils
    Participant

    You can do it via vr controllers, there are several apps like natural locomotion etc or I have cybershoes for example and what those do is they translate their motion type into vr controller thumbstick input, which vorpx then picks up and translates into game input.

    Natural locomotion works the easiest, by default its armswinger, but can even use phones on legs or put controllers on legs and use gamepad for other input.

    Point is it works. Mirrors edge one is quite fun with NaLo and armswinger in vorpx

    #218612
    Farutos
    Participant

    Thankss for suggestion, however i tried nalo and it works quite awkwardly, it works seldomly but when it does, its very cumbersome, the display is literally shaking since it register movement as humping from side to side, so basically while moreless i walk slowly i have to move by hands quickly or even when i move hands quickly the depiction of display is as i was running swinging drunk from side to side on a ship during a strom at ocean, the image of screen is shaking too much. Maybe its better with a phone or tracker mounted to leg.

    Furthermore hardware stuff like htc trackers not sure if supposed to be at place like kat loco need bases to track i think so you cant leave the room. If natural locomotion app could be due similar reason not supposed to be walking with it really but staying in place.
    Kat loco not sure if those need bases, but perhaps are slower, can be used only at place, and cannot be used like fbt full body tracking or tracking real world objects.

    Thanks for your suggested cyberhoes or walkovr perhaps could be better. I think there are some special trackers even for 50 euroes

    #218618
    onetoo
    Participant

    I used to use Natural Locomotion with JoyCons strapped to my legs. It worked well enough though they didn’t stop on the dime. The problem was, the app doesn’t work with the Oculus driver or OpenXR, and the SteamVR driver is unplayable with VorpX for my setup. Also, you have to use an older version of SteamVR because NatLo support is nonexistent these days. I’m looking for ways to do it on my own maybe using Auto Oculus Touch or the OpneXR Python library, though I would lose the built in VorpX gestures.

    #219072
    Wehrwolfi
    Participant

    I started the natural locomotion with NaLo and a phone on each ankle. It worked quite good but Iwanted more freedom for immersion… I play wireless, I don’t want to attach things to my body. That’s why I stopped using it.

    Then I tried Vrocker. I found nearly the same performance but I didn’t have to attach any external sensor. Since, I use it always, sometimes with only a phone for hip tracking in fps.

    Never tried it on flat games until I red your post! It feels weird but… it works! I can confirm.

    #221223
    Farutos
    Participant

    I dont’ quite understand why Ralf wont add vr x,y,z position translating script himself.

    Its some quite easy to do. Chatgpt created such script for me and it work fine, its not game changers but works , tested it in gta 5.
    It could be tuned for steps length.

    The script

    import openvr
    import time
    import math
    import keyboard  # Requires: pip install keyboard
    
    # Sensitivity threshold (in meters)
    move_threshold = 0.02  # 2 cm to detect movement
    short_walk_time = 0.5  # 0.5 sec press for ~20 cm movement
    long_walk_time = 1.5   # 1.5 sec press for ~1.5m movement
    
    def get_hmd_pose(vr_system):
        """Retrieve the headset's position and rotation from SteamVR."""
        poses = openvr.TrackedDevicePose_t * openvr.k_unMaxTrackedDeviceCount
        tracked_device_poses = poses()
       
        vr_system.getDeviceToAbsoluteTrackingPose(openvr.TrackingUniverseStanding, 0, tracked_device_poses)
    
        hmd_index = openvr.k_unTrackedDeviceIndex_Hmd
        hmd_pose = tracked_device_poses[hmd_index]
    
        if hmd_pose.bPoseIsValid:
            matrix = hmd_pose.mDeviceToAbsoluteTracking
            x = matrix[0][3]  # Left/Right position
            y = matrix[2][3]  # Forward/Backward position
    
            # Extract rotation (yaw) from the SteamVR tracking matrix
            yaw = math.atan2(matrix[0][2], matrix[2][2])  # Yaw angle in radians
    
            return x, y, yaw
        return None, None, None
    
    # Initialize OpenVR
    # vr_system = openvr.init(openvr.VRApplication_Scene)
    vr_system = openvr.init(openvr.VRApplication_Background)
    print("✅ SteamVR Tracking Initialized")
    
    # Store the last position
    last_x, last_y, last_yaw = get_hmd_pose(vr_system)
    if last_x is None or last_y is None or last_yaw is None:
        print("❌ Error: Headset tracking not available. Make sure SteamVR is running.")
        openvr.shutdown()
        exit()
    
    print("Starting position:", round(last_x * 100, 1), "cm X,", round(last_y * 100, 1), "cm Y")
    print("Starting yaw angle:", round(math.degrees(last_yaw), 1), "degrees")
    
    # Main loop to track **headset-relative movement** and trigger key presses
    try:
        while True:
            x, y, yaw = get_hmd_pose(vr_system)
    
            if x is not None and y is not None and yaw is not None:
                # Calculate relative movement (delta)
                delta_x = (x - last_x)  # Left/Right movement
                delta_y = (y - last_y)  # Forward/Backward movement
    
                # Convert movement into head-relative coordinates
                forward_movement = -(delta_x * math.sin(yaw) + delta_y * math.cos(yaw))  # Inverted for correct direction
                sideways_movement = delta_x * math.cos(yaw) - delta_y * math.sin(yaw)
    
                # Convert to cm for easier reading
                forward_cm = forward_movement * 100
                sideways_cm = sideways_movement * 100
    
                # Check movement threshold
                if abs(forward_cm) > move_threshold * 100:
                    if forward_cm > 0:  # Moving forward
                        key = "w"
                        print("🔼 MOVEMENT: {:.1f} cm forward".format(forward_cm))
                    else:  # Moving backward
                        key = "s"
                        print("🔽 MOVEMENT: {:.1f} cm backward".format(abs(forward_cm)))
    
                    # Determine key press duration
                    duration = short_walk_time if abs(forward_cm) < 100 else long_walk_time
                    keyboard.press(key)
                    time.sleep(duration)
                    keyboard.release(key)
    
                if abs(sideways_cm) > move_threshold * 100:
                    if sideways_cm > 0:  # Moving right
                        key = "d"
                        print("➡ MOVEMENT: {:.1f} cm right".format(sideways_cm))
                    else:  # Moving left
                        key = "a"
                        print("⬅ MOVEMENT: {:.1f} cm left".format(abs(sideways_cm)))
    
                    # Determine key press duration
                    duration = short_walk_time if abs(sideways_cm) < 100 else long_walk_time
                    keyboard.press(key)
                    time.sleep(duration)
                    keyboard.release(key)
    
                # Update last position for next frame
                last_x, last_y, last_yaw = x, y, yaw
    
            time.sleep(0.05)  # Short delay for smooth tracking
    except KeyboardInterrupt:
        print("\nShutting down SteamVR tracking.")
        openvr.shutdown()

    or for gta 5 script if you want press C to look behind and reverse movement

    
    import openvr
    import time
    import math
    import keyboard  # Requires: pip install keyboard
    
    # Sensitivity threshold (in meters)
    move_threshold = 0.02  # 2 cm to detect movement
    short_walk_time = 0.5  # 0.5 sec press for ~20 cm movement
    long_walk_time = 1.5   # 1.5 sec press for ~1.5m movement
    
    def get_hmd_pose(vr_system):
        """Retrieve the headset's position and rotation from SteamVR."""
        poses = openvr.TrackedDevicePose_t * openvr.k_unMaxTrackedDeviceCount
        tracked_device_poses = poses()
       
        vr_system.getDeviceToAbsoluteTrackingPose(openvr.TrackingUniverseStanding, 0, tracked_device_poses)
    
        hmd_index = openvr.k_unTrackedDeviceIndex_Hmd
        hmd_pose = tracked_device_poses[hmd_index]
    
        if hmd_pose.bPoseIsValid:
            matrix = hmd_pose.mDeviceToAbsoluteTracking
            x = matrix[0][3]  # Left/Right position
            y = matrix[2][3]  # Forward/Backward position
    
            # Extract rotation (yaw) from the SteamVR tracking matrix
            yaw = math.atan2(matrix[0][2], matrix[2][2])  # Yaw angle in radians
    
            return x, y, yaw
        return None, None, None
    
    # Initialize OpenVR
    vr_system = openvr.init(openvr.VRApplication_Background)
    print("✅ SteamVR Tracking Initialized")
    
    # Store the last position
    last_x, last_y, last_yaw = get_hmd_pose(vr_system)
    if last_x is None or last_y is None or last_yaw is None:
        print("❌ Error: Headset tracking not available. Make sure SteamVR is running.")
        openvr.shutdown()
        exit()
    
    print("Starting position:", round(last_x * 100, 1), "cm X,", round(last_y * 100, 1), "cm Y")
    print("Starting yaw angle:", round(math.degrees(last_yaw), 1), "degrees")
    
    # Main loop to track **headset-relative movement** and trigger key presses
    try:
        while True:
            x, y, yaw = get_hmd_pose(vr_system)
    
            if x is not None and y is not None and yaw is not None:
                # Calculate relative movement (delta)
                delta_x = (x - last_x)  # Left/Right movement
                delta_y = (y - last_y)  # Forward/Backward movement
    
                # Convert movement into head-relative coordinates
                forward_movement = -(delta_x * math.sin(yaw) + delta_y * math.cos(yaw))  # Inverted for correct direction
                sideways_movement = delta_x * math.cos(yaw) - delta_y * math.sin(yaw)
    
                # Convert to cm for easier reading
                forward_cm = forward_movement * 100
                sideways_cm = sideways_movement * 100
    
                # **Check if "C" is being held**
                reverse_mode = keyboard.is_pressed("c")  # True when "C" is pressed
    
                # Check movement threshold
                if abs(forward_cm) > move_threshold * 100:
                    if forward_cm > 0:  
                        key = "s" if reverse_mode else "w"  # Reverse W ↔ S
                        print("🔼 MOVEMENT: {:.1f} cm forward".format(forward_cm) if not reverse_mode else "🔽 MOVEMENT: {:.1f} cm backward".format(abs(forward_cm)))
                    else:  
                        key = "w" if reverse_mode else "s"  # Reverse S ↔ W
                        print("🔽 MOVEMENT: {:.1f} cm backward".format(abs(forward_cm)) if not reverse_mode else "🔼 MOVEMENT: {:.1f} cm forward".format(forward_cm))
    
                    # Determine key press duration
                    duration = short_walk_time if abs(forward_cm) < 100 else long_walk_time
                    keyboard.press(key)
                    time.sleep(duration)
                    keyboard.release(key)
    
                if abs(sideways_cm) > move_threshold * 100:
                    if sideways_cm > 0:  
                        key = "a" if reverse_mode else "d"  # Reverse A ↔ D
                        print("➡ MOVEMENT: {:.1f} cm right".format(sideways_cm) if not reverse_mode else "⬅ MOVEMENT: {:.1f} cm left".format(abs(sideways_cm)))
                    else:  
                        key = "d" if reverse_mode else "a"  # Reverse D ↔ A
                        print("⬅ MOVEMENT: {:.1f} cm left".format(abs(sideways_cm)) if not reverse_mode else "➡ MOVEMENT: {:.1f} cm right".format(sideways_cm))
    
                    # Determine key press duration
                    duration = short_walk_time if abs(sideways_cm) < 100 else long_walk_time
                    keyboard.press(key)
                    time.sleep(duration)
                    keyboard.release(key)
    
                # Update last position for next frame
                last_x, last_y, last_yaw = x, y, yaw
    
            time.sleep(0.05)  # Short delay for smooth tracking
    except KeyboardInterrupt:
        print("\nShutting down SteamVR tracking.")
        openvr.shutdown()
    
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Spread the word. Share this post!