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

📄 model.h

📁 3D数学基础:图形与游戏开发书籍源码,里面有很多实用的代码,对做3D的同志很有意义
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
//
// 3D Math Primer for Games and Graphics Development
//
// Model.h - Model used for rendering
//
// Visit gamemath.com for the latest version of this file.
//
/////////////////////////////////////////////////////////////////////////////

#ifndef __MODEL_H_INCLUDED__
#define __MODEL_H_INCLUDED__

// Forward declarations

class EditTriMesh;
class TriMesh;
struct TextureReference;

/////////////////////////////////////////////////////////////////////////////
//
// class Model
//
// Renderable model class.  This class constists of a list of "parts."
// Each part is a triangle mesh and can have its own texture.
//
/////////////////////////////////////////////////////////////////////////////

class Model {
public:
	Model();
	~Model();

	// Memory allocation

	void	allocateMemory(int nPartCount);
	void	freeMemory();

	// Part accessors

	int	getPartCount() const { return partCount; }
	TriMesh	*getPartMesh(int index);

	// Texture accessors

	TextureReference	*getPartTexture(int index);
	void			setPartTextureName(int index, const char *name);

	// Cache textures.  For best performance, always cache your textures
	// before rendering

	void	cache() const;

	// Render the entire model, or a single part.  This will use
	// the current 3D context.  The current texture will be changed.

	void	render() const;
	void	renderPart(int index) const;

	// Conversion to/from an "edit" mesh

	void	fromEditMesh(EditTriMesh &mesh);
	void	toEditMesh(EditTriMesh &mesh) const;

	// Shorthand for importing an S3D.  (Uses EditTriMesh)

	void	importS3d(const char *s3dFilename);

protected:

	// Parts and textures

	int			partCount;
	TriMesh			*partMeshList;
	TextureReference	*partTextureList;
};

/////////////////////////////////////////////////////////////////////////////
#endif // #ifndef __MODEL_H_INCLUDED__

⌨️ 快捷键说明

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