Exemple #1
0
    // Use this for initialization
    public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

        storedPlan = new List <FootstepPlanningAction>();

        outputPlan = new Stack <DefaultAction>();

        domainList = new List <PlanningDomainBase>();
        domainList.Add(new FootstepPlanningDomain(analyzer, neighborhood, obstacles));

        planner = new ADAstarPlanner();

        planner.init(ref domainList, MaxNumberOfNodes);

        initialized = true;

        currentState = null;

        isPlanComputed = false;

        planChanged = false;

        goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer;


        currentGoal = goalStateTransform.position;
    }
Exemple #2
0
    //public void Init (AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, FootstepPlanningTest planner,
    public void Init(AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, Planner planner,
                     NeighbourAgents agents, NeighbourObstacles obstacles, CollisionReaction colReact)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

        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 = colReact;
        if (collision != null && !collision.initialized)
        {
            collision.Init(analyzer, planning, engine, agents, obstacles);
        }

        if (debugText != null)
        {
            debugText.gameObject.active = false;
        }

        initialized = true;
    }
Exemple #3
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, RootMotionComputer computer, NeighbourAgents agents, NeighbourObstacles obstacles){
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

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

        foreach (AnimationState state in animation)
        {
            state.enabled  = true;
            state.speed    = 1.0f;
            state.wrapMode = WrapMode.Loop;
            state.weight   = 0;
        }

        currentAnimation = null;
        action           = null;

        animation.Stop();

        initialized = true;

        actionNum = 0;

        changed = false;

        errorT = new Vector3(0, 0, 0);
        errorR = 0;

        currentBlendingTime  = 0;
        currentActionTime    = 0;
        previousBlendingTime = 0;
        currentActionEndTime = 0;

        actionsSinceLastPlan = 0;

        insertedAction = false;

        initGameObjectPos  = transform.position;
        initGameObjectRotY = transform.eulerAngles.y;

        initLocalRootPos = root.localPosition;

        lastRootPos = root.position;
        lastRootRot = root.rotation;
    }
    // Use this for initialization
    public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

        storedPlan = new List <FootstepPlanningAction>();

        outputPlan = new Stack <DefaultAction>();

        domainList = new List <PlanningDomainBase>();

        gpd = new GridPlanningDomain(analyzer);
        //gtd = new GridTimeDomain(analyzer, obstacles);
        gtd = new GridTimeDomain(obstacles, neighborhood);
        fpd = new FootstepPlanningDomain(analyzer, neighborhood, obstacles);

        if (useGridDomain)
        {
            domainList.Add(gpd);
            //domainList.Add(gpd);
        }
        if (useGridTimeDomain)
        {
            domainList.Add(gtd);
            //domainList.Add(gtd);
        }
        if (useFootstepDomain)
        {
            domainList.Add(fpd);
            //domainList.Add(fpd);
        }

        planner = new BestFirstSearchPlanner();

        planner.init(ref domainList, MaxNumberOfNodes);

        initialized = true;

        currentState = null;

        isPlanComputed = false;

        planChanged = false;

        goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer;

        currentGoal = goalStateTransform.position;

        goalReached = false;
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        //AnimationAnalyzer analyzer = agent.GetComponent("AnimationAnalyzer") as AnimationAnalyzer;

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

            animationNames = analyzer.animationNames;
        }

        currentAnimationIndex = 0;
    }
Exemple #6
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine,
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine,
                     NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

        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);
        }

        if (rightFoot.position[1] < leftFoot.position[1])
        {
            auxHeight = rightFoot.position[1];
        }
        else
        {
            auxHeight = leftFoot.position[1];
        }

        counter = 0;

        footSteps = new Object[numberOfFootSteps];

        initiated = true;
    }
Exemple #7
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles)
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
        {
            analyzer.Init();
        }

        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);
        }

        reacting = false;

        initialized = true;
    }
Exemple #8
0
    //public void Init (AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, FootstepPlanningTest planner,
    public void Init(AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, Planner planner,
	                  NeighbourAgents agents, NeighbourObstacles obstacles, CollisionReaction colReact)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

        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 = colReact;
        if (collision != null && !collision.initialized)
            collision.Init(analyzer,planning,engine,agents,obstacles);

        if (debugText != null)
            debugText.gameObject.active = false;

        initialized = true;
    }
Exemple #9
0
    // Use this for initialization
    public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

        storedPlan = new List<FootstepPlanningAction>();

        outputPlan = new Stack<DefaultAction>();

        domainList = new List<PlanningDomainBase>();
        domainList.Add(new FootstepPlanningDomain(analyzer, neighborhood, obstacles));

        planner = new ADAstarPlanner();

        planner.init(ref domainList, MaxNumberOfNodes);

        initialized = true;

        currentState = null;

        isPlanComputed = false;

        planChanged = false;

        goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer;

        currentGoal = goalStateTransform.position;
    }
Exemple #10
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles)
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine,NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

        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);

        reacting = false;

        initialized = true;
    }
    // Use this for initialization
    public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

        storedPlan = new List<FootstepPlanningAction>();

        outputPlan = new Stack<DefaultAction>();

        domainList = new List<PlanningDomainBase>();

        gpd = new GridPlanningDomain(analyzer);
        //gtd = new GridTimeDomain(analyzer, obstacles);
        gtd = new GridTimeDomain(obstacles,neighborhood);
        fpd = new FootstepPlanningDomain(analyzer, neighborhood, obstacles);

        if (useGridDomain)
        {
            domainList.Add(gpd);
            //domainList.Add(gpd);
        }
        if (useGridTimeDomain)
        {
            domainList.Add(gtd);
            //domainList.Add(gtd);
        }
        if (useFootstepDomain)
        {
            domainList.Add(fpd);
            //domainList.Add(fpd);
        }

        planner = new BestFirstSearchPlanner();

        planner.init(ref domainList, MaxNumberOfNodes);

        initialized = true;

        currentState = null;

        isPlanComputed = false;

        planChanged = false;

        goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer;

        currentGoal = goalStateTransform.position;

        goalReached = false;
    }
Exemple #12
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine,
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine,
	                 NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

        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);

        if (rightFoot.position[1] < leftFoot.position[1])
            auxHeight = rightFoot.position[1];
        else
            auxHeight = leftFoot.position[1];

        counter = 0;

        footSteps = new Object[numberOfFootSteps];

        initiated = true;
    }
Exemple #13
0
    //public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, RootMotionComputer computer, NeighbourAgents agents, NeighbourObstacles obstacles){
    public void Init(AnimationAnalyzer animAnalyzer, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles)
    {
        analyzer = animAnalyzer;
        if (analyzer != null && !analyzer.initialized)
            analyzer.Init();

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

        foreach (AnimationState state in animation)
        {
            state.enabled = true;
            state.speed = 1.0f;
            state.wrapMode = WrapMode.Loop;
            state.weight = 0;
        }

        currentAnimation = null;
        action = null;

        animation.Stop();

        initialized = true;

        actionNum = 0;

        changed = false;

        errorT = new Vector3(0,0,0);
        errorR = 0;

        currentBlendingTime = 0;
        currentActionTime = 0;
        previousBlendingTime = 0;
        currentActionEndTime = 0;

        actionsSinceLastPlan = 0;

        insertedAction = false;

        initGameObjectPos = transform.position;
        initGameObjectRotY = transform.eulerAngles.y;

        initLocalRootPos = root.localPosition;

        lastRootPos = root.position;
        lastRootRot = root.rotation;
    }
Exemple #14
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);
            }
        }
    }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        //AnimationAnalyzer analyzer = agent.GetComponent("AnimationAnalyzer") as AnimationAnalyzer;

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

            animationNames = analyzer.animationNames;
        }

        currentAnimationIndex = 0;
    }