I am trying to assign my own generated texture in C++ in an object in the scene in Unreal e.g. a cube.
The code with which I generate the texture is outlined below. I am using data from a Kinect device to create a color texture - just like a normal camera.
// @BeginPlay
ColorTexture = UTexture2D::CreateTransient(1920, 1080);
ColorTexture->UpdateResource();
ColorTexture->SRGB = 1;
ColorQuad = new RGBQUAD[1920 * 1080];
// @Tick
pColorBuffer = ColorQuad;
nColorBufferSize = 1920 * 1080 * sizeof(RGBQUAD);
HRESULT hr = ColorFrameReader->AcquireLatestFrame(&ColorFrame); // ColorFrameReader and ColorFrame are from Kinect library.
hr = ColorFrame->CopyConvertedFrameDataToArray(nColorBufferSize, reinterpret_cast<BYTE*>(pColorBuffer), ColorImageFormat_Bgra);
const size_t SizeColorQuad = 1920 * 1080 * sizeof(RGBQUAD);
uint8* Destination = (uint8*)ColorTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(Destination, (uint8*)ColorQuad, SizeColorQuad);
ColorTexture->PlatformData->Mips[0].BulkData.Unlock();
ColorTexture->UpdateResource();
These are the objects in my scene with which I am experimenting:
https://i.imgur.com/q9IUd5p.png
How can I assign my own dynamic generated texture in C++ to an object in the scene?