First try

This commit is contained in:
Thorbjoern
2025-06-28 16:40:31 +02:00
parent 4facf6a768
commit 643c071c51
40 changed files with 19460 additions and 1356 deletions
+19
View File
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 52a5761204929f34abe1c66ab2876c93, type: 3}
m_Name: Base
m_EditorClassIdentifier:
sceneId: Base
doors: 0
furniture: 0
portals: 0
enemies: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9b233cea23be1ef4aa725341395000c2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -33,16 +33,23 @@ namespace GhostSystem
public static event Action OnRecord;
public static event Action OnStopRecord;
private void Awake()
{
DontDestroyOnLoad(this);
}
private void OnEnable()
{
SupabaseManager.OnSuperbaseReady += HandleSupabaseReady;
RoomManager.OnSceneIdReady += HandleSceneIdReady;
StopRecordingTrigger.OnRecordStop += HandleRecordStop;
}
private void OnDisable()
{
SupabaseManager.OnSuperbaseReady -= HandleSupabaseReady;
RoomManager.OnSceneIdReady -= HandleSceneIdReady;
StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
}
private void Start()
@@ -59,15 +66,29 @@ namespace GhostSystem
{
SceneId = id;
sceneIdReady = true;
foreach (GameObject door in doors)
if (SceneId == "Base")
{
var rotator = door.GetComponentInChildren<OneGrabRotateTransformer>();
if (rotator != null)
{
TrackedObjects.Add(rotator.transform);
doorCount++;
}
_flushTimer = 0f;
_ = FlushBatchAsync(); // Fire and forget
}
else
{
foreach (GameObject door in doors)
{
var rotator = door.GetComponentInChildren<OneGrabRotateTransformer>();
if (rotator != null)
{
TrackedObjects.Add(rotator.transform);
doorCount++;
}
}
StartRecording();
}
}
private void HandleRecordStop()
{
StopRecording();
}
private void Update()
@@ -83,11 +104,11 @@ namespace GhostSystem
RecordSample();
}
if (_frameBuffer.Count >= BatchSize || _flushTimer >= FlushInterval)
/*if (_frameBuffer.Count >= BatchSize || _flushTimer >= FlushInterval)
{
_flushTimer = 0f;
_ = FlushBatchAsync(); // Fire and forget
}
}*/
}
private void RecordSample()
@@ -105,6 +126,7 @@ namespace GhostSystem
var batch = new List<FrameModel>(_frameBuffer);
_frameBuffer.Clear();
Debug.Log("Flushing Frame Buffer");
try
{
+49
View File
@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameStarter : MonoBehaviour
{
[SerializeField] int startScene = 1;
private int currentscene;
private int nextscene;
private void OnEnable()
{
StopRecordingTrigger.OnRecordStop += HandleRecordStop;
}
private void OnDisable()
{
StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
}
private void Awake()
{
DontDestroyOnLoad(this);
currentscene = startScene;
}
// Update is called once per frame
void Update()
{
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
{
if (SceneManager.GetActiveScene() != SceneManager.GetSceneByBuildIndex(startScene)) return;
nextscene = currentscene + 1;
currentscene = nextscene;
StartGameByLoadingScene(nextscene);
}
}
void StartGameByLoadingScene(int sceneIndex)
{
SceneManager.LoadScene(sceneIndex);
}
private void HandleRecordStop()
{
StartGameByLoadingScene(startScene);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e580ea451ce98a24b81fd7e238ac6393
@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class SpawnAtLongestEdge : MonoBehaviour
{
[SerializeField] GameObject roomPrefab;
[SerializeField] GameObject pointPrefab;
[SerializeField] GameObject reticlePrefab;
// Start is called before the first frame update
void Start()
{
// Prüfe, ob die Boundary aktiviert ist
if (OVRManager.boundary != null)
{
// Hole die Boundary-Geometrie (Play Area)
Vector3[] boundaryPoints = OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.PlayArea);
if (boundaryPoints != null && boundaryPoints.Length > 0)
{
Debug.Log("Boundary Points gefunden: " + boundaryPoints.Length);
AlignObjectToLongestEdge(boundaryPoints);
}
else
{
Debug.LogWarning("Keine Boundary Points gefunden.");
}
}
else
{
Debug.LogError("OVRManager.boundary ist nicht aktiviert.");
}
}
void AlignObjectToLongestEdge(Vector3[] boundaryPoints)
{
float maxLength = 0f;
Vector3 longestEdgeStart = Vector3.zero;
Vector3 longestEdgeEnd = Vector3.zero;
// Iteriere über die Punkte und finde die längste Kante
for (int i = 0; i < boundaryPoints.Length; i++)
{
Vector3 start = boundaryPoints[i];
Vector3 end = boundaryPoints[(i + 1) % boundaryPoints.Length]; // Modulo für den letzten Punkt
// Debug Visuals for Points
Instantiate(pointPrefab, start, Quaternion.LookRotation(end));
float length = Vector3.Distance(start, end);
if (length > maxLength)
{
maxLength = length;
longestEdgeStart = start;
longestEdgeEnd = end;
}
}
Debug.Log($"Längste Kante gefunden: Start({longestEdgeStart}), Ende({longestEdgeEnd}), Länge: {maxLength}");
// Richte dein Objekt aus
Vector3 midPoint = (longestEdgeStart + longestEdgeEnd) / 2;
Vector3 direction = (longestEdgeEnd - longestEdgeStart).normalized;
Instantiate(roomPrefab, midPoint, Quaternion.LookRotation(direction));
Transform reticle = Instantiate(reticlePrefab, longestEdgeStart, Quaternion.LookRotation(direction)).transform;
reticle.position = new Vector3 (reticle.position.x - 0.75f, reticle.position.y, reticle.position.z + 1);
// Beispiel: Objekt positionieren und ausrichten
//Transform objTransform = this.transform;
//objTransform.position = midPoint;
//objTransform.rotation = Quaternion.LookRotation(direction);
Debug.Log("Objekt wurde an der längsten Kante ausgerichtet.");
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78d0b4c770471684b819e3235a0688bf
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System;
using UnityEngine;
public class StopRecordingTrigger : MonoBehaviour
{
public string tagFilter = "Player";
public static event Action OnRecordStop;
// Start is called once before the first execution of Update after the MonoBehaviour is created
private void OnTriggerEnter(Collider other)
{
if (!string.IsNullOrEmpty(tagFilter) && !other.gameObject.CompareTag(tagFilter)) return;
OnRecordStop.Invoke();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: edf374aa5a0a0cb4f9a7b1e7d4426155