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

📄 cuboid.h

📁 DirectX 8 教程 第六章 源码下载:可运行
💻 H
字号:
// Cuboid.h: interface for the CCuboid class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_)
#define AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_

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

#include <d3dx8.h>
#include "Helper.h"


//Define a FVF for our cubiods
//定义立方体的灵活顶点格式
#define CUBIOD_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

class CCuboid  
{
public:
	bool SetTexture(const char* szTextureFilePath);
	bool SetPosition(float x, float y, float z);
	bool SetSize(float rWidth, float rHeight, float rDepth);
	bool Render();
	CCuboid(LPDIRECT3DDEVICE8 pD3DDevice);
	virtual ~CCuboid();

private:
	bool UpdateVertices();
	HRESULT CreateVertexBuffer();
	LPDIRECT3DDEVICE8 m_pD3DDevice;
	LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
	LPDIRECT3DTEXTURE8 m_pTexture;

	float m_rWidth;
	float m_rHeight;
	float m_rDepth;
	float m_rX;
	float m_rY;
	float m_rZ;

	//Define a custom vertex for our cubiods
	//定义立方体的自定义顶点格式
	struct CUBIOD_CUSTOMVERTEX
	{
		FLOAT x, y, z;		//Position of vertex in 3D space  空间坐标
		DWORD colour;		//Colour of vertex     顶点颜色
		FLOAT tu, tv;		//Texture coordinates  纹理坐标
	};
};

#endif // !defined(AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_)

⌨️ 快捷键说明

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