Beispiel #1
0
        public IEnumerator RunVolumeTest()
        {
            MutableObject testObj = new MutableObject();

            testObj.Add("height", 3f);
            testObj.Add("heightMax", 5f);

            VisualPayload payload = new VisualPayload(
                testObj,
                new VisualDescription(BoundingBox.ConstructBoundingBox(GetType().Name)));


            // create a volume controller
            RectangularVolumeController volumeController = new RectangularVolumeController();

            volumeController.YAxis.AbsoluteKey = "height";
            volumeController.YMax.AbsoluteKey  = "heightMax";

            // send the test mutable
            var iterator = volumeController.StartReceivePayload(payload);

            while (iterator.MoveNext( ))
            {
                yield return(null);
            }
        }
Beispiel #2
0
        public void Update()
        {
            if (!Exec)
            {
                return;
            }
            Exec = false;

            // declare the bounds we'll test with.  Boring.
            var topBound = BoundingBox.ConstructBoundingBox("Top Bound");

            topBound.transform.parent = transform;

            AllList = new List <BoundingBox>();

            for (int i = 0; i < 50; i++)
            {
                for (int k = 0; k < 50; k++)
                {
                    var newBound = topBound.CreateDependingBound("Second level " + i + ": Group" + i);
                    //newBound.DiscriminatingValues.Add( new KeyValuePair< string, object >( "Name", "Group" + i ) );
                    newBound.Data.Add("Name", i);
                    newBound.Data.Add("OtherName", k);
                    newBound.transform.position += transform.right * i;
                    newBound.transform.position += transform.forward * k;

                    var thirdBound = newBound.CreateDependingBound("Third level");
                    for (var j = 0; j < 50; j++)
                    {
                        var fourthBound = thirdBound.CreateDependingBound("Fourth level " + j + ": Team " + j);
                        fourthBound.Data.Add("Team", j);
                        fourthBound.transform.position += transform.up * j;
                        AllList.Add(fourthBound);
                    }
                }
            }


            //PayloadExpression newExpression = new PayloadExpression();

            //var step1 = new CriteriaGroup();
            //step1.Conjunction = CriteriaConjunction.Or;
            //step1.AddCriterion( new PredicateCriterionStatement(
            //    mut => CheckValueEquals(mut, "OtherName", 1)));
            //step1.AddCriterion(new PredicateCriterionStatement(
            //    mut => CheckValueEquals(mut, "Name", 2)));
            //newExpression.AddCriteriaGroup( step1 );

            //var step2 = new CriteriaGroup();
            //step2.Conjunction = CriteriaConjunction.Or;
            //step2.AddCriterion(new PredicateCriterionStatement(
            //    mut => CheckValueEquals(mut, "Team", 4)));
            //step2.AddCriterion(new PredicateCriterionStatement(
            //    mut => CheckValueEquals(mut, "Team", 12)));
            //newExpression.AddCriteriaGroup( step2 );

            //SelectedList = newExpression.ResolveExpression(new List<BoundingBox>() { topBound });
            //Debug.Log("Found " + SelectedList.Count + " valid objects.");
        }
Beispiel #3
0
        public BoundingBox ConstructCornerChild(CameraCorner corner)
        {
            var newBound = BoundingBox.ConstructBoundingBox(Vector3.zero, corner.ToString());

            newBound.transform.parent        = CameraCornerProvider.GetCornerTransform(corner);
            newBound.transform.localScale    = Vector3.one;
            newBound.transform.localRotation = Quaternion.identity;
            newBound.transform.localPosition = Vector3.zero;
            return(newBound);
        }
        public void DrawPoint(Vector3 drawPoint, MutableObject mutable)
        {
            var localPoint = transform.localToWorldMatrix.MultiplyPoint(drawPoint);

            var newBound = BoundingBox.ConstructBoundingBox(GetType().Name, localPoint, transform.rotation, Vector3.one);

            newBound.transform.parent = transform;

            newBound.name = "Scatter point: " + drawPoint;

            ScatterPoints.Add(new VisualPayload(mutable,
                                                new VisualDescription(newBound)));
        }
Beispiel #5
0
        public IEnumerator BeginRootNodeEvaluation(List <BoundingBox> rootBoundingBoxes)
        {
            var boundingBox = BoundingBox.ConstructBoundingBox(GetType().Name);

            rootBoundingBoxes.Add(boundingBox);


            var iterator = StartReceivePayload(new VisualPayload(new MutableObject(), new VisualDescription(boundingBox)));

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
        private MutableObject AddBoundsList(MutableObject mutable)
        {
            var boundsList = new List <BoundingBox>();

            for (int i = 0; i < NumberOfBounds.GetFirstValue(mutable); i++)
            {
                var newBound = BoundingBox.ConstructBoundingBox("Bound " + (i + 1),
                                                                Vector3.right * i,
                                                                Quaternion.identity,
                                                                Vector3.one);

                //newBound.Data.Add("BoundNumber", i);
                boundsList.Add(newBound);
            }

            BoundsTarget.SetValue(boundsList, mutable);

            return(mutable);
        }
Beispiel #7
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var boundsList = BoundsList.GetFirstValue(mutable).ToList();

            BoundingBox outgoingBound;

            if (boundsList.Any())
            {
                outgoingBound = boundsList.First();
            }
            else
            {
                outgoingBound = SchemaBound ?? (SchemaBound = BoundingBox.ConstructBoundingBox("Schema Box"));
            }

            FirstBoundTarget.SetValue(outgoingBound, mutable);

            return(mutable);
        }
        public IEnumerator SelectPlane(Vector3 includedPosition, Vector3 planeNormal)
        {
            BoundingBox selectVolume = BoundingBox.ConstructBoundingBox(GetType().Name, includedPosition,
                                                                        Quaternion.LookRotation(planeNormal), Vector3.one);

            selectVolume.transform.localScale = new Vector3(999f, 999f, 1f);

            selectVolume.transform.position -= selectVolume.transform.right * 500f + selectVolume.transform.up * 500f;

            var iterator = PayloadSelectVolume.SelectVolumeByCenter(SelectionMode, selectVolume);

            while (iterator.MoveNext( ))
            {
                yield return(null);
            }

            //selectVolume.name = "Select Volume";

            DestroyImmediate(selectVolume.gameObject);
        }
Beispiel #9
0
        private BoundingBox ConstructChildBound(IEnumerable <BoundingBox> bounds, BoundChildTypes childMethod)
        {
            ClearBounds();

            if (!bounds.Any())
            {
                return(BoundingBox.ConstructBoundingBox("Child Bound"));
            }

            var firstBound = bounds.First();

            var sharedSpace = BoundingBox.SharedVisualSpace(bounds.ToList());

            switch (childMethod)
            {
            case BoundChildTypes.CenterOfFirst:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(Vector3.zero)
                           , firstBound.transform.rotation));

            case BoundChildTypes.OriginOfFirst:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(Vector3.one * -.5f),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfMinusX:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(-.5f, 0f, 0f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfPlusX:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(+.5f, 0f, 0f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfMinusY:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(0f, -.5f, 0f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfPlusY:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(0f, +.5f, 0f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfMinusZ:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(0f, 0f, -.5f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfPlusZ:
                return(ConstructMinimalBound(
                           firstBound.VisualSpace.LocalToWorldSpace(new Vector3(0f, 0f, +.5f)),
                           firstBound.transform.rotation));

            case BoundChildTypes.CenterOfAll:

                // note: this does not inherit rotation from any of the related bounds.  Use average?
                var center     = Vector3.zero;
                var totalCount = 0f;
                foreach (var bound in bounds)
                {
                    center += bound.Centerpoint;
                    totalCount++;
                }
                center /= Mathf.Max(totalCount, 1f);

                var extents = new UnityEngine.Bounds();
                extents.center = center;

                foreach (var bound in bounds)
                {
                    extents.Encapsulate(bound.Centerpoint);
                }
                return(BoundingBox.ConstructBoundingBox
                           ("Child Bound", extents.center, Quaternion.identity, .01f * Vector3.one));

            case BoundChildTypes.CenterOfAllPlusX:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(.5f, 0, 0) * sharedSpace.size.x,
                           Quaternion.identity));

            case BoundChildTypes.CenterOfAllMinusX:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(-.5f, 0, 0) * sharedSpace.size.x,
                           Quaternion.identity));

            case BoundChildTypes.CenterOfAllPlusY:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(0, .5f, 0) * sharedSpace.size.y,
                           Quaternion.identity));

            case BoundChildTypes.CenterOfAllMinusY:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(0, -.5f, 0) * sharedSpace.size.y,
                           Quaternion.identity));

            case BoundChildTypes.CenterOfAllPlusZ:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(0, 0, .5f) * sharedSpace.size.z,
                           Quaternion.identity));

            case BoundChildTypes.CenterOfAllMinusZ:
                return(ConstructMinimalBound(
                           sharedSpace.center + new Vector3(0, 0, -.5f) * sharedSpace.size.z,
                           Quaternion.identity));

            default:
                throw new Exception("Invalid child bounding operation!");
            }
        }
Beispiel #10
0
 private BoundingBox ConstructMinimalBound(Vector3 position, Quaternion rotation)
 {
     return(BoundingBox.ConstructBoundingBox
                ("Child Bound", position, rotation, .01f * Vector3.one));
 }