diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index b633f9252d..c420d9469c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -70,7 +70,8 @@ static std::function createFunctions[] = CL(Sprite3DMirrorTest), CL(QuaternionTest), CL(Sprite3DEmptyTest), - CL(UseCaseSprite3D) + CL(UseCaseSprite3D), + CL(Sprite3DForceDepthTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -156,6 +157,42 @@ void Sprite3DTestDemo::backCallback(Ref* sender) s->release(); } +//------------------------------------------------------------------ +// +// Sprite3DForceDepthTest +// +//------------------------------------------------------------------ +Sprite3DForceDepthTest::Sprite3DForceDepthTest() +{ + auto orc = Sprite3D::create("Sprite3DTest/orc.c3b"); + orc->setScale(5); + orc->setNormalizedPosition(Vec2(.5,.3)); + orc->setPositionZ(40); + orc->setRotation3D(Vec3(0,180,0)); + orc->setGlobalZOrder(-1); + + addChild(orc); + + auto ship = Sprite3D::create("Sprite3DTest/boss1.obj"); + ship->setScale(5); + ship->setTexture("Sprite3DTest/boss.png"); + ship->setNormalizedPosition(Vec2(.5,.5)); + ship->setRotation3D(Vec3(90,0,0)); + ship->setForceDepthWrite(true); + + addChild(ship); +} + +std::string Sprite3DForceDepthTest::title() const +{ + return "Force Depth Write Test"; +} + +std::string Sprite3DForceDepthTest::subtitle() const +{ + return "Ship should always appear behind orc"; +} + //------------------------------------------------------------------ // // Sprite3DEmptyTest diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 812e84171c..c59cd4895d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -54,6 +54,15 @@ public: virtual void onEnter() override; }; +class Sprite3DForceDepthTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Sprite3DForceDepthTest); + Sprite3DForceDepthTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + class Sprite3DEmptyTest : public Sprite3DTestDemo { public: