20 MonkeyBrainsDemo_SteeringBehaviors/nbproject/project.properties
... ...
@@ -1,7 +1,11 @@
1  
-application.title=MyGame
2  
-application.vendor=MyCompany
  1
+annotation.processing.enabled=true
  2
+annotation.processing.enabled.in.editor=false
  3
+annotation.processing.processors.list=
  4
+annotation.processing.run.all.processors=true
  5
+application.title=Steer Demos
  6
+application.vendor=Jes\u00fas Mart\u00edn Berlanga
3 7
 assets.jar.name=assets.jar
4  
-assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh\.xml,**/*.skeleton\.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9]
  8
+assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh.xml,**/*.skeleton.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9]
5 9
 assets.folder.name=assets
6 10
 assets.compress=true
7 11
 build.classes.dir=${build.dir}/classes
@@ -36,6 +40,8 @@ javac.classpath=\
36 40
 # Space-separated list of extra javac options
37 41
 javac.compilerargs=
38 42
 javac.deprecation=false
  43
+javac.processorpath=\
  44
+    ${javac.classpath}
39 45
 javac.source=1.5
40 46
 javac.target=1.5
41 47
 javac.test.classpath=\
@@ -58,12 +64,14 @@ jnlp.descriptor=application
58 64
 jnlp.enabled=false
59 65
 jnlp.offline-allowed=false
60 66
 jnlp.signed=false
61  
-main.class=mygame.Main
  67
+main.class=steeringDemos.demos.DemosLauncher
62 68
 meta.inf.dir=${src.dir}/META-INF
63 69
 manifest.file=MANIFEST.MF
  70
+mkdist.disabled=false
  71
+obfuscate.options=-keep public class * extends com.jme3.app.Application{public *;}\n-keep public class * extends com.jme3.system.JmeSystemDelegate{public *;}\n-keep public class * implements com.jme3.renderer.Renderer{public *;}\n-keep public class * implements com.jme3.asset.AssetLoader{public *;}\n-keep public class * implements com.jme3.asset.AssetLocator{public *;}\n-keep public class * implements de.lessvoid.nifty.screen.ScreenController{public *;}\n-dontwarn\n-dontnote\n
64 72
 platform.active=default_platform
65  
-project.AgentFramework=../JMEAI
66  
-reference.AgentFramework.jar=${project.AgentFramework}/dist/MyGame.jar
  73
+project.AgentFramework=../../JMEAI
  74
+reference.AgentFramework.jar=${project.AgentFramework}/dist/MonkeyBrains.jar
67 75
 run.classpath=\
68 76
     ${javac.classpath}:\
69 77
     ${build.classes.dir}:\
150 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/AlignmentDemo.java
... ...
@@ -0,0 +1,150 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.AlignmentBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  18
+import com.jme3.math.FastMath;
  19
+import java.util.ArrayList;
  20
+
  21
+import steeringDemos.control.CustomSteerControl;
  22
+
  23
+import java.util.List;
  24
+import java.util.Arrays;
  25
+
  26
+/**
  27
+ * AI Steer Test - Testing the cohesion behaviour
  28
+ *
  29
+ * @author Jesús Martín Berlanga
  30
+ * @version 1.0
  31
+ */
  32
+public class AlignmentDemo extends SimpleApplication {
  33
+
  34
+    private Game game = Game.getInstance(); //creating game
  35
+    //TEST SETTINGS - START
  36
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  37
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  38
+
  39
+    private final int NUMBER_NEIGHBOURS = 250;
  40
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  41
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  42
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  43
+    private final float NEIGHBOURS_MASS = 50;
  44
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  45
+    //TEST SETTINGS - END
  46
+
  47
+    public static void main(String[] args) {
  48
+        AlignmentDemo app = new AlignmentDemo();
  49
+        app.start();
  50
+    }
  51
+
  52
+    @Override
  53
+    public void simpleInitApp() {
  54
+        //defining rootNode for game processing
  55
+        game.setRootNode(rootNode);
  56
+
  57
+        game.setInputManager(inputManager);
  58
+        game.setGameControl(new CustomSteerControl(50f));
  59
+        game.getGameControl().loadInputManagerMapping();
  60
+
  61
+        this.setupCamera();
  62
+
  63
+        Vector3f[] spawnArea = null;
  64
+
  65
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  66
+
  67
+        
  68
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  69
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  70
+            boids[i].setRadius(0.1f);
  71
+            game.addAgent(boids[i]); //Add the neighbours to the game
  72
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  73
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  74
+                    this.NEIGHBOURS_MAX_FORCE);
  75
+            game.getGameControl().spawn(boids[i], spawnArea);
  76
+        }
  77
+
  78
+        List<Agent> obstacles = new ArrayList<Agent>();
  79
+        obstacles.addAll(Arrays.asList(boids));
  80
+
  81
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  82
+
  83
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  84
+        AlignmentBehaviour[] alignment = new AlignmentBehaviour[boids.length];
  85
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  86
+
  87
+        for (int i = 0; i < boids.length; i++) {
  88
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  89
+
  90
+
  91
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  92
+            alignment[i] = new AlignmentBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  93
+            wander[i] = new WanderBehaviour(boids[i]);
  94
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  95
+
  96
+            separation[i].setupStrengthControl(0.85f);
  97
+            alignment[i].setupStrengthControl(2.15f);
  98
+            wander[i].setupStrengthControl(0.35f);
  99
+            
  100
+
  101
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  102
+
  103
+           steer.addSteerBehaviour(alignment[i]);
  104
+           steer.addSteerBehaviour(separation[i]);
  105
+           steer.addSteerBehaviour(wander[i]);
  106
+           neighboursMainBehaviour[i].addBehaviour(steer);
  107
+            
  108
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  109
+             
  110
+        }
  111
+
  112
+        game.start();
  113
+    }
  114
+
  115
+    private void setupCamera() {
  116
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  117
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  118
+        getFlyByCamera().setMoveSpeed(50);
  119
+
  120
+        flyCam.setDragToRotate(true);
  121
+        //flyCam.setEnabled(false);  
  122
+    }
  123
+
  124
+    //Create an agent with a name and a color
  125
+    private Agent createBoid(String name, ColorRGBA color) {
  126
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  127
+        boidSpatial.setLocalScale(0.1f); //Resize
  128
+
  129
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  130
+        mat.setColor("Color", color);
  131
+        boidSpatial.setMaterial(mat);
  132
+
  133
+        return new Agent(name, boidSpatial);
  134
+    }
  135
+
  136
+    //Setup the stats for an agent
  137
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  138
+            float mass, float maxForce) {
  139
+
  140
+        myAgent.setMoveSpeed(moveSpeed);
  141
+        myAgent.setRotationSpeed(rotationSpeed);
  142
+        myAgent.setMass(mass);
  143
+        myAgent.setMaxForce(maxForce);
  144
+    }
  145
+
  146
+    @Override
  147
+    public void simpleUpdate(float tpf) {
  148
+        game.update(tpf);
  149
+    }
  150
+}
182 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/ArriveDemo.java
... ...
@@ -0,0 +1,182 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  7
+import com.jme3.ai.agents.behaviours.npc.steering.ArriveBehaviour;
  8
+import com.jme3.ai.agents.util.control.Game;
  9
+import com.jme3.app.SimpleApplication;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.math.ColorRGBA;
  12
+import com.jme3.math.Vector3f;
  13
+import com.jme3.scene.Geometry;
  14
+import com.jme3.scene.Spatial;
  15
+import com.jme3.scene.shape.Sphere;
  16
+import steeringDemos.control.CustomSteerControl;
  17
+
  18
+/**
  19
+ * Demo for ArriveBehaviour
  20
+ *
  21
+ * @author Jesús Martín Berlanga
  22
+ */
  23
+public class ArriveDemo extends SimpleApplication {
  24
+    
  25
+    private Game game = Game.getInstance(); //creating game
  26
+    //TEST SETTINGS - START
  27
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  28
+    private final String MATERIAL_1 = "Common/MatDefs/Misc/Unshaded.j3md";
  29
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  30
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  31
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  32
+    private final float NEIGHBOURS_MASS = 50;
  33
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  34
+    //TEST SETTINGS - END
  35
+    private Agent[] agents = new Agent[3];
  36
+    private Agent target;
  37
+    private ArriveBehaviour[] arrive;
  38
+    private int[] upadtes = new int[3];
  39
+    
  40
+    public static void main(String[] args) {
  41
+        ArriveDemo app = new ArriveDemo();
  42
+        app.start();
  43
+    }
  44
+    
  45
+    @Override
  46
+    public void simpleInitApp() {
  47
+        game.setRootNode(rootNode);
  48
+        game.setInputManager(inputManager);
  49
+        game.setGameControl(new CustomSteerControl(50f));
  50
+        game.getGameControl().loadInputManagerMapping();
  51
+        this.setupCamera();
  52
+        
  53
+        this.target = this.createSphere("target", ColorRGBA.Red);
  54
+        game.addAgent(target);
  55
+        game.getGameControl().spawn(target, new Vector3f());
  56
+        
  57
+        for (int i = 0; i < this.agents.length; i++) {
  58
+            agents[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  59
+            agents[i].setRadius(0.1f);
  60
+            game.addAgent(agents[i]); //Add the neighbours to the game
  61
+            this.setStats(agents[i], this.NEIGHBOURS_MOVE_SPEED,
  62
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  63
+                    this.NEIGHBOURS_MAX_FORCE);
  64
+        }
  65
+        
  66
+        game.getGameControl().spawn(agents[0], new Vector3f(-10, 0, 0));
  67
+        game.getGameControl().spawn(agents[1], new Vector3f(8, 0, 0));
  68
+        game.getGameControl().spawn(agents[2], new Vector3f(0, 13, 2));
  69
+        
  70
+        arrive = new ArriveBehaviour[3];
  71
+        
  72
+        SimpleMainBehaviour main0 = new SimpleMainBehaviour(agents[0]);
  73
+        SimpleMainBehaviour main1 = new SimpleMainBehaviour(agents[1]);
  74
+        SimpleMainBehaviour main2 = new SimpleMainBehaviour(agents[2]);
  75
+        
  76
+        arrive[0] = new ArriveBehaviour(agents[0], target, 5f, 0.0035f);
  77
+        arrive[1] = new ArriveBehaviour(agents[1], target, 3f, 0.01f);
  78
+        arrive[2] = new ArriveBehaviour(agents[2], target);
  79
+        arrive[2].getSlow().setUnitIncrementSlow(0.0085f);
  80
+        
  81
+        main0.addBehaviour(arrive[0]);
  82
+        main1.addBehaviour(arrive[1]);
  83
+        main2.addBehaviour(arrive[2]);
  84
+        
  85
+        agents[0].setMainBehaviour(main0);
  86
+        agents[1].setMainBehaviour(main1);
  87
+        agents[2].setMainBehaviour(main2);
  88
+        
  89
+        SimpleMainBehaviour targetMain = new SimpleMainBehaviour(target);
  90
+        target.setMainBehaviour(targetMain);
  91
+        
  92
+        game.start();
  93
+    }
  94
+    
  95
+    private void setupCamera() {
  96
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  97
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  98
+        getFlyByCamera().setMoveSpeed(50);
  99
+        
  100
+        flyCam.setDragToRotate(true);
  101
+        //flyCam.setEnabled(false);
  102
+    }
  103
+    
  104
+    //Create an agent with a name and a color
  105
+    private Agent createBoid(String name, ColorRGBA color) {
  106
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  107
+        boidSpatial.setLocalScale(0.1f); //Resize
  108
+        
  109
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  110
+        mat.setColor("Color", color);
  111
+        boidSpatial.setMaterial(mat);
  112
+        
  113
+        return new Agent(name, boidSpatial);
  114
+    }
  115
+    
  116
+    //Create a sphere
  117
+    private Agent createSphere(String name, ColorRGBA color) {
  118
+        Sphere sphere = new Sphere(10, 10, 0.25f);
  119
+        Geometry sphereG = new Geometry("Sphere Geometry", sphere);
  120
+        Spatial spatial = sphereG;
  121
+        
  122
+        spatial.setLocalScale(0.1f); //Resize0
  123
+        
  124
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  125
+        mat.setColor("Color", color);
  126
+        spatial.setMaterial(mat);
  127
+        
  128
+        return new Agent(name, spatial);
  129
+    }
  130
+    
  131
+    //Setup the stats for an agent
  132
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  133
+            float mass, float maxForce) {
  134
+        
  135
+        myAgent.setMoveSpeed(moveSpeed);
  136
+        myAgent.setRotationSpeed(rotationSpeed);
  137
+        myAgent.setMass(mass);
  138
+        myAgent.setMaxForce(maxForce);
  139
+    }
  140
+    
  141
+    @Override
  142
+    public void simpleUpdate(float tpf) {
  143
+        game.update(tpf);
  144
+        
  145
+        for(int i = 0; i < this.arrive.length; i++)
  146
+        {
  147
+            if(this.arrive[i].getFreezeTheMovement() == true)
  148
+            {
  149
+                if( this.upadtes[i] > 60)
  150
+                {
  151
+                    Vector3f resetPosition;
  152
+                    
  153
+                    switch(i)
  154
+                    {
  155
+                        case 0:
  156
+                            resetPosition = new Vector3f(-10, 0, 0);
  157
+                            break;
  158
+                            
  159
+                        case 1:
  160
+                            resetPosition = new Vector3f(8, 0, 0);
  161
+                            break;
  162
+                            
  163
+                        case 2:
  164
+                            resetPosition = new Vector3f(0, 13, 2);
  165
+                            break;
  166
+                            
  167
+                        default:
  168
+                            resetPosition = new Vector3f();
  169
+                    }
  170
+                    
  171
+                    this.agents[i].setLocalTranslation(resetPosition);
  172
+                    
  173
+                    this.arrive[i].getSlow().resetSlow();
  174
+                    this.arrive[i].setFreezeTheMovement(false);
  175
+                    this.upadtes[i] = 0;
  176
+                }
  177
+                else
  178
+                    this.upadtes[i]++;
  179
+            }
  180
+        }
  181
+    }
  182
+}
155 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/CohesionAndAlignmentDemo.java
... ...
@@ -0,0 +1,155 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.AlignmentBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CohesionBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  18
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  19
+import com.jme3.math.FastMath;
  20
+import java.util.ArrayList;
  21
+
  22
+import steeringDemos.control.CustomSteerControl;
  23
+
  24
+import java.util.List;
  25
+import java.util.Arrays;
  26
+
  27
+/**
  28
+ * AI Steer Test - Testing the cohesion and the alignment behaviours
  29
+ *
  30
+ * @author Jesús Martín Berlanga
  31
+ * @version 1.0
  32
+ */
  33
+public class CohesionAndAlignmentDemo extends SimpleApplication {
  34
+
  35
+    private Game game = Game.getInstance(); //creating game
  36
+    //TEST SETTINGS - START
  37
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  38
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  39
+
  40
+    private final int NUMBER_NEIGHBOURS = 250;
  41
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  42
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  43
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  44
+    private final float NEIGHBOURS_MASS = 50;
  45
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  46
+    //TEST SETTINGS - END
  47
+
  48
+    public static void main(String[] args) {
  49
+        CohesionAndAlignmentDemo app = new CohesionAndAlignmentDemo();
  50
+        app.start();
  51
+    }
  52
+
  53
+    @Override
  54
+    public void simpleInitApp() {
  55
+        //defining rootNode for game processing
  56
+        game.setRootNode(rootNode);
  57
+
  58
+        game.setInputManager(inputManager);
  59
+        game.setGameControl(new CustomSteerControl(50f));
  60
+        game.getGameControl().loadInputManagerMapping();
  61
+
  62
+        this.setupCamera();
  63
+
  64
+        Vector3f[] spawnArea = null;
  65
+
  66
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  67
+
  68
+        
  69
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  70
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  71
+            boids[i].setRadius(0.1f);
  72
+            game.addAgent(boids[i]); //Add the neighbours to the game
  73
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  74
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  75
+                    this.NEIGHBOURS_MAX_FORCE);
  76
+            game.getGameControl().spawn(boids[i], spawnArea);
  77
+        }
  78
+
  79
+        List<Agent> obstacles = new ArrayList<Agent>();
  80
+        obstacles.addAll(Arrays.asList(boids));
  81
+
  82
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  83
+
  84
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  85
+        CohesionBehaviour[] cohesion = new CohesionBehaviour[boids.length];
  86
+        AlignmentBehaviour[] alignment = new AlignmentBehaviour[boids.length];
  87
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  88
+
  89
+        for (int i = 0; i < boids.length; i++) {
  90
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  91
+
  92
+
  93
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  94
+            cohesion[i] = new CohesionBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  95
+            alignment[i] = new AlignmentBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4.2f);
  96
+            wander[i] = new WanderBehaviour(boids[i]);
  97
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  98
+
  99
+            separation[i].setupStrengthControl(0.85f);
  100
+            cohesion[i].setupStrengthControl(2.15f);
  101
+            alignment[i].setupStrengthControl(0.25f);
  102
+            wander[i].setupStrengthControl(0.35f);
  103
+            
  104
+
  105
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  106
+
  107
+           steer.addSteerBehaviour(cohesion[i]);
  108
+           steer.addSteerBehaviour(alignment[i]);
  109
+           steer.addSteerBehaviour(separation[i]);
  110
+           steer.addSteerBehaviour(wander[i]);
  111
+           neighboursMainBehaviour[i].addBehaviour(steer);
  112
+            
  113
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  114
+             
  115
+        }
  116
+
  117
+        game.start();
  118
+    }
  119
+
  120
+    private void setupCamera() {
  121
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  122
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  123
+        getFlyByCamera().setMoveSpeed(50);
  124
+
  125
+        flyCam.setDragToRotate(true);
  126
+        //flyCam.setEnabled(false);  
  127
+    }
  128
+
  129
+    //Create an agent with a name and a color
  130
+    private Agent createBoid(String name, ColorRGBA color) {
  131
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  132
+        boidSpatial.setLocalScale(0.1f); //Resize
  133
+
  134
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  135
+        mat.setColor("Color", color);
  136
+        boidSpatial.setMaterial(mat);
  137
+
  138
+        return new Agent(name, boidSpatial);
  139
+    }
  140
+
  141
+    //Setup the stats for an agent
  142
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  143
+            float mass, float maxForce) {
  144
+
  145
+        myAgent.setMoveSpeed(moveSpeed);
  146
+        myAgent.setRotationSpeed(rotationSpeed);
  147
+        myAgent.setMass(mass);
  148
+        myAgent.setMaxForce(maxForce);
  149
+    }
  150
+
  151
+    @Override
  152
+    public void simpleUpdate(float tpf) {
  153
+        game.update(tpf);
  154
+    }
  155
+}
150 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/CohesionDemo.java
... ...
@@ -0,0 +1,150 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.CohesionBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  18
+import com.jme3.math.FastMath;
  19
+import java.util.ArrayList;
  20
+
  21
+import steeringDemos.control.CustomSteerControl;
  22
+
  23
+import java.util.List;
  24
+import java.util.Arrays;
  25
+
  26
+/**
  27
+ * AI Steer Test - Testing the cohesion behaviour
  28
+ *
  29
+ * @author Jesús Martín Berlanga
  30
+ * @version 1.0
  31
+ */
  32
+public class CohesionDemo extends SimpleApplication {
  33
+
  34
+    private Game game = Game.getInstance(); //creating game
  35
+    //TEST SETTINGS - START
  36
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  37
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  38
+
  39
+    private final int NUMBER_NEIGHBOURS = 250;
  40
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  41
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  42
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  43
+    private final float NEIGHBOURS_MASS = 50;
  44
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  45
+    //TEST SETTINGS - END
  46
+
  47
+    public static void main(String[] args) {
  48
+        CohesionDemo app = new CohesionDemo();
  49
+        app.start();
  50
+    }
  51
+
  52
+    @Override
  53
+    public void simpleInitApp() {
  54
+        //defining rootNode for game processing
  55
+        game.setRootNode(rootNode);
  56
+
  57
+        game.setInputManager(inputManager);
  58
+        game.setGameControl(new CustomSteerControl(50f));
  59
+        game.getGameControl().loadInputManagerMapping();
  60
+
  61
+        this.setupCamera();
  62
+
  63
+        Vector3f[] spawnArea = null;
  64
+
  65
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  66
+
  67
+        
  68
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  69
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  70
+            boids[i].setRadius(0.1f);
  71
+            game.addAgent(boids[i]); //Add the neighbours to the game
  72
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  73
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  74
+                    this.NEIGHBOURS_MAX_FORCE);
  75
+            game.getGameControl().spawn(boids[i], spawnArea);
  76
+        }
  77
+
  78
+        List<Agent> obstacles = new ArrayList<Agent>();
  79
+        obstacles.addAll(Arrays.asList(boids));
  80
+
  81
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  82
+
  83
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  84
+        CohesionBehaviour[] cohesion = new CohesionBehaviour[boids.length];
  85
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  86
+
  87
+        for (int i = 0; i < boids.length; i++) {
  88
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  89
+
  90
+
  91
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  92
+            cohesion[i] = new CohesionBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  93
+            wander[i] = new WanderBehaviour(boids[i]);
  94
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  95
+
  96
+            separation[i].setupStrengthControl(0.85f);
  97
+            cohesion[i].setupStrengthControl(2.15f);
  98
+            wander[i].setupStrengthControl(0.35f);
  99
+            
  100
+
  101
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  102
+
  103
+           steer.addSteerBehaviour(cohesion[i]);
  104
+           steer.addSteerBehaviour(separation[i]);
  105
+           steer.addSteerBehaviour(wander[i]);
  106
+           neighboursMainBehaviour[i].addBehaviour(steer);
  107
+            
  108
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  109
+             
  110
+        }
  111
+
  112
+        game.start();
  113
+    }
  114
+
  115
+    private void setupCamera() {
  116
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  117
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  118
+        getFlyByCamera().setMoveSpeed(50);
  119
+
  120
+        flyCam.setDragToRotate(true);
  121
+        //flyCam.setEnabled(false);  
  122
+    }
  123
+
  124
+    //Create an agent with a name and a color
  125
+    private Agent createBoid(String name, ColorRGBA color) {
  126
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  127
+        boidSpatial.setLocalScale(0.1f); //Resize
  128
+
  129
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  130
+        mat.setColor("Color", color);
  131
+        boidSpatial.setMaterial(mat);
  132
+
  133
+        return new Agent(name, boidSpatial);
  134
+    }
  135
+
  136
+    //Setup the stats for an agent
  137
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  138
+            float mass, float maxForce) {
  139
+
  140
+        myAgent.setMoveSpeed(moveSpeed);
  141
+        myAgent.setRotationSpeed(rotationSpeed);
  142
+        myAgent.setMass(mass);
  143
+        myAgent.setMaxForce(maxForce);
  144
+    }
  145
+
  146
+    @Override
  147
+    public void simpleUpdate(float tpf) {
  148
+        game.update(tpf);
  149
+    }
  150
+}
141 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/DemosLauncher.form
... ...
@@ -0,0 +1,141 @@
  1
+<?xml version="1.0" encoding="UTF-8" ?>
  2
+
  3
+<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
  4
+  <Properties>
  5
+    <Property name="defaultCloseOperation" type="int" value="2"/>
  6
+    <Property name="resizable" type="boolean" value="false"/>
  7
+  </Properties>
  8
+  <SyntheticProperties>
  9
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
  10
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
  11
+  </SyntheticProperties>
  12
+  <AuxValues>
  13
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
  14
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
  15
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
  16
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
  17
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
  18
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
  19
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
  20
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
  21
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
  22
+  </AuxValues>
  23
+
  24
+  <Layout>
  25
+    <DimensionLayout dim="0">
  26
+      <Group type="103" groupAlignment="0" attributes="0">
  27
+          <Group type="102" alignment="0" attributes="0">
  28
+              <EmptySpace max="-2" attributes="0"/>
  29
+              <Component id="jPanel1" max="32767" attributes="0"/>
  30
+              <EmptySpace max="-2" attributes="0"/>
  31
+          </Group>
  32
+      </Group>
  33
+    </DimensionLayout>
  34
+    <DimensionLayout dim="1">
  35
+      <Group type="103" groupAlignment="0" attributes="0">
  36
+          <Group type="102" alignment="0" attributes="0">
  37
+              <EmptySpace max="-2" attributes="0"/>
  38
+              <Component id="jPanel1" max="32767" attributes="0"/>
  39
+              <EmptySpace max="-2" attributes="0"/>
  40
+          </Group>
  41
+      </Group>
  42
+    </DimensionLayout>
  43
+  </Layout>
  44
+  <SubComponents>
  45
+    <Container class="javax.swing.JPanel" name="jPanel1">
  46
+
  47
+      <Layout>
  48
+        <DimensionLayout dim="0">
  49
+          <Group type="103" groupAlignment="0" attributes="0">
  50
+              <Group type="102" attributes="0">
  51
+                  <EmptySpace max="-2" attributes="0"/>
  52
+                  <Group type="103" groupAlignment="0" attributes="0">
  53
+                      <Component id="jButton1" alignment="1" max="32767" attributes="0"/>
  54
+                      <Component id="jButton2" alignment="1" max="32767" attributes="0"/>
  55
+                      <Component id="jButton3" alignment="0" pref="329" max="32767" attributes="0"/>
  56
+                      <Component id="jButton4" alignment="1" max="32767" attributes="0"/>
  57
+                      <Component id="jButton5" alignment="0" max="32767" attributes="0"/>
  58
+                      <Component id="jButton6" alignment="1" max="32767" attributes="0"/>
  59
+                  </Group>
  60
+                  <EmptySpace max="-2" attributes="0"/>
  61
+                  <Component id="jScrollBar1" min="-2" max="-2" attributes="0"/>
  62
+                  <EmptySpace max="-2" attributes="0"/>
  63
+              </Group>
  64
+          </Group>
  65
+        </DimensionLayout>
  66
+        <DimensionLayout dim="1">
  67
+          <Group type="103" groupAlignment="0" attributes="0">
  68
+              <Group type="102" alignment="0" attributes="0">
  69
+                  <EmptySpace max="-2" attributes="0"/>
  70
+                  <Component id="jButton1" min="-2" max="-2" attributes="0"/>
  71
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  72
+                  <Component id="jButton2" min="-2" max="-2" attributes="0"/>
  73
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  74
+                  <Component id="jButton3" min="-2" max="-2" attributes="0"/>
  75
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  76
+                  <Component id="jButton4" min="-2" max="-2" attributes="0"/>
  77
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  78
+                  <Component id="jButton5" min="-2" max="-2" attributes="0"/>
  79
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  80
+                  <Component id="jButton6" min="-2" max="-2" attributes="0"/>
  81
+                  <EmptySpace pref="129" max="32767" attributes="0"/>
  82
+              </Group>
  83
+              <Component id="jScrollBar1" alignment="1" max="32767" attributes="0"/>
  84
+          </Group>
  85
+        </DimensionLayout>
  86
+      </Layout>
  87
+      <SubComponents>
  88
+        <Component class="javax.swing.JButton" name="jButton1">
  89
+          <Properties>
  90
+            <Property name="text" type="java.lang.String" value="Cohesion Demo"/>
  91
+          </Properties>
  92
+          <Events>
  93
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
  94
+          </Events>
  95
+        </Component>
  96
+        <Component class="javax.swing.JButton" name="jButton2">
  97
+          <Properties>
  98
+            <Property name="text" type="java.lang.String" value="Alignment Demo"/>
  99
+          </Properties>
  100
+          <Events>
  101
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
  102
+          </Events>
  103
+        </Component>
  104
+        <Component class="javax.swing.JButton" name="jButton3">
  105
+          <Properties>
  106
+            <Property name="text" type="java.lang.String" value="Cohesion and Alignment Demo"/>
  107
+          </Properties>
  108
+          <Events>
  109
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
  110
+          </Events>
  111
+        </Component>
  112
+        <Component class="javax.swing.JButton" name="jButton4">
  113
+          <Properties>
  114
+            <Property name="text" type="java.lang.String" value="Slow Demo"/>
  115
+          </Properties>
  116
+          <Events>
  117
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
  118
+          </Events>
  119
+        </Component>
  120
+        <Component class="javax.swing.JButton" name="jButton5">
  121
+          <Properties>
  122
+            <Property name="text" type="java.lang.String" value="Arrive Demo"/>
  123
+          </Properties>
  124
+          <Events>
  125
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/>
  126
+          </Events>
  127
+        </Component>
  128
+        <Component class="javax.swing.JButton" name="jButton6">
  129
+          <Properties>
  130
+            <Property name="text" type="java.lang.String" value="Leader Following Demo"/>
  131
+          </Properties>
  132
+          <Events>
  133
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton6ActionPerformed"/>
  134
+          </Events>
  135
+        </Component>
  136
+        <Component class="javax.swing.JScrollBar" name="jScrollBar1">
  137
+        </Component>
  138
+      </SubComponents>
  139
+    </Container>
  140
+  </SubComponents>
  141
+</Form>
273 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/DemosLauncher.java
... ...
@@ -0,0 +1,273 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+/**
  6
+ * Demos laucher
  7
+ * @author Jesús Martín Berlanga
  8
+ */
  9
+public class DemosLauncher extends javax.swing.JFrame {
  10
+
  11
+    private Thread appThread;
  12
+    
  13
+    /**
  14
+     * Creates new form laucherForm
  15
+     */
  16
+    public DemosLauncher() {
  17
+        initComponents();
  18
+    }
  19
+
  20
+    /**
  21
+     * This method is called from within the constructor to initialize the form.
  22
+     * WARNING: Do NOT modify this code. The content of this method is always
  23
+     * regenerated by the Form Editor.
  24
+     */
  25
+    @SuppressWarnings("unchecked")
  26
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  27
+    private void initComponents() {
  28
+
  29
+        jPanel1 = new javax.swing.JPanel();
  30
+        jButton1 = new javax.swing.JButton();
  31
+        jButton2 = new javax.swing.JButton();
  32
+        jButton3 = new javax.swing.JButton();
  33
+        jButton4 = new javax.swing.JButton();
  34
+        jButton5 = new javax.swing.JButton();
  35
+        jButton6 = new javax.swing.JButton();
  36
+        jScrollBar1 = new javax.swing.JScrollBar();
  37
+
  38
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  39
+        setResizable(false);
  40
+
  41
+        jButton1.setText("Cohesion Demo");
  42
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
  43
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  44
+                jButton1ActionPerformed(evt);
  45
+            }
  46
+        });
  47
+
  48
+        jButton2.setText("Alignment Demo");
  49
+        jButton2.addActionListener(new java.awt.event.ActionListener() {
  50
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  51
+                jButton2ActionPerformed(evt);
  52
+            }
  53
+        });
  54
+
  55
+        jButton3.setText("Cohesion and Alignment Demo");
  56
+        jButton3.addActionListener(new java.awt.event.ActionListener() {
  57
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  58
+                jButton3ActionPerformed(evt);
  59
+            }
  60
+        });
  61
+
  62
+        jButton4.setText("Slow Demo");
  63
+        jButton4.addActionListener(new java.awt.event.ActionListener() {
  64
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  65
+                jButton4ActionPerformed(evt);
  66
+            }
  67
+        });
  68
+
  69
+        jButton5.setText("Arrive Demo");
  70
+        jButton5.addActionListener(new java.awt.event.ActionListener() {
  71
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  72
+                jButton5ActionPerformed(evt);
  73
+            }
  74
+        });
  75
+
  76
+        jButton6.setText("Leader Following Demo");
  77
+        jButton6.addActionListener(new java.awt.event.ActionListener() {
  78
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  79
+                jButton6ActionPerformed(evt);
  80
+            }
  81
+        });
  82
+
  83
+        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  84
+        jPanel1.setLayout(jPanel1Layout);
  85
+        jPanel1Layout.setHorizontalGroup(
  86
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  87
+            .addGroup(jPanel1Layout.createSequentialGroup()
  88
+                .addContainerGap()
  89
+                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  90
+                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  91
+                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  92
+                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
  93
+                    .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  94
+                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  95
+                    .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  96
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  97
+                .addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  98
+                .addContainerGap())
  99
+        );
  100
+        jPanel1Layout.setVerticalGroup(
  101
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  102
+            .addGroup(jPanel1Layout.createSequentialGroup()
  103
+                .addContainerGap()
  104
+                .addComponent(jButton1)
  105
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  106
+                .addComponent(jButton2)
  107
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  108
+                .addComponent(jButton3)
  109
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  110
+                .addComponent(jButton4)
  111
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  112
+                .addComponent(jButton5)
  113
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  114
+                .addComponent(jButton6)
  115
+                .addContainerGap(129, Short.MAX_VALUE))
  116
+            .addComponent(jScrollBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  117
+        );
  118
+
  119
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  120
+        getContentPane().setLayout(layout);
  121
+        layout.setHorizontalGroup(
  122
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  123
+            .addGroup(layout.createSequentialGroup()
  124
+                .addContainerGap()
  125
+                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  126
+                .addContainerGap())
  127
+        );
  128
+        layout.setVerticalGroup(
  129
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  130
+            .addGroup(layout.createSequentialGroup()
  131
+                .addContainerGap()
  132
+                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  133
+                .addContainerGap())
  134
+        );
  135
+
  136
+        pack();
  137
+    }// </editor-fold>//GEN-END:initComponents
  138
+
  139
+    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  140
+      
  141
+        this.appThread = new Thread(new Runnable() 
  142
+        {
  143
+            public void run() 
  144
+            {
  145
+            AlignmentDemo.main(null);
  146
+            }
  147
+        });
  148
+        
  149
+        this.appThread.start();
  150
+        
  151
+        this.dispose();
  152
+    }//GEN-LAST:event_jButton2ActionPerformed
  153
+
  154
+    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  155
+       
  156
+        this.appThread = new Thread(new Runnable() 
  157
+        {
  158
+            public void run() 
  159
+            {
  160
+            SlowDemo.main(null);
  161
+            }
  162
+        });
  163
+        
  164
+        this.appThread.start();
  165
+        
  166
+        this.dispose();
  167
+    }//GEN-LAST:event_jButton4ActionPerformed
  168
+
  169
+    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  170
+
  171
+        this.appThread = new Thread(new Runnable() 
  172
+        {
  173
+            public void run() 
  174
+            {
  175
+            CohesionDemo.main(null);
  176
+            }
  177
+        });
  178
+        
  179
+        this.appThread.start();
  180
+        
  181
+        this.dispose();
  182
+    }//GEN-LAST:event_jButton1ActionPerformed
  183
+
  184
+    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  185
+        
  186
+        this.appThread = new Thread(new Runnable() 
  187
+        {
  188
+            public void run() 
  189
+            {
  190
+            CohesionAndAlignmentDemo.main(null);
  191
+            }
  192
+        });
  193
+        
  194
+        this.appThread.start();
  195
+        
  196
+        this.dispose();
  197
+    }//GEN-LAST:event_jButton3ActionPerformed
  198
+
  199
+    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
  200
+        
  201
+        this.appThread = new Thread(new Runnable() 
  202
+        {
  203
+            public void run() 
  204
+            {
  205
+            ArriveDemo.main(null);
  206
+            }
  207
+        });
  208
+        
  209
+        this.appThread.start();
  210
+        
  211
+        this.dispose();
  212
+    }//GEN-LAST:event_jButton5ActionPerformed
  213
+
  214
+    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
  215
+       
  216
+        this.appThread = new Thread(new Runnable() 
  217
+        {
  218
+            public void run() 
  219
+            {
  220
+            LeaderFollowingDemo.main(null);
  221
+            }
  222
+        });
  223
+        
  224
+        this.appThread.start();
  225
+        
  226
+        this.dispose();
  227
+    }//GEN-LAST:event_jButton6ActionPerformed
  228
+
  229
+    /**
  230
+     * @param args the command line arguments
  231
+     */
  232
+    public static void main(String args[]) {
  233
+        /* Set the Nimbus look and feel */
  234
+        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  235
+        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  236
+         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
  237
+         */
  238
+        try {
  239
+            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  240
+                if ("Nimbus".equals(info.getName())) {
  241
+                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
  242
+                    break;
  243
+                }
  244
+            }
  245
+        } catch (ClassNotFoundException ex) {
  246
+            java.util.logging.Logger.getLogger(DemosLauncher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  247
+        } catch (InstantiationException ex) {
  248
+            java.util.logging.Logger.getLogger(DemosLauncher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  249
+        } catch (IllegalAccessException ex) {
  250
+            java.util.logging.Logger.getLogger(DemosLauncher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  251
+        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  252
+            java.util.logging.Logger.getLogger(DemosLauncher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  253
+        }
  254
+        //</editor-fold>
  255
+
  256
+        /* Create and display the form */
  257
+        java.awt.EventQueue.invokeLater(new Runnable() {
  258
+            public void run() {
  259
+                new DemosLauncher().setVisible(true);
  260
+            }
  261
+        });
  262
+    }
  263
+    // Variables declaration - do not modify//GEN-BEGIN:variables
  264
+    private javax.swing.JButton jButton1;
  265
+    private javax.swing.JButton jButton2;
  266
+    private javax.swing.JButton jButton3;
  267
+    private javax.swing.JButton jButton4;
  268
+    private javax.swing.JButton jButton5;
  269
+    private javax.swing.JButton jButton6;
  270
+    private javax.swing.JPanel jPanel1;
  271
+    private javax.swing.JScrollBar jScrollBar1;
  272
+    // End of variables declaration//GEN-END:variables
  273
+}
302 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/LeaderFollowingDemo.java
... ...
@@ -0,0 +1,302 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.SimpleMoveBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.BalancedCompoundSteeringBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.LeaderFollowing;
  18
+import com.jme3.font.BitmapText;
  19
+import com.jme3.input.KeyInput;
  20
+import com.jme3.input.controls.ActionListener;
  21
+import com.jme3.input.controls.AnalogListener;
  22
+import com.jme3.input.controls.KeyTrigger;
  23
+import java.util.ArrayList;
  24
+
  25
+import steeringDemos.control.CustomSteerControl;
  26
+
  27
+import java.util.List;
  28
+import java.util.Arrays;
  29
+
  30
+/**
  31
+ * AI Steer Test - Testing the leader following and separation behaviours
  32
+ *
  33
+ * @author Jesús Martín Berlanga
  34
+ * @version 1.3
  35
+ */
  36
+public class LeaderFollowingDemo extends SimpleApplication {
  37
+    
  38
+    private SeparationBehaviour[] separation;
  39
+    private boolean isStrengthEscalar = true;
  40
+    private float escalarStrength = 0.1f;
  41
+    private BitmapText escalarStrengthHudText;
  42
+    private BitmapText escalarInfoHudtext;
  43
+    private final String ESCALAR_INFO_HUD_MESSAGE = "Press H to increase the separation escalar strength, L to decrease.";
  44
+    
  45
+    private Game game = Game.getInstance(); //creating game
  46
+    //TEST SETTINGS - START
  47
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  48
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  49
+    private final ColorRGBA TARGET_COLOR = ColorRGBA.Red;
  50
+    private final float TARGET_MOVE_SPEED = 1f;
  51
+    private final float TARGET_ROTATION_SPEED = 30;
  52
+    private final float TARGET_MASS = 50;
  53
+    private final float TARGET_MAX_FORCE = 20;
  54
+    private final int NUMBER_NEIGHBOURS = 50;
  55
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  56
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  57
+    private final float NEIGHBOURS_ROTATION_SPEED = 30;
  58
+    private final float NEIGHBOURS_MASS = 50;
  59
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  60
+    //TEST SETTINGS - END
  61
+
  62
+    public static void main(String[] args) {
  63
+        LeaderFollowingDemo app = new LeaderFollowingDemo();
  64
+        app.start();
  65
+    }
  66
+    
  67
+    @Override
  68
+    public void simpleInitApp() {
  69
+        
  70
+        //KEYS
  71
+        keys();
  72
+        
  73
+        //HUD TEXT
  74
+        BitmapText hudText = new BitmapText(guiFont, false);          
  75
+        hudText.setSize(guiFont.getCharSet().getRenderedSize() * 0.65f);      // font size
  76
+        hudText.setColor(ColorRGBA.Red);                             // font color
  77
+        hudText.setText("Press N to switch betwen escalar 'separation strength' and 'plane strength'.");             // the text
  78
+        hudText.setLocalTranslation(0, 475, 0); // position
  79
+        guiNode.attachChild(hudText);
  80
+        
  81
+        this.escalarStrengthHudText = new BitmapText(guiFont, false);          
  82
+        this.escalarStrengthHudText.setSize(guiFont.getCharSet().getRenderedSize() * 0.65f);      // font size
  83
+        this.escalarStrengthHudText.setColor(ColorRGBA.Orange);                             // font color
  84
+        this.escalarStrengthHudText.setText(String.valueOf(this.escalarStrength));             // the text
  85
+        this.escalarStrengthHudText.setLocalTranslation(0, 430, 0); // position
  86
+        guiNode.attachChild(escalarStrengthHudText); 
  87
+        
  88
+        this.escalarInfoHudtext = new BitmapText(guiFont, false);          
  89
+        this.escalarInfoHudtext.setSize(guiFont.getCharSet().getRenderedSize() * 0.65f);      // font size
  90
+        this.escalarInfoHudtext.setColor(ColorRGBA.Orange);                             // font color
  91
+        this.escalarInfoHudtext.setText(this.ESCALAR_INFO_HUD_MESSAGE);             // the text
  92
+        this.escalarInfoHudtext.setLocalTranslation(0, 450, 0); // position
  93
+        guiNode.attachChild(escalarInfoHudtext); 
  94
+        
  95
+        
  96
+        //defining rootNode for game processing
  97
+        game.setRootNode(rootNode);
  98
+        
  99
+        game.setInputManager(inputManager);
  100
+        game.setGameControl(new CustomSteerControl(5f));
  101
+        game.getGameControl().loadInputManagerMapping();
  102
+        
  103
+        this.setupCamera();
  104
+        
  105
+        Vector3f[] spawnArea = null;
  106
+        
  107
+        Agent target = this.createBoid("Target", this.TARGET_COLOR);
  108
+        game.addAgent(target); //Add the target to the game
  109
+        this.setStats(target, this.TARGET_MOVE_SPEED,
  110
+                this.TARGET_ROTATION_SPEED, this.TARGET_MASS,
  111
+                this.TARGET_MAX_FORCE);
  112
+        game.getGameControl().spawn(target, new Vector3f());
  113
+        //this.setStats(target, this.TARGET_MOVE_SPEED, this.TARGET_ROTATION_SPEED, 
  114
+        //        this.TARGET_MASS, this.TARGET_MAX_FORCE);
  115
+        
  116
+        Agent[] neighbours = new Agent[this.NUMBER_NEIGHBOURS];
  117
+        
  118
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  119
+            neighbours[i] = this.createBoid("Neighbour " + i, this.NEIGHBOURS_COLOR);
  120
+            game.addAgent(neighbours[i]); //Add the neighbours to the game
  121
+            this.setStats(neighbours[i], this.NEIGHBOURS_MOVE_SPEED,
  122
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  123
+                    this.NEIGHBOURS_MAX_FORCE);
  124
+            game.getGameControl().spawn(neighbours[i], spawnArea);
  125
+        }
  126
+        
  127
+        List<Agent> obstacles = new ArrayList<Agent>();
  128
+        obstacles.addAll(Arrays.asList(neighbours));
  129
+        obstacles.add(target);
  130
+        
  131
+        SimpleMainBehaviour targetMainBehaviour = new SimpleMainBehaviour(target);
  132
+        SimpleMoveBehaviour targetMoveBehavior = new SimpleMoveBehaviour(target);
  133
+        targetMoveBehavior.setMoveDirection(new Vector3f(1,1,0)); //moves in x-y direction
  134
+        
  135
+        float randomDistance = ((float) Math.random()) * 1000f;
  136
+        
  137
+        targetMoveBehavior.setMoveDirection(new Vector3f(randomDistance, randomDistance, randomDistance));
  138
+        targetMainBehaviour.addBehaviour(targetMoveBehavior);
  139
+        target.setMainBehaviour(targetMainBehaviour);
  140
+        
  141
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[neighbours.length];
  142
+        
  143
+        separation = new SeparationBehaviour[neighbours.length];
  144
+        
  145
+        for (int i = 0; i < neighbours.length; i++) {
  146
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(neighbours[i]);
  147
+            
  148
+            LeaderFollowing pursuit = new LeaderFollowing(
  149
+                    neighbours[i], target,
  150
+                    2f,
  151
+                    (float) Math.PI / 2,
  152
+                    0.78f,
  153
+                    5f);
  154
+            
  155
+            this.separation[i] = new SeparationBehaviour(neighbours[i], obstacles);
  156
+            
  157
+            separation[i].setupStrengthControl(escalarStrength);
  158
+
  159
+            BalancedCompoundSteeringBehaviour steer = new BalancedCompoundSteeringBehaviour(neighbours[i]);
  160
+            
  161
+            steer.addSteerBehaviour(separation[i]);
  162
+            steer.addSteerBehaviour(pursuit);
  163
+            
  164
+            neighboursMainBehaviour[i].addBehaviour(steer);
  165
+
  166
+            neighbours[i].setMainBehaviour(neighboursMainBehaviour[i]);
  167
+        }
  168
+        
  169
+        game.start();
  170
+    }
  171
+    
  172
+    private void setupCamera() {
  173
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  174
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  175
+        getFlyByCamera().setMoveSpeed(50);
  176
+
  177
+        flyCam.setDragToRotate(true);
  178
+        //flyCam.setEnabled(false);  
  179
+    }
  180
+
  181
+    //Create an agent with a name and a color
  182
+    private Agent createBoid(String name, ColorRGBA color) {
  183
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  184
+        boidSpatial.setLocalScale(0.1f); //Resize
  185
+        
  186
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);        
  187
+        mat.setColor("Color", color);
  188
+        boidSpatial.setMaterial(mat);
  189
+        
  190
+        return new Agent(name, boidSpatial);
  191
+    }
  192
+
  193
+    //Setup the stats for an agent
  194
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  195
+            float mass, float maxForce) {
  196
+        
  197
+        myAgent.setMoveSpeed(moveSpeed);
  198
+        myAgent.setRotationSpeed(rotationSpeed);
  199
+        myAgent.setMass(mass);
  200
+        myAgent.setMaxForce(maxForce);
  201
+    }
  202
+    
  203
+    @Override
  204
+    public void simpleUpdate(float tpf) {
  205
+        game.update(tpf);
  206
+        
  207
+        if(this.isStrengthEscalar)
  208
+        {
  209
+            escalarStrengthHudText.setText(String.valueOf(escalarStrength));
  210
+            this.escalarInfoHudtext.setText(this.ESCALAR_INFO_HUD_MESSAGE);
  211
+        }
  212
+        else
  213
+        {
  214
+            escalarStrengthHudText.setText("");
  215
+            this.escalarInfoHudtext.setText("");   
  216
+        }
  217
+    }
  218
+    
  219
+  /** Custom Keybinding: Map named actions to inputs. */
  220
+  private void keys() {
  221
+    // You can map one or several inputs to one named action
  222
+    inputManager.addMapping("Switch mode",  new KeyTrigger(KeyInput.KEY_N));
  223
+    inputManager.addMapping("Increase separation",   new KeyTrigger(KeyInput.KEY_H));
  224
+    inputManager.addMapping("Decrease separation",  new KeyTrigger(KeyInput.KEY_L));
  225
+
  226
+    // Add the names to the action listener.
  227
+    inputManager.addListener(actionListener,"Switch mode");
  228
+    inputManager.addListener(analogListener,"Increase separation", "Decrease separation");
  229
+ 
  230
+  }
  231
+  
  232
+   private ActionListener actionListener = new ActionListener() {
  233
+    public void onAction(String name, boolean keyPressed, float tpf) {
  234
+        
  235
+      if (name.equals("Switch mode") && !keyPressed) {
  236
+         changeMode();
  237
+      }
  238
+      
  239
+    }
  240
+  };
  241
+   
  242
+   private void changeMode() {
  243
+       
  244
+       if(this.isStrengthEscalar) 
  245
+       {
  246
+           for(SeparationBehaviour behaviour :  this.separation)
  247
+                behaviour.setupStrengthControl(1, 1, 0);
  248
+           
  249
+           this.isStrengthEscalar = false;
  250
+       }
  251
+       else
  252
+       {
  253
+           for(SeparationBehaviour behaviour :  this.separation)
  254
+                 behaviour.setupStrengthControl(escalarStrength);
  255
+           
  256
+           this.isStrengthEscalar = true;
  257
+       }
  258
+   }
  259
+ 
  260
+  private AnalogListener analogListener = new AnalogListener() {
  261
+    public void onAnalog(String name, float value, float tpf) {
  262
+
  263
+        
  264
+        if (name.equals("Increase separation")) {
  265
+          increaseSeparation();
  266
+        }
  267
+        else if (name.equals("Decrease separation")) {
  268
+          decreaseSeparation();
  269
+        }
  270
+
  271
+    }
  272
+  };
  273
+  
  274
+  private void increaseSeparation() {
  275
+      
  276
+      if(this.isStrengthEscalar)
  277
+      {
  278
+          this.escalarStrength = this.escalarStrength + 0.05f;
  279
+          
  280
+          for(SeparationBehaviour behaviour :  this.separation)
  281
+          behaviour.setupStrengthControl(this.escalarStrength);
  282
+      }
  283
+      
  284
+  }
  285
+  
  286
+  private void decreaseSeparation() {
  287
+      
  288
+      if(this.isStrengthEscalar)
  289
+      {
  290
+          this.escalarStrength = this.escalarStrength - 0.075f;
  291
+          
  292
+          if(this.escalarStrength < 0)
  293
+              this.escalarStrength = 0;
  294
+          
  295
+          for(SeparationBehaviour behaviour :  this.separation)
  296
+             behaviour.setupStrengthControl(this.escalarStrength);
  297
+      }
  298
+      
  299
+  }
  300
+  
  301
+  
  302
+}
129 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/SlowDemo.java
... ...
@@ -0,0 +1,129 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  7
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  8
+import com.jme3.ai.agents.behaviours.npc.steering.MoveBehaviour;
  9
+import com.jme3.ai.agents.behaviours.npc.steering.SlowBehaviour;
  10
+import com.jme3.ai.agents.util.control.Game;
  11
+import com.jme3.app.SimpleApplication;
  12
+import com.jme3.material.Material;
  13
+import com.jme3.math.ColorRGBA;
  14
+import com.jme3.math.Vector3f;
  15
+import com.jme3.scene.Geometry;
  16
+import com.jme3.scene.Spatial;
  17
+import com.jme3.scene.shape.Sphere;
  18
+import steeringDemos.control.CustomSteerControl;
  19
+
  20
+/**
  21
+ * Demo for the slow behaviour
  22
+ *
  23
+ * @author Jesús Martín Berlanga
  24
+ * @version 1.0
  25
+ */
  26
+public class SlowDemo extends SimpleApplication {
  27
+    
  28
+    private Game game = Game.getInstance(); //creating game
  29
+    //TEST SETTINGS - START
  30
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  31
+    private final String MATERIAL_1 = "Common/MatDefs/Misc/Unshaded.j3md";
  32
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  33
+    private final float NEIGHBOURS_MOVE_SPEED = 1f;
  34
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  35
+    private final float NEIGHBOURS_MASS = 50;
  36
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  37
+    //TEST SETTINGS - END
  38
+    
  39
+    public static void main(String[] args) {
  40
+        SlowDemo app = new SlowDemo();
  41
+        app.start();
  42
+    }
  43
+    
  44
+    @Override
  45
+    public void simpleInitApp() {
  46
+        game.setRootNode(rootNode);
  47
+        game.setInputManager(inputManager);
  48
+        game.setGameControl(new CustomSteerControl(50f));
  49
+        game.getGameControl().loadInputManagerMapping();
  50
+        this.setupCamera();
  51
+        
  52
+        
  53
+        Agent agent = this.createBoid("boid ", this.NEIGHBOURS_COLOR);
  54
+        agent.setRadius(0.1f);
  55
+        game.addAgent(agent); //Add the neighbours to the game
  56
+        this.setStats(agent, this.NEIGHBOURS_MOVE_SPEED,
  57
+                this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  58
+                this.NEIGHBOURS_MAX_FORCE);
  59
+        
  60
+        
  61
+        game.getGameControl().spawn(agent, new Vector3f());
  62
+        
  63
+        
  64
+        SimpleMainBehaviour main = new SimpleMainBehaviour(agent);
  65
+        MoveBehaviour move = new MoveBehaviour(agent);
  66
+        SlowBehaviour slow = new SlowBehaviour(agent);
  67
+        move.setMoveDirection(new Vector3f(1, 0, 0));
  68
+        CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(agent);
  69
+        
  70
+        steer.addSteerBehaviour(move);
  71
+        steer.addSteerBehaviour(slow);
  72
+        
  73
+        main.addBehaviour(steer);
  74
+        agent.setMainBehaviour(main);
  75
+        
  76
+        game.start();
  77
+    }
  78
+    
  79
+    private void setupCamera() {
  80
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  81
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  82
+        getFlyByCamera().setMoveSpeed(50);
  83
+        
  84
+        flyCam.setDragToRotate(true);
  85
+        //flyCam.setEnabled(false);  
  86
+    }
  87
+
  88
+    //Create an agent with a name and a color
  89
+    private Agent createBoid(String name, ColorRGBA color) {
  90
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  91
+        boidSpatial.setLocalScale(0.1f); //Resize
  92
+
  93
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  94
+        mat.setColor("Color", color);
  95
+        boidSpatial.setMaterial(mat);
  96
+        
  97
+        return new Agent(name, boidSpatial);
  98
+    }
  99
+
  100
+    //Create a sphere
  101
+    private Agent createSphere(String name, ColorRGBA color) {
  102
+        Sphere sphere = new Sphere(10, 10, 0.25f);
  103
+        Geometry sphereG = new Geometry("Sphere Geometry", sphere);
  104
+        Spatial spatial = sphereG;
  105
+        
  106
+        spatial.setLocalScale(0.1f); //Resize0
  107
+
  108
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  109
+        mat.setColor("Color", color);
  110
+        spatial.setMaterial(mat);
  111
+        
  112
+        return new Agent(name, spatial);
  113
+    }
  114
+
  115
+    //Setup the stats for an agent
  116
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  117
+            float mass, float maxForce) {
  118
+        
  119
+        myAgent.setMoveSpeed(moveSpeed);
  120
+        myAgent.setRotationSpeed(rotationSpeed);
  121
+        myAgent.setMass(mass);
  122
+        myAgent.setMaxForce(maxForce);
  123
+    }
  124
+    
  125
+    @Override
  126
+    public void simpleUpdate(float tpf) {
  127
+        game.update(tpf);
  128
+    }
  129
+}
13 ...emos/simpleExamples/PursuitAndSeparationTest.java → ...src/steeringDemos/simpleExamples/PursuitTest.java
@@ -31,9 +31,9 @@
31 31
  * AI Steer Test - Testing the pursuit and separation behaviours
32 32
  *
33 33
  * @author Jesús Martín Berlanga
34  
- * @version 1.2
  34
+ * @version 1.0
35 35
  */
36  
-public class PursuitAndSeparationTest extends SimpleApplication {
  36
+public class PursuitTest extends SimpleApplication {
37 37
     
38 38
     private SeparationBehaviour[] separation;
39 39
     private boolean isStrengthEscalar = true;
@@ -60,7 +60,7 @@
60 60
     //TEST SETTINGS - END
61 61
 
62 62
     public static void main(String[] args) {
63  
-        PursuitAndSeparationTest app = new PursuitAndSeparationTest();
  63
+        PursuitTest app = new PursuitTest();
64 64
         app.start();
65 65
     }
66 66
     
@@ -145,12 +145,7 @@ public void simpleInitApp() {
145 145
         for (int i = 0; i < neighbours.length; i++) {
146 146
             neighboursMainBehaviour[i] = new SimpleMainBehaviour(neighbours[i]);
147 147
             
148  
-            PursuitBehaviour pursuit = new PursuitBehaviour(
149  
-                    neighbours[i], target,
150  
-                    2f,
151  
-                    (float) Math.PI / 2,
152  
-                    0.78f,
153  
-                    5f);
  148
+            PursuitBehaviour pursuit = new PursuitBehaviour(neighbours[i], target);
154 149
             
155 150
             this.separation[i] = new SeparationBehaviour(neighbours[i], obstacles);
156 151
             
113 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/simpleExamples/WanderTest.java
... ...
@@ -0,0 +1,113 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.simpleExamples;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  15
+
  16
+
  17
+import steeringDemos.control.CustomSteerControl;
  18
+
  19
+/**
  20
+ * AI Steer Test - Testing the wander behaviour
  21
+ * 
  22
+ * @author Jesús Martín Berlanga
  23
+ * @version 1.0
  24
+ */
  25
+public class WanderTest extends SimpleApplication {
  26
+    
  27
+    private Game game = Game.getInstance(); //creating game
  28
+    
  29
+    //TEST SETTINGS - START
  30
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  31
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  32
+    private final ColorRGBA TARGET_COLOR = ColorRGBA.Red;
  33
+    private final float TARGET_MOVE_SPEED = 1;
  34
+    private final float TARGET_ROTATION_SPEED = 30;
  35
+    private final float TARGET_MASS = 50;
  36
+    private final float TARGET_MAX_FORCE = 20;
  37
+    //TEST SETTINGS - END
  38
+
  39
+    public static void main(String[] args) {
  40
+        WanderTest app = new WanderTest();
  41
+        app.start();
  42
+    }
  43
+    
  44
+    @Override
  45
+    public void simpleInitApp() {
  46
+        //defining rootNode for game processing
  47
+        game.setRootNode(rootNode);
  48
+        
  49
+        game.setInputManager(inputManager);
  50
+        game.setGameControl(new CustomSteerControl());
  51
+        game.getGameControl().loadInputManagerMapping();
  52
+        
  53
+        this.setupCamera();
  54
+        
  55
+        Vector3f[] spawnArea = null;
  56
+        
  57
+        Agent target = this.createBoid("Target", this.TARGET_COLOR);
  58
+   
  59
+        game.addAgent(target); //Add the target to the game
  60
+        game.getGameControl().spawn(target, spawnArea);
  61
+        this.setStats(target, this.TARGET_MOVE_SPEED, this.TARGET_ROTATION_SPEED, 
  62
+                this.TARGET_MASS, this.TARGET_MAX_FORCE);
  63
+                
  64
+
  65
+        
  66
+        SimpleMainBehaviour targetMainBehaviour =  new SimpleMainBehaviour(target);
  67
+        WanderBehaviour targetMoveBehavior = new WanderBehaviour(target);
  68
+        //targetMoveBehavior.setArea(Vector3f.ZERO, Vector3f.POSITIVE_INFINITY);
  69
+        targetMainBehaviour.addBehaviour(targetMoveBehavior);
  70
+        target.setMainBehaviour(targetMainBehaviour);
  71
+      
  72
+       
  73
+        
  74
+        game.start();
  75
+    }
  76
+    
  77
+    private void setupCamera(){
  78
+        getCamera().setLocation(new Vector3f(0,20,0));
  79
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  80
+        getFlyByCamera().setMoveSpeed(50);
  81
+        
  82
+         // Disable flying camera - DEBUG ONLY
  83
+         //flyCam.setDragToRotate(true);
  84
+         //flyCam.setEnabled(false); 
  85
+    }
  86
+    
  87
+    //Create an agent with a name and a color
  88
+    private Agent createBoid(String name, ColorRGBA color){
  89
+            Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  90
+            boidSpatial.setLocalScale(0.1f); //Resize
  91
+ 
  92
+            Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);                         
  93
+            mat.setColor("Color", color);
  94
+            boidSpatial.setMaterial(mat);
  95
+            
  96
+            return new Agent(name, boidSpatial);
  97
+    }
  98
+    
  99
+    //Setup the stats for an agent
  100
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  101
+            float mass, float maxForce){
  102
+        
  103
+            myAgent.setMoveSpeed(moveSpeed);
  104
+            myAgent.setRotationSpeed(rotationSpeed);
  105
+            myAgent.setMass(mass);
  106
+            myAgent.setMaxForce(maxForce);
  107
+    }
  108
+    
  109
+    @Override
  110
+    public void simpleUpdate(float tpf) {
  111
+        game.update(tpf);
  112
+    }
  113
+}