2023-12-29 19:00:20 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Oculus SDK License Agreement (the "License");
|
|
|
|
* you may not use the Oculus SDK except in compliance with the License,
|
|
|
|
* which is provided at the time of installation or download, or which
|
|
|
|
* otherwise accompanies this software in either electronic or hard copy form.
|
|
|
|
*
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* https://developer.oculus.com/licenses/oculussdk/
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class SampleVirtualFrames : MonoBehaviour
|
|
|
|
{
|
|
|
|
public OVRSceneManager _sceneManager;
|
|
|
|
|
2024-01-05 16:35:05 +01:00
|
|
|
public SimpleResizable _tablePrefab;
|
2023-12-29 19:00:20 +01:00
|
|
|
|
2024-01-05 17:35:57 +01:00
|
|
|
public GameObject _cube;
|
|
|
|
|
2024-01-05 17:37:25 +01:00
|
|
|
|
2023-12-29 19:00:20 +01:00
|
|
|
void Awake()
|
|
|
|
{
|
|
|
|
MarcsWebLogger.Log("SampleVirtualFrames::Awake()");
|
|
|
|
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_ANDROID
|
|
|
|
OVRManager.eyeFovPremultipliedAlphaModeEnabled = false;
|
|
|
|
#endif
|
|
|
|
_sceneManager.SceneModelLoadedSuccessfully += InitializeRoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitializeRoom()
|
|
|
|
{
|
|
|
|
MarcsWebLogger.Log("SampleVirtualFrames::InitializeRoom()");
|
|
|
|
OVRSceneAnchor[] sceneAnchors = FindObjectsOfType<OVRSceneAnchor>();
|
|
|
|
if (sceneAnchors != null)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < sceneAnchors.Length; i++)
|
|
|
|
{
|
2024-01-05 16:35:05 +01:00
|
|
|
var randomNumber = UnityEngine.Random.Range(10000, 99999);
|
2023-12-29 19:00:20 +01:00
|
|
|
OVRSceneAnchor instance = sceneAnchors[i];
|
|
|
|
OVRSemanticClassification classification = instance.GetComponent<OVRSemanticClassification>();
|
2024-01-05 16:35:05 +01:00
|
|
|
//MarcsWebLogger.Log($"{randomNumber} | is a {classification}");
|
2023-12-29 19:00:20 +01:00
|
|
|
|
2024-01-05 16:35:05 +01:00
|
|
|
if (classification.Contains(OVRSceneManager.Classification.Table))
|
2023-12-29 19:00:20 +01:00
|
|
|
{
|
2024-01-05 16:35:05 +01:00
|
|
|
MarcsWebLogger.Log($"{randomNumber} | FOUND A Table");
|
2023-12-29 19:00:20 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
SimpleResizer resizer = new SimpleResizer();
|
2024-01-05 16:35:05 +01:00
|
|
|
SimpleResizable prefab = _tablePrefab;
|
2023-12-29 19:00:20 +01:00
|
|
|
Vector3 dimensions = instance.transform.GetChild(0).localScale;
|
|
|
|
if (prefab.GetComponent<ResizablePadding>())
|
|
|
|
{
|
|
|
|
dimensions += prefab.GetComponent<ResizablePadding>().dimensionPadding;
|
|
|
|
}
|
|
|
|
resizer.CreateResizedObject(dimensions, sceneAnchors[i].gameObject, prefab);
|
2024-01-05 17:35:57 +01:00
|
|
|
|
|
|
|
// now place the cubes
|
2024-01-05 17:37:25 +01:00
|
|
|
Instantiate(_cube, sceneAnchors[i].gameObject.transform.position + new Vector3(0, 0, 0.3f), Quaternion.Euler(0, 90, 0));
|
|
|
|
|
2023-12-29 19:00:20 +01:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
MarcsWebLogger.Log($"{randomNumber} | Error: {e.Message}");
|
|
|
|
}
|
2024-01-05 16:35:05 +01:00
|
|
|
MarcsWebLogger.Log($"{randomNumber} | PLACED A Table");
|
2023-12-29 19:00:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-05 16:35:05 +01:00
|
|
|
/*
|
|
|
|
if (classification.Contains(OVRSceneManager.Classification.WallFace))
|
|
|
|
{
|
|
|
|
var randomNumber = UnityEngine.Random.Range(10000, 99999);
|
|
|
|
MarcsWebLogger.Log($"{randomNumber} | FOUND A WALL");
|
|
|
|
try
|
2023-12-29 19:00:20 +01:00
|
|
|
{
|
2024-01-05 16:35:05 +01:00
|
|
|
SimpleResizer resizer = new SimpleResizer();
|
|
|
|
SimpleResizable prefab = _wallPrefab;
|
|
|
|
Vector3 dimensions = instance.transform.GetChild(0).localScale;
|
|
|
|
if (prefab.GetComponent<ResizablePadding>())
|
|
|
|
{
|
|
|
|
dimensions += prefab.GetComponent<ResizablePadding>().dimensionPadding;
|
|
|
|
}
|
|
|
|
resizer.CreateResizedObject(dimensions, sceneAnchors[i].gameObject, prefab);
|
2023-12-29 19:00:20 +01:00
|
|
|
}
|
2024-01-05 16:35:05 +01:00
|
|
|
catch (Exception e)
|
2023-12-29 19:00:20 +01:00
|
|
|
{
|
2024-01-05 16:35:05 +01:00
|
|
|
MarcsWebLogger.Log($"{randomNumber} | Error: {e.Message}");
|
2023-12-29 19:00:20 +01:00
|
|
|
}
|
2024-01-05 16:35:05 +01:00
|
|
|
MarcsWebLogger.Log($"{randomNumber} | PLACED A WALL");
|
|
|
|
//i = 99999;
|
2023-12-29 19:00:20 +01:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MarcsWebLogger.Log("NO ANCHORS FOUND. ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|