INTERIOR.C 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. /****************************************************************************
  2. * interior.c
  3. *
  4. * This module contains all functions for interior stuff.
  5. *
  6. * from Persistence of Vision(tm) Ray Tracer
  7. * Copyright 1996,1999 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. * NOTICE: This source code file is provided so that users may experiment
  10. * with enhancements to POV-Ray and to port the software to platforms other
  11. * than those supported by the POV-Ray Team. There are strict rules under
  12. * which you are permitted to use this file. The rules are in the file
  13. * named POVLEGAL.DOC which should be distributed with this file.
  14. * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  15. * Team Coordinator by email to team-coord@povray.org or visit us on the web at
  16. * http://www.povray.org. The latest version of POV-Ray may be found at this site.
  17. *
  18. * This program is based on the popular DKB raytracer version 2.12.
  19. * DKBTrace was originally written by David K. Buck.
  20. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  21. *
  22. *****************************************************************************/
  23. #include "frame.h"
  24. #include "vector.h"
  25. #include "povproto.h"
  26. #include "chi2.h"
  27. #include "colour.h"
  28. #include "povray.h"
  29. #include "texture.h"
  30. #include "pigment.h"
  31. #include "objects.h"
  32. #include "lighting.h"
  33. #include "matrices.h"
  34. #include "interior.h"
  35. #include "povray.h"
  36. #include "point.h"
  37. #include "texture.h"
  38. #include "ray.h"
  39. /*****************************************************************************
  40. * Local preprocessor defines
  41. ******************************************************************************/
  42. /*****************************************************************************
  43. * Local typedefs
  44. ******************************************************************************/
  45. /*****************************************************************************
  46. * Local variables
  47. ******************************************************************************/
  48. /*****************************************************************************
  49. * Static functions
  50. ******************************************************************************/
  51. /*****************************************************************************
  52. *
  53. * FUNCTION
  54. *
  55. * Init_Interior
  56. *
  57. * INPUT
  58. *
  59. * OUTPUT
  60. *
  61. * RETURNS
  62. *
  63. * AUTHOR
  64. *
  65. * Dieter Bayer
  66. *
  67. * DESCRIPTION
  68. *
  69. * Initialize interior.
  70. *
  71. * CHANGES
  72. *
  73. * Jan 1997 : Creation.
  74. *
  75. ******************************************************************************/
  76. void Init_Interior(INTERIOR *Interior)
  77. {
  78. }
  79. /*****************************************************************************
  80. *
  81. * FUNCTION
  82. *
  83. * Create_Interior
  84. *
  85. * INPUT
  86. *
  87. * OUTPUT
  88. *
  89. * RETURNS
  90. *
  91. * INTERIOR * - created interior
  92. *
  93. * AUTHOR
  94. *
  95. * Dieter Bayer
  96. *
  97. * DESCRIPTION
  98. *
  99. * Create a interior.
  100. *
  101. * CHANGES
  102. *
  103. * Dec 1994 : Creation.
  104. *
  105. ******************************************************************************/
  106. INTERIOR *Create_Interior()
  107. {
  108. INTERIOR *New;
  109. New = (INTERIOR *)POV_MALLOC(sizeof(INTERIOR), "interior");
  110. New->References = 1;
  111. New->IOR = 0.0;
  112. New->Old_Refract = 1.0;
  113. New->Caustics = 0.0;
  114. New->Fade_Distance = 0.0;
  115. New->Fade_Power = 0.0;
  116. New->IMedia = NULL;
  117. return(New);
  118. }
  119. /*****************************************************************************
  120. *
  121. * FUNCTION
  122. *
  123. * Copy_Interior
  124. *
  125. * INPUT
  126. *
  127. * Old - interior to copy
  128. *
  129. * OUTPUT
  130. *
  131. * RETURNS
  132. *
  133. * INTERIOR * - new interior
  134. *
  135. * AUTHOR
  136. *
  137. * Dieter Bayer
  138. *
  139. * DESCRIPTION
  140. *
  141. * Copy an interior.
  142. *
  143. * CHANGES
  144. *
  145. * Dec 1994 : Creation.
  146. *
  147. ******************************************************************************/
  148. INTERIOR *Copy_Interior(INTERIOR *Old)
  149. {
  150. INTERIOR *New;
  151. if (Old != NULL)
  152. {
  153. New = Create_Interior();
  154. *New = *Old;
  155. New->IMedia = Copy_Media(Old->IMedia);
  156. return(New);
  157. }
  158. else
  159. {
  160. return(NULL);
  161. }
  162. }
  163. /*****************************************************************************
  164. *
  165. * FUNCTION
  166. *
  167. * Copy_Interior_Pointer
  168. *
  169. * INPUT
  170. *
  171. * Old - interior to copy
  172. *
  173. * OUTPUT
  174. *
  175. * RETURNS
  176. *
  177. * INTERIOR * - new interior
  178. *
  179. * AUTHOR
  180. *
  181. * Dieter Bayer
  182. *
  183. * DESCRIPTION
  184. *
  185. * Copy an interior by increasing number of references.
  186. *
  187. * CHANGES
  188. *
  189. * Dec 1994 : Creation.
  190. *
  191. ******************************************************************************/
  192. INTERIOR *Copy_Interior_Pointer(INTERIOR *Old)
  193. {
  194. if (Old != NULL)
  195. {
  196. Old->References++;
  197. }
  198. return(Old);
  199. }
  200. /*****************************************************************************
  201. *
  202. * FUNCTION
  203. *
  204. * Destroy_Interior
  205. *
  206. * INPUT
  207. *
  208. * Interior - interior to destroy
  209. *
  210. * OUTPUT
  211. *
  212. * RETURNS
  213. *
  214. * AUTHOR
  215. *
  216. * Dieter Bayer
  217. *
  218. * DESCRIPTION
  219. *
  220. * Destroy an interior.
  221. *
  222. * CHANGES
  223. *
  224. * Dec 1994 : Creation.
  225. *
  226. ******************************************************************************/
  227. void Destroy_Interior(INTERIOR *Interior)
  228. {
  229. if ((Interior != NULL) && (--(Interior->References) == 0))
  230. {
  231. Destroy_Media(Interior->IMedia);
  232. POV_FREE(Interior);
  233. }
  234. }
  235. /*****************************************************************************
  236. *
  237. * FUNCTION
  238. *
  239. * Transform_Interior
  240. *
  241. * INPUT
  242. *
  243. * OUTPUT
  244. *
  245. * RETURNS
  246. *
  247. * AUTHOR
  248. *
  249. * Dieter Bayer
  250. *
  251. * DESCRIPTION
  252. *
  253. * Transform interior.
  254. *
  255. * CHANGES
  256. *
  257. * Jan 1997 : Creation.
  258. *
  259. ******************************************************************************/
  260. void Transform_Interior(INTERIOR *Interior, TRANSFORM *Trans)
  261. {
  262. if (Interior != NULL)
  263. {
  264. if (Interior->IMedia != NULL)
  265. {
  266. Transform_Media(Interior->IMedia, Trans);
  267. }
  268. }
  269. }
  270. MATERIAL *Create_Material()
  271. {
  272. MATERIAL *New;
  273. New = (MATERIAL *)POV_MALLOC(sizeof(MATERIAL), "material");
  274. New->Texture = NULL;
  275. New->Interior = NULL;
  276. return(New);
  277. }
  278. MATERIAL *Copy_Material(MATERIAL *Old)
  279. {
  280. MATERIAL *New;
  281. if (Old != NULL)
  282. {
  283. New = Create_Material();
  284. *New = *Old;
  285. New->Texture = Copy_Textures(Old->Texture);
  286. New->Interior = Copy_Interior(Old->Interior);
  287. return(New);
  288. }
  289. else
  290. {
  291. return(NULL);
  292. }
  293. }
  294. void Destroy_Material(MATERIAL *Material)
  295. {
  296. if (Material != NULL)
  297. {
  298. Destroy_Textures(Material->Texture);
  299. Destroy_Interior(Material->Interior);
  300. POV_FREE(Material);
  301. }
  302. }