Creating Camera Scripts with GtkRadiant |
by Dairyman |
Once you have implemented scripted cameras in Quake 3, using the Implementing Scripted Cameras tutorial, you have to create the camera scripts to make it usable. While you can create a script by hand, using a text editor, getting the position of the points correct is difficult. Using the GtkRadiant level editor with the camera plugin is much easier and will allow you to create scripts very quickly.
As of this writing, the latest version of GtkRadiant ( v1.5 ) did not have the camera plugin packaged with it. Instead you must use the stable 1.4 version, which comes with a full suite of plugins.
To create a camera script you must start GtkRadiant and load the desired map file into it. Then select the camera plugin from the Plugins button. You will see :
The first time you do this you will be creating a new camera script so you select one of the New ... Camera options. We will look at the creation of all three types of cameras, starting with New Fixed Camera.
New Fixed Camera
After selecting this camera type, the Camera Inspector will start, showing the following dialog box.
The Name: field is the name you want assigned to this camera. This name is not used anywhere in the script but it does allow you to identify which camera script you are working on at the moment. In the Edit: field the camera path is given the default name position.
When first started the Camera Inspector is in Add Points mode, as shown by having this option selected. In this mode if we left click anywhere on the map the camera will be positioned there.
Each time we left click on the map the camera position will be changed to that location. The map view that you click on determines which coordinates of the camera are altered. If you are in the XY view then the X and Y coordinates of the camera are altered. The Z coordinate is left unaltered. In the YZ view only Y and Z coordinates are changes and in the XZ view the X and Z coordinates are altered.
By selecting the Edit Points option we can move the camera position around on the map using the mouse.
In this mode we must left click and hold on the Fixed point marker shown in the map and drag it to it's new position. Again, the map view we use determines which camera coordinates are altered.
New Interpolated Camera
When the Camera Inspector starts with this camera type we see :
Again, we are in Add Points when the Camera Inspector starts. An Interpolated Camera has two positions for the camera, the Start and the End. When we left click on the map we alternate between moving the Start interpolated position and the End interpolated position to that location. A line is drawn between the two points so you can see the path the camera will take.
When the camera moves it will go from the Start interpolated position to the End interpolated position. As usual, the map view we click on determines which coordinates of the position are altered. If you are in the XY view then the X and Y coordinates of the position are altered. The Z coordinate is left unaltered. In the YZ view only Y and Z coordinates are changes and in the XZ view the X and Z coordinates are modified.
By selecting the Edit Points option we can move the interpolated positions around on the map using the mouse.
In this mode we must left click and hold on either of the interpolated markers shown in the map and drag it to it's new position. Again, the map view we use determines which position coordinates are altered.
New Spline Camera
As usual, when the Camera Inspector starts with this camera type we are in Add Points mode.
With a Spline Camera this mode allows us to add new points along the path that the camera will follow. With this camera type it is best to use the XY view when placing the path points and editing the Z coordinate later. When a point is first created in the XY view it's Z coordinate is set to 0.
Each time we left click on the map a new path position is created. After a few positions have been created a line is drawn through those points, showing the path the camera will take. Please note that once a point is created you can not delete it.
The point with the larger box around it is the start position of the camera. The first point you place on the map is not part of the path the camera will travel (the starting position is the second point) but it does affect the curve of the path, as seen here :
By moving the first point the shape of the curve is altered, as well as the camera starting position. The last point placed on the curve is the same. It is not part of the camera path but it will alter the shape of the path curve. When creating a camera path for a Spline Camera it is best to place the points along the curve from start to finish one right after the other. Trying to add a new point in between two existing points can cause problems and is best avoided. You can change the position of the points after they are created (using the Edit Points mode) to fine tune your path.
To alter the position of the points along the path we select the Edit Points mode.
In this mode we can left click and hold on a point and drag it to a new location. The curve of the path will be altered when we do this. As usual, the map view we click on determines which coordinates of the point are altered. If you are in the XY view then the X and Y coordinates of the point are altered. The Z coordinate is left unaltered. In the YZ view only Y and Z coordinates are changes and in the XZ view the X and Z coordinates are modified.
Camera Timeline
After we have created the path that the camera will follow we must set the amount of time that the camera will be active. This time, known as the camera timeline, determines how fast the camera must move in order to cover it's path while it is active. By default a camera has a 30 second timeline, ie. the camera will take 30 seconds to move along it's path before becoming inactive. To change the length of the timeline we alter the value in the Time section of the Camera Inspector.
Enter the time value in seconds in the Length field and then click the Apply button to make the change take place. The Current Time: timeline slider will now reflect the new length of the timeline. This timeline is known as the original timeline and is used to calculate how fast the camera must move to cover it's path. This time is not necessarily the amount of time the camera will be active since certain events can add to the length of the actual timeline.
Target Creation
Now that we have our camera path created and the length of the original timeline set, we next turn to creating targets for the camera. A target is a location that the camera looks at while moving along it's path. A target can be either fixed or moving and a camera can have more than one target defined, with target switching taking place during the camera timeline.
To create a target we click on the Add Target... button.
This will open the Add Target dialog box.
We have a choice of the type of target we want - fixed, interpolated or spline and the name we wish to assign to the target. This name is used later when we wish to switch targets during the camera timeline.
The Camera Inspector changes to reflect the addition of a target.
The Edit: field now shows the name of the path we are working on and we are in Add Points mode. We add and edit the target path in exactly the same way we edit a camera path of the same type. See above for details. If you have multiple targets, or you wish to go back and edit the camera path, use the dropdown arrow at the end of the Edit: field to select the desired item.
When we create our first target we also automatically create a new event in the script. In the Events: box you will now see
0 TARGET target1
This says that the camera will use target1 as it's viewpoint at 0 seconds into the timeline - in otherwords, when the camera script starts. This is the default event for the camera but the actual starting target can be changed later.
If the target is moving (of type interpolated or spline) then the speed at which it moves is calculated from the actual timeline value. This timeline takes into account any wait events that may take place, so it may be longer than the original timeline value. A target never stops moving during the timeline, regardless of any wait events.
Adding Events
Events are things that happen during the camera's timeline. The scripted camera system we are using only supports three types of events - Switch Target, Wait and Stop. As we seen above, a Switch Target event is automatically added when we create our first target. Events only affect the camera and not the targets. A Switch Target event changes the camera viewpoint, a Wait stops the camera from moving and a Stop ends the camera timeline at that point.
To add another event to the timeline we first move the Current Time: slider to the time we wish to have the event occur.
Here we want an event to occur at 4.88 seconds (4880 milliseconds) into the timeline. To create a new event we click on the Add... button. This brings up the Add Event dialog box.
We can now select which type of event we want to add. As stated above only the Change Target, Wait and Stop events are supported. In the Parameters: field we must enter the data required by the choosen event. For Change Target this is the name of the target and for Wait it is the number of seconds we wish to pause the camera's movement. Stop requires no parameter. If a parameter is required and none is given then the Ok button will not work. Here we have selected a Wait event with a 4 second pause time.
After creating the new event the Camera Inspector reflects the addition.
You will notice a number of changes. In the Events: box there is another event shown. This takes place at 4877 milliseconds (4.877 seconds) into the timeline and is Wait of 4 seconds. You'll also notice a change in the length of the actual timeline, as displayed by the Current Time: slider. It is now 14 seconds long rather than 10 seconds as it was previously. This is because a Wait event adds its pause time to the camera timeline. This will affect the speed that the targets move since they use the actual timeline value in their speed calculations. This does not affect the camera speed. Instead, at 4.877 seconds into the actual timeline the camera movement will stop for 4 seconds before resuming.
To remove an event we click on it to highlight and press the Del button. If we delete a Wait event the timeline will reflect the removal of the pause time.
Setting the Camera FOV
Currently, there is no way to set the camera's Fov from the Camera Inspector. Instead, you must edit the saved .camera file using a text editor and change the value in the fov section of the script.
Previewing The Results
At any point in our script creation we can preview what the camera script would look like in the game. By checking the Track Camera box we can cause the map viewpoint camera to follow our script.
If we move the Current Time: slider both the camera icon in the map view and the preview window will move to match the position and direction as calculated by the camera script. Unfortunately, there is a bug in the plugin that causes the camera to reverse when a Wait event occurs rather than stopping when using the slider. Instead, we use the Preview button. This runs the script for it's full timeline and shows the resulting position and viewpoint in both the map view and preview window. It works correctly for Wait events.
Miscellaneous
The Camera Inspector has other buttons that do various different functions. This will be a quick look at them.
New... - creates a new camera script. The New Camera dialog box will appear so you can select the type of camera desired.
Multiple camera scripts can be active at any one time and you switch between them using the File: dropdown arrow.
Load... - loads a previously saved camera script. It looks for files with the .camera extension.
Save... saves the camera script to a file with a .camera extension.
Unload - removes the current camera script from the Camera Inspector.
Rename... - renames the target or camera path that is shown in the Edit: field. The Rename Path dialog box will appear so you can change the name.