diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD3.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD3.h b/libraries/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD3.h new file mode 100644 index 0000000..1b01eee --- /dev/null +++ b/libraries/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD3.h | |||
@@ -0,0 +1,135 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #ifndef __C_ANIMATED_MESH_MD3_H_INCLUDED__ | ||
6 | #define __C_ANIMATED_MESH_MD3_H_INCLUDED__ | ||
7 | |||
8 | #include "IAnimatedMeshMD3.h" | ||
9 | #include "IReadFile.h" | ||
10 | #include "IFileSystem.h" | ||
11 | #include "irrArray.h" | ||
12 | #include "irrString.h" | ||
13 | #include "SMesh.h" | ||
14 | #include "SMeshBuffer.h" | ||
15 | #include "IQ3Shader.h" | ||
16 | |||
17 | namespace irr | ||
18 | { | ||
19 | namespace scene | ||
20 | { | ||
21 | |||
22 | class CAnimatedMeshMD3 : public IAnimatedMeshMD3 | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | //! constructor | ||
27 | CAnimatedMeshMD3(); | ||
28 | |||
29 | //! destructor | ||
30 | virtual ~CAnimatedMeshMD3(); | ||
31 | |||
32 | //! loads a quake3 md3 file | ||
33 | virtual bool loadModelFile(u32 modelIndex, io::IReadFile* file, | ||
34 | io::IFileSystem* fs, video::IVideoDriver* driver); | ||
35 | |||
36 | // IAnimatedMeshMD3 | ||
37 | virtual void setInterpolationShift(u32 shift, u32 loopMode); | ||
38 | virtual SMD3Mesh* getOriginalMesh(); | ||
39 | virtual SMD3QuaternionTagList* getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); | ||
40 | |||
41 | //IAnimatedMesh | ||
42 | virtual u32 getFrameCount() const; | ||
43 | |||
44 | //! Gets the default animation speed of the animated mesh. | ||
45 | /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ | ||
46 | virtual f32 getAnimationSpeed() const | ||
47 | { | ||
48 | return FramesPerSecond; | ||
49 | } | ||
50 | |||
51 | //! Gets the frame count of the animated mesh. | ||
52 | /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. | ||
53 | The actual speed is set in the scene node the mesh is instantiated in.*/ | ||
54 | virtual void setAnimationSpeed(f32 fps) | ||
55 | { | ||
56 | FramesPerSecond=fps; | ||
57 | } | ||
58 | |||
59 | virtual IMesh* getMesh(s32 frame, s32 detailLevel, | ||
60 | s32 startFrameLoop, s32 endFrameLoop); | ||
61 | virtual const core::aabbox3d<f32>& getBoundingBox() const; | ||
62 | virtual E_ANIMATED_MESH_TYPE getMeshType() const; | ||
63 | |||
64 | //! returns amount of mesh buffers. | ||
65 | virtual u32 getMeshBufferCount() const; | ||
66 | |||
67 | //! returns pointer to a mesh buffer | ||
68 | virtual IMeshBuffer* getMeshBuffer(u32 nr) const; | ||
69 | |||
70 | //! Returns pointer to a mesh buffer which fits a material | ||
71 | virtual IMeshBuffer* getMeshBuffer(const video::SMaterial &material) const; | ||
72 | |||
73 | virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); | ||
74 | |||
75 | //! set user axis aligned bounding box | ||
76 | virtual void setBoundingBox(const core::aabbox3df& box); | ||
77 | |||
78 | //! set the hardware mapping hint, for driver | ||
79 | virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); | ||
80 | |||
81 | //! flags the meshbuffer as changed, reloads hardware buffers | ||
82 | virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); | ||
83 | |||
84 | private: | ||
85 | //! animates one frame | ||
86 | inline void Animate(u32 frame); | ||
87 | |||
88 | video::SMaterial Material; | ||
89 | |||
90 | //! hold original compressed MD3 Info | ||
91 | SMD3Mesh *Mesh; | ||
92 | |||
93 | u32 IPolShift; | ||
94 | u32 LoopMode; | ||
95 | f32 Scaling; | ||
96 | |||
97 | //! Cache Info | ||
98 | struct SCacheInfo | ||
99 | { | ||
100 | SCacheInfo(s32 frame=-1, s32 start=-1, s32 end=-1 ) : | ||
101 | Frame(frame), startFrameLoop(start), | ||
102 | endFrameLoop(end) | ||
103 | {} | ||
104 | |||
105 | bool operator == ( const SCacheInfo &other ) const | ||
106 | { | ||
107 | return 0 == memcmp ( this, &other, sizeof ( SCacheInfo ) ); | ||
108 | } | ||
109 | s32 Frame; | ||
110 | s32 startFrameLoop; | ||
111 | s32 endFrameLoop; | ||
112 | }; | ||
113 | SCacheInfo Current; | ||
114 | |||
115 | //! return a Mesh per frame | ||
116 | SMesh* MeshIPol; | ||
117 | SMD3QuaternionTagList TagListIPol; | ||
118 | |||
119 | IMeshBuffer* createMeshBuffer(const SMD3MeshBuffer* source, | ||
120 | io::IFileSystem* fs, video::IVideoDriver* driver); | ||
121 | |||
122 | void buildVertexArray(u32 frameA, u32 frameB, f32 interpolate, | ||
123 | const SMD3MeshBuffer* source, | ||
124 | SMeshBufferLightMap* dest); | ||
125 | |||
126 | void buildTagArray(u32 frameA, u32 frameB, f32 interpolate); | ||
127 | f32 FramesPerSecond; | ||
128 | }; | ||
129 | |||
130 | |||
131 | } // end namespace scene | ||
132 | } // end namespace irr | ||
133 | |||
134 | #endif | ||
135 | |||