D3DVertex.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:7k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1999 DXGuide. All Rights Reserved.
- // File: D3DVertex.h
- #ifndef _D3DVERTEX__H
- #define _D3DVERTEX__H
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- // turn off warnings for /W4
- #pragma warning(disable: 4201)
- #define D3D_OVERLOADS
- #include <d3d.h> // for dwVertexTypeDesc...
- #pragma warning(default: 4201)
- #pragma pack(4)
- // U -> Untransformed, member: dvX+dvY+dvZ, TypeDesc: D3DFVF_XYZ
- // N -> U, Normal, member: dvNX+dvNY+dvNZ, TypeDesc: D3DFVF_NORMAL
- // T -> Transformed, member: dvSX+dvSY+dvSZ+dvRHW, TypeDesc: D3DFVF_XYZRHW
- // L -> lit, D+S, member: dcColor+dcSpecular, TypeDesc: D3DFVF_DIFFUSE+D3DFVF_SPECULAR
- // D -> Diffuse, member: dcColor, TypeDesc: D3DFVF_DIFFUSE
- // S -> Specular, member: dcSpecular, TypeDesc: D3DFVF_SPECULAR
- // 0..8 -> Number of texture coordinate sets, member: dvTUx+dvTVx, TypeDesc: D3DFVF_TEX0 through D3DFVF_TEX8
- // 1..4 -> D3DFVF_TEXCOORDSIZE?
- // Samples: D3DVERTEX = CD3DUN1Vertex, D3DFVF_VERTEX = CD3DUN1Vertex.TypeDesc
- // Untransformed/unlit vertices == D3DVERTEX
- class CD3DUN1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1
- };
- public:
- CD3DUN1Vertex(void)
- {
- }
- CD3DUN1Vertex(const D3DVECTOR& v,
- const D3DVECTOR& n,
- D3DVALUE dvTU1, D3DVALUE dvTV1)
- {
- m_dvX = v.x;
- m_dvY = v.y;
- m_dvZ = v.z;
- m_dvNX = n.x;
- m_dvNY = n.y;
- m_dvNZ = n.z;
- m_dvTU1 = dvTU1;
- m_dvTV1 = dvTV1;
- }
- public:
- D3DVALUE m_dvX; // Homogeneous coordinates
- D3DVALUE m_dvY;
- D3DVALUE m_dvZ;
- D3DVALUE m_dvNX; // Normal
- D3DVALUE m_dvNY;
- D3DVALUE m_dvNZ;
- D3DVALUE m_dvTU1; // Texture coordinates
- D3DVALUE m_dvTV1;
- };
- class CD3DUN13Vertex : public CD3DUN1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0)
- };
- public:
- CD3DUN13Vertex(void)
- {
- }
- CD3DUN13Vertex(const D3DVECTOR& v, const D3DVECTOR& n,
- D3DVALUE dvTU1, D3DVALUE dvTV1, D3DVALUE dvTZ1)
- :
- CD3DUN1Vertex(v, n, dvTU1, dvTV1)
- {
- m_dvTZ1 = dvTZ1;
- }
- public:
- D3DVALUE m_dvTZ1; // Texture 3th coordinates
- };
- // Untransformed/unlit and multitextured vertices
- class CD3DUN2Vertex : public CD3DUN1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2
- };
- public:
- CD3DUN2Vertex(void)
- {
- }
- CD3DUN2Vertex(const D3DVECTOR& v, const D3DVECTOR& n,
- D3DVALUE dvTU1, D3DVALUE dvTV1,
- D3DVALUE dvTU2, D3DVALUE dvTV2)
- :
- CD3DUN1Vertex(v, n, dvTU1, dvTV1)
- {
- m_dvTU2 = dvTU2;
- m_dvTV2 = dvTV2;
- }
- public:
- D3DVALUE m_dvTU2; // 2nd Texture coordinates
- D3DVALUE m_dvTV2;
- };
- // --------------------------------------
- // Transformed/lit vertices = D3DTLVERTEX
- class CD3DTL1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1
- };
- public:
- CD3DTL1Vertex(void)
- {
- }
- CD3DTL1Vertex(const D3DVECTOR& v, D3DVALUE dvRHW,
- D3DCOLOR dcColor, D3DCOLOR dcSpecular,
- D3DVALUE dvTU1, D3DVALUE dvTV1)
- {
- m_dvSX = v.x;
- m_dvSY = v.y;
- m_dvSZ = v.z;
- m_dvRHW = dvRHW;
- m_dcColor = dcColor;
- m_dcSpecular = dcSpecular;
- m_dvTU1 = dvTU1;
- m_dvTV1 = dvTV1;
- }
- public:
- D3DVALUE m_dvSX; // Screen coordinates
- D3DVALUE m_dvSY;
- D3DVALUE m_dvSZ;
- D3DVALUE m_dvRHW; // Reciprocal of homogeneous w
- D3DCOLOR m_dcColor; // Vertex color
- D3DCOLOR m_dcSpecular; // Specular component of vertex
- D3DVALUE m_dvTU1; // 1st Texture coordinates
- D3DVALUE m_dvTV1;
- };
- // Transformed/lit and multitextured vertices
- class CD3DTL2Vertex : public CD3DTL1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2
- };
- public:
- CD3DTL2Vertex(void)
- {
- }
- CD3DTL2Vertex(const D3DVECTOR& v, D3DVALUE dvRHW,
- D3DCOLOR dcColor, D3DCOLOR dcSpecular,
- D3DVALUE dvTU1, D3DVALUE dvTV1,
- D3DVALUE dvTU2, D3DVALUE dvTV2)
- :
- CD3DTL1Vertex(v, dvRHW, dcColor, dcSpecular,
- dvTU1, dvTV1)
- {
- m_dvTU2 = dvTU2;
- m_dvTV2 = dvTV2;
- }
- public:
- D3DVALUE m_dvTU2; // 2nd Texture coordinates
- D3DVALUE m_dvTV2;
- };
- // --------------------------------------
- // Untransformed/lit vertices ~= D3DLVERTEX
- class CD3DUL1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1
- };
- public:
- CD3DUL1Vertex(void)
- {
- }
- CD3DUL1Vertex(const D3DVECTOR& v,
- D3DCOLOR dcColor, D3DCOLOR dcSpecular,
- D3DVALUE dvTU1, D3DVALUE dvTV1)
- {
- m_dvX = v.x;
- m_dvY = v.y;
- m_dvZ = v.z;
- m_dcColor = dcColor;
- m_dcSpecular = dcSpecular;
- m_dvTU1 = dvTU1;
- m_dvTV1 = dvTV1;
- }
- public:
- D3DVALUE m_dvX; // Homogeneous coordinates
- D3DVALUE m_dvY;
- D3DVALUE m_dvZ;
- D3DCOLOR m_dcColor; // Vertex color
- D3DCOLOR m_dcSpecular; // Specular component of vertex
- D3DVALUE m_dvTU1; // 1st Texture coordinates
- D3DVALUE m_dvTV1;
- };
- // Untransformed/lit and multitextured vertices
- class CD3DUL2Vertex : public CD3DUL1Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2
- };
- public:
- CD3DUL2Vertex(void)
- {
- }
- CD3DUL2Vertex(const D3DVECTOR& v,
- D3DCOLOR dcColor, D3DCOLOR dcSpecular,
- D3DVALUE dvTU1, D3DVALUE dvTV1,
- D3DVALUE dvTU2, D3DVALUE dvTV2)
- :
- CD3DUL1Vertex(v, dcColor, dcSpecular, dvTU1, dvTV1)
- {
- m_dvTU2 = dvTU2;
- m_dvTV2 = dvTV2;
- }
- public:
- D3DVALUE m_dvTU2; // 2nd Texture coordinates
- D3DVALUE m_dvTV2;
- };
- // --------------------------------------
- // a custom vertex that uses XYZ and two sets of tex coords
- class CD3DU2Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_TEX2
- };
- public:
- CD3DU2Vertex(void)
- {
- }
- CD3DU2Vertex(const D3DVECTOR& v,
- D3DVALUE dvTU1, D3DVALUE dvTV1,
- D3DVALUE dvTU2, D3DVALUE dvTV2)
- {
- m_dvX = v.x;
- m_dvY = v.y;
- m_dvZ = v.z;
- m_dvTU1 = dvTU1;
- m_dvTV1 = dvTV1;
- m_dvTU2 = dvTU2;
- m_dvTV2 = dvTV2;
- }
- public:
- D3DVALUE m_dvX; // Homogeneous coordinates
- D3DVALUE m_dvY;
- D3DVALUE m_dvZ;
- D3DVALUE m_dvTU1; // 1st Texture coordinates
- D3DVALUE m_dvTV1;
- D3DVALUE m_dvTU2; // 2nd Texture coordinates
- D3DVALUE m_dvTV2;
- };
- // Define a custom vertex that uses XYZ, a color, and two sets of tex coords
- class CD3DUD2Vertex
- {
- public:
- enum
- {
- TypeDesc = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2
- };
- public:
- CD3DUD2Vertex(void)
- {
- }
- CD3DUD2Vertex(const D3DVECTOR& v,
- D3DCOLOR dcColor,
- D3DVALUE dvTU1, D3DVALUE dvTV1,
- D3DVALUE dvTU2, D3DVALUE dvTV2)
- {
- m_dvX = v.x;
- m_dvY = v.y;
- m_dvZ = v.z;
- m_dcColor = dcColor;
- m_dvTU1 = dvTU1;
- m_dvTV1 = dvTV1;
- m_dvTU2 = dvTU2;
- m_dvTV2 = dvTV2;
- }
- public:
- D3DVALUE m_dvX; // Homogeneous coordinates
- D3DVALUE m_dvY;
- D3DVALUE m_dvZ;
- D3DCOLOR m_dcColor;
- D3DVALUE m_dvTU1; // 1st Texture coordinates
- D3DVALUE m_dvTV1;
- D3DVALUE m_dvTU2; // 2nd Texture coordinates
- D3DVALUE m_dvTV2;
- };
- #pragma pack()
- #endif // _D3DVERTEX__H