Dec 052017
 
Utility to work with DKBTRACE ray-tracer to make animated scenes.
File RAYSCENE.ZIP from The Programmer’s Corner in
Category Printer + Display Graphics
Utility to work with DKBTRACE ray-tracer to make animated scenes.
File Name File Size Zip Size Zip Type
BALLS.ARR 5065 907 deflated
BALLS.DAT 1476 544 deflated
RANGE.EXE 29314 18703 deflated
RAYSCENE.EXE 45690 27177 deflated
SIN.DOC 11335 3263 deflated
SIN.EXE 21644 12941 deflated

Download File RAYSCENE.ZIP Here

Contents of the SIN.DOC file



Sin version 1.5 05.01.1990
---------------

This little program is a utility for RayScene. It calculates
values of sine and cosine functions so that creating circular paths,
for example, becomes easy. Calculated values are written to stdout.
Program can be controlled with these command line options:

SINcount start_angle [+] [-] end_angle
[M multiplier1 [multiplier2]] [O offset]
[F values_per_line output_format_string] [COS] [POS] [NEG] [LOOP]


count, start_angle and end_angle are the necessary parameters, the
rest are optional.

COUNT is the number of values to be calculated. Program calculates
values from START_ANGLE to END_ANGLE. Both angles should be given as
degrees. The angle of the first value of a line is printed in the
beginning of each line. There are two ways of defining the angles:
1. sin 10 90 180 would give the values from 90 to 180 degrees.
2. sin 10 90 + 180 would be from 90 to (90+180) degrees.

If you want to multiply values with a number, use M multiplier1
[multiplier2]. Why two multipliers? If you specify both, first value
is multiplied with first multiplier, last with the second, and the
values between these two are multiplied with a number changing from
multiplier1 to multiplier2. You could use this to create a spiral for
example. Still confused? Try sin 10 90 90 m 1 100.

To add a number to each value, use O offset, where offset is the number
you want to be added.

Two parameters are provided for changing the output format.
values_per_line is exactly what you think it is, output_format_string
is a C-language formatting string for printf(). It must have format
D.D where D's are digits. 8.1 would print values with one decimal,
default is 7.2.

Use COS parameter to get values of cosine() function.

If you want your values to be positive/negative only, use POS/NEG
parameters. sin 100 0 720 POS could be used to create path for a
bouncing object. Notice: output-values are calculated following way:
1. get value of sin() or cosine().
2. multiply value
3. change sign if needed
4. add offset value
This means that it's still possible to get negative values if you
define a negative offset value.

LOOP is the last parameter. It is a nice little timesaver when you
want to create smooth animation. Let's have an example. You want to
calculate a 100 frame animation, in which a ball moves on a circular
path. When the animation is played, frames from 1 to 100 are displayed
and after this the frame sequence is continued from 1 again. If you typed
sin 100 0 360, movement would be smooth except where the frame 1 comes
after frame 100. In this phase you would notice a little jerk because
frames 1 and 100 would be identical ( sin(0) = sin(360) ).

To get rid of this, you could take your calculator and calculate the
end angle from 360-(360/(100+1)) or use sin 100 0 360 LOOP.
-----------------------------------------------------------------------

Just to make sure everybody understood, let's take another example.
We make a simple 80 frame animation with DKBTrace, RayScene and Sin
In this animation there are two balls moving above the ground on
elliptical tracks (animation is called 2balls.anim for Amiga, 2balls.fli
for PC). The variables we use are x-coordinate, z-coordinate and
transparency for both balls. Changing transparency causes a blinking
effect.

First we type a DKBTrace scene file, which RayScene uses to create
scene files for frames 1 to 80. It is included below:

-------------------- 2balls.dat starts from here: --------------------------
INCLUDE "BasicShapes.data"

VIEW_POINT {*** camera ***}
LOCATION <0.0 25 -70.0>
LOOK_AT <0.0 0.0 30.0>
UP <0.0 1.0 0.0>
RIGHT <1.0 0.0 0.0>
END_VIEW_POINT

OBJECT {*** light source ***}
SPHERE <0.0 0.0 0.0> 3.0 END_SPHERE
LIGHT_SOURCE

TRANSLATE < -40 80 -40 >

COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
AMBIENT 1.0
DIFFUSE 0.0
END_OBJECT

OBJECT {*** black horizon ***}
PLANE <0.0 0.0 1.0> 10000.0 END_PLANE

COLOUR Black
AMBIENT 0.0
DIFFUSE 0.0
END_OBJECT

OBJECT {*** red wavy ground ***}
PLANE <0 1 0> -10.0 END_PLANE

TEXTURE
RIPPLES 2.0
PHASE 1
SCALE <10.0 10.0 10.0>
END_TEXTURE

COLOUR Red
AMBIENT 0
DIFFUSE 1.0
BRILLIANCE 5.0
REFLECTION 0.6
END_OBJECT

OBJECT {*** ball1 ***}
SPHERE <0.0 0.0 0.0> 0.3 END_SPHERE

SCALE < 20 20 20 >
TRANSLATE < #x1# 15 #z1# >

COLOUR Green ALPHA #transparency_1#
AMBIENT 0.2
DIFFUSE 0.8
BRILLIANCE 10
REFLECTION 0.9
SPECULAR 0.4
ROUGHNESS 0.02
END_OBJECT


OBJECT {*** ball2 ***}
SPHERE <0.0 0.0 0.0> 0.3 END_SPHERE

SCALE < 20 20 20 >
TRANSLATE < #x2# 15 #z2# >

COLOUR Blue ALPHA #transparency_2#
AMBIENT 0.2
DIFFUSE 0.8
BRILLIANCE 10
REFLECTION 0.9
SPECULAR 0.4
ROUGHNESS 0.02
END_OBJECT
-------------------- end of 2balls.dat -------------------------------------

After this we create an array file from which the values for variables are
read. Type:

echo "x1,80" >2balls.arr
sin 80 360 0 loop m 20 20 >>2balls.arr
echo "z1,80" >>2balls.arr
sin 80 90 -270 loop m 15 15 >>2balls.arr
echo "x2,80" >>2balls.arr
sin 80 0 360 loop m 15 15 >>2balls.arr
echo "z2,80" >>2balls.arr
sin 80 -90 270 loop m 20 20 >>2balls.arr
echo "transparency_1,80" >>2balls.arr
sin 80 -90 270 loop >>2balls.arr
echo "transparency_2,80" >>2balls.arr
sin 80 0 360 loop 0 >>2balls.arr

to create this:

-------------------- 2balls.arr starts from here: ---------------------------
x1,80

# 0.00# 0.00 -1.57 -3.13 -4.67 -6.18
# -22.50# -7.65 -9.08 -10.45 -11.76 -12.99
# -45.00# -14.14 -15.21 -16.18 -17.05 -17.82
# -67.50# -18.48 -19.02 -19.45 -19.75 -19.94
# -90.00# -20.00 -19.94 -19.75 -19.45 -19.02
#-112.50# -18.48 -17.82 -17.05 -16.18 -15.21
#-135.00# -14.14 -12.99 -11.76 -10.45 -9.08
#-157.50# -7.65 -6.18 -4.67 -3.13 -1.57
#-180.00# 0.00 1.57 3.13 4.67 6.18
#-202.50# 7.65 9.08 10.45 11.76 12.99
#-225.00# 14.14 15.21 16.18 17.05 17.82
#-247.50# 18.48 19.02 19.45 19.75 19.94
#-270.00# 20.00 19.94 19.75 19.45 19.02
#-292.50# 18.48 17.82 17.05 16.18 15.21
#-315.00# 14.14 12.99 11.76 10.45 9.08
#-337.50# 7.65 6.18 4.67 3.13 1.57

z1,80

# 0.00# 15.00 14.95 14.82 14.59 14.27
# -22.50# 13.86 13.37 12.79 12.14 11.41
# -45.00# 10.61 9.74 8.82 7.84 6.81
# -67.50# 5.74 4.64 3.50 2.35 1.18
# -90.00# -0.00 -1.18 -2.35 -3.50 -4.64
#-112.50# -5.74 -6.81 -7.84 -8.82 -9.74
#-135.00# -10.61 -11.41 -12.14 -12.79 -13.37
#-157.50# -13.86 -14.27 -14.59 -14.82 -14.95
#-180.00# -15.00 -14.95 -14.82 -14.59 -14.27
#-202.50# -13.86 -13.37 -12.79 -12.14 -11.41
#-225.00# -10.61 -9.74 -8.82 -7.84 -6.81
#-247.50# -5.74 -4.64 -3.50 -2.35 -1.18
#-270.00# 0.00 1.18 2.35 3.50 4.64
#-292.50# 5.74 6.81 7.84 8.82 9.74
#-315.00# 10.61 11.41 12.14 12.79 13.37
#-337.50# 13.86 14.27 14.59 14.82 14.95

x2,80

# 180.00# -0.00 1.18 2.35 3.50 4.64
# 157.50# 5.74 6.81 7.84 8.82 9.74
# 135.00# 10.61 11.41 12.14 12.79 13.37
# 112.50# 13.86 14.27 14.59 14.82 14.95
# 90.00# 15.00 14.95 14.82 14.59 14.27
# 67.50# 13.86 13.37 12.79 12.14 11.41
# 45.00# 10.61 9.74 8.82 7.84 6.81
# 22.50# 5.74 4.64 3.50 2.35 1.18
# 0.00# 0.00 -1.18 -2.35 -3.50 -4.64
# -22.50# -5.74 -6.81 -7.84 -8.82 -9.74
# -45.00# -10.61 -11.41 -12.14 -12.79 -13.37
# -67.50# -13.86 -14.27 -14.59 -14.82 -14.95
# -90.00# -15.00 -14.95 -14.82 -14.59 -14.27
#-112.50# -13.86 -13.37 -12.79 -12.14 -11.41
#-135.00# -10.61 -9.74 -8.82 -7.84 -6.81
#-157.50# -5.74 -4.64 -3.50 -2.35 -1.18

z2,80

# 180.00# -20.00 -19.94 -19.75 -19.45 -19.02
# 157.50# -18.48 -17.82 -17.05 -16.18 -15.21
# 135.00# -14.14 -12.99 -11.76 -10.45 -9.08
# 112.50# -7.65 -6.18 -4.67 -3.13 -1.57
# 90.00# -0.00 1.57 3.13 4.67 6.18
# 67.50# 7.65 9.08 10.45 11.76 12.99
# 45.00# 14.14 15.21 16.18 17.05 17.82
# 22.50# 18.48 19.02 19.45 19.75 19.94
# 0.00# 20.00 19.94 19.75 19.45 19.02
# -22.50# 18.48 17.82 17.05 16.18 15.21
# -45.00# 14.14 12.99 11.76 10.45 9.08
# -67.50# 7.65 6.18 4.67 3.13 1.57
# -90.00# -0.00 -1.57 -3.13 -4.67 -6.18
#-112.50# -7.65 -9.08 -10.45 -11.76 -12.99
#-135.00# -14.14 -15.21 -16.18 -17.05 -17.82
#-157.50# -18.48 -19.02 -19.45 -19.75 -19.94

transparency_1,80

# 180.00# -1.00 -1.00 -0.99 -0.97 -0.95
# 157.50# -0.92 -0.89 -0.85 -0.81 -0.76
# 135.00# -0.71 -0.65 -0.59 -0.52 -0.45
# 112.50# -0.38 -0.31 -0.23 -0.16 -0.08
# 90.00# -0.00 0.08 0.16 0.23 0.31
# 67.50# 0.38 0.45 0.52 0.59 0.65
# 45.00# 0.71 0.76 0.81 0.85 0.89
# 22.50# 0.92 0.95 0.97 0.99 1.00
# 0.00# 1.00 1.00 0.99 0.97 0.95
# -22.50# 0.92 0.89 0.85 0.81 0.76
# -45.00# 0.71 0.65 0.59 0.52 0.45
# -67.50# 0.38 0.31 0.23 0.16 0.08
# -90.00# -0.00 -0.08 -0.16 -0.23 -0.31
#-112.50# -0.38 -0.45 -0.52 -0.59 -0.65
#-135.00# -0.71 -0.76 -0.81 -0.85 -0.89
#-157.50# -0.92 -0.95 -0.97 -0.99 -1.00

transparency_2,80

# 180.00# -0.00 0.08 0.16 0.23 0.31
# 157.50# 0.38 0.45 0.52 0.59 0.65
# 135.00# 0.71 0.76 0.81 0.85 0.89
# 112.50# 0.92 0.95 0.97 0.99 1.00
# 90.00# 1.00 1.00 0.99 0.97 0.95
# 67.50# 0.92 0.89 0.85 0.81 0.76
# 45.00# 0.71 0.65 0.59 0.52 0.45
# 22.50# 0.38 0.31 0.23 0.16 0.08
# 0.00# 0.00 -0.08 -0.16 -0.23 -0.31
# -22.50# -0.38 -0.45 -0.52 -0.59 -0.65
# -45.00# -0.71 -0.76 -0.81 -0.85 -0.89
# -67.50# -0.92 -0.95 -0.97 -0.99 -1.00
# -90.00# -1.00 -1.00 -0.99 -0.97 -0.95
#-112.50# -0.92 -0.89 -0.85 -0.81 -0.76
#-135.00# -0.71 -0.65 -0.59 -0.52 -0.45
#-157.50# -0.38 -0.31 -0.23 -0.16 -0.08
-------------------- end of 2balls.arr ------------------------------------

Then we create scene files with RayScene:
RayScene -c80 -d2balls -a2balls

Now all you have to do is render the frames with DKBTrace and combine them
to make an animation.


 December 5, 2017  Add comments

Leave a Reply