public Vector3 GetAnchorDirection(ItemAnchorPlane anchorPlane) { Vector3 direction = Vector3.one; switch (anchorPlane) { case ItemAnchorPlane.POSITIVE_X: direction = Vector3.right; break; case ItemAnchorPlane.POSITIVE_Y: direction = Vector3.up; break; case ItemAnchorPlane.POSITIVE_Z: direction = Vector3.forward; break; case ItemAnchorPlane.NEGATIVE_X: direction = -Vector3.right; break; case ItemAnchorPlane.NEGATIVE_Y: direction = -Vector3.up; break; case ItemAnchorPlane.NEGATIVE_Z: direction = -Vector3.forward; break; } return(direction); }
private Matrix4x4 GetRandomOrientationMatrix(System.Random rnd, ItemAnchorPlane anchorPlane) { Vector3 dir = GetAnchorDirection(anchorPlane); int rot = rnd.Next(4) * 90; return(Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(dir * rot), Vector3.one)); }
public Vector3 GetAnchorPosition(ItemAnchorPlane anchorPlane, Bounds bounds) { Vector3 direction = GetAnchorDirection(anchorPlane); return(bounds.center + direction * Mathf.Abs(Vector3.Dot(direction, bounds.extents))); }
private List <int> CalculateAvailableItemsInProceduralVolume(string parentItemTag, Bounds proceduralVolume, ItemAnchorPlane anchorPlane) { List <int> itemIndices = new List <int>(); if (itemIndicesByTagParent.ContainsKey(parentItemTag)) { HashSet <int> availableIndices = itemIndicesByTagParent[parentItemTag]; foreach (int itemIndex in availableIndices) { ItemData item = itemDataArray[itemIndex]; // We are ignoring random transformations for this check. This is on purpose... randoms shouldn't change too much if (item.anchorPlane == anchorPlane && MathUtils.ContainsWithoutTranslation(proceduralVolume, item.itemBounds)) { itemIndices.Add(itemIndex); } } } return(itemIndices); }