home *** CD-ROM | disk | FTP | other *** search
/ Ray Tracing Box / RAY_CD.mdf / RAYTRACE / FORM / DOCS / TUTOR.DOC < prev   
Encoding:
Text File  |  1993-11-11  |  19.6 KB  |  626 lines

  1. TUTOR.DOC
  2.  
  3. REGISTRATION. 
  4.  
  5.     This program is FREE, you don't have to register. I would like
  6. some feedback though, you could consider this some sort of
  7. registration if you like. For more info see readme.1st and form.doc.
  8.  
  9.  
  10. HOW TO RUN IT 
  11.  
  12.     In it's simplest invocation you can just type "FORM". Don't do
  13. that yet, you would normally supply a filename, try "FORM
  14. SAMPLE1.FRM". Usually form files have a .frm extension and this is
  15. assumed of you do not supply it. 
  16.  
  17.     This should display a sort of staircase in grey on your monitor
  18. with the message "Press any key to continue" splatted all over the
  19. top line. You can abort displaying by pressing <ESC>.
  20.  
  21.     Press a key, the form program should return your text screen, and
  22. display :-
  23.  
  24. Zbuffer used DOS Memory
  25. Display took 19.67 secs at resolution 320x200
  26. // sample file
  27. a_spine=box <0.2 , 0.5 , 0.2 > stack 10 in 50% grow 0.2 twist 90;
  28. tweeny_bit = sphere 0.3 stack 1;
  29. tweeny_bit, [a_spine] stack 30 in 75% twist 360;
  30. end;
  31. Zbuffer used DOS Memory
  32.  
  33.     The first and last lines of this output are really debug messages.
  34.  
  35.     The second line is self explanatory, the rest of the lines are
  36. the contents of sample1.frm, FORM always displays the text that
  37. produced the form just displayed. It also puts this text into a file
  38. temp.frm, and also at the beginning of any pov file it outputs. Well
  39. you wouldn't want to accidently lose your form would you?  We should
  40. now be able to configure the program so it runs faster and produces a
  41. better quality display.
  42.  
  43.  
  44. CONFIGURING
  45.  
  46. 1. DIRECT SCREEN ACCESS
  47.  
  48.     The default configuration uses the BIOS to perform its display
  49. function, this is extremely slow and limited. So to improve the
  50. display speed you can turn off the "compatibility mode" with the
  51. -bios- command line switch. 
  52.  
  53.     WARNING: As with all screen mechanisms that bypass BIOS there may
  54. be some danger of damage to your monitor, this is very unlikely but
  55. if you are unhappy do not use this command line switch. 
  56.  
  57.     Try running "FORM -bios- sample1" this should have displayed
  58. quite a bit faster. If you saw nothing or something strange then it
  59. looks as if you may (I only say may) be unable to use the faster access, 
  60. or higher resolution modes. All is not yet lost, you can try "FORM -bios-
  61. -modex sample1", this uses an alternative (more standard) method of
  62. accessing the VGA screen that is still much faster than BIOS, but
  63. doesn't use the SVGAKIT drivers.
  64.  
  65.     If "-bios-" or "-bios- -modex" worked then you can edit the line
  66. "bios=no" to "bios=yes" in sstools.ini, and also, optionally, insert the
  67. line "ModeX=yes" set (or set an environment variable "FORM=-bios- -modex")
  68.  
  69. 2. SUPERVGA MODES
  70.  
  71.     Now we will try higher resolution modes. This will probably only
  72. work if you have a "Super VGA" card.
  73.  
  74.     Try "FORM -res2 sample1" you should see the same picture but the
  75. edges should be smoother. When you press a key the screen resolution
  76. used will be displayed. This may still be 320x200 if FORM couldn't
  77. find a higher resolution mode for your card. 
  78.  
  79.     If that worked try "FORM -res3 sample1" (you're probably getting
  80. bored of sample1 by now). Again you should see the same picture but
  81. the edges should be smoother still. When you press a key the screen
  82. resolution used will be displayed, and the time taken.
  83.  
  84.     If -res2 didn't work, then I'm afraid you're stuck with plain old
  85. 320x200.  If -res3 didn't work, then I'm afraid you're stuck with
  86. res2.
  87.  
  88.  
  89. Res2 tries modes 640x350, 640x400, and 640x480
  90. Res3 tries all res1 and res2 modes and 800x600, 1024x768 and 1280x1024
  91.  
  92.     You may find that your system supports a higher resolution than
  93. FORM will use, this is probably because FORM couldn't find enough
  94. extended or expanded memory for it's workspace, it will use the 
  95. highest resolution that it can.
  96.  
  97.  
  98.     To set a resolution as "permanent" edit the sstools.ini file
  99. "screen_res=" line. Don't necessarily pick screen_res=3 as the time
  100. taken to display at the higher resolutions can be annoyingly long. I
  101. use res1 normally, res2 on a 486 (cos they're blindingly fast) and
  102. either res2 or res3 when I'm saving the screen to a file (more about
  103. saving screens in a bit).
  104.  
  105.  
  106. Saving the screen 
  107.  
  108.     If you add the command line "-save" the screen will be saved to a
  109. file called TEMP.GIF, you can override the output type and save as a
  110. TGA file with the -t option, you can also override the output
  111. filename if you use -save=filename, (.GIF ot .TGA will be added as
  112. appropriate). 
  113.  
  114.  
  115. TUTORIAL
  116.  
  117. Creating your own forms
  118. =======================
  119.  
  120.     If you do not give FORM a file to process it will accept input
  121. from the keyboard, this is only useful when you are playing around, a
  122. much better method would be to use an editor to edit your form, and a
  123. batch file like FORMED.BAT, which you would run with a filename to
  124. edit. 
  125.  
  126.     FORMED is a simple batch file that runs in an edit/display loop,
  127. so it allows you to progressively change your form. It is also useful
  128. for getting rid of errors, and is probably worth using throughout
  129. this tutorial.  To run try "FORMED TEST.FRM", your editor (taken from
  130. an environment variable "edit" or the batch file edit.bat) will run
  131. up with TEST.FRM as the input file. When you leave your editor FORM
  132. will be run with an input file of TEST.FRM.
  133.  
  134.     In this tutorial we will assume you are using FORMED.
  135.  
  136.     Run FORM you will see some text like:
  137.  
  138.             Copyright message
  139.             Form: 
  140.                 $Revision: 1.7 $ $Date: 93/11/11 13:00:11 $
  141.  
  142.  
  143.     This is pretty much useless information and is there mainly for
  144. my purposes.
  145.  
  146. SIMPLE FORM SCRIPT
  147.  
  148. Start up FORMED and enter exactly (FORM is case-sensitive)
  149.  
  150.             sphere; 
  151.             end;
  152.  
  153. Quit your editor and FORM will display a single sphere in the middle
  154. of the screen.
  155.  
  156. This is a simple Form script. 
  157.  
  158.     All form descriptions end with the word "end;" This tells FORM
  159. where the end of the input is. FORM will then produce any required
  160. output. If the description just ended without the word "end" no
  161. output would be generated.
  162.  
  163.     What you instructed FORM to do was to create a form consisting of
  164. a single sphere. Note the semi-colon, this told FORM that the object
  165. had finished and not to try and interpret the next word as part of
  166. the same object. 
  167.  
  168.     Form is blind to spaces, as long as there is at least one space,
  169. tab or newline FORM doesn't care.
  170.  
  171.     Form also accepts comments (only really useful in files), these
  172. look like "/* comment here */" or "// comment until the end of the
  173. line"
  174.  
  175. ERRORS
  176.  
  177. FORM does not come with much error checking, what there is comes in
  178. two flavours.
  179.  
  180. 1. SYNTAX ERRORS 
  181.  
  182.     If you entered somthing wrong FORM will print out something like:
  183. "error on line 2 near:" and then print out the script upto the point
  184. where it failed. The error is usually a missing semi-colon from the
  185. previous word, or a spelling mistake.
  186.  
  187. 2. Program errors.
  188.  
  189.     As I said FORM does very little error checking, so it can (and
  190. WILL) allow you to enter something that doesn't really make sense to
  191. it (after all it's only a dumb computer). In these cases you will
  192. probably get a beep and a message along the lines of "FPE SIGNAL".
  193. FORM may even return to DOS. All that I can say about your error is
  194. that it probably consisted of one of "bend, twist, or grow" without a
  195. preceeding "stack" ot "list". This explanation will make a little
  196. more sense later. 
  197.  
  198.  
  199. JOINING
  200.  
  201. Run FORM again, this time enter
  202.  
  203.         sphere, box;
  204.         end;
  205.  
  206.     You got a sphere and a box stacked on top of each other, in FORM
  207. when two objects are separated by a "," they are "joined" end to end. 
  208.  
  209.  
  210. STACKING
  211.  
  212. Try     sphere stack 5;
  213.         end;
  214.  
  215.     This time you get 5 spheres "stacked" on top of each other.
  216. Stacking is not quite the same as joining, but it is similar. 
  217.  
  218. Try     sphere, box stack 5;
  219.         end;
  220.  
  221.     You get three spheres and two boxes because you asked to stack
  222. them 5 high. The stack works on the sphere, box in order so you get:
  223.  
  224.     sphere
  225.     box
  226.     sphere
  227.     box
  228.     sphere
  229.  
  230.  
  231. NUMBERS 
  232.  
  233.     Now is a good time to make some points about numbers, in FORM
  234. scripts all numbers are floating point, that means that 1.5 is a valid
  235. number anywhere that 1 is valid. BUT if FORM only expects an integer
  236. then the number will be truncated to 1. (e.g. for stack)
  237.  
  238.     All angles are in degrees, since that is what most people are
  239. used to.
  240.  
  241.     Expressions are allowed, i.e. 3*360 is a perfectly valid way of
  242. saying three turns of a circle.
  243.  
  244.     Numbers are as far as I can remember always separated from each
  245. other by a comma or keyword unless they are in an expression as above.
  246.  
  247.     If you have to enter three numbers together you will almost
  248. certainly need to enclose them in "<" and ">".
  249.  
  250. STACK TRANSFORMS
  251.  
  252.     Once you have stacked or joined some objects you can apply some
  253. transformations to them, for example you can "compress" them slightly
  254. e.g.
  255.  
  256.         sphere stack 10 in 7;
  257.         end;
  258.  
  259.     This will fit 10 spheres into the space that would have been
  260. occupied by 7. Another way is
  261.  
  262.         sphere stack 10 in 50%;
  263.         end;
  264.  
  265. This stacked them into 50% of their original space.
  266.  
  267.  
  268. you can bend them
  269.     
  270. BEND
  271.         sphere stack 10 bend 90;
  272.  
  273. This bent them so that the last one is bent 90 degrees out of position. 
  274.  
  275. and 
  276. TWIST
  277.         box stack 10 twist 45
  278.  
  279. This twists them around their own axis, similar yet different to bend. 
  280.  
  281. OFFSET TWIST
  282. A variation on twist is:
  283.  
  284.         sphere stack 40 twist 360 , 1;
  285.  
  286. in this case the boxes are twisted but not around their own axes, the
  287. second number is the amount of offset.
  288.  
  289. TWISTX and TWISTZ
  290.     These are two more variations on TWIST, can be nice when combined
  291. with BEND try
  292.         torus stack 20 in 25% twistz -90 bend 180; (see flip.frm)
  293.  
  294. GROW
  295.         sphere stack 10 grow 0.1;
  296.  
  297. This "grows" the stack leaving the first item alone, and
  298. progressivly "growing" each item until the last is "grown" by the
  299. specified amount.
  300.  
  301. other types of grow are:
  302. powered_grow
  303. centered_grow
  304. powered_centered_grow
  305.  
  306. There is very little difference between these types, but you might
  307. like to play with them later. (I might like to improve the syntax as well)
  308.  
  309. COMBINATIONS
  310.  
  311. Twist, bend, grow can be combined in ANY order as in 
  312.  
  313.     sphere stack 40 in 75% twist 45 bend 60 grow 1.3;
  314.  
  315. NOTE the semi colon at the end , this means that the object is
  316. finished, most commands in FORM finish with a semicolon.
  317.  
  318. NOTE ALSO if we had entered
  319.  
  320.     sphere stack 40 in 75% bend 60 twist 45 grow 1.3;
  321.  
  322. We would have got a different form.
  323.  
  324. CHANGING SIZES
  325.  
  326. In FORM there are only four basic objects, the "sphere", the "box",
  327. the "torus", and the "ellipse". All of these have a basic size and
  328. shape. But you are not limited to these defaults, you can set your
  329. own values for radii/proportions.
  330.  
  331. For example the word "sphere" creates a sphere with a "radius" of
  332. half a unit, the phrase "sphere 1.5", creates a sphere three times as
  333. large. This means we can vary the appearance of a sphere so:
  334.  
  335.     sphere , sphere 0.8 stack 10;
  336.  
  337. Will give a stack of alternating large and small spheres.
  338.  
  339. BOX
  340.     for boxes you can again vary the size as in
  341.  
  342.     box 1.5; 
  343.  
  344. but you can also turn the box into a brick by specifying three
  345. lengths for it as in: 
  346.  
  347.         box <0.5 , 1.5 , 0.2>;
  348.  
  349. which gives a box 1 unit across 3 units high and 0.4 units deep. 
  350.  
  351. NOTE the "<" and ">", these are required.
  352.  
  353. ELLIPSE
  354.  
  355.     The default ellipse is indistinguishable from a sphere, the
  356. reason spheres are included is simply because they display faster.
  357. Ellipses (or ellipsoids as they should be called) can be modified.
  358. You can specify their width and height, or their size along all three
  359. axes to give smartie and rugby ball shapes.
  360.  
  361.     e.g. 
  362.         ellipse;                     a spherical ellipse 
  363.         ellipse 0.5 , 0.1;           an ellipse 0.5 wide, 0.1 high (a smartie)
  364.         ellipse <1.4 , 0.2, 0.34>    an ellipse 1.4 wide, 0.2 high, 0.34 deep.
  365.                                      (rugby ball along x axis)
  366.  
  367.  
  368. TORUS
  369.  
  370.     Toroids, are doughnut shapes, you specify the small radius and
  371. the large radius, defaults are: 0.2 , 0.5. These are quite expensive
  372. computationally, but can give nice hollow stem effects, if you don't
  373. need them to be hollow try ellipse above to achieve a similar effect.
  374.  
  375.     e.g.    torus;
  376.             torus 0.3, 0.6;
  377.  
  378.  
  379. DEFINING YOUR OWN OBJECTS :  named objects 
  380.  
  381.     Unfortunately you cannot define your own primitives as such, but
  382. you can create NAMED OBJECTS. The way to do this is best shown by an
  383. example:-
  384.  
  385. my_object = sphere stack 10 bend 30;
  386.  
  387.     This defines an object called "my_object", it will not be
  388. displayed, to display it you would need a line like:
  389.  
  390. my_object;
  391.  
  392.     This line actually creates one of my_object for display. Once you
  393. have defined an object you can use it anywhere you like - so you can
  394. now have:
  395.  
  396.     my_object = sphere stack 10 bend 30;
  397.     my_object , box 5;
  398.     end;
  399.  
  400.     Not especially useful, but some of the more fun operations can
  401. only be performed using named objects. Another use for named objects
  402. is to speed up display, if you are using a lot of torus or ellipses,
  403. you might use named objects to speed things up like so:
  404.  
  405.     torus stack 30 bend 20; 
  406.  
  407.     will take x seconds to display on my machine, so I change the
  408. description to read:
  409.  
  410.     basic_object = ellipse 0.7, 0.5;    // min rad+ maj rad = 0.5+ 0.2 = 0.7
  411.     basic_object stack 30 bend 20;
  412.  
  413.     this now displays in y seconds. When I am happy with the form I
  414. can now change the first line to read
  415.  
  416.     basic_object = torus 0.2 , 0.5;
  417.  
  418. and I get my original picture back again.
  419.  
  420. SQUARE BRACKETS
  421.  
  422.     If you include a named object in a list you can optionally turn
  423. it on its side by using "[" object_name "]". This makes the obect
  424. grow out sideways. This is used in SAMPLE1 to get the stair treads.
  425.  
  426. FAN
  427. ===
  428.     This is not very well named, it produces a "dandelion head" effect, try
  429.  
  430.     ellipse <0.2 , 0.5, 0.2> fan 40 , 180;
  431.  
  432.     The first value after fan is the number of copies to make, just
  433. like stack.  The second value is the amount of spread to use, 180 is
  434. full spread, 90 gives a hemisphere etc.
  435.  
  436.     There is an optional third value, "tightness", this gives "pulls"
  437. the individual spikes together, try
  438.  
  439.     ellipse <0.2 , 0.5, 0.2> fan 40 , 180 , 0.1;
  440.  
  441. remember you can use named objects wherever you had a simple object,
  442. so you could try:
  443.  
  444.     sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45;
  445.     sos fan 40 , 180 , 0.1;
  446.  
  447. It starts taking longer doesn't it, but it does look quite complex
  448. (it is there are now 800 spheres in that picture).
  449.  
  450. The base in "flagpole.frm" is made from a fan of smartie shaped ellipsoids.
  451.  
  452. WEB
  453. ===
  454.     This on the other hand is well named, it produces a spiders web
  455. effect. It does however work best with previously defined stacks of
  456. objects.
  457.  
  458.     try 
  459.     sos /* stack of spheres */ = sphere stack 10;
  460.     sob /* stack of boxes */ = box stack 10 bend 20 twist 45;
  461.     sos web 3 with sob 4;
  462.     
  463. there are three more optional values, so for a full web you can get
  464.  
  465.     OBJECT web SPOKE_NUMBER with DEFINED_OBJECT scale SCALE_NUMBER
  466.     WEBBING_NUMBER HOLE_NUMBER EXCESS_NUMBER (uppercase words
  467.     supplied by you)
  468.  
  469.  
  470.     so using the above objects "sob" and "sos" we can get
  471.  
  472.     sos web 5 with sob scale(2) 10;
  473.  
  474.     will enlarge the "webbing" to twice its original size.
  475.  
  476.     sos web 5 with sob 10 hole 0.5
  477.  
  478.     will leave a hole about half the length of the spokes in the
  479.     middle. 
  480.  
  481.     sos web 5 with sob 10 excess 0.5
  482.  
  483.     will make the webbing continue on past the end of the spokes for
  484.     a distance of about half the length of the spokes.
  485.  
  486.  
  487.     see web1.frm, web2.frm and webgood.frm for examples of this.
  488.  
  489.  
  490. HEIGHTLESS OBJECTS
  491.  
  492.     When an object has been made with WEB or FAN it has no height,
  493. stacking them together has no effect, you MUST place an object in
  494. between them to get them to stack. But what if you don't want to see
  495. an inbetween object, what do you do? Well you can "delete" it so that
  496. it becomes invisible and works just as a spacer. a simple example is:
  497.  
  498.     sphere , sphere , box, sphere delete 2 delete 4 stack 20;
  499.  
  500.     will delete the second and fourth objects, giving the effect of a
  501. pair of spaced out spheres and boxes.
  502.  
  503. BUG: you will probably have to change the above to 
  504.     my_obj =    sphere , sphere , box, sphere delete 2 delete 4;
  505.     my_obj stack 5;
  506. to get it to work
  507.  
  508.  
  509. Other operations
  510. ================
  511. you can
  512.  
  513. DELETE  x
  514.     this removes the x'th piece from the from.
  515. and 
  516. DELETE x..y
  517.     which removes the x to y'th pieces from the from.
  518.  
  519. useful for getting rid of clutter, or "spacing objects" (I'll get to
  520. these later)
  521.  
  522.  
  523. MOVE < x , y , z>
  524.     Moves the whole objects so far x units along the x axis etc. I'm still
  525. not very happy about this command, but it might be usefull.
  526.  
  527.  
  528.  
  529. Spacing Objects
  530.  
  531.     This is a generic term used for objects used to get round
  532. problems in the system. For example we have made a fan
  533.  
  534.     sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45 , 0.5;
  535.     nicefan = sos fan 10 , 90, 0.1
  536.  
  537. and we want to put 5 on top of each other:
  538.  
  539.     nicefan stack 5;
  540.  
  541. (press <ESC> if you get bored waiting for it to finish)
  542.  
  543. that didn't work because fans have no or very little height, we need
  544. to space them around.   
  545.  
  546. so try
  547.     
  548.     sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45 , 0.5;
  549.     nicefan = sos fan 10 , 90, 0.1
  550.     spaced_fan = nicefan , sphere 5 delete 2; 
  551.     // the sphere is just a spacing object and isn't meant to be seen. 
  552.     // sphere is radius 5 because if we look closely at sos we can  
  553.     // guess it's about 5 units tall (10 * 0.5)
  554.     // alternatively we could have had
  555.     // spaced_fan = nicefan , sos delete 2 // which would have been
  556.     // more accurate
  557.  
  558.     spaced_fan stack 5;
  559.  
  560. works fine. Try it yourself without the delete, to see what's going on.
  561.  
  562.  
  563. Negative Spacing Objects
  564.  
  565. This is another workaround, consider:
  566.     a = sphere stack 10 in 10%;
  567.     b = sphere stack 10 in 10%;
  568.  
  569. then the join in "a,b" should be virtually indistingushable, 
  570. unfortunately it isn't, there's no overlap!
  571.  
  572. so we introduce a negative spacer 
  573.  
  574.     spacer = sphere -0.4 delete 1;
  575.     a,spacer,b; 
  576.  
  577. this then looks OKish. I'll be fixing this problem in a later release.
  578.  
  579.  
  580. Textures (POV users only)
  581. ========
  582.  
  583.     FORM does not support textures as such, but it does allow some 
  584. level of textures for POV usage. To apply a texture simply put the keyword
  585. texture and the texture name after the object.
  586. e.g.
  587.  
  588.         sphere texture Red;
  589.  
  590. textures apply (in POV) to all uncoloured objects, so :
  591.  
  592.         a_piece = sphere , sphere texture red, box stack 20 texture blue;
  593.                 
  594.         will colour half of the spheres and all the boxes box "blue", 
  595. and the remaining sphere will be coloured "red".
  596.  
  597. Note the above could have been written
  598.  
  599.         a_piece = sphere, sphere texture red, box stack 20;
  600.         a_piece texture blue;
  601.  
  602. Also note once textured an object cannot be "repainted".
  603.  
  604. If the texture you want is not already a predefined one you can 
  605. "roll your own" by enclosing it in Quotes for example we could have said:
  606.  
  607.         a_piece texture "Metal pigment{White}";
  608.  
  609.  
  610. Authors Note
  611. ============
  612. Texturing is still in it's infancy (introduced at the start of NOV 93), I 
  613. still have to fix it so that textures can be applied between transforms. 
  614. It can be done in the current version but it doesn't work properly.
  615.  
  616.  
  617.  
  618.  
  619.  
  620. Other command line features are described in another document, look for it  
  621. as some of the features can be useful. 
  622.  
  623.         rummy@snaffle.demon.co.uk
  624.  
  625.         Andrew Rowbottom
  626.