/// <summary>
    /// Creates a bounding box around a GameObject
    /// </summary>
    /// <param name="content">The GameObject which should be encompassed by the bounding box</param>
    /// <param name="bounds">The bounds to encompass (usually the GameObject's bounds or
    /// combined bounds with its children)</param>
    void CreateBoundingBox(GameObject content, Bounds bounds)
    {
        // create a bounding-box around the object
        GameObject box = GameObject.Instantiate(boundingBoxPrefab);

        box.transform.localScale = bounds.size;
        Transform contentHolder = box.transform.Find("Content");

        content.transform.parent = contentHolder;

        // set the correct position and rotation
        box.transform.position      = spawnPosition;
        box.transform.localRotation = Quaternion.Euler(spawnEulerAngles);

        BoundingBoxInfo info = box.GetComponent <BoundingBoxInfo>();

        info.Id = boundingBoxId;

        if (globalSpawnParent != null)
        {
            box.transform.parent = globalSpawnParent;
        }

        if (remotelySpawned)
        {
            CustomTapToPlace tapToPlace = box.GetComponent <CustomTapToPlace>();
            tapToPlace.IsBeingPlaced = false;
        }
    }
示例#2
0
 /// <summary>
 /// Get the necessary components: the collider of the bounding box and its annotationManager
 /// </summary>
 public void Start()
 {
     coll = GetComponent <BoxCollider>();
     attachementManager = gameObject.GetComponentInChildren <AttachementManager>();
     x3dParent          = transform.Find("Content/X3D Parent");
     if (x3dParent != null)
     {
         objectInfo = x3dParent.GetComponent <ObjectInfo>();
     }
     tapToPlace            = GetComponent <CustomTapToPlace>();
     transformationManager = GetComponent <TransformationManager>();
     info = GetComponent <BoundingBoxInfo>();
 }
示例#3
0
        public BoundingBoxInfo BoundingBox()
        {
            BoundingBoxInfo bb   = new BoundingBoxInfo();
            var             maxx = Points.Max(z => z.X);
            var             maxy = Points.Max(z => z.Y);
            var             maxz = Points.Max(z => z.Z);

            var minx = Points.Min(z => z.X);
            var miny = Points.Min(z => z.Y);
            var minz = Points.Min(z => z.Z);

            bb.Center = new Vector3d((maxx + minx) / 2, (maxy + miny) / 2, (maxz + minz) / 2);
            bb.Sizes  = new double[] { maxx - minx, maxy - miny, maxz - minz };
            return(bb);
        }
 private void Start()
 {
     ridgidBody = GetComponent <Rigidbody>();
     tapToPlace = GetComponent <CustomTapToPlace>();
     boxInfo    = GetComponentInChildren <BoundingBoxInfo>();
     if (boxInfo == null)
     {
         Debug.LogError("Bounding Box needs to have a BoundingBoxInfo");
     }
     if (instances == null)
     {
         instances = new Dictionary <string, TransformationManager>();
     }
     instances.Add(boxInfo.Id.ToString(), this);
 }
示例#5
0
    protected override void Start()
    {
        Debug.Log("Start of bounding box menu");
        base.Start();
        actions    = BoundingBox.GetComponent <BoundingBoxActions>();
        info       = BoundingBox.GetComponent <BoundingBoxInfo>();
        tapToPlace = BoundingBox.GetComponent <CustomTapToPlace>();
        Debug.Log("Create menu reference for " + info.Id.ToString());
        info.Menu = this;

        Debug.Log("InfoMenu: " + info.Menu);

        InitializeButtons();
        SetPlayerTypeMode();
        gameObject.SetActive(false);

        tapToPlace.OnPickUp += BoundingBoxPickedUp;
        tapToPlace.OnPlaced += BoundingBoxPlaced;
    }
 protected override void Start()
 {
     base.Start();
     info = GetComponent <BoundingBoxInfo>();
 }