Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 22 and Version 23 of pps/tutorial


Ignore:
Timestamp:
Apr 9, 2011, 9:07:38 PM (14 years ago)
Author:
dafrick
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial

    v22 v23  
    2525 5. Now build for the first time (may take some time, further builds will be faster):
    2626{{{
    27 make -j3  #-j3 means to create 3 parallel compile processes
     27make -j3
    2828}}}
     29 The ''-j3'' means to create 3 parallel compile processes.
    2930 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;))
    3031'''Start the game for the first time'''
     
    4849{{{
    4950#!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>
    5152}}}
    52 Otherwise you'll get tons of compiler errors. ;)
     53Otherwise you'll get tons of compiler errors.
     54Be sure to also read the comments labeled with TODO in the code files.
     55
    5356We 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.
    5457
     
    6871XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode)
    6972}}}
    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).
    7174 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.
    7275
     
    7881
    7982== 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.
     83Now 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.
    8184
    8285 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:
    8588{{{
    86 rnd() // return a random value between 0 and 1
    87 sin() // should be clear (also cos)
    88 // many other functions (have a look at src/util/Math.h for details)
     89rnd() // Return a random value between 0 and 1
     90sin() // Should be clear (also cos)
     91// Many other functions (have a look at src/util/Math.h for details)
    8992}}}
    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
     95Again 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.
    9197
    9298== 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)
     99As 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).
    94100
    95 Now that you finished the classes you can recompile the project. Afterwards open the level file:
     101Now that you finished the classes you can recompile the project. This is again done by typing in the console:
     102{{{
     103make -j3
     104}}}
     105
     106Afterwards open the level file:
    96107 1. Open ''tutorial/data/levels/tutorial.oxw''.
    97108 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:
     
    100111</ClassX>
    101112}}}
    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)
     113Of 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).
    103115 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:
    104116{{{
     
    106118    <Model scale="10" mesh="drone.mesh"/>
    107119  </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.
    110122
    111123 5. Because the physics engine needs a collision shape to work with, we will add the following entry (before </ClassX>):
     
    115127  </collisionShapes>
    116128}}}
    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).
    118130 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.)
    119131{{{
     
    135147== Commit your code to the repository ==
    136148We 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):
    138150{{{
    139151~/orxonox/tutorial$ svn up