Esempio n. 1
0
//-----------------------------------------------------------------------
void Entity::attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation, const Vector3 &offsetPosition) {
  if(pMovable->isAttached()) {
    Except(Exception::ERR_INVALIDPARAMS, "Object already attached to a sceneNode or a Bone",
           "Entity::attachObjectToBone");
  }
  if (!mMesh->hasSkeleton()) {
    Except(Exception::ERR_INVALIDPARAMS, "This entity's mesh has no skeleton to attach object to.",
           "Entity::attachObjectToBone");
  }
  Bone* bone = mMesh->getSkeleton()->getBone(boneName);
  if (!bone) {
    Except(Exception::ERR_INVALIDPARAMS, "Cannot locate bone named " + boneName,
           "Entity::attachObjectToBone");
  }

  TagPoint *tp = bone->createChildTagPoint(offsetOrientation, offsetPosition);
  tp->setParentEntity(this);
  tp->setChildObject(pMovable);

  attachObjectImpl(pMovable, tp);
}