1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright © 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __OGRE_POSE_H
|
---|
26 | #define __OGRE_POSE_H
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreString.h"
|
---|
30 | #include "OgreHardwareVertexBuffer.h"
|
---|
31 | #include "OgreVector3.h"
|
---|
32 | #include "OgreIteratorWrappers.h"
|
---|
33 |
|
---|
34 | namespace Ogre {
|
---|
35 |
|
---|
36 | /** A pose is a linked set of vertex offsets applying to one set of vertex
|
---|
37 | data.
|
---|
38 | @remarks
|
---|
39 | The target index referred to by the pose has a meaning set by the user
|
---|
40 | of this class; but for example when used by Mesh it refers to either the
|
---|
41 | Mesh shared geometry (0) or a SubMesh dedicated geometry (1+).
|
---|
42 | Pose instances can be referred to by keyframes in VertexAnimationTrack in
|
---|
43 | order to animate based on blending poses together.
|
---|
44 | */
|
---|
45 | class _OgreExport Pose
|
---|
46 | {
|
---|
47 | public:
|
---|
48 | /** Constructor
|
---|
49 | @param target The target vertexdata index (0 for shared, 1+ for
|
---|
50 | dedicated at the submesh index + 1)
|
---|
51 | @param name Optional name
|
---|
52 | */
|
---|
53 | Pose(ushort target, const String& name = StringUtil::BLANK);
|
---|
54 | virtual ~Pose();
|
---|
55 | /// Return the name of the pose (may be blank)
|
---|
56 | const String& getName(void) const { return mName; }
|
---|
57 | /// Return the target geometry index of the pose
|
---|
58 | ushort getTarget(void) const { return mTarget; }
|
---|
59 | /// A collection of vertex offsets based on the vertex index
|
---|
60 | typedef std::map<size_t, Vector3> VertexOffsetMap;
|
---|
61 | /// An iterator over the vertex offsets
|
---|
62 | typedef MapIterator<VertexOffsetMap> VertexOffsetIterator;
|
---|
63 | /// An iterator over the vertex offsets
|
---|
64 | typedef ConstMapIterator<VertexOffsetMap> ConstVertexOffsetIterator;
|
---|
65 |
|
---|
66 | /** Adds an offset to a vertex for this pose.
|
---|
67 | @param index The vertex index
|
---|
68 | @param offset The position offset for this pose
|
---|
69 | */
|
---|
70 | void addVertex(size_t index, const Vector3& offset);
|
---|
71 |
|
---|
72 | /** Remove a vertex offset. */
|
---|
73 | void removeVertex(size_t index);
|
---|
74 |
|
---|
75 | /** Clear all vertex offsets. */
|
---|
76 | void clearVertexOffsets(void);
|
---|
77 |
|
---|
78 | /** Gets an iterator over all the vertex offsets. */
|
---|
79 | ConstVertexOffsetIterator getVertexOffsetIterator(void) const;
|
---|
80 | /** Gets an iterator over all the vertex offsets. */
|
---|
81 | VertexOffsetIterator getVertexOffsetIterator(void);
|
---|
82 | /** Gets a const reference to the vertex offsets. */
|
---|
83 | const VertexOffsetMap& getVertexOffsets(void) const { return mVertexOffsetMap; }
|
---|
84 |
|
---|
85 | /** Get a hardware vertex buffer version of the vertex offsets. */
|
---|
86 | const HardwareVertexBufferSharedPtr& _getHardwareVertexBuffer(size_t numVertices) const;
|
---|
87 | protected:
|
---|
88 | /// Target geometry index
|
---|
89 | ushort mTarget;
|
---|
90 | /// Optional name
|
---|
91 | String mName;
|
---|
92 | /// Primary storage, sparse vertex use
|
---|
93 | VertexOffsetMap mVertexOffsetMap;
|
---|
94 | /// Derived hardware buffer, covers all vertices
|
---|
95 | mutable HardwareVertexBufferSharedPtr mBuffer;
|
---|
96 | };
|
---|
97 | typedef std::vector<Pose*> PoseList;
|
---|
98 |
|
---|
99 |
|
---|
100 | }
|
---|
101 |
|
---|
102 | #endif
|
---|