Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 12 and Version 13 of content/LevelHowTo


Ignore:
Timestamp:
Feb 10, 2011, 5:49:32 PM (13 years ago)
Author:
jo
Comment:

mixed up "tag" and "attribute"

Legend:

Unmodified
Added
Removed
Modified
  • content/LevelHowTo

    v12 v13  
    99 4. Open your level with your favourite editor.
    1010
    11 
    12 
    1311== About XML ==
    14 
    15 XML is a description language that looks similar to HTML. Like in HTML there are tags (in fact we are only using tags):
    16 <templates>                                                     <!-- Opening tag -->
    17     <Template link=lodtemplate_default />                       <!-- Opening and closing at once -->
    18  </templates>                                                   <!-- Closing tag -->
    19 A template can contain several tags. A tag is the place where a value is set.
    20  <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
    21 The syntax is tag=“vaule(s)“ if only one value is set the quotation marks are not necessary.
    22 
    23 Tip: Since your XML files do not have to be compiled you have to simply reload a level to view the changes. In Linux you can switch between the game and the editor by pressing [alt] + [tab]. If you insert only a little error and try to load a level the game will „stuck“. By pressing [alt] + [tab] you can leave the game and view the error message on the terminal.
    24 
    25 
    26 
    27 To create a level in Orxonox is really easy. One does not have to program anything or compile the code again, because our levels are created with XML-Files. There the objects in the level can be defined. On this page we explain what one can do with the XML-Files and how to create a new level for Orxonox with them.
    28 
    29 The objects we can add are rooms (BSP-files), spacecrafts (OBJ-files) and moving objects (MD2-files). How to that exactly is best explained with the examples below.
    30 
    31 If you're interested in creating rooms and BSP-levels check out this page: [wiki:MappingForOrxonox Maping for Orxonox with GTK-Radiant]
    32 
    33 == Adding a menu entry ==
    34 Before you can play a level in Orxonox you have to add the level as a menu entry in the game. To do that you have to alter the DefaultCampaign.oxc file in the data/levels directory (or data/worlds in older versions).[[br]]
    35 
    36 Below there is a example for that file:
     12XML is a description language that looks similar to HTML. We use tags to describe objects:
    3713{{{
    3814#!xml
    39 <Campaign>
    40   <name>default</name>
    41   <identifier>0</identifier>
    42   <description>The one and only default debug campaign</description>
    43   <WorldList>
    44 
    45     <GameMenu>
    46       <identifier>0</identifier>
    47       <name>GameMenu</name>
    48       <path>levels/Menu.oxw</path>
    49       <nextid>1</nextid>
    50     </GameMenu>
    51 
    52     <SinglePlayerWorld>
    53       <identifier>1</identifier>
    54       <nextid>2</nextid>
    55       <name>Demo Mountain Lake</name>
    56       <path>levels/sp_demo_mountain_lake.oxw</path>
    57       <menu-entry>1</menu-entry>
    58     </SinglePlayerWorld>
    59 
    60     <MultiPlayerWorld>
    61       <identifier>2</identifier>
    62       <nextid>0</nextid>
    63       <path>levels/mp_level_arena.oxw</path>
    64     </MultiPlayerWorld>
    65 
    66     ...
    67 
    68   </WorldList>
    69 </Campaign>
     15<templates>                                 <!-- Opening tag 1 -->
     16    <Template link=lodtemplate_default />   <!-- Opening and closing tag 2 at once -->
     17</templates>                                <!-- Closing tag 1 -->
    7018}}}
    71 Now to add your level you have to add an !SinglePlayerWorld (or !MultiPlayerWorld) entry to the !WorldList. Be sure to add an identifier a name and the most important: the path of your OXW-file. The number of the identifier and the menu-entry have to be incremented. Close every <tag> you open.
    72 
    73 == XML level file (OXW) syntax ==
    74 
    75 Level files have the extension OXW (for '''O'''rxono'''X''' '''W'''orld). The order of the things you add does not matter.
    76 
    77 At the beginning of every file you have to put the tag <WorldDataFile> and close it in the end. Then you put in the name of the level and the screenshot (or picture) you want to show in the menu. You can check out the example below to see how it works.
    78 
    79 Every tag has to be closed and stuff which is written in a tag is related to that tag. If open a tag <name> you have to be sure you open it at the right place. In the !WorldDataFile tag the name tag is refering to the name of the level and in the !SpaceShip tag for example it refers to the name of that space ship. So be careful where to put your tags and when you have to close them.
    80 
    81 === Important to know ===
    82  * '''Coordiane system:''' The y axis looks up not z!
    83  * '''Rotation:''' The rotation is described by a Quaternion. Quaternion(rotation, Vector(x,y,z)).[[br]]
    84 Example: Rotation around y by 90° -> <abs-dir>3.14, 0, 1, 0</abs-dir>
    85 
    86 
    87 === Example ===
     19                                                       
     20A tag can contain several attributes. An attribute is the place where a value is set.
    8821{{{
    8922#!xml
    90 <WorldDataFile>
    91   <name>Meteroid</name>
    92   <screenshoot>pictures/menu/ss_meteroid_512x512.png</screenshoot>
     23<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
     24<!-- Quite a lot attributes. -->
     25}}}
     26The syntax is attribute=“vaule(s)“. If only one value is set, the quotation marks are not necessary.
    9327
    94   <LoadScreen>
    95     <BackgroundImage>pictures/load_screens/default.jpg</BackgroundImage>
    96 
    97     <ElementCount>16</ElementCount>
    98     <BackgroundPS>0,0,1.0,1</BackgroundPS>
    99     <BarPS>.65,.87,.3,.05</BarPS>
    100     <BarImage>pictures/load_screens/default_bar.png</BarImage>
    101   </LoadScreen>
    102 
    103   <WorldEntities>
    104 
    105     <TurbineHover>
    106       <name>Player</name>
    107       <abs-coor>522,-389,419</abs-coor>
    108     </TurbineHover>
    109 
    110     <SpaceShip>
    111       <name>Player2</name>
    112       <model>models/ships/reap_#.obj</model>
    113       <abs-coor>312.19, 172.36, 60.74</abs-coor>
    114     </SpaceShip>
    115 
    116     ...
    117 
    118     <MovieEntity>
    119       <abs-coor>413.5,183,36.3</abs-coor>
    120       <name>media/hero.mov</name>
    121       <fps>15</fps>
    122       <axis>90</axis>
    123       <size>75,38.5</size>
    124     </MovieEntity>
    125 
    126     ...
    127 
    128     <SkyBox>
    129       <name>Sky</name>
    130       <Materialset>pictures/sky/simple_space</Materialset>
    131       <Size>10000</Size>
    132     </SkyBox>
    133 
    134     <ModelEntity>
    135       <name>comet</name>
    136       <abs-coor>300,50,-400</abs-coor>
    137       <model>models/comet.obj, 2.5</model>
    138     </ModelEntity>
    139 
    140     ...
    141 
    142     <Terrain>
    143       <name>Meteroit</name>
    144       <abs-coor>300,50,0</abs-coor>
    145       <model>models/environments/meteorit.obj, 2.5</model>
    146     </Terrain>
    147 
    148     <Rotor>
    149        <name>testrotate</name>
    150        <model>models/environments/uranus.obj, 10</model>
    151        <abs-coor>50,0,0</abs-coor>
    152        <rotation>5,10,5</rotation>
    153     </Rotor>
    154 
    155   </WorldEntities>
    156 
    157   <Music>sound/music/allgorythm-once_upon_a_time_in_a_small_club.ogg</Music>
    158 
    159     <LightManager>
    160     <Lights>
    161       <Light>
    162        <diffuse-color>1,1,1</diffuse-color>
    163        <abs-coor>300,800,0</abs-coor>
    164       </Light>
    165      
    166       ...
    167 
    168     </Lights>
    169     <ambient-color>1,1,1</ambient-color>
    170   </LightManager>
    171 
    172   <GraphicsEngine>
    173     <GraphicsEffect>
    174         <LenseFlare>
    175           <name>lense flare</name>
    176           <add-flare-texture>pictures/lense_flare/sun.png</add-flare-texture>
    177           <add-flare-texture>pictures/lense_flare/lens2.png</add-flare-texture>
    178           <add-flare-texture>pictures/lense_flare/lens1.png</add-flare-texture>
    179           <add-flare-texture>pictures/lense_flare/lens3.png</add-flare-texture>
    180           <add-flare-texture>pictures/lense_flare/lens4.png</add-flare-texture>
    181           <add-flare-texture>pictures/lense_flare/lens1.png</add-flare-texture>
    182           <add-flare-texture>pictures/lense_flare/lens3.png</add-flare-texture>
    183         </LenseFlare>
    184     </GraphicsEffect>
    185   </GraphicsEngine>
    186 
    187 </WorldDataFile>
    188 }}}
    189 
    190 === Load Screen ===
    191 While your level file is read and the entities are created the game will show a loading screen you will have to define inside the <LoadScreen> tag. The element count is the number of elements the loading bar will have and the bar image can also be defined. Of course you can also define the position of the two elements (background and bar) on the screen. Check out the example to see how this works.
    192 
    193 === World Entities ===
    194 World entities are all the objects we have in a level. That includes space ships, meteors, animated textures and so on. Since all those objects have the !WorldEntity class in common, we have a list of all the world entities in our XML-file. This list is defined in the <WorldEntities> tag.
    195 
    196 ==== Player ====
    197 To add your player to the scene all you have to do is define a space ship or a turbine hover or any other kind of craft you want to play in. We make a difference here because not every ships is controlled the same way. If you define a space ship with the turbine hover model, the hover will be acting like a space ship. Keep that in mind when you define new space ships and players in your level.
    198 
    199 As seen in the example above the turbine hover has it's own tag and all you have to do is give it a name and of course fell it where its position should be. This can be achieved by using the <abs-coor> tag and define x,y and z coordinates of the position you want to have your turbine hover to be created.
    200 
    201 Inside of the !SpaceShip tag we see that a model is defined as well, because we have different models we could use as a space ship. These models can be found in the data/models directory and can be every model of your choice.
    202 
    203 ==== Skybox ====
    204 The skybox is a world entity. You should only use one skybox, more of them wouldn't make sense. The interesting attributes of the skybox are shown in the example: The size is important for the dimension in every direction. If you choose a size which is higher than the clip of the camera, the skybox will not be visible completely. The material set is also very important. There you define which skybox should be chosen for your level. A skybox is built from six images with the extension ''neg'' or ''pos'' to define front and back and with ''x'', ''y'' and ''z''. The front skybox picture file from the example would be called simple_space_pos_x.jpg.
    205 
    206 ==== Rotor ====
    207 Rotor is a object which just rotates around a given axis. What you have to do is define the position and direction of the model and the source file of the model itself like you do it with most world entitites. In addition you define the speed the model will rotate around x, y and z axis in the game. This is done in the rotation tag.
    208 
    209 ==== Weather effects ====
    210 ...
    211 
    212 === Music ===
    213 Music is no world entity. All you have to do is to define a sound file you want to play in the level. This can be an ogg file like in the example or a wav or an mp3 file. Feel free to play your own music in the level.
    214 
    215 === Lights ===
    216 You can put several lights into the level. You want that because the level shouldn't be in complete darkness. Most of the time it's advised to put the light far away from the actual scene to put light everywhere. To make other things lighter, just add another light a lot closer to the previous.
    217 
    218 You have to experiment with the light sources and it is advised not to use too many. Lights should be locked at as suns and not as street lamps.
    219 
    220 First you open the !LightManager tag. Inside you have the Lights tag where you define your list of lights. Each light has a position (abs-coor attribute) and a diffuse color (1,1,1 is white). Play with the values to get your light color of choice. Outside the Lights tag you can define the ambient light color which is important for the light in the whole level. You should play with that option as well.
     28Tip: XML files do not have to be compiled. If you changed a level file (and didn't forget to save it), you simply have to reload the level to view the changes. In Linux you can switch between the game and the editor by pressing [alt] + [tab]. If you insert only a little error and try to load a level the game will „stuck“. By pressing [alt] + [tab] you can leave the game and view the error message on the terminal.