Exemplo n.º 1
0
	void SubMesh::Create(MeshPtr pMesh, int indexOffset, int indexCount, int vertexOffset, int vertexCount, int vertexStride, int matIndex, int primCount, PRIMITIVE_TYPE primType, const VertexFormat& vf, G_FORMAT indexFormat)
	{
		m_pMesh						= pMesh;

		m_indexOffset				= indexOffset;
		m_vertexOffset				= vertexOffset;

		m_vertexCount				= vertexCount;
		m_indexCount				= indexCount;
		m_primitiveCount			= primCount;
		m_materialIndex				= matIndex;
		m_vertexStride				= vertexStride;

		m_indexed					= pMesh->GetIndexData() == NULL ? false : true;
		m_primitiveType				= primType;

		m_vertexFormat				= vf;
		m_indexFormat				= indexFormat;
	}
Exemplo n.º 2
0
	void MeshRenderer::Reset(MeshDataPtr pMD)
	{
		if(pMD == NULL)
		{
			return;
		}

		MeshPtr pMesh = pMD->GetMesh();
		if(pMesh == nullptr)
		{
			return;
		}

		if(m_pIndexBuffer)
		{
			m_pIndexBuffer->Release();
			m_pIndexBuffer.reset();
		}
		if(m_pVertexBuffer)
		{
			m_pVertexBuffer->Release();
			m_pVertexBuffer.reset();
		}

		m_Subsets.clear();


		if(pMesh->GetIndexData() != nullptr)
		{
			m_pIndexBuffer = m_pRS->GetSysGraphics()->CreateBuffer(BT_INDEX_BUFFER, pMesh->GetIndexDataBytes(), pMesh->GetIndexData(), false);
		}
		m_pVertexBuffer = m_pRS->GetSysGraphics()->CreateBuffer(BT_VERTEX_BUFFER, pMesh->GetVertexDataBytes(), pMesh->GetVertexData(), false);

		for(int i = 0; i < pMesh->GetSubMeshCount(); ++i)
		{
			SubMeshPtr pSub = pMesh->GetSubMesh(i);

			SubMeshRenderDataPtr pSR = m_pManager->GetAllocator()->AllocObject<SubMeshRenderData, GameObjectPtr>(GetGameObject());
			pSR->Create(pSub, m_pIndexBuffer, m_pVertexBuffer);
			m_Subsets.push_back(pSR);
		}
	}