eggTexture.I 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. // Filename: eggTexture.I
  2. // Created by: drose (18Jan99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////
  6. // Function: EggTexture::Assignment operator
  7. // Access: Public
  8. // Description:
  9. ////////////////////////////////////////////////////////////////////
  10. INLINE EggTexture &EggTexture::
  11. operator = (const string &filename) {
  12. EggFilenameNode::operator = (filename);
  13. return *this;
  14. }
  15. ////////////////////////////////////////////////////////////////////
  16. // Function: EggTexture::Assignment operator
  17. // Access: Public
  18. // Description:
  19. ////////////////////////////////////////////////////////////////////
  20. INLINE EggTexture &EggTexture::
  21. operator = (const char *filename) {
  22. EggFilenameNode::operator = (filename);
  23. return *this;
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: EggTexture::Assignment operator
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE EggTexture &EggTexture::
  31. operator = (const Filename &filename) {
  32. EggFilenameNode::operator = (filename);
  33. return *this;
  34. }
  35. ////////////////////////////////////////////////////////////////////
  36. // Function: EggTexture::set_format
  37. // Access: Public
  38. // Description:
  39. ////////////////////////////////////////////////////////////////////
  40. INLINE void EggTexture::
  41. set_format(Format format) {
  42. _format = format;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: EggTexture::get_format
  46. // Access: Public
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. INLINE EggTexture::Format EggTexture::
  50. get_format() const {
  51. return _format;
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: EggTexture::set_wrap_mode
  55. // Access: Public
  56. // Description:
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE void EggTexture::
  59. set_wrap_mode(WrapMode mode) {
  60. _wrap_mode = mode;
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: EggTexture::get_wrap_mode
  64. // Access: Public
  65. // Description:
  66. ////////////////////////////////////////////////////////////////////
  67. INLINE EggTexture::WrapMode EggTexture::
  68. get_wrap_mode() const {
  69. return _wrap_mode;
  70. }
  71. ////////////////////////////////////////////////////////////////////
  72. // Function: EggTexture::set_wrap_u
  73. // Access: Public
  74. // Description:
  75. ////////////////////////////////////////////////////////////////////
  76. INLINE void EggTexture::
  77. set_wrap_u(WrapMode mode) {
  78. _wrap_u = mode;
  79. }
  80. ////////////////////////////////////////////////////////////////////
  81. // Function: EggTexture::get_wrap_u
  82. // Access: Public
  83. // Description: Returns the amount specified for U wrap. This may be
  84. // unspecified, even if there is an overall wrap value.
  85. ////////////////////////////////////////////////////////////////////
  86. INLINE EggTexture::WrapMode EggTexture::
  87. get_wrap_u() const {
  88. return _wrap_u;
  89. }
  90. ////////////////////////////////////////////////////////////////////
  91. // Function: EggTexture::determine_wrap_u
  92. // Access: Public
  93. // Description: Determines the appropriate wrap in the U direction.
  94. // This is different from get_wrap_u() in that if the U
  95. // wrap is unspecified, it returns the overall wrap
  96. // value.
  97. ////////////////////////////////////////////////////////////////////
  98. INLINE EggTexture::WrapMode EggTexture::
  99. determine_wrap_u() const {
  100. return (_wrap_u == WM_unspecified) ? get_wrap_mode() : get_wrap_u();
  101. }
  102. ////////////////////////////////////////////////////////////////////
  103. // Function: EggTexture::set_wrap_v
  104. // Access: Public
  105. // Description:
  106. ////////////////////////////////////////////////////////////////////
  107. INLINE void EggTexture::
  108. set_wrap_v(WrapMode mode) {
  109. _wrap_v = mode;
  110. }
  111. ////////////////////////////////////////////////////////////////////
  112. // Function: EggTexture::get_wrap_v
  113. // Access: Public
  114. // Description: Returns the amount specified for V wrap. This may be
  115. // unspecified, even if there is an overall wrap value.
  116. ////////////////////////////////////////////////////////////////////
  117. INLINE EggTexture::WrapMode EggTexture::
  118. get_wrap_v() const {
  119. return _wrap_v;
  120. }
  121. ////////////////////////////////////////////////////////////////////
  122. // Function: EggTexture::determine_wrap_v
  123. // Access: Public
  124. // Description: Determines the appropriate wrap in the V direction.
  125. // This is different from get_wrap_v() in that if the U
  126. // wrap is unspecified, it returns the overall wrap
  127. // value.
  128. ////////////////////////////////////////////////////////////////////
  129. INLINE EggTexture::WrapMode EggTexture::
  130. determine_wrap_v() const {
  131. return (_wrap_v == WM_unspecified) ? get_wrap_mode() : get_wrap_v();
  132. }
  133. ////////////////////////////////////////////////////////////////////
  134. // Function: EggTexture::set_minfilter
  135. // Access: Public
  136. // Description:
  137. ////////////////////////////////////////////////////////////////////
  138. INLINE void EggTexture::
  139. set_minfilter(FilterType type) {
  140. _minfilter = type;
  141. }
  142. ////////////////////////////////////////////////////////////////////
  143. // Function: EggTexture::get_minfilter
  144. // Access: Public
  145. // Description:
  146. ////////////////////////////////////////////////////////////////////
  147. INLINE EggTexture::FilterType EggTexture::
  148. get_minfilter() const {
  149. return _minfilter;
  150. }
  151. ////////////////////////////////////////////////////////////////////
  152. // Function: EggTexture::set_magfilter
  153. // Access: Public
  154. // Description:
  155. ////////////////////////////////////////////////////////////////////
  156. INLINE void EggTexture::
  157. set_magfilter(FilterType type) {
  158. _magfilter = type;
  159. }
  160. ////////////////////////////////////////////////////////////////////
  161. // Function: EggTexture::get_magfilter
  162. // Access: Public
  163. // Description:
  164. ////////////////////////////////////////////////////////////////////
  165. INLINE EggTexture::FilterType EggTexture::
  166. get_magfilter() const {
  167. return _magfilter;
  168. }
  169. ////////////////////////////////////////////////////////////////////
  170. // Function: EggTexture::set_magfilteralpha
  171. // Access: Public
  172. // Description:
  173. ////////////////////////////////////////////////////////////////////
  174. INLINE void EggTexture::
  175. set_magfilteralpha(FilterType type) {
  176. _magfilteralpha = type;
  177. }
  178. ////////////////////////////////////////////////////////////////////
  179. // Function: EggTexture::get_magfilteralpha
  180. // Access: Public
  181. // Description:
  182. ////////////////////////////////////////////////////////////////////
  183. INLINE EggTexture::FilterType EggTexture::
  184. get_magfilteralpha() const {
  185. return _magfilteralpha;
  186. }
  187. ////////////////////////////////////////////////////////////////////
  188. // Function: EggTexture::set_magfiltercolor
  189. // Access: Public
  190. // Description:
  191. ////////////////////////////////////////////////////////////////////
  192. INLINE void EggTexture::
  193. set_magfiltercolor(FilterType type) {
  194. _magfiltercolor = type;
  195. }
  196. ////////////////////////////////////////////////////////////////////
  197. // Function: EggTexture::get_magfiltercolor
  198. // Access: Public
  199. // Description:
  200. ////////////////////////////////////////////////////////////////////
  201. INLINE EggTexture::FilterType EggTexture::
  202. get_magfiltercolor() const {
  203. return _magfiltercolor;
  204. }
  205. ////////////////////////////////////////////////////////////////////
  206. // Function: EggTexture::set_env_type
  207. // Access: Public
  208. // Description:
  209. ////////////////////////////////////////////////////////////////////
  210. INLINE void EggTexture::
  211. set_env_type(EnvType type) {
  212. _env_type = type;
  213. }
  214. ////////////////////////////////////////////////////////////////////
  215. // Function: EggTexture::get_env_type
  216. // Access: Public
  217. // Description:
  218. ////////////////////////////////////////////////////////////////////
  219. INLINE EggTexture::EnvType EggTexture::
  220. get_env_type() const {
  221. return _env_type;
  222. }
  223. ////////////////////////////////////////////////////////////////////
  224. // Function: EggTexture::set_transform
  225. // Access: Public
  226. // Description:
  227. ////////////////////////////////////////////////////////////////////
  228. INLINE void EggTexture::
  229. set_transform(const LMatrix3d &transform) {
  230. _transform = transform;
  231. _has_transform = true;
  232. }
  233. ////////////////////////////////////////////////////////////////////
  234. // Function: EggTexture::clear_transform
  235. // Access: Public
  236. // Description:
  237. ////////////////////////////////////////////////////////////////////
  238. INLINE void EggTexture::
  239. clear_transform() {
  240. _transform = LMatrix3d::ident_mat();
  241. _has_transform = false;
  242. }
  243. ////////////////////////////////////////////////////////////////////
  244. // Function: EggTexture::has_transform
  245. // Access: Public
  246. // Description: Returns true if a texture matrix transform has been
  247. // specified for the texture (even if the transform is
  248. // identity).
  249. ////////////////////////////////////////////////////////////////////
  250. INLINE bool EggTexture::
  251. has_transform() const {
  252. return _has_transform;
  253. }
  254. ////////////////////////////////////////////////////////////////////
  255. // Function: EggTexture::get_transform
  256. // Access: Public
  257. // Description:
  258. ////////////////////////////////////////////////////////////////////
  259. INLINE LMatrix3d EggTexture::
  260. get_transform() const {
  261. nassertr(_has_transform, LMatrix3d::ident_mat());
  262. return _transform;
  263. }
  264. ////////////////////////////////////////////////////////////////////
  265. // Function: EggTexture::transform_is_identity()
  266. // Access: Public
  267. // Description: Returns true if no texture matrix transform has been
  268. // specified, or if the one specified is the identity
  269. // transform. Returns false only if a nonidentity
  270. // transform has been applied.
  271. ////////////////////////////////////////////////////////////////////
  272. INLINE bool EggTexture::
  273. transform_is_identity() const {
  274. return (!_has_transform ||
  275. _transform.almost_equal(LMatrix3d::ident_mat(), 0.0001));
  276. }
  277. ////////////////////////////////////////////////////////////////////
  278. // Function: UniqueEggTextures::Constructor
  279. // Access: Public
  280. // Description:
  281. ////////////////////////////////////////////////////////////////////
  282. INLINE UniqueEggTextures::
  283. UniqueEggTextures(int eq) : _eq(eq) {
  284. }
  285. ////////////////////////////////////////////////////////////////////
  286. // Function: UniqueEggTextures::Function operator
  287. // Access: Public
  288. // Description:
  289. ////////////////////////////////////////////////////////////////////
  290. INLINE bool UniqueEggTextures::
  291. operator ()(const EggTexture *t1, const EggTexture *t2) const {
  292. return t1->sorts_less_than(*t2, _eq);
  293. }