2004-05-29 22:56:24 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Name: ModelDef.h
|
|
|
|
// Author: Rich Cross
|
|
|
|
// Contact: rich@wildfiregames.com
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _MODELDEF_H
|
|
|
|
#define _MODELDEF_H
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
#include "CStr.h"
|
2004-05-29 22:56:24 +02:00
|
|
|
#include "Vector3D.h"
|
|
|
|
#include "SkeletonAnimDef.h"
|
2004-06-28 17:34:10 +02:00
|
|
|
#include <vector>
|
2004-05-29 22:56:24 +02:00
|
|
|
|
2004-11-08 23:02:01 +01:00
|
|
|
class CMeshManager;
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SPropPoint: structure describing a prop point
|
|
|
|
struct SPropPoint
|
|
|
|
{
|
|
|
|
// name of the prop point
|
|
|
|
CStr m_Name;
|
|
|
|
// position of the point
|
|
|
|
CVector3D m_Position;
|
|
|
|
// rotation of the point
|
|
|
|
CQuaternion m_Rotation;
|
|
|
|
// object to parent space transformation
|
|
|
|
CMatrix3D m_Transform;
|
|
|
|
// index of parent bone; 0xff if unboned
|
|
|
|
u8 m_BoneIndex;
|
|
|
|
};
|
2004-05-29 22:56:24 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SVertexBlend: structure containing the necessary data for blending vertices
|
|
|
|
// with multiple bones
|
|
|
|
struct SVertexBlend
|
|
|
|
{
|
|
|
|
enum { SIZE = 4 };
|
|
|
|
// index of the influencing bone, or 0xff if none
|
|
|
|
u8 m_Bone[SIZE];
|
|
|
|
// weight of the influence; all weights sum to 1
|
|
|
|
float m_Weight[SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SModelVertex: structure containing per-vertex data
|
|
|
|
struct SModelVertex
|
|
|
|
{
|
|
|
|
// vertex position
|
|
|
|
CVector3D m_Coords;
|
|
|
|
// vertex normal
|
|
|
|
CVector3D m_Norm;
|
|
|
|
// vertex UVs
|
|
|
|
float m_U, m_V;
|
|
|
|
// vertex blend data
|
|
|
|
SVertexBlend m_Blend;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SModelFace: structure containing per-face data
|
|
|
|
struct SModelFace
|
|
|
|
{
|
|
|
|
// indices of the 3 vertices on this face
|
|
|
|
u16 m_Verts[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CModelDef: a raw 3D model; describes the vertices, faces, skinning and skeletal
|
|
|
|
// information of a model
|
|
|
|
class CModelDef
|
|
|
|
{
|
2004-11-08 23:02:01 +01:00
|
|
|
friend class CMeshManager;
|
2004-05-29 22:56:24 +02:00
|
|
|
public:
|
|
|
|
// current file version given to saved animations
|
|
|
|
enum { FILE_VERSION = 2 };
|
|
|
|
// supported file read version - files with a version less than this will be rejected
|
|
|
|
enum { FILE_READ_VERSION = 1 };
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
CModelDef();
|
|
|
|
// destructor
|
|
|
|
virtual ~CModelDef();
|
|
|
|
|
|
|
|
// model I/O functions
|
|
|
|
static void Save(const char* filename,const CModelDef* mdef);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// accessor: get vertex data
|
|
|
|
int GetNumVertices() const { return m_NumVertices; }
|
2004-10-06 20:45:59 +02:00
|
|
|
SModelVertex* GetVertices() const { return m_pVertices; }
|
2004-05-29 22:56:24 +02:00
|
|
|
|
|
|
|
// accessor: get face data
|
|
|
|
int GetNumFaces() const { return m_NumFaces; }
|
2004-10-06 20:45:59 +02:00
|
|
|
SModelFace* GetFaces() const { return m_pFaces; }
|
2004-05-29 22:56:24 +02:00
|
|
|
|
|
|
|
// accessor: get bone data
|
|
|
|
int GetNumBones() const { return m_NumBones; }
|
2004-10-06 20:45:59 +02:00
|
|
|
CBoneState* GetBones() const { return m_Bones; }
|
|
|
|
|
|
|
|
|
|
|
|
// accessor: get prop data
|
|
|
|
int GetNumPropPoints() const { return m_NumPropPoints; }
|
|
|
|
SPropPoint* GetPropPoints() const { return m_PropPoints; }
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// find and return pointer to prop point matching given name; return
|
|
|
|
// null if no match (case insensitive search)
|
|
|
|
SPropPoint* FindPropPoint(const char* name) const;
|
2004-05-29 22:56:24 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
// vertex data
|
|
|
|
u32 m_NumVertices;
|
|
|
|
SModelVertex* m_pVertices;
|
|
|
|
// face data
|
|
|
|
u32 m_NumFaces;
|
|
|
|
SModelFace* m_pFaces;
|
|
|
|
// bone data - default model pose
|
|
|
|
u32 m_NumBones;
|
2004-05-30 02:46:58 +02:00
|
|
|
CBoneState* m_Bones;
|
|
|
|
// prop point data
|
|
|
|
u32 m_NumPropPoints;
|
2004-05-29 22:56:24 +02:00
|
|
|
SPropPoint* m_PropPoints;
|
2004-12-12 20:43:55 +01:00
|
|
|
|
2004-11-08 23:02:01 +01:00
|
|
|
protected:
|
2004-12-12 20:43:55 +01:00
|
|
|
static CModelDef* Load(const char* filename);
|
2004-05-29 22:56:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|