Exemple #1
0
    //public void Init(AnimationAnalyzer analyzer, FootstepPlanningTest planner,
    public void Init(AnimationAnalyzer analyzer, Planner planner,
                     AnimationEngine animEngine, CollisionReaction collisionReact,
                     NavMeshWayPoints navMeshWaypoints, SteeringManager steering,
                     NeighbourAgents agents, NeighbourObstacles obstacles,
                     PlaceFootSteps steps)
    {
        planning = planner;
        if (planning != null && !planning.initialized)
        {
            planning.Init(analyzer, agents, obstacles);
        }

        engine = animEngine;
        if (engine != null && !engine.initialized)
        {
            engine.Init(analyzer, planning, agents, obstacles);
        }

        collision = collisionReact;
        if (collision != null && !collision.initialized)
        {
            collision.Init(analyzer, planner, engine, agents, obstacles);
        }

        waypoints = navMeshWaypoints;
        //if (waypoints != null && !waypoints.initialized)
        //	waypoints.Init(planning,steering,analyzer,agents,obstacles);

        neighborhood = agents;
        if (neighborhood != null && !neighborhood.initialized)
        {
            neighborhood.Init();
        }

        footsteps = steps;
        if (footsteps != null && !footsteps.initiated)
        {
            footsteps.Init(analyzer, planner, engine, neighborhood, obstacles);
        }

        nObstacles = obstacles;
        if (nObstacles != null && !nObstacles.initialized)
        {
            nObstacles.Init();
        }

        timeSinceLastPlan      = 0;
        timeSinceLastWaypoints = 0;

        previousGoalPosition        = planning.goalStateTransform.position;
        previousCurrentGoalPosition = planning.currentGoal;

        previousActionsSinceLastPlan = -1;

        newWaypoint = false;

        initialized = true;
    }
Exemple #2
0
    //public void Init(AnimationAnalyzer analyzer, FootstepPlanningTest planner,
    public void Init(AnimationAnalyzer analyzer, Planner planner, 
	                 AnimationEngine animEngine, CollisionReaction collisionReact, 
	                 NavMeshWayPoints navMeshWaypoints, SteeringManager steering,
	                 NeighbourAgents agents, NeighbourObstacles obstacles,
	                 PlaceFootSteps steps)
    {
        planning = planner;
        if (planning != null && !planning.initialized)
            planning.Init(analyzer,agents,obstacles);

        engine = animEngine;
        if (engine != null && !engine.initialized)
            engine.Init(analyzer,planning,agents,obstacles);

        collision = collisionReact;
        if (collision != null && !collision.initialized)
            collision.Init(analyzer,planner,engine,agents,obstacles);

        waypoints = navMeshWaypoints;
        //if (waypoints != null && !waypoints.initialized)
        //	waypoints.Init(planning,steering,analyzer,agents,obstacles);

        neighborhood = agents;
        if (neighborhood != null && !neighborhood.initialized)
            neighborhood.Init();

        footsteps = steps;
        if (footsteps != null && !footsteps.initiated)
            footsteps.Init(analyzer,planner,engine,neighborhood,obstacles);

        nObstacles = obstacles;
        if (nObstacles != null && !nObstacles.initialized)
            nObstacles.Init();

        timeSinceLastPlan = 0;
        timeSinceLastWaypoints = 0;

        previousGoalPosition = planning.goalStateTransform.position;
        previousCurrentGoalPosition = planning.currentGoal;

        previousActionsSinceLastPlan = -1;

        newWaypoint = false;

        initialized = true;
    }
Exemple #3
0
    // Use this for initialization
    void InitAgent(int i)
    {
        AnimationAnalyzer analyzer = null;

        // Initialize different components of the agents
        // ( Animation Engine, Planner, Neighbors, ...)
        //foreach (GameObject agent in agents)
        //for(int i = 0; i < agents.Length; i++)
        {
            GameObject agent = agents[i];

            //agent.active = true;

            agent.transform.position = agentsPos[i];

            //if (analyzer == null)
            {
                analyzer = agent.GetComponent("AnimationAnalyzer") as AnimationAnalyzer;
                if (analyzer != null)
                {
                    analyzer.Init();

                    //analyzer.ReadAnalysisFromFile(animationsFileName);
                }
            }

            /*
             * else
             * {
             *      Vector3 startPos = agent.transform.position;
             *      Quaternion startRot = agent.transform.rotation;
             *      analyzer.RemoveAnimations(agent.animation);
             *      agent.transform.position = startPos;
             *      agent.transform.rotation = startRot;
             * }
             */

            NeighbourAgents neighbourAgents = agent.GetComponent("NeighbourAgents") as NeighbourAgents;
            //if (neighbourAgents != null)
            //	neighbourAgents.Init();

            NeighbourObstacles neighbourObstacles = agent.GetComponent("NeighbourObstacles") as NeighbourObstacles;
            //if (neighbourObstacles != null)
            //	neighbourObstacles.Init();

            Planner planning;
            if (ADAFootstepTest.ADA_PLANNER_IN_USE)
            {
                ADAFootstepTest ADAplanning = agent.GetComponent("ADAFootstepTest") as ADAFootstepTest;
                planning = ADAplanning as Planner;
            }
            else
            {
                FootstepPlanningTest FPTplanning = agent.GetComponent("FootstepPlanningTest") as FootstepPlanningTest;
                planning = FPTplanning as Planner;
            }
            if (planning != null)
            {
                planning.Init(analyzer, neighbourAgents, neighbourObstacles);
            }

            AnimationEngine engine = agent.GetComponent("AnimationEngine") as AnimationEngine;
            if (engine != null)
            {
                engine.Init(analyzer, planning, neighbourAgents, neighbourObstacles);
            }

            CollisionReaction collider = agent.GetComponent("CollisionReaction") as CollisionReaction;
            if (collider != null)
            {
                collider.Init(analyzer, planning, engine, neighbourAgents, neighbourObstacles);
            }

            NavMeshWayPoints waypoints = agent.GetComponent("NavMeshWayPoints") as NavMeshWayPoints;
            if (waypoints != null)
            {
                waypoints.Init(planning, steering, analyzer, neighbourAgents, neighbourObstacles);
            }

            PlaceFootSteps footsteps = agent.GetComponent("PlaceFootSteps") as PlaceFootSteps;
            if (footsteps != null)
            {
                footsteps.Init(analyzer, planning, engine, neighbourAgents, neighbourObstacles);
            }

            EventsMonitor events = agent.GetComponent("EventsMonitor") as EventsMonitor;
            if (events != null)
            {
                events.Init(analyzer, planning, engine, collider, waypoints, steering, neighbourAgents, neighbourObstacles, footsteps);

                events.enabled = false;
            }

            DebugScript debug = agent.GetComponent("DebugScript") as DebugScript;
            if (debug != null)
            {
                debug.Init(analyzer, engine, planning, neighbourAgents, neighbourObstacles, collider);
            }

            if (analyzer != null)
            {
                analyzer.RemoveAnimations(agent.animation);
            }
        }
    }