home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / rtrace / spec / sff.txt < prev   
Text File  |  1994-06-01  |  30KB  |  895 lines

  1. ----- SFF -----
  2.  
  3. The SFF ray-tracing format
  4.  
  5. Version 8
  6.  
  7. Anto'nio Costa, 1993
  8. acc@asterix.inescn.pt
  9.  
  10.  
  11. Table of Contents
  12.  
  13. Table of Contents 2
  14. 1. Introduction 3
  15. 2. Overview and Motivations 3
  16. 3. Main Sections 3
  17. 3.1. Viewing 3
  18. 3.2. Ambient and Background 4
  19. 3.3. Lights 4
  20. 3.4. Surfaces 4
  21. 3.5. Objects, Textures and Transformations 5
  22. 4. Compatibility 11
  23. 5. Examples 12
  24. 6. Conclusions 1 3
  25. 7. References 13
  26. 8. Annexes 14
  27. 8.1. Annex 1 - Font formats PPF and PPE 14
  28. 8.2. Annex 2 - CSG Example 17
  29. 8.3. Annex 3 - Textured Spheres Examples 18
  30. 8.4. Annex 4 - Striped Spheres Example 20
  31.  
  32.  
  33. 1. Introduction
  34.  
  35. The SFF (Simple File Format) is a simple way of describing geometry 
  36. (3D objects), colors, surfaces and so on. It is mainly used to describe 
  37. environments that are processed by programs called ray-tracers, 
  38. which simulate, at least to a certain extent, the physics of optical
  39. processes and interactions between light and matter.
  40.  
  41. The ray-tracing algorithm produces images of 3D objects by shooting 
  42. rays from a point in space (called eye point) through a grid of 
  43. points (centered in the look point) and then computing, for each of 
  44. these directions (which correspond basically to a screen pixel), the 
  45. color of the nearest object in that particular direction. For the 
  46. color calculation, the object's surface perpendicular vector (also called 
  47. normal vector) in the point of intersection with the ray is used to 
  48. determine the directions of auxiliary rays such as reflected and 
  49. transmitted rays, along with the light sources contributions. Each of these 
  50. contributions is scaled according to the object's surface characteristics 
  51. and then the pixel color is finally obtained and stored.
  52.  
  53. 2. Overview and Motivations
  54.  
  55. The first version of the SFF format was defined in late 1988, when 
  56. the first running version of the RTRACE ray-tracer was operational. 
  57. As this program was first written in Pascal, one major goal of SFF 
  58. was simplicity. As the Pascal language is not very good in I/O 
  59. support, the objective was to define it simple enough so that it 
  60. would not be too complicated to parse.
  61.  
  62. Another simple scene format is NFF (Neutral File Format), invented 
  63. by Eric Haines for his SPD package (Standard Procedural Database - 
  64. a collection of C programs that generates test scenes for any type 
  65. of rendering programs, including ray-tracers). It is widely used, 
  66. but does not support many advanced features. Within the RTRACE package
  67. there is a program to translate NFF scenes to SFF (it runs on UNIX 
  68. and DOS machines).
  69.  
  70. 3. Main Sections
  71.  
  72. Any SFF file is divided into 5 sections (or 6, for compatibility 
  73. purposes). In each one there are definitions, which can be of several types.
  74.  
  75. 3.1. Viewing
  76.  
  77. This section is the first one to appear. It has 5 lines, in which 
  78. the first is reserved for comments, and then come eye point, look 
  79. point, up vector and finally horizontal/vertical view angles. Each of 
  80. these items must be in a line. After each one, anything can follow 
  81. up to the end of line.
  82.  
  83. Example:
  84.  
  85. viewr
  86. 8 0 0- Eye<EOL>
  87. 0 0 0- Look<EOL>
  88. 0 1 0- Up<EOL>
  89. 20 20- View angles (horizontal and vertical)<EOL>
  90.  
  91. 3.2. Ambient and Background
  92.  
  93. After the viewing section comes the Ambient/Background section. It 
  94. has 3 lines, in which the first one is reserved for comments, the 
  95. second defines the background color and the last defines the ambient 
  96. color (in RGB format, both). After each item there may be comments 
  97. up to the end of line. 
  98.  
  99. Example:
  100.  
  101. colors<EOL>
  102. 0.1 0.5 0.7- Sky blue(red=0.1 green=0.5 blue=0.7)<EOL>
  103. 0.2 0.2 0.2- Dark gray(red=0.2 green=0.2 blue=0.2)<EOL>
  104.  
  105. 3.3. Lights
  106.  
  107. The Lights section defines lights, which can be of 3 types. Normally,
  108. the illumination decreases with distance; to make it distance-
  109. independent, the brightness should be negative (at least one component).
  110. The first line is for comments, and then each line defines a light. 
  111. To end the section, there must be an empty line.
  112. The point light is defined by code 1, a position and RGB brightness.
  113. The directional light is defined by code 2, position, RGB brightness, 
  114. direction, angle and attenuation factor. This kind of light irradiates 
  115. from a point in the specified direction inside the solid 
  116. angle, and the transition may be sharp (factor ~= 1) or soft 
  117. (factor >> 1). A truly directional light may be simulated by 
  118. positioning it far away from the objects and defining its brightness 
  119. negative.  The extended light is defined by code 3, position, 
  120. RGB brightness, radius and samples. This 
  121. kind of light is simulated by a sphere of specified radius, which 
  122. is sampled to calculate the actual illumination (a low value for samples 
  123. produces undesirable effects).
  124.  
  125. Example:
  126.  
  127. lights<EOL>  
  128. 1  4 5 1  0.9 0.9 0.9- White point light<EOL>
  129. 2  0 10 0  0 0 1  0 -1 0  15 5- Blue spot light<EOL>
  130. 3  8 1 -3  0 1 0  0.3 8- Green extended light<EOL>
  131. 1  1000 1000 1000  -1 -1 -1- Directional light<EOL>
  132. <EOL>
  133.  
  134. 3.4. Surfaces
  135.  
  136. In this section all the surfaces used must be defined. It starts with a 
  137. line reserved for comments and then a line for each surface, ending in 
  138. an empty line. There are 2 types of surface definitions.
  139.  
  140. The code 1 defines a surface by body RGB color, diffuse RGB factor, 
  141. specular RGB factor, specular exponent factor, metalness factor and 
  142. transmission RGB factor. The RGB's colors and factors must be in the 
  143. [0,1] range. The diffuse RGB factor defines the quantity of light coming 
  144. from all directions. The specular RGB factor defines the quantity of 
  145. light coming from the ideal reflection direction. The exponent factor 
  146. controls the shininess of the surface (the surface is very shiny with factors 
  147. bigger than 10; if near zero, it appears dull). The metalness factor makes 
  148. the reflected light appear white if it is small (like in plastic) 
  149. or metallic if it is near 1. The transmission RGB factor defines the 
  150. transparency. The sum of diffuse, specular and transparency RGB factors 
  151. should be equal or approximately 1.
  152.  
  153. The code 2 surface has body RGB color, smoothness RGB factor, metalness 
  154. RGB factor and transmission RGB factor. This is an alternative for 
  155. defining surfaces, but this method is more intuitive. The smoothness 
  156. RGB factor controls the shininess of the surface. 
  157.  
  158. Example:
  159.  
  160. surfaces<EOL>
  161. 1  1 0 0  1 1 1  0 0 0  0 0  0 0 0    - Matte<EOL>
  162. 1  0 1 0  0.5 0.5 0.5  0.5 0.5 0.5  10 0.5   0 0 0<EOL>
  163. 1  0 0 1  0.7 0.8 0.9  0.3 0.2 0.1  100 1    0 0 0   - Metallic<EOL>
  164. 1  1 1 1  0.1 0.1 0.1  0.1 0.1 0.1  200 0.8  0.8 0.8 0.8<EOL>
  165. 2  1 1 0  0 0 0  0 0 0  0 0 0   - Matte<EOL>
  166. 2  1 0 1  1 1 1  1 1 1  0 0 0   - Mirror<EOL>
  167. <EOL>
  168.  
  169. 3.5. Objects, Textures and Transformations
  170.  
  171. This next section defines the 3D objects, and optionally, textures and 
  172. transformations. It starts with a line reserved for comments and then by 
  173. object definitions. All objects are defined by a code, a surface index 
  174. (which specifies one of the previously defined surfaces, starting in 1), 
  175. a refraction index and then specific data.
  176.  
  177. The object with code 1 is a sphere and has a center point and radius. 
  178.  
  179. Example:
  180.  
  181. 1  3  1.0  4 3 2  0.5- Sphere centered at (4,3,2) radius=0.5<EOL>
  182.  
  183. The object with code 2 is a parallelipiped aligned with the XYZ axis. 
  184. It requires a center point and 3 dimensions for X, Y and Z directions. 
  185.  
  186. Example:
  187.  
  188. 2  2  1.0  1 0 0  10 1 3- Box at (1,0,0) with sizes (+-10,+-1,+-3)<EOL>
  189.  
  190. The object with code 3 is a bicubic patch or a group of bicubic patches. 
  191. It is followed by a translation vector, 3 scale factors for X, Y and Z, 
  192. and by a filename or "-". If there is a filename, then the patch's 
  193. geometry is read from that file, else it is read from the following lines 
  194. in the SFF file ending with an empty line. 
  195.  
  196. Example:
  197.  
  198. 3  1  1.0  0 0 0  1 1 1  example.pat- Read from file example.pat<EOL>
  199. 3  2  1.0  0 0 0  2 1 1  -  Read from the next lines<EOL>
  200. ...
  201.  
  202. A bicubic patch is defined by 12 points, arranged like in the figure:
  203.  
  204. Points P4, P5, P8 and P9 define the patch corners. The other points are 
  205. used in the definition of the frontiers and curvature of the patch. The 
  206. patch normal points outwards the screen (in P4-P8-P9-P5 counterclockwise 
  207. order, similar to the Right Hand rule). A file with patches is composed 
  208. of 2 parts. In the first come the patch's definitions using indices 
  209. into the vertex list, which is separated by a line and comes next 
  210. (and terminates by another empty line). 
  211.  
  212. Example:
  213.  
  214. 1 2 4 5 6 7 9 10 11 12 14 15- Patch 1<EOL>
  215. 2 3 5 6 7 8 10 11 12 13 15 16- Patch 2<EOL>
  216. <EOL>
  217. 0 -0.5 -1- Vertex 1<EOL>
  218. 0 0 -2- Vertex 2<EOL>
  219. 0 -0.5 -3<EOL>
  220. 1 0 0<EOL>
  221. 1 0 -1<EOL>
  222. 1 0.5 -2<EOL>
  223. 1 0 -3<EOL>
  224. 1 0 -4<EOL>
  225. 2 0 0<EOL>
  226. 2 0 -1<EOL>
  227. 2 0.5 -2<EOL>
  228. 2 0 -3<EOL>
  229. 2 0 -4<EOL>
  230. 0 -0.25 -1<EOL>
  231. 0 0 -2<EOL>
  232. 0 0 -3<EOL>
  233. <EOL>
  234.  
  235. Please note that the vertex list starts in index 1. Using these 2 lists, 
  236. it is possible to save a lot of space by avoiding redundant vertex 
  237. specification, and at the same time with only one definition create 
  238. many of these bicubic patch objects. Next figure is a picture of the 
  239. patch data of the above example.
  240.  
  241. Another example is in the next figure. The vase has 72 vertices and 64 
  242. patches. The main disadvantage of the patch primitive is the complexity 
  243. of finding intersections of rays with its surface. As it uses an 
  244. iterative algorithm with lots of floating-point operations, it takes 
  245. much more time to produce a picture, when compared to spheres and boxes.
  246.  
  247. The code 4 object is a cone or cylinder. It has an apex center point and 
  248. radius, followed by base center point and radius. The apex radius must 
  249. be less (in this case the object is a cone) or equal (cylinder) to the 
  250. base radius. The cone/cylinder are opened objects, ie, they do not have 
  251. any circular surfaces in the apex or base.
  252.  
  253. 4  1  1.0  0 1 0  0  0 0 0  1- Cone<EOL>
  254. 4  1  1.0  0 1 0  1  0 0 0  1- Cylinder<EOL>
  255.  
  256. The code 5 object is a polygon or a group of polygons, similar to 
  257. patches. It is followed by a translation vector, 3 scale factors for X, 
  258. Y and Z, and by a filename or "-". If there is a filename, then 
  259. the polygon's geometry is read from that file, else it is read from 
  260. the following lines in the SFF file, ending with an empty line. 
  261.  
  262. Example:
  263.  
  264. 5  1  1.0  0 0 0  1 1 1  example.pol- Read from file example.pol<EOL>
  265. 5  2  1.0  0 0 0  1 1 1- Read from the next lines<EOL>
  266. ...
  267.  
  268. A polygon is defined by its vertices in counterclockwise order. A file with 
  269. polygons is composed of 2 parts. In the first come the number of polygons 
  270. and the polygon's definitions using indices into the vertex list, which 
  271. is separated by a line and comes next (and terminates by another empty 
  272. line). 
  273.  
  274. Example:
  275.  
  276. 5  1 2 3 4 5- polygon 1<EOL>
  277. 3  1 6 2- polygon 2<EOL>
  278. <EOL>
  279. 0 0 -2- vertex 1<EOL>
  280. 1 0 0- vertex 2<EOL>
  281. 2 0 -1- vertex 3<EOL>
  282. 2 0 -3- vertex 4<EOL>
  283. 1 0 -4- vertex 5<EOL>
  284. 0.5 2 -1- vertex 6<EOL>
  285. <EOL>
  286.  
  287. The next figure is an image of the previous 2 polygons. Please note again 
  288. that it is possible to save a lot of disk space with the specification 
  289. of the polygon's list and vertices list in separate. The polygon's 
  290. normal is computed using the first 3 vertices in the following way: 
  291. vector from polygon's vertex #2 to polygon's vertex #1 *  vector from 
  292. polygon's vertex #3 to polygon's vertex #1. In the figure, the normal 
  293. of polygon #2 points to the right and out of the screen (its first 3 
  294. vertices are shown, along with the auxiliary vectors). Polygon's #1 
  295. normal points vertically up.
  296.  
  297. The code 6 object is a triangle or a group of triangles, similar to 
  298. polygons, but specifying also each vertex normal vector (these triangles 
  299. are also known as Phong triangles). It is followed by a translation vector, 
  300. 3 scale factors for X, Y and Z, and by a filename or "-". If there is 
  301. a filename, then the triangle's geometry is read from that file, else 
  302. it is read from the following lines in the SFF file, ending with 
  303. an empty line. 
  304.  
  305. Example:
  306.  
  307. 6  1  1.0  0 0 0  1 1 1  example.tri- Read from file example.tri<EOL>
  308. 6  2  1.0  0 0 0  1 1 1- Read from the next lines<EOL>
  309. ...
  310.  
  311. A triangle is defined by its vertices (data and normal) in counterclockwise 
  312. order. A file with triangles is composed of the triangle's definitions 
  313. in each line with first vertex data and normal, followed by the second 
  314. vertex data and normal and finally the third vertex data and normal 
  315. (and terminates by another empty line). 
  316.  
  317. Example:
  318.  
  319. 0 0 0 0 1 0  1 0 0 0 1 0  1 0 -1 0 1 0- Triangle 1<EOL>
  320. 0 0 0 1 1 0  0 1 0 1 0 0  0 1 -1 1 0 1- Triangle 2<EOL>
  321. ...
  322.  
  323. In this example, the first triangle has vertices (0,0,0) (1,0,0) 
  324. and (1,0,-1). The normals at these vertices are (0,1,0) (0,1,0) and 
  325. (0,1,0), ie, they all have the same direction. The second triangle has 
  326. vertices (0,0,0) (0,1,0) and (0,1,-1). Its normals are (1,1,0) 
  327. (1,0,0) and (1,0,1).
  328.  
  329. The code 7 object is an extruded primitive derived from closed segments 
  330. composed by lines and splines. This object is very well suited to trace 
  331. high quality text, although it may be used for many other purposes. It 
  332. is followed by a filename or "-". If there is a filename, then the 
  333. character's geometry is read from that file, else it is read from 
  334. the following lines in the SFF file, ending with an empty line.
  335.  
  336. Example:
  337.  
  338. spacing     0.1<EOL>
  339. orientation 0 0 -1  0 1 0  1 0 0<EOL>
  340. encoding    ascii.ppe<EOL>
  341. font        roman.ppf<EOL>
  342. scale       0.4 0.4 0.2<EOL>
  343. at          1 1 2  "RTrace /copyright/ Antonio Costa 1993"<EOL>
  344. font        times.ppf<EOL>
  345. scale       0.5 0.6 0.3<EOL>
  346. at          0 3 0  "Etc"<EOL>
  347. ...
  348.  
  349. The spacing keyword defines the separation between characters. Most 
  350. of the supplied fonts have its characters enclosed in a 1 unit square. 
  351. The orientation keyword defines how the text appears in the 3D space; 
  352. the first vector defines the text direction, the second the up 
  353. direction and the third the extrusion direction. As these are 
  354. independent, it is possible to slant the text or create more complex 
  355. effects. The encoding keyword specifies a file which contains 
  356. translations from character names to character codes, which are 
  357. used to access the character data. The font keyword specifies a 
  358. file which contains the character's data (number of closed 
  359. segments - lines and splines - and other data for each character). 
  360. The scale keyword defines the scaling for the characters, using the 
  361. directions specified with the orientation keyword. Finally, the at 
  362. keyword specifies the starting baseline position and which 
  363. characters to trace. With the supplied font files, it is possible 
  364. to use POSTSCRIPT names for the characters in almost all languages; in 
  365. this case, the character name must be enclosed in / /.
  366.  
  367. The next figure is an example of high quality text with textures. Please 
  368. note the use of international characters like c and g, because they 
  369. are supported in the font files. The second line is similar to the first 
  370. except in the scale, which is wider. The fourth line uses a different 
  371. font file. As the characters use a very precise mathematical description 
  372. which is used to trace them, they result much better than approximating 
  373. them with small polygons (which do not produce the same quality and 
  374. increase the tracing time). A description of font files is in Annex 1.
  375.  
  376. The next codes are not used to define primitive objects, but rather 
  377. to associate, transform or texture objects. The code 64 defines a 
  378. texture to be applied to an object, usually the previous none. It is 
  379. followed by a type, an object id, a transformation matrix and local 
  380. data. The supported types are:
  381.  
  382.  
  383.  
  384. Type    Name        Parameters
  385.  
  386. 0    Null
  387.  
  388. 1    Checker        surface
  389.  
  390. 2    Blotch        scale   surface   [file(colormap)]
  391.  
  392. 3    Bump        scale
  393.  
  394. 4    Marble        [file(colormap)]
  395.  
  396. 5    FBM        offset   scale   omega   lambda   threshold   octaves
  397.  
  398. 6    FBM Bump    offset   scale   lambda   octaves
  399.  
  400. 7    Wood        color(red)   color(green)   color(blue)
  401.  
  402. 8    Round        scale
  403.  
  404. 9    Bozo        turbulence   [file(colormap)]
  405.  
  406. 10    Ripples        frequency   phase   scale
  407.  
  408. 11    Waves        frequency   phase   scale
  409.  
  410. 12    Spotted        [file(colormap)]
  411.  
  412. 13    Dents        scale
  413.  
  414. 14    Agate        [file(colormap)]
  415.  
  416. 15    Wrinkles    scale
  417.  
  418. 16    Granite        [file(colormap)]
  419.  
  420. 17    Gradient    turbulence   direction(x)   direction(y)   
  421.             direction(z)   [file(colormap)]
  422.  
  423. 18    Imagemap    turbulence   mode   axis(horizontal)   
  424.             axis(vertical)   file(image)
  425.  
  426. 19    Gloss        scale
  427.  
  428. 20    Bump 3D        scale   size
  429.  
  430.  
  431. The object id is a number that identifies a previously defined object 
  432. (the first object has number 1; 0 means the previous object). The 
  433. transformation matrix is a group of 16 real numbers that defines a 
  434. 4x4 matrix - the first 4 numbers specify the first column of the 
  435. matrix and so on (the last column usually is 0 0 0 1, but may be different!).
  436.  
  437. The code 65 defines a transformation to be applied to an object, usually 
  438. the previous none. It is followed by an object id and transformation 
  439. matrix data. The order is X1 Y1 Z1 W1 ... X4 Y4 Z4 
  440. W4. The matrix is like:
  441.  
  442. X1X2X3X4
  443. Y1Y2Y3Y4
  444. Z1Z2Z3Z4
  445. W1W2W3W4
  446. SUM Wi != 0
  447.  
  448. The code 66 is used to apply CSG (Computer Solid Geometry) operations to 
  449. the previously defined objects. A CSG operation has always two components 
  450. which are combined into an higher level object. This CSG object can be 
  451. the union, the subtraction or the intersection of two objects. Any CSG 
  452. object can have CSG objects as its components. The main restriction 
  453. is that the components must always define a closed volume in 3D space. 
  454. It is followed by type and type-dependent data like in the table:
  455.  
  456.  
  457.  
  458.  
  459. Type    Explanation            Parameters
  460.  
  461. 0    Start of left components    surface refraction operation
  462.  
  463. 1    Start of right components
  464.  
  465. 2    End
  466.  
  467. The CSG operations are union (0), subtraction (1) and intersection (2). 
  468. The surface id may be zero; in this case the color of the CSG object 
  469. is the result of the colors of the its components. 
  470.  
  471. Example:
  472.  
  473. 66 0 1 1 1 - CSG subtraction<EOL>
  474. 1    2 1  0 0 0 1- Sphere at (0,0,0) radius=1<EOL>
  475. 66 1- Right component of CSG<EOL>
  476. 1    3 1  0 1 0 0.6- Sphere at (0,1,0) radius=0.6<EOL>
  477. 2    3 1  1 0 0 0.5 0.5 0.5- Box at (1,0,0) sizes=0.5,0.5,0.5<EOL>
  478. 66 2- End of CSG<EOL>
  479.  
  480. The resulting object is in the next figure. Its SFF description is in 
  481. Annex 2.
  482.  
  483. It is very important not to have aligned faces in the CSG objects (or 
  484. aligned edges too), because the CSG operations are very sensitive to 
  485. numerical inaccuracies.
  486.  
  487. The code 67 is used to group objects so that the whole set of objects is 
  488. treated like a primitive object. This is mainly used with CSG operations 
  489. so that there are no non-closed objects in the CSG object. It is 
  490. followed by a surface id and refraction. If the surface id is non-zero 
  491. then the list object has a color, which supersedes the individual colors. 
  492.  
  493. Example:
  494.  
  495. 67 0 0 1- Start of list<EOL>
  496. 4 1 1  0 1      0 1     0 0 0 1- Cylinder (opened)<EOL>
  497. 4 1 1  0 1.001  0 0.001 0 1 0 1- Cone (very flat)<EOL>
  498. 4 1 1  0 -0.001 0 0.001 0 0 0 1- Cone (very flat)<EOL>
  499. 67 1- End of list<EOL>
  500.  
  501. This object (closed cylinder) can be safely used inside any CSG operation; 
  502. otherwise, some errors would appear in the ray traced image.  
  503.  
  504.  
  505. 4. Compatibility
  506.  
  507. For compatibility with old SFF files, the textures can be specified 
  508. completely after the objects. In this case, there must be an empty line 
  509. after the objects section and then the textures may be defined. The 
  510. code 64 should not appear in the line. 
  511.  
  512. Example:
  513.  
  514. objects<EOL>
  515. 1 1 1  0 0 0 1- Sphere<EOL>
  516. 2 2 1  0 2 0 1 1 1- Box<EOL>
  517. <EOL>
  518. textures<EOL>
  519. 3 1  1 0 0 0  0 1 0 0  0 0 1 0  0 0 0 1  0.4- Bump<EOL>
  520. 9 2  2 0 0 0  0 1 0 0  0 0 1 0  0 0 0 1  0.5 bozo.map- Bozo+colormap<EOL>
  521. <EOL>
  522.  
  523.  
  524. 5. Examples
  525.  
  526. The supported textures allow for an immense variation of colors, patterns, 
  527. etc. Next there are some examples. The SFF descriptions of these spheres 
  528. is in Annex 3.
  529.  
  530.   Agate.     Blotch.     Bozo.
  531.  
  532. Also it is possible to modify the primitive objects using transformations 
  533. like in the next examples.
  534.  
  535. Sphere stretched in one direction and squashed in another direction. The 
  536. description of the two spheres with textures is like:
  537.  
  538. 1 2 1 0 1 0 1- Top sphere<EOL>
  539. 64 0 0 1 0 0 500 0 1 0 500 0 0 1 0 0 0 0 1- Translate texture<EOL>
  540. 64 1 0 1000 0 0 0 0 1000 0 0 0 0 0.25 0 0 0 0 1 3 - Scale texture<EOL>
  541. 1 2 1 0 -1 0 1- Bottom sphere<EOL>
  542. 65 0 0.5 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1- Stretch and squash<EOL>
  543. 64 0 0 0.5 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1- Texture on normal sphere<EOL>
  544. 64 0 0 1 0 0 500 0 1 0 500 0 0 1 0 0 0 0 1<EOL>
  545. 64 1 0 1000 0 0 0 0 1000 0 0 0 0 0.25 0 0 0 0 1 3<EOL>
  546.  
  547. In this example, a new type of object is created by scaling a sphere 
  548. differently in the 3 axis directions. To apply a texture to an object 
  549. independently of its object transformations (invariant texture), all 
  550. you have to do is to list the transformations as texture transformations 
  551. in reverse order. The full description of this scene is in Annex 3.
  552.  
  553. Box with shear in one direction. The description of the two boxes is like:
  554.  
  555. 2 2 1 0 1 0 1 0.95 1<EOL>
  556. 22 2 1 0 -1 0 1 0.95 <EOL>
  557. 65 0 1 0 0 0 0 1 0 0 0 -1 1 0 0 0 0 1- Shear matrix<EOL>
  558.  
  559. The shear is achieved by making the Z axis information dependent of the 
  560. Y coordinate (the -1 creates that effect).
  561.  
  562.  
  563. 6. Conclusions
  564.  
  565. This simple format has proved suitable for use in many environments. Even 
  566. so, it is very complicated to use interactively, so a better format (in 
  567. the sense of abstraction and ease of writing) has been developed to 
  568. replace it. It is called SCN (scene format) and makes things much 
  569. more easy to do. The converter from SCN to SFF is called SCN2SFF 
  570. and runs on the same platforms as RTRACE.
  571.  
  572. To fully understand this format, it is recommended that you read first 
  573. the program's manual so that you have a minimal idea of the options of 
  574. RTRACE and so on.
  575.  
  576.  
  577. 7. References
  578.  
  579. Reid Judd, Anto'nio Costa and Greg Ferrar - RTRACE 1.0 for the Macintosh User 
  580. Manual
  581.  
  582. Pedro Borges, Paulo Almeida, Anto'nio Costa - Extrusion Objects for 3D Text
  583.  
  584.  
  585. 8. Annexes
  586.  
  587. 8.1. Annex 1 - Font formats PPF and PPE
  588.  
  589. The PPF files describe objects made from the extrusion of closed lines. 
  590. These closed lines can be straight line segments or cubic Bizier segments. 
  591. The restriction of being closed allows these lines to be specified by 
  592. only 3 points for Bizier and just 1 point for straight segments. The 
  593. last point of one segment is always the starting point of the next.
  594.  
  595. In the next figure all the control points are showed, and it could be 
  596. used to generate a 'D' letter:
  597.  
  598. The lower left corner is (0,0) and the upper left is (0,23). Its description 
  599. could be something like:
  600.  
  601. letter 'D'  name
  602. 2  number of closed lines
  603. 4  number of segments of the 1st line
  604. line0 0  straight line
  605. line0 23
  606. cubic8 23   25 21   23 0  Bezier; starts in (8,23)
  607. line8 0
  608. 1  number of segments of the 2nd line
  609. cubic6 15   4 -6   23 17  one Bezier curve only
  610.  
  611. The actual PPF description is:
  612.  
  613. /D# name (the slash is mandatory)<EOL>
  614. 2# number of closed lines<EOL>
  615. 4# number of segments of 1st line<EOL>
  616. l 0 0# start<EOL>
  617. l 0 23# line<EOL>
  618. c 8 23 25 21 23 0# cubic<EOL>
  619. l 8 0# line<EOL>
  620. 1# number of segments of 2nd line<EOL>
  621. c 6 15 4 -6 23 17# cubic<EOL>
  622.  
  623. Any PPF file may contain any number of definitions like the last one 
  624. (the supplied files usually have about 96 character definitions each). 
  625. Any character must have a unique name inside a PPF file (it is a good 
  626. idea to use the names that appear in the Postscript Language Reference 
  627. Manual). To avoid remembering all those names, it is possible to define 
  628. a mapping between character codes and names. 
  629.  
  630. Characters that do not appear in the mapping file (PPE) may only be 
  631. accessed by its original name. 
  632.  
  633. Example:
  634.  
  635. ...
  636. 64/at# code 64(@) represents 'at'<EOL>
  637. 65/A# code 65(A) represents 'A'<EOL>
  638. 66/backslash# code 66(B) represents 'backslash'<EOL>
  639. 67/copyright# code 67(C) represents 'copyright'<EOL>
  640. 68/D# code 68(D) represents 'D'<EOL>
  641. ...
  642.  
  643. A complete example of a tank created with this type of objects follows. 
  644. First, it was necessary to create a specific PPF file (tank.ppf) that 
  645. contains all the tank extruded parts:
  646.  
  647. # tank<EOL>
  648. /wheels<EOL>
  649. 1<EOL>
  650. 6<EOL>
  651. l 4 0<EOL>
  652. c 16 0 18 0 20 2<EOL>
  653. c 20 3 20 4 18 4<EOL>
  654. l 16 4<EOL>
  655. c 4 4 2 4 0 3<EOL>
  656. c 0 2 0 1 2 0<EOL>
  657. /body<EOL>
  658. 1<EOL>
  659. 6<EOL>
  660. l 5 1<EOL>
  661. c 15 1 18 1 18 2<EOL>
  662. c 18 3 18 4 13 5<EOL>
  663. l 12 5<EOL>
  664. c 8 5 5 5 2 4<EOL>
  665. c 2 3 2 2 4 1<EOL>
  666. /tower<EOL>
  667. 1<EOL>
  668. 4<EOL>
  669. c 10 -10 14 -10 20 -4<EOL>
  670. c 20 0 20 4 14 10<EOL>
  671. c 10 10 6 10 0 10<EOL>
  672. c 0 0 0 -10 6 -10<EOL>
  673. /cannon<EOL>
  674. 1<EOL>
  675. 2<EOL>
  676. c 1 0 1 1 -1 1<EOL>
  677. c -1 0 -1 -1 1 -1<EOL>
  678.  
  679. The SFF file for this example is:
  680.  
  681. view<EOL>
  682. 28 -9 9<EOL>
  683. 12.5 5 2<EOL>
  684. 0 0 1<EOL>
  685. 30 30<EOL>
  686. colors<EOL>
  687. 0.1 0.4 0.7<EOL>
  688. 0.6 0.6 0.6<EOL>
  689. lights<EOL>
  690. 1 20 20 40 1 1 1<EOL>
  691. 1 30 -10 10 2 2 2<EOL>
  692. 1 -30 -60 10 4 4 4<EOL>
  693. 2 -300 400 10 0 0 -1 -1 -1 -1 89.8<EOL>
  694. <EOL>
  695. surfaces<EOL>
  696. 1 0.5 0.7 0.5 0.3 0.3 0.3 0.7 0.7 0.7 70 0.7 0 0 0<EOL>
  697. 1 0.6 0.4 0.3 1 1 1 0 0 0 0 0 0 0 0<EOL>
  698. <EOL>
  699. objects<EOL>
  700. 7 1 1 tank.t3d<EOL>
  701. 2 2 1 0 0 0 1000 1000 0.01<EOL>
  702. <EOL>
  703. end<EOL>
  704.  
  705. Finally, the tank is described in tank.t3d like:
  706.  
  707. spacing0.1<EOL>
  708. orientation1 0 0 0 0 1 0 1 0<EOL>
  709. fonttank.ppf<EOL>
  710. encodingascii.ppe<EOL>
  711. scale1 1 2<EOL>
  712. at0 0 0 "/wheels/"<EOL>
  713. at0 8 0 "/wheels/"<EOL>
  714. scale1 1 6<EOL>
  715. at0 2 0 "/body/"<EOL>
  716. scale0.4 0.28 2<EOL>
  717. orientation1 0 0 0 1 0 0 0 1<EOL>
  718. at6 5 5 "/tower/"<EOL>
  719. scale0.5 0.5 8<EOL>
  720. orientation0 1 0 0 0 1 1 0 0<EOL>
  721. at10 5 6 "/cannon/"<EOL>
  722.  
  723. The resulting picture is in the next figure:
  724.  
  725.  
  726. 8.2. Annex 2 - CSG Example
  727.  
  728. The full description of the CSG scene is:
  729.  
  730. view<EOL>
  731. 3 1 1<EOL>
  732. 0 0 0<EOL>
  733. 0 1 0<EOL>
  734. 20 20<EOL>
  735. colors<EOL>
  736. 1 1 1<EOL>
  737. 0.2 0.2 0.2<EOL>
  738. lights<EOL>
  739. 1 3 2 2 1 1 1<EOL>
  740. <EOL>
  741. surfaces<EOL>
  742. 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0<EOL>
  743. 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0<EOL>
  744. 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0<EOL>
  745. <EOL>
  746. objects<EOL>
  747. 66 0 1 1 1 - CSG subtraction<EOL>
  748. 1    2 1  0 0 0 1- sphere at (0,0,0) radius=1<EOL>
  749. 66 1- right component of CSG<EOL>
  750. 1    3 1  0 1 0 0.6- sphere at (0,1,0) radius=0.3<EOL>
  751. 2    3 1  1 0 0 0.5 0.5 0.5- box at (1,0,0) sizes=0.5,0.1,0.1<EOL>
  752. 66 2- end of CSG<EOL>
  753. <EOL>
  754. end<EOL>
  755.  
  756.  
  757. 8.3. Annex 3 - Textured Spheres Examples
  758.  
  759. Agate example:
  760.  
  761. view<EOL>
  762. 1.6 1.6 1.6<EOL>
  763. 0 0 0<EOL>
  764. 0 1 0<EOL>
  765. 22.5 22.5<EOL>
  766. colors<EOL>
  767. 0.2 0.5 0.7<EOL>
  768. 0.1 0.1 0.1<EOL>
  769. lights<EOL>
  770. 1 57735.03 57735.03 -57735.03 -1 -1 -1<EOL>
  771. <EOL>
  772. surfaces<EOL>
  773. 1 0.9 0.9 0.9 0.9 0.9 0.9 0.1 0.1 0.1 4 0 0 0 0<EOL>
  774. <EOL>
  775. objects<EOL>
  776. 1 1 1 0 0 0 1<EOL>
  777. 64 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 earthtones.map<EOL>
  778. <EOL>
  779. end<EOL>
  780.  
  781. Blotch example:
  782.  
  783. view<EOL>
  784. 1.6 1.6 1.6<EOL>
  785. 0 0 0<EOL>
  786. 0 1 0<EOL>
  787. 22.5 22.5<EOL>
  788. colors<EOL>
  789. 0.2 0.5 0.7<EOL>
  790. 0.1 0.1 0.1<EOL>
  791. lights<EOL>
  792. 1 57735.03 57735.03 -57735.03 -1 -1 -1<EOL>
  793. <EOL>
  794. surfaces<EOL>
  795. 1 1 0 0 0.999 0.999 0.999 0 0 0 0 0 0 0 0<EOL>
  796. 1 1 1 0 0.999 0.999 0.999 0 0 0 0 0 0 0 0<EOL>
  797. <EOL>
  798. objects<EOL>
  799. 1 1 1 0 0 0 1<EOL>
  800. 64 2 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1 0.4 2 -<EOL>
  801. <EOL>
  802. end<EOL>
  803.  
  804. Bozo example:
  805.  
  806. view<EOL>
  807. 1.6 1.6 1.6<EOL>
  808. 0 0 0<EOL>
  809. 0 1 0<EOL>
  810. 22.5 22.5<EOL>
  811. colors<EOL>
  812. 0.2 0.5 0.7<EOL>
  813. 0.1 0.1 0.1<EOL>
  814. lights<EOL>
  815. 1 57735.03 57735.03 -57735.03 -1 -1 -1<EOL>
  816. <EOL>
  817. surfaces<EOL>
  818. 1 0.9 0.9 0.9 0.9 0.9 0.9 0.1 0.1 0.1 4 0 0 0 0<EOL>
  819. <EOL>
  820. objects<EOL>
  821. 1 1 1 0 0 0 1<EOL>
  822. 64 9 0 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1 1 earthtones.map<EOL>
  823. <EOL>
  824. end<EOL>
  825.  
  826. The color map file used (earthones.map) is:
  827.  
  828. 40 128 200<EOL>
  829. 40 128 200<EOL>
  830. 41 129 201<EOL>
  831. ... + 250 colors ...
  832. 254 255 253<EOL>
  833. 254 255 253<EOL>
  834. 254 255 253<EOL>
  835. <EOL>
  836. Earth Tones<EOL>
  837.  
  838.  
  839. 8.4. Annex 4 - Striped Spheres Example
  840.  
  841. This is the full description for the two striped spheres of chapter 5:
  842.  
  843. view<EOL>
  844. 7 3 2<EOL>
  845. 0 0 0<EOL>
  846. 0 1 0<EOL>
  847. 22.5 22.5<EOL>
  848. colors<EOL>
  849. 1 1 1<EOL>
  850. 0.1 0.1 0.1<EOL>
  851. lights<EOL>
  852. 1 6 2 2 1 1 1<EOL>
  853. <EOL>
  854. surfaces<EOL>
  855. 1 0.7 0.7 0.7 0.999 0.999 0.999 0 0 0 0 0 0 0 0<EOL>
  856. 1 0 1 0 0.999 0.999 0.999 0 0 0 0 0 0 0 0<EOL>
  857. 1 1 1 1 0.999 0.999 0.999 0 0 0 0 0 0 0 0<EOL>
  858. <EOL>
  859. objects<EOL>
  860. 4 1 1 1.5 1 0 0.05 0 1 0 0.05<EOL>
  861. 4 1 1 1.5 1 0 0.1 1.8 1 0 1e-07<EOL>
  862. 4 1 1 0 1 1.5 0.05 0 1 0 0.05<EOL>
  863. 4 1 1 0 1 1.5 0.1 0 1 1.8 1e-07<EOL>
  864. 4 1 1 1.5 -1 0 0.05 0 -1 0 0.05<EOL>
  865. 4 1 1 1.5 -1 0 0.1 1.8 -1 0 1e-07<EOL>
  866. 4 1 1 0 -1 2.5 0.05 0 -1 0 0.05<EOL>
  867. 4 1 1 0 -1 2.5 0.1 0 -1 2.8 1e-07<EOL>
  868. 1 2 1 0 1 0 1<EOL>
  869. 64 0 0 1 0 0 500 0 1 0 500 0 0 1 0 0 0 0 1<EOL>
  870. 64 1 0 1000 0 0 0 0 1000 0 0 0 0 0.25 0 0 0 0 1 3<EOL>
  871. 1 2 1 0 -1 0 1<EOL>
  872. 65 0 0.5 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1<EOL>
  873. 64 0 0 0.5 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1<EOL>
  874. 64 0 0 1 0 0 500 0 1 0 500 0 0 1 0 0 0 0 1<EOL>
  875. 64 1 0 1000 0 0 0 0 1000 0 0 0 0 0.25 0 0 0 0 1 3<EOL>
  876. <EOL>
  877. end<EOL>
  878.  
  879. To ray trace these examples and produce the pictures (fast and with low 
  880. quality), assuming the SFF file was called spheres.sff, the ray tracer 
  881. should be executed like:
  882.  
  883. rtrace t1 O1 m0 spheres.sff spheres.ppm
  884.  
  885. For an high quality rendering, use instead:
  886.  
  887. rtrace t1 O1 p2 A0.075 spheres.sff spheres.ppm
  888.  
  889.  * represents cross-product of two vectors.
  890.  
  891.  
  892.  
  893. ----- end of SFF -----
  894.  
  895.