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

其他游戏

开发平台:

Visual C++

  1. #ifndef AF_TEXTURESTAGE
  2. #define AF_TEXTURESTAGE
  3. #include "afTexture.h"
  4. #include <D3DX9.h>
  5. /**
  6.  *  afTextureStage defines the setup of a specific
  7.  *  texture stage for a segment.
  8.  */
  9. class afTextureStage
  10. {
  11. friend class afSegment;
  12. friend class afXUtil;
  13. public:
  14. /// Filder method
  15. enum FILTER  {
  16. FILTER_NONE = D3DTEXF_NONE, /**<  No filtering (only valid for mipmap, means: no mipmapping)  */
  17. FILTER_POINT = D3DTEXF_POINT, /**<  Nearest neighbour  */
  18. FILTER_LINEAR = D3DTEXF_LINEAR, /**<  Linear interpolation  */
  19. FILTER_ANISOTROPIC = D3DTEXF_ANISOTROPIC /**<  Anisotropic filtering  */
  20. };
  21. enum TEXTUREOP  {
  22. TEXOP_DISABLE = D3DTOP_DISABLE,
  23. TEXOP_SELECT_ARG1 = D3DTOP_SELECTARG1,
  24. TEXOP_SELECT_ARG2 = D3DTOP_SELECTARG2,
  25. TEXOP_MODULATE = D3DTOP_MODULATE,
  26. TEXOP_MODULATE2X = D3DTOP_MODULATE2X,
  27. TEXOP_MODULATE4X = D3DTOP_MODULATE4X,
  28. TEXOP_ADD = D3DTOP_ADD,
  29. TEXOP_ADDSIGNED = D3DTOP_ADDSIGNED,
  30. TEXOP_ADDSIGNED2X = D3DTOP_ADDSIGNED2X,
  31. TEXOP_SUBTRACT = D3DTOP_SUBTRACT,
  32. TEXOP_ADDSMOOTH = D3DTOP_ADDSMOOTH,
  33. TEXOP_BLENDDIFFUSEALPHA = D3DTOP_BLENDDIFFUSEALPHA,
  34. TEXOP_BLENDTEXTUREALPHA = D3DTOP_BLENDTEXTUREALPHA,
  35. TEXOP_BLENDFACTORALPHA = D3DTOP_BLENDFACTORALPHA,
  36. TEXOP_BLENDTEXTUREALPHAPM = D3DTOP_BLENDTEXTUREALPHAPM,
  37. TEXOP_BLENDCURRENTALPHA = D3DTOP_BLENDCURRENTALPHA,
  38. TEXOP_PREMODULATE = D3DTOP_PREMODULATE,
  39. TEXOP_MODULATEALPHA_ADDCOLOR = D3DTOP_MODULATEALPHA_ADDCOLOR,
  40. TEXOP_MODULATECOLOR_ADDALPHA = D3DTOP_MODULATECOLOR_ADDALPHA,
  41. TEXOP_MODULATEINVALPHA_ADDCOLOR = D3DTOP_MODULATEINVALPHA_ADDCOLOR,
  42. TEXOP_MODULATEINVCOLOR_ADDALPHA = D3DTOP_MODULATEINVCOLOR_ADDALPHA,
  43. TEXOP_BUMPENVMAP = D3DTOP_BUMPENVMAP,
  44. TEXOP_BUMPENVMAPLUMINANCE = D3DTOP_BUMPENVMAPLUMINANCE,
  45. TEXOP_DOTPRODUCT3 = D3DTOP_DOTPRODUCT3,
  46. TEXOP_MULTIPLYADD = D3DTOP_MULTIPLYADD,
  47. TEXOP_LERP = D3DTOP_LERP  };
  48. enum TEXTUREARG  {
  49. TEXARG_DIFFUSE = D3DTA_DIFFUSE,
  50. TEXARG_CURRENT = D3DTA_CURRENT,
  51. TEXARG_TEXTURE = D3DTA_TEXTURE,
  52. TEXARG_TFACTOR = D3DTA_TFACTOR,
  53. TEXARG_SPECULAR = D3DTA_SPECULAR,
  54. TEXARG_TEMP = D3DTA_TEMP,
  55. TEXARG_COMPLEMENT = D3DTA_COMPLEMENT,
  56. TEXARG_ALPHAREPLICATE = D3DTA_ALPHAREPLICATE  };
  57. afTextureStage(afTexture* nTexture=NULL, FILTER nMinFilter=FILTER_LINEAR, FILTER nMagFilter=FILTER_LINEAR, FILTER nMipFilter=FILTER_POINT);
  58. void setTexture(afTexture* nTexture)  {  texture = nTexture;  }
  59. void setCoordIndex(int nIdx)  {  coordIdx = nIdx;  }
  60. void setMinFilter(FILTER nMinFilter)  {  minFilter = nMinFilter;  }
  61. void setMagFilter(FILTER nMagFilter)  {  magFilter = nMagFilter;  }
  62. void setMipFilter(FILTER nMipFilter)  {  mipFilter = nMipFilter;  }
  63. void setColorOp(TEXTUREOP nOp)  {  colorOp = nOp;  }
  64. void setColorArg1(TEXTUREARG nArg)  {  colorArg1 = nArg;  }
  65. void setColorArg2(TEXTUREARG nArg)  {  colorArg2 = nArg;  }
  66. void setAlphaOp(TEXTUREOP nOp)  {  alphaOp = nOp;  }
  67. void setAlphaArg1(TEXTUREARG nArg)  {  alphaArg1 = nArg;  }
  68. void setAlphaArg2(TEXTUREARG nArg)  {  alphaArg2 = nArg;  }
  69. const afTexture* getTexture() const  {  return texture;  }
  70. friend bool // operator== needed for afList
  71. operator==(const afTextureStage&, const afTextureStage&)  {  return false;  }
  72. static FILTER getFilterFromString(const afString& nString);
  73. static const char* getStringFromFilter(FILTER nFilter);
  74. static TEXTUREOP getTextureOpFromString(const afString& nString);
  75. static const char* getStringFromTextureOp(afTextureStage::TEXTUREOP nOp);
  76. static TEXTUREARG getTextureArgFromString(const afString& nString);
  77. static const char* getStringFromTextureArg(afTextureStage::TEXTUREARG nArg);
  78. protected:
  79. afTexture* texture;
  80. FILTER minFilter,
  81. magFilter,
  82. mipFilter;
  83. TEXTUREOP colorOp;
  84. TEXTUREARG colorArg1, colorArg2;
  85. TEXTUREOP alphaOp;
  86. TEXTUREARG alphaArg1, alphaArg2;
  87. int coordIdx;
  88. };
  89. #endif