示例#1
0
// Create per-CModel data for the model (and per-CModelDef data if necessary)
void* PolygonSortModelRenderer::CreateModelData(CModel* model)
{
    CModelDefPtr mdef = model->GetModelDef();
    PSModelDef* psmdef = (PSModelDef*)mdef->GetRenderData(m);

    if (!psmdef)
    {
        psmdef = new PSModelDef(mdef);
        mdef->SetRenderData(m, psmdef);
    }

    return new PSModel(model);
}
示例#2
0
// Build modeldef data if necessary - we have no per-CModel data
void* InstancingModelRenderer::CreateModelData(CModel* model)
{
	CModelDefPtr mdef = model->GetModelDef();
	IModelDef* imodeldef = (IModelDef*)mdef->GetRenderData(m);

	ENSURE(!model->IsSkinned());

	if (!imodeldef)
	{
		imodeldef = new IModelDef(mdef);
		mdef->SetRenderData(m, imodeldef);
	}

	return NULL;
}
// Build modeldef data if necessary - we have no per-CModel data
CModelRData* InstancingModelRenderer::CreateModelData(const void* key, CModel* model)
{
	CModelDefPtr mdef = model->GetModelDef();
	IModelDef* imodeldef = (IModelDef*)mdef->GetRenderData(m);

	if (m->gpuSkinning)
 		ENSURE(model->IsSkinned());
	else
		ENSURE(!model->IsSkinned());

	if (!imodeldef)
	{
		imodeldef = new IModelDef(mdef, m->gpuSkinning, m->calculateTangents);
		mdef->SetRenderData(m, imodeldef);
	}

	return new CModelRData(key);
}
示例#4
0
// Build model data (and modeldef data if necessary)
void* ShaderModelRenderer::CreateModelData(CModel* model)
{
	CModelDefPtr mdef = model->GetModelDef();
	ShaderModelDef* shadermodeldef = (ShaderModelDef*)mdef->GetRenderData(m);

	if (!shadermodeldef)
	{
		shadermodeldef = new ShaderModelDef(mdef);
		mdef->SetRenderData(m, shadermodeldef);
	}

	// Build the per-model data
	ShaderModel* shadermodel = new ShaderModel;

	shadermodel->m_Position.type = GL_FLOAT;
	shadermodel->m_Position.elems = 3;
	shadermodel->m_Array.AddAttribute(&shadermodel->m_Position);

	shadermodel->m_UV.type = GL_FLOAT;
	shadermodel->m_UV.elems = 2;
	shadermodel->m_Array.AddAttribute(&shadermodel->m_UV);

	shadermodel->m_Normal.type = GL_FLOAT;
	shadermodel->m_Normal.elems = 3;
	shadermodel->m_Array.AddAttribute(&shadermodel->m_Normal);

	shadermodel->m_Array.SetNumVertices(mdef->GetNumVertices());
	shadermodel->m_Array.Layout();

	// Fill in static UV coordinates
	VertexArrayIterator<float[2]> UVit = shadermodel->m_UV.GetIterator<float[2]>();

	ModelRenderer::BuildUV(mdef, UVit);

	return shadermodel;
}