[N-World Contents] [Book Contents] [Prev] [Next] [Index]
Animating Paint Operations
In this chapter, you'll learn how to drive N-Paint operations from N-Dynamics. You'll learn how to perform such tasks as loading and saving sequences of images, how to modify a loaded image from a script, and how to composite images in N-Paint.
![](92DAnimation.anc.gif)
In this Chapter
You'll lean how to:
This chapter assumes that you have some basic familiarity with N-Dynamics, Nichimen Graphics' animation module. If you're not familiar with N-Dynamics, you may want to read the first two chapters of the N-Dynamics Tutorial before you try this tutorial.
- Note. This chapter also appears in the N-Dynamics Tutorial.
Calling N-Paint Operations
Because N·World is completely integrated, you can drive any of its applications from N-Dynamics. In the same way that you use it to animate skeletons with the Skeletal Animation System, or objects in N-Geometry, you can work with images in N-Paint.
This section walks you through the process of building a script that will drive N-Paint to perform some simple operations. In this script, we'll do the following:
Copy the Source Image
We'll be using the following image file for this example:
/usr/local/ngc/demo/images/hero.tif
Part of the process will involve writing files to the directory which contains the source image. Because users typically don't have enough UNIX file permissions to write to /usr/local/ngc/demo/images, this can lead to a problem when it comes time to animate the script. To avoid this problem:
1. Copy the source image to a directory for which you have adequate write permissions.
- Usually your home directory will be adequate. To copy the file, open a UNIX shell and execute this command:
unix 13% cp /usr/local/ngc/demo/images/hero.tif ~
- If you encounter any problems with write permissions or other UNIX issues, see your system administrator.
Create a New Script
1. (CLICK-L) on File>Create New Script.
- Name the script PAINT-FILTER and specify four channels when prompted.
Loading Images into a Window
In the first channel in the script, you'll set up the parameters for reading in a new image each frame:
2. (CLICK-M) on the first channel in the script.
3. (CLICK-L) on the Operation field.
4. In the Dynamics section of the Operations menu, (CLICK-L) on Image Operations>Load Image into Window.
- The Load Image into Window
5. (CLICK-L) on the Directory field and enter the following directory:
/usr/local/ngc/demo/images
- Note that the default names shows a "padding" scheme which can be used to load a sequence of numbered images. If you are loading in a sequence of images, they should have a name like this:
filename-nnnn.ext
- where filename is the image name, nnnn is the frame number, and ext is the extension for the images.
6. (CLICK-R) on the Names field and select the following image:
hero.tif
7. (CLICK-M) on the Increment field and enter a value of 0.
- This is used if you are reading in a numbered series of images and don't want to use every image in the sequence.
8. (CLICK-L) on the Window field and select Paint Canvas.
- This specifies where you are loading the image to.
- Your parameters should look something like this when you're done:
![](92DAnimation.anc1.gif)
Figure 9.1 Loading an image into N-Paint
9. (CLICK-L) on Do It.
- Note. There are other operations for loading images into particular N-Paint buffers; see the section "Using the Composite Images Operation," on page 9-14 for more information.
Performing N-Paint Operations
In the second channel, we'll do something relatively simple; we'll apply a Scatter ink to the entire image. However, we want the effect to be cumulative over the course of the animation. This means that the values which determine how much the image is scattered must be made dynamic-they should change over time:
10. (CLICK-M) on the second channel in your script.
11. (CLICK-L) on the Operation field.
12. (CLICK-L) on Filtering>Scatter in the Paint section of the Operations menu.
- The Scatter ink Action Properties menu appears:
![](92DAnimation.anc2.gif)
Figure 9.2 The Scatter Ink Action Properties menu
13. For both the Horizontal and Vertical fields, (CLICK-L) on Source and choose DynamicValue from the menu that appears.
- The Scatter ink moves pixels in the image in both directions by an amount you specify with the Horizontal and Vertical parameters.
- By making these parameters values dynamic, you create subchannels under the operation that let you specify how much horizontal and vertical scattering occurs over time.
14. (CLICK-L) on Do It.
- The new channel appears in your script. It has two subchannels, one to control horizontal movement, the other to control vertical movement.
![](92DAnimation.anc3.gif)
Figure 9.3 Adding dynamic channels for the Scatter operation
15. (CLICK-L) on the [Horizontal] (Linear) subchannel of the Scatter channel.
- This opens the subchannel, revealing the curve channel that it contains:
![](92DAnimation.anc4.gif)
Figure 9.4 Revealing a curve subchannel
16. (CLICK-M) on the curve channel.
- The Curve Properties menu appears. You can use this menu to define the shape and behavior of the curve.
![](92DAnimation.anc5.gif)
Figure 9.5 Edit Curve Properties menu
17. Specify a Start Value of 0 and an End Value of 150.
18. Repeat steps 15 - 17 for the Vertical subchannel curve.
- Your channels should now look something like this:
![](92DAnimation.anc6.gif)
Figure 9.6 Dynamic values for the Scatter operation
Saving Images
In this script, we're going to both save the images and create a movie file (in the next section). Movie files are good for previewing, but if you actually want to create an individual, editable image file for each new frames, you should save each image after it's been modified:
19. (CLICK-M) on the third channel in your script.
20. (CLICK-L) on the Operation field.
21. (CLICK-L) on Image Operations>Save Window to File in the Dynamics section of the Operations menu.
- The Edit Action Properties for this operation appears:
![](92DAnimation.anc7.gif)
Figure 9.7 Edit Action Properties menu for Save Window to File operation
- This operation lets you save images to file from any of three windows:
22. (CLICK-L) on the Directory field and enter the directory where you want to save the images.
23. (CLICK-R) on the Names field and specify the name and padding scheme for the image.
- Note that the default names shows a "padding" scheme which can be used to load a numbered sequence of images. If you are loading in a sequence of images, they should have a name like this:
filename-nnnn.ext
- where filename is the image name, nnnn is the frame number, and ext is the extension for the images. For example, we used
hero-movie-0001.tif
.
24. (CLICK-M) on the Increment field and enter a value of 0.
- The increment controls how images written out to disk are numbered. If you specify an increment of 1, frames numbers are incremented by 1.
- For example, if you use a Name of image-001 and an Increment of 1, images will be named like this:
image-001
image-002
image-003
- ...and so forth.
25. (CLICK-L) on the Input field and select Paint Canvas.
- This specifies where the image you want to write to disk is sitting. Since we're performing N-Paint operations, we want to save the active paint image or paint canvas.
26. (CLICK-M) on the Scale field and enter a value of 1.0.
- If you want to scale the output images (either smaller or larger) enter the factor by which they should be scaled in the Scale field.
27. (CLICK-L) on the Format field and select the file format to use when writing out the images.
28. (CLICK-L) on Yes or No next to Alpha to specify whether or not to save the alpha channel with the images.
- Remember, to save the alpha channel you must choose a four-component image format like .tpx or .tif.
- When you've finished, your parameters should look like those in Figure 9.7.
29. (CLICK-L) on Do It.
Saving a Movie
In order to preview the effect of N-Paint's Scatter filer, you should write out a movie file:
30. (CLICK-M) on the last empty channel.
31. (CLICK-L) on Operation>Image Operations>Record Movie Image in the Dynamics section of the Operations menu.
- The Edit Action Properties menu for the Record Movie Operation appears
![](92DAnimation.anc8.gif)
Figure 9.8 Recoid Movie Image Action properties menu
Figure 9.9 Script for filtering a series of images
32. (CLICK-L) on the Animate button in the N-Dynamics window.
To play back the animation:
33. Open a UNIX shell.
34. Go to the directory into which you wrote the movie clip.
- Movies have the extension .clip. You should see a file that looks like this in the directory you specified above:
script-name.clip
35. Enter the following command at the UNIX prompt:
movieplayer script-name.clip
- The image is scattered both vertically and horizontally.
You can use this approach to create interesting transitions between sequences, or simply to edit a sequence of images. Try working with other inks to create other interesting effects!
Compositing Images
One task that you're likely to perform quite a bit is the compositing of one series of images over another, using the alpha channel of the image being composited as a "mask."
In N-Dynamics, you can build a script that lets you composite a sequence of images over the same background image or one series of images over another.
In this script, we'll:
Copy Source Image Files
For this example, we'll be using the following two image files:
/usr/local/ngc/demo/images/hero-scaled.rgba
/usr/local/ngc/demo/images/background.rgb
You'll need to copy these files to a directory for which you have write permission. Otherwise, Dynamics will be unable to write certain temporary files, and an error will result.
Create a New Script
1. (CLICK-L) on File>Create New Script.
- Name the script COMPOSITE and specify two channels when prompted.
Using the Composite Images Operation
In the previous script, we didn't need to do any "layering" operations; it was simple enough to load our image into N-Paint, perform the operation on the image, and save it back out.
In this script, however, we need to work with two images, a background and a foreground. We'll use a new N-Dynamics operation to load an image into a particular buffer in N-Paint:
2. (CLICK-M) on the first channel in the script.
- The Edit Action Properties menu appears:
![](92DAnimation.anc10.gif)
Figure 9.10 The Edit Action Properties menu
3. (CLICK-L) on the Operation field.
4. (CLICK-L) on Canvas Operations>Composite Images in the Paint section of the Operations menu.
- The parameters for the operation look something like this:
![](92DAnimation.anc11.gif)
Figure 9.11 Composite Images operations parameters
5. (CLICK-L) on Yes next to PreMultiplied.
- The PreMultiplied field determines whether the matte of the foreground image is used in the compositing operation. If set to Yes, only the area with a matte is composited onto the background image.
- Opacity is a multiplier that can be used to make the composited foreground image partially opaque.
Loading the Foreground Image
6. (CLICK-L) on the File button next to Foreground.
- Doing so exposes new menu items, which you'll use to specify the foreground image file you want to use:
![](92DAnimation.anc12.gif)
Figure 9.12 Foreground image parameters
7. Specify the directory and file name of the foreground image
- For this example, select the following image
hero-scaled.rgba
- Specify an increment of 0.
- If you were loading in a series of images (like a walk-cycle), you'd specify a padding scheme in the filename. See the section on the Composite command N-Dynamics Reference Guide for more information about loading sequential files.
Loading the Background Image
8. (CLICK-L) on the File button next to Background.
- Specify the directory and file name of the background image. For this example, select the following image:
background.rgb
- If you were loading in a series of images (like a walk-cycle), you'd specify a padding scheme in the filename. See the section on the Composite command N-Dynamics Reference Guide for more information about loading sequential files.
Saving the Composited Images
To save the composited images:
9. (CLICK-L) on the Canvas button next to Destination.
- Specify the directory and file name to which the composited images should be written. Be sure to choose a directory for which you have write permisson!
- If you were saving a series of images, you'd specify a padding scheme in the filename as described in the section on the Composite command N-Dynamics Reference Guide.
- Here's what our parameters looked like:
![](92DAnimation.anc13.gif)
Figure 9.13 Our finished composite parameters
10. (CLICK-L) on Do It.
Saving a Movie
If you want to play back the composited frames in sequence, you should write out a movie file:
11. (CLICK-M) on the second channel.
12. (CLICK-L) on Operation>Dynamics>Image Operations>Record Movie Image.
Your completed script should look like this:
![](92DAnimation.anc14.gif)
Figure 9.14 Script for compositing images
13. (CLICK-L) on the Animate button in the N-Dynamics window.
Playing Back the Animation
To play back the animation:
14. Open a UNIX shell.
15. Change to the directory into which you wrote the movie clip.
- Movies have the extension .clip. You should see a file that looks like this in the directory you specified above:
script-name.clip
16. Enter the following command at the UNIX prompt:
movieplayer script-name.clip
- The foreground image is composited over the background image at each frame.
Congratulations!
You've now learned to how to load and save images into and out of N-Paint using an N-Dynamics script. You've also learned how to modify an image while it's on the canvas and how to composite images.
[N-World Contents] [Book Contents] [Prev] [Next] [Index]
Another fine product from Nichimen documentation!
Copyright © 1996, Nichimen Graphics Corporation. All rights
reserved.