[1809] | 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-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 |
|
---|
| 26 | #ifndef __Bone_H__
|
---|
| 27 | #define __Bone_H__
|
---|
| 28 |
|
---|
| 29 | #include "OgrePrerequisites.h"
|
---|
| 30 | #include "OgreNode.h"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | namespace Ogre
|
---|
| 34 | {
|
---|
| 35 | /** A bone in a skeleton.
|
---|
| 36 | @remarks
|
---|
| 37 | See Skeleton for more information about the principles behind skeletal animation.
|
---|
| 38 | This class is a node in the joint hierarchy. Mesh vertices also have assignments
|
---|
| 39 | to bones to define how they move in relation to the skeleton.
|
---|
| 40 | */
|
---|
| 41 | class _OgreExport Bone : public Node
|
---|
| 42 | {
|
---|
| 43 | public:
|
---|
| 44 | /** Constructor, not to be used directly (use Bone::createChild or Skeleton::createBone) */
|
---|
| 45 | Bone(unsigned short handle, Skeleton* creator);
|
---|
| 46 | /** Constructor, not to be used directly (use Bone::createChild or Skeleton::createBone) */
|
---|
| 47 | Bone(const String& name, unsigned short handle, Skeleton* creator);
|
---|
| 48 | ~Bone();
|
---|
| 49 |
|
---|
| 50 | /** Creates a new Bone as a child of this bone.
|
---|
| 51 | @remarks
|
---|
| 52 | This method creates a new bone which will inherit the transforms of this
|
---|
| 53 | bone, with the handle specified.
|
---|
| 54 | @param
|
---|
| 55 | handle The numeric handle to give the new bone; must be unique within the Skeleton.
|
---|
| 56 | @param
|
---|
| 57 | translate Initial translation offset of child relative to parent
|
---|
| 58 | @param
|
---|
| 59 | rotate Initial rotation relative to parent
|
---|
| 60 | */
|
---|
| 61 | Bone* createChild(unsigned short handle,
|
---|
| 62 | const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | /** Gets the numeric handle for this bone (unique within the skeleton). */
|
---|
| 66 | unsigned short getHandle(void) const;
|
---|
| 67 |
|
---|
| 68 | /** Sets the current position / orientation to be the 'binding pose' ie the layout in which
|
---|
| 69 | bones were originally bound to a mesh.
|
---|
| 70 | */
|
---|
| 71 | void setBindingPose(void);
|
---|
| 72 |
|
---|
| 73 | /** Resets the position and orientation of this Bone to the original binding position.
|
---|
| 74 | @remarks
|
---|
| 75 | Bones are bound to the mesh in a binding pose. They are then modified from this
|
---|
| 76 | position during animation. This method returns the bone to it's original position and
|
---|
| 77 | orientation.
|
---|
| 78 | */
|
---|
| 79 | void reset(void);
|
---|
| 80 |
|
---|
| 81 | /** Sets whether or not this bone is manually controlled.
|
---|
| 82 | @remarks
|
---|
| 83 | Manually controlled bones can be altered by the application at runtime,
|
---|
| 84 | and their positions will not be reset by the animation routines. Note
|
---|
| 85 | that you should also make sure that there are no AnimationTrack objects
|
---|
| 86 | referencing this bone, or if there are, you should disable them using
|
---|
| 87 | pAnimation->destroyTrack(pBone->getHandle());
|
---|
| 88 | */
|
---|
| 89 | void setManuallyControlled(bool manuallyControlled);
|
---|
| 90 |
|
---|
| 91 | /** Getter for mManuallyControlled Flag */
|
---|
| 92 | bool isManuallyControlled() const;
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | /** Gets the transform which takes bone space to current from the binding pose.
|
---|
| 96 | @remarks
|
---|
| 97 | Internal use only.
|
---|
| 98 | */
|
---|
| 99 | void _getOffsetTransform(Matrix4& m) const;
|
---|
| 100 |
|
---|
| 101 | /** Gets the inverted binding pose scale. */
|
---|
| 102 | const Vector3& _getBindingPoseInverseScale(void) const { return mBindDerivedInverseScale; }
|
---|
| 103 | /** Gets the inverted binding pose position. */
|
---|
| 104 | const Vector3& _getBindingPoseInversePosition(void) const { return mBindDerivedInversePosition; }
|
---|
| 105 | /** Gets the inverted binding pose orientation. */
|
---|
| 106 | const Quaternion& _getBindingPoseInverseOrientation(void) const { return mBindDerivedInverseOrientation; }
|
---|
| 107 |
|
---|
| 108 | /// @see Node::needUpdate
|
---|
| 109 | void needUpdate(bool forceParentUpdate = false);
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | protected:
|
---|
| 113 | /// The numeric handle of this bone
|
---|
| 114 | unsigned short mHandle;
|
---|
| 115 |
|
---|
| 116 | /** Bones set as manuallyControlled are not reseted in Skeleton::reset() */
|
---|
| 117 | bool mManuallyControlled;
|
---|
| 118 |
|
---|
| 119 | /** See Node. */
|
---|
| 120 | Node* createChildImpl(void);
|
---|
| 121 | /** See Node. */
|
---|
| 122 | Node* createChildImpl(const String& name);
|
---|
| 123 |
|
---|
| 124 | /// Pointer back to creator, for child creation (not smart ptr so child does not preserve parent)
|
---|
| 125 | Skeleton* mCreator;
|
---|
| 126 |
|
---|
| 127 | /// The inversed derived scale of the bone in the binding pose
|
---|
| 128 | Vector3 mBindDerivedInverseScale;
|
---|
| 129 | /// The inversed derived orientation of the bone in the binding pose
|
---|
| 130 | Quaternion mBindDerivedInverseOrientation;
|
---|
| 131 | /// The inversed derived position of the bone in the binding pose
|
---|
| 132 | Vector3 mBindDerivedInversePosition;
|
---|
| 133 | };
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | #endif
|
---|