Пример #1
0
void Model::Render(const matrix4x4f &trans, RenderData *rd)
{
	//update color parameters (materials are shared by model instances)
	if (m_curPattern) {
		for (MaterialContainer::const_iterator it = m_materials.begin(); it != m_materials.end(); ++it) {
			if ((*it).second->GetDescriptor().usePatterns) {
				(*it).second->texture4 = m_colorMap.GetTexture();
				(*it).second->texture3 = m_curPattern;
			}
		}
	}

	//update decals (materials and geometries are shared)
	for (unsigned int i=0; i < MAX_DECAL_MATERIALS; i++)
		if (m_decalMaterials[i].Valid())
			m_decalMaterials[i]->texture0 = m_curDecals[i];

	//Override renderdata if this model is called from ModelNode
	RenderData *params = (rd != 0) ? rd : &m_renderData;

	m_renderer->SetBlendMode(Graphics::BLEND_SOLID);
	m_renderer->SetTransform(trans);
	//using the entire model bounding radius for all nodes at the moment.
	//BR could also be a property of Node.
	params->boundingRadius = GetDrawClipRadius();

	//render in two passes, if this is the top-level model
	if (params->nodemask & MASK_IGNORE) {
		m_root->Render(trans, params);
	} else {
		params->nodemask = NODE_SOLID;
		m_root->Render(trans, params);
		params->nodemask = NODE_TRANSPARENT;
		m_root->Render(trans, params);
	}
}
Пример #2
0
void Model::Render(const matrix4x4f &trans, const RenderData *rd)
{
	//update color parameters (materials are shared by model instances)
	if (m_curPattern) {
		for (MaterialContainer::const_iterator it = m_materials.begin(); it != m_materials.end(); ++it) {
			if ((*it).second->GetDescriptor().usePatterns) {
				(*it).second->texture5 = m_colorMap.GetTexture();
				(*it).second->texture4 = m_curPattern;
			}
		}
	}

	//update decals (materials and geometries are shared)
	for (unsigned int i=0; i < MAX_DECAL_MATERIALS; i++)
		if (m_decalMaterials[i])
			m_decalMaterials[i]->texture0 = m_curDecals[i];

	//Override renderdata if this model is called from ModelNode
	RenderData params = (rd != 0) ? (*rd) : m_renderData;

	m_renderer->SetTransform(trans);
	//using the entire model bounding radius for all nodes at the moment.
	//BR could also be a property of Node.
	params.boundingRadius = GetDrawClipRadius();

	//render in two passes, if this is the top-level model
	if (m_debugFlags & DEBUG_WIREFRAME)
		m_renderer->SetWireFrameMode(true);

	if (params.nodemask & MASK_IGNORE) {
		m_root->Render(trans, &params);
	} else {
		params.nodemask = NODE_SOLID;
		m_root->Render(trans, &params);
		params.nodemask = NODE_TRANSPARENT;
		m_root->Render(trans, &params);
	}

	if (!m_debugFlags)
		return;

	if (m_debugFlags & DEBUG_WIREFRAME)
		m_renderer->SetWireFrameMode(false);

	if (m_debugFlags & DEBUG_BBOX) {
		m_renderer->SetTransform(trans);
		DrawAabb();
	}

	if (m_debugFlags & DEBUG_COLLMESH) {
		m_renderer->SetTransform(trans);
		DrawCollisionMesh();
	}

	if (m_debugFlags & DEBUG_TAGS) {
		m_renderer->SetTransform(trans);
		DrawAxisIndicators(m_tagPoints);
	}

	if (m_debugFlags & DEBUG_DOCKING) {
		m_renderer->SetTransform(trans);
		DrawAxisIndicators(m_dockingPoints);
	}
}