HFIELD.H 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /****************************************************************************
  2. * hfield.h
  3. *
  4. * This module contains all defines, typedefs, and prototypes for HFIELD.C.
  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. #ifndef HFIELD_H
  24. #define HFIELD_H
  25. #include "bbox.h"
  26. #include "boxes.h"
  27. /*****************************************************************************
  28. * Global preprocessor defines
  29. ******************************************************************************/
  30. #define HFIELD_OBJECT (BASIC_OBJECT+WATER_LEVEL_OK_OBJECT+SMOOTH_OK_OBJECT+HIERARCHY_OK_OBJECT)
  31. #define HF_CACHE_SIZE 16
  32. /* Generate additional height field statistics. */
  33. #define HFIELD_EXTRA_STATS 1
  34. /*****************************************************************************
  35. * Global typedefs
  36. ******************************************************************************/
  37. typedef struct HField_Struct HFIELD;
  38. typedef struct HField_Data_Struct HFIELD_DATA;
  39. typedef struct HField_Block_Struct HFIELD_BLOCK;
  40. typedef struct HField_Normal_Struct HFIELD_NORMAL;
  41. typedef short HF_Normals[3];
  42. typedef unsigned short HF_VAL;
  43. struct HField_Normal_Struct
  44. {
  45. DBL fx, fz;
  46. VECTOR normal;
  47. };
  48. struct HField_Block_Struct
  49. {
  50. int xmin, xmax;
  51. int zmin, zmax;
  52. DBL ymin, ymax;
  53. };
  54. struct HField_Data_Struct
  55. {
  56. int References;
  57. int cache_pos;
  58. int Normals_Height; /* Needed for Destructor */
  59. int max_x, max_z;
  60. HF_VAL min_y, max_y;
  61. int block_max_x, block_max_z;
  62. int block_width_x, block_width_z;
  63. HF_VAL **Map;
  64. HF_Normals **Normals;
  65. HFIELD_NORMAL Normal_Cache[HF_CACHE_SIZE];
  66. HFIELD_BLOCK **Block;
  67. };
  68. struct HField_Struct
  69. {
  70. OBJECT_FIELDS
  71. TRANSFORM *Trans;
  72. BOX *bounding_box;
  73. HFIELD_DATA *Data;
  74. };
  75. /*****************************************************************************
  76. * Global variables
  77. ******************************************************************************/
  78. extern METHODS HField_Methods;
  79. /*****************************************************************************
  80. * Global functions
  81. ******************************************************************************/
  82. HFIELD *Create_HField (void);
  83. void Compute_HField_BBox (HFIELD *HField);
  84. void Compute_HField (HFIELD *H_Field, IMAGE *Image);
  85. #endif