本文整理汇总了C++中IDriver::setupModelMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ IDriver::setupModelMatrix方法的具体用法?C++ IDriver::setupModelMatrix怎么用?C++ IDriver::setupModelMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDriver
的用法示例。
在下文中一共展示了IDriver::setupModelMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//*******************************************************************************
void CWaterEnvMap::update(TGlobalAnimationTime time, IDriver &driver)
{
if (_LastRenderTime == time) return;
_LastRenderTime = time;
// First five updates are used to render the cubemap faces (bottom face is not rendered)
// Sixth update project the cubemap into a 2D texture
uint numTexToRender;
if (_UpdateTime > 0)
{
uint64 currRenderTick = (uint64) (time / (_UpdateTime / (NUM_FACES_TO_RENDER + 1)));
numTexToRender = (uint) (currRenderTick - _LastRenderTick);
_LastRenderTick = currRenderTick;
}
else
{
numTexToRender = NUM_FACES_TO_RENDER + 1;
}
if (!numTexToRender) return;
if (_NumRenderedFaces == 0)
{
_StartRenderTime = time;
}
uint lastCubeFacesToRender = std::min((uint) NUM_FACES_TO_RENDER, _NumRenderedFaces + numTexToRender); // we don't render negative Z (only top hemisphere is used)
for(uint k = _NumRenderedFaces; k < lastCubeFacesToRender; ++k)
{
driver.setRenderTarget(_EnvCubic, 0, 0, _EnvCubicSize, _EnvCubicSize, 0, (uint32) k);
render((CTextureCube::TFace) k, _StartRenderTime);
}
_NumRenderedFaces = lastCubeFacesToRender;
if (_NumRenderedFaces == NUM_FACES_TO_RENDER && (_NumRenderedFaces + numTexToRender) > NUM_FACES_TO_RENDER)
{
// render to 2D map
driver.setRenderTarget(_Env2D, 0, 0, _Env2DSize, _Env2DSize);
doInit();
//
driver.activeVertexProgram(NULL);
driver.activeVertexBuffer(_FlattenVB);
driver.activeIndexBuffer(_FlattenIB);
driver.setFrustum(-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, false);
driver.setupViewMatrix(CMatrix::Identity);
CMatrix mat;
//mat.scale(0.8f);
driver.setupModelMatrix(mat);
_MaterialPassThru.setTexture(0, _EnvCubic);
_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, _Alpha));
driver.renderTriangles(_MaterialPassThru, 0, FVB_NUM_TRIS);
_NumRenderedFaces = 0; // start to render again
}
driver.setRenderTarget(NULL);
}
示例2: tempDumpColPolys
// TMP TMP
void tempDumpColPolys()
{
CPackedWorld *pw = R2::getEditor().getIslandCollision().getPackedIsland();
if (pw)
{
static CMaterial material;
static CMaterial wiredMaterial;
static CMaterial texturedMaterial;
static CVertexBuffer vb;
static bool initDone = false;
if (!initDone)
{
vb.setVertexFormat(CVertexBuffer::PositionFlag);
vb.setPreferredMemory(CVertexBuffer::AGPVolatile, false);
material.initUnlit();
material.setDoubleSided(true);
material.setZFunc(CMaterial::lessequal);
wiredMaterial.initUnlit();
wiredMaterial.setDoubleSided(true);
wiredMaterial.setZFunc(CMaterial::lessequal);
wiredMaterial.setColor(CRGBA(255, 255, 255, 250));
wiredMaterial.texEnvOpAlpha(0, CMaterial::Replace);
wiredMaterial.texEnvArg0Alpha(0, CMaterial::Diffuse, CMaterial::SrcAlpha);
wiredMaterial.setBlend(true);
wiredMaterial.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
texturedMaterial.initUnlit();
texturedMaterial.setDoubleSided(true);
texturedMaterial.setZFunc(CMaterial::lessequal);
initDone = true;
}
// just add a projected texture
R2::getEditor().getIslandCollision().loadEntryPoints();
R2::CScenarioEntryPoints &sep = R2::CScenarioEntryPoints::getInstance();
CVectorD playerPos = UserEntity->pos();
R2::CScenarioEntryPoints::CCompleteIsland *island = sep.getCompleteIslandFromCoords(CVector2f((float) playerPos.x, (float) playerPos.y));
static CSString currIsland;
if (island && island->Island != currIsland)
{
currIsland = island->Island;
CTextureFile *newTex = new CTextureFile(currIsland + "_sp.tga");
newTex->setWrapS(ITexture::Clamp);
newTex->setWrapT(ITexture::Clamp);
texturedMaterial.setTexture(0, newTex);
texturedMaterial.texEnvOpRGB(0, CMaterial::Replace);
texturedMaterial.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
texturedMaterial.setTexCoordGen(0, true);
texturedMaterial.setTexCoordGenMode(0, CMaterial::TexCoordGenObjectSpace);
CMatrix mat;
CVector scale((float) (island->XMax - island->XMin),
(float) (island->YMax - island->YMin), 0.f);
scale.x = 1.f / favoid0(scale.x);
scale.y = 1.f / favoid0(scale.y);
scale.z = 0.f;
mat.setScale(scale);
mat.setPos(CVector(- island->XMin * scale.x, - island->YMin * scale.y, 0.f));
//
CMatrix uvScaleMat;
//
uint texWidth = (uint) (island->XMax - island->XMin);
uint texHeight = (uint) (island->YMax - island->YMin);
float UScale = (float) texWidth / raiseToNextPowerOf2(texWidth);
float VScale = (float) texHeight / raiseToNextPowerOf2(texHeight);
//
uvScaleMat.setScale(CVector(UScale, - VScale, 0.f));
uvScaleMat.setPos(CVector(0.f, VScale, 0.f));
//
texturedMaterial.enableUserTexMat(0, true);
texturedMaterial.setUserTexMat(0, uvScaleMat * mat);
}
const CFrustum &frust = MainCam.getFrustum();
//
IDriver *driver = ((CDriverUser *) Driver)->getDriver();
driver->enableFog(true);
const CRGBA clearColor = CRGBA(0, 0, 127, 0);
driver->setupFog(frust.Far * 0.8f, frust.Far, clearColor);
CViewport vp;
vp.init(0.f, 0.f, 1.f, 1.f);
driver->setupViewport(vp);
CScissor scissor;
viewportToScissor(vp, scissor);
driver->setupScissor(scissor);
//
driver->setFrustum(frust.Left, frust.Right, frust.Bottom, frust.Top, frust.Near, frust.Far, frust.Perspective);
driver->setupViewMatrix(MainCam.getMatrix().inverted());
driver->setupModelMatrix(CMatrix::Identity);
//
//
const CVector localFrustCorners[8] =
{
CVector(frust.Left, frust.Near, frust.Top),
CVector(frust.Right, frust.Near, frust.Top),
CVector(frust.Right, frust.Near, frust.Bottom),
CVector(frust.Left, frust.Near, frust.Bottom),
CVector(frust.Left * frust.Far / frust.Near, frust.Far, frust.Top * frust.Far / frust.Near),
CVector(frust.Right * frust.Far / frust.Near, frust.Far, frust.Top * frust.Far / frust.Near),
CVector(frust.Right * frust.Far / frust.Near, frust.Far, frust.Bottom * frust.Far / frust.Near),
CVector(frust.Left * frust.Far / frust.Near, frust.Far, frust.Bottom * frust.Far / frust.Near)
//.........这里部分代码省略.........