model.h
来自「3D数学基础:图形与游戏开发书籍源码,里面有很多实用的代码,对做3D的同志很有意」· C头文件 代码 · 共 80 行
H
80 行
/////////////////////////////////////////////////////////////////////////////
//
// 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 + =
减小字号Ctrl + -
显示快捷键?