Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dummy animation for the root scene node #429

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions graphics/src/AssimpLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ class AssimpLoader::Implementation
const aiNode* _node,
std::unordered_set<std::string>& _boneNames) const;

/// \brief Adds animation at time 0, with default translation and
/// quaternion values for the given node.
/// \param[in] _skeleton Skeleton for the animation.
/// \param[in] _nodeName Node name for the animation.
public: void AddDumyAnimation(SkeletonPtr _skeleton, const char *_nodeName);

/// \brief Apply the the inv bind transform to the skeleton pose.
/// \remarks have to set the model transforms starting from the root in
/// breadth first order. Because setting the model transform also updates
Expand Down Expand Up @@ -673,6 +679,19 @@ AssimpLoader::~AssimpLoader()
{
}

//////////////////////////////////////////////////
void AssimpLoader::Implementation::AddDumyAnimation(SkeletonPtr _skeleton,
const char *_nodeName)
{
SkeletonAnimation* skelAnim = new SkeletonAnimation("dummyAnimation");
math::Vector3d pos(0, 0, 0);
math::Quaterniond quat(0, 0, 0, 0);
math::Pose3d pose(pos, quat);
skelAnim->AddKeyFrame(_nodeName, 0, pose);
_skeleton->AddAnimation(skelAnim);
return;
}

//////////////////////////////////////////////////
Mesh *AssimpLoader::Load(const std::string &_filename)
{
Expand Down Expand Up @@ -736,6 +755,7 @@ Mesh *AssimpLoader::Load(const std::string &_filename)
// Recursive call to keep track of transforms,
// mesh is passed by reference and edited throughout
this->dataPtr->RecursiveCreate(scene, rootNode, rootTransform, mesh);
this->dataPtr->AddDumyAnimation(mesh->MeshSkeleton(), "scene");
// Add the animations
for (unsigned animIdx = 0; animIdx < scene->mNumAnimations; ++animIdx)
{
Expand Down
Loading