void HardwareMeshCreationStrategy::setSubMeshGeometryImpl(submeshptr_type submesh, Vertex *verts, int numVertices, Face *faces, int numFaces)
	{
		HardwareBufferManager *hwm = HardwareBufferManager::getManager();

		HardwareBuffer *vertexBuffer = hwm->createBuffer(sizeof(Vertex), numVertices);
		void* vertData = vertexBuffer->lock();
		memcpy(vertData, verts, sizeof(Vertex) * numVertices);
		vertexBuffer->unlock();
		
		HardwareBuffer *faceBuffer = hwm->createBuffer(sizeof(Face), numFaces);
		void* faceData = faceBuffer->lock();
		memcpy(faceData, faces, sizeof(Face) * numFaces);
		faceBuffer->unlock();

		submesh->setGeoBuffers(vertexBuffer, faceBuffer);
	}
	void HardwareMeshCreationStrategy::setSubMeshNormalsImpl(submeshptr_type submesh, Vertex *normals, int numNormals)
	{
		HardwareBufferManager *hwm = HardwareBufferManager::getManager();

		HardwareBuffer *normBuffer = hwm->createBuffer(sizeof(Vertex), numNormals);
		void* normData = normBuffer->lock();
		memcpy(normData, normals, sizeof(Vertex) * numNormals);
		normBuffer->unlock();
		submesh->setNormalBuffer(normBuffer);
	}
	void HardwareMeshCreationStrategy::setSubMeshUVsImpl(submeshptr_type submesh, TexCoord *coords, int numTXCoords)
	{
		HardwareBufferManager *hwm = HardwareBufferManager::getManager();

		HardwareBuffer *txBuffer = hwm->createBuffer(sizeof(TexCoord), numTXCoords);
		void* txData = txBuffer->lock();
		memcpy(txData, coords, sizeof(TexCoord) * numTXCoords);
/*
		for (int i = 0; i < numTXCoords; ++i)
		{
			TexCoord* cur = &((TexCoord*)txData)[i];
			std::cout << "txc " << cur->x << " " << cur->y << std::endl;
		}*/
		txBuffer->unlock();

		submesh->setUVBuffer(txBuffer);
	}
Exemplo n.º 4
0
void HardwareBuffer::copyData(HardwareBuffer& srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, BOOL discardWholeBuffer /* = FALSE */)
{
    const void* srcData = srcBuffer.lock(srcOffset, length, HBL_READ_ONLY);
    this->writeData(dstOffset, length, srcData, discardWholeBuffer);
    srcBuffer.unlock();
}