解决方案 »
- CHeaderCtrl如何固定表头
- 如何安全删除IOCP里的overlap对象
- 想HookADO中的DllGetClassObject方法,以监视应用程序使用ADO进行的数据库连接,可行么?
- 一个简单的小问题,关于中文字符的
- exe与dll的参数传递?
- 【串口】如何检测串口设备意外断开的事件?
- 怎么设定CSplitterWnd分割后滑杆的范围
- extern "C" declspec(dllexport) bool _stdcall mypro()为什么调用时成了_mypro@8
- Unicode 到 ANSI 的转换问题?
- 有熟悉BCG组件的兄弟?
- 300分求源程序,急
- 在C标准库或是MFC库里有一些算法的模版吗?
/*
BMF : The Basic Model Format for 3DS Polygonal Model
*/#ifndef _3DS_BMF_H_
#define _3DS_BMF_H_typedef short word; //16-bit
typedef unsigned short int uword; //16-bit
typedef int dword; //32-bit
typedef float float32; //32-bit float /*
* Untransformed with Normal Vertex
* Corresponds to OpenGL's GL_T2F_N3F_V3F format
*/typedef struct {
float32 u, v;
float32 i, j, k;
float32 x, y, z;
} BMF_UNVERTEX;typedef struct {
float32 x, y, z, w;
} T_VERTEX;typedef struct {
float32 i, j, k;
} T_NORMAL;/*
* RGB Color
*/typedef struct {
float32 red, green, blue, alpha;
} BMF_RGBCOLOR;/*
* Surface of three indexes into a vertex list; this is a triangle
*/typedef struct {
uword p0, p1, p2;
} BMF_SURFACE;/*
* The texture name length includes the terminating 0, so it is
* always at least one. The texture name is a string terminated
* with a 0. If it is empty (ie, no texture), then it is simply
* a 0.
*
* The ambient, diffuse, and specular red, green, and blue
* components are exactly that.
*
* The number of vertices is the size of the vertex list array.
* The vertex list is an array of UNVERTEX, or an Untransformed with
* Normal Vertex.
* The vertex list is local to this particular material.
*
*/typedef struct {
uword texture_name_length;
byte *texture_name;
BMF_RGBCOLOR ambient;
BMF_RGBCOLOR diffuse;
BMF_RGBCOLOR specular;
uword number_of_vertices;
BMF_UNVERTEX *vertexlist;
short number_of_triangles;
BMF_SURFACE *indexlist;
} SparseMesh;typedef struct {
uword texture_name_length;
byte *texture_name;
BMF_RGBCOLOR ambient;
BMF_RGBCOLOR diffuse;
BMF_RGBCOLOR specular;
uword number_of_vertices;
BMF_UNVERTEX *vertexlist;
uword number_of_strips;
uword *length_of_strip;
uword number_of_strip_indices;
uword *stripindex;
} StripMesh;/*
* This is the actual BMF object. NumMaterials is the size of the
* mesh array. The mesh array is either sparse, or strip. One will be
* a null pointer and the other will be a real pointer to the data.
* Thus, if BMFObject->strip == 0, then BMFObject->sparse is an array
* of SparseMesh elements.
*/
typedef struct {
uword NumMaterials;
SparseMesh *sparse;
StripMesh *strip;
} BMFObject;BMFObject* LoadBMFObject(char *file);
void UnitizeBMFObject(BMFObject *object);
void DrawBMFObject(BMFObject *object);
void FreeBMFObject(BMFObject *object);
void GetMinMaxBMF(float min[3], float max[3], float *scaleFactor);
#endif
#define MODEL_3DSBMF_H#include "Layer2\Model3DS-BMF\3dsbmf.h" // 3DS BMF Modelclass AFX_EXT_CLASS Model3DSBMF : public GraphicalObject
//class Model3DSBMF : public GraphicalObject
{
public:
Model3DSBMF(void);
~Model3DSBMF(void); // ¶Á 3DS µÄ .bmf Ä£ÐÍ
BOOL LoadModel(char *strFile); // »æÖÆģʽ SOLID, WIRE
void SetDrawMode(int mode); // ²ÄÖ浀 Emissive ·ÖÁ¿
void SetEmissive(float emissive[3]);
// ²ÄÖ浀 Shininess ·ÖÁ¿, shininess = [0,128]
void SetShininess(float shininess=0); // »æÖÆ
virtual void Draw(void); // »ñÈ¡¶ÔÏóµÄ×îС×ø±êÖµ(minx,miny,minz)Óë×î´ó×ø±êÖµ(maxx, maxy, maxz)
virtual void GetMinMax( float *minx, float *miny, float *minz,
float *maxx, float *maxy, float *maxz); // »ñÈ¡¶ÔÏóµÄ°üΧÇò£¬(cx,cy,cz) ΪÖÐÐÄ×ø±ê£¬radius Ϊ°ë¾¶
virtual void GetBoundSphere(float *radius, float *cx, float *cy, float *cz);
// »ñÈ¡¶ÔÏóµÄ°üΧºÐ£¬(cx,cy,cz) ΪÖÐÐÄ×ø±ê£¬
virtual void GetBoundBox(float *dx, float *dy, float *dz,
float *cx, float *cy, float *cz);protected: GLuint m_uDisplayList; // ÏÔʾÁбí
BOOL m_bStateChanged;// Êý¾Ý¸Ä±äµÄ±êÖ¾
BMFObject * m_pModel; // BMF Object int m_iDrawMode; // »æÖÆģʽ (SOLID, WIRE)
float m_fMinXYZ[3]; // ×îСֵ
float m_fMaxXYZ[3]; // ×î´óÖµ
float m_fScaleFactor; // Ä£ÐÍËõСµÄ±ÈÀý
float m_fEmissive[3]; // ²ÄÖ浀 Emissive ·ÖÁ¿
float m_fShininess; // ²ÄÖ浀 Shininess ·ÖÁ¿, shininess = [0,128]
};#endif
2:2:Model3DSBMF.h
#if !defined (MODEL_3DSBMF_H)
#define MODEL_3DSBMF_H#include "Layer2\Model3DS-BMF\3dsbmf.h" // 3DS BMF Modelclass AFX_EXT_CLASS Model3DSBMF : public GraphicalObject
//class Model3DSBMF : public GraphicalObject
{
public:
Model3DSBMF(void);
~Model3DSBMF(void); // READ 3DS
BOOL LoadModel(char *strFile);
E
void SetDrawMode(int mode);
void SetEmissive(float emissive[3]);
void SetShininess(float shininess=0);
virtual void Draw(void);
virtual void GetMinMax( float *minx, float *miny, float *minz,
float *maxx, float *maxy, float *maxz);
virtual void GetBoundSphere(float *radius, float *cx, float *cy, float *cz);
virtual void GetBoundBox(float *dx, float *dy, float *dz,
float *cx, float *cy, float *cz);protected: GLuint m_uDisplayList;
BOOL m_bStateChanged;
BMFObject * m_pModel; int m_iDrawMode;
float m_fMinXYZ[3];
float m_fMaxXYZ[3];
float m_fScaleFactor;
float m_fEmissive[3];
float m_fShininess;
};#endif