本文整理汇总了C++中CModel::GetRenderData方法的典型用法代码示例。如果您正苦于以下问题:C++ CModel::GetRenderData方法的具体用法?C++ CModel::GetRenderData怎么用?C++ CModel::GetRenderData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::GetRenderData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareModels
void SortModelRenderer::PrepareModels()
{
CMatrix3D worldToCam;
if (m->models.size() == 0)
return;
g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam);
for(std::vector<SModel*>::iterator it = m->models.begin(); it != m->models.end(); ++it)
{
SModel* smdl = *it;
CModel* model = smdl->GetModel();
ENSURE(model->GetRenderData() == smdl);
m->vertexRenderer->UpdateModelData(model, smdl->m_Data, smdl->m_UpdateFlags);
smdl->m_UpdateFlags = 0;
CVector3D modelpos = model->GetTransform().GetTranslation();
modelpos = worldToCam.Transform(modelpos);
smdl->m_Distance = modelpos.Z;
}
PROFILE_START( "sorting transparent" );
std::sort(m->models.begin(), m->models.end(), SortModelsByDist());
PROFILE_END( "sorting transparent" );
}
示例2: PrepareModels
// Call update for all submitted models and enter the rendering phase
void ShaderModelRenderer::PrepareModels()
{
for (int cullGroup = 0; cullGroup < CRenderer::CULL_MAX; ++cullGroup)
{
for (size_t i = 0; i < m->submissions[cullGroup].size(); ++i)
{
CModel* model = m->submissions[cullGroup][i];
model->ValidatePosition();
CModelRData* rdata = static_cast<CModelRData*>(model->GetRenderData());
ENSURE(rdata->GetKey() == m->vertexRenderer.get());
m->vertexRenderer->UpdateModelData(model, rdata, rdata->m_UpdateFlags);
rdata->m_UpdateFlags = 0;
}
}
}
示例3: Render
//.........这里部分代码省略.........
// ensure they are definitely empty
std::fill(texBindings.begin(), texBindings.end(), CShaderProgram::Binding());
std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)NULL);
std::fill(texBindingNames.begin(), texBindingNames.end(), CStrIntern());
}
// bind the samplers to the shader
for (size_t s = 0; s < samplersNum; ++s)
{
const CMaterial::TextureSampler& samp = samplers[s];
CShaderProgram::Binding bind = texBindings[s];
// check that the handles are current
// and reevaluate them if necessary
if (texBindingNames[s] == samp.Name && bind.Active())
{
bind = texBindings[s];
}
else
{
bind = shader->GetTextureBinding(samp.Name);
texBindings[s] = bind;
texBindingNames[s] = samp.Name;
}
// same with the actual sampler bindings
CTexture* newTex = samp.Sampler.get();
if (bind.Active() && newTex != currentTexs[s])
{
shader->BindTexture(bind, samp.Sampler->GetHandle());
currentTexs[s] = newTex;
}
}
// Bind modeldef when it changes
CModelDef* newModeldef = model->GetModelDef().get();
if (newModeldef != currentModeldef)
{
currentModeldef = newModeldef;
m->vertexRenderer->PrepareModelDef(shader, streamflags, *currentModeldef);
}
// Bind all uniforms when any change
CShaderUniforms newStaticUniforms = model->GetMaterial().GetStaticUniforms();
if (newStaticUniforms != currentStaticUniforms)
{
currentStaticUniforms = newStaticUniforms;
currentStaticUniforms.BindUniforms(shader);
}
const CShaderRenderQueries& renderQueries = model->GetMaterial().GetRenderQueries();
for (size_t q = 0; q < renderQueries.GetSize(); q++)
{
CShaderRenderQueries::RenderQuery rq = renderQueries.GetItem(q);
if (rq.first == RQUERY_TIME)
{
CShaderProgram::Binding binding = shader->GetUniformBinding(rq.second);
if (binding.Active())
{
double time = g_Renderer.GetTimeManager().GetGlobalTime();
shader->Uniform(binding, time, 0,0,0);
}
}
else if (rq.first == RQUERY_WATER_TEX)
{
WaterManager* WaterMgr = g_Renderer.GetWaterManager();
double time = WaterMgr->m_WaterTexTimer;
double period = 1.6;
int curTex = (int)(time*60/period) % 60;
if (WaterMgr->m_RenderWater && WaterMgr->WillRenderFancyWater())
shader->BindTexture(str_waterTex, WaterMgr->m_NormalMap[curTex]);
else
shader->BindTexture(str_waterTex, g_Renderer.GetTextureManager().GetErrorTexture());
}
else if (rq.first == RQUERY_SKY_CUBE)
{
shader->BindTexture(str_skyCube, g_Renderer.GetSkyManager()->GetSkyCube());
}
}
modifier->PrepareModel(shader, model);
CModelRData* rdata = static_cast<CModelRData*>(model->GetRenderData());
ENSURE(rdata->GetKey() == m->vertexRenderer.get());
m->vertexRenderer->RenderModel(shader, streamflags, model, rdata);
}
}
m->vertexRenderer->EndPass(streamflags);
currentTech->EndPass(pass);
}
idxTechStart = idxTechEnd;
}
}
}