This is a child page. You can use Parent in the quick nav bar at the top or the bottom of the page to navigate directly back to the parent of this page. Some child pages are more than one level deep, and in that case will require more than one Parent click to reach the outermost document level.

§ - Mathematical Expressions and Keys

Animating a ray trace requires some basic mathematical background. This animation will be simple in its movements so as not to be overly complicated. The image below was used in the image map on the rectangle. This image gave the rectangle a "felt table" look.

Note that all keys are set for 30 frames. Library:  <libpath "c:\w3\"  <lib "textures.w3d" Initialize random number:  <seed 10 Keys let you set "trends" for any effect in the ray trace operator. The Keys operator works as follows: Keys "keyname" frame1 value frame2 value... etc. This is saying "From frame 1 to frame 15, I want the value of 'cuemovex' to go from -12 to -2. Then, from frame 15 to 30, I want the value of 'cuemovex' to go from -2 to -5." This value is going to be used in the x-position of the cueball. That means that the cueball is going to move left, and bounce back rightward abruptly:  <keys "cuemovex" 1 -12 15 -2 30 -5 "From frame 1 to 15, 'cuemovez' will remain 0. From frame 15 to 30, the value of 'cuemovez' will go from 0 to 3." This value will be used in the z-position of the cueball, that means that it's also going to move farther away from the camera:  <keys "cuemovez" 1 0 15 0 30 3 This is going to be used in the rotation of the cueball. It will rotate just a bit about x when the abrupt bounce happens:  <keys "cuerotz" 1 0 15 360 30 180  <keys "cuerotx" 1 0 15 0 30 -5 This is going to be used as the x-position of the fourball, so it stays in place until frame 15, then shoots forward on x:  <keys "fourmove" 1 4 15 4 30 12  <keys "fourrotz" 1 0 15 0 30 180  <keys "fourrotx" 1 0 15 0 30 5 Four ball:  <normalize  <position fourmove 0 0 Follow the "four" keys  <radius 3  <apply "glossy"  <reflectivity 0.1  <color 1 0 0  <rotate fourrotx 0 fourrotz Follow four rotation keys  <imagemap "c:\imagemaps\raytrace_imagemap_1.jpg"  <object sphere "My Sphere" Cue Ball:  <normalize  <position cuemovex 0 cuemovez Follow cue keys  <radius 3  <apply "glossy"  <rotate cuerotx 0 cuerotz Rotate per cue keys  <reflectivity 0.1  <specular 0  <roughness 0  <color 1 1 1  <color 0 0.5 1  <texturemap "marble" 0.01 30  <object sphere "My Sphere" Felt: The felt surface is going to be a arbitrarily large rectangle, to simulate a pool table surface, it will also be imagemapped with a tiled image of real felt. Rectangles have to be bound within a structure:  <structure  <normalize  <apply "matte"  <ambient 0.5  <vtx0 10000 -3 10000 These are the vertices of the rectangle.  <vtx1 10000 -3 -10000  <vtx2 -10000 -3 10000  <color 0 0.5 0  <tile 10000 10000 Tile 10000 x 10000 area  <imagemap "c:\imagemaps\felttile.jpg"  <object rect "felt"  </structure Optimize:  <object bound Light:  <normalize  <position 50 500 -750  <color 1 1 1  <object light "light_1" Camera:  <viewlocation 0 2 14  <viewtarget 0 0 0

This is the end product of the script

Some notes and tips for adding mathematical expressions to your ray traces:

Always remember that you must prefix an expression with '!' (an exclamation point). No whitespace is allowed inside the expression either, whitespace is the signal to the evaluator that the expression is complete.


A simple boilerplate way to make circles is to add the following expressions:


Now it treats the frame number as a fractional part of one whole rotation. Now you just determine the radius you want, and you have a circle.

You can also set a variable for the radius so it lives in one easy to find place by adding a key:

 <keys "radius" 1 10

Now "radius" will remain constant, and can be changed for all instances with little effort.

You can also model an oval by giving unequal radii for the sin and cos function.

Spinning the camera would be:

 <viewlocation !cos(loopv(cframe(0))*6.281835)*radius 0 !sin(loopv(cframe(0))*6.281835)*radius

This will move in a circle in/out and left/right, not up/down

Here is a list of valid expressions for the ray tracer's SceneScript.

One more example.

Keyboard Navigation
, Previous Page . Next Page t TOC i Index o Operators g Glossary
WinImages F/x, Morph and all associated documentation
Copyright © 1992-2007 Black Belt Systems ALL RIGHTS RESERVED Under the Pan-American Conventions
WinImages F/x Manual Version 7, Revision 6, Level A

Valid HTML 4.01 Loose

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses python 2.7
Page 244