[8342] | 1 | /*! |
---|
[8343] | 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 | */ |
---|
[8342] | 7 | |
---|
[8343] | 8 | #ifndef _MD3_MODEL_H |
---|
| 9 | #define _MD3_MODEL_H |
---|
[8342] | 10 | |
---|
[8343] | 11 | #include <string> |
---|
[8439] | 12 | #include "interactive_model.h" |
---|
[8342] | 13 | |
---|
| 14 | |
---|
[8724] | 15 | #define FRACTION 0.34f |
---|
| 16 | |
---|
| 17 | |
---|
[8351] | 18 | namespace md3 |
---|
| 19 | { |
---|
| 20 | |
---|
[8354] | 21 | |
---|
[8357] | 22 | class MD3Data; |
---|
[8724] | 23 | class MD3BoneFrame; |
---|
| 24 | class MD3Mesh; |
---|
| 25 | class MD3Tag; |
---|
| 26 | class MD3AnimationCfg; |
---|
| 27 | class MD3Animation; |
---|
[8357] | 28 | |
---|
[8724] | 29 | struct MD3Normal; |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | typedef enum MD3FrameHandling { |
---|
| 33 | MD3_ANIM_NEXT = 0, //!< swith to the next frame |
---|
| 34 | MD3_ANIM_PREVIOUS, //!< swith to the previous frame |
---|
| 35 | MD3_ANIM_REWIND //!< rewind the animation |
---|
| 36 | }; |
---|
| 37 | |
---|
| 38 | |
---|
[8439] | 39 | class MD3Model : public InteractiveModel |
---|
[8342] | 40 | { |
---|
| 41 | |
---|
[8343] | 42 | public: |
---|
[8353] | 43 | MD3Model(std::string filename, float scaling); |
---|
[8343] | 44 | ~MD3Model(); |
---|
[8342] | 45 | |
---|
[8439] | 46 | virtual void setAnimation(int animNum, int playbackMode = 0) {} |
---|
[8724] | 47 | virtual int getAnimation() { return 0;} |
---|
[8342] | 48 | |
---|
[8724] | 49 | virtual void tick(float dt); |
---|
| 50 | virtual void draw() const; |
---|
| 51 | |
---|
| 52 | |
---|
[8343] | 53 | private: |
---|
[8724] | 54 | |
---|
| 55 | void autoAssemblePlayerModel(std::string filename, float scaling); |
---|
| 56 | |
---|
| 57 | void draw(MD3Data* data) const; |
---|
| 58 | void tick(float dt, MD3Data* data); |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | void drawMesh(MD3Mesh* mesh, sVec3D* frame) const; |
---|
| 62 | void drawVertexNormals(sVec3D* frame, MD3Normal* normals) const; |
---|
| 63 | void drawBoneFrame(MD3BoneFrame* frame) const; |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | MD3BoneFrame* interpolateBoneFrame(MD3Data* data, MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac); |
---|
| 67 | sVec3D* interpolateMeshFrame(MD3Data* data, sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i); |
---|
| 68 | MD3Normal* interpolateVertexNormals(MD3Data* data, MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i); |
---|
| 69 | float* interpolateTransformation(MD3Data* data, MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i); |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | void interpolate(MD3Data* data, MD3Animation* anim, int op, bool bInterpolate); |
---|
| 73 | |
---|
| 74 | void visit(MD3Data* data, float time); |
---|
| 75 | int next(MD3Data* data, int nr); |
---|
| 76 | int prev(MD3Data* data, int nr); |
---|
| 77 | void doOp(MD3Data* data, float time); |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | private: |
---|
[8354] | 81 | MD3Data* md3Data; //!< reference to the md3 model data |
---|
[8724] | 82 | |
---|
| 83 | bool bDrawBones; //!< draws the bone frames too |
---|
| 84 | bool bDrawNormals; //!< draw the normals |
---|
| 85 | |
---|
| 86 | MD3AnimationCfg* config; //!< the config file parsed |
---|
| 87 | |
---|
| 88 | float time; |
---|
| 89 | |
---|
[8357] | 90 | }; |
---|
[8354] | 91 | |
---|
[8724] | 92 | |
---|
[8351] | 93 | } |
---|
[8342] | 94 | |
---|
[8343] | 95 | #endif /* _MD3_MODEL_H */ |
---|