home *** CD-ROM | disk | FTP | other *** search
- // Scene File: B-SPLINE.PI
- // Author: Rob McGregor
-
- // Uses B-Spline interpolation influenced by key frame
- // points to calculate an object's path...
-
- include "..\..\..\colors.inc"
- include "..\..\..\texture.inc"
- include "..\..\..\stones.inc"
-
- // Set up the camera
- viewpoint {
- from <0, 0, -10>
- at <0, 0, 0>
- up <0, 1, 0>
- angle 45
- resolution 320,200
- aspect 1.6
- }
-
- // Define the range of the animation
- start_frame 0
- end_frame 50
- outfile "bspln"
-
- /********************************************************
- The control points are:
-
- <0, 0, 0>, <1.6, 2.8, 0>, <3.6, 0, 0>,
- <0.4, -3.2, 0>, <-3.2, -0.4, 0>, <0, 0, 0>
-
- The first and last points are doubled to include them
- in the interpolation and create a smoother loop.
-
- x-axis: 0, 0, 1.6, 3.6, 0.4, -3.2, 0, 0
- y-axis: 0, 0, 2.8, 0.0, -3.2, -0.4, 0, 0
- *********************************************************/
-
- // Define the 4 local 3-D control points as arrays
- define n1x [0, 0, 1.6, 3.6, 0.4]
- define n1y [0, 0, 2.8, 0.0, -3.2]
-
- define n2x [0, 1.6, 3.6, 0.4, -3.2]
- define n2y [0, 2.8, 0.0, -3.2, -0.4]
-
- define n3x [1.6, 3.6, 0.4, -3.2, -0.4]
- define n3y [2.8, 0.0, -3.2, -0.4, 0.0]
-
- define n4x [3.6, 0.4, -3.2, 0, 0]
- define n4y [0.0, -3.2, -0.4, 0, 0]
-
- // Set up the key frames in another array
- define KF [0, 9, 19, 29, 39, 49]
-
- // Assign the value of "frame" to variable "F"
- define F frame
-
- // Determine what key frame sequence we're in
- if (F <= KF[1]) // <= 9
- define key 0
- if (F > KF[1] && F <= KF[2]) // > 9 && <= 19
- define key 1
- if (F > KF[2] && F <= KF[3]) // > 19 && <= 29
- define key 2
- if (F > KF[3] && F <= KF[4]) // > 29 && <= 39
- define key 3
- if (F > KF[4]) // > 39
- define key 4
-
- // Calculate the value of "t" from the
- // current frame and key frame sequence
- define F1 KF[key]
- define F2 KF[key + 1]
- define t (F - F1) / (F2 - F1)
-
- /****************************************************************
- Calculate the values of the object's location vector using the
- B-Spline equation:
-
- P = ((-P1 * t^3 + 3 * P2 * t^3 - 3 * P3 * t^3 + P4 * t^3) +
- (3 * P1 * t^2 - 6 * P2 * t^2 + 3 * P3 * t^2) +
- (-3 * P1 * t +3 * P3 *t) + (P1 + 4 * P2 + P3)) * (1 / 6)
- ****************************************************************/
-
- define t2 t * t
- define t3 t2 * t
-
- define Px ((-n1x[key] * t3 + 3 * n2x[key] * t3 - 3 * n3x[key] *
- t3 + n4x[key] * t3) + (3 * n1x[key] * t2 - 6 *
- n2x[key] * t2 + 3 * n3x[key] * t2) + (-3 * n1x[key] *
- t +3 * n3x[key] *t) + (n1x[key] + 4 * n2x[key] +
- n3x[key])) * (1 / 6)
-
- define Py ((-n1y[key] * t3 + 3 * n2y[key] * t3 - 3 * n3y[key] *
- t3 + n4y[key] * t3) + (3 * n1y[key] * t2 - 6 *
- n2y[key] * t2 + 3 * n3y[key] * t2) + (-3 * n1y[key] *
- t +3 * n3y[key] *t) + (n1y[key] + 4 * n2y[key] +
- n3y[key])) * (1 / 6)
-
- // Now move the sphere to the new location
- object {
- sphere <0, 0, 0>, 0.5
- reflective_red
- translate <Px, Py, 0>
- }
-
- // Set the sky color and add a little haze
- background Grey
- haze 0.98, 25, Grey
-
- // Lights
- light <-5, 30, -100>
- light <5, 30, -100>
-
- // The floor...
- object {
- disc <0, 0, 0>, <0, 1, 0>, 10000
- texture {
- checker steely_blue,
- texture { shiny { color white }}
- }
- rotate <0, 25, 0>
- translate <0, -4.5, 0>
- }
-