Changes between Version 14 and Version 15 of pps/tutorial_basic
- Timestamp:
- Oct 1, 2008, 10:35:54 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pps/tutorial_basic
v14 v15 58 58 The 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: 59 59 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: 61 61 {{{ 62 SetConfigValue('' variable name'', ''default value'').description(''description text'');62 SetConfigValue(''member variable name'', ''default value'').description(''description text''); 63 63 }}} 64 64 … … 70 70 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]] 71 71 72 === First run test andthe 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 === 73 We 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]] 74 74 You 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]] 75 75 76 76 === 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: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]''' 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: 78 78 {{{ 79 79 config TutorialShip reloadTime_ 0.1 … … 83 83 === Declare XML loading === 84 84 This 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'' parameterwhich tells the underlaying !SpaceShip whether to visualise the special effects. The syntax for XML parameters is:85 Find 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: 86 86 {{{ 87 87 XMLPortParam(classname, parameter name as string, setSpecialEffects, hasSpecialEffects, xmlelement, mode); … … 95 95 # Some unimportant parameters. Better don't mess with them ;) 96 96 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. 98 98 name-of-your-parameter="true" 99 99 /> … … 101 101 102 102 === Logging messages === 103 Stay in the ''XMLPort()'' function and add a statement a t the endto display a log message with output level 3:103 Stay in the ''XMLPort()'' function and add a statement after the SUPER call to display a log message with output level 3: 104 104 {{{ 105 105 COUT(3) << "My name is Bond. James Bond." << std::endl; … … 111 111 112 112 == 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 itlike "TutorialShip_MyName.cc":113 Subversion 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": 114 114 {{{ 115 115 cd orxonox/src/orxonox/objects … … 121 121 svn ci TutorialShip_Blofeld.cc -m "A message" 122 122 }}} 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!123 The -m parameter simply specifies a commit message that shows in the log. NEVER forget it. There is no way to edit it once commited! 124 124 125 125 == 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)...126 There 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)...