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

📄 mdx.h

📁 暴风雪公司*.MPQ通用文件查看器源码,游戏,仅供娱乐
💻 H
字号:
/********************************************************************************
    Warcraft 3 Viewer - Utility to view models and textures from Warcraft 3
    Copyright (C) 2002  David GRIMBICHLER (theprophet@wanadoo.Fr)
	http://www.xeberon.net

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
********************************************************************************/

#ifndef _MDX_H_
#define _MDX_H_


extern BOOL gTextured;
extern BOOL gAllGeom;
extern char gDataDir[1024];

//
// we have to inverse the byte order, intel platform
//
#define TAG(x) (DWORD)(  (((DWORD)x&0x0000ff00)<<8)+(((DWORD)x&0x000000ff)<<24)+(((DWORD)x&0x00ff0000)>>8)+(((DWORD)x&0xff000000)>>24) )

void toregistre (LPCTSTR text, ...);
//
// 3-short vertex indexing Triangle 
//
struct Triangle
{
	short ind[3];
};

struct Layer1
{ 
	int		mLayerSize; // in Bytes
	int		mBlendMode;
	int		mUnk3;
	int		mTexture;
	int		mUnk5;
	int		mUnk6;
	float	mUnk7;		// alpha ?
	BOOL	mKMTA;
};


struct SequenceName
{
	char	mName[80];
	int		mUnk1;

	int		mUnk2;
	float	mUnk3;
	int		mUnk4;
	float	mUnk5;
	int		mUnk6;
	float	mUnk7;

	Vec3	mMins;
	Vec3	mMaxs;
};

struct Texture
{
	DWORD	mUnk1;
	char	mName[MAX_PATH]; // 260
	DWORD	mUnk2;
};


struct Camera
{
	char cName[80];
	float posx;
	float posy;
	float posz;
	float cFOV;
	float farClip;
	float nearClip;
	float targetx;
	float targety;
	float targetz;
};


//
// Auxiliary union TypePointer
//
// Used for better readability
//

union TypePointer1
{
	DWORD*		  dw;
	char*		  c;
	void*		  p;
	float*		  f;
	Vec3*		  v3;
	Vec2*		  v2;
	Triangle*	  tri;
	SequenceName* seq;
	Texture*	  tex;
	Camera*		  cam;

	TypePointer1(void* in) :p(in)
	{
	}
};


class mdxVersion
{
public:
	DWORD			mVersion;

					mdxVersion			(void) : mVersion(0) {	};
						
						
	void			Read				(TypePointer1 inP,int inSize);
	BOOL			IsValid				(void);
	void			Print				(void);
};

class mdxModel
{
public:
	char*			mName;
	char*			mName2;
	float			mUnk1;
	Vec3*			mMins;
	Vec3*			mMaxs;
	int				mUnk2;

	
					mdxModel			(void) : mName(NULL),mMins(NULL),mMaxs(NULL) { }
		
	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
	void			RenderBBox			(void);
};

class mdxGeoChunk
{
public:
	int				mNumVertices;
	Vec3*			mVertices;
	Vec3*			mNormals;

	int				mPolyCount;
	Triangle*		mTriangles;

	char*			mVertexGroupIndices;

	Vec2*			mUVs;

	int				mMaterial;
	int				mUnk2;
	int				mUnk3;

	float			mUnk4;
	Vec3*			mMins;
	Vec3*			mMaxs;

	int				mSomeCount;
	
					mdxGeoChunk			(void) : mNumVertices(0) { }

	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
	void			Render				(void);
};

class mdxGeometry
{
#define MAX_CHUNKS 32
public:
	int				mNumChunks;
	mdxGeoChunk		mChunks[MAX_CHUNKS];
	BOOL			mLoaded;

					mdxGeometry			(void) : mNumChunks(NULL),mLoaded(false)	{ }

	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
	void			Render				(void);
};

class mdxTextures
{
public:

	int				mNumTextures;
	Texture*		mTextures;
	BOOL			mLoaded;
	int				mGLBind[128];

					mdxTextures			(void) : mNumTextures(0),mLoaded(0) {}

	void			Read				(TypePointer1 inP,int inSize);

	void			Print				(void);
};

class mdxSequence
{
public:

	int				mNumSequences;
	SequenceName*	mSequences;
	BOOL			mLoaded;
	
					mdxSequence			(void) : mNumSequences(0),mLoaded(0) {}

	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
};

class mdxMaterial
{
#define MAX_LAYER 8
public:
	int				mUnk1;
	int				mUnk2;
	// 'LAYS'	
	int				mNumLayers;
	Layer1			mLayers[MAX_LAYER];

					mdxMaterial			(void) {}

	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
};

class mdxMaterialMap
{
#define MAX_MATERIALS 128
public:

	BOOL			mLoaded;
	int				mNumMaterials;
	mdxMaterial		mMaterials[MAX_MATERIALS];
	
					mdxMaterialMap		(void) : mLoaded(0) {}

	void			Read				(TypePointer1 inP,int inSize);
	void			Print				(void);
};


class mdxCameras
{
#define MAX_CAMERAS 32
public:
	int				mNumCameras;
	Camera			mCameras[MAX_CAMERAS];
	BOOL			mLoaded;

					mdxCameras			(void) : mNumCameras(NULL),mLoaded(false)	{ }

	void			Read				(TypePointer1 inP, int inSize);
//	void			Print				(void);
	void			Render				(void);
};



class WarCraft_ModelX
{
public:
	int				mSize;
	TypePointer1		mpData;

	BOOL			mLoaded;

	mdxCameras		mCameras;
	mdxVersion		mVersion;
	mdxModel		mModel;
	mdxGeometry		mGeometry;
	mdxSequence		mSequences;
	mdxTextures		mTextures;
	mdxMaterialMap	mMaterials;

					WarCraft_ModelX		(void);
					~WarCraft_ModelX	(void);

	void			Free				(void);

	void			Render				(void);
	void			Load				(char* inName);
};

#else
#error "mdx.h already included"
#endif//_MDX_H_

⌨️ 快捷键说明

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