コード例 #1
0
    // Computation of the absolute x and z coordinates for each node
    private void SecondWalk(GenericOperator nodeN, float x, float z, float l, float t)
    {
        IconProperties np  = nodeN.GetIcon().GetComponent <IconProperties>();
        Vector3        pos = new Vector3(x, 2, z);

        l = np.depth / (np.depth + 1);

        nodeN.GetIcon().transform.position = pos;
        float dd        = l * np.d;
        float p         = t + Mathf.PI;
        float freeSpace = (nodeN.Children.Count == 0 ? 0 : np.f / (nodeN.Children.Count + 1));
        float previous  = 0;

        foreach (var child in nodeN.Children)
        {
            IconProperties cp = child.GetIcon().GetComponent <IconProperties>();
            float          aa = np.c * cp.a;
            float          rr = np.d * Mathf.Tan(aa) / (1 - Mathf.Tan(aa));
            p += previous + aa + freeSpace;
            float xx = (l * rr + dd) * Mathf.Cos(p);
            float zz = (l * rr + dd) * Mathf.Sin(p);
            previous = aa;
            SecondWalk(child, x + xx, z + zz, l * np.c, p);
        }
    }
コード例 #2
0
 [Test] public void LogicalOperation()
 {
     Assert.AreEqual(0x0123456 & 0x654321, GenericOperator.And(0x0123456, 0x654321));
     Assert.AreEqual(0x0123456 | 0x654321, GenericOperator.Or(0x0123456, 0x654321));
     Assert.AreEqual(0x0123456 ^ 0x654321, GenericOperator.Xor(0x0123456, 0x654321));
     Assert.AreEqual(~0x0123456, GenericOperator.Not(0x0123456));
 }
コード例 #3
0
 private void Awake()
 {
     if (transform != null && transform.parent != null)
     {
         Op = transform.parent.GetComponent <GenericOperator>();
     }
 }
コード例 #4
0
    private void drawConnectionToChildren(GenericOperator go)
    {
        if (go.Children == null || go.Children.Count == 0)
        {
            return;
        }
        foreach (GenericOperator child in go.Children)
        {
            if (go.GetIcon() == null || child == null || child.GetIcon() == null)
            {
                continue;
            }

            GameObject   line         = new GameObject();
            LineRenderer lineRenderer = line.AddComponent <LineRenderer>();
            lineRenderer.SetWidth(0.01f, 0.01f);

            lineRenderer.SetPositions(new Vector3[] {
                go.GetIcon().transform.position + new Vector3(0, 0, 0.001f), child.GetIcon().transform.position + new Vector3(0, 0, 0.001f)
            });
            line.transform.parent         = Container.transform;
            lineRenderer.transform.parent = Container.transform;
            graphEdges.Add(line);
        }
    }
コード例 #5
0
        [Test] public void VectorMath()
        {
            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) + new Vector2(1.0f, 3.0f),
                GenericOperator.Add(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f)));
            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) - new Vector2(1.0f, 3.0f),
                GenericOperator.Subtract(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f)));
            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) * new Vector2(1.0f, 3.0f),
                GenericOperator.Multiply(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f)));
            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) / new Vector2(1.0f, 3.0f),
                GenericOperator.Divide(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f)));

            Assert.AreEqual(
                -new Vector2(2.0f, 0.5f),
                GenericOperator.Negate(new Vector2(2.0f, 0.5f)));

            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) == new Vector2(1.0f, 3.0f),
                GenericOperator.Equal(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f)));
            Assert.AreEqual(
                new Vector2(2.0f, 0.5f) == new Vector2(2.0f, 0.5f),
                GenericOperator.Equal(new Vector2(2.0f, 0.5f), new Vector2(2.0f, 0.5f)));
        }
コード例 #6
0
 [Test] public void ConvertOperation()
 {
     Assert.AreEqual((float)5, GenericOperator.Convert <int, float>(5));
     Assert.AreEqual((int)5.5f, GenericOperator.Convert <float, int>(5.5f));
     Assert.AreEqual((decimal)5.5f, GenericOperator.Convert <float, decimal>(5.5f));
     Assert.AreEqual((int)ColorRgba.Red, GenericOperator.Convert <ColorRgba, int>(ColorRgba.Red));
 }
コード例 #7
0
    IEnumerator SetIconLocation(GenericOperator op, Vector3 position)
    {
        yield return(0);

        op.GetIcon().transform.position = position;
        op.Fetchdata();
        op.Process();
    }
コード例 #8
0
 public void moveNewIconAndDestroyOperator(GenericOperator genericOperator)
 {
     if (spawnedPrefab.GetComponent <GenericOperator>() == genericOperator) //genericOperator.GetType().Equals((typeof(NewOperator))) &&
     {
         genericOperator.GetIcon().gameObject.transform.localPosition =
             GetOperator().GetIcon().transform.localPosition;
         GetOperator().Observer.NewOperatorInitializedAndRunnningEvent -= moveNewIconAndDestroyOperator;
         GetOperator().Observer.DestroyOperator(GetOperator());
     }
 }
コード例 #9
0
 // Update is called once per frame
 void Update()
 {
     if (runConeTree)
     {
         root        = observer.GetOperators()[0];
         _anchor     = root.GetIcon().transform.position;
         runConeTree = false;
         Layout(root, _anchor.x, _anchor.z);
     }
 }
コード例 #10
0
        [Test] public void LerpOperation()
        {
            Assert.AreEqual(0.6f, GenericOperator.Lerp(0.0f, 1.0f, 0.6f));

            Assert.AreEqual(0, GenericOperator.Lerp(0, 1, 0.61f));
            Assert.AreEqual(1, GenericOperator.Lerp(0, 2, 0.61f));
            Assert.AreEqual(6, GenericOperator.Lerp(0, 10, 0.61f));

            Assert.AreEqual(ColorRgba.Lerp(ColorRgba.Red, ColorRgba.Blue, 0.6f), GenericOperator.Lerp(ColorRgba.Red, ColorRgba.Blue, 0.6f));
            Assert.AreEqual(Vector2.Lerp(Vector2.UnitX, Vector2.UnitY, 0.6f), GenericOperator.Lerp(Vector2.UnitX, Vector2.UnitY, 0.6f));
        }
コード例 #11
0
    public void moveToSpawnPosition(GenericOperator op)
    {
        if (op.GetType().Equals((typeof(NewOperator))) && op.Parents != null)
        {
            op.GetIcon().transform.position = op.Parents[0].GetIcon().transform.position + new Vector3(1, 0, 0);
        }

        if (op.Parents != null && op.Parents.Count > 0 && op.Parents[0].Children != null)
        {
            op.GetIcon().transform.position += new Vector3(0, (op.Parents[0].Children.Count - 1) * 0.3f, 0);
        }
    }
コード例 #12
0
    IEnumerator ReloadData(GenericOperator firstNode)
    {
        yield return(0);

        if (firstNode.GetRawInputData() != null)
        {
            firstNode.ReProcess(firstNode.GetRawInputData());
        }
        else
        {
            firstNode.ReProcess(firstNode.GetOutputData());
        }
    }
コード例 #13
0
 private void DestroyNewOperatorChildren(GenericOperator op)
 {
     if (op.GetType().Equals(typeof(NewOperator)))
     {
         Observer.DestroyOperator(op);
     }
     if (op.Children.Count == 0)
     {
         return;
     }
     else
     {
         DestroyNewOperatorChildren(op.Children[op.Children.Count - 1]);
     }
 }
コード例 #14
0
        protected override void OnLeftClickOnTargetEventAction()
        {
            //Debug.Log("New Operator Clicked");

            ClickedOp = GetOperator();

            if (optionsDisplayed)
            {
                hideOptions();
            }
            else
            {
                displayOptions();
            }
        }
コード例 #15
0
        [Test] public void FloatMath()
        {
            Assert.AreEqual(2f + 3f, GenericOperator.Add(2f, 3f));
            Assert.AreEqual(2f - 3f, GenericOperator.Subtract(2f, 3f));
            Assert.AreEqual(2f * 3f, GenericOperator.Multiply(2f, 3f));
            Assert.AreEqual(2f / 3f, GenericOperator.Divide(2f, 3f));

            Assert.AreEqual(Math.Abs(-5f), GenericOperator.Abs(-5f));
            Assert.AreEqual(5f % 4f, GenericOperator.Modulo(5f, 4f));
            Assert.AreEqual(-5f, GenericOperator.Negate(5f));

            Assert.AreEqual(5f == 4f, GenericOperator.Equal(5f, 4f));
            Assert.AreEqual(5f == 5f, GenericOperator.Equal(5f, 5f));
            Assert.AreEqual(5f > 4f, GenericOperator.GreaterThan(5f, 4f));
            Assert.AreEqual(5f >= 5f, GenericOperator.GreaterThanOrEqual(5f, 5f));
            Assert.AreEqual(5f < 4f, GenericOperator.LessThan(5f, 4f));
            Assert.AreEqual(5f <= 5f, GenericOperator.LessThanOrEqual(5f, 5f));
        }
コード例 #16
0
        [Test] public void IntMath()
        {
            Assert.AreEqual(2 + 3, GenericOperator.Add(2, 3));
            Assert.AreEqual(2 - 3, GenericOperator.Subtract(2, 3));
            Assert.AreEqual(2 * 3, GenericOperator.Multiply(2, 3));
            Assert.AreEqual(2 / 3, GenericOperator.Divide(2, 3));

            Assert.AreEqual(Math.Abs(-5), GenericOperator.Abs(-5));
            Assert.AreEqual(5 % 4, GenericOperator.Modulo(5, 4));
            Assert.AreEqual(-5, GenericOperator.Negate(5));

            Assert.AreEqual(5 == 4, GenericOperator.Equal(5, 4));
            Assert.AreEqual(5 == 5, GenericOperator.Equal(5, 5));
            Assert.AreEqual(5 > 4, GenericOperator.GreaterThan(5, 4));
            Assert.AreEqual(5 >= 5, GenericOperator.GreaterThanOrEqual(5, 5));
            Assert.AreEqual(5 < 4, GenericOperator.LessThan(5, 4));
            Assert.AreEqual(5 <= 5, GenericOperator.LessThanOrEqual(5, 5));
        }
コード例 #17
0
    /* Bottom up proceeding, computing value for distances
     * possibly computing scaling factor for children and
     * computing radius of circles
     */
    private void FirstWalk(GenericOperator node)
    {
        IconProperties np = node.GetIcon().GetComponent <IconProperties>();

        np.d = 0;
        float s = 0;

        foreach (var child in node.Children)
        {
            FirstWalk(child);
            IconProperties cp = child.GetIcon().GetComponent <IconProperties>();
            np.d = Mathf.Max(np.d, cp.r);
            cp.a = Mathf.Atan(cp.r / (np.d + cp.r));
            s   += cp.a;
        }
        AdjustChildren(np, s);
        SetRadius(np);
    }
コード例 #18
0
        [Test] public void ColorRgbaMath()
        {
            Assert.AreEqual(
                ColorRgba.Red + ColorRgba.Blue,
                GenericOperator.Add(ColorRgba.Red, ColorRgba.Blue));
            Assert.AreEqual(
                ColorRgba.Red - ColorRgba.Blue,
                GenericOperator.Subtract(ColorRgba.Red, ColorRgba.Blue));
            Assert.AreEqual(
                ColorRgba.Red * ColorRgba.Blue,
                GenericOperator.Multiply(ColorRgba.Red, ColorRgba.Blue));

            Assert.AreEqual(
                ColorRgba.Red == ColorRgba.Blue,
                GenericOperator.Equal(ColorRgba.Red, ColorRgba.Blue));
            Assert.AreEqual(
                ColorRgba.Red == ColorRgba.Red,
                GenericOperator.Equal(ColorRgba.Red, ColorRgba.Red));
        }
コード例 #19
0
 public static void LoadData(string path)
 {
     Debug.Log("press load");
     ClearOperators();
     //destroy any current nodes in observer
     if (observer.GetOperators() != null)
     {
         for (int i = observer.GetOperators().Count - 1; i >= 0; i--)
         {
             observer.GetOperators()[i].Disable();
             observer.DestroyOperator(observer.GetOperators()[i]);
         }
     }
     genericOperatorContainer = LoadOperators(path);
     foreach (OperatorData data in genericOperatorContainer.operators)
     {
         SaveLoadController.CreateGenericOperator(data);
     }
     root = observer.GetOperators()[0];
     instance.StartCoroutine(instance.ReloadData(root));
 }
コード例 #20
0
        /// <summary>
        /// Returns the animated value at the specified time.
        /// </summary>
        /// <param name="time">Time in seconds.</param>
        /// <returns></returns>
        public T GetValue(float time)
        {
            if (this.keyFrames.Count == 0)
            {
                throw new InvalidOperationException("Can't interpolate on empty AnimationTrack.");
            }

            AnimationKeyFrame <T>[] data = this.keyFrames.Data;
            int   frameCount             = this.KeyFrameCount;
            float duration = this.Duration;

            if (this.loop)
            {
                time = MathF.NormalizeVar(time, 0.0f, duration);
            }

            int baseIndex = this.SearchIndexBelow(time);

            if (baseIndex < 0)
            {
                return(data[0].Value);
            }
            if (baseIndex == frameCount - 1 && !this.loop)
            {
                return(data[frameCount - 1].Value);
            }

            int   nextIndex = (baseIndex + 1) % frameCount;
            float nextTime  = data[nextIndex].Time;

            if (nextTime < data[baseIndex].Time)
            {
                nextTime += duration;
            }

            float factor = (time - data[baseIndex].Time) / (nextTime - data[baseIndex].Time);

            return(GenericOperator.Lerp(data[baseIndex].Value, data[nextIndex].Value, factor));
        }
コード例 #21
0
    public static GenericOperator CreateGenericOperator(OperatorData data)
    {
        Vector3 position = new Vector3();
        List <GenericOperator> parents    = new List <GenericOperator>();
        List <GameObject>      prefabList = obs.GetOperatorPrefabs();

        foreach (var prefab in prefabList)
        {
            if (data.name == prefab.name)
            {
                parents  = new List <GenericOperator>();
                position = new Vector3(data.posX, data.posY, data.posZ);
                int parentID = 0;
                foreach (var child in obs.GetOperators())
                {
                    parentID = child.Id;
                    if (parentID == data.parent)
                    {
                        parents.Add(child.GetComponent <GenericOperator>());
                        break;
                    }
                }
                GameObject      go = obs.CreateOperator(prefab, parents);
                GenericOperator op = go.GetComponent <GenericOperator>() ?? go.AddComponent <GenericOperator>();
                //waiting for one frame, due to generating icons and children
                instance.StartCoroutine(instance.SetIconLocation(op, position));
                instance.StartCoroutine(instance.DestroyNewOperatorChildren(op.Children));
                op.Id = data.ID;
                op.LoadSpecificData(data);

                operatorList.Add(op);
                return(op);
            }
        }
        return(null);
    }
コード例 #22
0
    public void InstallVisualization(GenericOperator op)
    {
        if (op == null)
        {
            return;
        }
        if (gameObject.transform.childCount > 0)
        {
            foreach (var vis in transform.GetComponentsInChildren <GenericVisualization>())
            {
                vis.gameObject.transform.parent = vis.GetOperator().gameObject.transform;
                vis.gameObject.SetActive(false);
            }
        }

        if (op.GetVisualization() == null)
        {
            return;
        }

        op.GetVisualization().gameObject.SetActive(true);
        op.GetVisualization().gameObject.transform.parent = gameObject.transform;
        //op.getVisualization().gameObject.transform.localPosition = new Vector3();
    }
コード例 #23
0
 public override bool ValidateIfOperatorPossibleForParents(GenericOperator parent)
 {
     //spawn SplitDatasetOperator only if a parent has output data
     return(parent.hasOutput);
 }
コード例 #24
0
 public void SetOperator(GenericOperator operatorObj)
 {
     Op = operatorObj;
 }
コード例 #25
0
 public override bool ValidateIfOperatorPossibleForParents(GenericOperator parent)
 {
     //data loader operator can be spawned even if no datamodel exists yet
     return(true);
 }
コード例 #26
0
 public static T Add <T>(T first, T second)
 {
     return(GenericOperator <T, T> .Add(first, second));
 }
コード例 #27
0
 private void Layout(GenericOperator root, float x, float z)
 {
     FirstWalk(root);
     SecondWalk(root, x, z, 1f, 0f);
 }
コード例 #28
0
 public override bool ValidateIfOperatorPossibleForParents(GenericOperator parent)
 {
     return(true);
 }
コード例 #29
0
 public static TResult Convert <TFrom, TResult>(TFrom value)
 {
     return(GenericOperator <TFrom, TResult> .Convert(value));
 }
コード例 #30
0
 T IAnimation.GetCurrentValue <T>()
 {
     return(GenericOperator.Convert <TValue, T>(this.CurrentValue));
 }