Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 14 and Version 15 of pps/tutorial_basic


Ignore:
Timestamp:
Oct 1, 2008, 10:35:54 AM (11 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial_basic

    v14 v15  
    5858The interesting part: Modifying the C++ code. '''Open orxonox/orxonox_tutorial/src/orxonox/objects/TutorialShip.cc'''. As you have already heard from Fabian, the Core Framework is like a language extension to C++. But it cannot be fully automatic. That means you have to add a few lines accordingly:
    5959 1. Find the constructor (TutorialShip::TutorialShip()) and add '''RegisterObject(TutorialShip);''' as the first statement. This is used for the class hierarchy and for the ObjectLists. Whenever you derive from OrxonoxClass or any derivative, this call is necessary.
    60  2. Next will be creating a configurable value in our class. This enables us to configure the TutorialShip from outside (Shell or orxonox.ini). Go to the ''setConfigValues()'' and configure the member variable ''reloadTime_'' with a default value of 0.125. Remember the syntax:
     60 2. Next will be creating a configurable value in our class. This enables us to configure the TutorialShip from outside (Shell or orxonox.ini). Go to the ''setConfigValues()'' function and configure the member variable ''reloadTime_'' with a default value of 0.125. Remember the syntax:
    6161{{{
    62 SetConfigValue(''variable name'', ''default value'').description(''description text'');
     62SetConfigValue(''member variable name'', ''default value'').description(''description text'');
    6363}}}
    6464
     
    7070    keybindMode specifies how the console command should be treated when used on a key. ''OnHold'' means the command gets fired continuously, ''OnRelease'' and ''OnPress'' only once. [[br]]
    7171
    72 === First run test and the Shell ===
    73 We haven't done everything yet, but a little function test would be nice. Compile Orxonox and run it just according to instructions above. If it doesn't compile at all, try to understand the error message and if that doesn't help, ask an assistant. [[br]]
     72=== First test run and using the Shell ===
     73We haven't done everything yet, but a little function test couldn't hurt. Compile Orxonox and run it just according to instructions above. If it doesn't compile at all, try to understand the error message and if that doesn't help, ask an assistant. [[br]]
    7474You should now see exactly what you saw last time. The ship still won't fire anything. To change that we can assign that static ''fire()'' function to a key or button. To do that, open the console with the key just above "tab". To bind a console command to a key, type '''{{{keybind fire}}}''' (keybind is a command itself actually), hit enter and then hit the key or button you would like to assign the command to (preferably the left mouse button...). Close the console and try to fire a projectile (mouse would also work with an open console).[[br]][[br]]
    7575
    7676=== orxonox.ini and the "config" command ===
    77 Now exit the game by hitting ''Esc'' or typing "exit" into the console. In order to change the reload time of the ship's weapon open src/bin/orxonox.ini and look for the section called '''[TutorialShip]'''. There you should see the entry '''reloadTime_'''. Set it to 1.0, save the file and start orxonox again (you don't need to compile anything now). Laggy weapon, right? To change it back open then console and enter "config T". Hit tab then and you will see a list of classes starting with "T" having config values (only ''TutorialShip'' for now). Hit tab again and the shell completes your text. Hit tab two times more and it will even complete the (only) configurable value ''reloadTime_''. You can see the old value being 1.0 above. You need to add a value to the command in order to change the !ConfigValue. Complete instruction now:
     77Now exit the game by hitting ''Esc'' or typing "exit" into the console. In order to change the reload time of the ship's weapon open src/bin/orxonox.ini and look for the section called '''[TutorialShip]''' at the end of the file. There you should see the entry '''reloadTime_'''. Set it to 1.0, save the file and start orxonox again (you don't need to compile anything now). Laggy weapon, right? To revert it open the console and type "config T". Hit tab then and you will see a list of classes starting with "T" having config values (only ''TutorialShip'' for now). Hit tab again and the shell completes your text. Hit tab twice more and it will even complete the (only) configurable value ''reloadTime_''. You can see the old value being 1.0 above. You need to add a value to the command in order to change the !ConfigValue. Hit enter. Complete instruction:
    7878{{{
    7979config TutorialShip reloadTime_ 0.1
     
    8383=== Declare XML loading ===
    8484This part is about how you can load class parameters with XML. Unlike ConfigValues, XML parameters are per object instead of per class. That means you can load multiple objects of the same class with different settings. We are now going to add one XML parameter for the TutorialShip class. [[br]]
    85 Find the ''XMLPort()'' function in the source file. You can see that there is comment but no statement after it. That's where you can insert the macro which specifies a parameter. Keep in mind that when loading with XMLPort, you need to have an access and a store function (not just a variable). These have already been created for the ''specialEffects'' parameter which tells the underlaying !SpaceShip whether to visualise the special effects. The syntax for XML parameters is:
     85Find the ''XMLPort()'' function in the source file. You can see that there are is section declare with INSERT CODE. That's where you can insert the macro which specifies a parameter. Keep in mind that when loading with XMLPort, you need to have an access and a store function (not just a variable). These have already been created for the ''specialEffects'' parameter (hasSpecialEffects() and setSpecialEffects()) which tells the underlaying !SpaceShip whether to visualise the special effects. The syntax for XML parameters is:
    8686{{{
    8787XMLPortParam(classname, parameter name as string, setSpecialEffects, hasSpecialEffects, xmlelement, mode);
     
    9595    # Some unimportant parameters. Better don't mess with them ;)
    9696    camera="true" position="0,0,0".......
    97     # Your own. Set it to "false" to disable showing special effects.
     97    # Your own. Set it to "false" if you want to disable showing special effects.
    9898    name-of-your-parameter="true"
    9999/>
     
    101101
    102102=== Logging messages ===
    103 Stay in the ''XMLPort()'' function and add a statement at the end to display a log message with output level 3:
     103Stay in the ''XMLPort()'' function and add a statement after the SUPER call to display a log message with output level 3:
    104104{{{
    105105COUT(3) << "My name is Bond. James Bond." << std::endl;
     
    111111
    112112== SVN Part II ==
    113 Subversion is not only about 'consuming', you should also be able to commit something. Now copy your TutorialShip.cc file and name it like "TutorialShip_MyName.cc":
     113Subversion is not only about 'consuming', you should also be able to commit something. Now copy your TutorialShip.cc file and rename it to someething like "TutorialShip_MyName.cc":
    114114{{{
    115115cd orxonox/src/orxonox/objects
     
    121121svn ci TutorialShip_Blofeld.cc -m "A message"
    122122}}}
    123 The -m parameter simply specifies a commit message that shows in the log. NEVER forget it. There is no way to edit once commited!
     123The -m parameter simply specifies a commit message that shows in the log. NEVER forget it. There is no way to edit it once commited!
    124124
    125125== Bored? ==
    126 There is some additional code in XMLPort() which you can uncomment. It will show you billboard set just above your ship. There is also a tick() function somewhere that gets called every frame. Maybe you can animate that billboard set by placing some of the variables from the commented code into the member section of the class (open TutorialShip.h for that matter)...
     126There is some additional code in XMLPort() which you can uncomment. It will show you a billboard set just above your ship. There is also a tick() function somewhere that gets called every frame. Maybe you can animate that billboard set by placing some of the variables from the commented code into the member section of the class (open TutorialShip.h for that matter)...