OBJECTS.H 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /****************************************************************************
  2. * objects.h
  3. *
  4. * This module contains all defines, typedefs, and prototypes for OBJECTS.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. /* NOTE: FRAME.H contains other object stuff. */
  24. #ifndef OBJECTS_H
  25. #define OBJECTS_H
  26. /*****************************************************************************
  27. * Global preprocessor defines
  28. ******************************************************************************/
  29. /*
  30. * [DB 7/94]
  31. *
  32. * The flag field is used to store all possible flags that are
  33. * used for objects (up to 16).
  34. *
  35. * The flages are manipulated using the following macros:
  36. *
  37. * Set_Flag (Object, Flag) : set specified Flag in Object
  38. * Clear_Flag (Object, Flag) : clear specified Flag in Object
  39. * Invert_Flag (Object, Flag) : invert specified Flag in Object
  40. * Test_Flag (Object, Flag) : test specified Flag in Object
  41. *
  42. * Copy_Flag (Object1, Object2, Flag) : Set the Flag in Object1 to the
  43. * value of the Flag in Object2.
  44. * Bool_Flag (Object, Flag, Bool) : if(Bool) Set flag else Clear flag
  45. *
  46. * Object is a pointer to the object.
  47. * Flag is the number of the flag to test.
  48. *
  49. */
  50. #define NO_SHADOW_FLAG 0x00001 /* Object doesn't cast shadows */
  51. #define CLOSED_FLAG 0x00002 /* Object is closed */
  52. #define INVERTED_FLAG 0x00004 /* Object is inverted */
  53. #define SMOOTHED_FLAG 0x00008 /* Object is smoothed */
  54. #define CYLINDER_FLAG 0x00010 /* Object is a cylinder */
  55. #define DEGENERATE_FLAG 0x00020 /* Object is degenerate */
  56. #define STURM_FLAG 0x00040 /* Object should use sturmian root solver */
  57. #define OPAQUE_FLAG 0x00080 /* Object is opaque */
  58. #define MULTITEXTURE_FLAG 0x00100 /* Object is multi-textured */
  59. #define INFINITE_FLAG 0x00200 /* Object is infinite */
  60. #define HIERARCHY_FLAG 0x00400 /* Object can have a bounding hierarchy */
  61. #define HOLLOW_FLAG 0x00800 /* Object is hollow (atmosphere inside) */
  62. #define HOLLOW_SET_FLAG 0x01000 /* Hollow explicitly set in scene file */
  63. #define Set_Flag(Object, Flag) \
  64. { (Object)->Flags |= (Flag); }
  65. #define Clear_Flag(Object, Flag) \
  66. { (Object)->Flags &= ~(Flag); }
  67. #define Invert_Flag(Object, Flag) \
  68. { (Object)->Flags ^= (Flag); }
  69. #define Test_Flag(Object, Flag) \
  70. ((Object)->Flags & (Flag))
  71. #define Copy_Flag(Object1, Object2, Flag) \
  72. { (Object1)->Flags = (((Object1)->Flags) & (!Flag)) | \
  73. (((Object2)->Flags) & (Flag)); }
  74. #define Bool_Flag(Object1, Flag, Bool) \
  75. { if(Bool){ (Object)->Flags |= (Flag); } else { (Object)->Flags &= ~(Flag); }}
  76. /* Object types. */
  77. #define BASIC_OBJECT 0
  78. #define PATCH_OBJECT 1 /* Has no inside, no inverse */
  79. #define TEXTURED_OBJECT 2 /* Has texture, possibly in children */
  80. #define COMPOUND_OBJECT 4 /* Has children field */
  81. #define STURM_OK_OBJECT 8 /* STRUM legal */
  82. #define WATER_LEVEL_OK_OBJECT 16 /* WATER_LEVEL legal */
  83. #define LIGHT_SOURCE_OBJECT 32 /* link me in frame.light_sources */
  84. #define BOUNDING_OBJECT 64 /* This is a holder for bounded object */
  85. #define SMOOTH_OK_OBJECT 128 /* SMOOTH legal */
  86. #define IS_CHILD_OBJECT 256 /* Object is inside a COMPOUND */
  87. #define DOUBLE_ILLUMINATE 512 /* Illuminate both sides of surface to avoid normal purturb bug */
  88. #define HIERARCHY_OK_OBJECT 1024 /* NO_HIERARCHY legal */
  89. #define LT_SRC_UNION_OBJECT 2048 /* Union of light_source objects only */
  90. #define CHILDREN_FLAGS (PATCH_OBJECT+TEXTURED_OBJECT) /* Reverse inherited flags */
  91. /*****************************************************************************
  92. * Global typedefs
  93. ******************************************************************************/
  94. /*****************************************************************************
  95. * Global variables
  96. ******************************************************************************/
  97. extern unsigned int Number_of_istacks;
  98. extern unsigned int Max_Intersections;
  99. extern ISTACK *free_istack;
  100. /*****************************************************************************
  101. * Global functions
  102. ******************************************************************************/
  103. int Intersection (INTERSECTION *Ray_Intersection, OBJECT *Object, RAY *Ray);
  104. int Ray_In_Bound (RAY *Ray, OBJECT *Bounding_Object);
  105. int Point_In_Clip (VECTOR IPoint, OBJECT *Clip);
  106. OBJECT *Copy_Object (OBJECT *Old);
  107. void Translate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  108. void Rotate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  109. void Scale_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  110. void Transform_Object (OBJECT *Object, TRANSFORM *Trans);
  111. int Inside_Object (VECTOR IPoint, OBJECT *Vector);
  112. void Invert_Object (OBJECT *Object);
  113. void Destroy_Object (OBJECT *Object);
  114. ISTACK *open_istack (void);
  115. void close_istack (ISTACK *istk);
  116. void incstack (ISTACK *istk);
  117. void Destroy_IStacks (void);
  118. #endif