www.pudn.com > Gimcrack-v0.0051-Source.zip > ms3dformat.h


#ifndef _MS3DFORMAT_H_ 
#define _MS3DFORMAT_H_ 
 
#include "../texture.h" 
#include "../math/vector.h" 
#include "../math/matrix.h" 
 
struct Material 
{ 
	char m_name[32]; 
	float m_ambient[4], m_diffuse[4], m_specular[4], m_emissive[4]; 
	float m_shininess; 
	GcTexture texture; 
	char m_textureFilename[256]; 
	char m_alphamapFilename[256]; 
}; 
 
struct Triangle 
{ 
	//GcVector3 m_Normal; 
	float m_normal[3]; 
	int m_vertexIndices[3];			// FIXME: UGLY AND DUMB! REMOVE AS SOON AS POSSIBLE! 
	float m_vertexNormals[3][3];	// UGLY AND DUMB! REMOVE AS SOON AS POSSIBLE! 
	float m_s[3], m_t[3];			// UGLY AND DUMB! REMOVE AS SOON AS POSSIBLE! 
}; 
 
struct Vertex 
{ 
	char m_boneID;	// For skeleton 
	//GcVector3 m_location; 
	float m_location[3]; 
	GcVector3 m_normal; 
	float m_u, m_v; 
 
}; 
 
struct Mesh 
{ 
	char m_name[32]; 
 
	int m_materialIndex; 
 
	int m_numVertices; 
	Vertex * m_vertices; 
 
	int m_numTriangles; 
	int * m_triangleIndices; 
}; 
 
struct Keyframe 
{ 
	int m_jointIndex; 
	float m_time;			// in milliseconds 
	float m_parameter[3]; 
}; 
 
 
struct Joint 
{ 
	GcVector3 m_localRotation; 
	GcVector3 m_localTranslation; 
	GcMatrix4 m_absolute, m_relative; 
 
	int m_numRotationKeyframes, m_numTranslationKeyframes; 
	Keyframe * m_translationKeyframes; 
	Keyframe * m_rotationKeyframes; 
 
	int m_currentTranslationKeyframe, m_currentRotationKeyframe; 
	GcMatrix4 m_final; 
 
	int m_parent; 
}; 
 
/*  
	MS3D STRUCTURES  
*/ 
 
#define PATH_MAX _MAX_PATH 
// byte-align structures 
/*#if defined( _MSC_VER ) || defined( __BORLANDC__ ) 
#	include  
#	define PACK_STRUCT 
#	 
#elif defined( __GNUC__ ) 
#	define PACK_STRUCT	__attribute__((packed)) 
#	include  
#else 
#	error you must byte-align these structures with the appropriate compiler directives 
#endif*/ 
 
#pragma pack(push, 1) 
 
typedef unsigned char byte; 
typedef unsigned short word; 
 
// File header 
struct MS3DHeader 
{ 
	char m_ID[10]; 
	int m_version; 
}; 
 
// Vertex information 
struct MS3DVertex 
{ 
	byte m_flags; 
	float m_vertex[3]; 
	char m_boneID; 
	byte m_refCount; 
}; 
 
// Triangle information 
struct MS3DTriangle 
{ 
	word m_flags; 
	word m_vertexIndices[3]; 
	float m_vertexNormals[3][3]; 
	float m_s[3], m_t[3]; 
	byte m_smoothingGroup; 
	byte m_groupIndex; 
}; 
 
// Material information 
struct MS3DMaterial 
{ 
    char m_name[32]; 
    float m_ambient[4]; 
    float m_diffuse[4]; 
    float m_specular[4]; 
    float m_emissive[4]; 
    float m_shininess;		// 0.0f - 128.0f 
    float m_transparency;	// 0.0f - 1.0f 
    byte m_mode;			// 0, 1, 2 is unused now 
    char m_texture[128]; 
    char m_alphamap[128]; 
}; 
 
//	Joint information 
struct MS3DJoint 
{ 
	byte m_flags; 
	char m_name[32]; 
	char m_parentName[32]; 
	float m_rotation[3]; 
	float m_translation[3]; 
	word m_numRotationKeyframes; 
	word m_numTranslationKeyframes; 
}; 
 
// Keyframe data 
struct MS3DKeyframe 
{ 
	float m_time; 
	float m_parameter[3]; 
}; 
 
// Default alignment 
 
#pragma pack(pop) 
 
#endif