Changes between Version 14 and Version 15 of pps/tutorial
- Timestamp:
- Sep 13, 2010, 3:16:35 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pps/tutorial
v14 v15 29 29 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;)) 30 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.31 7. Enter to the appropriate folder and start the game. You will see a menu popping up, just press the ''Quickstart'' button. 32 32 {{{ 33 33 cd ~/orxonox/tutorial/build … … 43 43 <p style="text-align: left; color: red">Note: Do not just copy & paste! Most commands / codelines need to be edited.</p> Otherwise you'll get tons of compiler errors ;) 44 44 }}} 45 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}'.45 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}''. 46 46 47 1. Open the file AutonomousDrone.ccand have a look at the code.48 2. In order to be able to create an AutonomousDrone 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).47 1. Open the file ''AutonomousDrone.cc'' and have a look at the code. 48 2. In order to be able to create an AutonomousDrone 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'' (global, inside the namespace). 49 49 {{{ 50 50 CreateFactory(ClassX) 51 51 }}} 52 3. Make sure th e each drone object gets registered to the core by adding a call of RegisterObject(Classname) inside the constructor52 3. Make sure that each drone object gets registered to the core by adding a call of ''RegisterObject(Classname)'' inside the constructor. 53 53 {{{ 54 54 RegisterObject(ClassXY) 55 55 }}} 56 4. Now go to the XMLPort function and add the calls for the two variables auxiliaryThrust_ and rotationThrust_. As you can see, the XMLPort function for the variable 'primaryThurst_' has already been specified.56 4. Now go to the XMLPort function and add the calls for the two variables ''auxiliaryThrust_'' and ''rotationThrust_''. As you can see, the XMLPort function for the variable ''primaryThurst_'' has already been specified. 57 57 {{{ 58 58 XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode) 59 59 }}} 60 '''Note: You need to add set- and get-functions for auxiliaryThrust_ and rotationThrust_ inside the AutonomousDrone.hfile (have a look at {get/set}PrimaryThrust).'''61 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.ccfile for further builds.60 '''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).''' 61 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. 62 62 63 63 That's it for the AutonomousDrone class. … … 65 65 == The AutonomousDroneController == 66 66 Now you will finish the AutonomousDroneController which gets called each tick and steers the drone. 67 1. Open the file AutonomousDroneController.ccand look at it.67 1. Open the file ''AutonomousDroneController.cc'' and look at it. 68 68 2. Have a look at the constructor and make sure nothing is missing (think of the core). 69 69 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: … … 77 77 == The XML Part == 78 78 Now that you finished the classes you can recompile the project. Afterwards open the level file: 79 1. Open tutorial/data/levels/tutorial.oxw79 1. Open ''tutorial/data/levels/tutorial.oxw'' 80 80 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: 81 81 {{{ … … 83 83 </ClassX> 84 84 }}} 85 3. Now add the appropriate entries for the variables you defined in AutonomousDrone/4. (Have a look at data/levels/templates/spaceship_assff.oxtfor example values)85 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) 86 86 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: 87 87 {{{ … … 122 122 ~/orxonox/tutorial$ svn up 123 123 }}} 124 2. In order to avoid conflicts copy your file ( AutonomousDroneController.cc)124 2. In order to avoid conflicts copy your file (''AutonomousDroneController.cc'') 125 125 {{{ 126 126 ~/orxonox/tutorial$ svn cp src/orxonox/objects/controllers/AutonomousDroneController.cc src/orxonox/objects/controllers/AutonomousDroneController_myUserName.cc … … 130 130 ~/orxonox/tutorial$ svn revert src/orxonox/objects/controllers/AutonomousDroneController.cc 131 131 }}} 132 4. Now commit 132 4. Now commit. 133 133 {{{ 134 ~/orxonox/tutorial$ svn ci -m " this is my version of theDrone steering function" src/orxonox/controllers/AutonomousDroneController_myUserName.cc134 ~/orxonox/tutorial$ svn ci -m "This is my version of the AutonomousDrone steering function" src/orxonox/controllers/AutonomousDroneController_myUserName.cc 135 135 }}}