Skip to content

Commit 262fba4

Browse files
author
Onur Berk Tore
committed
Adds check for default animation names
Signed-off-by: Onur Berk Tore <[email protected]>
1 parent 5d576ba commit 262fba4

File tree

4 files changed

+235
-0
lines changed

4 files changed

+235
-0
lines changed

graphics/src/AssimpLoader.cc

+7
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial(
350350
Pbr pbr;
351351
aiString texturePath(_path.c_str());
352352
ret = assimpMat->GetTexture(aiTextureType_DIFFUSE, 0, &texturePath);
353+
std::cout << "Texture path is: " << _path.c_str() << std::endl;
353354
// TODO(luca) check other arguments,
354355
// type of mappings to be UV, uv index, blend mode
355356
if (ret == AI_SUCCESS)
@@ -640,6 +641,7 @@ Mesh *AssimpLoader::Load(const std::string &_filename)
640641
// as documented here https://github.com/assimp/assimp/issues/849
641642
// remove workaround when fixed
642643
transform = aiMatrix4x4(rootScaling, aiQuaternion(), rootPos);
644+
std::cout << "Num anim is: " << scene->mNumAnimations << std::endl;
643645

644646
auto rootTransform = this->dataPtr->ConvertTransform(transform);
645647

@@ -669,16 +671,21 @@ Mesh *AssimpLoader::Load(const std::string &_filename)
669671
SkeletonPtr rootSkeleton = std::make_shared<Skeleton>(rootSkelNode);
670672
mesh->SetSkeleton(rootSkeleton);
671673
}
674+
std::cout << "Num anim is: " << scene->mNumAnimations << std::endl;
675+
672676
// Now create the meshes
673677
// Recursive call to keep track of transforms,
674678
// mesh is passed by reference and edited throughout
675679
this->dataPtr->RecursiveCreate(scene, rootNode, rootTransform, mesh);
676680
// Add the animations
681+
std::cout << "Num anim is: " << scene->mNumAnimations << std::endl;
682+
677683
for (unsigned animIdx = 0; animIdx < scene->mNumAnimations; ++animIdx)
678684
{
679685
auto& anim = scene->mAnimations[animIdx];
680686
auto animName = ToString(anim->mName);
681687
SkeletonAnimation* skelAnim = new SkeletonAnimation(animName);
688+
std::cout << "Anim name is: " << animName << std::endl;
682689
for (unsigned chanIdx = 0; chanIdx < anim->mNumChannels; ++chanIdx)
683690
{
684691
auto& animChan = anim->mChannels[chanIdx];

graphics/src/AssimpLoader_TEST.cc

+17
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,20 @@ TEST_F(AssimpLoader, LoadGlbPbrAsset)
697697
EXPECT_STREQ("Action2", skel->Animation(1)->Name().c_str());
698698
EXPECT_STREQ("Action3", skel->Animation(2)->Name().c_str());
699699
}
700+
701+
/////////////////////////////////////////////////
702+
// Load animation without a name
703+
TEST_F(AssimpLoader, NoAnimName)
704+
{
705+
common::AssimpLoader loader;
706+
707+
std::string meshFilename =
708+
common::testing::TestFile("data", "box_with_no_animation_name.dae");
709+
710+
common::Mesh *mesh = loader.Load(meshFilename);
711+
common::SkeletonPtr skeleton = mesh->MeshSkeleton();
712+
ASSERT_EQ(1u, skeleton->AnimationCount());
713+
common::SkeletonAnimation *anim = skeleton->Animation(0);
714+
auto animName = anim->Name();
715+
EXPECT_EQ(animName, "animation1");
716+
}

graphics/src/ColladaLoader_TEST.cc

+17
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,20 @@ TEST_F(ColladaLoader, LoadCylinderAnimatedFrom3dsMax)
489489
EXPECT_EQ(1u, anim->NodeCount());
490490
EXPECT_TRUE(anim->HasNode("Bone02"));
491491
}
492+
493+
/////////////////////////////////////////////////
494+
// Load animation without a name
495+
TEST_F(ColladaLoader, NoAnimName)
496+
{
497+
common::ColladaLoader loader;
498+
499+
std::string meshFilename =
500+
common::testing::TestFile("data", "box_with_no_animation_name.dae");
501+
502+
common::Mesh *mesh = loader.Load(meshFilename);
503+
common::SkeletonPtr skeleton = mesh->MeshSkeleton();
504+
ASSERT_EQ(1u, skeleton->AnimationCount());
505+
common::SkeletonAnimation *anim = skeleton->Animation(0);
506+
auto animName = anim->Name();
507+
EXPECT_EQ(animName, "animation1");
508+
}
+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<asset>
4+
<contributor>
5+
<author>Blender User</author>
6+
<authoring_tool>Blender 2.80.40 commit date:2019-01-07, commit time:23:37, hash:91a155833e59</authoring_tool>
7+
</contributor>
8+
<created>2019-01-08T17:44:11</created>
9+
<modified>2019-01-08T17:44:11</modified>
10+
<unit name="meter" meter="1"/>
11+
<up_axis>Z_UP</up_axis>
12+
</asset>
13+
<library_effects>
14+
<effect id="Material-effect">
15+
<profile_COMMON>
16+
<technique sid="common">
17+
<lambert>
18+
<diffuse>
19+
<color sid="diffuse">0.8 0.8 0.8 1</color>
20+
</diffuse>
21+
<specular>
22+
<color sid="specular">0 0.5 0 1</color>
23+
</specular>
24+
</lambert>
25+
</technique>
26+
</profile_COMMON>
27+
</effect>
28+
</library_effects>
29+
<library_images/>
30+
<library_materials>
31+
<material id="Material-material" name="Material">
32+
<instance_effect url="#Material-effect"/>
33+
</material>
34+
</library_materials>
35+
<library_geometries>
36+
<geometry id="Cube-mesh" name="Cube">
37+
<mesh>
38+
<source id="Cube-mesh-positions">
39+
<float_array id="Cube-mesh-positions-array" count="24">1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1</float_array>
40+
<technique_common>
41+
<accessor source="#Cube-mesh-positions-array" count="8" stride="3">
42+
<param name="X" type="float"/>
43+
<param name="Y" type="float"/>
44+
<param name="Z" type="float"/>
45+
</accessor>
46+
</technique_common>
47+
</source>
48+
<source id="Cube-mesh-normals">
49+
<float_array id="Cube-mesh-normals-array" count="18">0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0</float_array>
50+
<technique_common>
51+
<accessor source="#Cube-mesh-normals-array" count="6" stride="3">
52+
<param name="X" type="float"/>
53+
<param name="Y" type="float"/>
54+
<param name="Z" type="float"/>
55+
</accessor>
56+
</technique_common>
57+
</source>
58+
<source id="Cube-mesh-map-0">
59+
<float_array id="Cube-mesh-map-0-array" count="72">0.625 0 0.375 0.25 0.375 0 0.625 0.25 0.375 0.5 0.375 0.25 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.75 0.375 1 0.375 0.75 0.375 0.5 0.125 0.75 0.125 0.5 0.875 0.5 0.625 0.75 0.625 0.5 0.625 0 0.625 0.25 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1 0.375 1 0.375 0.5 0.375 0.75 0.125 0.75 0.875 0.5 0.875 0.75 0.625 0.75</float_array>
60+
<technique_common>
61+
<accessor source="#Cube-mesh-map-0-array" count="36" stride="2">
62+
<param name="S" type="float"/>
63+
<param name="T" type="float"/>
64+
</accessor>
65+
</technique_common>
66+
</source>
67+
<vertices id="Cube-mesh-vertices">
68+
<input semantic="POSITION" source="#Cube-mesh-positions"/>
69+
</vertices>
70+
<polylist material="Material-material" count="12">
71+
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
72+
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
73+
<input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="1"/>
74+
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
75+
<p>4 0 0 2 0 1 0 0 2 2 1 3 7 1 4 3 1 5 6 2 6 5 2 7 7 2 8 1 3 9 7 3 10 5 3 11 0 4 12 3 4 13 1 4 14 4 5 15 1 5 16 5 5 17 4 0 18 6 0 19 2 0 20 2 1 21 6 1 22 7 1 23 6 2 24 4 2 25 5 2 26 1 3 27 3 3 28 7 3 29 0 4 30 2 4 31 3 4 32 4 5 33 0 5 34 1 5 35</p>
76+
</polylist>
77+
</mesh>
78+
</geometry>
79+
</library_geometries>
80+
<library_controllers>
81+
<controller id="Armature_Cube-skin" name="Armature">
82+
<skin source="#Cube-mesh">
83+
<bind_shape_matrix>1 0 0 -1 0 1 0 1 0 0 1 1 0 0 0 1</bind_shape_matrix>
84+
<source id="Armature_Cube-skin-joints">
85+
<Name_array id="Armature_Cube-skin-joints-array" count="1">Bone</Name_array>
86+
<technique_common>
87+
<accessor source="#Armature_Cube-skin-joints-array" count="1" stride="1">
88+
<param name="JOINT" type="name"/>
89+
</accessor>
90+
</technique_common>
91+
</source>
92+
<source id="Armature_Cube-skin-bind_poses">
93+
<float_array id="Armature_Cube-skin-bind_poses-array" count="16">0.7886752 0.2113248 0.5773504 -0.5773504 -0.5773503 0.5773503 0.5773503 1.154701 -0.2113249 -0.7886752 0.5773503 -0.5773502 0 0 0 1</float_array>
94+
<technique_common>
95+
<accessor source="#Armature_Cube-skin-bind_poses-array" count="1" stride="16">
96+
<param name="TRANSFORM" type="float4x4"/>
97+
</accessor>
98+
</technique_common>
99+
</source>
100+
<source id="Armature_Cube-skin-weights">
101+
<float_array id="Armature_Cube-skin-weights-array" count="8">1 1 1 1 1 1 1 1</float_array>
102+
<technique_common>
103+
<accessor source="#Armature_Cube-skin-weights-array" count="8" stride="1">
104+
<param name="WEIGHT" type="float"/>
105+
</accessor>
106+
</technique_common>
107+
</source>
108+
<joints>
109+
<input semantic="JOINT" source="#Armature_Cube-skin-joints"/>
110+
<input semantic="INV_BIND_MATRIX" source="#Armature_Cube-skin-bind_poses"/>
111+
</joints>
112+
<vertex_weights count="8">
113+
<input semantic="JOINT" source="#Armature_Cube-skin-joints" offset="0"/>
114+
<input semantic="WEIGHT" source="#Armature_Cube-skin-weights" offset="1"/>
115+
<vcount>1 1 1 1 1 1 1 1 </vcount>
116+
<v>0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7</v>
117+
</vertex_weights>
118+
</skin>
119+
</controller>
120+
</library_controllers>
121+
<library_animations>
122+
<animation id="Armature_ArmatureAction_transform" name="">
123+
<source id="Armature_ArmatureAction_transform-input">
124+
<float_array id="Armature_ArmatureAction_transform-input-array" count="40">0.04166662 0.08333331 0.125 0.1666666 0.2083333 0.25 0.2916666 0.3333333 0.375 0.4166666 0.4583333 0.5 0.5416667 0.5833333 0.625 0.6666667 0.7083333 0.75 0.7916667 0.8333333 0.875 0.9166667 0.9583333 1 1.041667 1.083333 1.125 1.166667 1.208333 1.25 1.291667 1.333333 1.375 1.416667 1.458333 1.5 1.541667 1.583333 1.625 1.666667</float_array>
125+
<technique_common>
126+
<accessor source="#Armature_ArmatureAction_transform-input-array" count="40" stride="1">
127+
<param name="TIME" type="float"/>
128+
</accessor>
129+
</technique_common>
130+
</source>
131+
<source id="Armature_ArmatureAction_transform-output">
132+
<float_array id="Armature_ArmatureAction_transform-output-array" count="640">1 0 0 1 0 1 0 -1 0 0 1 0 0 0 0 1 0.9999878 3.10816e-5 0.004935208 1 0 0.9999802 -0.006297799 -1 -0.004935306 0.006297722 0.999968 0 0 0 0 1 0.999819 4.61727e-4 0.01901668 1 0 0.9997054 -0.02427293 -1 -0.01902229 0.02426853 0.9995245 0 0 0 0 1 0.9991519 0.002163141 0.04111904 1 0 0.9986191 -0.05253414 -1 -0.04117589 0.05248959 0.9977722 0 0 0 0 1 0.9975264 0.006301912 0.07000974 1 0 0.9959731 -0.08965231 -1 -0.0702928 0.08943056 0.9935095 0 0 0 0 1 0.9944467 0.01411698 0.1042901 1 0 0.9909625 -0.1341392 -1 -0.1052413 0.1333943 0.9854594 0 0 0 0 1 0.9894527 0.02671701 0.1423712 1 0 0.9828442 -0.184438 -1 -0.1448563 0.1824927 0.9724778 0 0 0 0 1 0.9821799 0.04490547 0.1825 1 0 0.9710366 -0.2389307 -1 -0.1879434 0.234673 0.9537326 0 0 0 0 1 0.9724072 0.06904543 0.2228386 1 0 0.9551992 -0.2959637 -1 -0.2332902 0.2877972 0.9288425 0 0 0 0 1 0.9600915 0.09897761 0.261587 1 0 0.9352878 -0.3538882 -1 -0.2796861 0.339765 0.8979618 0 0 0 0 1 0.9453882 0.1340003 0.2971281 1 0 0.9115852 -0.4111113 -1 -0.3259466 0.3886598 0.8618018 0 0 0 0 1 0.9286572 0.1729132 0.328172 1 0 0.8847058 -0.4661497 -1 -0.3709391 0.4328933 0.8215885 0 0 0 0 1 0.9104556 0.2141147 0.3538722 1 0 0.8555763 -0.5176768 -1 -0.4136069 0.4713217 0.7789642 0 0 0 0 1 0.8915175 0.2557371 0.3738919 1 0 0.8253933 -0.5645581 -1 -0.4529863 0.5033134 0.7358525 0 0 0 0 1 0.8727233 0.2957927 0.388408 1 0 0.7955672 -0.6058654 -1 -0.4882152 0.5287529 0.6943099 0 0 0 0 1 0.8550603 0.332307 0.3980502 1 0 0.7676533 -0.6408653 -1 -0.5185286 0.5479785 0.6563899 0 0 0 0 1 0.8395769 0.3634188 0.4037789 1 0 0.7432778 -0.6689829 -1 -0.5432408 0.5616626 0.6240388 0 0 0 0 1 0.8273312 0.3874339 0.4067161 1 0 0.7240622 -0.6897347 -1 -0.5617144 0.5706391 0.5990393 0 0 0 0 1 0.8193359 0.4028329 0.4079393 1 0 0.7115462 -0.7026393 -1 -0.5733138 0.5756976 0.5829953 0 0 0 0 1 0.8164964 0.4082482 0.4082486 1 7.75722e-8 0.707107 -0.7071065 -1 -0.5773504 0.57735 0.5773503 0 0 0 0 1 0.8190646 0.4033515 0.4079717 1 7.78161e-8 0.7111219 -0.7030687 -1 -0.5737014 0.5758587 0.5824547 0 0 0 0 1 0.8263245 0.3893851 0.4068995 1 7.85059e-8 0.7224849 -0.6913868 -1 -0.5631944 0.5713098 0.5970069 0 0 0 0 1 0.8375081 0.3675125 0.4043696 1 7.95684e-8 0.7400277 -0.6725764 -1 -0.5464249 0.5632883 0.6197791 0 0 0 0 1 0.8517552 0.3390183 0.3994742 1 8.0922e-8 0.7624427 -0.6470557 -1 -0.5239399 0.5511332 0.6494145 0 0 0 0 1 0.8681612 0.3053284 0.3912425 1 8.24806e-8 0.7883466 -0.6152314 -1 -0.4962822 0.5341201 0.6844119 0 0 0 0 1 0.8858209 0.2680094 0.3788038 1 8.41584e-8 0.8163394 -0.5775725 -1 -0.4640273 0.5116258 0.7231305 0 0 0 0 1 0.9038687 0.2287352 0.3615268 1 8.58731e-8 0.8450637 -0.5346656 -1 -0.42781 0.4832675 0.7638266 0 0 0 0 1 0.9215156 0.1892192 0.339124 1 8.75496e-8 0.8732626 -0.4872499 -1 -0.3883413 0.4490085 0.8047251 0 0 0 0 1 0.9380813 0.1511175 0.3117163 1 8.91235e-8 0.899834 -0.4362323 -1 -0.3464153 0.4092214 0.8441175 0 0 0 0 1 0.9530206 0.1159168 0.2798482 1 9.05428e-8 0.9238796 -0.3826832 -1 -0.3029055 0.3647051 0.8804763 0 0 0 0 1 0.965943 0.08482374 0.2444564 1 9.17705e-8 0.9447417 -0.3278156 -1 -0.2587547 0.3166512 0.9125667 0 0 0 0 1 0.9766233 0.05867312 0.2067956 1 9.27852e-8 0.9620277 -0.2729518 -1 -0.2149581 0.2665711 0.9395387 0 0 0 0 1 0.9850019 0.03787052 0.1683363 1 9.35812e-8 0.975616 -0.2194843 -1 -0.1725436 0.2161924 0.9609836 0 0 0 0 1 0.991176 0.02237916 0.1306496 1 9.41678e-8 0.9856446 -0.1688333 -1 -0.1325524 0.1673435 0.9769473 0 0 0 0 1 0.9953793 0.01175384 0.09529842 1 9.45671e-8 0.9924796 -0.1224106 -1 -0.09602053 0.121845 0.9878936 0 0 0 0 1 0.997952 0.005218936 0.06375288 1 9.48115e-8 0.996666 -0.08159051 -1 -0.06396614 0.08142342 0.9946249 0 0 0 0 1 0.9993011 0.001782816 0.03733916 1 9.49397e-8 0.998862 -0.04769476 -1 -0.0373817 0.04766143 0.9981638 0 0 0 0 1 0.9998515 3.78837e-4 0.01722835 1 9.4992e-8 0.9997582 -0.02198936 -1 -0.01723252 0.0219861 0.9996098 0 0 0 0 1 0.99999 2.53135e-5 0.004462156 1 9.50052e-8 0.9999838 -0.00569412 -1 -0.004462227 0.005694063 0.9999738 0 0 0 0 1 1 0 0 2 0 1 0 -1 0 0 1 0 0 0 0 1</float_array>
133+
<technique_common>
134+
<accessor source="#Armature_ArmatureAction_transform-output-array" count="40" stride="16">
135+
<param name="TRANSFORM" type="float4x4"/>
136+
</accessor>
137+
</technique_common>
138+
</source>
139+
<source id="Armature_ArmatureAction_transform-interpolation">
140+
<Name_array id="Armature_ArmatureAction_transform-interpolation-array" count="40">LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR</Name_array>
141+
<technique_common>
142+
<accessor source="#Armature_ArmatureAction_transform-interpolation-array" count="40" stride="1">
143+
<param name="INTERPOLATION" type="name"/>
144+
</accessor>
145+
</technique_common>
146+
</source>
147+
<sampler id="Armature_ArmatureAction_transform-sampler">
148+
<input semantic="INPUT" source="#Armature_ArmatureAction_transform-input"/>
149+
<input semantic="OUTPUT" source="#Armature_ArmatureAction_transform-output"/>
150+
<input semantic="INTERPOLATION" source="#Armature_ArmatureAction_transform-interpolation"/>
151+
</sampler>
152+
<channel source="#Armature_ArmatureAction_transform-sampler" target="Armature_Bone/transform"/>
153+
</animation>
154+
</library_animations>
155+
<library_visual_scenes>
156+
<visual_scene id="Scene" name="Scene">
157+
<node id="Armature" name="Armature" type="NODE">
158+
<matrix sid="transform">1 0 0 1 0 1 0 -1 0 0 1 0 0 0 0 1</matrix>
159+
<node id="Armature_Bone" name="Bone" sid="Bone" type="JOINT">
160+
<matrix sid="transform">0.7886751 -0.5773503 -0.211325 0 0.2113248 0.5773503 -0.7886751 0 0.5773503 0.5773503 0.5773502 0 0 0 0 1</matrix>
161+
<extra>
162+
<technique profile="blender">
163+
<layer sid="layer" type="string">0</layer>
164+
<roll sid="roll" type="float">-0.5235989</roll>
165+
<tip_x sid="tip_x" type="float">-2</tip_x>
166+
<tip_y sid="tip_y" type="float">2</tip_y>
167+
<tip_z sid="tip_z" type="float">2</tip_z>
168+
</technique>
169+
</extra>
170+
</node>
171+
<node id="Cube" name="Cube" type="NODE">
172+
<translate sid="location">0 0 0</translate>
173+
<rotate sid="rotationZ">0 0 1 0</rotate>
174+
<rotate sid="rotationY">0 1 0 0</rotate>
175+
<rotate sid="rotationX">1 0 0 0</rotate>
176+
<scale sid="scale">1 1 1</scale>
177+
<instance_controller url="#Armature_Cube-skin">
178+
<skeleton>#Armature_Bone</skeleton>
179+
<bind_material>
180+
<technique_common>
181+
<instance_material symbol="Material-material" target="#Material-material">
182+
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
183+
</instance_material>
184+
</technique_common>
185+
</bind_material>
186+
</instance_controller>
187+
</node>
188+
</node>
189+
</visual_scene>
190+
</library_visual_scenes>
191+
<scene>
192+
<instance_visual_scene url="#Scene"/>
193+
</scene>
194+
</COLLADA>

0 commit comments

Comments
 (0)