2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
28 void mesh_actor_test_startup(void)
30 test_return_value = TET_UNDEF;
33 void mesh_actor_test_cleanup(void)
35 test_return_value = TET_PASS;
44 MeshData::VertexContainer vertices;
45 MeshData::FaceIndices faces;
47 ConstructVertices(vertices, 60);
48 ConstructFaces(vertices, faces);
49 Material customMaterial = ConstructMaterial();
50 meshData.SetData(vertices, faces, bones, customMaterial);
51 Mesh mesh = Mesh::New(meshData);
55 static AnimatableMesh NewAnimatableMesh()
57 AnimatableMesh::Faces faces;
62 Material customMaterial = Material::New("CustomMaterial");
63 customMaterial.SetOpacity(.76f);
64 customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
65 customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
66 customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
68 AnimatableMesh mesh = AnimatableMesh::New( 10u, faces, customMaterial );
71 } // anonymous namespace
73 int UtcDaliMeshActorConstructorVoid(void)
75 TestApplication application;
76 tet_infoline("Testing Dali::MeshActor::MeshActor()");
79 DALI_TEST_CHECK(!actor);
83 int UtcDaliMeshActorNew01(void)
85 TestApplication application;
86 tet_infoline("Testing Dali::MeshActor::New()");
88 AnimatableMesh mesh = NewAnimatableMesh();
89 MeshActor actor = MeshActor::New(mesh);
90 application.SendNotification();
93 application.SendNotification();
95 DALI_TEST_CHECK(actor);
99 int UtcDaliMeshActorNew02(void)
101 TestApplication application;
102 TestPlatformAbstraction& platform = application.GetPlatform();
104 tet_infoline("Testing Dali::MeshActor::New()");
106 std::string modelName("AModel");
107 Dali::ModelData modelData = Dali::ModelData::New(modelName);
108 Dali::Entity rootEntity = Dali::Entity::New("root");
109 modelData.SetRootEntity(rootEntity);
110 rootEntity.SetType(Dali::Entity::OBJECT);
112 Model model = Model::New("Fake model");
114 // Run Core - will query using TestPlatformAbstraction::GetResources().
115 application.SendNotification();
116 application.Render();
118 Integration::ResourceRequest* request = platform.GetRequest();
121 platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject())));
124 application.Render();
125 application.SendNotification();
127 Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded
129 DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded);
130 DALI_TEST_CHECK(actor);
131 DALI_TEST_CHECK(actor.GetName().compare("root") == 0);
135 int UtcDaliMeshActorNew03(void)
137 TestApplication application;
138 tet_infoline("Testing Dali::Mesh::New() - Create with no mesh");
142 MeshActor actor = MeshActor::New(); // Shouldn't assert
143 tet_result(TET_PASS);
145 catch (Dali::DaliException& e)
147 tet_result(TET_FAIL);
153 int UtcDaliMeshActorCreateNoMeshData(void)
155 TestApplication application;
156 tet_infoline("Testing Dali::Mesh::New() - Create with no mesh data");
161 Mesh mesh = Mesh::New(meshData);
162 MeshActor actor1 = MeshActor::New(mesh);
164 catch(Dali::DaliException& e)
166 DALI_TEST_PRINT_ASSERT( e );
167 DALI_TEST_ASSERT(e, "object", TEST_LOCATION);
173 int UtcDaliMeshActorCreateSetData01(void)
175 TestApplication application;
176 tet_infoline("Testing Dali::MeshData::SetData() - Create with no verts");
180 MeshData::VertexContainer vertices;
181 MeshData::FaceIndices faces;
183 Material customMaterial;
184 meshData.SetData(vertices, faces, bones, customMaterial);
185 Mesh mesh = Mesh::New(meshData);
186 MeshActor actor1 = MeshActor::New(mesh);
188 catch(Dali::DaliException& e)
190 DALI_TEST_PRINT_ASSERT( e );
191 DALI_TEST_ASSERT(e, "!vertices.empty()", TEST_LOCATION );
196 int UtcDaliMeshActorCreateSetData02(void)
198 TestApplication application;
199 tet_infoline("Testing Dali::MeshData::SetData - Create with no faces");
203 MeshData::VertexContainer vertices;
204 MeshData::FaceIndices faces;
206 Material customMaterial;
207 ConstructVertices(vertices, 60);
208 meshData.SetData(vertices, faces, bones, customMaterial);
209 Mesh mesh = Mesh::New(meshData);
210 MeshActor actor1 = MeshActor::New(mesh);
212 catch(Dali::DaliException& e)
214 DALI_TEST_PRINT_ASSERT( e );
215 DALI_TEST_ASSERT(e, "!faceIndices.empty", TEST_LOCATION );
220 int UtcDaliMeshActorCreateSetData03(void)
222 TestApplication application;
223 tet_infoline("Testing Dali::MeshData::SetData - Create with no mats");
227 MeshData::VertexContainer vertices;
228 MeshData::FaceIndices faces;
230 Material customMaterial;
231 ConstructVertices(vertices, 60);
232 ConstructFaces(vertices, faces);
233 meshData.SetData(vertices, faces, bones, customMaterial);
234 Mesh mesh = Mesh::New(meshData);
235 MeshActor actor1 = MeshActor::New(mesh);
237 catch(Dali::DaliException& e)
239 DALI_TEST_PRINT_ASSERT( e );
240 DALI_TEST_ASSERT(e, "material", TEST_LOCATION );
245 int UtcDaliMeshActorCreateSetData04(void)
247 TestApplication application;
248 tet_infoline("Testing Dali::MeshActor::SetData()");
251 MeshData::VertexContainer vertices;
252 MeshData::FaceIndices faces;
254 ConstructVertices(vertices, 60);
255 ConstructFaces(vertices, faces);
256 Material customMaterial = ConstructMaterial();
257 meshData.SetData(vertices, faces, bones, customMaterial);
259 Mesh mesh = Mesh::New(meshData);
260 MeshActor actor1 = MeshActor::New(mesh);
261 DALI_TEST_CHECK(actor1);
266 int UtcDaliMeshActorDownCast(void)
268 TestApplication application;
269 tet_infoline("Testing Dali::MeshActor::DownCast()");
272 MeshData::VertexContainer vertices;
273 MeshData::FaceIndices faces;
275 ConstructVertices(vertices, 60);
276 ConstructFaces(vertices, faces);
277 Material customMaterial = ConstructMaterial();
278 meshData.SetData(vertices, faces, bones, customMaterial);
279 Mesh mesh = Mesh::New(meshData);
281 MeshActor actor1 = MeshActor::New(mesh);
282 Actor anActor = Actor::New();
285 Actor child = anActor.GetChildAt(0);
286 MeshActor meshActor = MeshActor::DownCast(child);
288 DALI_TEST_CHECK(meshActor);
292 int UtcDaliMeshActorDownCast2(void)
294 TestApplication application;
295 tet_infoline("Testing Dali::MeshActor::DownCast()");
297 Actor actor1 = Actor::New();
298 Actor anActor = Actor::New();
301 Actor child = anActor.GetChildAt(0);
302 MeshActor meshActor = MeshActor::DownCast(child);
303 DALI_TEST_CHECK(!meshActor);
305 Actor unInitialzedActor;
306 meshActor = DownCast< MeshActor >( unInitialzedActor );
307 DALI_TEST_CHECK(!meshActor);
311 int UtcDaliMeshActorSetMaterial01(void)
313 TestApplication application;
314 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
316 Mesh mesh = NewMesh();
318 MeshActor actor = MeshActor::New(mesh);
319 std::string name = "AMeshActor";
320 Stage::GetCurrent().Add(actor);
322 application.SendNotification();
323 application.Render();
324 application.Render();
325 application.SendNotification();
327 Material customMaterial = Material::New("CustomMaterial");
328 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
330 MeshActor::SetMaterial(actor, name, customMaterial);
331 application.SendNotification();
332 application.Render();
333 application.Render();
334 application.SendNotification();
336 DALI_TEST_CHECK( actor.GetMaterial() == customMaterial );
340 int UtcDaliMeshActorSetMaterial01b(void)
342 TestApplication application;
343 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
345 Mesh mesh = NewMesh();
347 Actor rootActor = Actor::New();
348 MeshActor meshActor = MeshActor::New(mesh);
349 rootActor.Add(meshActor);
351 std::string name = "AMeshActor";
352 meshActor.SetName(name);
354 Stage::GetCurrent().Add(rootActor);
355 application.SendNotification();
356 application.Render();
357 application.Render();
358 application.SendNotification();
360 Material customMaterial = Material::New("CustomMaterial");
361 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
363 MeshActor::SetMaterial(rootActor, name, customMaterial);
364 application.SendNotification();
365 application.Render();
366 application.Render();
367 application.SendNotification();
369 DALI_TEST_CHECK(meshActor.GetMaterial() == customMaterial );
374 int UtcDaliMeshActorSetMaterial02(void)
376 TestApplication application;
377 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
379 Mesh mesh = NewMesh();
380 MeshActor actor = MeshActor::New(mesh);
382 std::string name = "AMeshActor";
384 Stage::GetCurrent().Add(actor);
385 application.SendNotification();
386 application.Render();
387 application.Render();
388 application.SendNotification();
390 Material baseMat = actor.GetMaterial();
391 Material customMaterial = Material::New("CustomMaterial");
392 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
394 MeshActor::SetMaterial(actor, "NoName", customMaterial);
395 application.SendNotification();
396 application.Render();
397 application.Render();
398 application.SendNotification();
400 DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
401 DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
405 int UtcDaliMeshActorSetMaterial02b(void)
407 TestApplication application;
408 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
410 Mesh mesh = NewMesh();
412 MeshActor actor = MeshActor::New(mesh);
413 Stage::GetCurrent().Add(actor);
415 std::string name = "AMeshActor";
417 application.SendNotification();
418 application.Render();
419 application.Render();
420 application.SendNotification();
422 Material baseMat = actor.GetMaterial();
423 Material customMaterial = Material::New("CustomMaterial");
424 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
426 MeshActor::SetMaterial(actor, "NoName", customMaterial);
427 application.SendNotification();
428 application.Render();
429 application.Render();
430 application.SendNotification();
432 DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
433 DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
438 int UtcDaliMeshActorSetMaterial03(void)
440 TestApplication application;
441 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
443 Mesh mesh = NewMesh();
445 MeshActor actor = MeshActor::New(mesh);
446 std::string name = "AMeshActor";
448 Stage::GetCurrent().Add(actor);
450 Material customMaterial = Material::New("CustomMaterial");
451 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
453 actor.SetMaterial(customMaterial);
454 application.SendNotification();
455 application.Render(0);
456 application.Render(16);
457 application.SendNotification();
459 DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
463 int UtcDaliMeshActorSetMaterial03b(void)
465 TestApplication application;
466 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
468 Mesh mesh = NewMesh();
470 MeshActor actor = MeshActor::New(mesh);
471 std::string name = "AMeshActor";
473 Stage::GetCurrent().Add(actor);
475 Material customMaterial = Material::New("CustomMaterial");
476 customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
478 actor.SetMaterial(customMaterial);
479 application.SendNotification();
480 application.Render(0);
481 application.Render(16);
482 application.SendNotification();
483 DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
489 int UtcDaliMeshActorGetMaterial01(void)
491 TestApplication application;
492 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
495 MeshData::VertexContainer vertices;
496 MeshData::FaceIndices faces;
498 ConstructVertices(vertices, 60);
499 ConstructFaces(vertices, faces);
500 Material material = ConstructMaterial();
501 meshData.SetData(vertices, faces, bones, material);
502 Mesh mesh = Mesh::New(meshData);
504 MeshActor actor = MeshActor::New(mesh);
505 std::string name = "AMeshActor";
507 application.SendNotification();
508 application.Render();
509 application.Render();
510 application.SendNotification();
512 Material gotMaterial = actor.GetMaterial();
514 DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
515 DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
516 DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
517 DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
522 int UtcDaliMeshActorGetMaterial02(void)
524 TestApplication application;
525 tet_infoline("Testing Dali::MeshActor::SetMaterial()");
528 MeshData::VertexContainer vertices;
529 MeshData::FaceIndices faces;
531 ConstructVertices(vertices, 60);
532 ConstructFaces(vertices, faces);
533 Material material = ConstructMaterial();
534 meshData.SetData(vertices, faces, bones, material);
535 Mesh mesh = Mesh::New(meshData);
537 MeshActor actor = MeshActor::New(mesh);
538 std::string name = "AMeshActor";
540 application.SendNotification();
541 application.Render();
542 application.Render();
543 application.SendNotification();
545 Material gotMaterial = actor.GetMaterial();
547 DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
548 DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
549 DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
550 DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
554 int UtcDaliMeshActorSetLighting01(void)
556 TestApplication application;
557 tet_infoline("Testing Dali::MeshActor::GetLighting()");
559 Mesh mesh = NewMesh();
561 MeshActor actor = MeshActor::New(mesh);
562 Stage::GetCurrent().Add(actor);
564 // Mesh actors should be lit by default
565 DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION);
569 int UtcDaliMeshActorSetLighting02(void)
571 TestApplication application;
572 tet_infoline("Testing Dali::MeshActor::SetLighting()");
574 Mesh mesh = NewMesh();
575 MeshActor actor = MeshActor::New(mesh);
576 Stage::GetCurrent().Add(actor);
578 application.SendNotification();
579 application.Render();
580 application.Render();
581 application.SendNotification();
583 Light light = Light::New("KeyLight");
584 light.SetFallOff(Vector2(10000.0f, 10000.0f));
585 LightActor keyLightActor = LightActor::New();
586 keyLightActor.SetParentOrigin(ParentOrigin::CENTER);
587 keyLightActor.SetPosition(200.0f, 500.0f, 300.0f);
588 keyLightActor.SetName(light.GetName());
590 Stage::GetCurrent().Add(keyLightActor);
591 keyLightActor.SetLight(light);
592 keyLightActor.SetActive(true);
594 actor.SetAffectedByLighting(true);
595 DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION);
597 // Test rendering to ensure that the correct shader setup is used in renderer
598 // (check in debugger or via coverage)
599 application.Render(1);
600 application.SendNotification();
601 application.Render(1);
602 application.SendNotification();
603 application.Render(1);
604 application.SendNotification();
605 application.Render(1);
606 application.SendNotification();
607 application.Render(1);
609 actor.SetAffectedByLighting(false);
610 DALI_TEST_EQUALS(actor.IsAffectedByLighting(), false, TEST_LOCATION);
612 // Test rendering to ensure that the correct shader setup is used in renderer
613 // (check in debugger or via coverage)
614 application.Render(1);
615 application.SendNotification();
616 application.Render(1);
617 application.SendNotification();
618 application.Render(1);
619 application.SendNotification();
620 application.Render(1);
621 application.SendNotification();
622 application.Render(1);
629 Material ConstructMaterial(float opacity, float diffuseOpacity)
631 Material customMaterial = Material::New("CustomMaterial");
632 customMaterial.SetOpacity(opacity);
633 customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, diffuseOpacity));
634 customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
635 customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
636 return customMaterial;
639 static void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
642 MeshData::VertexContainer vertices;
643 MeshData::FaceIndices faces;
645 ConstructVertices(vertices, 60);
646 ConstructFaces(vertices, faces);
647 meshData.SetData(vertices, faces, bones, material);
648 Mesh mesh = Mesh::New(meshData);
650 application.SendNotification();
651 application.Render(0);
652 application.Render();
653 application.SendNotification();
655 MeshActor actor = MeshActor::New(mesh);
656 Stage::GetCurrent().Add(actor);
658 actor.SetAffectedByLighting(false);
659 actor.SetBlendMode(blendingMode);
660 actor.SetOpacity(actorOpacity);
662 TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
663 cullFaceTrace.Enable(true);
664 application.SendNotification();
665 application.Render();
666 DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
668 } //anonymous namespace
671 int UtcDaliMeshActorBlend01(void)
673 // Set Material with translucent color, actor color opaque, Set Use image alpha to true
676 TestApplication application;
677 tet_infoline("Testing Dali::MeshActor::Blend01()");
679 TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::AUTO, true );
684 int UtcDaliMeshActorBlend02(void)
686 // Set material to translucent, set use image alpha to false, set actor opacity to 1.0f
687 // Expect no blending
689 TestApplication application;
690 tet_infoline("Testing Dali::MeshActor::Blend02()");
691 TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::OFF, false );
695 int UtcDaliMeshActorBlend03(void)
697 // Set material to opaque, set use image alpha to true, set actor opacity to 1.0f
698 // Expect no blending
700 TestApplication application;
701 tet_infoline("Testing Dali::MeshActor::Blend03()");
702 TestBlending( application, ConstructMaterial(1.0f, 1.0f), 1.0f, BlendingMode::AUTO, false );
707 int UtcDaliMeshActorBlend04(void)
709 // Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f
711 TestApplication application;
712 tet_infoline("Testing Dali::MeshActor::Blend04()");
714 Material material = ConstructMaterial(1.0f, 1.0f);
715 BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
716 material.SetDiffuseTexture( image );
717 application.SendNotification();
718 application.Render(0);
720 TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
724 int UtcDaliMeshActorBlend05(void)
726 // Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f
727 // Expect no blending
729 TestApplication application;
730 tet_infoline("Testing Dali::MeshActor::Blend05()");
732 Material material = ConstructMaterial(1.0f, 1.0f);
733 BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
734 material.SetDiffuseTexture( image );
735 application.SendNotification();
736 application.Render(0);
738 TestBlending( application, material, 1.0f, BlendingMode::ON, true );
743 int UtcDaliMeshActorBlend06(void)
745 // Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f
746 // Expect no blending
748 TestApplication application;
749 tet_infoline("Testing Dali::MeshActor::Blend()");
751 Material material = ConstructMaterial(1.0f, 1.0f);
752 BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
753 material.SetDiffuseTexture( image );
754 application.SendNotification();
755 application.Render(0);
757 TestBlending( application, material, 1.0f, BlendingMode::AUTO, false );
761 int UtcDaliMeshActorBlend07(void)
763 // Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f
765 TestApplication application;
766 tet_infoline("Testing Dali::MeshActor::Blend07()");
767 application.Render(0);
769 Material material = ConstructMaterial(1.0f, 1.0f);
770 FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
771 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
772 RenderTask task = taskList.GetTask( 0u );
773 task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
774 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
775 application.SendNotification();
776 application.Render();
778 material.SetDiffuseTexture( image ); // (to render from)
779 application.SendNotification();
780 application.Render();
781 application.Render();
782 application.SendNotification();
784 TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
788 int UtcDaliMeshActorBlend08(void)
790 // Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f
792 TestApplication application;
793 tet_infoline("Testing Dali::MeshActor::Blend08()");
795 Material material = ConstructMaterial(1.0f, 1.0f);
796 BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
797 material.SetDiffuseTexture( image );
798 application.SendNotification();
799 application.Render(0);
801 TestBlending( application, material, 0.5f, BlendingMode::AUTO, true );
805 int UtcDaliMeshActorBlend09(void)
807 // Set material to have image with no alpha, set material opacity to 0.5, set use image alpha to true, set actor opacity to 1.0f
809 TestApplication application;
810 tet_infoline("Testing Dali::MeshActor::Blend08()");
812 Material material = ConstructMaterial(0.5f, 1.0f);
813 BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
814 material.SetDiffuseTexture( image );
815 application.SendNotification();
816 application.Render(0);
818 TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
822 int UtcDaliMeshActorBoneUpdate01(void)
824 TestApplication application;
825 tet_infoline("Testing Dali::MeshActor::BoneUpdate01()");
827 // Set up a mesh with bones.
829 // ensure bone actor's world matrix is updated
831 Actor trunk = Actor::New();
832 trunk.SetName("trunk");
833 trunk.SetPosition(Vector3(100.0f, 200.0f, 300.0f));
834 trunk.SetRotation(Quaternion(M_PI*0.3f, Vector3::XAXIS));
835 Actor branch = Actor::New();
836 branch.SetName("branch");
837 branch.SetPosition(Vector3(10.0f, 100.0f, 0.0f));
838 branch.SetRotation(Quaternion(M_PI*0.2f, Vector3::YAXIS));
840 Actor twig = ImageActor::New(CreateBitmapImage());
841 twig.SetName("twig");
842 branch.SetPosition(Vector3(20.0f, 30.0f, 40.0f));
844 Actor bug = Actor::New(); // Not a bone
846 bug.SetPosition(Vector3(10.0f, 10.0f, 10.0f));
848 Stage::GetCurrent().Add(trunk);
854 CreateMeshData(meshData); // Created with named bones (as above)
855 Mesh mesh = Mesh::New(meshData);
856 MeshActor meshActor = MeshActor::New(mesh);
857 Stage::GetCurrent().Add(meshActor);
859 meshActor.BindBonesToMesh(Stage::GetCurrent().GetRootLayer());
861 application.SendNotification();
862 application.Render(0);
863 application.Render();
864 application.SendNotification();
867 // Need to see what bone actor's node has set as world matrix.
869 Animation anim = Animation::New(1.0f);
870 anim.RotateBy(trunk, Radian(M_PI*0.5f), Vector3::ZAXIS);
872 application.SendNotification();
873 application.Render(500);
874 application.SendNotification();
875 application.Render(500);
876 application.SendNotification();
877 application.Render(10);
879 // All bones have moved.
880 // Check that their world matrix has been updated: ( Isn't IDENTITY )
881 DALI_TEST_CHECK( ! application.GetGlAbstraction().CheckUniformValue("uModelMatrix", Matrix::IDENTITY ) );
884 GLuint programId, uniformId;
885 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformIds("uModelMatrix", programId, uniformId) );
886 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue( programId, uniformId, worldMatrix) );
888 // But also check that property is calculated as needed:
889 Matrix calcWorldMatrix = twig.GetCurrentWorldMatrix();
890 DALI_TEST_CHECK( Matrix::IDENTITY != calcWorldMatrix );
891 DALI_TEST_CHECK( worldMatrix == calcWorldMatrix );
896 int UtcDaliMeshActorIndices(void)
898 TestApplication application;
899 Actor basicActor = Actor::New();
900 Mesh mesh = NewMesh();
901 MeshActor meshActor = MeshActor::New(mesh);
903 Property::IndexContainer indices;
904 meshActor.GetPropertyIndices( indices );
905 DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
906 DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
910 int UtcDaliAnimatableMeshActorIndices(void)
912 TestApplication application;
913 Actor basicActor = Actor::New();
914 AnimatableMesh mesh = NewAnimatableMesh();
915 MeshActor meshActor = MeshActor::New(mesh);
917 Property::IndexContainer indices;
918 meshActor.GetPropertyIndices( indices );
919 DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
920 DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );