17 #ifndef GZ_RENDERING_BASE_BASENODE_HH_
18 #define GZ_RENDERING_BASE_BASENODE_HH_
31 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
101 public:
virtual void SetOrigin(
double _x,
double _y,
double _z)
override;
132 public:
virtual void Scale(
double _scale)
override;
135 public:
virtual void Scale(
double _x,
double _y,
double _z)
override;
149 public:
virtual bool HasChildId(
unsigned int _id)
const override;
207 protected:
bool initialLocalPoseSet =
false;
233 NodePtr parent = this->Parent();
237 auto baseShared = this->shared_from_this();
238 auto thisShared = std::dynamic_pointer_cast<BaseNode<T>>(baseShared);
239 parent->RemoveChild(thisShared);
248 if (_child->Id() == this->Id())
254 if (this->AttachChild(_child))
256 this->Children()->Add(_child);
264 NodePtr child = this->Children()->Remove(_child);
265 if (child) this->DetachChild(child);
273 NodePtr child = this->Children()->RemoveById(_id);
274 if (child) this->DetachChild(child);
282 NodePtr child = this->Children()->RemoveByName(_name);
283 if (child) this->DetachChild(child);
291 NodePtr child = this->Children()->RemoveByIndex(_index);
292 if (child) this->DetachChild(child);
300 for (
unsigned int i = this->ChildCount(); i > 0; --i)
302 this->RemoveChildByIndex(i - 1);
311 this->PreRenderChildren();
318 unsigned int count = this->ChildCount();
320 for (
unsigned int i = 0; i < count; ++i)
322 this->ChildByIndex(i)->PreRender();
331 pose.
Pos() += pose.
Rot() * this->origin;
341 gzerr <<
"Unable to set non-finite pose [" << _pose
342 <<
"] to node [" << this->Name() <<
"]" <<
std::endl;
347 pose.
Pos() = pose.
Pos() - pose.
Rot() * this->origin;
349 if (!initialLocalPoseSet)
351 this->initialLocalPose = pose;
352 this->initialLocalPoseSet =
true;
355 this->SetRawLocalPose(pose);
362 return this->initialLocalPose;
369 return this->LocalPose().Pos();
385 gzerr <<
"Unable to set non-finite position [" << _position
386 <<
"] to node [" << this->Name() <<
"]" <<
std::endl;
391 pose.
Pos() = _position;
392 this->SetLocalPose(pose);
399 return this->LocalPose().Rot();
423 gzerr <<
"Unable to set non-finite rotation [" << _rotation
424 <<
"] to node [" << this->Name() <<
"]" <<
std::endl;
429 pose.
Rot() = _rotation;
430 this->SetLocalPose(pose);
437 NodePtr parent = this->Parent();
445 return parent->WorldPose() * pose;
453 this->SetLocalPose(pose);
467 return this->WorldPose().Pos();
475 pose.
Pos() = _position;
476 this->SetWorldPose(pose);
483 return this->WorldPose().Rot();
506 pose.
Rot() = _rotation;
507 this->SetWorldPose(pose);
514 NodePtr parent = this->Parent();
521 return parent->WorldPose().Inverse() * _pose;
544 gzerr <<
"Unable to set non-finite origin [" << _origin
545 <<
"] to node [" << this->Name() <<
"]" <<
std::endl;
548 this->origin = _origin;
570 this->SetLocalScaleImpl(_scale);
571 this->SetLocalPose(rawPose);
580 if (!this->InheritScale() || !this->HasParent())
585 return scale * this->Parent()->WorldScale();
607 if (this->InheritScale() && this->HasParent())
608 toScale = this->Parent()->WorldScale();
610 this->SetLocalScale(_scale / toScale);
631 this->SetLocalScale(_scale * this->LocalScale());
639 this->RemoveParent();
646 return this->Children()->Size();
653 return this->Children()->Contains(_child);
660 return this->Children()->ContainsId(_id);
667 return this->Children()->ContainsName(_name);
674 return this->Children()->GetById(_id);
681 return this->Children()->GetByName(_name);
688 return this->Children()->GetByIndex(_index);
696 this->userData[_key] = _value;
704 auto it = this->userData.find(_key);
705 if (it != this->userData.end())
714 return this->userData.find(_key) != this->userData.end();