Irrlicht 3D Engine
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
SAnimatedMesh.h
Go to the documentation of this file.
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 __S_ANIMATED_MESH_H_INCLUDED__
6
#define __S_ANIMATED_MESH_H_INCLUDED__
7
8
#include "
IAnimatedMesh.h
"
9
#include "
IMesh.h
"
10
#include "
aabbox3d.h
"
11
#include "
irrArray.h
"
12
13
namespace
irr
14
{
15
namespace
scene
16
{
17
19
struct
SAnimatedMesh
:
public
IAnimatedMesh
20
{
22
SAnimatedMesh
(
scene::IMesh
* mesh=0,
scene::E_ANIMATED_MESH_TYPE
type=
scene::EAMT_UNKNOWN
) :
IAnimatedMesh
(),
FramesPerSecond
(25.f),
Type
(type)
23
{
24
#ifdef _DEBUG
25
setDebugName
(
"SAnimatedMesh"
);
26
#endif
27
addMesh
(mesh);
28
recalculateBoundingBox
();
29
}
30
32
virtual
~SAnimatedMesh
()
33
{
34
// drop meshes
35
for
(
u32
i=0; i<
Meshes
.
size
(); ++i)
36
Meshes
[i]->
drop
();
37
}
38
40
41
virtual
u32
getFrameCount
()
const
42
{
43
return
Meshes
.
size
();
44
}
45
47
48
virtual
f32
getAnimationSpeed
()
const
49
{
50
return
FramesPerSecond
;
51
}
52
54
56
virtual
void
setAnimationSpeed
(
f32
fps)
57
{
58
FramesPerSecond
=fps;
59
}
60
62
69
virtual
IMesh
*
getMesh
(
s32
frame,
s32
detailLevel=255,
s32
startFrameLoop=-1,
s32
endFrameLoop=-1)
70
{
71
if
(
Meshes
.
empty
())
72
return
0;
73
74
return
Meshes
[frame];
75
}
76
78
void
addMesh
(
IMesh
* mesh)
79
{
80
if
(mesh)
81
{
82
mesh->
grab
();
83
Meshes
.
push_back
(mesh);
84
}
85
}
86
88
89
virtual
const
core::aabbox3d<f32>
&
getBoundingBox
()
const
90
{
91
return
Box
;
92
}
93
95
virtual
void
setBoundingBox
(
const
core::aabbox3df
& box)
96
{
97
Box
= box;
98
}
99
101
void
recalculateBoundingBox
()
102
{
103
Box
.
reset
(0,0,0);
104
105
if
(
Meshes
.
empty
())
106
return
;
107
108
Box
=
Meshes
[0]->getBoundingBox();
109
110
for
(
u32
i=1; i<
Meshes
.
size
(); ++i)
111
Box
.
addInternalBox
(
Meshes
[i]->getBoundingBox());
112
}
113
115
virtual
E_ANIMATED_MESH_TYPE
getMeshType
()
const
116
{
117
return
Type
;
118
}
119
121
virtual
u32
getMeshBufferCount
()
const
122
{
123
if
(
Meshes
.
empty
())
124
return
0;
125
126
return
Meshes
[0]->getMeshBufferCount();
127
}
128
130
virtual
IMeshBuffer
*
getMeshBuffer
(
u32
nr)
const
131
{
132
if
(
Meshes
.
empty
())
133
return
0;
134
135
return
Meshes
[0]->getMeshBuffer(nr);
136
}
137
139
142
virtual
IMeshBuffer
*
getMeshBuffer
(
const
video::SMaterial
&material)
const
143
{
144
if
(
Meshes
.
empty
())
145
return
0;
146
147
return
Meshes
[0]->getMeshBuffer(material);
148
}
149
151
virtual
void
setMaterialFlag
(
video::E_MATERIAL_FLAG
flag,
bool
newvalue)
152
{
153
for
(
u32
i=0; i<
Meshes
.
size
(); ++i)
154
Meshes
[i]->
setMaterialFlag
(flag, newvalue);
155
}
156
158
virtual
void
setHardwareMappingHint
(
E_HARDWARE_MAPPING
newMappingHint,
E_BUFFER_TYPE
buffer=
EBT_VERTEX_AND_INDEX
)
159
{
160
for
(
u32
i=0; i<
Meshes
.
size
(); ++i)
161
Meshes
[i]->
setHardwareMappingHint
(newMappingHint, buffer);
162
}
163
165
virtual
void
setDirty
(
E_BUFFER_TYPE
buffer=
EBT_VERTEX_AND_INDEX
)
166
{
167
for
(
u32
i=0; i<
Meshes
.
size
(); ++i)
168
Meshes
[i]->
setDirty
(buffer);
169
}
170
172
core::array<IMesh*>
Meshes
;
173
175
core::aabbox3d<f32>
Box
;
176
178
f32
FramesPerSecond
;
179
181
E_ANIMATED_MESH_TYPE
Type
;
182
};
183
184
185
}
// end namespace scene
186
}
// end namespace irr
187
188
#endif
189
Irrlicht Engine
Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Sun Apr 21 2019 20:57:28 for Irrlicht 3D Engine by
Doxygen
1.8.1.2