D3DVertex.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:7k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1999 DXGuide.  All Rights Reserved.
  2. // File: D3DVertex.h
  3. #ifndef _D3DVERTEX__H
  4. #define _D3DVERTEX__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. // turn off warnings for /W4
  9. #pragma warning(disable: 4201)
  10. #define D3D_OVERLOADS
  11. #include <d3d.h> // for dwVertexTypeDesc...
  12. #pragma warning(default: 4201)
  13. #pragma pack(4)
  14. // U -> Untransformed, member: dvX+dvY+dvZ, TypeDesc: D3DFVF_XYZ
  15. // N -> U, Normal, member: dvNX+dvNY+dvNZ, TypeDesc: D3DFVF_NORMAL
  16. // T -> Transformed, member: dvSX+dvSY+dvSZ+dvRHW, TypeDesc: D3DFVF_XYZRHW
  17. // L -> lit, D+S, member: dcColor+dcSpecular, TypeDesc: D3DFVF_DIFFUSE+D3DFVF_SPECULAR
  18. // D -> Diffuse, member: dcColor, TypeDesc: D3DFVF_DIFFUSE
  19. // S -> Specular, member: dcSpecular, TypeDesc: D3DFVF_SPECULAR
  20. // 0..8 -> Number of texture coordinate sets, member: dvTUx+dvTVx, TypeDesc: D3DFVF_TEX0 through D3DFVF_TEX8
  21. // 1..4 -> D3DFVF_TEXCOORDSIZE?
  22. // Samples: D3DVERTEX = CD3DUN1Vertex, D3DFVF_VERTEX = CD3DUN1Vertex.TypeDesc
  23. // Untransformed/unlit vertices == D3DVERTEX
  24. class CD3DUN1Vertex
  25. {
  26. public:
  27. enum
  28. {
  29. TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1
  30. };
  31. public:
  32. CD3DUN1Vertex(void)
  33. {
  34. }
  35. CD3DUN1Vertex(const D3DVECTOR&  v,
  36. const D3DVECTOR&  n,
  37. D3DVALUE  dvTU1, D3DVALUE  dvTV1)
  38. {
  39. m_dvX = v.x;
  40. m_dvY = v.y;
  41. m_dvZ = v.z;
  42. m_dvNX = n.x;
  43. m_dvNY = n.y;
  44. m_dvNZ = n.z;
  45. m_dvTU1 = dvTU1;
  46. m_dvTV1 = dvTV1;
  47. }
  48. public:
  49. D3DVALUE m_dvX; // Homogeneous coordinates
  50. D3DVALUE m_dvY;
  51. D3DVALUE m_dvZ;
  52. D3DVALUE m_dvNX; // Normal
  53. D3DVALUE m_dvNY;
  54. D3DVALUE m_dvNZ;
  55. D3DVALUE m_dvTU1; // Texture coordinates
  56. D3DVALUE m_dvTV1;
  57. };
  58. class CD3DUN13Vertex : public CD3DUN1Vertex
  59. {
  60. public:
  61. enum
  62. {
  63. TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0)
  64. };
  65. public:
  66. CD3DUN13Vertex(void)
  67. {
  68. }
  69. CD3DUN13Vertex(const D3DVECTOR&  v, const D3DVECTOR&  n,
  70. D3DVALUE  dvTU1, D3DVALUE  dvTV1, D3DVALUE  dvTZ1)
  71. :
  72. CD3DUN1Vertex(v, n, dvTU1, dvTV1)
  73. {
  74. m_dvTZ1 = dvTZ1;
  75. }
  76. public:
  77. D3DVALUE m_dvTZ1; // Texture 3th coordinates
  78. };
  79. // Untransformed/unlit and multitextured vertices
  80. class CD3DUN2Vertex : public  CD3DUN1Vertex
  81. {
  82. public:
  83. enum
  84. {
  85. TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2
  86. };
  87. public:
  88. CD3DUN2Vertex(void)
  89. {
  90. }
  91. CD3DUN2Vertex(const D3DVECTOR&  v, const D3DVECTOR&  n,
  92. D3DVALUE  dvTU1, D3DVALUE  dvTV1,
  93. D3DVALUE  dvTU2, D3DVALUE  dvTV2)
  94. :
  95. CD3DUN1Vertex(v, n, dvTU1, dvTV1)
  96. {
  97. m_dvTU2 = dvTU2;
  98. m_dvTV2 = dvTV2;
  99. }
  100. public:
  101. D3DVALUE m_dvTU2; // 2nd Texture coordinates
  102. D3DVALUE m_dvTV2;
  103. };
  104. // --------------------------------------
  105. // Transformed/lit vertices = D3DTLVERTEX
  106. class CD3DTL1Vertex
  107. {
  108. public:
  109. enum
  110. {
  111. TypeDesc = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1
  112. };
  113. public:
  114. CD3DTL1Vertex(void)
  115. {
  116. }
  117. CD3DTL1Vertex(const D3DVECTOR&  v, D3DVALUE  dvRHW,
  118. D3DCOLOR  dcColor, D3DCOLOR  dcSpecular,
  119. D3DVALUE  dvTU1, D3DVALUE  dvTV1)
  120. {
  121. m_dvSX = v.x;
  122. m_dvSY = v.y;
  123. m_dvSZ = v.z;
  124. m_dvRHW = dvRHW;
  125. m_dcColor = dcColor;
  126. m_dcSpecular = dcSpecular;
  127. m_dvTU1 = dvTU1;
  128. m_dvTV1 = dvTV1;
  129. }
  130. public:
  131. D3DVALUE m_dvSX; // Screen coordinates
  132. D3DVALUE m_dvSY;
  133. D3DVALUE m_dvSZ;
  134. D3DVALUE m_dvRHW; // Reciprocal of homogeneous w
  135. D3DCOLOR m_dcColor; // Vertex color
  136. D3DCOLOR m_dcSpecular; // Specular component of vertex
  137. D3DVALUE m_dvTU1; // 1st Texture coordinates
  138. D3DVALUE m_dvTV1;
  139. };
  140. // Transformed/lit and multitextured vertices
  141. class CD3DTL2Vertex : public  CD3DTL1Vertex
  142. {
  143. public:
  144. enum
  145. {
  146. TypeDesc = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2
  147. };
  148. public:
  149. CD3DTL2Vertex(void)
  150. {
  151. }
  152. CD3DTL2Vertex(const D3DVECTOR&  v, D3DVALUE  dvRHW,
  153. D3DCOLOR  dcColor, D3DCOLOR  dcSpecular,
  154. D3DVALUE  dvTU1, D3DVALUE  dvTV1,
  155. D3DVALUE  dvTU2, D3DVALUE  dvTV2)
  156. :
  157. CD3DTL1Vertex(v, dvRHW, dcColor, dcSpecular,
  158. dvTU1, dvTV1)
  159. {
  160. m_dvTU2 = dvTU2;
  161. m_dvTV2 = dvTV2;
  162. }
  163. public:
  164. D3DVALUE m_dvTU2; // 2nd Texture coordinates
  165. D3DVALUE m_dvTV2;
  166. };
  167. // --------------------------------------
  168. // Untransformed/lit vertices ~= D3DLVERTEX
  169. class CD3DUL1Vertex
  170. {
  171. public:
  172. enum
  173. {
  174. TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1
  175. };
  176. public:
  177. CD3DUL1Vertex(void)
  178. {
  179. }
  180. CD3DUL1Vertex(const D3DVECTOR&  v,
  181. D3DCOLOR  dcColor, D3DCOLOR dcSpecular,
  182. D3DVALUE  dvTU1, D3DVALUE  dvTV1)
  183. {
  184. m_dvX = v.x;
  185. m_dvY = v.y;
  186. m_dvZ = v.z;
  187.           m_dcColor = dcColor;
  188. m_dcSpecular = dcSpecular;
  189.           m_dvTU1 = dvTU1;
  190. m_dvTV1 = dvTV1;
  191. }
  192. public:
  193. D3DVALUE m_dvX; // Homogeneous coordinates
  194. D3DVALUE m_dvY;
  195. D3DVALUE m_dvZ;
  196. D3DCOLOR m_dcColor; // Vertex color
  197. D3DCOLOR m_dcSpecular; // Specular component of vertex
  198. D3DVALUE m_dvTU1; // 1st Texture coordinates
  199. D3DVALUE m_dvTV1;
  200. };
  201. // Untransformed/lit and multitextured vertices
  202. class CD3DUL2Vertex : public  CD3DUL1Vertex
  203. {
  204. public:
  205. enum
  206. {
  207. TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2
  208. };
  209. public:
  210. CD3DUL2Vertex(void)
  211. {
  212. }
  213. CD3DUL2Vertex(const D3DVECTOR&  v,
  214. D3DCOLOR  dcColor, D3DCOLOR  dcSpecular,
  215. D3DVALUE  dvTU1, D3DVALUE  dvTV1,
  216. D3DVALUE  dvTU2, D3DVALUE  dvTV2)
  217. :
  218. CD3DUL1Vertex(v, dcColor, dcSpecular, dvTU1, dvTV1)
  219. {
  220. m_dvTU2 = dvTU2;
  221. m_dvTV2 = dvTV2;
  222. }
  223. public:
  224. D3DVALUE m_dvTU2; // 2nd Texture coordinates
  225. D3DVALUE m_dvTV2;
  226. };
  227. // --------------------------------------
  228. // a custom vertex that uses XYZ and two sets of tex coords
  229. class CD3DU2Vertex
  230. {
  231. public:
  232. enum
  233. {
  234. TypeDesc = D3DFVF_XYZ | D3DFVF_TEX2
  235. };
  236. public:
  237. CD3DU2Vertex(void)
  238. {
  239. }
  240. CD3DU2Vertex(const D3DVECTOR&  v,
  241. D3DVALUE  dvTU1, D3DVALUE  dvTV1,
  242. D3DVALUE  dvTU2, D3DVALUE  dvTV2)
  243. {
  244. m_dvX = v.x;
  245. m_dvY = v.y;
  246. m_dvZ = v.z;
  247. m_dvTU1 = dvTU1;
  248. m_dvTV1 = dvTV1;
  249. m_dvTU2 = dvTU2;
  250. m_dvTV2 = dvTV2;
  251. }
  252. public:
  253. D3DVALUE m_dvX; // Homogeneous coordinates
  254. D3DVALUE m_dvY;
  255. D3DVALUE m_dvZ;
  256. D3DVALUE m_dvTU1; // 1st Texture coordinates
  257. D3DVALUE m_dvTV1;
  258. D3DVALUE m_dvTU2; // 2nd Texture coordinates
  259. D3DVALUE m_dvTV2;
  260. };
  261. // Define a custom vertex that uses XYZ, a color, and two sets of tex coords
  262. class CD3DUD2Vertex
  263. {
  264. public:
  265. enum
  266. {
  267. TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2
  268. };
  269. public:
  270. CD3DUD2Vertex(void)
  271. {
  272. }
  273. CD3DUD2Vertex(const D3DVECTOR&  v,
  274. D3DCOLOR  dcColor,
  275. D3DVALUE  dvTU1, D3DVALUE  dvTV1,
  276. D3DVALUE  dvTU2, D3DVALUE  dvTV2)
  277. {
  278. m_dvX = v.x;
  279. m_dvY = v.y;
  280. m_dvZ = v.z;
  281. m_dcColor = dcColor;
  282. m_dvTU1 = dvTU1;
  283. m_dvTV1 = dvTV1;
  284. m_dvTU2 = dvTU2;
  285. m_dvTV2 = dvTV2;
  286. }
  287. public:
  288. D3DVALUE m_dvX; // Homogeneous coordinates
  289. D3DVALUE m_dvY;
  290. D3DVALUE m_dvZ;
  291. D3DCOLOR m_dcColor;
  292. D3DVALUE m_dvTU1; // 1st Texture coordinates
  293. D3DVALUE m_dvTV1;
  294. D3DVALUE m_dvTU2; // 2nd Texture coordinates
  295. D3DVALUE m_dvTV2;
  296. };
  297. #pragma pack()
  298. #endif // _D3DVERTEX__H