Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
SAnimatedMesh.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef S_ANIMATED_MESH_HPP_INCLUDED
6#define S_ANIMATED_MESH_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/IAnimatedMesh.hpp>
9#include <nirtcpp/core/engine/IMesh.hpp>
10#include <nirtcpp/core/engine/aabbox3d.hpp>
11#include <nirtcpp/core/engine/irrArray.hpp>
12
13namespace nirt
14{
15namespace scene
16{
17
20 {
21 public:
24 {
25 #ifdef _DEBUG
26 setDebugName("SAnimatedMesh");
27 #endif
28 addMesh(mesh);
30 }
31
32 public:
35 {
36 // drop meshes
37 for (u32 i=0; i<Meshes.size(); ++i)
38 Meshes[i]->drop();
39 }
40
41 public:
43
44 virtual u32 getFrameCount() const override
45 {
46 return Meshes.size();
47 }
48
50
51 virtual f32 getAnimationSpeed() const override
52 {
53 return FramesPerSecond;
54 }
55
57
59 virtual void setAnimationSpeed(f32 fps) override
60 {
62 }
63
65
72 virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) override
73 {
74 if (Meshes.empty())
75 return 0;
76
77 return Meshes[frame];
78 }
79
81 void addMesh(IMesh* mesh)
82 {
83 if (mesh)
84 {
85 mesh->grab();
86 Meshes.push_back(mesh);
87 }
88 }
89
91
92 virtual const core::aabbox3d<f32>& getBoundingBox() const override
93 {
94 return Box;
95 }
96
98 virtual void setBoundingBox(const core::aabbox3df& box) override
99 {
100 Box = box;
101 }
102
105 {
106 Box.reset(0,0,0);
107
108 if (Meshes.empty())
109 return;
110
111 Box = Meshes[0]->getBoundingBox();
112
113 for (u32 i=1; i<Meshes.size(); ++i)
114 Box.addInternalBox(Meshes[i]->getBoundingBox());
115 }
116
118 virtual E_ANIMATED_MESH_TYPE getMeshType() const override
119 {
120 return Type;
121 }
122
124 virtual u32 getMeshBufferCount() const override
125 {
126 if (Meshes.empty())
127 return 0;
128
129 return Meshes[0]->getMeshBufferCount();
130 }
131
133 virtual IMeshBuffer* getMeshBuffer(u32 nr) const override
134 {
135 if (Meshes.empty())
136 return 0;
137
138 return Meshes[0]->getMeshBuffer(nr);
139 }
140
142
145 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const override
146 {
147 if (Meshes.empty())
148 return 0;
149
150 return Meshes[0]->getMeshBuffer(material);
151 }
152
154 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) override
155 {
156 for (u32 i=0; i<Meshes.size(); ++i)
157 Meshes[i]->setMaterialFlag(flag, newvalue);
158 }
159
161 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) override
162 {
163 for (u32 i=0; i<Meshes.size(); ++i)
164 Meshes[i]->setHardwareMappingHint(newMappingHint, buffer);
165 }
166
168 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) override
169 {
170 for (u32 i=0; i<Meshes.size(); ++i)
171 Meshes[i]->setDirty(buffer);
172 }
173
174 public:
177
180
183
186 };
187
188
189} // end namespace scene
190} // end namespace nirt
191
192#endif
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition IReferenceCounted.hpp:163
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.hpp:126
void grab() const
Grabs the object. Increments the reference counter by one.
Definition IReferenceCounted.hpp:96
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
Definition aabbox3d.hpp:82
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.hpp:50
Interface for an animated mesh.
Definition IAnimatedMesh.hpp:21
Class for holding a mesh with a single material.
Definition IMeshBuffer.hpp:41
Class which holds the geometry of an object.
Definition IMesh.hpp:72
Simple implementation of the IAnimatedMesh interface.
Definition SAnimatedMesh.hpp:20
SAnimatedMesh(scene::IMesh *mesh=0, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN)
constructor
Definition SAnimatedMesh.hpp:23
virtual IMeshBuffer * getMeshBuffer(const video::SMaterial &material) const override
Returns pointer to a mesh buffer which fits a material.
Definition SAnimatedMesh.hpp:145
void recalculateBoundingBox()
Recalculates the bounding box.
Definition SAnimatedMesh.hpp:104
core::array< IMesh * > Meshes
All meshes defining the animated mesh.
Definition SAnimatedMesh.hpp:176
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) override
flags the meshbuffer as changed, reloads hardware buffers
Definition SAnimatedMesh.hpp:168
virtual ~SAnimatedMesh()
destructor
Definition SAnimatedMesh.hpp:34
f32 FramesPerSecond
Default animation speed of this mesh.
Definition SAnimatedMesh.hpp:182
core::aabbox3d< f32 > Box
The bounding box of this mesh.
Definition SAnimatedMesh.hpp:179
virtual const core::aabbox3d< f32 > & getBoundingBox() const override
Returns an axis aligned bounding box of the mesh.
Definition SAnimatedMesh.hpp:92
virtual E_ANIMATED_MESH_TYPE getMeshType() const override
Returns the type of the animated mesh.
Definition SAnimatedMesh.hpp:118
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) override
Set a material flag for all meshbuffers of this mesh.
Definition SAnimatedMesh.hpp:154
E_ANIMATED_MESH_TYPE Type
The type of the mesh.
Definition SAnimatedMesh.hpp:185
virtual void setBoundingBox(const core::aabbox3df &box) override
set user axis aligned bounding box
Definition SAnimatedMesh.hpp:98
void addMesh(IMesh *mesh)
adds a Mesh
Definition SAnimatedMesh.hpp:81
virtual IMeshBuffer * getMeshBuffer(u32 nr) const override
returns pointer to a mesh buffer
Definition SAnimatedMesh.hpp:133
virtual u32 getFrameCount() const override
Gets the frame count of the animated mesh.
Definition SAnimatedMesh.hpp:44
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) override
set the hardware mapping hint, for driver
Definition SAnimatedMesh.hpp:161
virtual f32 getAnimationSpeed() const override
Gets the default animation speed of the animated mesh.
Definition SAnimatedMesh.hpp:51
virtual u32 getMeshBufferCount() const override
returns amount of mesh buffers.
Definition SAnimatedMesh.hpp:124
virtual void setAnimationSpeed(f32 fps) override
Gets the frame count of the animated mesh.
Definition SAnimatedMesh.hpp:59
virtual IMesh * getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) override
Returns the IMesh interface for a frame.
Definition SAnimatedMesh.hpp:72
Class for holding parameters for a material renderer.
Definition SMaterial.hpp:304
E_BUFFER_TYPE
Definition EHardwareBufferFlags.hpp:29
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.hpp:37
E_ANIMATED_MESH_TYPE
Possible types of meshes.
Definition IMesh.hpp:20
@ EAMT_UNKNOWN
Unknown animated mesh type.
Definition IMesh.hpp:22
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
E_MATERIAL_FLAG
Material flags.
Definition EMaterialFlags.hpp:15
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print