当前位置: 首页>>代码示例>>C++>>正文


C++ CModel::GetModelDef方法代码示例

本文整理汇总了C++中CModel::GetModelDef方法的典型用法代码示例。如果您正苦于以下问题:C++ CModel::GetModelDef方法的具体用法?C++ CModel::GetModelDef怎么用?C++ CModel::GetModelDef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CModel的用法示例。


在下文中一共展示了CModel::GetModelDef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

// Render submitted models (filtered by flags) using the given modifier
void SortModelRenderer::Render(const RenderModifierPtr& modifier, int flags)
{
    int pass = 0;

    if (m->models.size() == 0)
        return;

    do
    {
        int streamflags = modifier->BeginPass(pass);
        CModelDefPtr lastmdef;
        CTexturePtr lasttex;

        m->vertexRenderer->BeginPass(streamflags);

        for(std::vector<SModel*>::iterator it = m->models.begin(); it != m->models.end(); ++it)
        {
            SModel* smdl = *it;
            CModel* mdl = smdl->GetModel();

            if (flags && !(mdl->GetFlags() & flags))
                continue;

            ENSURE(smdl->GetKey() == m);

            CModelDefPtr mdef = mdl->GetModelDef();
            CTexturePtr tex = mdl->GetTexture();

            // Prepare per-CModelDef data if changed
            if (mdef != lastmdef)
            {
                m->vertexRenderer->PrepareModelDef(streamflags, mdef);
                lastmdef = mdef;
            }

            // Prepare necessary RenderModifier stuff
            if (tex != lasttex)
            {
                modifier->PrepareTexture(pass, tex);
                lasttex = tex;
            }

            modifier->PrepareModel(pass, mdl);

            // Render the model
            m->vertexRenderer->RenderModel(streamflags, mdl, smdl->m_Data);
        }

        m->vertexRenderer->EndPass(streamflags);
    } while(!modifier->EndPass(pass++));
}
开发者ID:,项目名称:,代码行数:52,代码来源:

示例2: BackToFrontIndexSort

float PSModel::BackToFrontIndexSort(const CMatrix3D& worldToCam)
{
    static std::vector<IntFloatPair> IndexSorter;

    CModelDefPtr mdef = m_Model->GetModelDef();
    size_t numFaces = mdef->GetNumFaces();
    const SModelFace* faces = mdef->GetFaces();

    if (IndexSorter.size() < numFaces)
        IndexSorter.resize(numFaces);

    VertexArrayIterator<CVector3D> Position = m_Position.GetIterator<CVector3D>();
    CVector3D tmpvtx;

    for(size_t i = 0; i < numFaces; ++i)
    {
        tmpvtx = Position[faces[i].m_Verts[0]];
        tmpvtx += Position[faces[i].m_Verts[1]];
        tmpvtx += Position[faces[i].m_Verts[2]];
        tmpvtx *= 1.0f/3.0f;

        tmpvtx = worldToCam.Transform(tmpvtx);
        float distsqrd = SQR(tmpvtx.X)+SQR(tmpvtx.Y)+SQR(tmpvtx.Z);

        IndexSorter[i].first = (int)i;
        IndexSorter[i].second = distsqrd;
    }

    std::sort(IndexSorter.begin(),IndexSorter.begin()+numFaces,SortFacesByDist());

    // now build index list
    size_t idxidx = 0;
    for (size_t i = 0; i < numFaces; ++i) {
        const SModelFace& face = faces[IndexSorter[i].first];
        m_Indices[idxidx++] = (u16)(face.m_Verts[0]);
        m_Indices[idxidx++] = (u16)(face.m_Verts[1]);
        m_Indices[idxidx++] = (u16)(face.m_Verts[2]);
    }

    return IndexSorter[0].second;
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例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;
		}
	}
}
开发者ID:righnatios,项目名称:0ad,代码行数:101,代码来源:ModelRenderer.cpp


注:本文中的CModel::GetModelDef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。