[148] | 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 (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | |
---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
---|
| 11 | in the Software without restriction, including without limitation the rights |
---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
---|
| 14 | furnished to do so, subject to the following conditions: |
---|
| 15 | |
---|
| 16 | The above copyright notice and this permission notice shall be included in |
---|
| 17 | all copies or substantial portions of the Software. |
---|
| 18 | |
---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 25 | THE SOFTWARE. |
---|
| 26 | ----------------------------------------------------------------------------- |
---|
| 27 | */ |
---|
| 28 | #ifndef __OGRE_POSE_H |
---|
| 29 | #define __OGRE_POSE_H |
---|
| 30 | |
---|
| 31 | #include "OgrePrerequisites.h" |
---|
| 32 | #include "OgreString.h" |
---|
| 33 | #include "OgreHardwareVertexBuffer.h" |
---|
| 34 | #include "OgreVector3.h" |
---|
| 35 | #include "OgreIteratorWrappers.h" |
---|
| 36 | #include "OgreHeaderPrefix.h" |
---|
| 37 | |
---|
| 38 | namespace Ogre { |
---|
| 39 | |
---|
| 40 | /** \addtogroup Core |
---|
| 41 | * @{ |
---|
| 42 | */ |
---|
| 43 | /** \addtogroup Animation |
---|
| 44 | * @{ |
---|
| 45 | */ |
---|
| 46 | /** A pose is a linked set of vertex offsets applying to one set of vertex |
---|
| 47 | data. |
---|
| 48 | @remarks |
---|
| 49 | The target index referred to by the pose has a meaning set by the user |
---|
| 50 | of this class; but for example when used by Mesh it refers to either the |
---|
| 51 | Mesh shared geometry (0) or a SubMesh dedicated geometry (1+). |
---|
| 52 | Pose instances can be referred to by keyframes in VertexAnimationTrack in |
---|
| 53 | order to animate based on blending poses together. |
---|
| 54 | */ |
---|
| 55 | class _OgreExport Pose : public AnimationAlloc |
---|
| 56 | { |
---|
| 57 | public: |
---|
| 58 | /** Constructor |
---|
| 59 | @param target The target vertexdata index (0 for shared, 1+ for |
---|
| 60 | dedicated at the submesh index + 1) |
---|
| 61 | @param name Optional name |
---|
| 62 | */ |
---|
| 63 | Pose(ushort target, const String& name = StringUtil::BLANK); |
---|
| 64 | virtual ~Pose(); |
---|
| 65 | /// Return the name of the pose (may be blank) |
---|
| 66 | const String& getName(void) const { return mName; } |
---|
| 67 | /// Return the target geometry index of the pose |
---|
| 68 | ushort getTarget(void) const { return mTarget; } |
---|
| 69 | /// A collection of vertex offsets based on the vertex index |
---|
| 70 | typedef map<size_t, Vector3>::type VertexOffsetMap; |
---|
| 71 | /// An iterator over the vertex offsets |
---|
| 72 | typedef MapIterator<VertexOffsetMap> VertexOffsetIterator; |
---|
| 73 | /// An iterator over the vertex offsets |
---|
| 74 | typedef ConstMapIterator<VertexOffsetMap> ConstVertexOffsetIterator; |
---|
| 75 | /// A collection of normals based on the vertex index |
---|
| 76 | typedef map<size_t, Vector3>::type NormalsMap; |
---|
| 77 | /// An iterator over the vertex offsets |
---|
| 78 | typedef MapIterator<NormalsMap> NormalsIterator; |
---|
| 79 | /// An iterator over the vertex offsets |
---|
| 80 | typedef ConstMapIterator<NormalsMap> ConstNormalsIterator; |
---|
| 81 | /// Return whether the pose vertices include normals |
---|
| 82 | bool getIncludesNormals() const { return !mNormalsMap.empty(); } |
---|
| 83 | |
---|
| 84 | /** Adds an offset to a vertex for this pose. |
---|
| 85 | @param index The vertex index |
---|
| 86 | @param offset The position offset for this pose |
---|
| 87 | */ |
---|
| 88 | void addVertex(size_t index, const Vector3& offset); |
---|
| 89 | |
---|
| 90 | /** Adds an offset to a vertex and a new normal for this pose. |
---|
| 91 | @param index The vertex index |
---|
| 92 | @param offset The position offset for this pose |
---|
| 93 | */ |
---|
| 94 | void addVertex(size_t index, const Vector3& offset, const Vector3& normal); |
---|
| 95 | |
---|
| 96 | /** Remove a vertex offset. */ |
---|
| 97 | void removeVertex(size_t index); |
---|
| 98 | |
---|
| 99 | /** Clear all vertices. */ |
---|
| 100 | void clearVertices(void); |
---|
| 101 | |
---|
| 102 | /** Gets an iterator over all the vertex offsets. */ |
---|
| 103 | ConstVertexOffsetIterator getVertexOffsetIterator(void) const; |
---|
| 104 | /** Gets an iterator over all the vertex offsets. */ |
---|
| 105 | VertexOffsetIterator getVertexOffsetIterator(void); |
---|
| 106 | /** Gets a const reference to the vertex offsets. */ |
---|
| 107 | const VertexOffsetMap& getVertexOffsets(void) const { return mVertexOffsetMap; } |
---|
| 108 | |
---|
| 109 | /** Gets an iterator over all the vertex offsets. */ |
---|
| 110 | ConstNormalsIterator getNormalsIterator(void) const; |
---|
| 111 | /** Gets an iterator over all the vertex offsets. */ |
---|
| 112 | NormalsIterator getNormalsIterator(void); |
---|
| 113 | /** Gets a const reference to the vertex offsets. */ |
---|
| 114 | const NormalsMap& getNormals(void) const { return mNormalsMap; } |
---|
| 115 | |
---|
| 116 | /** Get a hardware vertex buffer version of the vertex offsets. */ |
---|
| 117 | const HardwareVertexBufferSharedPtr& _getHardwareVertexBuffer(const VertexData* origData) const; |
---|
| 118 | |
---|
| 119 | /** Clone this pose and create another one configured exactly the same |
---|
| 120 | way (only really useful for cloning holders of this class). |
---|
| 121 | */ |
---|
| 122 | Pose* clone(void) const; |
---|
| 123 | protected: |
---|
| 124 | /// Target geometry index |
---|
| 125 | ushort mTarget; |
---|
| 126 | /// Optional name |
---|
| 127 | String mName; |
---|
| 128 | /// Primary storage, sparse vertex use |
---|
| 129 | VertexOffsetMap mVertexOffsetMap; |
---|
| 130 | /// Primary storage, sparse vertex use |
---|
| 131 | NormalsMap mNormalsMap; |
---|
| 132 | /// Derived hardware buffer, covers all vertices |
---|
| 133 | mutable HardwareVertexBufferSharedPtr mBuffer; |
---|
| 134 | }; |
---|
| 135 | typedef vector<Pose*>::type PoseList; |
---|
| 136 | |
---|
| 137 | /** @} */ |
---|
| 138 | /** @} */ |
---|
| 139 | |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | #include "OgreHeaderSuffix.h" |
---|
| 143 | |
---|
| 144 | #endif |
---|