Changes between Version 22 and Version 23 of pps/tutorial
- Timestamp:
- Apr 9, 2011, 9:07:38 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pps/tutorial
v22 v23 25 25 5. Now build for the first time (may take some time, further builds will be faster): 26 26 {{{ 27 make -j3 #-j3 means to create 3 parallel compile processes27 make -j3 28 28 }}} 29 The ''-j3'' means to create 3 parallel compile processes. 29 30 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;)) 30 31 '''Start the game for the first time''' … … 48 49 {{{ 49 50 #!html 50 <p style="text-align: left; color: red"> Note:Do not just copy & paste! Most commands / codelines need to be edited. But that doesn't mean you shouldn't copy & paste, but you should stink about whether what you paste should be modified and how.</p>51 <p style="text-align: left; color: red"><b>Note:</b> Do not just copy & paste! Most commands / codelines need to be edited. But that doesn't mean you shouldn't copy & paste, but you should stink about whether what you paste should be modified and how.</p> 51 52 }}} 52 Otherwise you'll get tons of compiler errors. ;) 53 Otherwise you'll get tons of compiler errors. 54 Be sure to also read the comments labeled with TODO in the code files. 55 53 56 We created for you the skeleton of an autonomous drone. You can find the code in the files ''src/orxonox/worldentities/AutonomousDrone.{cc|h}'' and ''src/orxonox/controllers/AutonomousDroneController.{cc|h}'' in the trunk folder that you checked out from our repository. 54 57 … … 68 71 XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode) 69 72 }}} 70 Note:You need to add set- and get-functions for ''auxiliaryThrust_'' and ''rotationThrust_'' inside the ''AutonomousDrone.h'' file (have a look at {get/set}PrimaryThrust).73 '''Note:''' You need to add set- and get-functions for ''auxiliaryThrust_'' and ''rotationThrust_'' inside the ''AutonomousDrone.h'' file (have a look at {get/set}PrimaryThrust). 71 74 5. Now you need to add the AutonomousDrone to the build system. Open the file ''src/orxonox/worldentities/CMakeLists.txt'' and add ''AutonomousDrone.cc'' to the ORXONOX_SRC_FILES. This makes ''cmake'' consider the ''AutonomousDrone.cc'' file for further builds. 72 75 … … 78 81 79 82 == The AutonomousDroneController == 80 Now you will finish the AutonomousDroneController which gets called each tick and steers the drone using the functionality of movement in the game world that the drone provides. 83 Now you will finish the AutonomousDroneController which gets called each tick and steers the drone using the functionality of movement in the game world that the drone provides. i.e. the drone's intelligence. 81 84 82 85 1. Open the file ''AutonomousDroneController.cc'' and look at it (''src/orxonox/controllers/''). 83 2. Have a look at the constructor and make sure nothing is missing (think of the core).84 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:86 2. Have a look at the constructor and make sure nothing is missing (think of the what we did for the AutonomousDrone). 87 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: 85 88 {{{ 86 rnd() // return a random value between 0 and 187 sin() // should be clear (also cos)88 // many other functions (have a look at src/util/Math.h for details)89 rnd() // Return a random value between 0 and 1 90 sin() // Should be clear (also cos) 91 // Many other functions (have a look at src/util/Math.h for details) 89 92 }}} 90 4. repeat step 5 (CMakeLists) of the AutonomousDrone for the AutonomousDroneController. 93 4. Repeat step 5 (CMakeLists) of the AutonomousDrone for the AutonomousDroneController. 94 95 Again if you have been having '''problems''' consider the following suggestions: 96 * Did you register the object and create a factory for it? If not or you don't know what this means, have a look at steps 2 and 3 of the AutonomousDrone and think about how this applies to the AutonomousDroneController. 91 97 92 98 == The XML Part == 93 As a last step we will include the drone in our level and add the visual part of the drone, the model . (and some other stuff, too)99 As a last step we will include the drone in our level and add the visual part of the drone, the model (and some other stuff, too). 94 100 95 Now that you finished the classes you can recompile the project. Afterwards open the level file: 101 Now that you finished the classes you can recompile the project. This is again done by typing in the console: 102 {{{ 103 make -j3 104 }}} 105 106 Afterwards open the level file: 96 107 1. Open ''tutorial/data/levels/tutorial.oxw''. 97 108 2. We want to add a drone to the level now, so put in an entry for it (below the comment that tells you to do so). Look at this example: … … 100 111 </ClassX> 101 112 }}} 102 3. Now add the appropriate entries for the variables you defined in AutonomousDrone/4. (Have a look at ''data/levels/templates/spaceship_assff.oxt'' for example values) 113 Of course ClassX has to be replaced with the class name of the object you want to create. Additionally the parameters ''variable1'', ''string1'' and ''coord1'' are just examples, they have to be replaced by the appropriate parameters for your drone. 114 3. Now add the appropriate entries for the variables you defined in ''AutonomousDrone.cc''. (Have a look at ''data/levels/templates/spaceship_assff.oxt'' for example values of the different thrusts). 103 115 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: 104 116 {{{ … … 106 118 <Model scale="10" mesh="drone.mesh"/> 107 119 </attached> 108 }}} 109 this adds a model with the mesh drone.mesh and the defined textures at the position of our drone object.120 }}} #-j3 means to create 3 parallel compile processes 121 This adds a model with the mesh drone.mesh and the defined textures at the position of our drone object. 110 122 111 123 5. Because the physics engine needs a collision shape to work with, we will add the following entry (before </ClassX>): … … 115 127 </collisionShapes> 116 128 }}} 117 this will tell the physics engine what dimensions our drone has (in this case its just a cube).129 This will tell the physics engine what dimensions our drone has (in this case its just a cube). 118 130 6. Now we define the mass and two damping parameters of our drone. Append definitions for the following variables as attributes to your drone. (as in 3.) 119 131 {{{ … … 135 147 == Commit your code to the repository == 136 148 We may want to use your steering function later on, so commit it now: 137 1. Make sure you have a recent version of the branch :149 1. Make sure you have a recent version of the branch (this is done by updating): 138 150 {{{ 139 151 ~/orxonox/tutorial$ svn up