示例#1
0
void CD3DObjectResource::PickResource(CUSOResourceManager * pResourceManager,UINT Param)
{
	for(int i=0;i<GetSubMeshCount();i++)
	{
		CD3DSubMesh * pSubMesh=GetSubMesh(i);
		if(pSubMesh)
		{
			pSubMesh->PickResource(pResourceManager,Param);
		}
	}	
}
示例#2
0
bool CD3DWOWM2ItemModel::BuildModel()
{
	D3DLOCK_FOR_OBJECT_MODIFY

	CBLZWOWDatabase::BLZ_DB_ITEM_DISPLAY_INFO * pDisplayInfo=CBLZWOWDatabase::GetInstance()->GetItemDisplayInfo(m_ItemDisplayID);
	if(pDisplayInfo)
	{
		CEasyString TexturePath=GetPathDirectory(m_pModelResource->GetName());
		if(m_ItemHandType==IHT_LEFT)
			TexturePath+=pDisplayInfo->LeftModelTexture+".blp";
		else
			TexturePath+=pDisplayInfo->RightModelTexture+".blp";
		CD3DTexture * pTexture=GetDevice()->GetTextureManager()->LoadTexture(TexturePath);
		if(pTexture)
		{
			for(int j=0;j<GetSubMeshCount();j++)
			{
				CD3DSubMesh  * pSubMesh=GetSubMesh(j);
				if(pSubMesh)
				{
					for(UINT i=0;i<pSubMesh->GetMaterial().GetTextureLayerCount();i++)
					{
						UINT TextureType=(pSubMesh->GetMaterial().GetTextureProperty(i)&CD3DWOWM2ModelResource::TF_SKIN_TEXTURE_TYPE_MASK)>>
							CD3DWOWM2ModelResource::TF_SKIN_TEXTURE_TYPE_SHIFT;
						if(TextureType!=D3D_TEXTURE_TYPE_DIRECT)
						{
							pSubMesh->GetMaterial().SetTexture(i,pTexture);
							pTexture->AddUseRef();
						}
					}

				}
			}
			SAFE_RELEASE(pTexture);			
		}
	}
	
	return true;
}
示例#3
0
	void PrelightPipeline::DrawRenderable(const std::shared_ptr<Pass> &pass, const std::shared_ptr<SceneNode> &node)
	{
		auto render = node->GetComponent<MeshRender>();
		auto mesh = render->GetMesh();

		unsigned int subMeshCount = mesh->GetSubMeshCount();
		if (subMeshCount > 0)
		{
			// with subMesh
			for (unsigned int i = 0; i < subMeshCount; i++)
			{
				if (auto subMesh = mesh->GetSubMeshAt(i))
				{
					auto material = render->GetMaterial(i);
					auto shader = material->GetShaderForPass(pass->GetRenderIndex());

					if (shader == nullptr)
						shader = pass->GetShader(material->GetShaderType());

					if (shader == nullptr)
					{
						LOGW << "Failed to draw " << node->GetName() << ", data incomplete!";
						return;
					}

					shader->Bind();
					shader->BindCamera(m_CurrentCamera);
					shader->BindMatrix(Matrix4::WORLD_MATRIX, node->GetWorldMatrix());

					shader->BindSubMesh(mesh, i);
					shader->BindMaterial(material);

					for (unsigned int i = 0; i < pass->GetTextureCount(true); i++)
					{
						auto ptr = pass->GetTextureAt(i, true);
						shader->BindTexture(ptr->GetName(), ptr);
					}

					glDrawElements(GL_TRIANGLES, subMesh->Indices.Data.size(), GL_UNSIGNED_INT, 0);

					shader->UnBind();

					m_DrawCall++;
				}
			}
		}
		else
		{
			// no subMesh
			auto material = render->GetMaterial();
			auto shader = material->GetShaderForPass(pass->GetRenderIndex());

			if (shader == nullptr)
				shader = pass->GetShader(material->GetShaderType());

			if (shader == nullptr)
			{
				LOGW << "Failed to draw " << node->GetName() << ", data incomplete!";
				return;
			}

			shader->Bind();
			shader->BindCamera(m_CurrentCamera);
			shader->BindMatrix(Matrix4::WORLD_MATRIX, node->GetWorldMatrix());

			shader->BindMesh(mesh);
			shader->BindMaterial(material);

			for (unsigned int i = 0; i < pass->GetTextureCount(true); i++)
			{
				auto ptr = pass->GetTextureAt(i, true);
				shader->BindTexture(ptr->GetName(), ptr);
			}

			glDrawElements(GL_TRIANGLES, mesh->Indices.Data.size(), GL_UNSIGNED_INT, 0);

			shader->UnBind();

			m_DrawCall++;
		}
	}