void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
	RAS_IRenderTools* rendertools, RAS_MeshSlot &ms)
{
	m_material->ActivateMeshSlot(ms, rasty);

	if (ms.m_pDeformer)
	{
		ms.m_pDeformer->Apply(m_material);
	//	KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_)
	}
	
	if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
		ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix));

	rendertools->PushMatrix();
	if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform())
	{
		rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
	}

	if (rasty->QueryLists())
		if (ms.m_DisplayList)
			ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified());

	// verify if we can use display list, not for deformed object, and
	// also don't create a new display list when drawing shadow buffers,
	// then it won't have texture coordinates for actual drawing. also
	// for zsort we can't make a display list, since the polygon order
	// changes all the time.
	if (ms.m_pDeformer && ms.m_pDeformer->IsDynamic())
		ms.m_bDisplayList = false;
	else if (!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW)
		ms.m_bDisplayList = false;
	else if (IsZSort())
		ms.m_bDisplayList = false;
	else if (m_material->UsesObjectColor() && ms.m_bObjectColor)
		ms.m_bDisplayList = false;
	else
		ms.m_bDisplayList = true;

	// for text drawing using faces
	if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
		rasty->IndexPrimitives_3DText(ms, m_material, rendertools);
	// for multitexturing
	else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL)))
		rasty->IndexPrimitivesMulti(ms);
	// use normal IndexPrimitives
	else
		rasty->IndexPrimitives(ms);

	if (rasty->QueryLists())
		if (ms.m_DisplayList)
			ms.m_mesh->SetMeshModified(false);

	rendertools->PopMatrix();
}
Exemple #2
0
void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer *rasty, RAS_MeshSlot *ms)
{
	RAS_MeshUser *meshUser = ms->m_meshUser;
	rasty->SetClientObject(meshUser->GetClientObject());
	rasty->SetFrontFace(meshUser->GetFrontFace());

	// Inverse condition of in ActivateMaterial.
	if (rasty->GetOverrideShader() == RAS_IRasterizer::RAS_OVERRIDE_SHADER_NONE) {
		bool uselights = m_material->UsesLighting(rasty);
		rasty->ProcessLighting(uselights, cameratrans);
		m_material->ActivateMeshSlot(ms, rasty);
	}
	else {
		// Set cull face without activating the material.
		rasty->SetCullFace(m_material->IsCullFace());
	}

	if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::RAS_SOLID) {
		ms->m_mesh->SortPolygons(ms, cameratrans * MT_Transform(meshUser->GetMatrix()));
		ms->m_displayArrayBucket->SetPolygonsModified(rasty);
	}

	rasty->PushMatrix();
	if ((!ms->m_pDeformer || !ms->m_pDeformer->SkipVertexTransform()) && !m_material->IsText()) {
		float mat[16];
		rasty->GetTransform(meshUser->GetMatrix(), m_material->GetDrawingMode(), mat);
		rasty->MultMatrix(mat);
	}

	if (m_material->IsText()) {
		rasty->IndexPrimitivesText(ms);
	}
	else {
		rasty->IndexPrimitives(ms);
	}

	rasty->PopMatrix();
}