| 1 | = Basic PPS Tutorial = |
| 2 | This is a basic tutorial for new PPS students to get familiar with our framework and build environment. The process is described for tardis here. If you use another system first go to the [download] page and make sure you have all dependencies installed. |
| 3 | |
| 4 | == Preparations == |
| 5 | '''We check out the source and media repository and build for the first time''' |
| 6 | 1. Create your orxonox directory (if not already existing): |
| 7 | {{{ |
| 8 | mkdir ~/orxonox |
| 9 | cd ~/orxonox |
| 10 | }}} |
| 11 | 2. Now check out the latest revision of the media repository (you will probably be asked for a username and password once): |
| 12 | {{{ |
| 13 | svn co https://svn.orxonox.net/data/Media |
| 14 | }}} |
| 15 | 3. Now get the latest revision of the tutorial: |
| 16 | {{{ |
| 17 | svn co https://svn.orxonox.net/orxonox/branches/tutorial |
| 18 | }}} |
| 19 | 4. Prepare to build: |
| 20 | {{{ |
| 21 | mkdir tutorial/build |
| 22 | cd tutorial/build |
| 23 | cmake .. |
| 24 | }}} |
| 25 | 5. Now build for the first time (may take some time, further builds will be faster): |
| 26 | {{{ |
| 27 | make -j4 #-j4 means to create 4 parallel compile processes |
| 28 | }}} |
| 29 | 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;)) |
| 30 | '''Start the game for the first time''' |
| 31 | 7. Enter to the appropriate folder and start the game. You will see a menu popping up, just press the ''Standalone'' button. |
| 32 | {{{ |
| 33 | cd ~/orxonox/tutorial/build |
| 34 | ./run |
| 35 | }}} |
| 36 | |
| 37 | == The Drone == |
| 38 | We created for you the skeleton of an autonomous drone. You can find the code in the files 'src/orxonox/objects/worldentities/Drone.{cc|h}' and 'src/orxonox/controlles/DroneController.{cc|h}'. |
| 39 | |
| 40 | 1. open the file Drone.cc and have a look at the code |
| 41 | 2. in order to be able to create a Drone object from the xml file or somewhere else just by the class name you need to add a call of CreateFactory(Classname) somewhere inside the cc file (global, inside the namespace) |
| 42 | {{{ |
| 43 | CreateFactory(ClassX) |
| 44 | }}} |
| 45 | 3. make sure the each drone object gets registered to the core by adding a call of RegisterObject(Classname) inside the constructor |
| 46 | {{{ |
| 47 | RegisterObject(ClassXY) |
| 48 | }}} |
| 49 | 4. now go to the XMLPort function and add the calls for the three variables primaryThrust_, auxilaryThrust_ and rotationThrust_. |
| 50 | {{{ |
| 51 | XMLPortParamVariable(Classname, "xml-attribute-name", variablename, xmlelement, mode) |
| 52 | }}} |
| 53 | |
| 54 | That's it for the Drone class |
| 55 | |
| 56 | == The DroneController == |
| 57 | Now you will finish the DroneController which gets called each tick and steers the drone. |
| 58 | 1. open the file DroneController.cc and look at it |
| 59 | 2. have a look at the constructor and make sure nothing is missing (think of the core) |
| 60 | 3. now look at the tick function. it gets called each time before a new frame is drawn. you can put in some steering code here. if you want you can use some functions provided by Math.h: |
| 61 | {{{ |
| 62 | rnd() // return a random value between 0 and 1 |
| 63 | sin() // should be clear (also cos) |
| 64 | // many other functions (have a look at src/util/Math.h for details) |
| 65 | }}} |
| 66 | |
| 67 | == The XML Part == |
| 68 | Now that you finished the classes you can recompile the project. Afterwards open the level file: |
| 69 | 1. open media/levels/tutorial.oxw |
| 70 | 2. we want to add a drone to the level now, so put in an entry for it (below the Light definition). look at this example: |
| 71 | {{{ |
| 72 | <ClassX variable1="2" string1="blabla" coord1="1,0,0"> |
| 73 | </ClassX> |
| 74 | }}} |
| 75 | 3. now add the appropriate entries for the variables you defined in Drone/4. |
| 76 | 4. as we want our drone to be visible we have to attach a model to it. add the following code between the above 2 lines: |
| 77 | {{{ |
| 78 | <attached> |
| 79 | <Model scale="10" mesh="drone.mesh"/> |
| 80 | </attached> |
| 81 | }}} |
| 82 | this adds a model with the mesh drone.mesh and the defined textures at the position of our drone object. |
| 83 | |
| 84 | 5. because the physic engine needs a collision shape to work we will add the following entry (before </ClassX>): |
| 85 | {{{ |
| 86 | <collisionShapes> |
| 87 | <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" /> |
| 88 | </collisionShapes> |
| 89 | }}} |
| 90 | this will tell the phyic engine what dimensions our drone has (in this case its just a cube) |