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

📄 maxmesh.h

📁 liu7788414
💻 H
字号:
// MaxMesh.h: interface for the CMaxMesh class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAXMESH_H__CC797406_441B_4EB6_AE38_3D4C1CF9B09A__INCLUDED_)
#define AFX_MAXMESH_H__CC797406_441B_4EB6_AE38_3D4C1CF9B09A__INCLUDED_

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

#include "Max.h"
#include "resource.h"
#include "istdplug.h"
#include "iparamb2.h"
#include "iparamm2.h"
#include <assert.h>
#include <io.h>
#include <commdlg.h>
#include "stdmat.h"

#include <fstream>
#include <vector>
#include <list>
#include <map>
#include "IGame.h"
#include "Moddata.h"

using namespace std;
//data getted directly from 3dmax5

struct BoneInfo
{
	int boneIndex;
	float weight;
};

struct Vector3f
{
	float x, y, z;
};

struct MaxVertex
{
	float x, y, z;
	float n1, n2, n3;
	Vector3f *FrameVertics;
	vector<BoneInfo> boneInfo;
	MaxVertex() 
	{
		FrameVertics = NULL;
	}
};

struct MaxFace
{
	int v1, v2, v3; //vertex index
	int t1, t2, t3; //texture coodinate index
	int matid;      //matirial index
	Point3 normal;
};

struct MaxTexCoord
{
	float u, v;
};

struct MaxMatrial
{
	MaxMatrial() {strcpy(texName, "");	bUseTexture = TRUE;}
	char texName[200];
	bool bUseTexture; //true: use texture false: use color. In our engine, it didn't support color
};

struct FrameTransform
{	
	int frameNo;
	float p1, p2, p3; //position
	float r1, r2, r3; //rotation

	//matrix data is ok
	Matrix3 mat;
};

struct MaxBone
{
	char name[50];
	vector<FrameTransform> m_transList; //bone's key frame trans
	int boneIndex;
	FrameTransform trans; //bones initial trans
	bool bUse;
};

struct MaxSubMesh
{	
	vector<MaxVertex> Vertics;
	vector<MaxFace> Faces;
	vector<MaxTexCoord> TexCoord;	
	vector<MaxMatrial> Mtrl;
};

class CMaxMesh  
{
public:
	int FindBoneIndex(int BoneID, vector<Bone> &bones);
	void GetBones();
	void MergeSubmesh();
	void AddSubMeshData(Mesh *pMesh, Mtl *pMtl, INode *pNode, IGameNode *pGameNode);
	void AddAnimationData(MaxSubMesh *pSubMesh, IGameNode *pGameNode);
	void ConvertToOurMesh(CMesh *pMesh);
	void ExportMaxMesh(const char * fileName);
	CMaxMesh();
	virtual ~CMaxMesh();

	int m_numVertics;
	int m_numFaces;
	int m_numTexCoords;

	vector<MaxVertex> m_Vertics;
	vector<MaxFace> m_Faces;
	vector<MaxTexCoord> m_TexCoord;

	int m_numMatrials;
	vector<MaxMatrial> m_Matrials;

	map<int, MaxBone> m_Bones;

	int m_FameCount;
	int m_startTime;
	int m_endTime;
	int m_interval;

	vector<MaxSubMesh> m_meshs;
	IGameScene *m_pScene;
protected:
	int AddMatrial(Mtl *pMtl, vector<MaxMatrial> *pMtrlList);
	void RetrieveInverseMatrices(IGameNode * node);	
	void AddBone(IGameNode * node);
	void make_face_uv(Face *f, Point3 *tv);

};


// ================================================== FindTextureFileName
// callback called by 3DSMAX
class FindTextureFilename : public NameEnumCallback
{
public:
	FindTextureFilename()
		:m_szTextureName(NULL) {}
	
	virtual void RecordName(TCHAR *szName)
	{
		m_szTextureName = szName;
	}
	
	TCHAR *m_szTextureName;    
};


#endif // !defined(AFX_MAXMESH_H__CC797406_441B_4EB6_AE38_3D4C1CF9B09A__INCLUDED_)

⌨️ 快捷键说明

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