16 SBone::SBone(
SScene* parent,
const std::string& boneName,
SSkeleton* skeleton,
const unsigned short&
id) :
SNode(parent, boneName,
SNode::BONE_TYPE_ID)
49 SBone::SBone() :
SNode(0,
"",
SNode::BONE_TYPE_ID)
89 O3Bone->setManuallyControlled(
true);
90 O3Bone->rotate(axis, Ogre::Radian(radianAngle),
static_cast <Ogre::Node::TransformSpace
> (
static_cast<int>(relativeTo)));
91 O3Bone->setInitialState();
92 O3Bone->setManuallyControlled(
false);
102 Ogre::Quaternion tempQuat(quat);
103 tempQuat.normalise();
106 O3Bone->setManuallyControlled(
true);
107 O3Bone->setOrientation(tempQuat);
108 O3Bone->setInitialState();
109 O3Bone->setManuallyControlled(
false);
118 Ogre::Quaternion tempQuat(quat);
119 tempQuat.normalise();
121 if (tempQuat != Ogre::Quaternion::ZERO)
134 O3Bone->setManuallyControlled(
true);
135 O3Bone->resetOrientation();
136 O3Bone->setInitialState();
137 O3Bone->setManuallyControlled(
false);
148 O3Bone->setManuallyControlled(
true);
149 O3Bone->setPosition(pos);
150 O3Bone->setInitialState();
151 O3Bone->setManuallyControlled(
false);
162 O3Bone->setManuallyControlled(
true);
163 O3Bone->translate(d,
static_cast <Ogre::Node::TransformSpace
> (
static_cast<int>(relativeTo)));
164 O3Bone->setInitialState();
165 O3Bone->setManuallyControlled(
false);
176 O3Bone->setManuallyControlled(
true);
177 O3Bone->setScale(scale);
178 O3Bone->setInitialState();
179 O3Bone->setManuallyControlled(
false);
186 return Ogre::Vector3::ZERO;
189 return O3Bone->getPosition();
195 return Ogre::Quaternion::IDENTITY;
198 return O3Bone->getOrientation();
204 return Ogre::Vector3::UNIT_SCALE;
207 return O3Bone->getScale();
213 return Ogre::Vector3::ZERO;
216 return O3Bone->getInitialPosition();
222 return Ogre::Quaternion::IDENTITY;
225 return O3Bone->getInitialOrientation();
231 return Ogre::Vector3::ZERO;
234 return O3Bone->getInitialScale();
241 return Ogre::Vector3::ZERO;
245 parent->_update(
false,
true);
246 Ogre::Quaternion parentQuat = parent->_getDerivedOrientation();
247 Ogre::Vector3 parentPos = parent->_getDerivedPosition();
248 Ogre::Vector3 parentScale = parent->_getDerivedScale();
249 O3Bone->_update(
false,
true);
250 Ogre::Vector3 bonePos = O3Bone->_getDerivedPosition();
252 Ogre::Vector3 globalPosition = parentPos + (parentQuat * (bonePos * parentScale));
253 return globalPosition;
259 return Ogre::Quaternion::IDENTITY;
263 parent->_update(
false,
true);
264 Ogre::Quaternion parentQuat = parent->_getDerivedOrientation();
265 O3Bone->_update(
false,
true);
266 Ogre::Quaternion boneQuat = O3Bone->_getDerivedOrientation();
268 Ogre::Quaternion globalOrientation = parentQuat * boneQuat;
272 return globalOrientation;
278 return Ogre::Vector3::UNIT_SCALE;
282 Ogre::Vector3 col1(mat[0][0], mat[1][0], mat[2][0]);
283 Ogre::Vector3 col2(mat[0][1], mat[1][1], mat[2][1]);
284 Ogre::Vector3 col3(mat[0][2], mat[1][2], mat[2][2]);
287 sc.x = col1.length();
288 sc.y = col2.length();
289 sc.z = col3.length();
291 return O3Bone->_getDerivedScale() * sc;
302 parent->_update(
false,
true);
303 Ogre::Quaternion parentQuat = parent->_getDerivedOrientation();
304 Ogre::Vector3 parentPos = parent->_getDerivedPosition();
305 Ogre::Vector3 parentScale = parent->_getDerivedScale();
308 if (parentScale == Ogre::Vector3::ZERO)
309 parentScale = Ogre::Vector3(0.000001f, 0.000001f, 0.000001f);
311 Ogre::Vector3 globalPosition = parentQuat.Inverse() * ((pos - parentPos) * (1.0 / parentScale));
313 O3Bone->setManuallyControlled(
true);
316 if (O3Bone->getParent() == 0)
317 O3Bone->setPosition(globalPosition);
319 O3Bone->_setDerivedPosition(globalPosition);
321 O3Bone->setInitialState();
322 O3Bone->setManuallyControlled(
false);
335 parent->_update(
false,
true);
336 Ogre::Quaternion parentQuat = parent->_getDerivedOrientation();
338 Ogre::Quaternion globalOrientation = parentQuat.Inverse() * quat;
340 O3Bone->setManuallyControlled(
true);
343 if (O3Bone->getParent() == 0)
344 O3Bone->setOrientation(globalOrientation);
346 O3Bone->_setDerivedOrientation(globalOrientation);
348 O3Bone->setInitialState();
349 O3Bone->setManuallyControlled(
false);
362 parent->_update(
false,
true);
364 O3Bone->setManuallyControlled(
true);
365 if (O3Bone->getParent() == 0)
366 O3Bone->setScale(scale / parent->_getDerivedScale());
368 O3Bone->setScale(scale / parent->_getDerivedScale() / O3Bone->getParent()->_getDerivedScale());
370 O3Bone->setInitialState();
371 O3Bone->setManuallyControlled(
false);
380 return Ogre::Matrix4::IDENTITY;
383 return O3Bone->_getFullTransform();
392 O3Bone->setManuallyControlled(
true);
393 O3Bone->pitch(Ogre::Radian(radianAngle),
static_cast <Ogre::Node::TransformSpace
> (
static_cast<int>(relativeTo)));
394 O3Bone->setInitialState();
395 O3Bone->setManuallyControlled(
false);
405 O3Bone->setManuallyControlled(
true);
406 O3Bone->yaw(Ogre::Radian(radianAngle),
static_cast <Ogre::Node::TransformSpace
> (
static_cast<int>(relativeTo)));
407 O3Bone->setInitialState();
408 O3Bone->setManuallyControlled(
false);
418 O3Bone->setManuallyControlled(
true);
419 O3Bone->roll(Ogre::Radian(radianAngle),
static_cast <Ogre::Node::TransformSpace
> (
static_cast<int>(relativeTo)));
420 O3Bone->setInitialState();
421 O3Bone->setManuallyControlled(
false);
431 return O3Bone->numChildren();
440 O3Bone->setManuallyControlled(
true);
441 O3Bone->setInitialState();
442 O3Bone->setManuallyControlled(
false);
456 O3Bone->setManuallyControlled(
true);
459 if (O3Bone->getParent())
469 O3Bone->setInitialState();
470 O3Bone->setManuallyControlled(
false);
490#if OGRE_VERSION < ((1 << 16) | (7 << 8) | 0)
491 ogreObject->detatchFromParent();
493 ogreObject->detachFromParent();
510 bool isBoneAttached =
false;
513#if OGRE_VERSION < ((1 << 16) | (7 << 8) | 0)
514 if (ogreObject->isAttached())
516 Ogre::Node* np = ogreObject->getParentNode();
517 Ogre::SceneNode* snp = ogreObject->getParentSceneNode();
520 isBoneAttached =
true;
523 isBoneAttached = ogreObject->isParentTagPoint();
544 ogreObject->detachFromParent();
547 ogreLinkedEntity->attachObjectToBone(O3Bone->getName(), ogreObject, Ogre::Quaternion::IDENTITY, Ogre::Vector3::ZERO);
561 return Ogre::Quaternion::IDENTITY;
564 return O3Bone->convertWorldToLocalOrientation(quat);
573 O3Bone->setInheritOrientation(state);
582 return O3Bone->getInheritOrientation();
591 O3Bone->resetOrientation();
virtual void SetOrientation(const Ogre::Quaternion &quat)
Ogre::Bone * GetOgreBonePointer()
unsigned short GetIndex()
virtual void Pitch(const float &radianAngle, const SNode::NodeTransformSpace &relativeTo=SNode::SO3_LOCAL_TS)
virtual void SetPosition(const Ogre::Vector3 &pos)
SSkeleton * GetSkeleton()
virtual Ogre::Quaternion GetInitialOrientation()
virtual void SetGlobalPosition(const Ogre::Vector3 &pos, bool updateBody=true)
virtual void Rotate(const Ogre::Vector3 &axis, const float &radianAngle, const SNode::NodeTransformSpace &relativeTo=SNode::SO3_LOCAL_TS)
virtual bool GetInheritOrientation()
virtual Ogre::Vector3 GetPosition()
void AttachToBone(Ogre::MovableObject *ogreObject)
virtual void ResetToInitialOrientation()
virtual void Roll(const float &radianAngle, const SNode::NodeTransformSpace &relativeTo=SNode::SO3_LOCAL_TS)
virtual void Translate(const Ogre::Vector3 &d, const SNode::NodeTransformSpace &relativeTo=SNode::SO3_PARENT_TS)
virtual Ogre::Vector3 GetInitialPosition()
void DetachFromBone(Ogre::MovableObject *ogreObject)
virtual void SetGlobalOrientation(const Ogre::Quaternion &quat, bool updateBody=true)
virtual void AddOrientation(const Ogre::Quaternion &quat)
virtual void Yaw(const float &radianAngle, const SNode::NodeTransformSpace &relativeTo=SNode::SO3_LOCAL_TS)
virtual void SetScale(const Ogre::Vector3 &scale)
virtual void ResetOrientation()
virtual Ogre::Vector3 GetScale()
virtual Ogre::Quaternion GetGlobalOrientation()
virtual void SetInheritOrientation(const bool &state)
virtual Ogre::Matrix4 GetTransformationMatrix()
Ogre::Entity * ogreLinkedEntity
virtual int GetNumChildren()
SSkeleton * parentSkeleton
virtual Ogre::Vector3 GetGlobalPosition()
Ogre::Quaternion ConvertWorldToLocalOrientation(const Ogre::Quaternion &quat)
virtual void SetGlobalScale(const Ogre::Vector3 &pos, bool updateBody=true)
virtual void ResetToInitialPRS()
virtual Ogre::Quaternion GetOrientation()
virtual Ogre::Vector3 GetGlobalScale()
virtual void StoreInitialPRS()
virtual Ogre::Vector3 GetInitialScale()
Ogre::Entity * getOgreEntityPointer()
void UpdateNodeBody(const bool &bScale)
Ogre::SceneNode * O3SceneNode
Ogre::Vector3 initialPosition
Ogre::MovableObject * GetMovableObjectPointer()
Ogre::Quaternion initialOrientation
Ogre::Vector3 initialScale
Ogre::SceneNode * GetOgreSceneNodePointer()
Ogre::SkeletonInstance * GetOgreSkeletonPointer()
SEntity * GetParentEntity()
void _OnBoneDeletion(SBone *boneInstance)