diff --git a/Tests/OgreMain/src/General.cpp b/Tests/OgreMain/src/General.cpp index 9e9b570b0a4..85c04cc6fb3 100644 --- a/Tests/OgreMain/src/General.cpp +++ b/Tests/OgreMain/src/General.cpp @@ -54,6 +54,9 @@ THE SOFTWARE. #include "OgreKeyFrame.h" +#include "OgreBillboardSet.h" +#include "OgreBillboard.h" + #include using std::minstd_rand; @@ -659,3 +662,37 @@ TEST(GpuProgramParams, Variability) EXPECT_EQ(params.getConstantDefinition("parameter").variability, GPV_PER_OBJECT); } + +TEST(Billboard, TextureCoords) +{ + Root root(""); + MaterialManager::getSingleton().initialise(); + + float xsegs = 3; + float ysegs = 3; + BillboardSet bbs("name"); + bbs.setTextureStacksAndSlices(ysegs, xsegs); + + auto& texcoords = bbs.getTextureCoords(); + + + float width = 300; + float height = 300; + float gap = 20; + + for (int y = 0; y < ysegs; ++y) + { + for (int x = 0; x < xsegs; ++x) + { + FloatRect ref((x + 0) / xsegs, (ysegs - y - 1) / ysegs, // uv + (x + 1) / xsegs, (ysegs - y - 0) / ysegs); + auto& genRect = texcoords[(ysegs - y - 1)*xsegs + x]; + EXPECT_EQ(genRect, ref); + + // only for visualisation + Billboard* bb = bbs.createBillboard({(x * width / xsegs) + ((x - 1) * gap), // position + (y * height / ysegs) + ((y - 1) * gap), 0}); + bb->setTexcoordIndex((ysegs - y - 1)*xsegs + x); + } + } +} \ No newline at end of file diff --git a/Tests/VisualTests/PlayPen/include/PlayPenTests.h b/Tests/VisualTests/PlayPen/include/PlayPenTests.h index b95b5e88ac2..29f63743d8e 100644 --- a/Tests/VisualTests/PlayPen/include/PlayPenTests.h +++ b/Tests/VisualTests/PlayPen/include/PlayPenTests.h @@ -636,20 +636,6 @@ class _OgreSampleClassExport PlayPen_ReloadResources : public VisualTest }; -//------------------------------------------------------------------------------ -/** Tests billboard texture coordinates */ -class _OgreSampleClassExport PlayPen_BillboardTextureCoords : public VisualTest -{ -public: - - PlayPen_BillboardTextureCoords(); - -protected: - - void setupContent() override; - -}; - //------------------------------------------------------------------------------ /** Tests particles with an RTT reflection */ class _OgreSampleClassExport PlayPen_ReflectedBillboards : public VisualTest diff --git a/Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp b/Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp index ad66b964b30..571e0b0bd6c 100644 --- a/Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp +++ b/Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp @@ -45,7 +45,6 @@ PlaypenTestPlugin::PlaypenTestPlugin() addSample(new PlayPen_BillboardAccurateFacing()); // blocks are not lit (no darkness) addSample(new PlayPen_BillboardChain()); addSample(new PlayPen_BillboardOrigins()); - addSample(new PlayPen_BillboardTextureCoords()); addSample(new PlayPen_BillboardText()); addSample(new PlayPen_BlendDiffuseColour()); addSample(new PlayPen_BlitSubTextures()); // center tex missing diff --git a/Tests/VisualTests/PlayPen/src/PlayPenTests.cpp b/Tests/VisualTests/PlayPen/src/PlayPenTests.cpp index c3d9a369454..a03d8e429e1 100644 --- a/Tests/VisualTests/PlayPen/src/PlayPenTests.cpp +++ b/Tests/VisualTests/PlayPen/src/PlayPenTests.cpp @@ -1633,60 +1633,6 @@ void PlayPen_BillboardOrigins::setupContent() //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -PlayPen_BillboardTextureCoords::PlayPen_BillboardTextureCoords() -{ - mInfo["Title"] = "PlayPen_BillboardTextureCoords"; - mInfo["Description"] = "Tests setting billboard texture coordinates."; - addScreenshotFrame(10); -} -//---------------------------------------------------------------------------- - -void PlayPen_BillboardTextureCoords::setupContent() -{ - mSceneMgr->setAmbientLight(ColourValue::White); - - BillboardSet* bbs = mSceneMgr->createBillboardSet("test"); - BillboardSet* bbs2 = mSceneMgr->createBillboardSet("test2"); - float xsegs = 3; - float ysegs = 3; - float width = 300; - float height = 300; - float gap = 20; - - // set up texture coords - bbs->setTextureStacksAndSlices(ysegs, xsegs); - bbs->setDefaultDimensions(width/xsegs, height/xsegs); - bbs2->setDefaultDimensions(width/xsegs, height/xsegs); - - for (int y = 0; y < ysegs; ++y) - { - for (int x = 0; x < xsegs; ++x) - { - Vector3 midPoint; - midPoint.x = (x * width / xsegs) + ((x-1) * gap); - midPoint.y = (y * height / ysegs) + ((y-1) * gap); - midPoint.z = 0; - Billboard* bb = bbs->createBillboard(midPoint); - bb->setTexcoordIndex((ysegs - y - 1)*xsegs + x); - Billboard* bb2 = bbs2->createBillboard(midPoint); - bb2->setTexcoordRect( - FloatRect((x + 0) / xsegs, (ysegs - y - 1) / ysegs, - (x + 1) / xsegs, (ysegs - y - 0) / ysegs)); - } - } - - bbs->setMaterialName("Examples/OgreLogo"); - bbs2->setMaterialName("Examples/OgreLogo"); - mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(bbs); - mSceneMgr->getRootSceneNode() - ->createChildSceneNode(Vector3(- (width + xsegs * gap), 0, 0)) - ->attachObject(bbs2); - - mCameraNode->setPosition(-100,150,900); -} -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- - PlayPen_BlendDiffuseColour::PlayPen_BlendDiffuseColour() { mInfo["Title"] = "PlayPen_BlendDiffuseColour";