Exemplo n.º 1
0
	public void Setup(int maxDepth, VisualNode startNode) {
		MaxDepth = maxDepth;
		PreviousNode = startNode;
		CurrentNode = startNode;
		
		transform.position = CurrentNode.transform.position + GetNodeOffset(CurrentNode);
	}
Exemplo n.º 2
0
        public void TestCreate02()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();

            storage.WriteUnsignedInteger(FieldCode.NodeSignature, 12);
            storage.WriteInteger(FieldCode.NodeType, 21);
            storage.Seek(0, SeekOrigin.Begin);

            Assert.Throws <ArgumentException>(() =>
            {
                IVisualNode node = VisualNode.Create(graphController, storage);
            });
        }
Exemplo n.º 3
0
	private Vector3 GetNodeOffset(VisualNode node) {
		if (node.IsRoot()) {
			return RootDistanceFromNode;
		}
		else if (node.Depth == 1) {
			return RootDepth1FromNode;
		}
		else if (node.Depth == 2) {
			return RootDepth2FromNode;
		}
		else {
			return LeafDistanceFromNode;
		}
	}
Exemplo n.º 4
0
 public void OnHideEdges()
 {
     hide_edges = true;
     edgesFound = Camera.main.GetComponents <EdgeUpdate>();
     GetComponent <MeshRenderer>().material.color = c_def;
     if (allocatedEdges.Count > 0)
     {
         foreach (int g in allocatedEdges)
         {
             VisualNode a = edgesFound[g].a.GetComponent <VisualNode>();
             VisualNode b = edgesFound[g].b.GetComponent <VisualNode>();
             edgesFound[g].Hide();
         }
     }
 }
    public GameObject CreateNewConversationNode(VisualNode node)
    {
        var inst = node.nodeManager.CreateNewNode();

        inst.transform.position = node.transform.position + Vector3.right * 5;
        node.responses.Add(inst.GetComponent <VisualNode>());
        node.data.responses.Add(inst.GetComponent <VisualNode>().data);
        inst.GetComponent <VisualNode>().responseTo.Add(node);
        inst.GetComponent <VisualNode>().data.responseTo.Add(node.data);
        Selection.activeTransform = inst.transform;

        node.nodeManager.CreateNewLineConnection(node.transform, inst.transform);

        return(inst);
    }
    public void setHead(VisualNode visualNode)
    {
        //Can't put something that's not a value inside here
        if (visualNode is BlockVisual)
        {
            return;
        }

        if (head != null)
        {
            visualNode.Next = head.Next;
        }

        head = visualNode;
    }
Exemplo n.º 7
0
 public void StartEdit(VisualNode visualNode, Node node)
 {
     if (contentUpdated)
     {
         StopEditing(delegate
         {
             InitializeNewNode(visualNode, node);
             Editor.StartEditingNode();
         });
     }
     else
     {
         InitializeNewNode(visualNode, node);
     }
 }
Exemplo n.º 8
0
 private void DisplayPreviewFailureMessage(uint nodeId)
 {
     if (null == CoreComponent.CurrentDispatcher)
     {
         return; // Headless mode?
     }
     CoreComponent.CurrentDispatcher.Invoke(new Action(() =>
     {
         VisualNode visualNode = controller.GetVisualNode(nodeId);
         if (null != visualNode && (false == visualNode.Error))
         {
             visualNode.SetPreviewValue("Framebuffer not supported");
         }
     }));
 }
    void OnCollisionStay(Collision other)
    {
        if (node == null)
        {
            node            = other.transform;
            nodeParent      = other.transform.parent;
            pickedUpNodePos = node.transform.position;
            print(node);
        }
        if (other.gameObject.tag == "CloseButton")
        {
            lasered_node = null;
        }
//        print(other.transform);
    }
Exemplo n.º 10
0
        public void DrawOperations_In_Cloned_Node_Are_Cloned()
        {
            var node1      = new VisualNode(Mock.Of <IVisual>(), null);
            var operation1 = RefCountable.Create(Mock.Of <IDrawOperation>());

            node1.AddDrawOperation(operation1);

            var node2      = node1.Clone(null);
            var operation2 = RefCountable.Create(Mock.Of <IDrawOperation>());

            node2.AddDrawOperation(operation2);

            Assert.Same(node1.DrawOperations[0].Item, node2.DrawOperations[0].Item);
            Assert.NotSame(node1.DrawOperations[0], node2.DrawOperations[0]);
        }
Exemplo n.º 11
0
	private void CreateChildrenNodes(VisualNode parent) {
		var nodeRenderer = parent.VisualComponent.renderer;
		var uvScrolls = nodeRenderer.GetComponents<ScrollUvLinear>();
		uvScrolls[0].materialToScroll = nodeRenderer.materials[0];
		uvScrolls[1].materialToScroll = nodeRenderer.materials[1];

		parent.VisualComponent.GetComponent<NodeClickComponent>().NodeCamera = NodeCamera;
		parent.SetupPaths();
		var lineClickComponent = parent.LineCollider.GetComponent<LineClickComponent>();
		lineClickComponent.NodeCamera = NodeCamera;

		if (parent.Depth > Depth) {
			return;
		}

		for (int childId = 0; childId < ChildrenPerNode; ++childId) {

			var position = parent.transform.position;
			var rotation = Quaternion.identity;

			var child = GameObject.Instantiate(VisualNodePrefab, position, rotation) as GameObject;
			child.transform.parent = parent.gameObject.transform;

			var node = child.GetComponent<VisualNode>();
			node.Parent = parent;

//			var nodeRenderer = childNode.VisualComponent.renderer;
//			nodeRenderer.GetComponent<ScrollUvLinear>().materialToScroll = nodeRenderer.material;
			//var radius = (nodeRenderer.bounds.max - nodeRenderer.bounds.min) * 0.25f; //TODO: Not general!

			var initialAngle = 0.66f * Mathf.PI;
			var angle = 0.33f * Mathf.PI;

			var distanceModifier = node.Depth;
			child.transform.localPosition = new Vector3(
				Mathf.Cos(initialAngle + angle*childId) * distanceModifier,
				Mathf.Sin(initialAngle + angle*childId) * distanceModifier, 
				0f
			) * baseDistanceBetweenNodes * node.DepthRatio;
			child.transform.localScale = baseScaleBetweenNodes * node.DepthRatio * Vector3.one;
			node.LineToParentChildWidth = child.transform.localScale.x * lineDepthWidthRatioChild;
			node.LineToParentParentWidth = child.transform.localScale.x * lineDepthWidthRatioParent;

			child.name = string.Format("Depth: {0}, Child: {1}", node.Depth.ToString("D3"), childId);

			CreateChildrenNodes(node);
		}
	}
    private void InitializePathFind()
    {
        search = true;
        PathMarker[] markers = FindObjectsOfType <PathMarker>();
        foreach (PathMarker p in markers)
        {
            Destroy(p.gameObject);
        }
        ArrayList allNodes = graph.returnGraphNodes();

        g1      = allNodes [Random.Range(0, allNodes.Count)] as GameObject;
        v1      = g1.GetComponent <VisualNode> ();
        v2      = v1;
        depth   = 0;
        explore = Random.Range(2, 6);
    }
    //Have these already set, just change to nextChild to make explicit
    public VisualNode nextNode()
    {
        VisualNode prev = current;

        if (current != null)
        {
            current = current.Next;
        }
        else
        {
            //If null then go back to head.
            current = head;
        }

        return(prev);
    }
Exemplo n.º 14
0
 protected void UpdateHighlights(VisualNode newNode)
 {
     if (_lastNode == newNode)
     {
         return;
     }
     if (_lastNode != null)
     {
         _lastNode.SetHighlighted(false);
     }
     if (newNode != null)
     {
         newNode.SetHighlighted(true);
     }
     _lastNode = newNode;
 }
        public void Should_Add_DrawOperations()
        {
            var node   = new VisualNode(new TestRoot(), null);
            var layers = new SceneLayers(node.Visual);
            var target = new DeferredDrawingContextImpl(null, layers);

            node.LayerRoot = node.Visual;

            using (target.BeginUpdate(node))
            {
                target.DrawRectangle(Brushes.Red, new Pen(Brushes.Green, 1), new Rect(0, 0, 100, 100));
            }

            Assert.Equal(1, node.DrawOperations.Count);
            Assert.IsType <RectangleNode>(node.DrawOperations[0].Item);
        }
Exemplo n.º 16
0
        public void Should_Update_DirtyRects()
        {
            var node      = new VisualNode(new TestRoot(), null);
            var operation = new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0);
            var layers    = new SceneLayers(node.Visual);
            var target    = new DeferredDrawingContextImpl(null, layers);

            node.LayerRoot = node.Visual;

            using (target.BeginUpdate(node))
            {
                target.FillRectangle(Brushes.Green, new Rect(0, 0, 100, 100));
            }

            Assert.Equal(new Rect(0, 0, 100, 100), layers.Single().Dirty.Single());
        }
 // Use this for initialization
 void Start()
 {
     placeNode += (VisualNode toPlaceOnto) =>
     {
         if (toPlaceOnto is BlockVisual)
         {
             BlockVisual bv = (BlockVisual)toPlaceOnto;
             bv.append(currentlyClicked);
         }
         else
         {
             toPlaceOnto.Next = currentlyClicked;
         }
         currentlyClicked = null;
     };
 }
Exemplo n.º 18
0
        public void Should_Not_Replace_Identical_VisualNode()
        {
            var parent = new VisualNode(new TestRoot(), null);
            var child  = new VisualNode(Mock.Of <IVisual>(), null);
            var layers = new SceneLayers(parent.Visual);

            parent.AddChild(child);

            var target = new DeferredDrawingContextImpl(null, layers);

            target.BeginUpdate(parent);
            target.BeginUpdate(child);

            Assert.Equal(1, parent.Children.Count);
            Assert.Same(child, parent.Children[0]);
        }
Exemplo n.º 19
0
	// Use this for initialization
	void Start () {
		//Random.seed = 58234;


		Root = GameObject.Instantiate(VisualNodePrefab, transform.position, Quaternion.identity) as GameObject;
		Root.name = "Root";
		RootNode = Root.GetComponent<VisualNode>();

		CreateChildrenNodes(RootNode);

		SetupNodeChildrenLinks(Root);
		SetNodeColors();

		NodeCamera.Setup(Depth, RootNode);

		RootNode.LineCollider.gameObject.SetActive(false);
	}
Exemplo n.º 20
0
        public void TrimChildren_Should_Work_Correctly()
        {
            var parent = new VisualNode(Mock.Of <IVisual>(), null);
            var child1 = new VisualNode(Mock.Of <IVisual>(), parent);
            var child2 = new VisualNode(Mock.Of <IVisual>(), parent);
            var child3 = new VisualNode(Mock.Of <IVisual>(), parent);

            parent.AddChild(child1);
            parent.AddChild(child2);
            parent.AddChild(child3);
            parent.TrimChildren(2);

            Assert.Equal(2, parent.Children.Count);
            Assert.False(child1.Disposed);
            Assert.False(child2.Disposed);
            Assert.True(child3.Disposed);
        }
    public GameObject CreateNewResponseNode(VisualNode node)
    {
        var inst = node.nodeManager.CreateNewNode();

        inst.transform.position = node.transform.position + Vector3.right * 5;
        inst.GetComponent <SpriteRenderer>().color = new Color(.7f, 1f, 1f);
        inst.GetComponent <VisualNode>().response  = true;
        node.responses.Add(inst.GetComponent <VisualNode>());
        node.data.responses.Add(inst.GetComponent <VisualNode>().data);
        inst.GetComponent <VisualNode>().responseTo.Add(node);
        inst.GetComponent <VisualNode>().data.responseTo.Add(node.data);
        Selection.activeTransform = inst.transform;

        node.nodeManager.CreateNewLineConnection(node.transform, inst.transform);

        return(inst);
    }
Exemplo n.º 22
0
        internal void EnsureNodeSlotInfo(uint nodeId, uint[] inputSlots, uint[] outputSlots)
        {
            VisualNode node = controller.GetVisualNode(nodeId);

            Assert.AreNotEqual(null, node);

            // Ensure input slot information is as expected.
            if (null == inputSlots || (inputSlots.Length <= 0))
            {
                Assert.AreEqual(null, node.GetInputSlots());
            }
            else
            {
                uint[] actualInputs = node.GetInputSlots();
                Assert.AreNotEqual(null, actualInputs);
                Assert.AreEqual(inputSlots.Length, actualInputs.Length);

                int index = 0;
                foreach (uint slot in inputSlots)
                {
                    // Ensure we have the expected input slots.
                    Assert.AreEqual(slot, actualInputs[index++]);
                }
            }


            // Ensure output slot information is as expected.
            if (null == outputSlots || (outputSlots.Length <= 0))
            {
                Assert.AreEqual(null, node.GetOutputSlots());
            }
            else
            {
                uint[] actualOutputs = node.GetOutputSlots();
                Assert.AreNotEqual(null, actualOutputs);
                Assert.AreEqual(outputSlots.Length, actualOutputs.Length);

                int index = 0;
                foreach (uint slot in outputSlots)
                {
                    // Ensure we have the expected output slots.
                    Assert.AreEqual(slot, actualOutputs[index++]);
                }
            }
        }
    // Generation Spheres
    void generateVisualization()
    {
        int count = graph.nodes.Count;
        int index = 0;

        nodePositions = new Vector3[count];
        springNodes   = new Rigidbody[count];
        // loop through nodePositions and generate vectors
        for (int i = 0; i < count; ++i)
        {
            float x = transform.position.x;
            float y = transform.position.y;
            float z = transform.position.z;

            nodePositions [i] =
                new Vector3(x + UnityEngine.Random.Range(-overallRadius * axisScale.x, overallRadius * axisScale.x),
                            y + UnityEngine.Random.Range(-overallRadius * axisScale.y, overallRadius * axisScale.y),
                            z + UnityEngine.Random.Range(-overallRadius * axisScale.z, overallRadius * axisScale.z));
        }
        // Go through each node create a VisualNode
        while (index < count)
        {
            Node       nodebeingadded = (Node)graph.nodes[index];
            GameObject icosphere      = Instantiate(node, nodePositions[index], transform.rotation);
            icosphere.transform.parent = transform;
            VisualNode n = icosphere.AddComponent <VisualNode>();
            n.setNode((Node)graph.nodes[index]);
            n.getNode().setVector3(nodePositions[index]);
            n.getNode().Transform = n.transform;
            // Adds positional information to node_info



            DrawLabel(icosphere.transform.position, n.getName(), 0, icosphere);
            icosphere.AddComponent <BoxCollider>();
            icosphere.AddComponent <Rigidbody>();
            springNodes[index]             = icosphere.GetComponent <Rigidbody>();
            springNodes[index].constraints = RigidbodyConstraints.FreezeRotation;
            icosphere.transform.parent     = this.transform;
            // add to array for reference later
            nodes_in_scene.Add((Node)graph.nodes[index], n);
            colombs_nodes.Add(icosphere);
            index++;
        }
    }
Exemplo n.º 24
0
        public void Adding_DrawOperation_To_Cloned_Node_Should_Create_New_Collection()
        {
            var node1      = new VisualNode(Mock.Of <IVisual>(), null);
            var operation1 = RefCountable.Create(Mock.Of <IDrawOperation>());

            node1.AddDrawOperation(operation1);

            var node2      = node1.Clone(null);
            var operation2 = RefCountable.Create(Mock.Of <IDrawOperation>());

            node2.ReplaceDrawOperation(0, operation2);

            Assert.NotSame(node1.DrawOperations, node2.DrawOperations);
            Assert.Equal(1, node1.DrawOperations.Count);
            Assert.Equal(1, node2.DrawOperations.Count);
            Assert.Same(operation1.Item, node1.DrawOperations[0].Item);
            Assert.Same(operation2.Item, node2.DrawOperations[0].Item);
        }
Exemplo n.º 25
0
        public void TestSlotType()
        {
            IGraphController controller = new GraphController(null);

            controller.DoCreateFunctionNode(1, 1, "", "Function", "double,double");

            List <IVisualNode> nodes = ((GraphController)controller).GetVisualNodes();
            VisualNode         node  = (VisualNode)nodes[0];
            uint  slotId             = node.GetInputSlot(0);
            ISlot slot   = ((GraphController)controller).GetSlot(slotId);
            bool  result = false;

            if (slot.SlotType != SlotType.None)
            {
                result = true;
            }
            Assert.AreEqual(true, result);
        }
Exemplo n.º 26
0
 public void UnHideEdges()
 {
     hide_edges = false;
     edgesFound = Camera.main.GetComponents <EdgeUpdate>();
     GetComponent <MeshRenderer>().material.color = c_def;
     if (allocatedEdges.Count > 0)
     {
         foreach (int g in allocatedEdges)
         {
             VisualNode a = edgesFound[g].a.GetComponent <VisualNode>();
             VisualNode b = edgesFound[g].b.GetComponent <VisualNode>();
             if (a.getCurrentlyHidden() == false && b.getCurrentlyHidden() == false)
             {
                 edgesFound[g].UnHide();
             }
         }
     }
 }
Exemplo n.º 27
0
    public void PlaceNode(Node node)
    {
        // Updates the node's position to the visual's position.
        node.PositionX = current.transform.position.x;
        node.PositionY = current.transform.position.y;

        // Tests if it is a new node or not.
        if (interactiveMap.Count < 1 ||
            node.Id > interactiveMap.Get(interactiveMap.Count - 1).Id)
        {
            interactiveMap.MapNodes.Add(node);
        }

        // Resets the state.
        NodeEditor.StartEdit(current, node);
        state   = MapEditorState.Idle;
        current = null;
        Editor.StartEditingNode();
    }
    public override void delete()
    {
        VisualNode current = head;
        VisualNode prev    = null;


        //Deletes everything nested under it.
        while (current != null)
        {
            //Okay this is where next is wanted to overriden, cause nested loops also recursively deleted.
            prev    = current;
            current = current.Next;
            Destroy(prev);
            prev = null;
        }

        //To delete itself
        base.delete();
    }
Exemplo n.º 29
0
        public void TrimChildren_Should_Trim_Children()
        {
            var root = new TestRoot();
            var node = new VisualNode(root, null)
            {
                LayerRoot = root
            };

            node.AddChild(new VisualNode(Mock.Of <IVisual>(), node)
            {
                LayerRoot = root
            });
            node.AddChild(new VisualNode(Mock.Of <IVisual>(), node)
            {
                LayerRoot = root
            });
            node.AddChild(new VisualNode(Mock.Of <IVisual>(), node)
            {
                LayerRoot = root
            });
            node.AddChild(new VisualNode(Mock.Of <IVisual>(), node)
            {
                LayerRoot = root
            });

            var layers = new SceneLayers(root);
            var target = new DeferredDrawingContextImpl(null, layers);
            var child1 = new VisualNode(Mock.Of <IVisual>(), null)
            {
                LayerRoot = root
            };
            var child2 = new VisualNode(Mock.Of <IVisual>(), null)
            {
                LayerRoot = root
            };

            target.BeginUpdate(node);
            using (target.BeginUpdate(child1)) { }
            using (target.BeginUpdate(child2)) { }
            target.TrimChildren();

            Assert.Equal(2, node.Children.Count);
        }
Exemplo n.º 30
0
        public void TestEnableEdit()
        {
            IGraphController controller = new GraphController(null);

            controller.DoCreateFunctionNode(1, 1, "", "Function", "int,int");

            List <IVisualNode> nodes   = ((GraphController)controller).GetVisualNodes();
            VisualNode         newNode = nodes[0] as VisualNode;

            newNode.EnableEdit(NodePart.Caption, -1);

            bool result = false;

            result = newNode.EnableEdit(NodePart.None, -1);
            Assert.AreEqual(false, result);
            newNode.DisableEdit();
            result = newNode.EnableEdit(NodePart.Caption, -1);
            Assert.AreEqual(true, result);
        }
    // Create thicker edges when highlighting
    public void createEdges()
    {
        ArrayList adjNodes = v.getAdjacencies();
        int       adjCount = adjNodes.Count;

        for (int i = 0; i < adjCount; i++)
        {
            GameObject g = new GameObject();
            g.AddComponent <LineRenderer>();
            LineRenderer l = g.gameObject.GetComponent <LineRenderer>();
            l.startWidth = 0.005f; l.endWidth = 0.005f;
            VisualNode adjNode = (VisualNode)adjNodes[i];
            l.SetPosition(0, transform.position);
            l.SetPosition(1, adjNode.transform.position);
            l.material = edgeMaterial;
            g.AddComponent <StudyEdges>();
            g.GetComponent <StudyEdges>().setEdge(transform, adjNode.transform);
            edgesCreated.Add(g.GetComponent <StudyEdges>());
        }
    }
Exemplo n.º 32
0
        VisualNode GetNewNode()
        {
            VisualNode ret = null;
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 2f, nodeLayer))
            {
                ret = hit.transform.GetComponent <VisualNode>();
                if (ret == null && hit.transform.parent != null)
                {
                    ret = hit.transform.parent.GetComponent <VisualNode>();
                }

                if (ret != null)
                {
                    _dragOffset = new Vector3(ret.transform.position.x - hit.point.x, ret.transform.position.y - hit.point.y, 0);
                }
            }
            return(ret);
        }
Exemplo n.º 33
0
        public void Trimmed_DrawOperations_Releases_Reference()
        {
            var node      = new VisualNode(new TestRoot(), null);
            var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0));
            var layers    = new SceneLayers(node.Visual);
            var target    = new DeferredDrawingContextImpl(null, layers);

            node.LayerRoot = node.Visual;
            node.AddDrawOperation(operation);
            Assert.Equal(2, operation.RefCount);

            using (target.BeginUpdate(node))
            {
                target.FillRectangle(Brushes.Green, new Rect(0, 0, 100, 100));
            }

            Assert.Equal(1, node.DrawOperations.Count);
            Assert.NotSame(operation, node.DrawOperations.Single());
            Assert.Equal(1, operation.RefCount);
        }
Exemplo n.º 34
0
        public void Should_Not_Replace_Identical_DrawOperation()
        {
            var node      = new VisualNode(new TestRoot(), null);
            var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0));
            var layers    = new SceneLayers(node.Visual);
            var target    = new DeferredDrawingContextImpl(null, layers);

            node.LayerRoot = node.Visual;
            node.AddDrawOperation(operation);

            using (target.BeginUpdate(node))
            {
                target.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100));
            }

            Assert.Equal(1, node.DrawOperations.Count);
            Assert.Same(operation.Item, node.DrawOperations.Single().Item);

            Assert.IsType <RectangleNode>(node.DrawOperations[0].Item);
        }
Exemplo n.º 35
0
	public void OnNodeClicked(VisualNode node) {
		CurrentNode = node;
		DetermineCameraTransition ();
	}
Exemplo n.º 36
0
	private VisualNode GetTopmostNode(VisualNode node) {
		if (node.IsLeaf()) {
			return node;
		}
		VisualNode leftmostNode = node.Children[0];
		for (int childId = 0; childId < node.Children.Length; ++childId) {
			var childNode = node.Children[childId];
			var tentativeLeftmost = GetTopmostNode(childNode);
			if (tentativeLeftmost.transform.position.y > leftmostNode.transform.position.y) {
				leftmostNode = tentativeLeftmost;
			}
		}
		return leftmostNode;
	}
Exemplo n.º 37
0
	private void OnEnable() {
		_visualNode = (VisualNode)target;
		//EditorApplication.update += Update;
	}
Exemplo n.º 38
0
        private void CreateBone(ModelBone i, int no)
        {
            var boneid  = i.Name.Replace(" ", "_");
            var bone    = new Bone()       { ID= "Bone-"+boneid, Name= i.Name, };
            var bonenode= new VisualNode() { ID= "Node-"+boneid, Name= i.Name, Instance= bone };
            var trn     = new SlimDX.Vector3(i.Params[0], i.Params[1], i.Params[2]);
            var rot     = new SlimDX.Quaternion(i.Params[3], i.Params[4], i.Params[5], -i.Params[6]);
            var mat     = SlimDX.Matrix.RotationQuaternion(rot)
                        * SlimDX.Matrix.Translation(trn);

            bonenode.SID            = "joint" + no;
            bonenode.LocalTransform = mat;

            Bones.Add(bonenode);
            Root.Instances.Add(bone);

            if(i.ParentID < 0)
            {
                bonenode.GlobalTransform= mat;

                Scene.Nodes.Add(bonenode);
            } else
            {
                var parent              = Bones[i.ParentID];
                bonenode.GlobalTransform= mat * parent.GlobalTransform;
                //bonenode.GlobalTransform= parent.GlobalTransform * mat;

                parent.Nodes.Add(bonenode);
            }
        }
Exemplo n.º 39
0
	private void SetNodeColorsHelper(VisualNode node, float minWorldX, float maxWorldX, float minWorldY, float maxWorldY) {

		float xLerp = Mathf.InverseLerp(minWorldX, maxWorldX, node.transform.position.x);
		float yLerp = Mathf.InverseLerp(minWorldY, maxWorldY, node.transform.position.y);
		//Debug.Log ("xLerp: " + xLerp + ", yLerp: " + yLerp);
		var nodeColor = new Color (0.5f + (xLerp + yLerp)/2.0f, xLerp, yLerp);
		var nodeRenderer = node.VisualComponent.renderer;

//		var randomColor = new Color(
//			Random.Range(0f, 1.0f),
//			Random.Range(0f, 1.0f),
//			Random.Range(0f, 1.0f),
//			1.0f
//		);
		var color = new Color(
			0.75f*Mathf.Cos (Mathf.PI*lastColoredNode*colorChangeRate) + 0.25f,
			0.75f*Mathf.Sin (Mathf.PI*lastColoredNode*colorChangeRate) + 0.25f,
			0.75f*Mathf.Sin (Mathf.PI*0.5f*lastColoredNode*colorChangeRate) + 0.25f,

			1.0f
		);
		++lastColoredNode;
		nodeRenderer.material.SetColor("_Color", color);

		if (node.IsLeaf()) {
			return;
		}
		for (int childId = 0; childId < node.Children.Length; ++childId) {
			var childNode = node.Children[childId];
			SetNodeColorsHelper(childNode, minWorldX, maxWorldX, minWorldY, maxWorldY);
		}
	}
Exemplo n.º 40
0
	// Update is called once per frame
	void Update () {
		PreviousNode = CurrentNode;
		CurrentNode = GetNextNode();

		DetermineCameraTransition();
	}