====== TUTORIAL 2.1 Level Creation ====== ===== TUTORIAL 2.1 – Basic level creation ===== To create levels for the HPL engine you use a 3D editor. Make sure you have read tutorial 1 so that you have your editor properly setup. Lets get started, open your 3D editor and make sure units are set to meter. Create a cube in the centre of the project and make it 6m*3m*6m(for me that is width, height and depth). This will be the room making up our first test level. First thing you need to do is to reverse/invert the normal, resulting in them facing the centre of the cube rather than facing away from the centre. Make sure you enable Backface culling so that you can see into the polygon(when it's textured that is). Now extract/separate the faces. If done right all the sides of the cube should be separate objects that you can select. This you do because HPL requires a level to not be a 100% solid object and also because we want to have different textures on the walls and ceiling. You can only have one texture on a single object. Lets texture the cube, from now on called the room. Use the “tut_floor_ceiling_texture.jpg” for your ceiling and floor, use “tut_wall_texture.jpg” for your four walls. You can find them in tutorials/tutorial_2. Last, but not least, the room needs a light. Create a single point light and place it in the centre of the room, perhaps closer to the ceiling than the floor. Some specifics on lights, there are 4 things you can do with basic lights in your 3D editor. I will not go into details on creating more advanced lights, this is only the very fundamental. The colour, you set the colour for the light as you normally do. For our light give it a small touch of yellow but keep it bright white. The next three things that you can do are not your normal way of using lights when 3D editing. To tell the game what size the light is, how much specular it has and if it casts a shadow you use the X, Y and Z settings for the lights SCALE. Scale X: The size in meters, 0 → as high as you like(or almost at least) Scale Y: The amount of specular, 0 → 1 where 1 is full specular. Scale Z: Cast shadow, 0 or 1. 0 means no shadow, 1 means cast shadow. There is no in between. For our light, set X to 5 and leave Y and Z to 1. Save the project to anywhere you want. And finally export the level as a collada file to your mystuff directory. Name the level “mystuff_level.dae”. Let's see if the level works, launch HPLHelper and select the “Scenes” tab, click browse and locate your “mystuff_level.dae” file. Click view and the level should show up. If it does not show up backtrack and see what could be wrong. The best way to quickly find what can be at fault is to open “hpl.log” located in the My Documents/Penumbra Overture/EpisodeX/ directory. Scrolling down you should see an error saying what the problem was, often it's that it could not create or locate a file. This usually means that you have named something wrong or simply have forgotten to add your directories to the resource.cfg file using the “Settings” tab in HPLHelper. This concludes how to create a simple room. Now we are going to look at how you open the level in Penumbra. ===== TUTORIAL 2.2 – Adding player start and references ===== To tell the game where the player is going to be when he enters the level we will need to create a small cube. Create a new cube, perhaps 0.5m*0.5m*0.5m the size is not important, it should be usable and not take up much space. The game uses the centre of the cube to know where the player is going to start. Move the cube down to the floor, making the centre of the cube appear slightly above the ground. Move the cube along the floor so that it's closer to one of the walls, simply because we do not want the player to start in the centre of the room. Now we need to tell the game that this is a special cube, rename the cube node to “_start_link1”. “_start” is the string telling the game that this is a start location and “_link1” is the name of the location. Save the project and export the level to collada again and overwrite your previous “mystuff_level.dae”. To see if the level is working properly with the new start location, go back to HPL Helper and go to the Scene tab. Open your level BUT before you click view, enter “link1” into the startposition: now you can click view and you should start at the location of your “_start “cube. If you want to face in another direction at the start of the level, rotate the _start cube in your 3D editor. Let's move on an get a model into the level as well. When we have done this we will test the level by actually playing it. In your 3D editor, select import collada and locate the “ref_mystuff_woodbox.dae “ reference file that you created in tutorial 1.4. This should import the file into your levels centre, make sure the model is called _ref_mystuff_woodbox_woodbox1 as we said it should be named in tutorial 1.4. Move the reference to a location of your choice, preferably not at the same place as the player location! The model will appear in the game exactly where you place the reference, so make sure the whole object is inside the room. Save the project and export the level overwriting your previous “mystuff_level.dae” file. Using the “Scenes” tab in HPL Helper, you can open the level and you should see a big wooden box in it. If so, congrats on getting this far! To test the level we will need to edit the “settings.cfg” file located in the My Documents/Penumbra Overture/EpisodeX/ directoy. Open the file in a regular text editor. Locate the following void OnStart() { } As you can see this area already has some script in it: //SET UP LINKS SetupLink( "warp", //Link name "mystuff_level.dae", //New map "link1", //Positon on new map "","", //Stop and end sound. 0.5f , 0.5f);//Fade out and in time (seconds). Link name, this is the area that the player can interact with to initate the loading of a new level. New map, the name of the new level and link1 is the area where the player will start when entering that new level. If you so far have named you level ”mystuff_level.dae” and added a link1 _start to it the script is ready to be used with only a slight modification. Links can also be used to travel between different locations in a single level. To try this out we are going to use the ”mystuff_level.dae” we already have and add a new area to it. Open the project in your 3D editor, create a new cube that is about 1m*1m*1m in size and place it in an location on the opposite side of the room from your ”_start_link1” cube. Rename this new cube to ”_area_link_warp”. This will create an area in the game that will bring up the door icon when you are close, if you click with the left mouse button you will activate the area and be transportaed to link1 in the map ”mystuff_level.dae”. Since this is the map you are already in you will simply be warped back to your starting location. To make it easier finding the ”_area_link_warp” cube, lets add a point light where the area is. Make it bright green and set the X scale to 2, making the radius of the light 2 meters. Export your level and overwrite the old ”mystuff_level.dae”. Make sure that you have copied the script file to the same location and that you have neamed it ”mystuff_level.hps” as we said in the beggining of this chapter. Now launch Penumbra and start a new game, you should see a green light and if you walk over to it and interact you should be transported back to the start. Lets do the same but use two different levels. First go back to your current project in the 3D editor and create another cube that you place in another location and rename it ”_area_link_travel”. Do the same here that you add a light to make it easier finding the location, this time make it bright blue. Export this level and overwrite the previous ”mystuff_level.dae”. Now, in your 3D editor delete the refernece for the wood box and also change the main lights in the room(the ones that are 5 meters) to any other bright colour you like. We do this simply to quickly make a level that looks different from the one we already have. Continue on and rename you ”_start_link1” to ”_start_newmap” and change your ”_area_link_warp” to ”_area_link_travelback” we do this not because we have to but because you need to practice renaming and later editing the script. Last delte the ”_area_link_travel” cube and the light for it as well. Export this level to collada and name it ”mystuff_level2.dae”. You should now have to maps, mystuff_level1.dae and mystuff_level2.dae. Go back to your ”mystuff_level.hps” script file and select the SET UP LINKS part and make a copy of it, your script file should then look like this: void OnStart() { //SET UP LINKS SetupLink( "warp", //Link name "mystuff_level.dae", //New map "link1", //Positon on new map "","", //Stop and end sound. 0.5f , 0.5f);//Fade out and in time (seconds). //SET UP LINKS SetupLink( "travel", //Link name "mystuff_level2.dae", //New map "newmap", //Positon on new map "","", //Stop and end sound. 0.5f , 0.5f);//Fade out and in time (seconds). } Edit the second SET UP LINKS so that the link name is ”travel”, the new map is ”mystuff_level2.dae” and position changed to ”newmap”. Save the script file. You now have the script file ready for ”mystuff_level.dae” but you will also need one for your new ”mystuff_level2.dae”. Make a copy of the script file and rename it ” mystuff_level2.hps”. Open this new script file in a text editor and delete one of the SET UP LINKS so that you get a script file that looks like this: void OnStart() { //SET UP LINKS SetupLink( "travelback", //Link name "mystuff_level.dae", //New map "link1", //Positon on new map "","", //Stop and end sound. 0.5f , 0.5f);//Fade out and in time (seconds). } Rename the link, new map and position to be as they are above. ”travelback” is the name of the link in you new ”mystuff_level2.dae” level that will activate to take you back to your first map and make you start in ”link1”. Save this script file. You should now have two levels and two script files. To test if it works, launch Penumbra and start a new game. If you click the green area you should warp inside your first level, if you click the blue area you go to the new level with out a wooden box in it and if you click the green area in it you should go back to the first level again. If it worked, a big congratulations. If not, try again! These two levels and their script files can be found in the ”tutorials/tutorial2/safety”. This directory is not added to the resource.cfg so you can't run the levels from there, I added them just incase you can't get it to work so that you would have something to look at and investigate to get it to work. Good going reading through this tutorial, it's the dullest and probably most difficult of them all. But now that it's over you should be able to create levels that have the right basic functions. In the three last tutorials we will look at material/texture files, particle effects and in the final one do some basic scripting using everything we have learned so far.