aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/IMeshCache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/IMeshCache.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/IMeshCache.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/IMeshCache.h b/src/others/irrlicht-1.8.1/include/IMeshCache.h
new file mode 100644
index 0000000..083fc5b
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/IMeshCache.h
@@ -0,0 +1,177 @@
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 __I_MESH_CACHE_H_INCLUDED__
6#define __I_MESH_CACHE_H_INCLUDED__
7
8#include "IReferenceCounted.h"
9#include "path.h"
10
11namespace irr
12{
13
14namespace scene
15{
16 class IMesh;
17 class IAnimatedMesh;
18 class IAnimatedMeshSceneNode;
19 class IMeshLoader;
20
21 //! The mesh cache stores already loaded meshes and provides an interface to them.
22 /** You can access it using ISceneManager::getMeshCache(). All existing
23 scene managers will return a pointer to the same mesh cache, because it
24 is shared between them. With this interface, it is possible to manually
25 add new loaded meshes (if ISceneManager::getMesh() is not sufficient),
26 to remove them and to iterate through already loaded meshes. */
27 class IMeshCache : public virtual IReferenceCounted
28 {
29 public:
30
31 //! Destructor
32 virtual ~IMeshCache() {}
33
34 //! Adds a mesh to the internal list of loaded meshes.
35 /** Usually, ISceneManager::getMesh() is called to load a mesh
36 from a file. That method searches the list of loaded meshes if
37 a mesh has already been loaded and returns a pointer to if it
38 is in that list and already in memory. Otherwise it loads the
39 mesh. With IMeshCache::addMesh(), it is possible to pretend
40 that a mesh already has been loaded. This method can be used
41 for example by mesh loaders who need to load more than one mesh
42 with one call. They can add additional meshes with this method
43 to the scene manager. The COLLADA loader for example uses this
44 method.
45 \param name Name of the mesh. When calling
46 ISceneManager::getMesh() with this name it will return the mesh
47 set by this method.
48 \param mesh Pointer to a mesh which will now be referenced by
49 this name. */
50 virtual void addMesh(const io::path& name, IAnimatedMesh* mesh) = 0;
51
52 //! Removes the mesh from the cache.
53 /** After loading a mesh with getMesh(), the mesh can be
54 removed from the cache using this method, freeing a lot of
55 memory.
56 \param mesh Pointer to the mesh which shall be removed. */
57 virtual void removeMesh(const IMesh* const mesh) = 0;
58
59 //! Returns amount of loaded meshes in the cache.
60 /** You can load new meshes into the cache using getMesh() and
61 addMesh(). If you ever need to access the internal mesh cache,
62 you can do this using removeMesh(), getMeshNumber(),
63 getMeshByIndex() and getMeshName().
64 \return Number of meshes in cache. */
65 virtual u32 getMeshCount() const = 0;
66
67 //! Returns current index number of the mesh or -1 when not found.
68 /** \param mesh Pointer to the mesh to search for.
69 \return Index of the mesh in the cache, or -1 if not found. */
70 virtual s32 getMeshIndex(const IMesh* const mesh) const = 0;
71
72 //! Returns a mesh based on its index number.
73 /** \param index: Index of the mesh, number between 0 and
74 getMeshCount()-1.
75 Note that this number is only valid until a new mesh is loaded
76 or removed.
77 \return Pointer to the mesh or 0 if there is none with this
78 number. */
79 virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0;
80
81 //! Returns a mesh based on its name (often a filename).
82 /** \deprecated Use getMeshByName() instead. This method may be removed by
83 Irrlicht 1.9 */
84 _IRR_DEPRECATED_ IAnimatedMesh* getMeshByFilename(const io::path& filename)
85 {
86 return getMeshByName(filename);
87 }
88
89 //! Get the name of a loaded mesh, based on its index. (Name is often identical to the filename).
90 /** \deprecated Use getMeshName() instead. This method may be removed by
91 Irrlicht 1.9 */
92 _IRR_DEPRECATED_ const io::path& getMeshFilename(u32 index) const
93 {
94 return getMeshName(index).getInternalName();
95 }
96
97 //! Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
98 /** \deprecated Use getMeshName() instead. This method may be removed by
99 Irrlicht 1.9 */
100 _IRR_DEPRECATED_ const io::path& getMeshFilename(const IMesh* const mesh) const
101 {
102 return getMeshName(mesh).getInternalName();
103 }
104
105 //! Renames a loaded mesh.
106 /** \deprecated Use renameMesh() instead. This method may be removed by
107 Irrlicht 1.9 */
108 _IRR_DEPRECATED_ bool setMeshFilename(u32 index, const io::path& filename)
109 {
110 return renameMesh(index, filename);
111 }
112
113 //! Renames a loaded mesh.
114 /** \deprecated Use renameMesh() instead. This method may be removed by
115 Irrlicht 1.9 */
116 _IRR_DEPRECATED_ bool setMeshFilename(const IMesh* const mesh, const io::path& filename)
117 {
118 return renameMesh(mesh, filename);
119 }
120
121 //! Returns a mesh based on its name.
122 /** \param name Name of the mesh. Usually a filename.
123 \return Pointer to the mesh or 0 if there is none with this number. */
124 virtual IAnimatedMesh* getMeshByName(const io::path& name) = 0;
125
126 //! Get the name of a loaded mesh, based on its index.
127 /** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
128 \return The name if mesh was found and has a name, else the path is empty. */
129 virtual const io::SNamedPath& getMeshName(u32 index) const = 0;
130
131 //! Get the name of the loaded mesh if there is any.
132 /** \param mesh Pointer to mesh to query.
133 \return The name if mesh was found and has a name, else the path is empty. */
134 virtual const io::SNamedPath& getMeshName(const IMesh* const mesh) const = 0;
135
136 //! Renames a loaded mesh.
137 /** Note that renaming meshes might change the ordering of the
138 meshes, and so the index of the meshes as returned by
139 getMeshIndex() or taken by some methods will change.
140 \param index The index of the mesh in the cache.
141 \param name New name for the mesh.
142 \return True if mesh was renamed. */
143 virtual bool renameMesh(u32 index, const io::path& name) = 0;
144
145 //! Renames the loaded mesh
146 /** Note that renaming meshes might change the ordering of the
147 meshes, and so the index of the meshes as returned by
148 getMeshIndex() or taken by some methods will change.
149 \param mesh Mesh to be renamed.
150 \param name New name for the mesh.
151 \return True if mesh was renamed. */
152 virtual bool renameMesh(const IMesh* const mesh, const io::path& name) = 0;
153
154 //! Check if a mesh was already loaded.
155 /** \param name Name of the mesh. Usually a filename.
156 \return True if the mesh has been loaded, else false. */
157 virtual bool isMeshLoaded(const io::path& name) = 0;
158
159 //! Clears the whole mesh cache, removing all meshes.
160 /** All meshes will be reloaded completely when using ISceneManager::getMesh()
161 after calling this method.
162 Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
163 and you did not grab them, then they may become invalid. */
164 virtual void clear() = 0;
165
166 //! Clears all meshes that are held in the mesh cache but not used anywhere else.
167 /** Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
168 and you did not grab them, then they may become invalid. */
169 virtual void clearUnusedMeshes() = 0;
170 };
171
172
173} // end namespace scene
174} // end namespace irr
175
176#endif
177