mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-05-14 13:00:35 +02:00
Spawnning on table works with Luis help. Yet to clean code
This commit is contained in:
parent
0a752531de
commit
4f239bed4c
Assets/SharedSpatialAnchors
@ -129,6 +129,39 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 3236b8f205019504589358e7e0412a38, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_positionConstraints:
|
||||
ConstraintsAreRelative: 0
|
||||
XAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
YAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
ZAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
_rotationConstraints:
|
||||
XAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
YAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
ZAxis:
|
||||
ConstrainAxis: 0
|
||||
AxisRange:
|
||||
Min: 0
|
||||
Max: 0
|
||||
--- !u!114 &8360913207784568672
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -141,7 +174,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 1bedaac29a943f844a7074b53c8bdf9f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_grabbable: {fileID: 6991219106398992493}
|
||||
_pointable: {fileID: 6991219106398992493}
|
||||
_rigidbody: {fileID: 5018166209383245865}
|
||||
_scaleMassWithSize: 1
|
||||
--- !u!54 &5018166209383245865
|
||||
|
@ -211,7 +211,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 382264866490105690}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 43f86b14a27b52f4f9298c33015b5c26, type: 3}
|
||||
m_Name:
|
||||
@ -275,7 +275,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 382264866490105690}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1bedaac29a943f844a7074b53c8bdf9f, type: 3}
|
||||
m_Name:
|
||||
@ -297,7 +297,7 @@ Rigidbody:
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 4
|
||||
m_Constraints: 80
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &4423142984711990833
|
||||
MonoBehaviour:
|
||||
|
@ -609,6 +609,11 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 315424170}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &327696156 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2307585708260157586, guid: 60fa00281e83b294583adc31df520fbe, type: 3}
|
||||
m_PrefabInstance: {fileID: 2982998299393685461}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &348428074
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3945,14 +3950,13 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1232630262}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4357a20539a2184997fc22358044a5f, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 21df138a5d6164c40949b47670df955b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
prefab: {fileID: 8661891273527454774, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
previewPrefab: {fileID: 87966117356681799, guid: c0118078f34d6b34ea8d5afec2be7cff, type: 3}
|
||||
currentPreview: {fileID: 0}
|
||||
prefab: {fileID: 485686342}
|
||||
previewPrefab: {fileID: 327696156}
|
||||
--- !u!4 &1232630264
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
2200
Assets/SharedSpatialAnchors/Scenes/TestMetaQuestLink.unity
Normal file
2200
Assets/SharedSpatialAnchors/Scenes/TestMetaQuestLink.unity
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f79cb053f17b20848a0d62abadb6cf50
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/SharedSpatialAnchors/Scripts/PrefabSpawnner.cs
Normal file
32
Assets/SharedSpatialAnchors/Scripts/PrefabSpawnner.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PrefabSpawnner : MonoBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public GameObject previewPrefab;
|
||||
private GameObject currentPreview;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
currentPreview = Instantiate(previewPrefab);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Ray ray = new Ray(OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch), OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch) * Vector3.forward);
|
||||
if(Physics.Raycast(ray,out RaycastHit hit))
|
||||
{
|
||||
currentPreview.transform.position = hit.point;
|
||||
currentPreview.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
|
||||
|
||||
if (OVRInput.GetDown(OVRInput.Button.One))
|
||||
{
|
||||
Instantiate(prefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/SharedSpatialAnchors/Scripts/PrefabSpawnner.cs.meta
Normal file
11
Assets/SharedSpatialAnchors/Scripts/PrefabSpawnner.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21df138a5d6164c40949b47670df955b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -146,32 +146,52 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
// use the component helper function to access all child anchors
|
||||
await container.FetchChildrenAsync(anchors);
|
||||
|
||||
SampleController.Instance.Log("Child Anchors Fetched.");
|
||||
SampleController.Instance.Log(anchors.Count.ToString());
|
||||
SampleController.Instance.Log(anchors[0].ToString());
|
||||
|
||||
// Log the children anchors and their positions
|
||||
foreach (var anchor in anchors)
|
||||
{
|
||||
// check that this anchor is the floor
|
||||
|
||||
// check that this anchor is the Table
|
||||
if (!anchor.TryGetComponent(out OVRSemanticLabels labels) ||
|
||||
!labels.Labels.Contains(OVRSceneManager.Classification.Table))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's the Table!
|
||||
// enable locatable/tracking
|
||||
if (!anchor.TryGetComponent(out OVRLocatable locatable))
|
||||
continue;
|
||||
await locatable.SetEnabledAsync(true);
|
||||
|
||||
|
||||
// localize the anchor
|
||||
locatable.TryGetSceneAnchorPose(out OVRLocatable.TrackingSpacePose pose);
|
||||
Vector3? worldPosition = pose.ComputeWorldPosition(Camera.main);
|
||||
Quaternion? worldRotation = pose.ComputeWorldRotation(Camera.main);
|
||||
|
||||
if(worldPosition != null && worldRotation != null)
|
||||
{
|
||||
// If you want the position in local space relative to the room, use anchor.transform.localPosition
|
||||
var networkedCube = PhotonPun.PhotonNetwork.Instantiate(cubePrefab.name, (Vector3)worldPosition, (Quaternion)worldRotation);
|
||||
var photonGrabbable = networkedCube.GetComponent<PhotonGrabbableObject>();
|
||||
// only interested in the first floor anchor
|
||||
}
|
||||
|
||||
|
||||
// get the floor dimensions
|
||||
anchor.TryGetComponent(out OVRBounded3D bounded3D);
|
||||
var size = bounded3D.BoundingBox.size;
|
||||
|
||||
SampleController.Instance.Log("Child Anchors Fetched."+ size);
|
||||
SampleController.Instance.Log(anchors.Count.ToString());
|
||||
SampleController.Instance.Log(anchors[0].ToString());
|
||||
// If you want the position in local space relative to the room, use anchor.transform.localPosition
|
||||
|
||||
// only interested in the first floor anchor
|
||||
SampleController.Instance.Log(bounded3D.GetType().ToString());
|
||||
SampleController.Instance.Log(bounded3D.BoundingBox.size.x.ToString());
|
||||
SampleController.Instance.Log(bounded3D.BoundingBox.size.y.ToString());
|
||||
SampleController.Instance.Log(bounded3D.BoundingBox.size.y.ToString());
|
||||
//// If you want the position in local space relative to the room, use anchor.transform.localPosition
|
||||
//var networkedCube = PhotonPun.PhotonNetwork.Instantiate(cubePrefab.name, new Vector3(bounded3D.BoundingBox.size.x, bounded3D.BoundingBox.size.y, bounded3D.BoundingBox.size.z), spawnPoint.rotation);
|
||||
//var photonGrabbable = networkedCube.GetComponent<PhotonGrabbableObject>();
|
||||
//// only interested in the first floor anchor
|
||||
break;
|
||||
|
||||
|
||||
@ -250,9 +270,11 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
var photonGrabbable = networkedCube.GetComponent<PhotonGrabbableObject>();
|
||||
photonGrabbable.TransferOwnershipToLocalPlayer();
|
||||
|
||||
//await roomDetails();
|
||||
// Read room details
|
||||
Task.Run(roomDetails);
|
||||
}
|
||||
|
||||
|
||||
public void ChangeUserPassthroughVisualization()
|
||||
{
|
||||
CoLocatedPassthroughManager.Instance.NextVisualization();
|
||||
|
Loading…
x
Reference in New Issue
Block a user