It's great that we have finally finished creating the house, but now we want to take a look outside! Of course, if we actually stepped outside, we would find ourselves in an eternal void. We're going to create an outdoor environment to change this.
This time, we will make use of the basic building block to create our courtyard. Create a new block by Object / Add Cube / Large and scale it so that our house sits nicely in the middle. After you have scaled the block, do not forget to Edit / Hollow Block it .
A sky would make our outdoor environment more complete, which means we need to remove the ceiling from the hollowed block first. In order to access the ceiling component for removal, we have to use the Scope Down function again. After scoping down, select the ceiling component and press the [Delete] button on your keyboard to remove it. Texture the remaining walls of the courtyard by selecting each individual component followed by a corresponding texture, similar to how we textured the house. Remember to Scope Up after you have finished! We must add another block by Object / Add Cube / Large to our level to form the sky. Scale this new object so that our house and courtyard are completely contained within it. Hollow the cube and apply the texture named sky_gorge to create a skycube. Enable File / Preferences / Options / Object Options / Sky Cube to allow WED to render how the sky cube texture will appear in the 3D View window. Alternatively, use one of the two animated sky textures available in the standard.wad to create a skydome. For an in-depth description of the difference between the two types of skies, refer to the 3DGamestudio Manual.
The final thing we need, to complete our newly created environment, is to connect the two rooms together! We will use another new cube to perform an operation called CSG Subtract. CSG Subtraction works similar to a cookie cutter where the selected shape removes portions or sections of another block or group of blocks. This process is particularly useful for creating gaps in a wall for windows, doors, and gates. Create a Object / Add Cube / Large and scale it appropriately to the dimension you would like to cut out of the wall. Keep in mind that the texture of the cutter block will be assigned to the cut planes! Simply line up the block with the wall and Edit / CSG Subtract. This hole in the wall will serve as the portal between the two rooms for this exercise.
Our level is starting to look better now isn't it? We can add some dynamics to our environment by adding static lights to the level. Lights provide the flexibility for allowing particular areas to be emphasized for specific scenes. Light calculations can take a long time for the compiler to process, so try to make effective use of them!
We're going to first start off by adding one light source to our room. I will add a light fixture prefab to my house for realism and a light source beside it. Gamestudio offers a library of prefabs which can be accessed under Object / Add Prefab.
To add a light to our house, select Object / Add Light and a light bulb will appear in the level. Take note that the light bulb is only a visual representation of a light source within WED. Place the light bulb somewhere within the house and take a look at the Properties Panel of the light to modify its configurations. Fine tune the light's properties to achieve the desired effect. You should notice when you alter the Range parameter that the circle it is encompassed by expands and contracts accordingly. You can use this as a guide to give you an idea of the range of effect that the light bulb will have.
Shadows are created when a light ray's path is blocked. You can experiment with this by adding prefabs to the level. I have added a bed, chair, desk, and lamp to my house which can be accessed from Gamestudio's prefab library under Object / Add Prefab.
Let's add sunlight to our courtyard room which will provide a sense of the time of day. Open the File / Map Properties / Sun of the level to bring up the Sunlight parameters for our level.
The first row of fields defines the Sun's colour. The second row of fields defines the colour of the ambient light throughout the level. Higher values will cause a greater overall brightness throughout your level. In most cases, each ambient colour value should be the same unless you want your level to have an unnatural hue.
Altering the values of the Sun Azimuth determines the location of the Sun around the level using the polar coordinate system. Altering the values of the Sun Elevation determines the angular elevation from the horizon. Gamestudio can actively manipulate these parameters to emulate passing time; however, this is beyond the scope of the tutorial as it requires scripting.
The above diagram uses a Sun Azimuth of 315.000 and a Sun Elevation of 40.000. Experiment with the Sun's azimuth
and elevation values if you are still unsure about how they correspond into the game engine.
Of course, you normally want to use your own textures and models instead of the collections that come with Gamestudio.
For using a texture, you must first create it or get it from somewhere. Surface textures are in the image formats PCX, BMP, TGA, or DDS, and must be a power of 2 in horizontal and vertical size (like 256x256, 256x1024, 512x512 ..). Have all your textures together in a folder - preferably a sub-folder of your work folder. For instance, when your map is in the folder "mymap", create a subfolder such as "mymap\textures" and copy your texture files into it. Then add the folder to your map: Open the Presets window, right click on Textures and select Add Folder. All image files inside that folder are now available as textures in the Textures window. Just double click on a texture for applying it to the selected block. You can also open a WAD texture collection or create a new WAD under Presets / Textures.
For adding your own models, either create them in a model editor of your choice and then import them in Gamestudio's model editor MED. Or create them directly in MED, as described in another part of this tutorial. Files of the types MDL or OBJ (for models), PCX, BMP, TGA, DDS (for sprites), WMB (for buildings), or HMP (for terrain) can be directly placed in your level. Just copy them directly into your work folder for making them available to WED. You can then for instance place a model in your level just with a right click onto the desired position in a 2D view and selecting Add / Model. You can also have your models in a subfolder - add that folder, similar to the texture folder above, with Presets / Path / Add Path.
This section is only applicable to users with the Commercial or Pro Edition of Gamestudio. If you are using a lower edition, you will have to upgrade to take advantage of this feature. Alternatively, the 30-day trial version has shader support.
Shader functionality adds another dimension of graphics to games by rendering realistic effects, such as water ripples, at runtime. In this section we will cover using the normal mapping shader included with Gamestudio.
If you have purchased the Hi-Res WAD Collection for Gamestudio you simply need to add the second WAD file named hires_nm.wad to add shader functionality. The Hi-Res WAD Collection is a replacement to the standard.wad with improved images and normal and specular bump mapping support. If you do not own the collection, you need to produce your own texture along with an additional normal map image. You can find a normal map plugin for most graphic editors or by using conversion software to produce normal maps for textures.
These two textures are an example of a surface texture and its normal map, respectively. Nvidia's Normal Map Filter is a commonly used plugin to generate normal map textures within graphic editors such as Adobe Photoshop. I will use these two textures to demonstrate how to apply shaders to a level. You must name the normal map image to the same filename as the surface texture with a "_n" appended to it. I have named my surface texture brick.bmp and its normal map brick_n.bmp.
!! The texture name (along with the extension) must not exceed the 15 character limit in WED!
Let's begin now; we will use the same level which we created earlier to apply this texture to. I will create a new WAD file in WED named shader.wad where I will add my surface texture. Create a new WAD by navigating to the Presets tab in the Project Pane then right-clicking the Textures Folder and selecting New WAD. Navigate to the Textures tab in the Project Pane and expand the heading named shader.wad to reveal the contents of the WAD file. From here, add the surface texture and Save WAD by right-clicking the empty black space under the shader.wad heading.
Now we need to add the normal map texture to our level, follow the same procedure in the previous paragraph to create a new WAD named shader_nm.wad. Add the normal map texture to this WAD file. After you have done that, apply the surface texture to the walls of our house.
Although we have a surface map texture and its normal map texture, it isn't sufficient for us to render normal map shading. Gamestudio needs to know what to do with these textures which are defined in a material script. We will use the mtlFX.c shader collection included with Gamestudio for our material script. This file contains all the predefined shaders that come with Gamestudio. If you already have a Lite-C script for your level, ensure that you include the shader library by adding this code to the top of your script: #include <mtlFX.c> and selecting that file in the File / Map Properties. Otherwise, if you do not have a script for this level, you can generate one which includes the mtlFX.c shader collection, by navigating to File / Map Properties and selecting the New Script button beside the Script text field. A new window will open asking which script you want to create. Select A7_lite_C_project.
We can finally apply a material shader to our level! Let's go back to our level and add a material property to the walls we just applied the surface textures to.
To apply a material property to a block, select the object and click the Choose button next to the Material field in the Properties Panel. A window will appear asking which material Gamestudio should use. Select either mtl_bump or mtl_specBump. You may have to Scope Down to access the individual block to apply a material to it!
!! If you don't see the list of materials, you missed a step! Go back and add the shader library to WED!
In order for the material to work properly, you need to have at least one dynamic light source within its range. If your light sources are within range to the blocks with a material attached, you need to ensure that they have the Dynamic flag checked in the Properties Panel. Another dynamic light source that a material can react to is the Sun, which we have already added to our level in the previous section.
If you applied the shader correctly, your house might look something like the above diagram.
Congratulations! You have now completed the Gamestudio World Editor Essentials tutorial. Be sure to visit Gamestudio's website for the latest news, patches, additional resources, and technical support.