1 /**************************************************************************** 2 * mesh.h 3 * 4 * This module contains all defines, typedefs, and prototypes for MESH.CPP. 5 * 6 * from Persistence of Vision(tm) Ray Tracer version 3.6. 7 * Copyright 1991-2003 Persistence of Vision Team 8 * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd. 9 *--------------------------------------------------------------------------- 10 * NOTICE: This source code file is provided so that users may experiment 11 * with enhancements to POV-Ray and to port the software to platforms other 12 * than those supported by the POV-Ray developers. There are strict rules 13 * regarding how you are permitted to use this file. These rules are contained 14 * in the distribution and derivative versions licenses which should have been 15 * provided with this file. 16 * 17 * These licences may be found online, linked from the end-user license 18 * agreement that is located at http://www.povray.org/povlegal.html 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 *=========================================================================== 26 * This file is part of MegaPOV, a modified and unofficial version of POV-Ray 27 * For more information on MegaPOV visit our website: 28 * http://megapov.inetart.net/ 29 *=========================================================================== 30 * 31 * $RCSfile: mesh.h,v $ 32 * $Revision: 1.9 $ 33 * $Author: chris $ 34 * 35 *****************************************************************************/ 36 37 38 #ifndef MESH_H 39 #define MESH_H 40 41 #include "bbox.h" 42 43 BEGIN_POV_NAMESPACE 44 45 /***************************************************************************** 46 * Global preprocessor defines 47 ******************************************************************************/ 48 49 #define MESH_OBJECT (PATCH_OBJECT+HIERARCHY_OK_OBJECT) 50 51 52 /***************************************************************************** 53 * Global typedefs 54 ******************************************************************************/ 55 56 typedef struct Mesh_Struct MESH; 57 typedef struct Mesh_Data_Struct MESH_DATA; 58 typedef struct Mesh_Triangle_Struct MESH_TRIANGLE; 59 60 struct Mesh_Struct 61 { 62 OBJECT_FIELDS 63 MESH_DATA *Data; /* Mesh data holding triangles. */ 64 long Number_Of_Textures; /* Number of textures in the mesh. */ 65 TEXTURE **Textures; /* Array of texture references. */ 66 short has_inside_vector; 67 #ifdef TRANSPARENT_INVERTED_NORMALS_PATCH 68 short inverted_normals; 69 #endif 70 }; 71 72 struct Mesh_Data_Struct 73 { 74 int References; /* Number of references to the mesh. */ 75 long Number_Of_UVCoords; /* Number of UV coords in the mesh. */ 76 long Number_Of_Normals; /* Number of normals in the mesh. */ 77 long Number_Of_Triangles; /* Number of trinagles in the mesh. */ 78 long Number_Of_Vertices; /* Number of vertices in the mesh. */ 79 SNGL_VECT *Normals, *Vertices; /* Arrays of normals and vertices. */ 80 UV_VECT *UVCoords; /* Array of UV coordinates */ 81 MESH_TRIANGLE *Triangles; /* Array of triangles. */ 82 BBOX_TREE *Tree; /* Bounding box tree for mesh. */ 83 VECTOR Inside_Vect; /* vector to use to test 'inside' */ 84 }; 85 86 struct Mesh_Triangle_Struct 87 { 88 unsigned int Smooth:1; /* Is this a smooth triangle. */ 89 unsigned int Dominant_Axis:2; /* Dominant axis. */ 90 unsigned int vAxis:2; /* Axis for smooth triangle. */ 91 unsigned int ThreeTex:1; /* Color Triangle Patch. */ 92 long Normal_Ind; /* Index of unsmoothed triangle normal. */ 93 long P1, P2, P3; /* Indices of triangle vertices. */ 94 long Texture; /* Index of triangle texture. */ 95 long Texture2, Texture3; /* Color Triangle Patch. */ 96 long N1, N2, N3; /* Indices of smoothed triangle normals. */ 97 long UV1, UV2, UV3; /* Indicies of UV coordinate vectors */ 98 SNGL Distance; /* Distance of triangle along normal. */ 99 SNGL_VECT Perp; /* Vector used for smooth triangles. */ 100 }; 101 102 103 104 /***************************************************************************** 105 * Global variables 106 ******************************************************************************/ 107 108 extern METHODS Mesh_Methods; 109 110 111 /***************************************************************************** 112 * Global functions 113 ******************************************************************************/ 114 115 MESH *Create_Mesh (void); 116 int Compute_Mesh_Triangle (MESH_TRIANGLE *Triangle, int Smooth, VECTOR P1, VECTOR P2, VECTOR P3, VECTOR S_Normal); 117 void Compute_Mesh_BBox (MESH *Mesh); 118 void Init_Mesh_Triangle (MESH_TRIANGLE *Triangle); 119 void Build_Mesh_BBox_Tree (MESH *Mesh); 120 void Test_Mesh_Opacity (MESH *Blob); 121 122 void Create_Mesh_Hash_Tables (void); 123 void Destroy_Mesh_Hash_Tables (void); 124 int Mesh_Hash_Vertex (int *Number_Of_Vertices, int *Max_Vertices, SNGL_VECT **Vertices, VECTOR Vertex); 125 int Mesh_Hash_Normal (int *Number_Of_Normals, int *Max_Normals, SNGL_VECT **Normals, VECTOR Normal); 126 int Mesh_Hash_Texture (int *Number_Of_Textures, int *Max_Textures, TEXTURE ***Textures, TEXTURE *Texture); 127 int Mesh_Hash_UV (int *Number, int *Max, UV_VECT **Elements, UV_VECT aPoint); 128 int Mesh_Degenerate (VECTOR P1, VECTOR P2, VECTOR P3); 129 void Initialize_Mesh_Code (void); 130 void Deinitialize_Mesh_Code (void); 131 int Mesh_Interpolate(VECTOR Weights, VECTOR IPoint, MESH *m, MESH_TRIANGLE *Triangle); 132 133 END_POV_NAMESPACE 134 135 #endif 136