source: GTP/trunk/Lib/Geom/OgreStuff/include/OgrePose.h @ 1809

Revision 1809, 4.0 KB checked in by gumbau, 18 years ago (diff)
RevLine 
[1809]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright © 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://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
34namespace 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
88                /** Clone this pose and create another one configured exactly the same
89                        way (only really useful for cloning holders of this class).
90                */
91                Pose* clone(void) const;
92        protected:
93                /// Target geometry index
94                ushort mTarget;
95                /// Optional name
96                String mName;
97                /// Primary storage, sparse vertex use
98                VertexOffsetMap mVertexOffsetMap;
99                /// Derived hardware buffer, covers all vertices
100                mutable HardwareVertexBufferSharedPtr mBuffer;
101        };
102        typedef std::vector<Pose*> PoseList;
103
104
105}
106
107#endif
Note: See TracBrowser for help on using the repository browser.