3D Game Programming All in One (Course Technology PTR Game Development Series)
You've already been exposed to the Mission Editor—a little bit here, a little bit there. As you've seen, the Mission Editor contains several subeditors: the World Editor, Terrain Editor, Terrain Terraformer Editor, Terrain Texture Editor, and Mission Area Editor. The main point of this section is to place objects in the game world and adjust them as required. To do this we will use the World Editor, which has two components: the World Editor Creator and its partner, the World Editor Inspector.
In the Mission Editor the normal movement keys can be used to control both the player and the camera. The right mouse button is used to rotate the camera or adjust the player's view.
Disk and file operations are carried out using the items in the File menu, as shown in Table 21.1. These include opening, saving, importing, and exporting.
Command | Description |
---|---|
New Mission | Creates a new empty mission with a default terrain and sky. |
Open Mission | Opens an existing mission for editing. |
Save Mission | Saves changes to the current mission to disk. |
Save Mission As | Saves the current mission under a new name. |
Import Terraform Data | Imports terraform rules from an existing terrain file. |
Import Texture Data | Imports terrain texture rules from an existing terrain file. |
Export Terraform Bitmap | (Only active from the Terrain Terraform Editor.) Exports the current terraform map to a bitmap. |
As is standard with windowed applications these days, there is an Edit menu that houses a variety of object and item editing commands. As you can see in Table 21.2, in addition to the ubiquitous Cut, Copy, and Paste functions, there are also commands that are used to access various settings for the editors.
Menu Item | Description |
---|---|
Undo | Undoes the last action in terrain or world editing. Not all actions can be undone. |
Redo | Redoes the last undone action. |
Cut | Cuts the selected objects in the World Editor from the mission to the Clipboard. |
Copy | Copies the selected objects in the World Editor to the Clipboard. |
Paste | Pastes the current clipboard contents into the mission. |
Select All | Selects all mission objects in the World Editor. |
Select None | Clears the current selection in the World and Terrain Editors. |
Relight Scene | Recomputes the mission's static lighting and applies it. |
World Editor Settings | Accesses the settings dialog box for the World Editor. |
Terrain Editor Settings | Accesses the settings dialog box for the Terrain Editor. |
Use the Camera menu, as described in Table 21.3, to change camera modes and adjust the camera fly mode speed.
Menu Item | Description |
---|---|
Drop Camera At Player | Moves the camera object to the location of the player, and sets the mode to camera movement mode (camera fly mode). |
Drop Player At Camera | Moves the player object to the location of the movable camera, and sets the mode to player movement mode (player mode). |
Toggle Camera | Toggles between player and camera fly movement modes. Your view will also switch to the location of either the player or the camera, depending on the mode. |
Slowest to Fastest | Adjusts the movement speed of the camera fly mode. |
The World menu is available by default and contains functions related to the World Editor—its capabilities will be described in the "World Editor" section, which is coming up next.
The Window menu is pretty straightforward, so it doesn't require a table to describe its functions. It is used to invoke each of the available subeditors.
World Editor
The World Editor provides a view of the 3D world. Objects in this view, like structures, interiors, shapes, and markers, can be manipulated with either the mouse or the keyboard.
There are three frames in the view: the World Editor Tree, the World Editor Inspector, and the World Editor Creator.
World Editor Tree
The World Editor Tree view is displayed in the frame in the upper-right screen corner in both the World Editor Inspector and the World Editor Creator. This tree displays the hierarchy of the mission data file. Objects selected in the Tree view will also be selected in the main view. Objects in the Tree view can be organized into groups.
There is a special group selection called the Instant Group, which is displayed with gray highlighting in the Tree view. This is the group in the Tree view where newly created or pasted objects are placed. Objects created from the World Editor Creator are also placed in the Instant Group. To change the current Instant Group, Alt+Click on a group in the Tree view.
World Editor Inspector
The World Editor Inspector lets you examine and specify properties of mission objects. When you select an object in Inspector mode, that object's properties are displayed in the frame at the lower right of the screen. After editing an object's properties, click the Apply button to commit those properties to the object. Dynamic properties can be assigned to objects with the Dynamic Fields Add button. Dynamic fields can be accessed via the scripting language and are normally used to add game-specific properties to objects.
World Editor Creator
The World Editor Creator displays an extra Tree view frame in the lower-right corner of the screen. This view contains all objects that can be created in a mission. Selecting an object from this list creates a new instance of it and drops the new object at the center of the screen (by default) or as specified by the selected Drop at command in the World menu, which is shown in Table 21.4.
Menu Item | Description |
---|---|
Lock Selection | Locks the current selection so that it cannot be manipulated from the World Editor view. |
Unlock Selection | Unlocks a locked selection. |
Hide Selection | Hides the current selection to help reduce visual clutter. |
Show Selection | Unhides hidden objects in the selection. |
Delete Selection | Deletes the currently selected objects. |
Camera To Selection | Moves the camera to the selected objects. |
Reset Transforms | Resets the rotation and scale on the selected objects. |
Drop Selection | Drops the selected objects into the mission according to the drop rule (see Drop Selection menu items that follow). If the object is already placed, it is picked up and dropped again. Drop at Origin: Drops newly created objects at the origin. Drop at Camera: Drops newly created objects at the camera's location. Drop at Camera w/ Rot: Drops newly created objects at the camera's location with the camera's current orientation. Drop below Camera: Drops newly created objects below the camera's current location. Drop at Screen Center: Drops newly created objects where the view direction hits an object. Drop at Centroid: Drops newly created objects at the center of the selection. Drop to Ground: Drops newly created objects to the terrain ground level at their current location. |
You can use both the mouse and the keyboard for editing, as shown in Table 21.5.
Operation | Description |
---|---|
Clicking on an unselected object | Deselects all currently selected objects and selects the clicked object. |
Clicking in empty space | Click-drags a box around objects, and selects all objects in the box. |
Shift-clicking on an object | Toggles selection of the clicked object. |
Mouse dragging a selected object | Moves the selected objects, either on a horizontal plane or sticking to the terrain, depending on the setting of the Planar Movement check box in the World Editor Settings dialog box. |
Control-clicking and drag | Moves the selected objects vertically. |
Alt-clicking and drag | Rotates the selected objects about the vertical axis. |
Alt-Ctrl-clicking and drag | Scales the selected object by a face on the bounding box. |
Gizmos are the visual representation of each object's three axes. When you select an object, and if you have gizmos enabled in the World Editor Settings dialog box, then they will appear centered on that object's local origin.
If gizmos are enabled, they can be clicked and dragged (as described in Table 21.6) in order to modify the object to which they are attached.
Operation | Description |
---|---|
Click-drag gizmo axis | Moves selection along the selected axis. |
Alt-click-drag gizmo axis | Rotates selection on the selected axis. |
Alt-Ctrl-click-drag gizmo axis | Scales along the selected axis. |
Terrain Editor
We use the Terrain Editor to manually modify the terrain height map and square properties by using a mouse-operated brush. The brush is a selection of terrain points or squares centered around the mouse cursor. Table 21.7 describes the functions available in the Brush menu.
Menu Item | Description |
---|---|
Box Brush | Uses a square-shaped brush. |
Circle Brush | Uses a circular brush. |
Soft Brush | Sets the brush so that its influence on the terrain diminishes toward the edges of the brush. The brush square colors vary from red, where the influence is greatest, to green, where the influence is least. The Terrain Editor Settings dialog box Filter view has controls that adjust the falloff. |
Hard Brush | Sets the brush so that the effect on the terrain is the same across the surface of the brush. All squares in the brush are the same red color. |
Size 1 1 to 25 25 | Sets the brush sizes. |
When we use the Terrain Editor, we modify the terrain as if we were piling dirt onto it or shoveling holes into the ground. Table 21.8 shows the operations available in the Terrain Editor via the Action menu.
Menu Item | Description |
---|---|
Select | Moves the brush in a painting motion to select grid points. |
Adjust Selection | Raises or lowers the terrain at the currently selected grid points as a group by dragging the mouse up or down. |
Add Dirt | Adds terrain "dirt" to the terrain at the center of the brush, raising the affected terrain area. |
Excavate | Removes dirt from the center of the brush. |
Adjust Height | Raises or lowers the area marked by the brush by dragging the mouse. |
Flatten | Sets the area marked by the brush to a flat plane height. |
Smooth | Smoothes the area marked by the brush—peaks are lowered and troughs are raised. |
Set Height | Sets the area marked by the brush to a constant height—the height is set using the Terrain Editor Settings. |
Set Empty | Makes a hole in the terrain in the squares covered by the brush. |
Clear Empty | Fills in any holes in the squares covered by the brush. |
Paint Material | Paints the current terrain texture material with the brush. |
Terrain Terraform Editor
The Terrain Terraform Editor uses mathematical algorithms to generate terrain height-fields (height maps). Heightfield operations are arranged in a stack, which is an ordered list of operations. Operations in the stack depend on the results of previous operations to produce new heightfields. The results of the final operation on the stack can be applied to the terrain using the Apply button.
There are two Terrain Terraform Editor frames. The top frame displays information about the currently selected operation, and the bottom frame shows the current operation stack. Between them is a pull-down menu for the creation of new operations. The first operation in the stack is always the General operation, which can't be deleted.
Table 21.9 shows the operations available.
Operation | Description |
---|---|
fBm Fractal | Creates bumpy hills. |
Rigid Multifractal | Creates ridges and sweeping valleys. |
Canyon Fractal | Creates vertical canyon ridges. |
Sinus | Creates overlapping sine wave patterns with different frequencies useful for making rolling hills. |
Bitmap | Imports an existing 256 by 256 bitmap as a heightfield. |
Turbulence | Jumbles the effects of another operation on the stack. |
Smoothing | Smoothes the effects of another operation on the stack. |
Smooth Water | Smoothes water. |
Smooth Ridges/Valleys | Smoothes an existing operation on edge boundaries. |
Filter | Applies a filter to an existing operation based on a curve. |
Thermal Erosion | Applies an erosion effect to an existing operation using a thermal erosion algorithm. |
Hydraulic Erosion | Applies an erosion effect to an existing operation using a hydraulic erosion algorithm. |
Blend | Blends two existing operations according to a scale factor and a mathematical operator. |
Terrain File | Loads an existing terrain file onto the stack. |
Terrain Texture Editor
The Terrain Texture Editor uses mathematical techniques to place terrain textures based on the heightfield at the bottom of the terraformer heightfield stack. The editor has three main interface elements on the right side of the screen. From top to bottom they are the operation Inspector frame, the Material list, and the Placement Operation list.
Terrain materials are textures that are added using the Add Material button. This will look for any texture (.png or .jpg) in a subdirectory of any directory named "terrains" (in this book, this also applies to a directory name maps). Once a material is added to the terrain, the user can select one of several placement operations that govern where that material will be placed on the terrain. They are shown in Table 21.10.
Operation | Description |
---|---|
Place by Fractal | Places the terrain texture randomly across the terrain based on a Brownian motion fractal operation. |
Place by Height | Places the texture based on an elevation filter. |
Place by Slope | Places the texture based on a slope filter. |
Place by Water Level | Places the texture based on the water level parameter in the Terraform Editor. |
Click the Apply button to commit the current texture operation list to the terrain file.
Mission Area Editor
The Mission Area Editor defines regions in the game that are used to constrain player travel. If we use mission areas in a game, we normally give warnings or disqualifications if a player leaves a mission area. Of course, you can probably find other uses for such a feature.
The Mission Area Editor displays an overhead height-map view of the current mission map in the upper-right corner of the screen. There are markers for mission objects, a box for the mission area, and a pair of lines denoting the current field of view. Clicking anywhere on the display will move the current view object (either camera or player) to that location in the mission.
To edit the mission area, select the Edit Area check box. This will display eight resizing knobs on the mission area box that can be dragged with the mouse.
Clicking the Center button will cause the terrain file data to be repositioned and centered at 0,0 in the center of the mission area box.
To mirror the terrain, click the Mirror button. This will put the Mission Area Editor in mirror mode. The Left and Right Arrow buttons adjust the mirror plane angle to one of eight different angles (two axis aligned, two 45-degree splits). Click the Apply button to commit the terrain mirroring across the mirror plane. Mirroring a mission area is a useful way to quickly create terrain for team-based games where each side would begin with identical terrain. This would stop either side from having a terrain advantage. You create the terrain for one side, and then simply mirror it for the other side.
Категории