/unmaintained/adsoda/adsoda-docs.factor

http://github.com/abeaumont/factor · Factor · 307 lines · 240 code · 50 blank · 17 comment · 0 complexity · d87f99613b2b6231bcb7ace186360488 MD5 · raw file

  1. ! Copyright (C) 2008 Jeff Bigot
  2. ! See http://factorcode.org/license.txt for BSD license.
  3. USING: help.markup help.syntax ;
  4. IN: adsoda
  5. ! --------------------------------------------------------------
  6. ! faces
  7. ! --------------------------------------------------------------
  8. ARTICLE: "face-page" "Face in ADSODA"
  9. "explanation of faces"
  10. $nl
  11. "link to functions" $nl
  12. "what is an halfspace" $nl
  13. "halfspace touching-corners adjacent-faces" $nl
  14. "touching-corners list of pointers to the corners which touch this face" $nl
  15. "adjacent-faces list of pointers to the faces which touch this face"
  16. { $subsections
  17. face
  18. <face>
  19. }
  20. "test relative position"
  21. { $subsections
  22. point-inside-or-on-face?
  23. point-inside-face?
  24. }
  25. "handling face"
  26. { $subsections
  27. flip-face
  28. face-translate
  29. face-transform
  30. }
  31. ;
  32. HELP: face
  33. { $class-description "a face is defined by"
  34. { $list "halfspace equation" }
  35. { $list "list of touching corners" }
  36. { $list "list of adjacent faces" }
  37. $nl
  38. "Touching corners and adjacent faces are defined by algorithm thanks to other faces of the solid"
  39. }
  40. ;
  41. HELP: <face>
  42. { $values { "v" "an halfspace equation" } { "tuple" "a face" } } ;
  43. HELP: flip-face
  44. { $values { "face" "a face" } { "face" "flipped face" } }
  45. { $description "change the orientation of a face" }
  46. ;
  47. HELP: face-translate
  48. { $values { "face" "a face" } { "v" "a vector" } }
  49. { $description
  50. "translate a face following a vector"
  51. $nl
  52. "a translation of an halfspace doesn't change the normal vector. this word just compute the new constant term" }
  53. ;
  54. HELP: face-transform
  55. { $values { "face" "a face" } { "m" "a transformation matrix" } }
  56. { $description "compute the transformation of a face using a transformation matrix" }
  57. ;
  58. ! --------------------------------
  59. ! solid
  60. ! --------------------------------------------------------------
  61. ARTICLE: "solid-page" "Solid in ADSODA"
  62. "explanation of solids"
  63. $nl
  64. "link to functions"
  65. { $subsections
  66. solid
  67. <solid>
  68. }
  69. "test relative position"
  70. { $subsections
  71. point-inside-solid?
  72. point-inside-or-on-solid?
  73. }
  74. "playing with faces and solids"
  75. { $subsections
  76. add-face
  77. cut-solid
  78. slice-solid
  79. }
  80. "solid handling"
  81. { $subsections
  82. solid-project
  83. solid-translate
  84. solid-transform
  85. subtract
  86. get-silhouette
  87. solid=
  88. }
  89. ;
  90. HELP: solid
  91. { $class-description "dimension" $nl "silhouettes" $nl "faces" $nl "corners" $nl "adjacencies-valid" $nl "color" $nl "name"
  92. }
  93. ;
  94. HELP: add-face
  95. { $values { "solid" "a solid" } { "face" "a face" } }
  96. { $description "reshape a solid with a face. The face truncate the solid." } ;
  97. HELP: cut-solid
  98. { $values { "solid" "a solid" } { "halfspace" "an halfspace" } }
  99. { $description "like add-face but just with halfspace equation" } ;
  100. HELP: slice-solid
  101. { $values { "solid" "a solid" } { "face" "a face" } { "solid1" "the outer part of the former solid" } { "solid2" "the inner part of the former solid" } }
  102. { $description "cut a solid into two parts. The face acts like a knife"
  103. } ;
  104. HELP: solid-project
  105. { $values { "lights" "lights" } { "ambient" "ambient" } { "solid" "solid" } { "solids" "projection of solid" } }
  106. { $description "Project the solid using pv vector"
  107. $nl
  108. "TODO: explain how to use lights"
  109. } ;
  110. HELP: solid-translate
  111. { $values { "solid" "a solid" } { "v" "translating vector" } }
  112. { $description "Translate a solid using a vector"
  113. $nl
  114. "v and solid must have the same dimension "
  115. } ;
  116. HELP: solid-transform
  117. { $values { "solid" "a solid" } { "m" "transformation matrix" } }
  118. { $description "Transform a solid using a matrix"
  119. $nl
  120. "v and solid must have the same dimension "
  121. } ;
  122. HELP: subtract
  123. { $values { "solid1" "initial shape" } { "solid2" "shape to remove" } { "solids" "resulting shape" } }
  124. { $description "Substract solid2 from solid1" } ;
  125. ! --------------------------------------------------------------
  126. ! space
  127. ! --------------------------------------------------------------
  128. ARTICLE: "space-page" "Space in ADSODA"
  129. "A space is a collection of solids and lights."
  130. $nl
  131. "link to functions"
  132. $nl
  133. "Defining words"
  134. { $subsections
  135. space
  136. <space>
  137. suffix-solids
  138. suffix-lights
  139. clear-space-solids
  140. describe-space
  141. }
  142. "Handling space"
  143. { $subsections
  144. space-ensure-solids
  145. eliminate-empty-solids
  146. space-transform
  147. space-translate
  148. remove-hidden-solids
  149. space-project
  150. }
  151. ;
  152. HELP: space
  153. { $class-description
  154. "dimension" $nl " solids" $nl " ambient-color" $nl "lights"
  155. }
  156. ;
  157. HELP: suffix-solids
  158. "( space solid -- space )"
  159. { $values { "space" "a space" } { "solid" "a solid to add" } }
  160. { $description "Add solid to space definition" } ;
  161. HELP: suffix-lights
  162. "( space light -- space ) "
  163. { $values { "space" "a space" } { "light" "a light to add" } }
  164. { $description "Add a light to space definition" } ;
  165. HELP: clear-space-solids
  166. "( space -- space )"
  167. { $values { "space" "a space" } }
  168. { $description "remove all solids in space" } ;
  169. HELP: space-ensure-solids
  170. { $values { "space" "a space" } }
  171. { $description "rebuild corners of all solids in space" } ;
  172. HELP: space-transform
  173. { $values { "space" "a space" } { "m" "a matrix" } }
  174. { $description "Transform a space using a matrix" } ;
  175. HELP: space-translate
  176. { $values { "space" "a space" } { "v" "a vector" } }
  177. { $description "Translate a space following a vector" } ;
  178. HELP: describe-space
  179. { $values { "space" "a space" } }
  180. { $description "return a description of space" } ;
  181. HELP: space-project
  182. { $values { "space" "a space" } { "i" "an integer" } }
  183. { $description "Project a space along ith coordinate" } ;
  184. ! --------------------------------------------------------------
  185. ! 3D rendering
  186. ! --------------------------------------------------------------
  187. ARTICLE: "3D-rendering-page" "The 3D rendering in ADSODA"
  188. "explanation of 3D rendering"
  189. $nl
  190. "link to functions"
  191. { $subsections
  192. face->GL
  193. solid->GL
  194. space->GL
  195. }
  196. ;
  197. HELP: face->GL
  198. { $values { "face" "a face" } { "color" "3 3 values array" } }
  199. { $description "display a face" } ;
  200. HELP: solid->GL
  201. { $values { "solid" "a solid" } }
  202. { $description "display a solid" } ;
  203. HELP: space->GL
  204. { $values { "space" "a space" } }
  205. { $description "display a space" } ;
  206. ! --------------------------------------------------------------
  207. ! light
  208. ! --------------------------------------------------------------
  209. ARTICLE: "light-page" "Light in ADSODA"
  210. "explanation of light"
  211. $nl
  212. "link to functions"
  213. ;
  214. ARTICLE: { "adsoda" "light" } "ADSODA : lights"
  215. { $code """
  216. ! HELP: light position color
  217. ! <light> ( -- tuple ) light new ;
  218. ! light est un vecteur avec 3 variables pour les couleurs\n
  219. void Light::Apply(Vector& normal, double &cRed, double &cGreen, double &cBlue)\n
  220. { \n
  221. // Dot the light direction with the normalized normal of Face.
  222. register double intensity = -(normal * (*this));
  223. // Face is a backface, from light's perspective
  224. if (intensity < 0)
  225. return;
  226. // Add the intensity componentwise
  227. cRed += red * intensity;
  228. cGreen += green * intensity;
  229. cBlue += blue * intensity;
  230. // Clip to unit range
  231. if (cRed > 1.0) cRed = 1.0;
  232. if (cGreen > 1.0) cGreen = 1.0;
  233. if (cBlue > 1.0) cBlue = 1.0;
  234. """ }
  235. ;
  236. ARTICLE: { "adsoda" "halfspace" } "ADSODA : halfspace"
  237. " defined by the concatenation of the normal vector and a constant"
  238. ;
  239. ARTICLE: "adsoda-main-page" "ADSODA : Arbitrary-Dimensional Solid Object Display Algorithm"
  240. "multidimensional handler :"
  241. $nl
  242. "design a solid using face delimitations. Only works on convex shapes"
  243. $nl
  244. { $emphasis "written in C++ by Greg Ferrar" }
  245. $nl
  246. "full explanation on adsoda page at " { $url "http://www.flowerfire.com/ADSODA/" }
  247. $nl
  248. "Useful words are describe on the following pages: "
  249. { $subsections
  250. "face-page"
  251. "solid-page"
  252. "space-page"
  253. "light-page"
  254. "3D-rendering-page"
  255. } ;
  256. ABOUT: "adsoda-main-page"