Cutscenes Part 2: Splines and Camera Movement: Difference between revisions
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
* Texture it with NODRAW. | * Texture it with NODRAW. | ||
* Select it and make it a ''func_splinemover'' ({{RMB}}, ''Create entity'', ''darkmod/func/func_splinemover''). | * Select it and make it a ''func_splinemover'' ({{RMB}}, ''Create entity'', ''darkmod/func/func_splinemover''). | ||
* Change its name to " | * Change its name to "Spline5" ("name" "Spline5"). | ||
Notice that Splinemover5 doesn't have any spline data in it. For that, we'll need to create a spline and copy its data to | Notice that Splinemover5 doesn't have any spline data in it. For that, we'll need to create a spline and copy its data to Spline5. | ||
===NURBS spline=== | ===NURBS spline=== | ||
Create a NURBS spline. | Create a NURBS spline. | ||
* With | * With Spline5 selected, hit the ''Change views'' button (the XYZ button on the main menu) three times. This centers all views on Spline5. | ||
* From the main menu, select ''Curve->Create NURBS Curve''. This creates a spline entity with the same origin as | * From the main menu, select ''Curve->Create NURBS Curve''. This creates a spline entity with the same origin as Spline5. | ||
At this point, | At this point, Spline5 and the spline entity should look like this: | ||
[[Image:Spline5.jpg|200px|thumb|left| | [[Image:Spline5.jpg|200px|thumb|left|Spline5 and a spline]] | ||
{{clear}} | {{clear}} | ||
Now we have to move the spline's curve data into | Now we have to move the spline's curve data into Spline5. | ||
* Select the spline anywhere along its curve. | * Select the spline anywhere along its curve. | ||
* In the Entity window, select the Property ''curve_Nurbs''. This property will appear on the line with the green checkmark on the right. | * In the Entity window, select the Property ''curve_Nurbs''. This property will appear on the line with the green checkmark on the right. | ||
* Hit {{key|ESC}} and select | * Hit {{key|ESC}} and select Spline5. | ||
* Click on the green arrow. This transfers the spline curve to | * Click on the green arrow. This transfers the spline curve to Spline5, which is where we want it. | ||
* Hide | * Hide Spline5. | ||
* Delete the spline entity. | * Delete the spline entity. | ||
* Unhide | * Unhide Spline5. | ||
At this point, | At this point, Spline5 looks like the previous picture, only now it's holding the spline data. | ||
Movement along this spline will begin at its origin and follow its path. At the moment, the path curves away from the origin in the XY plane. Since we want the camera to rise straight up, we need to change the spline path so it goes straight up from the spline's origin. | Movement along this spline will begin at its origin and follow its path. At the moment, the path curves away from the origin in the XY plane. Since we want the camera to rise straight up, we need to change the spline path so it goes straight up from the spline's origin. | ||
* With | * With Spline5 selected, press {{key|V}} to enter Vector mode. Two green dots will appear along the path. These are control points, and we're going to adjust them. | ||
* In the YZ view, drag the leftmost control point so it's 16 units directly above the spline's origin. You might need to set the grid size to 1 to do this. Note how the dashed line of the path changes when you do this. | * In the YZ view, drag the leftmost control point so it's 16 units directly above the spline's origin. You might need to set the grid size to 1 to do this. Note how the dashed line of the path changes when you do this. | ||
* Drag the rightmost control point so it's 48 units above the spline's origin. | * Drag the rightmost control point so it's 48 units above the spline's origin. | ||
Line 52: | Line 52: | ||
* In the XY view, drag both control points so they're directly over the origin, and the spline path is finished. | * In the XY view, drag both control points so they're directly over the origin, and the spline path is finished. | ||
[[Image:Spline5b.jpg|200px|thumb|left| | [[Image:Spline5b.jpg|200px|thumb|left|Spline5 Halfway There]][[Image:Spline5c.jpg|200px|thumb|center|Spline5 Finished]] | ||
{{clear}} | {{clear}} | ||
Line 58: | Line 58: | ||
===''func_mover''=== | ===''func_mover''=== | ||
Spline5 provides the path our camera will follow, but we need a ''func_mover'' to provide the movement. | |||
* Create a 16x16x16 brush above Splinemover5 and texture it with NODRAW. | * Create a 16x16x16 brush above Splinemover5 and texture it with NODRAW. | ||
* Select it, make it a func_mover ({{RMB}}, ''Create entity'', ''darkmod/func/Movers/func_mover''), and give it these Property/Value pairs: | * Select it, make it a ''func_mover'' ({{RMB}}, ''Create entity'', ''darkmod/func/Movers/func_mover''), and give it these Property/Value pairs: | ||
* Change its name to "Mover5" ("name" "Mover5"). | |||
* Give it the Property/Value pair "cinematic" "1". | |||
We'll discuss the ''cinematic'' property below. | We'll discuss the ''cinematic'' property below. | ||
=== | ===Camera5=== | ||
[[Image:Camera5.jpg|200px|thumb|right| | [[Image:Camera5.jpg|200px|thumb|right|Spline5, Mover5, and Camera5]] | ||
Create a ''func_cameraview'' above Mover5 and give it these Property/Value pairs: | Create a ''func_cameraview'' above Mover5 and give it these Property/Value pairs: | ||
Line 81: | Line 80: | ||
Now we have the three entities for a moving camera, but Camera5 is too high up off the porch. We'd like it to start low and rise until it's even with the center of the bulletin board. | Now we have the three entities for a moving camera, but Camera5 is too high up off the porch. We'd like it to start low and rise until it's even with the center of the bulletin board. | ||
* Swap Camera5 with | * Swap Camera5 with Spline5 to get this arrangement: | ||
[[Image:Stack5.jpg|200px|thumb|left|Final Arrangement]] | [[Image:Stack5.jpg|200px|thumb|left|Final Arrangement]] | ||
{{clear}} | {{clear}} | ||
Line 92: | Line 91: | ||
:* "target" "target_null_5" | :* "target" "target_null_5" | ||
[[Image:Target5.jpg|200px|thumb|left|target_null_5]] | [[Image:Target5.jpg|200px|thumb|left|target_null_5]] | ||
{{clear}} | |||
===Roll Camera5=== | |||
Open ''snitch2a.script'' and find the function Roll5(). | |||
<pre> | |||
void Roll5() | |||
{ | |||
// Camera5 - focus on bulletin board | |||
$Camera5.activate($player1); // Switch view | |||
$Mover5.time(7); // How many seconds it will take to move along the spline | |||
$Mover5.accelTime(0.1); // How long it takes to accelerate | |||
$Mover5.decelTime(0.1); // How long it takes to decelerate | |||
$Mover5.startSpline($Spline5); // Start the func_mover $Mover5 moving along $Spline5 | |||
sys.waitFor($Mover5); // Wait for $Mover5 to finish its movement | |||
$Camera5.activate($player1); // Return control to the player | |||
} | |||
</pre> | |||
The comments on each line tell us that: | |||
* we're passing control to Camera5 | |||
* providing Mover5 with movement times (0.1s acceleration, 0.1s deceleration, 7s total duration) | |||
* starting Mover5 along the spline path | |||
* waiting for Mover5 (and Camera5, which is bound to it) to complete its movement | |||
* passing control back to the player | |||
All that remains now is to set up a trigger to call Roll5(). That's been done for you. If you look at the first button near the player start, you'll see that it targets the ''target_callscriptfunction'' Roll5, which is set up to call the script function Roll5(). | |||
Save, build, and run. Press the first button once the actors have reached their marks and you should see a view from Camera5 as it rises off the porch. | |||
{{Template: Cutscenes}} | {{Template: Cutscenes}} |
Revision as of 20:17, 3 September 2010
NOTE: This article is under construction until this NOTE goes away.
Splines
Moving cameras can add a nice touch to a scene if not overused. Splines provide a path a camera can follow.
Download the file [snitch2.zip.txt], remove the ".txt" from the filename, and extract it into your darkmod folder. This includes our Snitch set with all the cameras we created in Part 1.
Open snitch2.map in Dark Radiant.
The first shot we want to create is to have the camera slowly rise from the porch to the south of the bulletin board while pointed in the direction of the bulletin board. To accomplish this, we'll need to add a func_splinemover, which holds a spline (NURBS curve), a func_mover, a func_cameraview, a target_null, and, of course, a script function to bring everything together.
func_splinemover
Create a func_splinemover to hold our spline data.
- Create a 16x16x16 brush sitting on the porch south of the bulletin board (in front of the tall door).
- Texture it with NODRAW.
- Select it and make it a func_splinemover (, Create entity, darkmod/func/func_splinemover).
- Change its name to "Spline5" ("name" "Spline5").
Notice that Splinemover5 doesn't have any spline data in it. For that, we'll need to create a spline and copy its data to Spline5.
NURBS spline
Create a NURBS spline.
- With Spline5 selected, hit the Change views button (the XYZ button on the main menu) three times. This centers all views on Spline5.
- From the main menu, select Curve->Create NURBS Curve. This creates a spline entity with the same origin as Spline5.
At this point, Spline5 and the spline entity should look like this:
Now we have to move the spline's curve data into Spline5.
- Select the spline anywhere along its curve.
- In the Entity window, select the Property curve_Nurbs. This property will appear on the line with the green checkmark on the right.
- Hit ESC and select Spline5.
- Click on the green arrow. This transfers the spline curve to Spline5, which is where we want it.
- Hide Spline5.
- Delete the spline entity.
- Unhide Spline5.
At this point, Spline5 looks like the previous picture, only now it's holding the spline data.
Movement along this spline will begin at its origin and follow its path. At the moment, the path curves away from the origin in the XY plane. Since we want the camera to rise straight up, we need to change the spline path so it goes straight up from the spline's origin.
- With Spline5 selected, press V to enter Vector mode. Two green dots will appear along the path. These are control points, and we're going to adjust them.
- In the YZ view, drag the leftmost control point so it's 16 units directly above the spline's origin. You might need to set the grid size to 1 to do this. Note how the dashed line of the path changes when you do this.
- Drag the rightmost control point so it's 48 units above the spline's origin.
In the camera view, the spline's path has changed, but it's still a curve, so we have to make two more adjustments.
- In the XY view, drag both control points so they're directly over the origin, and the spline path is finished.
Camera Movement
func_mover
Spline5 provides the path our camera will follow, but we need a func_mover to provide the movement.
- Create a 16x16x16 brush above Splinemover5 and texture it with NODRAW.
- Select it, make it a func_mover (, Create entity, darkmod/func/Movers/func_mover), and give it these Property/Value pairs:
- Change its name to "Mover5" ("name" "Mover5").
- Give it the Property/Value pair "cinematic" "1".
We'll discuss the cinematic property below.
Camera5
Create a func_cameraview above Mover5 and give it these Property/Value pairs:
- "name" "Camera5"
- "trigger" "1"
- "bind" "Mover5"
The bind property allows Camera5 to follow Mover5 as Mover5 follows the spline.
Now we have the three entities for a moving camera, but Camera5 is too high up off the porch. We'd like it to start low and rise until it's even with the center of the bulletin board.
- Swap Camera5 with Spline5 to get this arrangement:
Now that Camera5 is where we want it, we'll give it a target_null to point at.
- Create a target_null beneath the bulletin board and set its Z origin to Camera5's Z origin so they're at the same height.
- Give it the Property/Value pair:
- "name" "target_null_5"
- Give Camera5 the Property/Value pair:
- "target" "target_null_5"
Roll Camera5
Open snitch2a.script and find the function Roll5().
void Roll5() { // Camera5 - focus on bulletin board $Camera5.activate($player1); // Switch view $Mover5.time(7); // How many seconds it will take to move along the spline $Mover5.accelTime(0.1); // How long it takes to accelerate $Mover5.decelTime(0.1); // How long it takes to decelerate $Mover5.startSpline($Spline5); // Start the func_mover $Mover5 moving along $Spline5 sys.waitFor($Mover5); // Wait for $Mover5 to finish its movement $Camera5.activate($player1); // Return control to the player }
The comments on each line tell us that:
- we're passing control to Camera5
- providing Mover5 with movement times (0.1s acceleration, 0.1s deceleration, 7s total duration)
- starting Mover5 along the spline path
- waiting for Mover5 (and Camera5, which is bound to it) to complete its movement
- passing control back to the player
All that remains now is to set up a trigger to call Roll5(). That's been done for you. If you look at the first button near the player start, you'll see that it targets the target_callscriptfunction Roll5, which is set up to call the script function Roll5().
Save, build, and run. Press the first button once the actors have reached their marks and you should see a view from Camera5 as it rises off the porch.