Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: convert BillboardTextureCoords VTest to Unit Test #3000

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Tests/OgreMain/src/General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ THE SOFTWARE.

#include "OgreKeyFrame.h"

#include "OgreBillboardSet.h"
#include "OgreBillboard.h"

#include <random>
using std::minstd_rand;

Expand Down Expand Up @@ -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);
}
}
}
14 changes: 0 additions & 14 deletions Tests/VisualTests/PlayPen/include/PlayPenTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Tests/VisualTests/PlayPen/src/PlayPenTestPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 0 additions & 54 deletions Tests/VisualTests/PlayPen/src/PlayPenTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down