Ejemplo n.º 1
0
 /// <summary>
 /// To use this please pass the node you want to use as root node to this method. It is assumed that in the scene hierarchy this node is the root node to all other NEEDSIMNodes. So if you have  a village with houses and objects in each house you should, in the scene view, make the village parent of the houses, and the houses object of the village, and each game object should have a NEEDSIMNode. You can leave the interactions set to none for the village and the houses if they are just used to calculate the abstraction for the Affordance Tree.
 /// The method BuildTreeBasedOnSceneHierarchy() that is called here will not work for intermediate objects in the hierarchy - there is only deeper search if a direct ancestor is a NEEDSIMNode.
 /// </summary>
 /// <param name="node"></param>
 public void BuildAffordanceTreeFromNode(NEEDSIMNode node)
 {
     node.AffordanceTreeNode = new AffordanceTreeNode(null, node.name, node.speciesName, node.gameObject.transform.position);
     root = node.AffordanceTreeNode;
     Simulation.Manager.Instance.Data.Root = root;
     node.BuildTreeBasedOnSceneHierarchy();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Goes through the scene and adds all NEEDSIMNodes as children of the root.
        /// This is best if you don't have complexity issues to deal with. Otherwise building
        /// the affordance tree with more depth  is adviced.
        /// </summary>
        public void BuildFlatAffordanceTreeFromScene()
        {
            WriteToSimulationDebugLog("Affordance Tree build from scene.");

            root = new AffordanceTreeNode(null, "Root", "", Vector3.zero);
            Simulation.Manager.Instance.Data.Root = root;

            NEEDSIMNode[] allSmartObjects = GameObject.FindObjectsOfType <NEEDSIM.NEEDSIMNode>();

            //Add Affordance Tree nodes to every NEEDSIM Node that was found.
            for (int i = 0; i < allSmartObjects.Length; i++)
            {
                AddNEEDSIMNode(allSmartObjects[i]);
            }
        }