< Zurück | Inhalt | Weiter >

12.4.3 Reading spline key frames from disk

The following code is used to read in a series of key frames from a disk file. Defining key frames by hand takes a lot of trial and error, so it is very desirable to be able to quickly modify the key frame file and rerun the application rather than having to recompile.


A utility method was written to read the data for a series of key frames from a disk file. The format of the file is as follows:


1. Alpha time

2. Position x,y,z

3. Rotation x,y,z

4. Scale x,y,z

5. Tension (–1 to 1)

6. Continuity (–1 to 1)

7. Bias (–1 to 1)

8. Linear Interpolation (0 or 1)


For example, the spline curve that the viewer is interpolated along is defined as follows, from rotate_viewer_spline.xls:


0.0

5 6 5

−0.4 0 0

1 1 1

0 1 0

0


0.3

2 4 10

1.0 0.2 0

1 1 1

0 0 0

0


0.5

−2 4 8

−0.3 0.6 0.2

1 1 1

−1 1 −1

0


0.7

−2 5 10

−0.4 −0.6 0.5

1 1 1

−1 1 −1

0


0.8



−1 4

5

−0.6

−0.9

−0.2

1 1

1


1 1

1


0




0.9

0 10 15

−1.2 0 0

1 1 1

1 0 1

0


1.0

0 52 0

−1.5 0 0

1 1 1

0 1 1

0


The utility method to read and create the key frame array is simply the following:


 

From Utils.java in the org.selman.java3d.book package