本文整理汇总了C++中OverlayElement::setColour方法的典型用法代码示例。如果您正苦于以下问题:C++ OverlayElement::setColour方法的具体用法?C++ OverlayElement::setColour怎么用?C++ OverlayElement::setColour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OverlayElement
的用法示例。
在下文中一共展示了OverlayElement::setColour方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _setOverlay
void _setOverlay(void)
{
mOverlayMgr = OverlayManager::getSingletonPtr();
mTextOverlay = mOverlayMgr->create("TextOverlay");
mPanel = static_cast<Ogre::OverlayContainer*>(mOverlayMgr->createOverlayElement("Panel", "container1"));
mPanel->setDimensions(1, 1);
mPanel->setPosition(-0.3f, 0.5f);
OverlayElement* textBox = mOverlayMgr->createOverlayElement("TextArea", "TextID");
textBox->setMetricsMode(Ogre::GMM_PIXELS);
textBox->setPosition(10, 10);
textBox->setWidth(100);
textBox->setHeight(20);
textBox->setParameter("font_name", "Font/NanumBold18");
textBox->setParameter("char_height", "40");
textBox->setColour(Ogre::ColourValue::White);
textBox->setCaption(L"한국산업기술대학교 이대현 선수");
mPanel->addChild(textBox);
mTextOverlay->add2D(mPanel);
mTextOverlay->show();
mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/KPU_LOGO");
mLogoOverlay->show();
mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/Information");
mLogoOverlay->show();
}
示例2: update
bool TruckHUD::update(float dt, Beam *truck, bool visible)
{
OverlayElement *overlayElement = 0;
// only update every 300 ms
if (visible)
{
updatetime -= dt;
if (updatetime <= 0.0f)
{
// update now, reset timer
updatetime = 0.3f;
} else
{
// don't update visuals, only count stats
visible = false;
}
}
if (visible)
{
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Truckname");
overlayElement->setCaption(truck->getTruckName());
checkOverflow(overlayElement);
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Truckauthor");
overlayElement->setCaption(_L("(no author information available)"));
std::vector<authorinfo_t> file_authors = truck->getAuthors();
if (!file_authors.empty())
{
String authors = "";
for (std::vector<authorinfo_t>::iterator it = file_authors.begin(); it != file_authors.end(); ++it)
{
authors += (*it).name + " ";
}
overlayElement->setCaption(_L("Authors: ") + authors);
}
checkOverflow(overlayElement);
std::vector<std::string> description = truck->getDescription();
for (unsigned int i=1; i < 3; i++)
{
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/DescriptionLine" + TOSTRING(i+1));
overlayElement->setCaption("");
if (i < description.size())
{
overlayElement->setCaption(ANSI_TO_UTF(description[i]));
}
checkOverflow(overlayElement);
}
beam_t *beam = truck->getBeams();
float average_deformation = 0.0f;
float beamstress = 0.0f;
float current_deformation = 0.0f;
float mass = truck->getTotalMass();
int beamCount = truck->getBeamCount();
int beambroken = 0;
int beamdeformed = 0;
for (int i=0; i < beamCount; i++, beam++)
{
if (beam->broken != 0)
{
beambroken++;
}
beamstress += beam->stress;
current_deformation = fabs(beam->L-beam->refL);
if (fabs(current_deformation) > 0.0001f && beam->type != BEAM_HYDRO && beam->type != BEAM_INVISIBLE_HYDRO)
{
beamdeformed++;
}
average_deformation += current_deformation;
}
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamTotal");
overlayElement->setCaption(_L("beam count: ") + TOUTFSTRING(beamCount));
checkOverflow(overlayElement);
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamBroken");
overlayElement->setCaption(_L("broken: ") + TOUTFSTRING(beambroken) + U(" (") + TOUTFSTRING(Round((float)beambroken / (float)beamCount, 2) * 100.0f) + U("%)"));
checkOverflow(overlayElement);
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
float health = ((float)beambroken / (float)beamCount) * 10.0f + ((float)beamdeformed / (float)beamCount);
if (health < 1.0f)
{
overlayElement->setCaption(_L("health: ") + TOUTFSTRING(Round((1.0f - health) * 100.0f, 2)) + U("%"));
overlayElement->setColour(ColourValue(0.6f, 0.8f, 0.4f, 1.0f));
} else if (health >= 1.0f)
{
health = ((float)beambroken / (float)beamCount) * 3.0f;
health = std::min(health, 1.0f);
overlayElement->setCaption(_L("destruction: ") + TOUTFSTRING(Round(health * 100.0f, 2)) + U("%"));
overlayElement->setColour(ColourValue(0.8f, 0.4f, 0.4f, 1.0f));
}
checkOverflow(overlayElement);
overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamDeformed");
//.........这里部分代码省略.........
示例3: update
//.........这里部分代码省略.........
float mass = truck->getTotalMass();
for(int i=0; i<beamCount; i++, beam++)
{
if(beam->broken != 0)
beambroken++;
beamstress += beam->stress;
current_deformation = fabs(beam->L-beam->refL);
if (fabs(current_deformation) > 0.0001f && beam->type != BEAM_HYDRO && beam->type != BEAM_INVISIBLE_HYDRO) beamdeformed++;
average_deformation += current_deformation;
}
wchar_t beamcountstr[256];
swprintf(beamcountstr, 256, L"%d", beamCount);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamTotal");
descl->setCaption(_L("beam count: ") + UTFString(beamcountstr));
checkOverflow(descl);
wchar_t beambrokenstr[256];
swprintf(beambrokenstr, 256, L"%0.2f", ((float)beambroken/(float)beamCount)*100);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamBroken");
descl->setCaption(_L("broken: ") + TOUTFSTRING(beambroken) + U(" (") + UTFString(beambrokenstr) + U("%)"));
checkOverflow(descl);
wchar_t beamhealthstr[256];
float health = ((float)beambroken/(float)beamCount) * 10 + ((float)beamdeformed/(float)beamCount);
if(health<1)
{
swprintf(beamhealthstr, 256, L"%0.2f", (1-health)*100);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
descl->setCaption(_L("health: ") + UTFString(beamhealthstr) + U("%"));
checkOverflow(descl);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
descl->setColour(ColourValue(0.6,0.8,0.4,1));
checkOverflow(descl);
}else if(health>1)
{
health = ((float)beambroken/(float)beamCount) * 3;
if(health>1)
health=1;
swprintf(beamhealthstr, 256, L"%0.2f", (health)*100);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
descl->setCaption(_L("destruction: ") + UTFString(beamhealthstr) + U("%"));
checkOverflow(descl);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
descl->setColour(ColourValue(0.8,0.4,0.4,1));
checkOverflow(descl);
}
wchar_t beamdeformedstr[256];
swprintf(beamdeformedstr, 256, L"%0.2f", ((float)beamdeformed/(float)beamCount)*100);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamDeformed");
descl->setCaption(_L("deformed: ") + TOUTFSTRING(beamdeformed) + U(" (") + UTFString(beamdeformedstr) + U("%)"));
checkOverflow(descl);
wchar_t beamavdeformedstr[256];
swprintf(beamavdeformedstr, 256, L"%0.4f", ((float)average_deformation/(float)beamCount));
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageBeamDeformation");
descl->setCaption(_L("average deformation: ") + UTFString(beamavdeformedstr));
checkOverflow(descl);
wchar_t beamstressstr[256];
swprintf(beamstressstr, 256, L"%+08.0f", 1-(float)beamstress/(float)beamCount);
descl = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageBeamStress");
descl->setCaption(_L("average stress: ") + UTFString(beamstressstr));
checkOverflow(descl);