Creating a Basic World

From C4 Engine Wiki

Jump to: navigation, search
Image:warning.jpg Obsolete Article

Some or all of the information on this page is obsolete and needs to be updated.

In this tutorial, you will learn the basics behind creating a simple world map which you can walk around. You will first create an empty new world map, then add a skybox followed by geometry and lighting. You will then add a marker for the player to spawn at and then finally register your world with the demo game build.


Contents

Preparations

C4 works on a Virtual File system. If you are unfamiliar with this, please read Using Pack Files and Virtual Directories before continuing. For the purposes of this tutorial, we will store our world information in Data/BasicWorld/. In the C4 root folder, navigate to the Data directory and create a folder called BasicWorld. Then create two more folders in BasicWorld, one called textures and the other world.


New World Setup

Start C4 using game.dll. If you're confused on how to do this, please read the Hello World tutorial. Once C4 loads, press tilde to access the C4 overlay.


Click on the C4 Tools Menu and select New World, or press Ctrl-N. For more information on this tool bar, please see C4 Menu.

Image:BW-MU-T-NW.jpg


A new world file is displayed.


Now click on the editor's World menu and select Save World As..., or press Ctrl-Shift-S.

Image:BW-MU-W-SWA.jpg


You'll start in the Data directory. Navigate to the folder BasicWorld/world and name the file bw-base00. Click Save.

Image:BW-SaveWorldAs04b.jpg


The name and virtual directory are then displayed on the top left of the screen.

Image:BW-SaveWorldAs05.jpg


To reduce the risk of running into name conflicts on the virtual drive, we tagged the file name with BW. To minimize the potential for loss of data, we will save this world on a regular basis. With each save for major changes, we'll tag a version number suffix. Hence why our initial save ends with 00. If the world gets corrupted at any point we can simply reload an older version.


The Skybox

Rendering

To add a skybox, we must access the root node in the Scene Graph. By default the Scene Graph is displayed in the third viewport. If the Scene Graph is not visible, right-click in the bottom left viewport and select Scene Graph from the context menu.

Image:BW-CM-SG.jpg


To read more about viewports, please check out the subheading Viewports in the World Editor page. To pan around the Scene Graph, click the middle mouse button and move the mouse. Alternatively, press ALT, click the left mouse button and move the mouse.

The Scene Graph will display all of the world's nodes in a hierarchical tree structure, with the Infinite Zone at the root, this is also referred to as the Root Node. As this is a new world file, no nodes have been added to the Scene Graph yet. By default there is always an Infinite Zone. With the Scene Graph visible, select the Infinite Zone node. It will be highlighted in green.

Image:BW-SG-IZ.jpg


Right-click the node and select Get Info... or press Ctrl-I. Alternatively, you may double left-click the node.

Image:BW-SG-IZ-HL.jpg


The Node Info dialog displays, defaulting to the Zone tab. Mark the Render skybox in this zone check box. Click OK to close the Node Info dialog.


Adding Textures

To add the skybox textures, the Skyboxes Page needs to be visible. From the main menu bar at the top, click on Page, select Skyboxes.

Image:BW-MU-P-SB.jpg


The Skyboxes Page is now displayed on the left of the world editor.

Image:page_skybox.jpg


Click on the icon. Notice that the cursor turns to a small crosshair when in the Scene Graph viewport. Click on the Infinite Zone node in the Scene Graph and the Skybox node is attached to the Infinite Zone node. The Scene Graph now looks like the following:

Image:BW-SG-SB-HL.jpg


Press the 1 key or click on the Image:tool1.gif button, to return to the Select Nodes cursor. Now right-click the newly created Skybox node and select Get Info... or press Ctrl-I. Alternatively, you may double left-click the node. The following should appear:


Click on the Skybox tab.


To add a texture, click on the arrow on the right of Positive X texture map name box, and the Texture Map dialog is displayed. The starting directory is your Data folder in C4. Navigate to Data/Demo/sky. Select Storm1.tex and Click Open.


Note that the Texture Map dialog displayed Data/Demo/sky/ as the path name, whereas the Node Info dialog displays the path as sky/Storm1.

Image:BW-NI-SB-04.jpg


Repeat the above step for the remaining texture map name boxes but with each subsequent storm texture. Then mark the Enable skybox glow check box. When finished, the dialog box should look like this:

Click OK, to close the dialog.


Results

To see the Skybox rendered in the Perspective viewport, press the Lighting Toggle button found at the top of the world editor.

Image:BW-LightingToggle.jpg]


Once toggled, you should see the following:

Image:BW-NI-SB-06.jpg


With the skybox successfully added, lets save our work. In the menu bar at the top of the screen, click World, then select Save World As.... Choose bw-base01 as the file name and click Save.


Geometry

Creating The Floor

In order to create a basic world that a player can navigate around it will need to have some basic structures in place. This will involve creating a floor to run on and barriers at the edges of the floor to stop the player from from falling off. The barriers will be invisible. A pillar will also be added to add a little flare.


Right-click inside the third (bottom left) viewport and select Left (+y) from the context menu.

Image:BW-CM-FR.jpg


From the Geometries page on the left, select the Box Geometry icon.

Image:Page_geometries.jpg


Moving back to the first (top left) viewport, we'll now draw the floor. Simply hold left-click the mouse and drag. When the box is large enough, release the left mouse button.


You can further reshape your box by using the Resize Tool (Key 4). The box should still be highlighted, however if not, you will need to re-select the box using the Select Tool (Key 1).

Image:BW-Resize-Tool.png


To ensure we have the correct measurements and size, select Page, Transform.

Image:BW-Transform-Menu.png


The Transform page is now displayed in the left of the world editor. It shows the Position, Rotation, and Size of any selected object. Ensure the floor is selected by using the Select Tool (Key 1) and enter the dimensions shown in the following image.

Image:BW-Transorm-Floor-Dimensions.png


Your floor should now look like the following.


Adding Materials

At the moment the floor is not textured. This is because when a primitive geometry is drawn, it is textured with the currently selected material. In this case, it is a new world file and no material has been selected so our default material is nothing. This can be changed in a couple of ways. First is by changing the texture that the default material uses. This will automatically update the box with a new texture. Second is by creating a new material and applying it to the primitive. Let's use the second approach.

Double click the current material on the left hand side.

Image:BW-Material-Page.png


The Material Manager is now displayed.


For this tutorial, three new materials need to be created. One for the floor, one for the invisible barriers and one for the pillar. We will use default textures that come with C4. For the first material, click on New, and a new material is created. Under Texture Map Settings, click the arrow by Texture map (primary).

Image:BW-Texture-Map-Primary.png


A dialog box appears for opening a texture. Navigate to Data/Demo/texture and select Stone1.tex. Click Open.


Under Normal Map Settings, click the arrow by Normal map (primary). Just as before, a dialog box appears for opening a texture. It'll load in the previous used directory which should be Data/Demo/texture. Select Stone1Bump.tex. Click Open.


Finally, we need to name our new material. Towards the bottom right corner of the Material Manager dialog box, you'll see a text box for Material name:. Type in floor. The Material Manager for our new floor texture should look like this.


Now we will repeat the above process all over again for two more additional materials. Click on New and create a second material. Set the Texture map (primary) to the Barrier.tex found in Data/Demo/texture. Change the name to barrier. When done, your Material Manager should like this.


Once again, click on New and create the third material for our pillar. For this material, we will add a bit of specular lighting. Click on the Specular tab. Under Specular Reflection Settings, check Specular color and adjust the Specular exponent to 80.

Image:BW-MM-05.png


Click back to the Diffuse tab and set the Texture map (primary) to Pillar.tex. Set Normal map (primary) to PillarBump.tex. Both textures are found in Data/Demo/texture. Change the name to pillar. When done, your Material Manager should like this.


Make sure that the floor material is selected in the left hand panel and click Close to close the dialog. Notice that the Material page has updated to the floor material.

Image:BW-Material-Page-floor.png


To apply the texture, ensure the floor is selected by using the Selection Tool cursor (Key 1). Then click Geometry, Set Material or press CTRL-M.

Image:BW-Floor-with-texture.png


You're floor should now look like the following.

Image:BW-FL-02.png


Go ahead and save your progress so far. Click World, Save World As... and name a new file bw-base02.


Adding Invisible Barriers

Open the Material Manager again and select the barrier material. Close the dialog box. Select the Box Geometry icon and create a new box for a wall in any of the view ports. Once the wall has been created, notice that the dimensions may not be correct in the other viewports.


You could manually resize the wall using the Resize Tool, however for our purposes we will manually input the dimensions and locations. With the newly created wall still highlighted, input the following into the Transform page.

Image:BW-Wall-TP-01.png


Your world file should now look like the following.


Lets repeat this process for the remaining three walls. Create three more Box Geometries with the barrier texture still highlighted. They should each respectively have the following data for their transformations.

Image:BW-Walls-TP-01.png


Your world should now look like the following.


Select all four new walls by holding down SHIFT and left-clicking each wall. Then right-click and select Get Info... or press CTRL-I. The Node Info dialog box opens. Under the Geometry tab, check Geometry is invisible and uncheck Render stencil shadow.


Click on the Collision tab. Check Exclude projectile collisions, Exclude vehicle collisions, Exclude camera collisions, and Exclude interaction tests.


Click OK. Notice how the walls have disappeared from the Perspective viewport. Unchecking the Lighting Toggle will redisplay it. Alternatively, when you select the walls you can see the highlighting.

Image:BW-Walls-Pers-01.png


Creating a Cylinder

Open the Material Manager and select the pillar texture. Select the Cylinder Geometry.

Image:BW-CY-00.png


Create a pillar roughly in the center of the floor. Under the Transform page, ensure the following data is entered.

Image:BW-CY-02.png


Your world should now look like the following.


Lets save our work. In the menu bar at the top of the screen, click World, then select Save World As.... Choose bw-base03 as the file name and click Save.

Lighting

If you click on the Toggle Lighting button, you will see that although the skybox has created a glow and the scene is not in total darkness, there are no dynamic lights being cast.

From the page menu, select Lights

Image:BW-MU-P-L.jpg

Add the Lights page to the panel on the left.

Image:page_lights.gif

Click on the Infinite Light button and add it to the scene. Use the top left viewport and click somewhere in the bottom right as seen in the image below. Once the node has been added it is made active, but it is always a good idea to click 1 on the keypad to enable the Select Nodes button.

Image:BW-LI-02.jpg

Click 2 on the keypad to enable the Select Nodes button and press Ctrl-2 to maximize viewport 2. We need to raise the height of the light so that is will shine down and light the scene.

Image:BW-LI-03.jpg

To move the light in the Z direction, click on the green arrow and move the light upwards so that it is higher than the top of the scene. Press Ctrl-2 again to return to the default four viewports.

Image:BW-LI-04.jpg

Looking closer at the light, notice that apart from the usual three axis manipulators there is an extra one, a yellow single line, this is the light direction. At the moment it may be pointing away from the column. Press Ctrl-3 to maximize viewport 3 and zoom right in to the light, remembering where the column is in relation to the light. It is important to zoom in close to the light as it makes selecting the light direction easier. Press 4 on the keypad to select the Rotate Nodes button and rotate the light direction to point towards the column.

Image:BW-LI-05.jpg

Press Ctrl-3 to return to the four viewports and notice that although the light is now pointing towards the column, it is not yet casting a shadow. The light needs to be angled down slightly. Without maximizing a viewport (in order to see the dynamic shadows added in the perspective viewport) select the light direction arrow in viewport 2.

Image:BW-LI-06.jpg

Slightly angle the light direction downwards. The shadows will be dynamically cast behind the column in the perspective viewport.

Image:BW-LI-07.jpg

So that the perspective viewport looks something like this.

Image:BW-LI-08.jpg


Add a Player or Spectator Spawn Marker

The world is now contains geometry and lights, in order to enable us to run the world and enter it, it will need a spawn or spectator marker adding. From the Page menu, select Markers.

Image:BW-MU-P-M.jpg

The markers page is added to the panel on the left.

Image:page_markers.gif

Add a Location Marker to the scene using the top left viewport, add it on top of the floor bottom right. As in the image below.

Image:BW-SP-01.jpg

Rotate the marker around so that the red arrow points towards the column, the red arrow is the direction the player will point when spawning.

Image:BW-SP-02.jpg

Finally decide what type of spawn marker is required, highlight the marker and press Ctrl-I, click on the Locator tab and in the Locator type text box add either spwn (for a character) or spec (for a spectator).

Click OK.

And Save the World file as Base-02

From the World menu, select Save and Play World

Image:BW-MU-W-SAP.jpg

Once the world file loads, press ESC to remove the toolbar, you can now move around the world as a character or spectator.


Register Your World to Show up in the Main Menu

This does not work in the C4 Demo as the Worlds.txt and Worlds.str files are not available to modify. C4 needs to know a list of files that it can add to the start menu, these are held in the file Worlds.txt which can be located in Import/Demo/game The file currently has three entries

'DEMO' "world/Demo/Demo"
'DUNG' "world/Dungeon/Dungeon"
'MPMP' "world/MP/MP"

Add an entry to the bootm of the file that creates a unique identifier followed by the virtual path where the world file is located, for example

'BASE' "world/Base"

Save the text file and open C4, from the tool menu select Import String Table..

Image:BW-MU-T-IST.jpg

Navigate to Import/Demo/game/Worlds.txt

Image:BW-REG-01.jpg

Click OK and close C4

Next time when you open C4, the Main Menu will display the Base world file to load.

Image:BW-MM-SNG.jpg

Personal tools