Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 11 (modified by bknecht, 16 years ago) (diff)

How to create Orxonox Levels

This is an outdated page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

TracNav(TracNav/TOC_CC_Tut)?

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.

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.

If you're interested in creating rooms and BSP-levels check out this page: Maping for Orxonox with GTK-Radiant?

Adding a menu entry

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).

Below there is a example for that file:

<Campaign>
  <name>default</name>
  <identifier>0</identifier>
  <description>The one and only default debug campaign</description>
  <WorldList>

    <GameMenu>
      <identifier>0</identifier>
      <name>GameMenu</name>
      <path>levels/Menu.oxw</path>
      <nextid>1</nextid>
    </GameMenu>

    <SinglePlayerWorld>
      <identifier>1</identifier>
      <nextid>2</nextid>
      <name>Demo Mountain Lake</name>
      <path>levels/sp_demo_mountain_lake.oxw</path>
      <menu-entry>1</menu-entry>
    </SinglePlayerWorld>

    <MultiPlayerWorld>
      <identifier>2</identifier>
      <nextid>0</nextid>
      <path>levels/mp_level_arena.oxw</path>
    </MultiPlayerWorld>

    ...

  </WorldList>
</Campaign>

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.

XML level file (OXW) syntax

Level files have the extension OXW (for OrxonoX World). The order of the things you add does not matter.

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.

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.

Important to know

  • Coordiane system: The y axis looks up not z!
  • Rotation: The rotation is described by a Quaternion. Quaternion(rotation, Vector(x,y,z)).

Example: Rotation around y by 90° → <abs-dir>3.14, 0, 1, 0</abs-dir>

Example

<WorldDataFile>
  <name>Meteroid</name>
  <screenshoot>pictures/menu/ss_meteroid_512x512.png</screenshoot>

  <LoadScreen>
    <BackgroundImage>pictures/load_screens/default.jpg</BackgroundImage>

    <ElementCount>16</ElementCount>
    <BackgroundPS>0,0,1.0,1</BackgroundPS>
    <BarPS>.65,.87,.3,.05</BarPS>
    <BarImage>pictures/load_screens/default_bar.png</BarImage>
  </LoadScreen>

  <WorldEntities>

    <TurbineHover>
      <name>Player</name>
      <abs-coor>522,-389,419</abs-coor>
    </TurbineHover>

    <SpaceShip>
      <name>Player2</name>
      <model>models/ships/reap_#.obj</model>
      <abs-coor>312.19, 172.36, 60.74</abs-coor>
    </SpaceShip>

    ...

    <MovieEntity>
      <abs-coor>413.5,183,36.3</abs-coor>
      <name>media/hero.mov</name>
      <fps>15</fps>
      <axis>90</axis>
      <size>75,38.5</size>
    </MovieEntity>

    ...

    <SkyBox>
      <name>Sky</name>
      <Materialset>pictures/sky/simple_space</Materialset>
      <Size>10000</Size>
    </SkyBox>

    <ModelEntity>
      <name>comet</name>
      <abs-coor>300,50,-400</abs-coor>
      <model>models/comet.obj, 2.5</model>
    </ModelEntity>

    ...

    <Terrain>
      <name>Meteroit</name>
      <abs-coor>300,50,0</abs-coor>
      <model>models/environments/meteorit.obj, 2.5</model>
    </Terrain>

    <Rotor>
       <name>testrotate</name>
       <model>models/environments/uranus.obj, 10</model>
       <abs-coor>50,0,0</abs-coor>
       <rotation>5,10,5</rotation>
    </Rotor>

  </WorldEntities>

  <Music>sound/music/allgorythm-once_upon_a_time_in_a_small_club.ogg</Music>

    <LightManager>
    <Lights>
      <Light>
       <diffuse-color>1,1,1</diffuse-color>
       <abs-coor>300,800,0</abs-coor>
      </Light>
      
      ...

    </Lights>
    <ambient-color>1,1,1</ambient-color>
  </LightManager>

  <GraphicsEngine>
    <GraphicsEffect>
        <LenseFlare>
          <name>lense flare</name>
          <add-flare-texture>pictures/lense_flare/sun.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens2.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens1.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens3.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens4.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens1.png</add-flare-texture>
          <add-flare-texture>pictures/lense_flare/lens3.png</add-flare-texture>
        </LenseFlare>
    </GraphicsEffect>
  </GraphicsEngine>

</WorldDataFile>

Load Screen

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.

World Entities

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.

Player

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.

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.

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.

Skybox

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.

Rotor

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.

Weather effects

Music

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.

Lights

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.

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.

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.