afTextureStage.cpp
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:5k
源码类别:

其他游戏

开发平台:

Visual C++

  1. #include "afTextureStage.h"
  2. afTextureStage::afTextureStage(afTexture* nTexture, FILTER nMinFilter, FILTER nMagFilter, FILTER nMipFilter)
  3. {
  4. texture = nTexture;
  5. minFilter = nMinFilter;
  6. magFilter = nMagFilter;
  7. mipFilter = nMipFilter;
  8. colorOp = TEXOP_SELECT_ARG1;
  9. colorArg1 = TEXARG_TEXTURE;
  10. colorArg2 = TEXARG_DIFFUSE;
  11. alphaOp = TEXOP_DISABLE;
  12. alphaArg1 = alphaArg2 = TEXARG_DIFFUSE;
  13. coordIdx = 0;
  14. }
  15. afTextureStage::FILTER afTextureStage::getFilterFromString(const afString& nString)
  16. {
  17. afString str = nString;
  18. str.toLower();
  19. if(str=="none")
  20. return FILTER_NONE;
  21. if(str=="point")
  22. return FILTER_POINT;
  23. if(str=="linear")
  24. return FILTER_LINEAR;
  25. if(str=="anisotropic")
  26. return FILTER_ANISOTROPIC;
  27. return FILTER_LINEAR;
  28. }
  29. const char* afTextureStage::getStringFromFilter(afTextureStage::FILTER nFilter)
  30. {
  31. switch(nFilter)
  32. {
  33. default:
  34. case FILTER_NONE:
  35. return "none";
  36. case FILTER_POINT:
  37. return "point";
  38. case FILTER_LINEAR:
  39. return "linear";
  40. case FILTER_ANISOTROPIC:
  41. return "anisotropic";
  42. }
  43. }
  44. afTextureStage::TEXTUREOP afTextureStage::getTextureOpFromString(const afString& nString)
  45. {
  46. if(nString=="disable")
  47. return TEXOP_DISABLE;
  48. if(nString=="select_arg1")
  49. return TEXOP_SELECT_ARG1;
  50. if(nString=="select_arg2")
  51. return TEXOP_SELECT_ARG2;
  52. if(nString=="modulate")
  53. return TEXOP_MODULATE;
  54. if(nString=="modulate2x")
  55. return TEXOP_MODULATE2X;
  56. if(nString=="modulate4x")
  57. return TEXOP_MODULATE4X;
  58. if(nString=="add")
  59. return TEXOP_ADD;
  60. if(nString=="addsigned")
  61. return TEXOP_ADDSIGNED;
  62. if(nString=="addsigned2x")
  63. return TEXOP_ADDSIGNED2X;
  64. if(nString=="subtract")
  65. return TEXOP_SUBTRACT;
  66. if(nString=="addsmooth")
  67. return TEXOP_ADDSMOOTH;
  68. if(nString=="blenddiffusealpha")
  69. return TEXOP_BLENDDIFFUSEALPHA;
  70. if(nString=="blendtexturealpha")
  71. return TEXOP_BLENDTEXTUREALPHA;
  72. if(nString=="blendfactoralpha")
  73. return TEXOP_BLENDFACTORALPHA;
  74. if(nString=="blendtexturealphapm")
  75. return TEXOP_BLENDTEXTUREALPHAPM;
  76. if(nString=="blendcurrentalpha")
  77. return TEXOP_BLENDCURRENTALPHA;
  78. if(nString=="premodulate")
  79. return TEXOP_PREMODULATE;
  80. if(nString=="modulatealpha_addcolor")
  81. return TEXOP_MODULATEALPHA_ADDCOLOR;
  82. if(nString=="modulatecolor_addalpha")
  83. return TEXOP_MODULATECOLOR_ADDALPHA;
  84. if(nString=="modulateinvalpha_addcolor")
  85. return TEXOP_MODULATEINVALPHA_ADDCOLOR;
  86. if(nString=="modulateinvcolor_addalpha")
  87. return TEXOP_MODULATEINVCOLOR_ADDALPHA;
  88. if(nString=="bumpenvmap")
  89. return TEXOP_BUMPENVMAP;
  90. if(nString=="bumpenvmapluminance")
  91. return TEXOP_BUMPENVMAPLUMINANCE;
  92. if(nString=="dotproduct3")
  93. return TEXOP_DOTPRODUCT3;
  94. if(nString=="multiplyadd")
  95. return TEXOP_MULTIPLYADD;
  96. if(nString=="lerp")
  97. return TEXOP_LERP;
  98. return TEXOP_DISABLE;
  99. }
  100. const char* afTextureStage::getStringFromTextureOp(afTextureStage::TEXTUREOP nOp)
  101. {
  102. switch(nOp)
  103. {
  104. default:
  105. case TEXOP_DISABLE:
  106. return "disable";
  107. case TEXOP_SELECT_ARG1:
  108. return "select_arg1";
  109. case TEXOP_SELECT_ARG2:
  110. return "select_arg2";
  111. case TEXOP_MODULATE:
  112. return "modulate";
  113. case TEXOP_MODULATE2X:
  114. return "modulate2x";
  115. case TEXOP_MODULATE4X:
  116. return "modulate4x";
  117. case TEXOP_ADD:
  118. return "add";
  119. case TEXOP_ADDSIGNED:
  120. return "addsigned";
  121. case TEXOP_ADDSIGNED2X:
  122. return "addsigned2x";
  123. case TEXOP_SUBTRACT:
  124. return "subtract";
  125. case TEXOP_ADDSMOOTH:
  126. return "addsmooth";
  127. case TEXOP_BLENDDIFFUSEALPHA:
  128. return "blenddiffusealpha";
  129. case TEXOP_BLENDTEXTUREALPHA:
  130. return "blendtexturealpha";
  131. case TEXOP_BLENDFACTORALPHA:
  132. return "blendfactoralpha";
  133. case TEXOP_BLENDTEXTUREALPHAPM:
  134. return "blendtexturealphapm";
  135. case TEXOP_BLENDCURRENTALPHA:
  136. return "blendcurrentalpha";
  137. case TEXOP_PREMODULATE:
  138. return "premodulate";
  139. case TEXOP_MODULATEALPHA_ADDCOLOR:
  140. return "modulatealpha_addcolor";
  141. case TEXOP_MODULATECOLOR_ADDALPHA:
  142. return "modulatecolor_addalpha";
  143. case TEXOP_MODULATEINVALPHA_ADDCOLOR:
  144. return "modulateinvalpha_addcolor";
  145. case TEXOP_MODULATEINVCOLOR_ADDALPHA:
  146. return "modulateinvcolor_addalpha";
  147. case TEXOP_BUMPENVMAP:
  148. return "bumpenvmap";
  149. case TEXOP_BUMPENVMAPLUMINANCE:
  150. return "bumpenvmapluminance";
  151. case TEXOP_DOTPRODUCT3:
  152. return "dotproduct3";
  153. case TEXOP_MULTIPLYADD:
  154. return "multiplyadd";
  155. case TEXOP_LERP:
  156. return "lerp";
  157. }
  158. }
  159. afTextureStage::TEXTUREARG afTextureStage::getTextureArgFromString(const afString& nString)
  160. {
  161. if(nString=="diffuse")
  162. return TEXARG_DIFFUSE;
  163. if(nString=="current")
  164. return TEXARG_CURRENT;
  165. if(nString=="texture")
  166. return TEXARG_TEXTURE;
  167. if(nString=="tfactor")
  168. return TEXARG_TFACTOR;
  169. if(nString=="specular")
  170. return TEXARG_SPECULAR;
  171. if(nString=="temp")
  172. return TEXARG_TEMP;
  173. if(nString=="complement")
  174. return TEXARG_COMPLEMENT;
  175. if(nString=="alphareplicate")
  176. return TEXARG_ALPHAREPLICATE;
  177. return TEXARG_DIFFUSE;
  178. }
  179. const char* afTextureStage::getStringFromTextureArg(afTextureStage::TEXTUREARG nArg)
  180. {
  181. switch(nArg)
  182. {
  183. default:
  184. case TEXARG_DIFFUSE:
  185. return "diffuse";
  186. case TEXARG_CURRENT:
  187. return "current";
  188. case TEXARG_TEXTURE:
  189. return "texture";
  190. case TEXARG_TFACTOR:
  191. return "tfactor";
  192. case TEXARG_SPECULAR:
  193. return "specular";
  194. case TEXARG_TEMP:
  195. return "temp";
  196. case TEXARG_COMPLEMENT:
  197. return "complement";
  198. case TEXARG_ALPHAREPLICATE:
  199. return "alphareplicate";
  200. }
  201. return "diffuse";
  202. }