Skip to content

Commit bdc6bd2

Browse files
committed
Tests: convert BillboardTextureCoords VTest to Unit Test
1 parent 13e17a4 commit bdc6bd2

File tree

4 files changed

+37
-69
lines changed

4 files changed

+37
-69
lines changed

Tests/OgreMain/src/General.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ THE SOFTWARE.
5454

5555
#include "OgreKeyFrame.h"
5656

57+
#include "OgreBillboardSet.h"
58+
#include "OgreBillboard.h"
59+
5760
#include <random>
5861
using std::minstd_rand;
5962

@@ -659,3 +662,37 @@ TEST(GpuProgramParams, Variability)
659662

660663
EXPECT_EQ(params.getConstantDefinition("parameter").variability, GPV_PER_OBJECT);
661664
}
665+
666+
TEST(Billboard, TextureCoords)
667+
{
668+
Root root("");
669+
MaterialManager::getSingleton().initialise();
670+
671+
float xsegs = 3;
672+
float ysegs = 3;
673+
BillboardSet bbs("name");
674+
bbs.setTextureStacksAndSlices(ysegs, xsegs);
675+
676+
auto& texcoords = bbs.getTextureCoords();
677+
678+
679+
float width = 300;
680+
float height = 300;
681+
float gap = 20;
682+
683+
for (int y = 0; y < ysegs; ++y)
684+
{
685+
for (int x = 0; x < xsegs; ++x)
686+
{
687+
FloatRect ref((x + 0) / xsegs, (ysegs - y - 1) / ysegs, // uv
688+
(x + 1) / xsegs, (ysegs - y - 0) / ysegs);
689+
auto& genRect = texcoords[(ysegs - y - 1)*xsegs + x];
690+
EXPECT_EQ(genRect, ref);
691+
692+
// only for visualisation
693+
Billboard* bb = bbs.createBillboard({(x * width / xsegs) + ((x - 1) * gap), // position
694+
(y * height / ysegs) + ((y - 1) * gap), 0});
695+
bb->setTexcoordIndex((ysegs - y - 1)*xsegs + x);
696+
}
697+
}
698+
}

Tests/VisualTests/PlayPen/include/PlayPenTests.h

-14
Original file line numberDiff line numberDiff line change
@@ -636,20 +636,6 @@ class _OgreSampleClassExport PlayPen_ReloadResources : public VisualTest
636636

637637
};
638638

639-
//------------------------------------------------------------------------------
640-
/** Tests billboard texture coordinates */
641-
class _OgreSampleClassExport PlayPen_BillboardTextureCoords : public VisualTest
642-
{
643-
public:
644-
645-
PlayPen_BillboardTextureCoords();
646-
647-
protected:
648-
649-
void setupContent() override;
650-
651-
};
652-
653639
//------------------------------------------------------------------------------
654640
/** Tests particles with an RTT reflection */
655641
class _OgreSampleClassExport PlayPen_ReflectedBillboards : public VisualTest

Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ PlaypenTestPlugin::PlaypenTestPlugin()
4545
addSample(new PlayPen_BillboardAccurateFacing()); // blocks are not lit (no darkness)
4646
addSample(new PlayPen_BillboardChain());
4747
addSample(new PlayPen_BillboardOrigins());
48-
addSample(new PlayPen_BillboardTextureCoords());
4948
addSample(new PlayPen_BillboardText());
5049
addSample(new PlayPen_BlendDiffuseColour());
5150
addSample(new PlayPen_BlitSubTextures()); // center tex missing

Tests/VisualTests/PlayPen/src/PlayPenTests.cpp

-54
Original file line numberDiff line numberDiff line change
@@ -1633,60 +1633,6 @@ void PlayPen_BillboardOrigins::setupContent()
16331633
//----------------------------------------------------------------------------
16341634
//----------------------------------------------------------------------------
16351635

1636-
PlayPen_BillboardTextureCoords::PlayPen_BillboardTextureCoords()
1637-
{
1638-
mInfo["Title"] = "PlayPen_BillboardTextureCoords";
1639-
mInfo["Description"] = "Tests setting billboard texture coordinates.";
1640-
addScreenshotFrame(10);
1641-
}
1642-
//----------------------------------------------------------------------------
1643-
1644-
void PlayPen_BillboardTextureCoords::setupContent()
1645-
{
1646-
mSceneMgr->setAmbientLight(ColourValue::White);
1647-
1648-
BillboardSet* bbs = mSceneMgr->createBillboardSet("test");
1649-
BillboardSet* bbs2 = mSceneMgr->createBillboardSet("test2");
1650-
float xsegs = 3;
1651-
float ysegs = 3;
1652-
float width = 300;
1653-
float height = 300;
1654-
float gap = 20;
1655-
1656-
// set up texture coords
1657-
bbs->setTextureStacksAndSlices(ysegs, xsegs);
1658-
bbs->setDefaultDimensions(width/xsegs, height/xsegs);
1659-
bbs2->setDefaultDimensions(width/xsegs, height/xsegs);
1660-
1661-
for (int y = 0; y < ysegs; ++y)
1662-
{
1663-
for (int x = 0; x < xsegs; ++x)
1664-
{
1665-
Vector3 midPoint;
1666-
midPoint.x = (x * width / xsegs) + ((x-1) * gap);
1667-
midPoint.y = (y * height / ysegs) + ((y-1) * gap);
1668-
midPoint.z = 0;
1669-
Billboard* bb = bbs->createBillboard(midPoint);
1670-
bb->setTexcoordIndex((ysegs - y - 1)*xsegs + x);
1671-
Billboard* bb2 = bbs2->createBillboard(midPoint);
1672-
bb2->setTexcoordRect(
1673-
FloatRect((x + 0) / xsegs, (ysegs - y - 1) / ysegs,
1674-
(x + 1) / xsegs, (ysegs - y - 0) / ysegs));
1675-
}
1676-
}
1677-
1678-
bbs->setMaterialName("Examples/OgreLogo");
1679-
bbs2->setMaterialName("Examples/OgreLogo");
1680-
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(bbs);
1681-
mSceneMgr->getRootSceneNode()
1682-
->createChildSceneNode(Vector3(- (width + xsegs * gap), 0, 0))
1683-
->attachObject(bbs2);
1684-
1685-
mCameraNode->setPosition(-100,150,900);
1686-
}
1687-
//----------------------------------------------------------------------------
1688-
//----------------------------------------------------------------------------
1689-
16901636
PlayPen_BlendDiffuseColour::PlayPen_BlendDiffuseColour()
16911637
{
16921638
mInfo["Title"] = "PlayPen_BlendDiffuseColour";

0 commit comments

Comments
 (0)