aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h
new file mode 100644
index 0000000..0014910
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshMD2.h
@@ -0,0 +1,154 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
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_MD2_H_INCLUDED__
6#define __C_ANIMATED_MESH_MD2_H_INCLUDED__
7
8#include "IAnimatedMeshMD2.h"
9#include "IMesh.h"
10#include "CMeshBuffer.h"
11#include "IReadFile.h"
12#include "S3DVertex.h"
13#include "irrArray.h"
14#include "irrString.h"
15
16namespace irr
17{
18namespace scene
19{
20
21 class CAnimatedMeshMD2 : public IAnimatedMeshMD2
22 {
23 public:
24
25 //! constructor
26 CAnimatedMeshMD2();
27
28 //! destructor
29 virtual ~CAnimatedMeshMD2();
30
31 //! returns the amount of frames. If the amount is 1, it is a static (=non animated) mesh.
32 virtual u32 getFrameCount() const;
33
34 //! Gets the default animation speed of the animated mesh.
35 /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */
36 virtual f32 getAnimationSpeed() const
37 {
38 return FramesPerSecond;
39 }
40
41 //! Gets the frame count of the animated mesh.
42 /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated.
43 The actual speed is set in the scene node the mesh is instantiated in.*/
44 virtual void setAnimationSpeed(f32 fps)
45 {
46 FramesPerSecond=fps;
47 }
48
49 //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level.
50 virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1);
51
52 //! returns amount of mesh buffers.
53 virtual u32 getMeshBufferCount() const;
54
55 //! returns pointer to a mesh buffer
56 virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
57
58 //! Returns pointer to a mesh buffer which fits a material
59 /** \param material: material to search for
60 \return Returns the pointer to the mesh buffer or
61 NULL if there is no such mesh buffer. */
62 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
63
64 //! returns an axis aligned bounding box
65 virtual const core::aabbox3d<f32>& getBoundingBox() const;
66
67 //! set user axis aligned bounding box
68 virtual void setBoundingBox( const core::aabbox3df& box);
69
70 //! sets a flag of all contained materials to a new value
71 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
72
73 //! set the hardware mapping hint, for driver
74 virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
75
76 //! flags the meshbuffer as changed, reloads hardware buffers
77 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
78
79 //! Returns the type of the animated mesh.
80 virtual E_ANIMATED_MESH_TYPE getMeshType() const;
81
82 //! Returns frame loop data for a special MD2 animation type.
83 virtual void getFrameLoop(EMD2_ANIMATION_TYPE,
84 s32& outBegin, s32& outEnd, s32& outFps) const;
85
86 //! Returns frame loop data for a special MD2 animation type.
87 virtual bool getFrameLoop(const c8* name,
88 s32& outBegin, s32& outEnd, s32& outFps) const;
89
90 //! Returns amount of md2 animations in this file.
91 virtual s32 getAnimationCount() const;
92
93 //! Returns name of md2 animation.
94 //! \param nr: Zero based index of animation.
95 virtual const c8* getAnimationName(s32 nr) const;
96
97
98 //
99 // exposed for loader
100 //
101
102 //! the buffer that contains the most recent animation
103 SMeshBuffer* InterpolationBuffer;
104
105 //! named animations
106 struct SAnimationData
107 {
108 core::stringc name;
109 s32 begin;
110 s32 end;
111 s32 fps;
112 };
113
114 //! scale and translations for keyframes
115 struct SKeyFrameTransform
116 {
117 core::vector3df scale;
118 core::vector3df translate;
119 };
120
121 //! md2 vertex data
122 struct SMD2Vert
123 {
124 core::vector3d<u8> Pos;
125 u8 NormalIdx;
126 };
127
128 //! keyframe transformations
129 core::array<SKeyFrameTransform> FrameTransforms;
130
131 //! keyframe vertex data
132 core::array<SMD2Vert> *FrameList;
133
134 //! bounding boxes for each keyframe
135 core::array<core::aabbox3d<f32> > BoxList;
136
137 //! named animations
138 core::array< SAnimationData > AnimationData;
139
140 u32 FrameCount;
141
142 private:
143
144 //! updates the interpolation buffer
145 void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame);
146
147 f32 FramesPerSecond;
148 };
149
150} // end namespace scene
151} // end namespace irr
152
153#endif
154