本文整理汇总了C++中TexturePtr::reload方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::reload方法的具体用法?C++ TexturePtr::reload怎么用?C++ TexturePtr::reload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::reload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveWaterDepth
/// save water depth map
//-----------------------------------------------------------------------------------------------------------
void App::SaveWaterDepth()
{
if (scn->sc->fluids.empty())
{
gui->Delete(gcom->TrkDir()+"objects/waterDepth.png"); // no tex if no fluids
return;
}
Ogre::Timer ti;
// 2048 for bigger terrains ?
int w = 1024, h = w; float fh = h-1, fw = w-1;
using Ogre::uint;
uint *wd = new uint[w*h]; // water depth
register int x,y,a,i,ia,id;
register float fa,fd;
/// write to img -----------
// get ter height to fluid height difference for below
for (y = 0; y < h; ++y) { a = y*w;
for (x = 0; x < w; ++x, ++a)
{
// pos 0..1
float fx = float(y)/fh, fz = float(x)/fw;
// pos on ter -terSize..terSize
float w = scn->sc->td.fTerWorldSize;
float wx = (fx-0.5f) * w, wz = -(fz-0.5f) * w;
fa = 0.f; // fluid y pos
for (i=0; i < scn->sc->fluids.size(); ++i)
{
const FluidBox& fb = scn->sc->fluids[i];
const float sizex = fb.size.x*0.5f, sizez = fb.size.z*0.5f;
// check rect 2d - no rot ! todo: make 2nd type circle..
if (wx > fb.pos.x - sizex && wx < fb.pos.x + sizex &&
wz > fb.pos.z - sizez && wz < fb.pos.z + sizez)
{
float f = fb.pos.y - scn->terrain->getHeightAtTerrainPosition(fx,fz);
if (f > fa) fa = f;
}
} //par
fd = fa * 0.4f * 255.f; // depth far full at 2.5 m
fa = fa * 8.f * 255.f; // alpha near full at 1/8 m
ia = std::max(0, std::min(255, (int)fa )); // clamp
id = std::max(0, std::min(255, (int)fd ));
wd[a] = 0xFF000000 + /*0x01 */ ia + 0x0100 * id; // write
} }
Image im; // save img
im.loadDynamicImage((uchar*)wd, w,h,1, PF_BYTE_RGBA);
im.save(gcom->TrkDir()+"objects/waterDepth.png");
delete[] wd;
try {
TexturePtr tex = TextureManager::getSingleton().getByName("waterDepth.png");
if (!tex.isNull())
tex->reload();
else // 1st fluid after start, refresh matdef ?..
TextureManager::getSingleton().load("waterDepth.png", rgDef);
} catch(...) { }
LogO(String("::: Time WaterDepth: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");
}
示例2: LoadTrackEv
void App::LoadTrackEv()
{
Ogre::Timer ti;
NewCommon(false); // full destroy
iObjCur = -1;
scn->DestroyRoad();
scn->DestroyPace();
// load scene
scn->sc->LoadXml(gcom->TrkDir()+"scene.xml");
scn->sc->vdr = IsVdrTrack();
if (scn->sc->vdr) scn->sc->ter = false;
// water RTT recreate
scn->UpdateWaterRTT(mCamera);
BltWorldInit();
UpdWndTitle();
scn->CreateFluids();
scn->CreateWeather();
// set sky tex name for water
sh::MaterialInstance* m = mFactory->getMaterialInstance(scn->sc->skyMtr);
std::string skyTex = sh::retrieveValue<sh::StringValue>(m->getProperty("texture"), 0).get();
sh::Factory::getInstance().setTextureAlias("SkyReflection", skyTex);
sh::Factory::getInstance().setTextureAlias("CubeReflection", "ReflectionCube");
bNewHmap = false;/**/
scn->CreateTerrain(bNewHmap, scn->sc->ter);
if (track)
if (scn->sc->vdr) // vdrift track
{
if (!LoadTrackVdr(pSet->gui.track))
LogO("Error during track loading: " + pSet->gui.track);
CreateVdrTrack(pSet->gui.track, track);
CreateVdrTrackBlt();
}
// road ~
scn->road = new SplineRoad(this);
scn->road->Setup("sphere.mesh", pSet->road_sphr, scn->terrain, mSceneMgr, mCamera);
scn->road->LoadFile(gcom->TrkDir()+"road.xml");
scn->UpdPSSMMaterials();
// pace ~ ~
scn->pace = new PaceNotes(pSet);
scn->pace->Setup(mSceneMgr, mCamera, scn->terrain, gui->mGui, mWindow);
/// HW_Inst Test * * *
//inst = new Instanced();
//inst->Create(mSceneMgr,"sphere_inst.mesh");
CreateObjects();
if (pSet->bTrees && scn->sc->ter)
scn->CreateTrees(); // trees after objects so they aren't inside them
// updates after load
//--------------------------
gcom->ReadTrkStats();
gui->SetGuiFromXmls(); ///
Rnd2TexSetup();
//UpdVisGui();
//UpdStartPos();
UpdEditWnds(); //
try {
TexturePtr tex = TextureManager::getSingleton().getByName("waterDepth.png");
if (!tex.isNull())
tex->reload();
} catch(...) { }
gui->Status("#{Loaded}", 0.5,0.7,1.0);
if (pSet->check_load)
gui->WarningsCheck(scn->sc, scn->road);
LogO(String("::: Time Load Track: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");
}
示例3: LoadTrackEv
void App::LoadTrackEv()
{
QTimer ti; ti.update(); /// time
NewCommon(false); // full destroy
if (road)
{ road->Destroy(); delete road; road = 0; }
// load scene
sc->LoadXml(gcom->TrkDir()+"scene.xml");
sc->vdr = IsVdrTrack();
if (sc->vdr) sc->ter = false;
// water RTT recreate
UpdateWaterRTT(mCamera);
BltWorldInit();
UpdWndTitle();
CreateFluids();
CreateWeather();
// set sky tex name for water
sh::MaterialInstance* m = mFactory->getMaterialInstance(sc->skyMtr);
std::string skyTex = sh::retrieveValue<sh::StringValue>(m->getProperty("texture"), 0).get();
sh::Factory::getInstance().setTextureAlias("SkyReflection", skyTex);
sh::Factory::getInstance().setTextureAlias("CubeReflection", "ReflectionCube");
bNewHmap = false;/**/
CreateTerrain(bNewHmap,sc->ter);
if (sc->vdr) // vdrift track
{
if (!LoadTrackVdr(pSet->gui.track))
LogO("Error during track loading: " + pSet->gui.track);
CreateVdrTrack(pSet->gui.track, track);
CreateVdrTrackBlt();
}
// road ~
road = new SplineRoad(this);
road->Setup("sphere.mesh", 1.4f*pSet->road_sphr, terrain, mSceneMgr, mCamera);
road->LoadFile(gcom->TrkDir()+"road.xml");
UpdPSSMMaterials();
CreateObjects();
if (pSet->bTrees && sc->ter)
CreateTrees(); // trees after objects so they aren't inside them
// updates after load
//--------------------------
gcom->ReadTrkStats();
gui->SetGuiFromXmls(); ///
Rnd2TexSetup();
UpdVisGui();
LoadStartPos(gcom->TrkDir());
try {
TexturePtr tex = TextureManager::getSingleton().getByName("waterDepth.png");
if (!tex.isNull())
tex->reload();
} catch(...) { }
gui->Status("Loaded", 0.5,0.7,1.0);
if (pSet->check_load)
gui->WarningsCheck(sc,road);
ti.update(); /// time
float dt = ti.dt * 1000.f;
LogO(String("::: Time Load Track: ") + fToStr(dt,0,3) + " ms");
}