Have a Wetpaint account? Sign in
Reset the Camera Using Macros
In this tutorial, we’re going to add functionality to the scene to allow the camera to be reset back to its default position. We’ll use macros to implement this functionality and then we’ll wire them up to both the XBox 360 controller's Back button and the keyboard's Escape key.
To start, open up an instance of Blade3D; a new scene is created for you. Find the Macro section on the scene explorer on the right-hand side of the screen and right-click it. Drill through the Create option to Compound Macro.

To start, open up an instance of Blade3D; a new scene is created for you. Find the Macro section on the scene explorer on the right-hand side of the screen and right-click it. Drill through the Create option to Compound Macro.
Rename the new Compound Macro to ResetCamera. We’ll use this compound macro as a container for macros for altering both the camera’s position and its rotation.
To do that, right-click the new Reset Camera Compound Macro. Drill through the Create option to Set Value Macro. Rename this new macro ResetCameraPosition.
Double-click the new macro to open its property sheet. Under the Set Value Macro tab, click the
button next to the Target Instance property. Drill down to the scene’s Camera and select it. Click the
next to the Target Property property and select the Camera’s LocalPosition property. Now, set the Time property to 2. This means the movement from the camera’s current position to the new position will take two seconds. To make this happen, set the Interpolate property to True. In the Local Position property, set the values to:
· X: -10
· Y: 7
· Z: 12
These are the default values for the camera in a new scene. If you’d like your camera to reset to different position, set that position here. Compare your macro to the screenshot:
Now we’re going to do the same thing for the rotation. Under the Reset Camera macro, create a new Set Value Macro and name it ResetCameraRotation. Set its Target Instance to the Camera, and this time, set the Target Property to the camera’s LocalRotation. Set Time to 2, Interpolate to True, and set the rotation properties as such:
· Pitch: 0
· Yaw: -48
· Roll: 0
These are the default settings for the camera in a new scene. If you’d like to reset your camera to different rotation, change the values here. Compare your macro to the screenshot:
At this point we’re done with the macros, now we just need to wire them up. Find the Graphs section in the scene explorer. Right-click it, drill through Create and select Logic Diagram. Rename the logic diagram ResetCamera. You might want to drag the diagram up to the upper-left of the screen and then drag the lower-right-hand corner down to the lower-right-hand corner of the scene to give yourself some room to work.
In the graph surface, right-click and drill through Input Operations and select Xbox 360 Game Pad State. [Note, if you don’t see Input Operations as an option, you’re not actually on the logic diagram, you’re on the underlying scene. Click on the diagram and then try right-clicking again]. This will create a new instance of the GetGamePad360State.

Now find the Reset Camera compound macro you created earlier in the scene explorer. Don’t click it! If you click the macro the logic diagram closes and you’ll have to reopen it. Instead, click and hold the macro and drag it onto the logic diagram.
Find the arrow on the right-hand side of the Back property of the GetGamePad360State instance. Drag this arrow to the arrow on the left-hand side of the ResetCamera macro. The camera can now be reset with the XBox 360 game controller’s Back button.
Now let’s wire up the escape key to do the same thing. On the logic diagram, create a new instance of Input Operators->Is Key Down. Double-click the new IsKeyDown operator to open its property sheet. Drop down the selector next to the Key property and set its value to Escape to set the key to the escape key. Now drag another copy of the Reset Camera macro on the design surface. Just like before, wire the Pressed property to the Play property of the ResetCamera instance.
You can now move your camera all around the scene and then either press the Escape key, or the Back button on the XBox 360 controller and you will see the camera smoothly return to its default position over the next two seconds.
For more information, see the wiki pages on Logic Diagrams and Macros.
To do that, right-click the new Reset Camera Compound Macro. Drill through the Create option to Set Value Macro. Rename this new macro ResetCameraPosition.
· X: -10
· Y: 7
· Z: 12
These are the default values for the camera in a new scene. If you’d like your camera to reset to different position, set that position here. Compare your macro to the screenshot:
· Pitch: 0
· Yaw: -48
· Roll: 0
These are the default settings for the camera in a new scene. If you’d like to reset your camera to different rotation, change the values here. Compare your macro to the screenshot:
In the graph surface, right-click and drill through Input Operations and select Xbox 360 Game Pad State. [Note, if you don’t see Input Operations as an option, you’re not actually on the logic diagram, you’re on the underlying scene. Click on the diagram and then try right-clicking again]. This will create a new instance of the GetGamePad360State.
Now find the Reset Camera compound macro you created earlier in the scene explorer. Don’t click it! If you click the macro the logic diagram closes and you’ll have to reopen it. Instead, click and hold the macro and drag it onto the logic diagram.
Find the arrow on the right-hand side of the Back property of the GetGamePad360State instance. Drag this arrow to the arrow on the left-hand side of the ResetCamera macro. The camera can now be reset with the XBox 360 game controller’s Back button.
For more information, see the wiki pages on Logic Diagrams and Macros.
|
WaywardMage |
Latest page update: made by WaywardMage
, Jun 18 2007, 10:42 AM EDT
(about this update
About This Update
1 word deleted view changes - complete history) |
|
Keyword tags:
None
More Info: links to this page
|
| Started By | Thread Subject | Replies | Last Post | ||
|---|---|---|---|---|---|
| X-Tatic | Tutorial | 0 | Jun 16 2007, 6:21 AM EDT by X-Tatic | ||
|
Thread started: Jun 16 2007, 6:21 AM EDT
Watch
Not a bad tutorial layout/presentation :)
Good job. |
|||||
Showing 1 of 1 threads for this page

