⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3dstruct.h

📁 俄罗斯方块3D 程序+源码俄罗斯方块3D(程序+源码
💻 H
字号:
#ifndef _3dStruct_h
#define _3dStruct_h

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <d3d9.h>
#include <d3dx9math.h>

const int COORDVERTEX_FVF = ( D3DFVF_XYZ | D3DFVF_DIFFUSE );
const int BASEVERTEX_FVF = D3DFVF_XYZB1 | D3DFVF_NORMAL | D3DFVF_TEX1;
const int VERTEX_FVF	= D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;


/////////////////////////////////////////////////////////////////////
//坐标轴和包围盒的顶点结构,包含坐标和颜色
/////////////////////////////////////////////////////////////////////
struct COORDVERTEX
{
	union { 
		D3DVECTOR p;
		struct { 
			float x, y, z;
		};
	};
	D3DCOLOR color;
};

///////////////////////////////////////////////////////
//普通网格属性索引结构,包括材质索引,纹理索引
///////////////////////////////////////////////////////
struct ATTRIBUTEINDEX
{
	int iMaterialIndex;
	int iTextureIndex;
	int iBoneId;
	int iConnectedBoneId;

public:
	bool operator==( ATTRIBUTEINDEX &a )
	{ return ( (iBoneId == a.iBoneId) && (iConnectedBoneId == a.iConnectedBoneId) ); }
};

////////////////////////////////////////////////////////////////////
//顶点格式,用于多边体,网格
////////////////////////////////////////////////////////////////////
struct BASEVERTEX
{
	union { 
		D3DVECTOR p;
		struct { 
			float x, y, z;
		};
	};
	float weight1;			//顶点权重

	union {
		D3DVECTOR n;
		struct {
			float nx, ny, nz;	//法向量
		};
	};
	
	float u, v;
};

struct VERTEX
{
	union { 
		D3DVECTOR p;
		struct { 
			float x, y, z;
		};
	};

	union {
		D3DVECTOR n;
		struct {
			float nx, ny, nz;	//法向量
		};
	};
	
	float u, v;
};

//////////////////////////////////////////////////////////////////
//骨骼顶点(只有一个权重)的定义
//////////////////////////////////////////////////////////////////
/*struct BONEVERTEX1
{
	union { 
		D3DVECTOR p;
		struct { 
			float x, y, z;	//坐标
		};
	};
	float weight1;			//顶点权重
    //DWORD matrixIndices;	//矩阵索引

	union {
		D3DVECTOR n;
		struct {
			float nx, ny, nz;	//法向量
		};
	};		
	float u, v;				//纹理
};*/

/////////////////////////////////////////////////////////////////////////
//三角形的边
/////////////////////////////////////////////////////////////////////////
struct EDGE
{
	WORD v1;
	WORD v2;
};

/////////////////////////////////////////////////////////////////////////
//三角形的边
/////////////////////////////////////////////////////////////////////////
struct TRIANGLE
{
	union {
		struct {
			WORD v1, v2, v3;
		};
		WORD v[3];
	};

public:
	bool operator ==( TRIANGLE &t ) { return ( (t.v1 == v1) && (t.v2 == v2) && (t.v3 == v3) ); }
};

//////////////////////////////////////////////////////////////////////////
//向量的结构
//////////////////////////////////////////////////////////////////////////
struct VECTOR {
    union {
		struct {
			float x, y, z;
		};
		float v[3];
	};

public:
	VECTOR() {}
	VECTOR( D3DXVECTOR3 &v ) { x = v.x; y = v.y; z = v.z;}
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -