Horde3D
http://www.horde3d.org/forums/

Realizing an ogg/theora-extension
http://www.horde3d.org/forums/viewtopic.php?f=2&t=268
Page 2 of 2

Author:  craigomatic [ 25.05.2010, 02:50 ]
Post subject:  Re:

Volker wrote:
You can use the Horde3DUtils::createTGAImage and Horde3D::updateResourceData methods for that. We have done something similar here at our lab using DirectShow.

You first create a Texture Resource with the dimensions of your video source

Following code is untested:
Code:
char* img = 0;
unsigned int imgsize = 0;
unsigned char* tgaImgData = new unsigned char[videoBufferSize];
Horde3DUtils::createTGAImage(tgaImgData, width, height, depth, &img, &imgsize);
delete[] tgaImgData;
textureID = Horde3D::addResource(ResourceTypes::Texture2D, textureName, ResourceFlags::NoCompression);
Horde3D::loadResource(textureID, (char*) img, imgsize))
Horde3DUtils::freeMem(&img);   


Later you will update the texture data using updateResourceData
Code:
Horde3D::updateResourceData(textureID, ResourceData::Tex2DPixelData, imgData, size);


Since the texture data is not really a scene node I'm not sure if it would make sense to realize something like that as a SceneNode extension


Sorry to reopen an older thread, but I've been trying to get this working (DirectShow) with SourceForge r242 and am not having much luck. I seem to end up with nothing more than a black texture and the sound of my video playing in the background.

Here's what I'm doing:

1. load video
2. create tga with video dimensions, an empty bytearray and 32bit depth
3. create new material with albedo which points to the created tga
4. assign material to my mesh node
5. copy bytes from the sample grabber to my byte array:

Code:
for (int y = 0, y2 = _VideoHeight - 1; y < _VideoHeight; y++, y2--)
        {
            for (int x = 0; x < _VideoWidth; x++)
            {
                samplePosRGBA = (((y2 * _VideoWidth) + x) * 4);
                samplePosRGB24 = ((y * _VideoWidth) + x) * 3;
                _VideoFrameBytes[samplePosRGBA + 0] = _BGRData[samplePosRGB24 + 0];
                _VideoFrameBytes[samplePosRGBA + 1] = _BGRData[samplePosRGB24 + 1];
                _VideoFrameBytes[samplePosRGBA + 2] = _BGRData[samplePosRGB24 + 2];
                _VideoFrameBytes[samplePosRGBA + 3] = _AlphaTransparency;                       
            }
        }


6. write my bytes using a new method I introduced (I considered there may have been issue with the .NET wrapper) which looks like this:

Code:
DLLEXP void *h3dWriteBytes( ResHandle res, int elem, int elemIdx, int stream, const char *data, int size)
{
   Resource *resObj = Modules::resMan().resolveResHandle( res );
   VALIDATE_RES( resObj, "h3dMapResStream", 0x0 );

   unsigned char* mappedStream = (unsigned char *)resObj->mapStream( elem, elemIdx, stream, false, true );
   
   for(int i = 0; i < size; i++)
   {
      mappedStream[i] = data[i];
   }

   resObj->unmapStream();
}


I've tried putting hardcodes into the _VideoFrameBytes array but seem unable to get the black to change to any other colour, which to me indicates something important is missing or being done incorrectly.

Any ideas?

Page 2 of 2 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/