1 | /*! |
---|
2 | * @file md3_model.h |
---|
3 | * |
---|
4 | * Code heavely inspired by: JAVA MD3 Model Viewer - A Java based Quake 3 model viewer |
---|
5 | * Copyright (C) 1999 Erwin 'KLR8' Vervaet |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef _MD3_MODEL_H |
---|
9 | #define _MD3_MODEL_H |
---|
10 | |
---|
11 | #include <string> |
---|
12 | #include "interactive_model.h" |
---|
13 | |
---|
14 | |
---|
15 | namespace md3 |
---|
16 | { |
---|
17 | |
---|
18 | |
---|
19 | class MD3Data; |
---|
20 | class MD3BoneFrame; |
---|
21 | class MD3Mesh; |
---|
22 | class MD3Tag; |
---|
23 | class MD3AnimationCfg; |
---|
24 | |
---|
25 | struct MD3Normal; |
---|
26 | |
---|
27 | |
---|
28 | class MD3Model : public InteractiveModel |
---|
29 | { |
---|
30 | |
---|
31 | public: |
---|
32 | MD3Model(std::string filename, float scaling); |
---|
33 | ~MD3Model(); |
---|
34 | |
---|
35 | virtual void setAnimation(int animNum, int playbackMode = 0) {} |
---|
36 | |
---|
37 | virtual void tick(float dt); |
---|
38 | virtual void draw() const; |
---|
39 | |
---|
40 | |
---|
41 | private: |
---|
42 | |
---|
43 | void autoAssemblePlayerModel(std::string filename, float scaling); |
---|
44 | |
---|
45 | void draw(MD3Data* data) const; |
---|
46 | void tick(float dt, MD3Data* data); |
---|
47 | |
---|
48 | void drawMesh(MD3Mesh* mesh, sVec3D* frame) const; |
---|
49 | void drawVertexNormals(sVec3D* frame, MD3Normal* normals) const; |
---|
50 | void drawBoneFrame(MD3BoneFrame* frame) const; |
---|
51 | |
---|
52 | MD3BoneFrame* interpolateBoneFrame(MD3Data* data, MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac); |
---|
53 | sVec3D* interpolateMeshFrame(MD3Data* data, sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i); |
---|
54 | MD3Normal* interpolateVertexNormals(MD3Data* data, MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i); |
---|
55 | float* interpolateTransformation(MD3Data* data, MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i); |
---|
56 | |
---|
57 | private: |
---|
58 | MD3Data* md3Data; //!< reference to the md3 model data |
---|
59 | |
---|
60 | bool bDrawBones; //!< draws the bone frames too |
---|
61 | bool bDrawNormals; //!< draw the normals |
---|
62 | |
---|
63 | MD3AnimationCfg* config; //!< the config file parsed |
---|
64 | |
---|
65 | |
---|
66 | }; |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | #endif /* _MD3_MODEL_H */ |
---|