OCTREE.H 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /****************************************************************************
  2. * octree.h
  3. *
  4. * Oct-tree routine prototypes. Use by Radiosity calculation routies.
  5. * Implemented by and (c) 1994 Jim McElhiney, mcelhiney@acm.org or cserve 71201,1326
  6. * All standard POV distribution rights granted. All other rights reserved.
  7. *
  8. * from Persistence of Vision(tm) Ray Tracer
  9. * Copyright 1996,1999 Persistence of Vision Team
  10. *---------------------------------------------------------------------------
  11. * NOTICE: This source code file is provided so that users may experiment
  12. * with enhancements to POV-Ray and to port the software to platforms other
  13. * than those supported by the POV-Ray Team. There are strict rules under
  14. * which you are permitted to use this file. The rules are in the file
  15. * named POVLEGAL.DOC which should be distributed with this file.
  16. * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  17. * Team Coordinator by email to team-coord@povray.org or visit us on the web at
  18. * http://www.povray.org. The latest version of POV-Ray may be found at this site.
  19. *
  20. * This program is based on the popular DKB raytracer version 2.12.
  21. * DKBTrace was originally written by David K. Buck.
  22. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  23. *
  24. *************************************************************************/
  25. #ifndef OCTREE_H
  26. #define OCTREE_H
  27. /*****************************************************************************
  28. * Global preprocessor defines
  29. ******************************************************************************/
  30. #define OT_BIAS 10000000.
  31. #define MAX3(a,b,c) ( ((a)>(b)) ? max((a),(c)) : max((b),(c)) )
  32. /*****************************************************************************
  33. * Global typedefs
  34. ******************************************************************************/
  35. typedef struct ot_block_struct OT_BLOCK;
  36. typedef struct ot_id_struct OT_ID;
  37. typedef struct ot_node_struct OT_NODE;
  38. /* Each node in the oct-tree has a (possibly null) linked list of these
  39. data blocks off it. */
  40. struct ot_block_struct
  41. {
  42. OT_BLOCK *next;
  43. VECTOR Point, S_Normal;
  44. float drdx, dgdx, dbdx, drdy, dgdy, dbdy, drdz, dgdz, dbdz;
  45. RGB Illuminance;
  46. float Harmonic_Mean_Distance, Nearest_Distance;
  47. VECTOR To_Nearest_Surface;
  48. short Bounce_Depth;
  49. };
  50. /* This is the information necessary to name an oct-tree node. */
  51. struct ot_id_struct
  52. {
  53. long x, y, z;
  54. long Size;
  55. };
  56. /* These are the structures that make up the oct-tree itself, known as nodes */
  57. struct ot_node_struct
  58. {
  59. OT_ID Id;
  60. OT_BLOCK *Values;
  61. OT_NODE *Kids[8];
  62. };
  63. /*****************************************************************************
  64. * Global variables
  65. ******************************************************************************/
  66. /*****************************************************************************
  67. * Global functions
  68. ******************************************************************************/
  69. void ot_ins (OT_NODE **root, OT_BLOCK *new_block, OT_ID *new_id);
  70. void ot_list_insert (OT_BLOCK **list_ptr, OT_BLOCK *item);
  71. void ot_newroot (OT_NODE **root_ptr);
  72. long ot_dist_traverse (OT_NODE *subtree, VECTOR point, int bounce_depth, \
  73. long (*func)(OT_BLOCK *block, void *handle1), void *handle2);
  74. long ot_point_in_node (VECTOR point, OT_ID *node);
  75. void ot_index_sphere (VECTOR point, DBL radius, OT_ID *id);
  76. void ot_index_box (VECTOR min_point, VECTOR max_point, OT_ID *id);
  77. void ot_parent (OT_ID *dad, OT_ID *kid);
  78. long ot_save_tree (OT_NODE *rootptr, FILE *fd);
  79. long ot_write_block (OT_BLOCK *bl, void * handle);
  80. long ot_free_tree (OT_NODE **ppRoot);
  81. long ot_read_file (FILE * fd);
  82. /* a trunc function which always returns the floor integer */
  83. long Trunc (DBL value);
  84. #endif