-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added `LivekitVideo.cs` and `LivekitVideoManager.cs` to `Assets/SEE/Tools/Videochat/` - `LivekitVideo.cs`: Handles the positioning of video streams. It renames the GameObject so that `LivekitVideoManager` can access it later. - `LivekitVideoManager.cs`: Manages communication with the media server and handles incoming video streams. - Updated `BaseAvatar` prefab in `Assets/Resources/Prefabs/Players/CC4/` - Added a new child object with the following components: - `Mesh Filter` (set to `Quad`) - `Mesh Renderer` (using `ExampleMaterial` with the shader set to `Unlit/Texture`, `Receive Shadows`=disabled) - `LivekitVideo.cs` - The scale of the new child object is set to `x=0.2, y=0.2, z=-1`. - The `Mesh Renderer` is initially disabled and will be activated by the `LivekitVideoManager.cs` script. - Removed the old `FaceCam` object from the `BaseAvatar` prefab. - Modified the `SEENewWorld` scene: - Added a new `Canvas` object with the `LivekitVideoManager.cs` script attached. - Configured the `Livekit Url` to point to the media server (SFU) responsible for distributing video streams. - Configured the `Token Url` for the token server providing access to the media server. - Set the `Room Name`, ensuring that no two sessions use the same room name simultaneously to avoid conflicts. - Added a `TextMeshPro Dropdown` to the Canvas for listing available cameras, which is linked to `LivekitVideoManager`. - Updated `Assets/SEE/SEE.asmdef` to include `Packages/io.livekit.livekit-sdk/Runtime/livekit.unity.Runtime.asmdef`
- Loading branch information
Showing
10 changed files
with
2,716 additions
and
704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fileFormatVersion: 2 | ||
guid: 0d273552ff1475b4dbd45307424a9609 | ||
folderAsset: yes | ||
DefaultImporter: | ||
externalObjects: {} | ||
userData: | ||
assetBundleName: | ||
assetBundleVariant: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using UnityEngine; | ||
using Unity.Netcode; | ||
using SEE.Controls; | ||
using SEE.Utils; | ||
|
||
public class LivekitVideo : NetworkBehaviour | ||
{ | ||
/// <summary> | ||
/// The object with the position where the player's head is located. | ||
/// </summary> | ||
private Transform playerHead; | ||
|
||
/// <summary> | ||
/// The relative path to the bone of the player's head. | ||
/// This is used to position the Livekit video. | ||
/// </summary> | ||
private const string faceCamOrientationBone = "CC_Base_BoneRoot/CC_Base_Hip/CC_Base_Waist/CC_Base_Spine01/CC_Base_Spine02/CC_Base_NeckTwist01/CC_Base_NeckTwist02/CC_Base_Head"; | ||
|
||
/// <summary> | ||
/// The status of the position of the Livekit video. | ||
/// Can be positioned in front of the face or above the face, tilted towards the observer. | ||
/// When <c>faceCamOnFront</c> is true, the video is positioned in front of the face using <c>offsetInFrontOfFace</c>. | ||
/// When <c>faceCamOnFront</c> is false, the video is positioned above the head using <c>offsetAboveHead</c>. | ||
/// </summary> | ||
private bool faceCamOnFront = true; | ||
|
||
/// <summary> | ||
/// Offset for positioning the video in front of the player's face. | ||
/// Used when <c>faceCamOnFront</c> is true. | ||
/// </summary> | ||
private Vector3 offsetInFrontOfFace = new Vector3(0, 0.065f, 0.15f); | ||
|
||
/// <summary> | ||
/// Offset for positioning the video above the player's head. | ||
/// Used when <c>faceCamOnFront</c> is false. | ||
/// </summary> | ||
private Vector3 offsetAboveHead = new Vector3(0, 0.35f, 0); | ||
|
||
/// <summary> | ||
/// Called when the script instance is being loaded. | ||
/// Initializes the player head reference and sets the object name so that it contains the owner ID of the client. | ||
/// </summary> | ||
private void Start() | ||
{ | ||
// Set the name of the object to "LivekitVideo_" followed by the owner client ID. | ||
gameObject.name = "LivekitVideo_" + OwnerClientId; | ||
|
||
// Localizes the player's head bone for the positioning of the video. | ||
playerHead = transform.parent.Find(faceCamOrientationBone); | ||
} | ||
|
||
/// <summary> | ||
/// Called once per frame to update the position and rotation of the video. | ||
/// Toggles the position of the video between above the player's head or in front of it. | ||
/// The position can be toggled with <see cref="SEEInput.ToggleFaceCamPosition"/>. | ||
/// </summary> | ||
private void Update() | ||
{ | ||
// Update the video position when the player's head is found. | ||
if (playerHead != null) | ||
{ | ||
UpdatePosition(); | ||
} | ||
|
||
// Check for input to toggle the video position. | ||
if (SEEInput.ToggleFaceCamPosition()) | ||
{ | ||
faceCamOnFront = !faceCamOnFront; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Updates the position and orientation of the video based on the player's head. | ||
/// </summary> | ||
/// <remarks>If the video is positioned in front of the player's face, it follows | ||
/// the head's position and rotation. If positioned above the head, it faces the camera | ||
/// for remote clients.</remarks> | ||
private void UpdatePosition() | ||
{ | ||
if (faceCamOnFront) | ||
{ | ||
// Position the video in front of the player's face. | ||
transform.SetPositionAndRotation(playerHead.TransformPoint(offsetInFrontOfFace), playerHead.rotation); | ||
} | ||
else | ||
{ | ||
// Position the video above the player's head. | ||
transform.position = playerHead.TransformPoint(offsetAboveHead); | ||
|
||
// If this object is not owned by the local client, make it face the main camera. | ||
if (!IsOwner && MainCamera.Camera != null) | ||
{ | ||
transform.LookAt(MainCamera.Camera.transform); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fileFormatVersion: 2 | ||
guid: 814d03533fbb9a8409b921253838f2de | ||
MonoImporter: | ||
externalObjects: {} | ||
serializedVersion: 2 | ||
defaultReferences: [] | ||
executionOrder: 0 | ||
icon: {instanceID: 0} | ||
userData: | ||
assetBundleName: | ||
assetBundleVariant: |
Oops, something went wrong.