void SetBoundingBoxValues(BoundingBoxReference boundingBoxReference, AABB box) { var min = new Vector3(box.Min.X, box.Min.Y, box.Min.Z); var max = new Vector3(box.Max.X, box.Max.Y, box.Max.Z); EncapsulateGlobalBounds(min, max); var size = max - min; boundingBoxReference.gameObject.transform.localPosition = min + (size / 2); boundingBoxReference.gameObject.transform.localScale = size; }
void ReleaseBoundingBoxReference(BoundingBoxReference boundingBoxReference) { if (boundingBoxReference == null || boundingBoxReference.gameObject == null) { return; } boundingBoxReference.gameObject.SetActive(false); boundingBoxReference.streamState = StreamState.Asset; m_BoundingBoxPool.Add(boundingBoxReference); }
void SetStreamState(BoundingBoxReference boundingBoxReference, StreamState streamState) { if (boundingBoxReference.streamState == StreamState.Invalid) { return; } boundingBoxReference.streamState = streamState; if (CurrentMaterialPresets.TryGetValue(streamState, out var material)) { boundingBoxReference.meshRenderer.sharedMaterial = material; } }
void InitBoundingBoxSceneObjects() { // init bounding boxes var amount = settings.visibleObjectsMax; m_BoundingBoxParent = m_Root != null ? m_Root : new GameObject("BoundingBoxRoot").transform; m_BoundingBoxes = new BoundingBoxReference[amount]; for (var i = 0; i < amount; ++i) { var obj = Object.Instantiate(settings.boundingBoxPrefab, m_BoundingBoxParent); var meshRenderer = obj.GetComponent <MeshRenderer>(); meshRenderer.enabled = false; m_BoundingBoxes[i] = new BoundingBoxReference { transform = obj.transform, meshRenderer = meshRenderer }; } }
void ReleaseBoundingBoxReference(BoundingBoxReference boundingBoxReference) { boundingBoxReference.meshRenderer.enabled = false; boundingBoxReference.streamState = StreamState.Asset; m_BoundingBoxPool.Add(boundingBoxReference); }