MESH.H 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /****************************************************************************
  2. * mesh.h
  3. *
  4. * This module contains all defines, typedefs, and prototypes for MESH.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 MESH_H
  24. #define MESH_H
  25. #include "bbox.h"
  26. /*****************************************************************************
  27. * Global preprocessor defines
  28. ******************************************************************************/
  29. #define MESH_OBJECT (PATCH_OBJECT+HIERARCHY_OK_OBJECT)
  30. /*****************************************************************************
  31. * Global typedefs
  32. ******************************************************************************/
  33. typedef struct Mesh_Struct MESH;
  34. typedef struct Mesh_Data_Struct MESH_DATA;
  35. typedef struct Mesh_Triangle_Struct MESH_TRIANGLE;
  36. struct Mesh_Struct
  37. {
  38. OBJECT_FIELDS
  39. TRANSFORM *Trans; /* Transformation for this object. */
  40. MESH_DATA *Data; /* Mesh data holding triangles. */
  41. };
  42. struct Mesh_Data_Struct
  43. {
  44. int References; /* Number of references to the mesh. */
  45. long Number_Of_Normals; /* Number of normals in the mesh. */
  46. long Number_Of_Textures; /* Number of textures in the mesh. */
  47. long Number_Of_Triangles; /* Number of trinagles in the mesh. */
  48. long Number_Of_Vertices; /* Number of vertices in the mesh. */
  49. SNGL_VECT *Normals, *Vertices; /* Arrays of normals and vertices. */
  50. TEXTURE **Textures; /* Array of texture references. */
  51. MESH_TRIANGLE *Triangles; /* Array of triangles. */
  52. BBOX_TREE *Tree; /* Bounding box tree for mesh. */
  53. };
  54. struct Mesh_Triangle_Struct
  55. {
  56. unsigned int Smooth:1; /* Is this a smooth triangle. */
  57. unsigned int Dominant_Axis:2; /* Dominant axis. */
  58. unsigned int vAxis:2; /* Axis for smooth triangle. */
  59. long P1, P2, P3; /* Indices of triangle vertices. */
  60. long Normal_Ind; /* Index of unsmoothed triangle normal. */
  61. long Texture; /* Index of triangle texture. */
  62. SNGL Distance; /* Distance of triangle along normal. */
  63. long N1, N2, N3; /* Indices of smoothed triangle normals. */
  64. SNGL_VECT Perp; /* Vector used for smooth triangles. */
  65. };
  66. /*****************************************************************************
  67. * Global variables
  68. ******************************************************************************/
  69. extern METHODS Mesh_Methods;
  70. /*****************************************************************************
  71. * Global functions
  72. ******************************************************************************/
  73. MESH *Create_Mesh (void);
  74. int Compute_Mesh_Triangle (MESH_TRIANGLE *Triangle, int Smooth, VECTOR P1, VECTOR P2, VECTOR P3, VECTOR S_Normal);
  75. void Compute_Mesh_BBox (MESH *Mesh);
  76. void Init_Mesh_Triangle (MESH_TRIANGLE *Triangle);
  77. void Build_Mesh_BBox_Tree (MESH *Mesh);
  78. void Test_Mesh_Opacity (MESH *Blob);
  79. void Create_Mesh_Hash_Tables (void);
  80. void Destroy_Mesh_Hash_Tables (void);
  81. int Mesh_Hash_Vertex (int *Number_Of_Vertices, int *Max_Vertices, SNGL_VECT **Vertices, VECTOR Vertex);
  82. int Mesh_Hash_Normal (int *Number_Of_Normals, int *Max_Normals, SNGL_VECT **Normals, VECTOR Normal);
  83. int Mesh_Hash_Texture (int *Number_Of_Textures, int *Max_Textures, TEXTURE ***Textures, TEXTURE *Texture);
  84. int Mesh_Degenerate (VECTOR P1, VECTOR P2, VECTOR P3);
  85. void Initialize_Mesh_Code (void);
  86. void Deinitialize_Mesh_Code (void);
  87. #endif