12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include "3d/CCAttachNode.h"
- #include "3d/CCSkeleton3D.h"
- NS_CC_BEGIN
- AttachNode* AttachNode::create(Bone3D* attachBone)
- {
- auto attachnode = new (std::nothrow) AttachNode();
- attachnode->_attachBone = attachBone;
- attachnode->autorelease();
-
- return attachnode;
- }
- AttachNode::AttachNode()
- : _attachBone(nullptr)
- {
-
- }
- AttachNode::~AttachNode()
- {
-
- }
- Mat4 AttachNode::getWorldToNodeTransform() const
- {
- static Mat4 mat;
- mat.setIdentity();
- auto parent = getParent();
- if (parent)
- {
- mat = parent->getWorldToNodeTransform() * _attachBone->getWorldMat() * Node::getNodeToParentTransform();
- }
- else
- {
- mat = _attachBone->getWorldMat() * Node::getNodeToParentTransform();
- }
- return mat;
- }
- Mat4 AttachNode::getNodeToWorldTransform() const
- {
- return Node::getNodeToWorldTransform();
- }
- const Mat4& AttachNode::getNodeToParentTransform() const
- {
- Node::getNodeToParentTransform();
- _transformToParent = _attachBone->getWorldMat() * _transform;
- return _transformToParent;
- }
- void AttachNode::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t )
- {
- Node::visit(renderer, parentTransform, Node::FLAGS_DIRTY_MASK);
- }
- NS_CC_END
|