trimesh.h

来自「3D赛车游戏源代码-用Visual Studio 2005」· C头文件 代码 · 共 54 行

H
54
字号
//////////////////////////////////////////////////////////////////////////
//  TriMesh类,实现一个通用的三角形网孔
//
//  TriMesh.h: TriMesh类的声明
//
//////////////////////////////////////////////////////////////////////////

#ifndef __TRIMESH_H_INCLUDED__
#define __TRIMESH_H_INCLUDED__

#include "AABB3.h"

struct RenderVertex;
struct RenderTri;

//-------------------------------------------------------------------------------
// 三角形网孔
//-------------------------------------------------------------------------------
class TriMesh 
{
public:
	// 构造析构函数
	TriMesh();
	~TriMesh();

	// 存储管理
	void	AllocateMemory(int nVertexCount, int nTriCount);
	void	FreeMemory();

	// 网孔数据访问
	int		GetVertexCount() const { return m_vertexCount; }
	RenderVertex	*GetVertexList() const { return m_vertexList; }
	int		GetTriCount() const { return m_triCount; }
	RenderTri	*GetTriList() const { return m_triList; }

	// 渲染
	void	Render() const;

	// 计算轴对齐盒子,改了网孔数据后要调用本函数
	void		ComputeBoundingBox();
	// 获取轴对齐盒子
	const AABB3	&GetBoundingBox() const { return m_boundingBox; }

protected:
	int				m_vertexCount;		// 顶点数量
	RenderVertex	*m_vertexList;		// 顶点列表
	int				m_triCount;			// 三角形数量
	RenderTri		*m_triList;			// 三角形列表
	AABB3			m_boundingBox;		// 轴对齐盒子
};



#endif

⌨️ 快捷键说明

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